Skip to content

Commit 265a963

Browse files
committed
Lombard PoR address
1 parent 3f3d59c commit 265a963

File tree

9 files changed

+463
-93
lines changed

9 files changed

+463
-93
lines changed

.changeset/bright-shirts-love.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+
Add Lombard PoR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
[
2+
{ "inputs": [], "name": "AccessControlBadConfirmation", "type": "error" },
3+
{
4+
"inputs": [
5+
{ "internalType": "address", "name": "account", "type": "address" },
6+
{ "internalType": "bytes32", "name": "neededRole", "type": "bytes32" }
7+
],
8+
"name": "AccessControlUnauthorizedAccount",
9+
"type": "error"
10+
},
11+
{
12+
"inputs": [{ "internalType": "string", "name": "addressStr", "type": "string" }],
13+
"name": "AddressAlreadyExists",
14+
"type": "error"
15+
},
16+
{
17+
"inputs": [{ "internalType": "string", "name": "addressStr", "type": "string" }],
18+
"name": "AddressDoesNotExist",
19+
"type": "error"
20+
},
21+
{ "inputs": [], "name": "ArrayLengthMismatch", "type": "error" },
22+
{ "inputs": [], "name": "InvalidInitialization", "type": "error" },
23+
{
24+
"inputs": [
25+
{ "internalType": "string", "name": "addressStr", "type": "string" },
26+
{ "internalType": "string", "name": "messageOrPath", "type": "string" },
27+
{ "internalType": "bytes", "name": "signature", "type": "bytes" }
28+
],
29+
"name": "InvalidMessageSignature",
30+
"type": "error"
31+
},
32+
{ "inputs": [], "name": "InvalidRootPubkey", "type": "error" },
33+
{
34+
"inputs": [{ "internalType": "bytes32", "name": "id", "type": "bytes32" }],
35+
"name": "InvalidRootPubkeyId",
36+
"type": "error"
37+
},
38+
{ "inputs": [], "name": "NotInitializing", "type": "error" },
39+
{
40+
"inputs": [{ "internalType": "bytes", "name": "pubkey", "type": "bytes" }],
41+
"name": "RootPubkeyAlreadyExists",
42+
"type": "error"
43+
},
44+
{ "inputs": [], "name": "RootPubkeyCannotBeDeleted", "type": "error" },
45+
{
46+
"inputs": [{ "internalType": "bytes", "name": "pubkey", "type": "bytes" }],
47+
"name": "RootPubkeyDoesNotExist",
48+
"type": "error"
49+
},
50+
{
51+
"anonymous": false,
52+
"inputs": [{ "indexed": false, "internalType": "uint64", "name": "version", "type": "uint64" }],
53+
"name": "Initialized",
54+
"type": "event"
55+
},
56+
{
57+
"anonymous": false,
58+
"inputs": [
59+
{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" },
60+
{
61+
"indexed": true,
62+
"internalType": "bytes32",
63+
"name": "previousAdminRole",
64+
"type": "bytes32"
65+
},
66+
{ "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" }
67+
],
68+
"name": "RoleAdminChanged",
69+
"type": "event"
70+
},
71+
{
72+
"anonymous": false,
73+
"inputs": [
74+
{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" },
75+
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" },
76+
{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }
77+
],
78+
"name": "RoleGranted",
79+
"type": "event"
80+
},
81+
{
82+
"anonymous": false,
83+
"inputs": [
84+
{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" },
85+
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" },
86+
{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }
87+
],
88+
"name": "RoleRevoked",
89+
"type": "event"
90+
},
91+
{
92+
"inputs": [],
93+
"name": "DEFAULT_ADMIN_ROLE",
94+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
95+
"stateMutability": "view",
96+
"type": "function"
97+
},
98+
{
99+
"inputs": [],
100+
"name": "OPERATOR_ROLE",
101+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
102+
"stateMutability": "view",
103+
"type": "function"
104+
},
105+
{
106+
"inputs": [
107+
{ "internalType": "string[]", "name": "_addresses", "type": "string[]" },
108+
{ "internalType": "bytes32[]", "name": "_rootPkIds", "type": "bytes32[]" },
109+
{ "internalType": "string[]", "name": "_messagesOrDerivationData", "type": "string[]" },
110+
{ "internalType": "bytes[]", "name": "_signatures", "type": "bytes[]" }
111+
],
112+
"name": "addAddresses",
113+
"outputs": [],
114+
"stateMutability": "nonpayable",
115+
"type": "function"
116+
},
117+
{
118+
"inputs": [{ "internalType": "bytes", "name": "_pubkey", "type": "bytes" }],
119+
"name": "addRootPubkey",
120+
"outputs": [],
121+
"stateMutability": "nonpayable",
122+
"type": "function"
123+
},
124+
{
125+
"inputs": [{ "internalType": "string[]", "name": "_addresses", "type": "string[]" }],
126+
"name": "deleteAddresses",
127+
"outputs": [],
128+
"stateMutability": "nonpayable",
129+
"type": "function"
130+
},
131+
{
132+
"inputs": [{ "internalType": "bytes", "name": "_pubkey", "type": "bytes" }],
133+
"name": "deleteRootPubkey",
134+
"outputs": [],
135+
"stateMutability": "nonpayable",
136+
"type": "function"
137+
},
138+
{
139+
"inputs": [],
140+
"name": "getPoRAddressListLength",
141+
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
142+
"stateMutability": "view",
143+
"type": "function"
144+
},
145+
{
146+
"inputs": [
147+
{ "internalType": "uint256", "name": "_start", "type": "uint256" },
148+
{ "internalType": "uint256", "name": "_end", "type": "uint256" }
149+
],
150+
"name": "getPoRAddressSignatureMessages",
151+
"outputs": [
152+
{ "internalType": "string[]", "name": "", "type": "string[]" },
153+
{ "internalType": "bytes32[]", "name": "", "type": "bytes32[]" },
154+
{ "internalType": "string[]", "name": "", "type": "string[]" },
155+
{ "internalType": "bytes[]", "name": "", "type": "bytes[]" }
156+
],
157+
"stateMutability": "view",
158+
"type": "function"
159+
},
160+
{
161+
"inputs": [{ "internalType": "string[]", "name": "_addresses", "type": "string[]" }],
162+
"name": "getPoRSignatureMessages",
163+
"outputs": [
164+
{ "internalType": "bytes32[]", "name": "", "type": "bytes32[]" },
165+
{ "internalType": "string[]", "name": "", "type": "string[]" },
166+
{ "internalType": "bytes[]", "name": "", "type": "bytes[]" }
167+
],
168+
"stateMutability": "view",
169+
"type": "function"
170+
},
171+
{
172+
"inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }],
173+
"name": "getRoleAdmin",
174+
"outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
175+
"stateMutability": "view",
176+
"type": "function"
177+
},
178+
{
179+
"inputs": [{ "internalType": "bytes32", "name": "_id", "type": "bytes32" }],
180+
"name": "getRootPubkey",
181+
"outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
182+
"stateMutability": "view",
183+
"type": "function"
184+
},
185+
{
186+
"inputs": [
187+
{ "internalType": "bytes32", "name": "role", "type": "bytes32" },
188+
{ "internalType": "address", "name": "account", "type": "address" }
189+
],
190+
"name": "grantRole",
191+
"outputs": [],
192+
"stateMutability": "nonpayable",
193+
"type": "function"
194+
},
195+
{
196+
"inputs": [
197+
{ "internalType": "bytes32", "name": "role", "type": "bytes32" },
198+
{ "internalType": "address", "name": "account", "type": "address" }
199+
],
200+
"name": "hasRole",
201+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
202+
"stateMutability": "view",
203+
"type": "function"
204+
},
205+
{
206+
"inputs": [{ "internalType": "address", "name": "_owner", "type": "address" }],
207+
"name": "initialize",
208+
"outputs": [],
209+
"stateMutability": "nonpayable",
210+
"type": "function"
211+
},
212+
{
213+
"inputs": [
214+
{ "internalType": "bytes32", "name": "role", "type": "bytes32" },
215+
{ "internalType": "address", "name": "callerConfirmation", "type": "address" }
216+
],
217+
"name": "renounceRole",
218+
"outputs": [],
219+
"stateMutability": "nonpayable",
220+
"type": "function"
221+
},
222+
{
223+
"inputs": [
224+
{ "internalType": "bytes32", "name": "role", "type": "bytes32" },
225+
{ "internalType": "address", "name": "account", "type": "address" }
226+
],
227+
"name": "revokeRole",
228+
"outputs": [],
229+
"stateMutability": "nonpayable",
230+
"type": "function"
231+
},
232+
{
233+
"inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }],
234+
"name": "supportsInterface",
235+
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
236+
"stateMutability": "view",
237+
"type": "function"
238+
},
239+
{
240+
"inputs": [
241+
{ "internalType": "string[]", "name": "_addresses", "type": "string[]" },
242+
{ "internalType": "string[]", "name": "_messages", "type": "string[]" },
243+
{ "internalType": "bytes[]", "name": "_signatures", "type": "bytes[]" }
244+
],
245+
"name": "updateMessageSignature",
246+
"outputs": [],
247+
"stateMutability": "nonpayable",
248+
"type": "function"
249+
}
250+
]

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

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ export const inputParameters = new InputParameters(
4444
type: 'boolean',
4545
description: 'Flag to pass on to the balance adapter to search for limbo validators',
4646
},
47+
abiName: {
48+
type: 'string',
49+
options: ['Lombard', 'Default'],
50+
description: 'The name of ABI used for contractAddress',
51+
default: 'Default',
52+
},
4753
},
4854
[
4955
{
@@ -53,6 +59,7 @@ export const inputParameters = new InputParameters(
5359
batchSize: 10,
5460
network: 'ethereum',
5561
chainId: '1',
62+
abiName: 'Default',
5663
},
5764
],
5865
)

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

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { SubscriptionTransport } from '@chainlink/external-adapter-framework/transports/abstract/subscription'
22
import { EndpointContext } from '@chainlink/external-adapter-framework/adapter'
3-
import { PoRAddress } from '@chainlink/external-adapter-framework/adapter/por'
43
import { TransportDependencies } from '@chainlink/external-adapter-framework/transports'
54
import { AdapterResponse, sleep } from '@chainlink/external-adapter-framework/util'
6-
import { POR_ADDRESS_LIST_ABI } from '../config/abi'
5+
import { POR_ADDRESS_LIST_ABI } from '../config/PorAddressList'
6+
import LOMBARD_POR_ADDRESS_LIST_ABI from '../config/LombardPorAddressList.json'
77
import { BaseEndpointTypes, inputParameters } from '../endpoint/address'
88
import { ethers } from 'ethers'
9-
import { fetchAddressList, addProvider, getProvider } from './utils'
9+
import { addProvider, getProvider } from './providerUtils'
10+
import { DefaultAddressManager, LombardAddressManager, AddressManager } from './addressManager'
1011

1112
export type AddressTransportTypes = BaseEndpointTypes
1213

@@ -61,6 +62,8 @@ export class AddressTransport extends SubscriptionTransport<AddressTransportType
6162
async _handleRequest(
6263
param: RequestParams,
6364
): Promise<AdapterResponse<AddressTransportTypes['Response']>> {
65+
const providerDataRequestedUnixMs = Date.now()
66+
6467
const {
6568
confirmations,
6669
contractAddress,
@@ -69,27 +72,34 @@ export class AddressTransport extends SubscriptionTransport<AddressTransportType
6972
network,
7073
chainId,
7174
searchLimboValidators,
75+
abiName,
7276
} = param
7377

7478
this.providersMap = addProvider(contractAddressNetwork, this.providersMap)
7579
const provider = getProvider(contractAddressNetwork, this.providersMap, this.provider)
7680

77-
const addressManager = new ethers.Contract(contractAddress, POR_ADDRESS_LIST_ABI, provider)
81+
let addressManager: AddressManager<string[] | string[][]>
82+
83+
if (abiName == 'Lombard') {
84+
addressManager = new LombardAddressManager(
85+
contractAddress,
86+
LOMBARD_POR_ADDRESS_LIST_ABI,
87+
provider,
88+
)
89+
} else {
90+
addressManager = new DefaultAddressManager(contractAddress, POR_ADDRESS_LIST_ABI, provider)
91+
}
92+
7893
const latestBlockNum = await provider.getBlockNumber()
7994

80-
const providerDataRequestedUnixMs = Date.now()
81-
const addressList = await fetchAddressList<string>(
82-
addressManager,
95+
const addressList = await addressManager.fetchAddressList(
8396
latestBlockNum,
8497
confirmations,
8598
batchSize,
8699
this.settings.GROUP_SIZE,
87100
)
88-
const addresses: PoRAddress[] = addressList.map((address) => ({
89-
address,
90-
network,
91-
chainId,
92-
}))
101+
102+
const addresses = addressManager.processPoRAddressList(addressList, network, chainId)
93103

94104
return {
95105
data: {

0 commit comments

Comments
 (0)