@reyaxyz/sdk 0.15.1 → 0.16.0
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/services/executeTransaction.js +6 -18
- package/dist/services/executeTransaction.js.map +1 -1
- package/dist/types/services/executeTransaction.d.ts.map +1 -1
- package/dist/utils/contractAddresses.js +2 -2
- package/dist/utils/contractAddresses.js.map +1 -1
- package/package.json +3 -3
- package/src/services/executeTransaction.ts +1 -10
- package/src/utils/contractAddresses.ts +2 -2
|
@@ -48,12 +48,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.executeTransaction = exports.estimateGas = void 0;
|
|
51
|
-
var txHelpers_1 = require("../utils/txHelpers");
|
|
52
51
|
var contractAddresses_1 = require("../utils/contractAddresses");
|
|
53
52
|
var consts_1 = require("../utils/consts");
|
|
54
53
|
function estimateGas(signer, data, value, chainId, transactionType) {
|
|
55
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var accountAddress, contractAddress, tx, gasLimit
|
|
55
|
+
var accountAddress, contractAddress, tx, gasLimit;
|
|
57
56
|
return __generator(this, function (_a) {
|
|
58
57
|
switch (_a.label) {
|
|
59
58
|
case 0: return [4 /*yield*/, signer.getAddress()];
|
|
@@ -63,19 +62,8 @@ function estimateGas(signer, data, value, chainId, transactionType) {
|
|
|
63
62
|
? (0, contractAddresses_1.getAddress)(chainId, 'passive_pool_proxy')
|
|
64
63
|
: (0, contractAddresses_1.getAddress)(chainId, 'core_proxy');
|
|
65
64
|
tx = __assign({ from: accountAddress, to: contractAddress, data: data }, (value && value !== '0' ? { value: value } : {}));
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
_a.trys.push([2, 4, , 5]);
|
|
69
|
-
return [4 /*yield*/, signer.estimateGas(tx)];
|
|
70
|
-
case 3:
|
|
71
|
-
gasEstimate = _a.sent();
|
|
72
|
-
gasLimit = (0, txHelpers_1.getGasBuffer)(gasEstimate);
|
|
73
|
-
return [3 /*break*/, 5];
|
|
74
|
-
case 4:
|
|
75
|
-
error_1 = _a.sent();
|
|
76
|
-
console.warn(error_1);
|
|
77
|
-
throw new Error(error_1);
|
|
78
|
-
case 5: return [2 /*return*/, __assign(__assign({}, tx), { gasLimit: gasLimit })];
|
|
65
|
+
gasLimit = BigInt('5000000');
|
|
66
|
+
return [2 /*return*/, __assign(__assign({}, tx), { gasLimit: gasLimit })];
|
|
79
67
|
}
|
|
80
68
|
});
|
|
81
69
|
});
|
|
@@ -83,7 +71,7 @@ function estimateGas(signer, data, value, chainId, transactionType) {
|
|
|
83
71
|
exports.estimateGas = estimateGas;
|
|
84
72
|
function executeTransaction(signer, data, value, chainId, transactionType) {
|
|
85
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var txData, txResponse, txReceipt,
|
|
74
|
+
var txData, txResponse, txReceipt, error_1;
|
|
87
75
|
return __generator(this, function (_a) {
|
|
88
76
|
switch (_a.label) {
|
|
89
77
|
case 0: return [4 /*yield*/, estimateGas(signer, data, value, chainId, transactionType)];
|
|
@@ -100,8 +88,8 @@ function executeTransaction(signer, data, value, chainId, transactionType) {
|
|
|
100
88
|
txReceipt = _a.sent();
|
|
101
89
|
return [2 /*return*/, txReceipt];
|
|
102
90
|
case 5:
|
|
103
|
-
|
|
104
|
-
console.warn(
|
|
91
|
+
error_1 = _a.sent();
|
|
92
|
+
console.warn(error_1);
|
|
105
93
|
throw new Error('Transaction Execution Error');
|
|
106
94
|
case 6: return [2 /*return*/];
|
|
107
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeTransaction.js","sourceRoot":"/","sources":["services/executeTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"executeTransaction.js","sourceRoot":"/","sources":["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,CAAC;oBACpB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;;;;;CAElD;AAtBD,gDAsBC","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport { getAddress } from '../utils/contractAddresses';\nimport { TransactionType } from '../utils/consts';\n\nexport type Transaction = {\n from: string;\n to: string;\n data: string;\n value?: string;\n};\n\nexport async function estimateGas(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n transactionType: TransactionType,\n): Promise<Transaction & { gasLimit: bigint }> {\n const accountAddress = await signer.getAddress();\n const contractAddress =\n transactionType === TransactionType.LP\n ? getAddress(chainId, 'passive_pool_proxy')\n : getAddress(chainId, 'core_proxy');\n const tx = {\n from: accountAddress,\n to: contractAddress,\n data,\n ...(value && value !== '0' ? { value: value } : {}),\n };\n\n const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit\n return { ...tx, gasLimit };\n}\n\nexport async function executeTransaction(\n signer: Signer | JsonRpcSigner,\n data: string,\n value: string,\n chainId: number,\n transactionType: TransactionType,\n) {\n const txData = await estimateGas(\n signer,\n data,\n value,\n chainId,\n transactionType,\n );\n try {\n const txResponse = await signer.sendTransaction(txData);\n const txReceipt = await txResponse.wait();\n return txReceipt;\n } catch (error) {\n console.warn(error);\n throw new Error('Transaction Execution Error');\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executeTransaction.d.ts","sourceRoot":"/","sources":["services/executeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"executeTransaction.d.ts","sourceRoot":"/","sources":["services/executeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,GAAG,aAAa,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,eAAe,GAC/B,OAAO,CAAC,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAe7C;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,GAAG,aAAa,EAC9B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,eAAe,uDAiBjC"}
|
|
@@ -10,8 +10,8 @@ var addresses = (_a = {},
|
|
|
10
10
|
passive_pool_proxy: '0x1b9d499f3ac864b8d4da415846d1d1916e00a6ff',
|
|
11
11
|
},
|
|
12
12
|
_a[common_1.ReyaChainId.reyaCronos] = {
|
|
13
|
-
core_proxy: '
|
|
14
|
-
passive_pool_proxy: '
|
|
13
|
+
core_proxy: '0x141a7e35a22688c8e8f429da47e246f3896c5af8',
|
|
14
|
+
passive_pool_proxy: '0x730ea458b8b2d2fdf15406829c4106a12775bae0',
|
|
15
15
|
},
|
|
16
16
|
// TODO: add proper config
|
|
17
17
|
_a[common_1.ReyaChainId.reyaNetwork] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["utils/contractAddresses.ts"],"names":[],"mappings":";;;;AACA,+CAA+C;AAC/C,0CAA8C;AAI9C,IAAM,SAAS;IACb,GAAC,oBAAW,CAAC,aAAa,IAAG;QAC3B,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;IACD,GAAC,oBAAW,CAAC,UAAU,IAAG;QACxB,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;IACD,0BAA0B;IAC1B,GAAC,oBAAW,CAAC,WAAW,IAAG;QACzB,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,OAAO,6CAAsC,UAAU,CAAE,CAAC;IAC5D,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,OAAO,kCAA2B,YAAY,cAAW,CAAC;IAC5D,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["export type Address = Lowercase<string>;\n// @todo update with proper chainId for mainnet\nimport { ReyaChainId } from '@reyaxyz/common';\n\nexport type ContractType = 'core_proxy' | 'passive_pool_proxy';\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.polygonMumbai]: {\n core_proxy: '0xc2f1b4a1275b7338e0eb03967fea3858af4bc900',\n passive_pool_proxy: '0x1b9d499f3ac864b8d4da415846d1d1916e00a6ff',\n },\n [ReyaChainId.reyaCronos]: {\n core_proxy: '
|
|
1
|
+
{"version":3,"file":"contractAddresses.js","sourceRoot":"/","sources":["utils/contractAddresses.ts"],"names":[],"mappings":";;;;AACA,+CAA+C;AAC/C,0CAA8C;AAI9C,IAAM,SAAS;IACb,GAAC,oBAAW,CAAC,aAAa,IAAG;QAC3B,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;IACD,GAAC,oBAAW,CAAC,UAAU,IAAG;QACxB,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;IACD,0BAA0B;IAC1B,GAAC,oBAAW,CAAC,WAAW,IAAG;QACzB,UAAU,EAAE,4CAA4C;QACxD,kBAAkB,EAAE,4CAA4C;KACjE;OACF,CAAC;AACK,IAAM,UAAU,GAAG,UACxB,OAAe,EACf,YAA0B;IAE1B,IAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAEtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QACjD,OAAO,6CAAsC,UAAU,CAAE,CAAC;IAC5D,CAAC;IAED,IAAM,gBAAgB,GAAG,SAAS,CAAC,OAAsB,CAAC,CAAC;IAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1D,OAAO,kCAA2B,YAAY,cAAW,CAAC;IAC5D,CAAC;IAED,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACxC,CAAC,CAAC;AAhBW,QAAA,UAAU,cAgBrB","sourcesContent":["export type Address = Lowercase<string>;\n// @todo update with proper chainId for mainnet\nimport { ReyaChainId } from '@reyaxyz/common';\n\nexport type ContractType = 'core_proxy' | 'passive_pool_proxy';\n\nconst addresses: Record<ReyaChainId, Record<ContractType, Address>> = {\n [ReyaChainId.polygonMumbai]: {\n core_proxy: '0xc2f1b4a1275b7338e0eb03967fea3858af4bc900',\n passive_pool_proxy: '0x1b9d499f3ac864b8d4da415846d1d1916e00a6ff',\n },\n [ReyaChainId.reyaCronos]: {\n core_proxy: '0x141a7e35a22688c8e8f429da47e246f3896c5af8',\n passive_pool_proxy: '0x730ea458b8b2d2fdf15406829c4106a12775bae0',\n },\n // TODO: add proper config\n [ReyaChainId.reyaNetwork]: {\n core_proxy: '0x2cb06a22ee9b823a307d22f131380dbe151ece5f',\n passive_pool_proxy: '0x63df38878c5b8e84d7dcb347b934072add64bdc5',\n },\n};\nexport const getAddress = (\n chainId: number,\n contractName: ContractType,\n): string => {\n const keyChainId = chainId.toString();\n\n if (!Object.keys(addresses).includes(keyChainId)) {\n return `Unspecified addresses for chain id ${keyChainId}`;\n }\n\n const networkAddresses = addresses[chainId as ReyaChainId];\n if (!Object.keys(networkAddresses).includes(contractName)) {\n return `Unspecified address for ${contractName} contract`;\n }\n\n return networkAddresses[contractName];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@reyaxyz/common": "0.4.
|
|
32
|
+
"@reyaxyz/common": "0.4.2",
|
|
33
33
|
"bignumber.js": "^9.1.2",
|
|
34
34
|
"ethers": "6.9.0"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@8.10.4",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "b2aa9f1bbbed79a64b13a4adfca83a33548373f2"
|
|
38
38
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
|
-
import { getGasBuffer } from '../utils/txHelpers';
|
|
3
2
|
import { getAddress } from '../utils/contractAddresses';
|
|
4
3
|
import { TransactionType } from '../utils/consts';
|
|
5
4
|
|
|
@@ -29,15 +28,7 @@ export async function estimateGas(
|
|
|
29
28
|
...(value && value !== '0' ? { value: value } : {}),
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const gasEstimate = await signer.estimateGas(tx);
|
|
36
|
-
gasLimit = getGasBuffer(gasEstimate);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.warn(error);
|
|
39
|
-
throw new Error(error as string);
|
|
40
|
-
}
|
|
31
|
+
const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit
|
|
41
32
|
return { ...tx, gasLimit };
|
|
42
33
|
}
|
|
43
34
|
|
|
@@ -10,8 +10,8 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
10
10
|
passive_pool_proxy: '0x1b9d499f3ac864b8d4da415846d1d1916e00a6ff',
|
|
11
11
|
},
|
|
12
12
|
[ReyaChainId.reyaCronos]: {
|
|
13
|
-
core_proxy: '
|
|
14
|
-
passive_pool_proxy: '
|
|
13
|
+
core_proxy: '0x141a7e35a22688c8e8f429da47e246f3896c5af8',
|
|
14
|
+
passive_pool_proxy: '0x730ea458b8b2d2fdf15406829c4106a12775bae0',
|
|
15
15
|
},
|
|
16
16
|
// TODO: add proper config
|
|
17
17
|
[ReyaChainId.reyaNetwork]: {
|