Skip to content

Commit e5a1b76

Browse files
Fix/DF-20612 por address list solv (#3582)
* DF-20612 fix solv failures on multichain address list * add changeset * review fixes * fix test
1 parent e6e5825 commit e5a1b76

File tree

9 files changed

+80
-10
lines changed

9 files changed

+80
-10
lines changed

.changeset/smooth-wasps-shop.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/por-address-list-adapter': minor
3+
---
4+
5+
Fix solv issues in multichain address list endpoint
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"inputs": [
4+
{ "internalType": "uint256", "name": "startIndex_", "type": "uint256" },
5+
{ "internalType": "uint256", "name": "endIndex_", "type": "uint256" }
6+
],
7+
"name": "getPoRAddressList",
8+
"outputs": [
9+
{
10+
"components": [
11+
{ "internalType": "string", "name": "tokenSymbol", "type": "string" },
12+
{ "internalType": "string", "name": "chain", "type": "string" },
13+
{ "internalType": "uint64", "name": "chainId", "type": "uint64" },
14+
{ "internalType": "address", "name": "tokenAddress", "type": "address" },
15+
{ "internalType": "address", "name": "vaultAddress", "type": "address" }
16+
],
17+
"internalType": "struct IPoRAddressListMulti.TokenVaultInfo[]",
18+
"name": "tokenVaultInfos_",
19+
"type": "tuple[]"
20+
}
21+
],
22+
"stateMutability": "view",
23+
"type": "function"
24+
},
25+
{
26+
"inputs": [],
27+
"name": "getPoRAddressListLength",
28+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
29+
"stateMutability": "view",
30+
"type": "function"
31+
}
32+
]

