@raac/rpc 2.0.0-beta.0 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RPCLibrary.js +3 -0
- package/dist/configs/chains/1.json +3 -0
- package/dist/configs/chains/11155111.json +4 -0
- package/dist/configs/chains/17000.json +4 -0
- package/dist/configs/chains/18453.json +4 -0
- package/dist/configs/chains/8453.json +4 -0
- package/dist/configs/registry/1.json +1 -0
- package/dist/configs/registry/11155111.json +1 -0
- package/dist/configs/registry/17000.json +1 -0
- package/dist/configs/registry/18453.json +1 -0
- package/dist/configs/registry/8453.json +1 -0
- package/dist/configs/registry/index.js +24 -0
- package/dist/contracts/findContract.js +25 -10
- package/dist/contracts/resolveName.js +128 -0
- package/dist/types/RPCLibrary.d.ts +3 -0
- package/dist/types/configs/chains/index.d.ts +6 -0
- package/dist/types/configs/index.d.ts +3 -0
- package/dist/types/configs/registry/index.d.ts +13 -0
- package/dist/types/contracts/findContract.d.ts +3 -1
- package/dist/types/contracts/resolveName.d.ts +42 -0
- package/dist/types/utils/contracts.d.ts +6 -0
- package/package.json +1 -1
package/dist/RPCLibrary.js
CHANGED
|
@@ -98,6 +98,7 @@ const getContractAddress_1 = __importDefault(require("./contracts/getContractAdd
|
|
|
98
98
|
const getContract_1 = __importDefault(require("./contracts/getContract"));
|
|
99
99
|
const findContract_1 = require("./contracts/findContract");
|
|
100
100
|
const decodeCall_1 = require("./contracts/decodeCall");
|
|
101
|
+
const resolveName_1 = require("./contracts/resolveName");
|
|
101
102
|
// House Prices
|
|
102
103
|
const getLatestPrice_1 = __importDefault(require("./contracts/housePrices/getLatestPrice"));
|
|
103
104
|
const setOracle_1 = __importDefault(require("./contracts/housePrices/setOracle"));
|
|
@@ -457,6 +458,8 @@ class RPCLibrary {
|
|
|
457
458
|
getContract: getContract_1.default,
|
|
458
459
|
findContract: findContract_1.findContract,
|
|
459
460
|
decodeCall: decodeCall_1.decodeCall,
|
|
461
|
+
resolveName: resolveName_1.resolveName,
|
|
462
|
+
resolveNames: resolveName_1.resolveNames,
|
|
460
463
|
feeCollector: {
|
|
461
464
|
claimRewardFromPool: claimRewardFromPool_1.default,
|
|
462
465
|
},
|
|
@@ -224,12 +224,14 @@
|
|
|
224
224
|
"raacnftadapter": {
|
|
225
225
|
"id": "raacnftadapter",
|
|
226
226
|
"name": "RAAC NFT Adapter",
|
|
227
|
+
"label": "Lending Pool",
|
|
227
228
|
"contract": "0xd8Cb90b0A5b288F5f0c9a519Ae4B1B47D5E69353",
|
|
228
229
|
"type": "ERC721"
|
|
229
230
|
},
|
|
230
231
|
"rwaindextokenadapter": {
|
|
231
232
|
"id": "rwaindextokenadapter",
|
|
232
233
|
"name": "RWA Index Token",
|
|
234
|
+
"label": "Lending Pool",
|
|
233
235
|
"contract": "0x216433c8408A349B4b7342d60F948d89317E3366",
|
|
234
236
|
"type": "ERC20"
|
|
235
237
|
}
|
|
@@ -238,6 +240,7 @@
|
|
|
238
240
|
"raacnftadapter": {
|
|
239
241
|
"id": "raacnftadapter",
|
|
240
242
|
"name": "RAAC NFT Adapter",
|
|
243
|
+
"label": "RWA Vault",
|
|
241
244
|
"contract": "0xB1b35C62B99a450c474e9dAd75fA121d3Daa1d34",
|
|
242
245
|
"type": "ERC721"
|
|
243
246
|
}
|
|
@@ -276,12 +276,14 @@
|
|
|
276
276
|
"raacnftadapter": {
|
|
277
277
|
"id": "raacnftadapter",
|
|
278
278
|
"name": "RAAC NFT Adapter",
|
|
279
|
+
"label": "Lending Pool",
|
|
279
280
|
"contract": "0x0000000000000000000000000000000000000000",
|
|
280
281
|
"type": "ERC721"
|
|
281
282
|
},
|
|
282
283
|
"rwaindextokenadapter": {
|
|
283
284
|
"id": "rwaindextokenadapter",
|
|
284
285
|
"name": "RWA Index Token",
|
|
286
|
+
"label": "Lending Pool",
|
|
285
287
|
"contract": "0xeBab0C5152C406F74E76cB01f4eA9b57BdFad184",
|
|
286
288
|
"type": "ERC20"
|
|
287
289
|
}
|
|
@@ -290,12 +292,14 @@
|
|
|
290
292
|
"raacnftadapter": {
|
|
291
293
|
"id": "raacnftadapter",
|
|
292
294
|
"name": "RAAC NFT Adapter",
|
|
295
|
+
"label": "RWA Vault",
|
|
293
296
|
"contract": "0xd545a0a87571122f07F2B2367b5257DC8aa34640",
|
|
294
297
|
"type": "ERC721"
|
|
295
298
|
},
|
|
296
299
|
"crvusdadapter": {
|
|
297
300
|
"id": "crvusdadapter",
|
|
298
301
|
"name": "CRVUSD Adapter",
|
|
302
|
+
"label": "RWA Vault",
|
|
299
303
|
"contract": "0x0000000000000000000000000000000000000000",
|
|
300
304
|
"type": "ERC20"
|
|
301
305
|
}
|
|
@@ -229,12 +229,14 @@
|
|
|
229
229
|
"raacnftadapter": {
|
|
230
230
|
"id": "raacnftadapter",
|
|
231
231
|
"name": "RAAC NFT Adapter",
|
|
232
|
+
"label": "Lending Pool",
|
|
232
233
|
"contract": "",
|
|
233
234
|
"type": "ERC721"
|
|
234
235
|
},
|
|
235
236
|
"rwaindextokenadapter": {
|
|
236
237
|
"id": "rwaindextokenadapter",
|
|
237
238
|
"name": "RWA Index Token",
|
|
239
|
+
"label": "Lending Pool",
|
|
238
240
|
"contract": "",
|
|
239
241
|
"type": "ERC20"
|
|
240
242
|
}
|
|
@@ -243,12 +245,14 @@
|
|
|
243
245
|
"raacnftadapter": {
|
|
244
246
|
"id": "raacnftadapter",
|
|
245
247
|
"name": "RAAC NFT Adapter",
|
|
248
|
+
"label": "RWA Vault",
|
|
246
249
|
"contract": "",
|
|
247
250
|
"type": "ERC721"
|
|
248
251
|
},
|
|
249
252
|
"crvusdadapter": {
|
|
250
253
|
"id": "crvusdadapter",
|
|
251
254
|
"name": "CRVUSD",
|
|
255
|
+
"label": "RWA Vault",
|
|
252
256
|
"contract": "",
|
|
253
257
|
"type": "ERC20"
|
|
254
258
|
}
|
|
@@ -229,12 +229,14 @@
|
|
|
229
229
|
"raacnftadapter": {
|
|
230
230
|
"id": "raacnftadapter",
|
|
231
231
|
"name": "RAAC NFT Adapter",
|
|
232
|
+
"label": "Lending Pool",
|
|
232
233
|
"contract": "0x998abeb3E57409262aE5b751f60747921B33613E",
|
|
233
234
|
"type": "ERC721"
|
|
234
235
|
},
|
|
235
236
|
"rwaindextokenadapter": {
|
|
236
237
|
"id": "rwaindextokenadapter",
|
|
237
238
|
"name": "RWA Index Token",
|
|
239
|
+
"label": "Lending Pool",
|
|
238
240
|
"contract": "0x95401dc811bb5740090279Ba06cfA8fcF6113778",
|
|
239
241
|
"type": "ERC20"
|
|
240
242
|
}
|
|
@@ -243,12 +245,14 @@
|
|
|
243
245
|
"raacnftadapter": {
|
|
244
246
|
"id": "raacnftadapter",
|
|
245
247
|
"name": "RAAC NFT Adapter",
|
|
248
|
+
"label": "RWA Vault",
|
|
246
249
|
"contract": "0x99bbA657f2BbC93c02D617f8bA121cB8Fc104Acf",
|
|
247
250
|
"type": "ERC721"
|
|
248
251
|
},
|
|
249
252
|
"crvusdadapter": {
|
|
250
253
|
"id": "crvusdadapter",
|
|
251
254
|
"name": "CRVUSD Adapter",
|
|
255
|
+
"label": "RWA Vault",
|
|
252
256
|
"contract": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690",
|
|
253
257
|
"type": "ERC20"
|
|
254
258
|
}
|
|
@@ -325,12 +325,14 @@
|
|
|
325
325
|
"raacnftadapter": {
|
|
326
326
|
"id": "raacnftadapter",
|
|
327
327
|
"name": "RAAC NFT Adapter",
|
|
328
|
+
"label": "Lending Pool",
|
|
328
329
|
"contract": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F",
|
|
329
330
|
"type": "ERC721"
|
|
330
331
|
},
|
|
331
332
|
"rwaindextokenadapter": {
|
|
332
333
|
"id": "rwaindextokenadapter",
|
|
333
334
|
"name": "RWA Index Token",
|
|
335
|
+
"label": "Lending Pool",
|
|
334
336
|
"contract": "0x4A679253410272dd5232B3Ff7cF5dbB88f295319",
|
|
335
337
|
"type": "ERC20"
|
|
336
338
|
}
|
|
@@ -339,12 +341,14 @@
|
|
|
339
341
|
"raacnftadapter": {
|
|
340
342
|
"id": "raacnftadapter",
|
|
341
343
|
"name": "RAAC NFT Adapter",
|
|
344
|
+
"label": "RWA Vault",
|
|
342
345
|
"contract": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44",
|
|
343
346
|
"type": "ERC721"
|
|
344
347
|
},
|
|
345
348
|
"crvusdadapter": {
|
|
346
349
|
"id": "crvusdadapter",
|
|
347
350
|
"name": "CRVUSD Adapter",
|
|
351
|
+
"label": "RWA Vault",
|
|
348
352
|
"contract": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
|
|
349
353
|
"type": "ERC20"
|
|
350
354
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const _1_json_1 = __importDefault(require("./1.json"));
|
|
8
|
+
const _8453_json_1 = __importDefault(require("./8453.json"));
|
|
9
|
+
const _17000_json_1 = __importDefault(require("./17000.json"));
|
|
10
|
+
const _11155111_json_1 = __importDefault(require("./11155111.json"));
|
|
11
|
+
const _18453_json_1 = __importDefault(require("./18453.json"));
|
|
12
|
+
/**
|
|
13
|
+
* Curated, off-chain-known addresses per chain (wallets, external protocols),
|
|
14
|
+
* keyed by checksummed address. Empty until entries are reviewed and added -
|
|
15
|
+
* see resolveName.ts for why this ships empty rather than with guessed data.
|
|
16
|
+
*/
|
|
17
|
+
const registries = {
|
|
18
|
+
1: _1_json_1.default,
|
|
19
|
+
8453: _8453_json_1.default,
|
|
20
|
+
17000: _17000_json_1.default,
|
|
21
|
+
11155111: _11155111_json_1.default,
|
|
22
|
+
18453: _18453_json_1.default,
|
|
23
|
+
};
|
|
24
|
+
exports.default = registries;
|
|
@@ -24,32 +24,48 @@ function listContracts(chainId) {
|
|
|
24
24
|
};
|
|
25
25
|
// gauges: { <system>: { label, gaugeType, controller, distributor, gauges: [{ id, name, contract }] } }
|
|
26
26
|
for (const [key, system] of Object.entries((config.gauges ?? {}))) {
|
|
27
|
-
push({ address: system.controller, id: `${key}.controller`, name: `${system.label} Controller`, section: "gauges", abi: "gaugecontroller" });
|
|
28
|
-
push({ address: system.distributor, id: `${key}.distributor`, name: `${system.label} Distributor`, section: "gauges", abi: "gaugerewardsdistributor" });
|
|
27
|
+
push({ address: system.controller, id: `${key}.controller`, name: `${system.label} Controller`, label: `${system.label} Controller`, section: "gauges", abi: "gaugecontroller" });
|
|
28
|
+
push({ address: system.distributor, id: `${key}.distributor`, name: `${system.label} Distributor`, label: `${system.label} Distributor`, section: "gauges", abi: "gaugerewardsdistributor" });
|
|
29
29
|
for (const gauge of system.gauges ?? []) {
|
|
30
|
-
push({ address: gauge.contract, id: gauge.id, name: gauge.name, section: "gauges", abi: abiKey(system.gaugeType.toLowerCase()) });
|
|
30
|
+
push({ address: gauge.contract, id: gauge.id, name: gauge.name, label: gauge.name, section: "gauges", abi: abiKey(system.gaugeType.toLowerCase()) });
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
for (const section of FLAT_SECTIONS) {
|
|
34
34
|
for (const [key, value] of Object.entries((config[section] ?? {}))) {
|
|
35
|
-
push({ address: value.contract, id: value.id ?? key, name: value.name ?? key, section, abi: abiKey(key.toLowerCase()) });
|
|
35
|
+
push({ address: value.contract, id: value.id ?? key, name: value.name ?? key, label: value.name ?? key, section, abi: abiKey(key.toLowerCase()) });
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
// adapters: { <pool or vault>: { <adapter>: { contract, type: "ERC20" | "ERC721" } } }
|
|
38
|
+
// adapters: { <pool or vault>: { <adapter>: { contract, type: "ERC20" | "ERC721", label } } }
|
|
39
|
+
// `label` names the pool or vault the adapter belongs to - the adapter itself is internal.
|
|
39
40
|
for (const [owner, adapters] of Object.entries((config.adapters ?? {}))) {
|
|
40
41
|
for (const [key, value] of Object.entries(adapters)) {
|
|
41
42
|
const standard = (value.type ?? "").toLowerCase();
|
|
42
43
|
const kind = owner === "lendingpool" ? "assetadapter" : "vaultadapter";
|
|
43
|
-
push({ address: value.contract, id: value.id ?? key, name: value.name ?? key, section: "adapters", abi: abiKey(`${standard}${kind}`) });
|
|
44
|
+
push({ address: value.contract, id: value.id ?? key, name: value.name ?? key, label: value.label ?? value.name ?? key, section: "adapters", abi: abiKey(`${standard}${kind}`) });
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
// proposals: [{ id, label, governance, timelock }]
|
|
47
48
|
for (const instance of (config.proposals ?? [])) {
|
|
48
|
-
push({ address: instance.governance, id: `${instance.id}.governance`, name: `${instance.label} Governance`, section: "proposals", abi: "governance" });
|
|
49
|
-
push({ address: instance.timelock, id: `${instance.id}.timelock`, name: `${instance.label} Timelock`, section: "proposals", abi: "timelockcontroller" });
|
|
49
|
+
push({ address: instance.governance, id: `${instance.id}.governance`, name: `${instance.label} Governance`, label: `${instance.label} Governance`, section: "proposals", abi: "governance" });
|
|
50
|
+
push({ address: instance.timelock, id: `${instance.id}.timelock`, name: `${instance.label} Timelock`, label: `${instance.label} Timelock`, section: "proposals", abi: "timelockcontroller" });
|
|
50
51
|
}
|
|
51
52
|
return found;
|
|
52
53
|
}
|
|
54
|
+
const contractsByAddress = new Map();
|
|
55
|
+
/** Address -> entry index for a chain, built on first use. First match wins, as in `listContracts`. */
|
|
56
|
+
function getContractIndex(chainId) {
|
|
57
|
+
const key = String(chainId);
|
|
58
|
+
let index = contractsByAddress.get(key);
|
|
59
|
+
if (!index) {
|
|
60
|
+
index = {};
|
|
61
|
+
for (const entry of listContracts(chainId)) {
|
|
62
|
+
if (!(entry.address in index))
|
|
63
|
+
index[entry.address] = entry;
|
|
64
|
+
}
|
|
65
|
+
contractsByAddress.set(key, index);
|
|
66
|
+
}
|
|
67
|
+
return index;
|
|
68
|
+
}
|
|
53
69
|
/**
|
|
54
70
|
* Finds a contract by address in the chain config.
|
|
55
71
|
* Reads the chain config only; no RPC call is made.
|
|
@@ -61,8 +77,7 @@ function listContracts(chainId) {
|
|
|
61
77
|
const findContract = (chainId, address) => {
|
|
62
78
|
if (!ethers_1.ethers.isAddress(address))
|
|
63
79
|
return null;
|
|
64
|
-
|
|
65
|
-
return listContracts(chainId).find((c) => c.address === target) ?? null;
|
|
80
|
+
return getContractIndex(chainId)[ethers_1.ethers.getAddress(address)] ?? null;
|
|
66
81
|
};
|
|
67
82
|
exports.findContract = findContract;
|
|
68
83
|
exports.default = exports.findContract;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveName = resolveName;
|
|
7
|
+
exports.resolveNames = resolveNames;
|
|
8
|
+
const ethers_1 = require("ethers");
|
|
9
|
+
const chains_1 = __importDefault(require("../configs/chains"));
|
|
10
|
+
const findContract_1 = require("./findContract");
|
|
11
|
+
const registry_1 = __importDefault(require("../configs/registry"));
|
|
12
|
+
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
13
|
+
const BURN_ADDRESS = "0x000000000000000000000000000000000000dEaD";
|
|
14
|
+
/** Universal, chain-agnostic entries that do not belong in a per-chain registry file. */
|
|
15
|
+
const BUILTIN_REGISTRY = {
|
|
16
|
+
[ZERO_ADDRESS]: { name: "None", kind: "external" },
|
|
17
|
+
[ethers_1.ethers.getAddress(BURN_ADDRESS)]: { name: "Burn", kind: "external" },
|
|
18
|
+
};
|
|
19
|
+
/** address -> { name, expiresAt } | null (a confirmed miss, cached too so a repeat lookup does not re-hit the network). */
|
|
20
|
+
const ensCache = new Map();
|
|
21
|
+
const ENS_TTL_MS = 60 * 60 * 1000;
|
|
22
|
+
function contractInfoToAddressName(info) {
|
|
23
|
+
return {
|
|
24
|
+
address: info.address,
|
|
25
|
+
name: info.label ?? info.name,
|
|
26
|
+
kind: info.section === "gauges" ? "gauge" : "contract",
|
|
27
|
+
source: "config",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function lookupRegistry(chainId, address) {
|
|
31
|
+
const builtin = BUILTIN_REGISTRY[address];
|
|
32
|
+
if (builtin)
|
|
33
|
+
return { address, ...builtin, source: "registry" };
|
|
34
|
+
const registry = registry_1.default[String(chainId)];
|
|
35
|
+
const entry = registry?.[address];
|
|
36
|
+
if (!entry)
|
|
37
|
+
return null;
|
|
38
|
+
return { address, ...entry, source: "registry" };
|
|
39
|
+
}
|
|
40
|
+
async function lookupEns(address, provider) {
|
|
41
|
+
const cached = ensCache.get(address);
|
|
42
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
43
|
+
return cached.name ? { address, name: cached.name, kind: "ens", source: "ens" } : null;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const runner = provider ?? new ethers_1.ethers.JsonRpcProvider(chains_1.default[1].rpcs[0]);
|
|
47
|
+
const ensName = await runner.lookupAddress(address);
|
|
48
|
+
// Forward-verify: an ENS reverse record is set by its owner and can point anywhere,
|
|
49
|
+
// so trust it only once the name's forward resolution points back to this address.
|
|
50
|
+
const verified = ensName && ethers_1.ethers.getAddress((await runner.resolveName(ensName)) ?? "") === address;
|
|
51
|
+
const name = verified ? ensName : null;
|
|
52
|
+
ensCache.set(address, { name, expiresAt: Date.now() + ENS_TTL_MS });
|
|
53
|
+
return name ? { address, name, kind: "ens", source: "ens" } : null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// A broken or slow ENS lookup must not fail the rest of resolution.
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolves an address to a readable name.
|
|
62
|
+
*
|
|
63
|
+
* Checks the chain config (via `findContract`), then a curated registry of
|
|
64
|
+
* off-chain-known addresses (wallets, external protocols), then - mainnet
|
|
65
|
+
* only, and only once the first two miss - an ENS reverse lookup, forward-
|
|
66
|
+
* verified against the name it returns.
|
|
67
|
+
*
|
|
68
|
+
* @param chainId - The chain/network to use.
|
|
69
|
+
* @param address - Any-case address.
|
|
70
|
+
* @param options - `ens: false` skips the ENS step; `provider` reuses an existing connection for it.
|
|
71
|
+
* @returns The resolved name, or null when nothing matches.
|
|
72
|
+
*/
|
|
73
|
+
async function resolveName(chainId, address, options) {
|
|
74
|
+
if (!ethers_1.ethers.isAddress(address))
|
|
75
|
+
return null;
|
|
76
|
+
const target = ethers_1.ethers.getAddress(address);
|
|
77
|
+
const configMatch = (0, findContract_1.findContract)(chainId, target);
|
|
78
|
+
if (configMatch)
|
|
79
|
+
return contractInfoToAddressName(configMatch);
|
|
80
|
+
const registryMatch = lookupRegistry(chainId, target);
|
|
81
|
+
if (registryMatch)
|
|
82
|
+
return registryMatch;
|
|
83
|
+
if (options?.ens === false || String(chainId) !== "1")
|
|
84
|
+
return null;
|
|
85
|
+
return lookupEns(target, options?.provider);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Batch form of {@link resolveName}. Config and registry lookups run
|
|
89
|
+
* synchronously per address; only addresses that fall through to ENS pay for
|
|
90
|
+
* a network round trip, and those run concurrently.
|
|
91
|
+
*
|
|
92
|
+
* @param chainId - The chain/network to use.
|
|
93
|
+
* @param addresses - Any-case addresses.
|
|
94
|
+
* @param options - Same as {@link resolveName}.
|
|
95
|
+
* @returns A map from the (checksummed) input address to its resolved name, or null.
|
|
96
|
+
*/
|
|
97
|
+
async function resolveNames(chainId, addresses, options) {
|
|
98
|
+
const result = {};
|
|
99
|
+
const pending = [];
|
|
100
|
+
for (const raw of addresses) {
|
|
101
|
+
if (!ethers_1.ethers.isAddress(raw))
|
|
102
|
+
continue;
|
|
103
|
+
const target = ethers_1.ethers.getAddress(raw);
|
|
104
|
+
const configMatch = (0, findContract_1.findContract)(chainId, target);
|
|
105
|
+
if (configMatch) {
|
|
106
|
+
result[target] = contractInfoToAddressName(configMatch);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const registryMatch = lookupRegistry(chainId, target);
|
|
110
|
+
if (registryMatch) {
|
|
111
|
+
result[target] = registryMatch;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (options?.ens === false || String(chainId) !== "1") {
|
|
115
|
+
result[target] = null;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
pending.push(target);
|
|
119
|
+
}
|
|
120
|
+
if (pending.length > 0) {
|
|
121
|
+
const ensResults = await Promise.all(pending.map((address) => lookupEns(address, options?.provider)));
|
|
122
|
+
pending.forEach((address, i) => {
|
|
123
|
+
result[address] = ensResults[i];
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
exports.default = resolveName;
|
|
@@ -44,6 +44,7 @@ import getContractAddress from "./contracts/getContractAddress";
|
|
|
44
44
|
import getContract from "./contracts/getContract";
|
|
45
45
|
import { findContract } from "./contracts/findContract";
|
|
46
46
|
import { decodeCall } from "./contracts/decodeCall";
|
|
47
|
+
import { resolveName, resolveNames } from "./contracts/resolveName";
|
|
47
48
|
import getLatestPrice from "./contracts/housePrices/getLatestPrice";
|
|
48
49
|
import setOracle from "./contracts/housePrices/setOracle";
|
|
49
50
|
import tick from "./minter/tick";
|
|
@@ -338,6 +339,8 @@ declare class RPCLibrary {
|
|
|
338
339
|
getContract: typeof getContract;
|
|
339
340
|
findContract: typeof findContract;
|
|
340
341
|
decodeCall: typeof decodeCall;
|
|
342
|
+
resolveName: typeof resolveName;
|
|
343
|
+
resolveNames: typeof resolveNames;
|
|
341
344
|
feeCollector: {
|
|
342
345
|
claimRewardFromPool: typeof claimRewardFromPool;
|
|
343
346
|
};
|
|
@@ -222,12 +222,14 @@ declare const chains: {
|
|
|
222
222
|
raacnftadapter: {
|
|
223
223
|
id: string;
|
|
224
224
|
name: string;
|
|
225
|
+
label: string;
|
|
225
226
|
contract: string;
|
|
226
227
|
type: string;
|
|
227
228
|
};
|
|
228
229
|
rwaindextokenadapter: {
|
|
229
230
|
id: string;
|
|
230
231
|
name: string;
|
|
232
|
+
label: string;
|
|
231
233
|
contract: string;
|
|
232
234
|
type: string;
|
|
233
235
|
};
|
|
@@ -236,6 +238,7 @@ declare const chains: {
|
|
|
236
238
|
raacnftadapter: {
|
|
237
239
|
id: string;
|
|
238
240
|
name: string;
|
|
241
|
+
label: string;
|
|
239
242
|
contract: string;
|
|
240
243
|
type: string;
|
|
241
244
|
};
|
|
@@ -471,12 +474,14 @@ export declare const configs: {
|
|
|
471
474
|
raacnftadapter: {
|
|
472
475
|
id: string;
|
|
473
476
|
name: string;
|
|
477
|
+
label: string;
|
|
474
478
|
contract: string;
|
|
475
479
|
type: string;
|
|
476
480
|
};
|
|
477
481
|
rwaindextokenadapter: {
|
|
478
482
|
id: string;
|
|
479
483
|
name: string;
|
|
484
|
+
label: string;
|
|
480
485
|
contract: string;
|
|
481
486
|
type: string;
|
|
482
487
|
};
|
|
@@ -485,6 +490,7 @@ export declare const configs: {
|
|
|
485
490
|
raacnftadapter: {
|
|
486
491
|
id: string;
|
|
487
492
|
name: string;
|
|
493
|
+
label: string;
|
|
488
494
|
contract: string;
|
|
489
495
|
type: string;
|
|
490
496
|
};
|
|
@@ -222,12 +222,14 @@ declare function getChainsConfig(): {
|
|
|
222
222
|
raacnftadapter: {
|
|
223
223
|
id: string;
|
|
224
224
|
name: string;
|
|
225
|
+
label: string;
|
|
225
226
|
contract: string;
|
|
226
227
|
type: string;
|
|
227
228
|
};
|
|
228
229
|
rwaindextokenadapter: {
|
|
229
230
|
id: string;
|
|
230
231
|
name: string;
|
|
232
|
+
label: string;
|
|
231
233
|
contract: string;
|
|
232
234
|
type: string;
|
|
233
235
|
};
|
|
@@ -236,6 +238,7 @@ declare function getChainsConfig(): {
|
|
|
236
238
|
raacnftadapter: {
|
|
237
239
|
id: string;
|
|
238
240
|
name: string;
|
|
241
|
+
label: string;
|
|
239
242
|
contract: string;
|
|
240
243
|
type: string;
|
|
241
244
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated, off-chain-known addresses per chain (wallets, external protocols),
|
|
3
|
+
* keyed by checksummed address. Empty until entries are reviewed and added -
|
|
4
|
+
* see resolveName.ts for why this ships empty rather than with guessed data.
|
|
5
|
+
*/
|
|
6
|
+
declare const registries: {
|
|
7
|
+
1: {};
|
|
8
|
+
8453: {};
|
|
9
|
+
17000: {};
|
|
10
|
+
11155111: {};
|
|
11
|
+
18453: {};
|
|
12
|
+
};
|
|
13
|
+
export default registries;
|
|
@@ -5,8 +5,10 @@ export interface ContractInfo {
|
|
|
5
5
|
address: string;
|
|
6
6
|
/** The entry's id in the chain config, e.g. "treasury" or "RAAC_pmUSD". */
|
|
7
7
|
id: string;
|
|
8
|
-
/** The entry's
|
|
8
|
+
/** The entry's internal name, e.g. "Treasury". */
|
|
9
9
|
name: string;
|
|
10
|
+
/** The user-facing name, e.g. "Treasury". Same as `name` except for adapters, which report their pool or vault ("RWA Vault"). */
|
|
11
|
+
label: string;
|
|
10
12
|
/** Top-level config section the entry came from, e.g. "contracts", "gauges", "proposals". */
|
|
11
13
|
section: string;
|
|
12
14
|
/** Key into `ABIS`, or null when this library ships no ABI for the contract. */
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Provider } from "ethers";
|
|
2
|
+
import { ChainId } from "../configs/chains";
|
|
3
|
+
export interface AddressName {
|
|
4
|
+
/** Checksummed. */
|
|
5
|
+
address: string;
|
|
6
|
+
name: string;
|
|
7
|
+
kind: "contract" | "gauge" | "wallet" | "external" | "ens";
|
|
8
|
+
source: "config" | "registry" | "ens";
|
|
9
|
+
url?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ResolveNameOptions {
|
|
12
|
+
/** Attempt an ENS reverse lookup when nothing else matches. Mainnet only regardless of this flag. Default true. */
|
|
13
|
+
ens?: boolean;
|
|
14
|
+
/** Reuse an existing provider for the ENS lookup instead of constructing one from the chain config. */
|
|
15
|
+
provider?: Provider;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolves an address to a readable name.
|
|
19
|
+
*
|
|
20
|
+
* Checks the chain config (via `findContract`), then a curated registry of
|
|
21
|
+
* off-chain-known addresses (wallets, external protocols), then - mainnet
|
|
22
|
+
* only, and only once the first two miss - an ENS reverse lookup, forward-
|
|
23
|
+
* verified against the name it returns.
|
|
24
|
+
*
|
|
25
|
+
* @param chainId - The chain/network to use.
|
|
26
|
+
* @param address - Any-case address.
|
|
27
|
+
* @param options - `ens: false` skips the ENS step; `provider` reuses an existing connection for it.
|
|
28
|
+
* @returns The resolved name, or null when nothing matches.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveName(chainId: ChainId, address: string, options?: ResolveNameOptions): Promise<AddressName | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Batch form of {@link resolveName}. Config and registry lookups run
|
|
33
|
+
* synchronously per address; only addresses that fall through to ENS pay for
|
|
34
|
+
* a network round trip, and those run concurrently.
|
|
35
|
+
*
|
|
36
|
+
* @param chainId - The chain/network to use.
|
|
37
|
+
* @param addresses - Any-case addresses.
|
|
38
|
+
* @param options - Same as {@link resolveName}.
|
|
39
|
+
* @returns A map from the (checksummed) input address to its resolved name, or null.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveNames(chainId: ChainId, addresses: string[], options?: ResolveNameOptions): Promise<Record<string, AddressName | null>>;
|
|
42
|
+
export default resolveName;
|
|
@@ -224,12 +224,14 @@ export declare const getConfigs: () => {
|
|
|
224
224
|
raacnftadapter: {
|
|
225
225
|
id: string;
|
|
226
226
|
name: string;
|
|
227
|
+
label: string;
|
|
227
228
|
contract: string;
|
|
228
229
|
type: string;
|
|
229
230
|
};
|
|
230
231
|
rwaindextokenadapter: {
|
|
231
232
|
id: string;
|
|
232
233
|
name: string;
|
|
234
|
+
label: string;
|
|
233
235
|
contract: string;
|
|
234
236
|
type: string;
|
|
235
237
|
};
|
|
@@ -238,6 +240,7 @@ export declare const getConfigs: () => {
|
|
|
238
240
|
raacnftadapter: {
|
|
239
241
|
id: string;
|
|
240
242
|
name: string;
|
|
243
|
+
label: string;
|
|
241
244
|
contract: string;
|
|
242
245
|
type: string;
|
|
243
246
|
};
|
|
@@ -481,12 +484,14 @@ declare const _default: {
|
|
|
481
484
|
raacnftadapter: {
|
|
482
485
|
id: string;
|
|
483
486
|
name: string;
|
|
487
|
+
label: string;
|
|
484
488
|
contract: string;
|
|
485
489
|
type: string;
|
|
486
490
|
};
|
|
487
491
|
rwaindextokenadapter: {
|
|
488
492
|
id: string;
|
|
489
493
|
name: string;
|
|
494
|
+
label: string;
|
|
490
495
|
contract: string;
|
|
491
496
|
type: string;
|
|
492
497
|
};
|
|
@@ -495,6 +500,7 @@ declare const _default: {
|
|
|
495
500
|
raacnftadapter: {
|
|
496
501
|
id: string;
|
|
497
502
|
name: string;
|
|
503
|
+
label: string;
|
|
498
504
|
contract: string;
|
|
499
505
|
type: string;
|
|
500
506
|
};
|