Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-otters-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/wbtc-address-set-adapter': major
---

Update wbtc-address-set to use V2 API

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a major need to specify what needs to be done for upgrade

23 changes: 22 additions & 1 deletion .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
2 changes: 1 addition & 1 deletion packages/sources/wbtc-address-set/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"typescript": "5.8.3"
},
"dependencies": {
"@chainlink/external-adapter-framework": "2.11.6",
"@chainlink/external-adapter-framework": "2.16.0",
"tslib": "2.4.1"
}
}
52 changes: 41 additions & 11 deletions packages/sources/wbtc-address-set/src/transport/addresses.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import { HttpTransport } from '@chainlink/external-adapter-framework/transports'
import { BaseEndpointTypes } from '../endpoint/addresses'

const PAGE_SIZE = 500

interface AddressEntry {
id: string
address: string
balance?: string
type: 'custodial' | 'merchant' | 'deposit'
}

export interface ResponseSchema {
result: {
id: string
address: string
balance?: string
type: 'custodial' | 'merchant' | 'deposit'
verified: boolean
}[]
count: number
data: AddressEntry[]
total: number
pageIndex: number
pageSize: number
}

export type HttpTransportTypes = BaseEndpointTypes & {
Expand All @@ -18,19 +23,44 @@ export type HttpTransportTypes = BaseEndpointTypes & {
ResponseBody: ResponseSchema
}
}

const mapCustodialAddress = (address: AddressEntry) => ({
id: address.id,
address: address.address,
balance: address.balance,
type: address.type,
coin: 'btc',
chainId: 'mainnet',
network: 'bitcoin',
})

export const httpTransport = new HttpTransport<HttpTransportTypes>({
prepareRequests: (params, config) => {
return [
{
params,
request: { baseURL: config.ADDRESSES_ENDPOINT },
request: {
baseURL: config.ADDRESSES_ENDPOINT,
params: {
pageSize: PAGE_SIZE,
pageIndex: 1,
},
},
},
]
},
parseResponse: (params, response) => {
const result = response.data.result
const { data, total } = response.data

if (total > data.length) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we implement pagination?

throw new Error(
`wBTC custodial addresses API returned ${data.length} of ${total} addresses; increase PAGE_SIZE (currently ${PAGE_SIZE}) or add pagination`,
)
}

const result = data
.filter((a) => a.type == 'custodial' && a.balance && Number(a.balance) > 0)
.map((a) => ({ ...a, coin: 'btc', chainId: 'mainnet', network: 'bitcoin' }))
.map(mapCustodialAddress)

return [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ exports[`execute addresses endpoint should return success 1`] = `
"id": "601c5e4b11b1d4001e37091aa2618ee9",
"network": "bitcoin",
"type": "custodial",
"verified": false,
},
],
},
Expand Down
11 changes: 7 additions & 4 deletions packages/sources/wbtc-address-set/test/integration/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@ export const mockAddressesResponseSuccess = (): nock.Scope =>
})
.persist()
.get('/')
.query({ pageSize: '500', pageIndex: '1' })
.reply(
200,
() => ({
result: [
data: [
{
id: '601c5e4b11b1d4001e37091aa2618ee9',
address: '31h6SJ58NqVrifuyXN5A19ByD6vgyKVHEY',
balance: '123',
type: 'custodial',
verified: false,
chain: 'btc',
},
{
id: '602412a8a8f831001e0395eeeca68779',
address: '31rbKHDMsFpTF9T4u74osP24ZejMJnHukj',
balance: '0',
type: 'custodial',
verified: false,
chain: 'btc',
},
],
count: 1,
total: 2,
pageIndex: 1,
pageSize: 500,
}),
[
'Content-Type',
Expand Down
26 changes: 25 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,30 @@ __metadata:
languageName: node
linkType: hard

"@chainlink/external-adapter-framework@npm:2.16.0":
version: 2.16.0
resolution: "@chainlink/external-adapter-framework@npm:2.16.0"
dependencies:
"@date-fns/tz": "npm:1.5.0"
"@solana/kit": "npm:6.9.0"
ajv: "npm:8.20.0"
axios: "npm:1.16.1"
ethers: "npm:6.16.0"
eventsource: "npm:4.1.0"
fastify: "npm:5.8.5"
ioredis: "npm:5.11.0"
mock-socket: "npm:9.3.1"
pino: "npm:10.3.1"
pino-pretty: "npm:13.1.3"
prom-client: "npm:15.1.3"
redlock: "npm:5.0.0-beta.2"
ws: "npm:8.21.0"
bin:
create-external-adapter: adapter-generator.js
checksum: 10/428328556ef58f80af31ba2a541ae6cbe799155e0052860a05e90ffd66f14461ce8b419da1430c14426a36ab5c797e13ba24f0f5c454a9fbf21ca7ea00f9ed28
languageName: node
linkType: hard

"@chainlink/external-adapter-framework@npm:2.8.0":
version: 2.8.0
resolution: "@chainlink/external-adapter-framework@npm:2.8.0"
Expand Down Expand Up @@ -5746,7 +5770,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@chainlink/wbtc-address-set-adapter@workspace:packages/sources/wbtc-address-set"
dependencies:
"@chainlink/external-adapter-framework": "npm:2.11.6"
"@chainlink/external-adapter-framework": "npm:2.16.0"
"@types/jest": "npm:^29.5.14"
"@types/node": "npm:22.14.1"
nock: "npm:13.5.6"
Expand Down
Loading