packages/sources/por-address-list/src/endpoint/multichainAddress.ts

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export const inputParameters = new InputParameters(
1717
type: 'string',
1818
required: true,
1919
},
20+
abiName: {
21+
description: 'Used to select the ABI by name',
22+
type: 'string',
23+
options: ['MultiEVMPoRAddressList', 'PoRAddressListMulti', 'SolvMultiAddressList'],
24+
required: true,
25+
},
2026
type: {
2127
description:
2228
'The type of addresses you are looking for. tokens is for token-balance EA. vault is for eth-balance EA.',
@@ -43,6 +49,7 @@ export const inputParameters = new InputParameters(
4349
{
4450
contractAddress: '0xb7C0817Dd23DE89E4204502dd2C2EF7F57d3A3B8',
4551
contractAddressNetwork: 'BINANCE',
52+
abiName: 'MultiEVMPoRAddressList',
4653
type: 'tokens',
4754
vaultPlaceHolder: '0x0000000000000000000000000000000000000001',
4855
confirmations: 0,

packages/sources/por-address-list/src/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ export const adapter = new PoRAdapter({
88
name: 'POR_ADDRESS_LIST',
99
config,
1010
endpoints: [address, solvBTC, bedrockBTC, multichainAddress],
11+
rateLimiting: {
12+
tiers: {
13+
default: {
14+
rateLimit1s: 1,
15+
},
16+
},
17+
},
1118
})
1219

1320
export const server = (): Promise<ServerInstance | undefined> => expose(adapter)

packages/sources/por-address-list/src/transport/multichainAddress.ts

+23-8
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { SubscriptionTransport } from '@chainlink/external-adapter-framework/tra
22
import { EndpointContext } from '@chainlink/external-adapter-framework/adapter'
33
import { TransportDependencies } from '@chainlink/external-adapter-framework/transports'
44
import { AdapterResponse, sleep } from '@chainlink/external-adapter-framework/util'
5-
import ABI from '../config/PoRAddressListMulti.json'
6-
import PolygonABI from '../config/MultiEVMPoRAddressList.json'
5+
import PoRAddressListMultiABI from '../config/PoRAddressListMulti.json'
6+
import SolvMultiAddressListABI from '../config/SolvMultiAddressList.json'
7+
import MultiEVMPoRAddressListABI from '../config/MultiEVMPoRAddressList.json'
78
import { BaseEndpointTypes, inputParameters } from '../endpoint/multichainAddress'
89
import { ethers } from 'ethers'
910
import { fetchAddressList, addProvider, getProvider } from './utils'
11+
import { AdapterInputError } from '@chainlink/external-adapter-framework/validation/error'
1012

1113
export type AddressTransportTypes = BaseEndpointTypes
1214

@@ -64,16 +66,13 @@ export class AddressTransport extends SubscriptionTransport<AddressTransportType
6466
async _handleRequest(
6567
param: RequestParams,
6668
): Promise<AdapterResponse<AddressTransportTypes['Response']>> {
67-
const { confirmations, contractAddress, contractAddressNetwork, batchSize } = param
69+
const { confirmations, contractAddress, contractAddressNetwork, abiName, batchSize } = param
6870

6971
this.providersMap = addProvider(contractAddressNetwork, this.providersMap)
7072
const provider = getProvider(contractAddressNetwork, this.providersMap)
73+
const abi = this.getAbi(abiName)
7174

72-
const addressManager = new ethers.Contract(
73-
contractAddress,
74-
contractAddressNetwork.toUpperCase() == 'POLYGON' ? PolygonABI : ABI,
75-
provider,
76-
)
75+
const addressManager = new ethers.Contract(contractAddress, abi, provider)
7776
const latestBlockNum = await provider.getBlockNumber()
7877

7978
const providerDataRequestedUnixMs = Date.now()
@@ -108,6 +107,22 @@ export class AddressTransport extends SubscriptionTransport<AddressTransportType
108107
}
109108
}
110109

110+
private getAbi(abiName: string) {
111+
switch (abiName) {
112+
case 'MultiEVMPoRAddressList':
113+
return MultiEVMPoRAddressListABI
114+
case 'PoRAddressListMulti':
115+
return PoRAddressListMultiABI
116+
case 'SolvMultiAddressList':
117+
return SolvMultiAddressListABI
118+
default:
119+
throw new AdapterInputError({
120+
errorResponse: 'abiName not found',
121+
statusCode: 400,
122+
})
123+
}
124+
}
125+
111126
getSubscriptionTtlFromConfig(adapterSettings: BaseEndpointTypes['Settings']): number {
112127
return adapterSettings.WARMUP_SUBSCRIPTION_TTL
113128
}

packages/sources/por-address-list/src/transport/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const getProvider = (
7777
} else {
7878
throw new AdapterInputError({
7979
statusCode: 400,
80-
message: `Missing ${networkName}_RPC_URL or ${networkName}_RPC_URL environment variables`,
80+
message: `Missing ${networkName}_RPC_URL or ${networkName}_RPC_CHAIN_ID environment variables`,
8181
})
8282
}
8383
} else {

packages/sources/por-address-list/test-payload.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
}, {
1919
"endpoint": "multichainAddress",
2020
"contractAddress": "0xb7C0817Dd23DE89E4204502dd2C2EF7F57d3A3B8",
21-
"contractAddressNetwork": "BINANCE"
21+
"contractAddressNetwork": "BINANCE",
22+
"abiName": "PoRAddressListMulti"
2223
}]
2324
}

packages/sources/por-address-list/test/integration/adapter-multichain.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ describe('execute', () => {
9999
endpoint: 'multichainAddress',
100100
contractAddress: 'mock-contract-address',
101101
contractAddressNetwork: 'BSC',
102+
abiName: 'PoRAddressListMulti',
102103
vaultPlaceHolder: 'PLACE_HOLDER',
103104
}
104105
const response = await testAdapter.request(data)
@@ -111,6 +112,7 @@ describe('execute', () => {
111112
endpoint: 'multichainAddress',
112113
contractAddress: 'mock-contract-address',
113114
contractAddressNetwork: 'BSC',
115+
abiName: 'PoRAddressListMulti',
114116
vaultPlaceHolder: 'PLACE_HOLDER',
115117
type: 'vault',
116118
}

packages/sources/por-address-list/test/integration/adapter.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe('execute', () => {
5959
process.env.BEDROCK_UNIBTC_API_ENDPOINT = 'http://bedrock'
6060
process.env.SOLVBTC_API_ENDPOINT = 'http://solv'
6161
process.env.BACKGROUND_EXECUTE_MS = '0'
62+
process.env.RATE_LIMIT_CAPACITY_SECOND = '500'
6263
const mockDate = new Date('2001-01-01T11:11:11.111Z')
6364
spy = jest.spyOn(Date, 'now').mockReturnValue(mockDate.getTime())
6465

0 commit comments

Comments
 (0)