@raac/rpc 1.1.0-beta.83 → 1.1.0-beta.84
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/artifacts/core/collectors/FeeCollector.sol/FeeCollector.json +2 -2
- package/dist/artifacts/core/minters/RAACMinter/RAACMinter.sol/RAACMinter.json +2 -2
- package/dist/artifacts/core/oracles/RAACPrimeRateOracle.sol/RAACPrimeRateOracle.json +2 -2
- package/dist/artifacts/core/pools/LendingPool/LendingPool.sol/LendingPool.json +20 -10
- package/dist/artifacts/core/pools/StabilityPool/StabilityPool.sol/StabilityPool.json +2 -2
- package/dist/artifacts/core/tokens/DEToken.sol/DEToken.json +63 -7
- package/dist/artifacts/core/tokens/RToken.sol/RToken.json +58 -2
- package/dist/artifacts/core/vaults/RWAVault.sol/RWAVault.json +2 -20
- package/dist/configs/chains/11155111.json +20 -25
- package/dist/oracles/encryptSecretURLs.js +6 -17
- package/dist/oracles/encryptSecrets.js +5 -19
- package/dist/oracles/houses/config.js +6 -5
- package/dist/oracles/houses/request.js +31 -60
- package/dist/oracles/houses/simulate.js +4 -3
- package/dist/oracles/prime-rate/config.js +6 -5
- package/dist/oracles/prime-rate/request.js +33 -42
- package/dist/oracles/prime-rate/simulate.js +4 -3
- package/dist/pools/rwaVault/getRWAVaultInfo.js +3 -1
- package/dist/scripts/index.js +3 -10
- package/dist/scripts/liquidation.js +13 -29
- package/dist/types/oracles/encryptSecretURLs.d.ts +4 -4
- package/dist/types/oracles/encryptSecrets.d.ts +2 -4
- package/dist/types/oracles/houses/config.d.ts +4 -5
- package/dist/types/oracles/houses/request.d.ts +3 -5
- package/dist/types/oracles/prime-rate/config.d.ts +4 -5
- package/dist/types/oracles/prime-rate/request.d.ts +2 -2
- package/dist/types/pools/rwaVault/getRWAVaultInfo.d.ts +1 -0
- package/dist/types/utils/artifacts.d.ts +0 -113
- package/dist/utils/artifacts.js +0 -2
- package/package.json +8 -9
- package/dist/artifacts/core/collectors/NFTRoyaltyFeeCollector.sol/NFTRoyaltyFeeCollector.json +0 -246
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"raachouseprices": {
|
|
18
18
|
"id": "raachouseprices",
|
|
19
19
|
"name": "RAAC House Prices",
|
|
20
|
-
"contract": "
|
|
20
|
+
"contract": "0xF122d4Dcc791c6735d937E7118087A505c81b2b3"
|
|
21
21
|
},
|
|
22
22
|
"auctionfactory": {
|
|
23
23
|
"id": "auctionfactory",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"feecollector": {
|
|
38
38
|
"id": "feecollector",
|
|
39
39
|
"name": "Fee Collector",
|
|
40
|
-
"contract": "
|
|
40
|
+
"contract": "0x297d74333c285d5F39820c268C9e9AAb788e3625"
|
|
41
41
|
},
|
|
42
42
|
"treasury": {
|
|
43
43
|
"id": "treasury",
|
|
44
44
|
"name": "Treasury",
|
|
45
|
-
"contract": "
|
|
45
|
+
"contract": "0xF361850f103611D0ce869f369Fa62811B4BAa68B"
|
|
46
46
|
},
|
|
47
47
|
"repairfund": {
|
|
48
48
|
"id": "repairfund",
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"rwavault": {
|
|
58
58
|
"id": "rwavault",
|
|
59
59
|
"name": "RWA Vault",
|
|
60
|
-
"contract": "
|
|
60
|
+
"contract": "0x7D819769ADDbBcc7D482E7e8FcC2812De0929875"
|
|
61
61
|
},
|
|
62
62
|
"complianceregistry": {
|
|
63
63
|
"id": "complianceregistry",
|
|
64
64
|
"name": "Compliance Registry",
|
|
65
|
-
"contract": "
|
|
65
|
+
"contract": "0x74E2aEcC41F096Dca69368A7D10604142C44CfF0"
|
|
66
66
|
},
|
|
67
67
|
"rwaindextokencollector": {
|
|
68
68
|
"id": "rwaindextokencollector",
|
|
69
69
|
"name": "RWA Index Token Collector",
|
|
70
|
-
"contract": "
|
|
70
|
+
"contract": "0xc4999Db2fd4A58d870F9c8D18fBe4177308e2481"
|
|
71
71
|
},
|
|
72
72
|
"raactokencollector": {
|
|
73
73
|
"id": "raactokencollector",
|
|
@@ -77,41 +77,36 @@
|
|
|
77
77
|
"raachousepriceoracle": {
|
|
78
78
|
"id": "raachousepriceoracle",
|
|
79
79
|
"name": "RAAC House Price Oracle",
|
|
80
|
-
"contract": "
|
|
80
|
+
"contract": "0x6e15A7037cB6EEA74F8a5fCD20EBaa77e331093D"
|
|
81
81
|
},
|
|
82
82
|
"raacprimerateoracle": {
|
|
83
83
|
"id": "raacprimerateoracle",
|
|
84
84
|
"name": "RAAC Prime Rate Oracle",
|
|
85
|
-
"contract": "
|
|
85
|
+
"contract": "0x158c6c40DF3E7f9B1AdA92Ab7D4B8b437749BF6b"
|
|
86
86
|
},
|
|
87
87
|
"crvusdtousdoracle": {
|
|
88
88
|
"id": "crvusdtousdoracle",
|
|
89
89
|
"name": "CRVUSD to USD Oracle",
|
|
90
|
-
"contract": "
|
|
91
|
-
},
|
|
92
|
-
"nftroyaltyfeecollector": {
|
|
93
|
-
"id": "nftroyaltyfeecollector",
|
|
94
|
-
"name": "NFT Royalty Fee Collector",
|
|
95
|
-
"contract": "0x352b225A9f96ad9d90A1e8db4f1908943729b511"
|
|
90
|
+
"contract": "0x8A2E4B94ebf21A4b9CAF52958B2B8b6099CE46cA"
|
|
96
91
|
}
|
|
97
92
|
},
|
|
98
93
|
"pools": {
|
|
99
94
|
"stabilitypool": {
|
|
100
95
|
"id": "stabilitypool",
|
|
101
96
|
"name": "Stability Pool",
|
|
102
|
-
"contract": "
|
|
97
|
+
"contract": "0xF88967cbdEf88063b4c4d0F4F5E93b429C39689A"
|
|
103
98
|
},
|
|
104
99
|
"lendingpool": {
|
|
105
100
|
"id": "lendingpool",
|
|
106
101
|
"name": "Lending Pool",
|
|
107
|
-
"contract": "
|
|
102
|
+
"contract": "0x90d4e68C41333053248784e570C998EC915d5161"
|
|
108
103
|
}
|
|
109
104
|
},
|
|
110
105
|
"nfts": {
|
|
111
106
|
"raacnft": {
|
|
112
107
|
"id": "raacnft",
|
|
113
108
|
"name": "RAAC NFT",
|
|
114
|
-
"contract": "
|
|
109
|
+
"contract": "0xbac60A20C0B932b65E18F636C94e9f4b41F3A426"
|
|
115
110
|
}
|
|
116
111
|
},
|
|
117
112
|
"assets": {
|
|
@@ -125,19 +120,19 @@
|
|
|
125
120
|
"id": "crvusd",
|
|
126
121
|
"name": "CRVUSD",
|
|
127
122
|
"decimals": 18,
|
|
128
|
-
"contract": "
|
|
123
|
+
"contract": "0xfbA5b62A1a9d7Bd2bE46ca861DBfd49702E82f19"
|
|
129
124
|
},
|
|
130
125
|
"rtoken": {
|
|
131
126
|
"id": "rtoken",
|
|
132
127
|
"name": "RToken",
|
|
133
128
|
"decimals": 18,
|
|
134
|
-
"contract": "
|
|
129
|
+
"contract": "0xeb957D30f3F3c3534D3Dcd0828C7747602803B7A"
|
|
135
130
|
},
|
|
136
131
|
"detoken": {
|
|
137
132
|
"id": "detoken",
|
|
138
133
|
"name": "DEToken",
|
|
139
134
|
"decimals": 18,
|
|
140
|
-
"contract": "
|
|
135
|
+
"contract": "0x229495b726Bdc55917DBE89674306D3F3Daa5aE5"
|
|
141
136
|
},
|
|
142
137
|
"raactoken": {
|
|
143
138
|
"id": "raactoken",
|
|
@@ -155,13 +150,13 @@
|
|
|
155
150
|
"id": "debttoken",
|
|
156
151
|
"name": "Debt Token",
|
|
157
152
|
"decimals": 18,
|
|
158
|
-
"contract": "
|
|
153
|
+
"contract": "0xd4bE0b77c07C58fc5cAea5629587f54572090F88"
|
|
159
154
|
},
|
|
160
155
|
"rwaindextoken": {
|
|
161
156
|
"id": "rwaindextoken",
|
|
162
157
|
"name": "RWA Index Token",
|
|
163
158
|
"decimals": 18,
|
|
164
|
-
"contract": "
|
|
159
|
+
"contract": "0xa96a1578dCBd8bca443142567C19d61DF1513937"
|
|
165
160
|
}
|
|
166
161
|
},
|
|
167
162
|
"adapters": {
|
|
@@ -169,13 +164,13 @@
|
|
|
169
164
|
"raacnftadapter": {
|
|
170
165
|
"id": "raacnftadapter",
|
|
171
166
|
"name": "RAAC NFT Adapter",
|
|
172
|
-
"contract": "
|
|
167
|
+
"contract": "0xd8Cb90b0A5b288F5f0c9a519Ae4B1B47D5E69353",
|
|
173
168
|
"type": "ERC721"
|
|
174
169
|
},
|
|
175
170
|
"rwaindextokenadapter": {
|
|
176
171
|
"id": "rwaindextokenadapter",
|
|
177
172
|
"name": "RWA Index Token",
|
|
178
|
-
"contract": "
|
|
173
|
+
"contract": "0x216433c8408A349B4b7342d60F948d89317E3366",
|
|
179
174
|
"type": "ERC20"
|
|
180
175
|
}
|
|
181
176
|
},
|
|
@@ -183,7 +178,7 @@
|
|
|
183
178
|
"raacnftadapter": {
|
|
184
179
|
"id": "raacnftadapter",
|
|
185
180
|
"name": "RAAC NFT Adapter",
|
|
186
|
-
"contract": "
|
|
181
|
+
"contract": "0x5b10F4F746f10632e4Bb832A2e93bd5543830D7d",
|
|
187
182
|
"type": "ERC721"
|
|
188
183
|
},
|
|
189
184
|
"crvusdadapter": {
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.encryptSecretURLs = encryptSecretURLs;
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
14
|
-
signer: signerV5,
|
|
15
|
-
functionsRouterAddress,
|
|
16
|
-
donId,
|
|
17
|
-
});
|
|
18
|
-
await secretsManager.initialize();
|
|
19
|
-
const encryptedSecrets = await secretsManager.encryptSecretsUrls(urls);
|
|
20
|
-
const isVerified = await secretsManager.verifyOffchainSecrets(urls);
|
|
4
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
5
|
+
async function encryptSecretURLs(chainId, urls, signer) {
|
|
6
|
+
const { chain, network } = chainlinkjs_1.utils.getChainAndNetwork(chainId);
|
|
7
|
+
const secretsConnector = new chainlinkjs_1.connectors.ChainlinkSecretsConnector(signer, { chain, network });
|
|
8
|
+
const encryptedSecrets = await secretsConnector.encryptSecretsUrls(urls);
|
|
9
|
+
const isVerified = await secretsConnector.verifyOffchainSecrets(urls);
|
|
21
10
|
if (!isVerified) {
|
|
22
11
|
throw new Error("Offchain secrets verification failed");
|
|
23
12
|
}
|
|
@@ -4,26 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.encryptSecrets = encryptSecrets;
|
|
7
|
-
const
|
|
8
|
-
const chainlink_networks_config_1 = __importDefault(require("./chainlink-networks-config"));
|
|
9
|
-
const functions_toolkit_1 = require("@chainlink/functions-toolkit");
|
|
7
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
10
8
|
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
async function encryptSecrets(chainId, secrets, outputFile,
|
|
12
|
-
const chain =
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
throw new Error(`Chain configuration not found for chainId: ${chainId}`);
|
|
16
|
-
}
|
|
17
|
-
const functionsRouterAddress = network.functionsRouter;
|
|
18
|
-
const donId = network.donId;
|
|
19
|
-
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
20
|
-
// ethers v5 signer again
|
|
21
|
-
signer: signerV5,
|
|
22
|
-
functionsRouterAddress,
|
|
23
|
-
donId,
|
|
24
|
-
});
|
|
25
|
-
await secretsManager.initialize();
|
|
26
|
-
const encryptedSecrets = await secretsManager.encryptSecrets(secrets);
|
|
9
|
+
async function encryptSecrets(chainId, secrets, outputFile, signer) {
|
|
10
|
+
const { chain, network } = chainlinkjs_1.utils.getChainAndNetwork(chainId);
|
|
11
|
+
const secretsConnector = new chainlinkjs_1.connectors.ChainlinkSecretsConnector(signer, chain, network);
|
|
12
|
+
const encryptedSecrets = await secretsConnector.encryptSecrets(secrets);
|
|
27
13
|
fs_1.default.writeFileSync(outputFile, JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
|
|
28
14
|
return encryptedSecrets;
|
|
29
15
|
}
|
|
@@ -4,16 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const
|
|
7
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
8
|
+
const { Location, ReturnType, CodeLanguage } = chainlinkjs_1.enums;
|
|
8
9
|
const requestConfig = {
|
|
9
10
|
source: fs_1.default.readFileSync("./oracles/houses/api.js").toString(),
|
|
10
|
-
codeLocation:
|
|
11
|
+
codeLocation: Location.Inline,
|
|
11
12
|
// Optional
|
|
12
13
|
secrets: { apiKey: process.env.RAAC_HOUSING_API_KEY ?? "" },
|
|
13
14
|
// Optional
|
|
14
|
-
secretsLocation:
|
|
15
|
+
secretsLocation: Location.DONHosted,
|
|
15
16
|
args: [],
|
|
16
|
-
codeLanguage:
|
|
17
|
-
expectedReturnType:
|
|
17
|
+
codeLanguage: CodeLanguage.JavaScript,
|
|
18
|
+
expectedReturnType: ReturnType.uint256,
|
|
18
19
|
};
|
|
19
20
|
exports.default = requestConfig;
|
|
@@ -5,36 +5,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.generateSecretReference = generateSecretReference;
|
|
7
7
|
exports.request = request;
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const ethers_1 = require("ethers");
|
|
10
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
11
|
+
const { decodeResult, simulateScript, decomposeFromChainId } = chainlinkjs_1.utils;
|
|
12
|
+
const { ChainlinkFunctionConnector, ChainlinkSecretsConnector } = chainlinkjs_1.connectors;
|
|
13
|
+
const FulfillmentCode = chainlinkjs_1.enums.FulfillmentCode;
|
|
14
|
+
const ResponseListener = chainlinkjs_1.listeners.ResponseListener;
|
|
12
15
|
const config_1 = __importDefault(require("./config"));
|
|
13
|
-
const
|
|
16
|
+
const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
|
|
14
17
|
const artifacts_1 = require("../../utils/artifacts");
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
18
|
const subscriptionIds = {
|
|
17
19
|
8453: 4392,
|
|
18
20
|
17000: 4392,
|
|
19
21
|
11155111: 4392,
|
|
20
22
|
18453: 4392,
|
|
21
23
|
};
|
|
22
|
-
async function generateSecretReference(chainId, secrets,
|
|
23
|
-
const chain = (0, configs_1.getChainConfig)(chainId);
|
|
24
|
-
const network = chainlink_networks_config_1.default[chainId];
|
|
25
|
-
if (!chain) {
|
|
26
|
-
throw new Error(`Chain configuration not found for chainId: ${chainId}`);
|
|
27
|
-
}
|
|
24
|
+
async function generateSecretReference(chainId, secrets, signer) {
|
|
28
25
|
const slotId = 0;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
32
|
-
// ethers v5 signer again
|
|
33
|
-
signer: signerV5,
|
|
34
|
-
functionsRouterAddress,
|
|
35
|
-
donId,
|
|
36
|
-
});
|
|
37
|
-
await secretsManager.initialize();
|
|
26
|
+
const { chain, network } = decomposeFromChainId(chainId);
|
|
27
|
+
const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
|
|
38
28
|
const encryptedSecrets = await secretsManager.encryptSecrets(secrets);
|
|
39
29
|
fs_1.default.writeFileSync("encryptedFunctionsBeaconSecrets.json", JSON.stringify(encryptedSecrets, null, 2), { encoding: 'utf8' });
|
|
40
30
|
// DONHoster secrets
|
|
@@ -51,20 +41,16 @@ async function generateSecretReference(chainId, secrets, signerV5) {
|
|
|
51
41
|
// });
|
|
52
42
|
return encryptedSecrets;
|
|
53
43
|
}
|
|
54
|
-
async function request(chainId, houseId,
|
|
55
|
-
const chain = (
|
|
56
|
-
const network = chainlink_networks_config_1.default[chainId];
|
|
57
|
-
if (!chain) {
|
|
58
|
-
throw new Error(`Chain configuration not found for chainId: ${chainId}`);
|
|
59
|
-
}
|
|
44
|
+
async function request(chainId, houseId, signer) {
|
|
45
|
+
const { chain, network } = decomposeFromChainId(chainId);
|
|
60
46
|
// Simulate the request first
|
|
61
47
|
{
|
|
62
|
-
const { responseBytesHexstring, errorString } = await
|
|
48
|
+
const { responseBytesHexstring, errorString } = await simulateScript({
|
|
63
49
|
...config_1.default,
|
|
64
50
|
args: [houseId],
|
|
65
51
|
});
|
|
66
52
|
if (responseBytesHexstring) {
|
|
67
|
-
console.log(`\nResponse returned by script during local simulation: ${
|
|
53
|
+
console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
68
54
|
}
|
|
69
55
|
if (errorString) {
|
|
70
56
|
console.log(`\nError returned by simulated script:\n${errorString}\n`);
|
|
@@ -76,42 +62,27 @@ async function request(chainId, houseId, signerV5) {
|
|
|
76
62
|
const subscriptionId = subscriptionIds[chainId];
|
|
77
63
|
const slotId = 0;
|
|
78
64
|
const callbackGasLimit = 300_000;
|
|
79
|
-
const consumerContract = new
|
|
80
|
-
const linkTokenAddress = network.linkToken;
|
|
65
|
+
const consumerContract = new ethers_1.ethers.Contract(contractAddress, contractAbi, signer);
|
|
81
66
|
const functionsRouterAddress = network.functionsRouter;
|
|
82
|
-
const subscriptionManager = new
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
linkTokenAddress,
|
|
86
|
-
functionsRouterAddress,
|
|
87
|
-
});
|
|
88
|
-
await subscriptionManager.initialize();
|
|
89
|
-
const donId = network.donId;
|
|
90
|
-
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
91
|
-
// ethers v5 signer again
|
|
92
|
-
signer: signerV5,
|
|
93
|
-
functionsRouterAddress,
|
|
94
|
-
donId,
|
|
95
|
-
});
|
|
96
|
-
await secretsManager.initialize();
|
|
97
|
-
const subInfo = await subscriptionManager.getSubscriptionInfo(subscriptionId);
|
|
67
|
+
const subscriptionManager = new ChainlinkFunctionConnector(signer, { chain, network });
|
|
68
|
+
const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
|
|
69
|
+
const subInfo = await subscriptionManager.getSubscription(subscriptionId);
|
|
98
70
|
if (!subInfo.consumers
|
|
99
71
|
.map((c) => c.toLowerCase())
|
|
100
72
|
.includes(contractAddress.toLowerCase())) {
|
|
101
73
|
throw Error(`Consumer contract ${contractAddress} has not been added to subscription ${subscriptionId}`);
|
|
102
74
|
}
|
|
103
|
-
|
|
104
|
-
const { gasPrice } = await signerV5.provider.getFeeData();
|
|
75
|
+
const { gasPrice } = await signer.provider.getFeeData();
|
|
105
76
|
// @ts-ignore
|
|
106
|
-
const gasPriceWei = BigInt(Math.ceil(
|
|
77
|
+
const gasPriceWei = BigInt(Math.ceil(ethers_1.ethers.formatUnits(gasPrice, "wei").toString()));
|
|
107
78
|
const estimatedCostJuels = await subscriptionManager.estimateFunctionsRequestCost({
|
|
108
|
-
donId,
|
|
79
|
+
donId: subscriptionManager.donId,
|
|
109
80
|
subscriptionId,
|
|
110
81
|
callbackGasLimit,
|
|
111
82
|
gasPriceWei,
|
|
112
83
|
});
|
|
113
|
-
const estimatedCostLink =
|
|
114
|
-
const subBalanceLink =
|
|
84
|
+
const estimatedCostLink = ethers_1.ethers.formatUnits(estimatedCostJuels.toString(), 18);
|
|
85
|
+
const subBalanceLink = ethers_1.ethers.parseUnits(subInfo.balance, 18);
|
|
115
86
|
if (subInfo.balance <= estimatedCostJuels) {
|
|
116
87
|
throw Error(`Subscription ${subscriptionId} does not have sufficient funds. The estimated cost is ${estimatedCostLink} LINK, but the subscription only has ${subBalanceLink} LINK.`);
|
|
117
88
|
}
|
|
@@ -127,8 +98,8 @@ async function request(chainId, houseId, signerV5) {
|
|
|
127
98
|
slotId,
|
|
128
99
|
version,
|
|
129
100
|
});
|
|
130
|
-
const responseListener = new
|
|
131
|
-
provider:
|
|
101
|
+
const responseListener = new ResponseListener({
|
|
102
|
+
provider: signer.provider,
|
|
132
103
|
functionsRouterAddress,
|
|
133
104
|
});
|
|
134
105
|
console.log(`Waiting for transaction for RAACHousePriceOracle contract ${contractAddress} on network ${network.name} to be confirmed...`);
|
|
@@ -146,9 +117,9 @@ async function request(chainId, houseId, signerV5) {
|
|
|
146
117
|
// Get response data
|
|
147
118
|
const { requestId, totalCostInJuels, responseBytesHexstring, errorString, fulfillmentCode, } = await responseListener.listenForResponseFromTransaction(requestTx.hash, undefined, NUM_CONFIRMATIONS, undefined);
|
|
148
119
|
switch (fulfillmentCode) {
|
|
149
|
-
case
|
|
120
|
+
case FulfillmentCode.FULFILLED:
|
|
150
121
|
if (responseBytesHexstring !== "0x") {
|
|
151
|
-
console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${
|
|
122
|
+
console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
152
123
|
}
|
|
153
124
|
else if (errorString.length > 0) {
|
|
154
125
|
console.error(`Request ${requestId} fulfilled with error: ${errorString}\n`);
|
|
@@ -156,13 +127,13 @@ async function request(chainId, houseId, signerV5) {
|
|
|
156
127
|
else {
|
|
157
128
|
console.warn(`Request ${requestId} fulfilled with empty response data.\n`);
|
|
158
129
|
}
|
|
159
|
-
const linkCost =
|
|
130
|
+
const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
|
|
160
131
|
console.log(`Total request cost: ${linkCost + " LINK"}`);
|
|
161
132
|
break;
|
|
162
|
-
case
|
|
133
|
+
case FulfillmentCode.USER_CALLBACK_ERROR:
|
|
163
134
|
console.error("Error encountered when calling consumer contract callback.\nEnsure the fulfillRequest function in RAACHousePriceOracle is correct and the --callbackgaslimit is sufficient.");
|
|
164
135
|
break;
|
|
165
|
-
case
|
|
136
|
+
case FulfillmentCode.COST_EXCEEDS_COMMITMENT:
|
|
166
137
|
console.error(`Request ${requestId} failed due to a gas price spike when attempting to respond.`);
|
|
167
138
|
break;
|
|
168
139
|
default:
|
|
@@ -4,15 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.simulate = simulate;
|
|
7
|
-
const
|
|
7
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
8
|
+
const { simulateScript, decodeResult } = chainlinkjs_1.utils;
|
|
8
9
|
const config_1 = __importDefault(require("./config"));
|
|
9
10
|
async function simulate(houseId) {
|
|
10
|
-
const { responseBytesHexstring, errorString } = await
|
|
11
|
+
const { responseBytesHexstring, errorString } = await simulateScript({
|
|
11
12
|
...config_1.default,
|
|
12
13
|
args: [houseId],
|
|
13
14
|
});
|
|
14
15
|
if (responseBytesHexstring) {
|
|
15
|
-
console.log(`\nResponse returned by script during local simulation: ${
|
|
16
|
+
console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
16
17
|
}
|
|
17
18
|
if (errorString) {
|
|
18
19
|
console.log(`\nError returned by simulated script:\n${errorString}\n`);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
4
|
+
const { Location, ReturnType, CodeLanguage } = chainlinkjs_1.enums;
|
|
4
5
|
const requestConfig = {
|
|
5
6
|
name: "prime-rate",
|
|
6
7
|
sourceURL: "https://emerald-many-grasshopper-318.mypinata.cloud/ipfs/bafkreid3kubchc3f2sspzq25pnmnw3mppkhv46xvzg72xx7zqs2plvjbqu",
|
|
7
|
-
codeLocation:
|
|
8
|
+
codeLocation: Location["Inline"],
|
|
8
9
|
// Optional
|
|
9
10
|
secrets: { apiKey: process.env.FRED_API_KEY ?? "" },
|
|
10
11
|
// Optional
|
|
11
|
-
secretsLocation:
|
|
12
|
+
secretsLocation: Location["DONHosted"],
|
|
12
13
|
args: [],
|
|
13
|
-
codeLanguage:
|
|
14
|
-
expectedReturnType:
|
|
14
|
+
codeLanguage: CodeLanguage.JavaScript,
|
|
15
|
+
expectedReturnType: ReturnType.uint256,
|
|
15
16
|
};
|
|
16
17
|
exports.default = requestConfig;
|
|
@@ -4,10 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.request = request;
|
|
7
|
-
const
|
|
7
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
8
|
+
const { decodeResult, simulateScript, decomposeFromChainId } = chainlinkjs_1.utils;
|
|
9
|
+
const { ChainlinkFunctionConnector, ChainlinkSecretsConnector } = chainlinkjs_1.connectors;
|
|
10
|
+
const FulfillmentCode = chainlinkjs_1.enums.FulfillmentCode;
|
|
11
|
+
const ResponseListener = chainlinkjs_1.listeners.ResponseListener;
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
8
13
|
const configs_1 = require("../../configs");
|
|
9
14
|
const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
|
|
10
|
-
const ethers5_1 = require("ethers5");
|
|
11
15
|
const config_1 = __importDefault(require("./config"));
|
|
12
16
|
const chainlink_networks_config_1 = __importDefault(require("../chainlink-networks-config"));
|
|
13
17
|
const artifacts_1 = require("../../utils/artifacts");
|
|
@@ -17,10 +21,10 @@ const subscriptionIds = {
|
|
|
17
21
|
11155111: 4392,
|
|
18
22
|
18453: 4392,
|
|
19
23
|
};
|
|
20
|
-
async function request(chainId,
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
+
async function request(chainId, signer) {
|
|
25
|
+
const chainConfig = (0, configs_1.getChainConfig)(chainId);
|
|
26
|
+
const networkConfig = chainlink_networks_config_1.default[chainId];
|
|
27
|
+
if (!chainConfig) {
|
|
24
28
|
throw new Error(`Chain configuration not found for chainId: ${chainId}`);
|
|
25
29
|
}
|
|
26
30
|
const sourceFetch = await fetch(config_1.default.sourceURL);
|
|
@@ -28,12 +32,12 @@ async function request(chainId, signerV5) {
|
|
|
28
32
|
console.log("Reading source from URL: ", config_1.default.sourceURL);
|
|
29
33
|
// Simulate the request first
|
|
30
34
|
{
|
|
31
|
-
const { responseBytesHexstring, errorString } = await
|
|
35
|
+
const { responseBytesHexstring, errorString } = await simulateScript({
|
|
32
36
|
...config_1.default,
|
|
33
37
|
source,
|
|
34
38
|
});
|
|
35
39
|
if (responseBytesHexstring) {
|
|
36
|
-
console.log(`\nResponse returned by script during local simulation: ${
|
|
40
|
+
console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
37
41
|
}
|
|
38
42
|
if (errorString) {
|
|
39
43
|
console.log(`\nError returned by simulated script:\n${errorString}\n`);
|
|
@@ -41,7 +45,7 @@ async function request(chainId, signerV5) {
|
|
|
41
45
|
console.log("Local simulation of source code completed...");
|
|
42
46
|
}
|
|
43
47
|
// Get the RPC endpoint from the chain config and derive a v5 provider
|
|
44
|
-
const rpcUrl =
|
|
48
|
+
const rpcUrl = chainConfig.rpcs?.[0] ?? chainConfig.rpc ?? undefined;
|
|
45
49
|
if (!rpcUrl)
|
|
46
50
|
throw new Error("No RPC URL found in chain configuration");
|
|
47
51
|
const contractAddress = (0, getContractAddress_1.default)(chainId, "raacprimerateoracle");
|
|
@@ -49,42 +53,29 @@ async function request(chainId, signerV5) {
|
|
|
49
53
|
const subscriptionId = subscriptionIds[chainId];
|
|
50
54
|
const slotId = 0;
|
|
51
55
|
const callbackGasLimit = 300_000;
|
|
52
|
-
const consumerContract = new
|
|
53
|
-
const linkTokenAddress = network.linkToken;
|
|
54
|
-
const functionsRouterAddress =
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
linkTokenAddress,
|
|
59
|
-
functionsRouterAddress,
|
|
60
|
-
});
|
|
61
|
-
await subscriptionManager.initialize();
|
|
62
|
-
const donId = network.donId;
|
|
63
|
-
const secretsManager = new functions_toolkit_1.SecretsManager({
|
|
64
|
-
// ethers v5 signer again
|
|
65
|
-
signer: signerV5,
|
|
66
|
-
functionsRouterAddress,
|
|
67
|
-
donId,
|
|
68
|
-
});
|
|
69
|
-
await secretsManager.initialize();
|
|
56
|
+
const consumerContract = new ethers_1.ethers.Contract(contractAddress, contractAbi, signer);
|
|
57
|
+
// const linkTokenAddress = network.linkToken;
|
|
58
|
+
const functionsRouterAddress = networkConfig.functionsRouter;
|
|
59
|
+
const { chain, network } = decomposeFromChainId(chainId);
|
|
60
|
+
const subscriptionManager = new ChainlinkFunctionConnector(signer, { chain, network });
|
|
61
|
+
const secretsManager = new ChainlinkSecretsConnector(signer, { chain, network });
|
|
70
62
|
const subInfo = await subscriptionManager.getSubscriptionInfo(subscriptionId);
|
|
71
63
|
if (!subInfo.consumers
|
|
72
64
|
.map((c) => c.toLowerCase())
|
|
73
65
|
.includes(contractAddress.toLowerCase())) {
|
|
74
66
|
throw Error(`Consumer contract ${contractAddress} has not been added to subscription ${subscriptionId}`);
|
|
75
67
|
}
|
|
76
|
-
|
|
77
|
-
const { gasPrice } = await signerV5.provider.getFeeData();
|
|
68
|
+
const { gasPrice } = await signer.provider.getFeeData();
|
|
78
69
|
// @ts-ignore
|
|
79
|
-
const gasPriceWei = BigInt(Math.ceil(
|
|
70
|
+
const gasPriceWei = BigInt(Math.ceil(ethers_1.ethers.formatUnits(gasPrice, "wei").toString()));
|
|
80
71
|
const estimatedCostJuels = await subscriptionManager.estimateFunctionsRequestCost({
|
|
81
|
-
donId,
|
|
72
|
+
donId: subscriptionManager.donId,
|
|
82
73
|
subscriptionId,
|
|
83
74
|
callbackGasLimit,
|
|
84
75
|
gasPriceWei,
|
|
85
76
|
});
|
|
86
|
-
const estimatedCostLink =
|
|
87
|
-
const subBalanceLink =
|
|
77
|
+
const estimatedCostLink = ethers_1.ethers.formatUnits(estimatedCostJuels.toString(), 18);
|
|
78
|
+
const subBalanceLink = ethers_1.ethers.parseUnits(subInfo.balance.toString(), 18);
|
|
88
79
|
if (subInfo.balance <= estimatedCostJuels) {
|
|
89
80
|
throw Error(`Subscription ${subscriptionId} does not have sufficient funds. The estimated cost is ${estimatedCostLink} LINK, but the subscription only has ${subBalanceLink} LINK.`);
|
|
90
81
|
}
|
|
@@ -100,11 +91,11 @@ async function request(chainId, signerV5) {
|
|
|
100
91
|
slotId,
|
|
101
92
|
version,
|
|
102
93
|
});
|
|
103
|
-
const responseListener = new
|
|
104
|
-
provider:
|
|
94
|
+
const responseListener = new ResponseListener({
|
|
95
|
+
provider: signer.provider,
|
|
105
96
|
functionsRouterAddress,
|
|
106
97
|
});
|
|
107
|
-
console.log(`Waiting for transaction for RAACPrimeRateOracle contract ${contractAddress} on network ${
|
|
98
|
+
console.log(`Waiting for transaction for RAACPrimeRateOracle contract ${contractAddress} on network ${networkConfig.name} to be confirmed...`);
|
|
108
99
|
const overrides = {
|
|
109
100
|
gasLimit: 1_500_000,
|
|
110
101
|
};
|
|
@@ -115,13 +106,13 @@ async function request(chainId, signerV5) {
|
|
|
115
106
|
try {
|
|
116
107
|
// localFunctionsTestnet needs 0 or 1 confirmations to work correctly as it's local.
|
|
117
108
|
// If on live testnet or mainnet, setting to undefined then uses the functions-toolkit default of 2 confirmations.
|
|
118
|
-
const NUM_CONFIRMATIONS =
|
|
109
|
+
const NUM_CONFIRMATIONS = networkConfig.confirmations;
|
|
119
110
|
// Get response data
|
|
120
111
|
const { requestId, totalCostInJuels, responseBytesHexstring, errorString, fulfillmentCode, } = await responseListener.listenForResponseFromTransaction(requestTx.hash, undefined, NUM_CONFIRMATIONS, undefined);
|
|
121
112
|
switch (fulfillmentCode) {
|
|
122
|
-
case
|
|
113
|
+
case FulfillmentCode.FULFILLED:
|
|
123
114
|
if (responseBytesHexstring !== "0x") {
|
|
124
|
-
console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${
|
|
115
|
+
console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
125
116
|
}
|
|
126
117
|
else if (errorString.length > 0) {
|
|
127
118
|
console.error(`Request ${requestId} fulfilled with error: ${errorString}\n`);
|
|
@@ -129,13 +120,13 @@ async function request(chainId, signerV5) {
|
|
|
129
120
|
else {
|
|
130
121
|
console.warn(`Request ${requestId} fulfilled with empty response data.\n`);
|
|
131
122
|
}
|
|
132
|
-
const linkCost =
|
|
123
|
+
const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
|
|
133
124
|
console.log(`Total request cost: ${linkCost + " LINK"}`);
|
|
134
125
|
break;
|
|
135
|
-
case
|
|
126
|
+
case FulfillmentCode.USER_CALLBACK_ERROR:
|
|
136
127
|
console.error("Error encountered when calling consumer contract callback.\nEnsure the fulfillRequest function in RAACPrimeRateOracle is correct and the --callbackgaslimit is sufficient.");
|
|
137
128
|
break;
|
|
138
|
-
case
|
|
129
|
+
case FulfillmentCode.COST_EXCEEDS_COMMITMENT:
|
|
139
130
|
console.error(`Request ${requestId} failed due to a gas price spike when attempting to respond.`);
|
|
140
131
|
break;
|
|
141
132
|
default:
|
|
@@ -4,19 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.simulate = simulate;
|
|
7
|
-
const
|
|
7
|
+
const chainlinkjs_1 = require("@raac/chainlinkjs");
|
|
8
|
+
const { simulateScript, decodeResult } = chainlinkjs_1.utils;
|
|
8
9
|
const config_1 = __importDefault(require("./config"));
|
|
9
10
|
async function simulate() {
|
|
10
11
|
// Simulate the request first
|
|
11
12
|
const sourceFetch = await fetch(config_1.default.sourceURL);
|
|
12
13
|
const source = await sourceFetch.text();
|
|
13
14
|
console.log("Reading source from URL: ", config_1.default.sourceURL);
|
|
14
|
-
const { responseBytesHexstring, errorString } = await
|
|
15
|
+
const { responseBytesHexstring, errorString } = await simulateScript({
|
|
15
16
|
...config_1.default,
|
|
16
17
|
source,
|
|
17
18
|
});
|
|
18
19
|
if (responseBytesHexstring) {
|
|
19
|
-
console.log(`\nResponse returned by script during local simulation: ${
|
|
20
|
+
console.log(`\nResponse returned by script during local simulation: ${decodeResult(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
|
|
20
21
|
}
|
|
21
22
|
if (errorString) {
|
|
22
23
|
console.log(`\nError returned by simulated script:\n${errorString}\n`);
|