Skip to content

Commit

Permalink
Fix bedrock (#3583)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll authored Nov 25, 2024
1 parent 2bf139b commit c033089
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-parents-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/por-address-list-adapter': patch
---

Fix bedrock address logic
34 changes: 26 additions & 8 deletions packages/sources/por-address-list/src/transport/bedrockUniBTC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,32 @@ const getAddresses = (
chainId: 'mainnet',
}))
.sort()
case 'tokens':
return Object.entries(data.evm)
.map(([_, value]) => ({
chainId: value.chain_id.toString(),
contractAddress: value.vault,
wallets: value.tokens.filter((t) => t != VAULT_PLACEHOLDER).sort(),
}))
.sort()
case 'tokens': {
const list = Object.entries(data.evm)
.flatMap(([_, value]) =>
value.tokens.map((token) => ({
chainId: value.chain_id.toString(),
contractAddress: token,
wallet: value.vault,
})),
)
.filter((item) => item.contractAddress != VAULT_PLACEHOLDER)

const walletsByChain = Map.groupBy(list, (item) => item.chainId + item.contractAddress)

return Array.from(
new Map(
Array.from(walletsByChain, ([k, v]) => [
k,
{
chainId: v[0].chainId,
contractAddress: v[0].contractAddress,
wallets: v.map((v) => v.wallet).sort(),
},
]),
).values(),
).sort()
}
case 'vault':
return Object.entries(data.evm)
.filter(([_, value]) => value.tokens.includes(VAULT_PLACEHOLDER))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ exports[`execute apiAddress endpoint bedrock tokens should return success 1`] =
"result": [
{
"chainId": "1",
"contractAddress": "vault_1",
"contractAddress": "token_1",
"wallets": [
"token_1",
"vault_1",
],
},
{
"chainId": "56",
"contractAddress": "vault_2",
"contractAddress": "token_2",
"wallets": [
"token_2",
"vault_2",
],
},
],
Expand Down

0 comments on commit c033089

Please sign in to comment.