@raac/rpc 1.1.0-beta.82 → 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.
Files changed (31) hide show
  1. package/dist/artifacts/core/collectors/FeeCollector.sol/FeeCollector.json +2 -2
  2. package/dist/artifacts/core/minters/RAACMinter/RAACMinter.sol/RAACMinter.json +2 -2
  3. package/dist/artifacts/core/oracles/RAACPrimeRateOracle.sol/RAACPrimeRateOracle.json +2 -2
  4. package/dist/artifacts/core/pools/LendingPool/LendingPool.sol/LendingPool.json +20 -10
  5. package/dist/artifacts/core/pools/StabilityPool/StabilityPool.sol/StabilityPool.json +2 -2
  6. package/dist/artifacts/core/tokens/DEToken.sol/DEToken.json +63 -7
  7. package/dist/artifacts/core/tokens/RToken.sol/RToken.json +58 -2
  8. package/dist/artifacts/core/vaults/RWAVault.sol/RWAVault.json +2 -20
  9. package/dist/configs/chains/11155111.json +20 -25
  10. package/dist/oracles/encryptSecretURLs.js +6 -17
  11. package/dist/oracles/encryptSecrets.js +5 -19
  12. package/dist/oracles/houses/config.js +6 -5
  13. package/dist/oracles/houses/request.js +31 -60
  14. package/dist/oracles/houses/simulate.js +4 -3
  15. package/dist/oracles/prime-rate/config.js +6 -5
  16. package/dist/oracles/prime-rate/request.js +33 -42
  17. package/dist/oracles/prime-rate/simulate.js +4 -3
  18. package/dist/pools/rwaVault/getRWAVaultInfo.js +3 -1
  19. package/dist/scripts/index.js +3 -10
  20. package/dist/scripts/liquidation.js +4 -4
  21. package/dist/types/oracles/encryptSecretURLs.d.ts +4 -4
  22. package/dist/types/oracles/encryptSecrets.d.ts +2 -4
  23. package/dist/types/oracles/houses/config.d.ts +4 -5
  24. package/dist/types/oracles/houses/request.d.ts +3 -5
  25. package/dist/types/oracles/prime-rate/config.d.ts +4 -5
  26. package/dist/types/oracles/prime-rate/request.d.ts +2 -2
  27. package/dist/types/pools/rwaVault/getRWAVaultInfo.d.ts +1 -0
  28. package/dist/types/utils/artifacts.d.ts +0 -113
  29. package/dist/utils/artifacts.js +0 -2
  30. package/package.json +8 -9
  31. 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": "0x96EBC781867cF33F0Fac64e44388CBF065c78e92"
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": "0xf460b2436753AEed5Df275CA33528f5C9abB579D"
40
+ "contract": "0x297d74333c285d5F39820c268C9e9AAb788e3625"
41
41
  },
42
42
  "treasury": {
43
43
  "id": "treasury",
44
44
  "name": "Treasury",
45
- "contract": "0xDc1FCd959881533CCFBfB572881CdC6d8a2b35E7"
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": "0xEC9e67e9b6ceD5e48b5Dd39915414e7BbDf952f2"
60
+ "contract": "0x7D819769ADDbBcc7D482E7e8FcC2812De0929875"
61
61
  },
62
62
  "complianceregistry": {
63
63
  "id": "complianceregistry",
64
64
  "name": "Compliance Registry",
65
- "contract": "0x95bc6FCfB69BDbF723De06bCa1a689ad68762CC5"
65
+ "contract": "0x74E2aEcC41F096Dca69368A7D10604142C44CfF0"
66
66
  },
67
67
  "rwaindextokencollector": {
68
68
  "id": "rwaindextokencollector",
69
69
  "name": "RWA Index Token Collector",
70
- "contract": "0xdbEd45218e5c040Cdf696C740937997162cFb720"
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": "0x8C881051D397014E6D4ea711764E6875506d88D1"
80
+ "contract": "0x6e15A7037cB6EEA74F8a5fCD20EBaa77e331093D"
81
81
  },
82
82
  "raacprimerateoracle": {
83
83
  "id": "raacprimerateoracle",
84
84
  "name": "RAAC Prime Rate Oracle",
85
- "contract": "0x312F47A51F398C6504B31794dfCf604acF174c67"
85
+ "contract": "0x158c6c40DF3E7f9B1AdA92Ab7D4B8b437749BF6b"
86
86
  },
