Skip to content

Commit

Permalink
Update bedrock API structure (#3588)
Browse files Browse the repository at this point in the history
* Update bedrock API structure

* Comments
  • Loading branch information
mxiao-cll authored Nov 27, 2024
1 parent 1583166 commit c6bcee9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-suits-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/por-address-list-adapter': patch
---

Update bedrock BTC structure
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { BaseEndpointTypes } from '../endpoint/bedrockBTC'
interface ResponseSchema {
btc: {
type: string
bridge_source: string
addr: string
}[]
evm: {
[key: string]: {
chain_id: number
vault: string
tokens: string[]
tokens: [name: string, address: string, decimals: string, value: string][]
}
}
}
Expand Down Expand Up @@ -94,7 +95,7 @@ const getAddresses = (
.flatMap(([_, value]) =>
value.tokens.map((token) => ({
chainId: value.chain_id.toString(),
contractAddress: token,
contractAddress: token[1],
wallet: value.vault,
})),
)
Expand All @@ -117,7 +118,7 @@ const getAddresses = (
}
case 'vault':
return Object.entries(data.evm)
.filter(([_, value]) => value.tokens.includes(VAULT_PLACEHOLDER))
.filter(([_, value]) => value.tokens.map((token) => token[1]).includes(VAULT_PLACEHOLDER))
.map(([key, value]) => ({
address: value.vault,
network: key,
Expand Down
25 changes: 7 additions & 18 deletions packages/sources/por-address-list/test/integration/fixtures-api.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
import nock from 'nock'

interface ResponseSchema {
btc: {
type: string
addr: string
}[]
evm: {
[key: string]: {
chain_id: number
vault: string
tokens: string[]
}
}
}

export const mockBedRockResponseSuccess = (): nock.Scope =>
nock('http://bedrock', {
encodedQueryParams: true,
Expand All @@ -23,19 +9,22 @@ export const mockBedRockResponseSuccess = (): nock.Scope =>
200,
() => ({
btc: [
{ type: 'addr', addr: 'btc_1' },
{ type: 'addr', addr: 'btc_2' },
{ type: 'addr', bridge_source: 'btc', addr: 'btc_1' },
{ type: 'addr', bridge_source: 'btc', addr: 'btc_2' },
],
evm: {
eth: {
chain_id: 1,
vault: 'vault_1',
tokens: ['token_1', '0x0000000000000000000000000000000000000000'],
tokens: [
['BTC', 'token_1', '18', '10'],
['BTC', '0x0000000000000000000000000000000000000000', '18', '10'],
],
},
bsc: {
chain_id: 56,
vault: 'vault_2',
tokens: ['token_2'],
tokens: [['BTC', 'token_2', '18', '10']],
},
},
}),
Expand Down

0 comments on commit c6bcee9

Please sign in to comment.