87
87
  "crvusdtousdoracle": {
88
88
  "id": "crvusdtousdoracle",
89
89
  "name": "CRVUSD to USD Oracle",
90
- "contract": "0x627897baf46851500F116cec76346921C3292246"
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": "0xd7663c079445A070Ef24405CD5ef1511B9d9E060"
97
+ "contract": "0xF88967cbdEf88063b4c4d0F4F5E93b429C39689A"
103
98
  },
104
99
  "lendingpool": {
105
100
  "id": "lendingpool",
106
101
  "name": "Lending Pool",
107
- "contract": "0xefCff23AEed94ae0f23377DFDaB78C3c868eeB33"
102
+ "contract": "0x90d4e68C41333053248784e570C998EC915d5161"
108
103
  }
109
104
  },
110
105
  "nfts": {
111
106
  "raacnft": {
112
107
  "id": "raacnft",
113
108
  "name": "RAAC NFT",
114
- "contract": "0xb16453caAFF3c75e9D090793dD60C46668c1de52"
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": "0x8047a14301583CAaf9e2128D5F88F9f435659d35"
123
+ "contract": "0xfbA5b62A1a9d7Bd2bE46ca861DBfd49702E82f19"
129
124
  },
130
125
  "rtoken": {
131
126
  "id": "rtoken",
132
127
  "name": "RToken",
133
128
  "decimals": 18,
134
- "contract": "0xc96c34825aa96A77A4AD884e393960a70c5f1186"
129
+ "contract": "0xeb957D30f3F3c3534D3Dcd0828C7747602803B7A"
135
130
  },
136
131
  "detoken": {
137
132
  "id": "detoken",
138
133
  "name": "DEToken",
139
134
  "decimals": 18,
140
- "contract": "0x5841dc06d2C9e0D2605392f669be71Bfe6d04cf7"
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": "0x98db917a623a92a8553Fe59b9f05B8c936aa1E1e"
153
+ "contract": "0xd4bE0b77c07C58fc5cAea5629587f54572090F88"
159
154
  },
160
155
  "rwaindextoken": {
161
156
  "id": "rwaindextoken",
162
157
  "name": "RWA Index Token",
163
158
  "decimals": 18,
164
- "contract": "0x1c1789629B2511821aC78618eBd23d41E7b04989"
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": "0x608aD2608DAdDb633ceBe22d6Fcb7C9e660FfA65",
167
+ "contract": "0xd8Cb90b0A5b288F5f0c9a519Ae4B1B47D5E69353",
173
168
  "type": "ERC721"
174
169
  },
175
170
  "rwaindextokenadapter": {
176
171
  "id": "rwaindextokenadapter",
177
172
  "name": "RWA Index Token",
178
- "contract": "0x5374287a807c5513fC31bc9AECE5aC40f0e37c71",
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": "0x531F5d54Fda86f103E297ECE796c8B799B835E0c",
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
8
- const chainlink_networks_config_1 = __importDefault(require("./chainlink-networks-config"));
9
- async function encryptSecretURLs(chainId, urls, signerV5) {
10
- const network = chainlink_networks_config_1.default[chainId];
11
- const functionsRouterAddress = network.functionsRouter;
12
- const donId = network.donId;
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 configs_1 = require("../configs");
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, signerV5) {
12
- const chain = (0, configs_1.getChainConfig)(chainId);
13
- const network = chainlink_networks_config_1.default[chainId];
14
- if (!chain) {
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
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: functions_toolkit_1.Location.Inline,
11
+ codeLocation: Location.Inline,
11
12
  // Optional
12
13
  secrets: { apiKey: process.env.RAAC_HOUSING_API_KEY ?? "" },
13
14
  // Optional
14
- secretsLocation: functions_toolkit_1.Location.DONHosted,
15
+ secretsLocation: Location.DONHosted,
15
16
  args: [],
16
- codeLanguage: functions_toolkit_1.CodeLanguage.JavaScript,
17
- expectedReturnType: functions_toolkit_1.ReturnType.uint256,
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
9
- const configs_1 = require("../../configs");
10
- const getContractAddress_1 = __importDefault(require("../../contracts/getContractAddress"));
11
- const ethers5_1 = require("ethers5");
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 chainlink_networks_config_1 = __importDefault(require("../chainlink-networks-config"));
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, signerV5) {
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 functionsRouterAddress = network.functionsRouter;
30
- const donId = network.donId;
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, signerV5) {
55
- const chain = (0, configs_1.getChainConfig)(chainId);
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 (0, functions_toolkit_1.simulateScript)({
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: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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 ethers5_1.ethers.Contract(contractAddress, contractAbi, signerV5);
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 functions_toolkit_1.SubscriptionManager({
83
- // Use the v5 signer here (toolkit expects ethers v5 types)
84
- signer: signerV5,
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
- // Use the v5 provider for gas data (to avoid type mismatches)
104
- const { gasPrice } = await signerV5.provider.getFeeData();
75
+ const { gasPrice } = await signer.provider.getFeeData();
105
76
  // @ts-ignore
106
- const gasPriceWei = BigInt(Math.ceil(ethers5_1.ethers.utils.formatUnits(gasPrice, "wei").toString()));
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 = ethers5_1.ethers.utils.formatUnits(estimatedCostJuels.toString(), 18);
114
- const subBalanceLink = ethers5_1.ethers.utils.formatUnits(subInfo.balance.toString(), 18);
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 functions_toolkit_1.ResponseListener({
131
- provider: signerV5.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 functions_toolkit_1.FulfillmentCode.FULFILLED:
120
+ case FulfillmentCode.FULFILLED:
150
121
  if (responseBytesHexstring !== "0x") {
151
- console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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 = ethers5_1.ethers.utils.formatUnits(totalCostInJuels.toString(), 18);
130
+ const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
160
131
  console.log(`Total request cost: ${linkCost + " LINK"}`);
161
132
  break;
162
- case functions_toolkit_1.FulfillmentCode.USER_CALLBACK_ERROR:
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 functions_toolkit_1.FulfillmentCode.COST_EXCEEDS_COMMITMENT:
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
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 (0, functions_toolkit_1.simulateScript)({
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: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
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: functions_toolkit_1.Location["Inline"],
8
+ codeLocation: Location["Inline"],
8
9
  // Optional
9
10
  secrets: { apiKey: process.env.FRED_API_KEY ?? "" },
10
11
  // Optional
11
- secretsLocation: functions_toolkit_1.Location["DONHosted"],
12
+ secretsLocation: Location["DONHosted"],
12
13
  args: [],
13
- codeLanguage: functions_toolkit_1.CodeLanguage.JavaScript,
14
- expectedReturnType: functions_toolkit_1.ReturnType.uint256,
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
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, signerV5) {
21
- const chain = (0, configs_1.getChainConfig)(chainId);
22
- const network = chainlink_networks_config_1.default[chainId];
23
- if (!chain) {
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 (0, functions_toolkit_1.simulateScript)({
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: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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 = chain.rpcs?.[0] ?? chain.rpc ?? undefined;
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 ethers5_1.ethers.Contract(contractAddress, contractAbi, signerV5);
53
- const linkTokenAddress = network.linkToken;
54
- const functionsRouterAddress = network.functionsRouter;
55
- const subscriptionManager = new functions_toolkit_1.SubscriptionManager({
56
- // Use the v5 signer here (toolkit expects ethers v5 types)
57
- signer: signerV5,
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
- // Use the v5 provider for gas data (to avoid type mismatches)
77
- const { gasPrice } = await signerV5.provider.getFeeData();
68
+ const { gasPrice } = await signer.provider.getFeeData();
78
69
  // @ts-ignore
79
- const gasPriceWei = BigInt(Math.ceil(ethers5_1.ethers.utils.formatUnits(gasPrice, "wei").toString()));
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 = ethers5_1.ethers.utils.formatUnits(estimatedCostJuels.toString(), 18);
87
- const subBalanceLink = ethers5_1.ethers.utils.formatUnits(subInfo.balance.toString(), 18);
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 functions_toolkit_1.ResponseListener({
104
- provider: signerV5.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 ${network.name} to be confirmed...`);
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 = network.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 functions_toolkit_1.FulfillmentCode.FULFILLED:
113
+ case FulfillmentCode.FULFILLED:
123
114
  if (responseBytesHexstring !== "0x") {
124
- console.log(`Request ${requestId} fulfilled!\nResponse has been sent to consumer contract: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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 = ethers5_1.ethers.utils.formatUnits(totalCostInJuels.toString(), 18);
123
+ const linkCost = ethers_1.ethers.formatUnits(totalCostInJuels.toString(), 18);
133
124
  console.log(`Total request cost: ${linkCost + " LINK"}`);
134
125
  break;
135
- case functions_toolkit_1.FulfillmentCode.USER_CALLBACK_ERROR:
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 functions_toolkit_1.FulfillmentCode.COST_EXCEEDS_COMMITMENT:
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 functions_toolkit_1 = require("@chainlink/functions-toolkit");
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 (0, functions_toolkit_1.simulateScript)({
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: ${(0, functions_toolkit_1.decodeResult)(responseBytesHexstring, config_1.default.expectedReturnType).toString()}\n`);
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`);