@instadapp/interop-x 0.0.0-dev.75809ae → 0.0.0-dev.7adf1b5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/.env.example +2 -1
  2. package/dist/package.json +73 -0
  3. package/dist/src/abi/erc20.json +350 -0
  4. package/dist/src/abi/gnosisSafe.json +747 -0
  5. package/dist/src/abi/index.js +15 -0
  6. package/dist/src/abi/interopBridgeToken.json +298 -0
  7. package/dist/src/abi/interopXGateway.json +184 -0
  8. package/dist/src/api/index.js +36 -0
  9. package/dist/src/config/index.js +31 -0
  10. package/dist/src/constants/addresses.js +20 -0
  11. package/dist/{constants → src/constants}/index.js +2 -0
  12. package/dist/src/constants/itokens.js +13 -0
  13. package/dist/src/constants/tokens.js +107 -0
  14. package/dist/{db → src/db}/index.js +0 -0
  15. package/dist/{db → src/db}/models/index.js +1 -1
  16. package/dist/src/db/models/transaction.js +62 -0
  17. package/dist/{db → src/db}/sequelize.js +2 -1
  18. package/dist/src/gnosis/actions/deposit.js +48 -0
  19. package/dist/src/gnosis/actions/index.js +11 -0
  20. package/dist/src/gnosis/actions/withdraw.js +50 -0
  21. package/dist/src/gnosis/index.js +20 -0
  22. package/dist/src/index.js +130 -0
  23. package/dist/{logger → src/logger}/index.js +0 -0
  24. package/dist/{net → src/net}/index.js +0 -0
  25. package/dist/{net → src/net}/peer/index.js +13 -8
  26. package/dist/{net → src/net}/pool/index.js +34 -11
  27. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +1 -1
  28. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +17 -14
  29. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +28 -0
  30. package/dist/{net → src/net}/protocol/index.js +44 -4
  31. package/dist/src/tasks/AutoUpdateTask.js +70 -0
  32. package/dist/{tasks → src/tasks}/BaseTask.js +14 -6
  33. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +162 -0
  34. package/dist/src/tasks/InteropBridge/SyncBurnEvents.js +71 -0
  35. package/dist/src/tasks/InteropBridge/SyncMintEvents.js +67 -0
  36. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +164 -0
  37. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +74 -0
  38. package/dist/src/tasks/InteropXGateway/SyncWithdrawtEvents.js +72 -0
  39. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
  40. package/dist/src/tasks/index.js +55 -0
  41. package/dist/src/typechain/Erc20.js +2 -0
  42. package/dist/src/typechain/GnosisSafe.js +2 -0
  43. package/dist/src/typechain/InteropBridgeToken.js +2 -0
  44. package/dist/src/typechain/InteropXGateway.js +2 -0
  45. package/dist/src/typechain/common.js +2 -0
  46. package/dist/src/typechain/factories/Erc20__factory.js +367 -0
  47. package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
  48. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +471 -0
  49. package/dist/src/typechain/factories/InteropXGateway__factory.js +265 -0
  50. package/dist/src/typechain/factories/index.js +14 -0
  51. package/dist/src/typechain/index.js +35 -0
  52. package/dist/{types.js → src/types.js} +0 -0
  53. package/dist/src/utils/index.js +157 -0
  54. package/package.json +21 -7
  55. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  56. package/src/abi/erc20.json +350 -0
  57. package/src/abi/gnosisSafe.json +747 -0
  58. package/src/abi/index.ts +11 -0
  59. package/src/abi/interopBridgeToken.json +298 -0
  60. package/src/abi/interopXGateway.json +184 -0
  61. package/src/api/index.ts +36 -0
  62. package/src/config/index.ts +18 -2
  63. package/src/constants/addresses.ts +9 -2
  64. package/src/constants/index.ts +2 -0
  65. package/src/constants/itokens.ts +10 -0
  66. package/src/constants/tokens.ts +104 -0
  67. package/src/db/index.ts +1 -1
  68. package/src/db/models/index.ts +1 -1
  69. package/src/db/models/transaction.ts +106 -0
  70. package/src/db/sequelize.ts +2 -1
  71. package/src/gnosis/actions/deposit.ts +63 -0
  72. package/src/gnosis/actions/index.ts +7 -0
  73. package/src/gnosis/actions/withdraw.ts +67 -0
  74. package/src/gnosis/index.ts +19 -0
  75. package/src/index.ts +128 -6
  76. package/src/net/peer/index.ts +12 -10
  77. package/src/net/pool/index.ts +43 -13
  78. package/src/net/protocol/dial/BaseDialProtocol.ts +1 -1
  79. package/src/net/protocol/dial/SignatureDialProtocol.ts +20 -17
  80. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +31 -0
  81. package/src/net/protocol/index.ts +60 -4
  82. package/src/tasks/AutoUpdateTask.ts +82 -0
  83. package/src/tasks/BaseTask.ts +16 -7
  84. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +249 -0
  85. package/src/tasks/InteropBridge/SyncBurnEvents.ts +119 -0
  86. package/src/tasks/InteropBridge/SyncMintEvents.ts +99 -0
  87. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +260 -0
  88. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +124 -0
  89. package/src/tasks/InteropXGateway/SyncWithdrawtEvents.ts +105 -0
  90. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
  91. package/src/tasks/index.ts +45 -1
  92. package/src/typechain/Erc20.ts +491 -0
  93. package/src/typechain/GnosisSafe.ts +1728 -0
  94. package/src/typechain/InteropBridgeToken.ts +692 -0
  95. package/src/typechain/InteropXGateway.ts +407 -0
  96. package/src/typechain/common.ts +44 -0
  97. package/src/typechain/factories/Erc20__factory.ts +368 -0
  98. package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
  99. package/src/typechain/factories/InteropBridgeToken__factory.ts +478 -0
  100. package/src/typechain/factories/InteropXGateway__factory.ts +272 -0
  101. package/src/typechain/factories/index.ts +7 -0
  102. package/src/typechain/index.ts +12 -0
  103. package/src/types.ts +2 -2
  104. package/src/utils/index.ts +87 -5
  105. package/tsconfig.json +3 -0
  106. package/dist/config/index.js +0 -17
  107. package/dist/constants/addresses.js +0 -13
  108. package/dist/db/models/execution.js +0 -38
  109. package/dist/index.js +0 -34
  110. package/dist/tasks/index.js +0 -19
  111. package/dist/utils/index.js +0 -89
  112. package/src/db/models/execution.ts +0 -57
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ /* Autogenerated file. Do not edit manually. */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InteropXGateway__factory = void 0;
7
+ const ethers_1 = require("ethers");
8
+ const _abi = [
9
+ {
10
+ inputs: [
11
+ {
12
+ internalType: "address",
13
+ name: "__owner",
14
+ type: "address",
15
+ },
16
+ ],
17
+ stateMutability: "nonpayable",
18
+ type: "constructor",
19
+ },
20
+ {
21
+ anonymous: false,
22
+ inputs: [
23
+ {
24
+ indexed: false,
25
+ internalType: "address",
26
+ name: "user",
27
+ type: "address",
28
+ },
29
+ {
30
+ indexed: true,
31
+ internalType: "address",
32
+ name: "token",
33
+ type: "address",
34
+ },
35
+ {
36
+ indexed: false,
37
+ internalType: "uint256",
38
+ name: "amount",
39
+ type: "uint256",
40
+ },
41
+ {
42
+ indexed: true,
43
+ internalType: "uint256",
44
+ name: "vnonce",
45
+ type: "uint256",
46
+ },
47
+ {
48
+ indexed: false,
49
+ internalType: "uint32",
50
+ name: "sourceChainId",
51
+ type: "uint32",
52
+ },
53
+ {
54
+ indexed: true,
55
+ internalType: "uint32",
56
+ name: "targetChainId",
57
+ type: "uint32",
58
+ },
59
+ ],
60
+ name: "LogGatewayDeposit",
61
+ type: "event",
62
+ },
63
+ {
64
+ anonymous: false,
65
+ inputs: [
66
+ {
67
+ indexed: false,
68
+ internalType: "address",
69
+ name: "user",
70
+ type: "address",
71
+ },
72
+ {
73
+ indexed: true,
74
+ internalType: "address",
75
+ name: "token",
76
+ type: "address",
77
+ },
78
+ {
79
+ indexed: false,
80
+ internalType: "uint256",
81
+ name: "amount",
82
+ type: "uint256",
83
+ },
84
+ {
85
+ indexed: true,
86
+ internalType: "uint32",
87
+ name: "sourceChainId",
88
+ type: "uint32",
89
+ },
90
+ {
91
+ indexed: false,
92
+ internalType: "uint32",
93
+ name: "targetChainId",
94
+ type: "uint32",
95
+ },
96
+ {
97
+ indexed: true,
98
+ internalType: "bytes32",
99
+ name: "transactionHash",
100
+ type: "bytes32",
101
+ },
102
+ ],
103
+ name: "LogGatewayWithdraw",
104
+ type: "event",
105
+ },
106
+ {
107
+ anonymous: false,
108
+ inputs: [
109
+ {
110
+ indexed: true,
111
+ internalType: "address",
112
+ name: "previousOwner",
113
+ type: "address",
114
+ },
115
+ {
116
+ indexed: true,
117
+ internalType: "address",
118
+ name: "newOwner",
119
+ type: "address",
120
+ },
121
+ ],
122
+ name: "OwnershipTransferred",
123
+ type: "event",
124
+ },
125
+ {
126
+ inputs: [],
127
+ name: "_vnonce",
128
+ outputs: [
129
+ {
130
+ internalType: "uint256",
131
+ name: "",
132
+ type: "uint256",
133
+ },
134
+ ],
135
+ stateMutability: "view",
136
+ type: "function",
137
+ },
138
+ {
139
+ inputs: [
140
+ {
141
+ internalType: "address",
142
+ name: "token_",
143
+ type: "address",
144
+ },
145
+ {
146
+ internalType: "uint256",
147
+ name: "amount_",
148
+ type: "uint256",
149
+ },
150
+ {
151
+ internalType: "uint32",
152
+ name: "chainId_",
153
+ type: "uint32",
154
+ },
155
+ ],
156
+ name: "deposit",
157
+ outputs: [],
158
+ stateMutability: "nonpayable",
159
+ type: "function",
160
+ },
161
+ {
162
+ inputs: [
163
+ {
164
+ internalType: "address",
165
+ name: "to_",
166
+ type: "address",
167
+ },
168
+ {
169
+ internalType: "address",
170
+ name: "token_",
171
+ type: "address",
172
+ },
173
+ {
174
+ internalType: "uint256",
175
+ name: "amount_",
176
+ type: "uint256",
177
+ },
178
+ {
179
+ internalType: "uint32",
180
+ name: "chainId_",
181
+ type: "uint32",
182
+ },
183
+ ],
184
+ name: "depositFor",
185
+ outputs: [],
186
+ stateMutability: "nonpayable",
187
+ type: "function",
188
+ },
189
+ {
190
+ inputs: [],
191
+ name: "owner",
192
+ outputs: [
193
+ {
194
+ internalType: "address",
195
+ name: "",
196
+ type: "address",
197
+ },
198
+ ],
199
+ stateMutability: "view",
200
+ type: "function",
201
+ },
202
+ {
203
+ inputs: [],
204
+ name: "renounceOwnership",
205
+ outputs: [],
206
+ stateMutability: "nonpayable",
207
+ type: "function",
208
+ },
209
+ {
210
+ inputs: [
211
+ {
212
+ internalType: "uint256",
213
+ name: "amount_",
214
+ type: "uint256",
215
+ },
216
+ {
217
+ internalType: "address",
218
+ name: "user_",
219
+ type: "address",
220
+ },
221
+ {
222
+ internalType: "address",
223
+ name: "token_",
224
+ type: "address",
225
+ },
226
+ {
227
+ internalType: "uint32",
228
+ name: "chainId_",
229
+ type: "uint32",
230
+ },
231
+ {
232
+ internalType: "bytes32",
233
+ name: "transactionHash_",
234
+ type: "bytes32",
235
+ },
236
+ ],
237
+ name: "systemWithdraw",
238
+ outputs: [],
239
+ stateMutability: "nonpayable",
240
+ type: "function",
241
+ },
242
+ {
243
+ inputs: [
244
+ {
245
+ internalType: "address",
246
+ name: "newOwner",
247
+ type: "address",
248
+ },
249
+ ],
250
+ name: "transferOwnership",
251
+ outputs: [],
252
+ stateMutability: "nonpayable",
253
+ type: "function",
254
+ },
255
+ ];
256
+ class InteropXGateway__factory {
257
+ static createInterface() {
258
+ return new ethers_1.utils.Interface(_abi);
259
+ }
260
+ static connect(address, signerOrProvider) {
261
+ return new ethers_1.Contract(address, _abi, signerOrProvider);
262
+ }
263
+ }
264
+ exports.InteropXGateway__factory = InteropXGateway__factory;
265
+ InteropXGateway__factory.abi = _abi;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteropXGateway__factory = exports.InteropBridgeToken__factory = exports.GnosisSafe__factory = exports.Erc20__factory = void 0;
4
+ /* Autogenerated file. Do not edit manually. */
5
+ /* tslint:disable */
6
+ /* eslint-disable */
7
+ var Erc20__factory_1 = require("./Erc20__factory");
8
+ Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
9
+ var GnosisSafe__factory_1 = require("./GnosisSafe__factory");
10
+ Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
11
+ var InteropBridgeToken__factory_1 = require("./InteropBridgeToken__factory");
12
+ Object.defineProperty(exports, "InteropBridgeToken__factory", { enumerable: true, get: function () { return InteropBridgeToken__factory_1.InteropBridgeToken__factory; } });
13
+ var InteropXGateway__factory_1 = require("./InteropXGateway__factory");
14
+ Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.InteropXGateway__factory = exports.InteropBridgeToken__factory = exports.GnosisSafe__factory = exports.Erc20__factory = exports.factories = void 0;
27
+ exports.factories = __importStar(require("./factories"));
28
+ var Erc20__factory_1 = require("./factories/Erc20__factory");
29
+ Object.defineProperty(exports, "Erc20__factory", { enumerable: true, get: function () { return Erc20__factory_1.Erc20__factory; } });
30
+ var GnosisSafe__factory_1 = require("./factories/GnosisSafe__factory");
31
+ Object.defineProperty(exports, "GnosisSafe__factory", { enumerable: true, get: function () { return GnosisSafe__factory_1.GnosisSafe__factory; } });
32
+ var InteropBridgeToken__factory_1 = require("./factories/InteropBridgeToken__factory");
33
+ Object.defineProperty(exports, "InteropBridgeToken__factory", { enumerable: true, get: function () { return InteropBridgeToken__factory_1.InteropBridgeToken__factory; } });
34
+ var InteropXGateway__factory_1 = require("./factories/InteropXGateway__factory");
35
+ Object.defineProperty(exports, "InteropXGateway__factory", { enumerable: true, get: function () { return InteropXGateway__factory_1.InteropXGateway__factory; } });
File without changes
@@ -0,0 +1,157 @@
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.getContract = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
7
+ /**
8
+ * @module util
9
+ */
10
+ const axios_1 = __importDefault(require("axios"));
11
+ const axios_retry_1 = __importDefault(require("axios-retry"));
12
+ const constants_1 = require("@/constants");
13
+ const ethers_1 = require("ethers");
14
+ exports.http = axios_1.default.create();
15
+ (0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
16
+ function shortenHash(hash, length = 4) {
17
+ if (!hash)
18
+ return;
19
+ if (hash.length < 12)
20
+ return hash;
21
+ const beginningChars = hash.startsWith("0x") ? length + 2 : length;
22
+ const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
23
+ return shortened;
24
+ }
25
+ exports.shortenHash = shortenHash;
26
+ function short(buffer) {
27
+ return buffer.toString('hex').slice(0, 8) + '...';
28
+ }
29
+ exports.short = short;
30
+ const signGnosisSafeTx = async ({ to, data = null, value = '0', operation = '1', baseGas = '0', gasPrice = "0", gasToken = "0x0000000000000000000000000000000000000000", refundReceiver = "0x0000000000000000000000000000000000000000", safeTxGas = "79668", nonce = "0", chainId = 137, }, { signer }) => {
31
+ const gnosisSafe = constants_1.addresses[chainId].gnosisSafe;
32
+ const domain = {
33
+ verifyingContract: gnosisSafe,
34
+ chainId,
35
+ };
36
+ const types = {
37
+ SafeTx: [
38
+ { type: 'address', name: 'to' },
39
+ { type: 'uint256', name: 'value' },
40
+ { type: 'bytes', name: 'data' },
41
+ { type: 'uint8', name: 'operation' },
42
+ { type: 'uint256', name: 'safeTxGas' },
43
+ { type: 'uint256', name: 'baseGas' },
44
+ { type: 'uint256', name: 'gasPrice' },
45
+ { type: 'address', name: 'gasToken' },
46
+ { type: 'address', name: 'refundReceiver' },
47
+ { type: 'uint256', name: 'nonce' },
48
+ ],
49
+ };
50
+ const message = {
51
+ baseGas,
52
+ data,
53
+ gasPrice,
54
+ gasToken,
55
+ nonce: Number(nonce),
56
+ operation,
57
+ refundReceiver,
58
+ safeAddress: gnosisSafe,
59
+ safeTxGas: String(safeTxGas),
60
+ to,
61
+ value,
62
+ };
63
+ return await signer._signTypedData(domain, types, message);
64
+ };
65
+ exports.signGnosisSafeTx = signGnosisSafeTx;
66
+ const getRpcProviderUrl = (chainId) => {
67
+ switch (chainId) {
68
+ case 1:
69
+ return 'https://rpc.ankr.com/eth';
70
+ case 137:
71
+ return 'https://rpc.ankr.com/polygon';
72
+ case 43114:
73
+ return 'https://rpc.ankr.com/avalanche';
74
+ default:
75
+ throw new Error(`Unknown chainId: ${chainId}`);
76
+ }
77
+ };
78
+ exports.getRpcProviderUrl = getRpcProviderUrl;
79
+ const buildSignatureBytes = (signatures) => {
80
+ signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
81
+ let signatureBytes = "0x";
82
+ for (const sig of signatures) {
83
+ signatureBytes += sig.data.slice(2);
84
+ }
85
+ return signatureBytes;
86
+ };
87
+ exports.buildSignatureBytes = buildSignatureBytes;
88
+ /**
89
+ * Call an async function with a maximum time limit (in milliseconds) for the timeout
90
+ * Resolved promise for async function call, or an error if time limit reached
91
+ */
92
+ const asyncCallWithTimeout = async (asyncPromise, timeout) => {
93
+ let timeoutHandle;
94
+ const timeoutPromise = new Promise((_resolve, reject) => {
95
+ timeoutHandle = setTimeout(() => reject(new Error('Async call timeout limit reached')), timeout);
96
+ });
97
+ return Promise.race([asyncPromise, timeoutPromise]).then(result => {
98
+ clearTimeout(timeoutHandle);
99
+ return result;
100
+ });
101
+ };
102
+ exports.asyncCallWithTimeout = asyncCallWithTimeout;
103
+ const generateInteropTransactionHash = (data) => {
104
+ return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
105
+ String(data.action),
106
+ String(data.submitTransactionHash),
107
+ String(data.sourceChainId),
108
+ String(data.targetChainId),
109
+ ]);
110
+ };
111
+ exports.generateInteropTransactionHash = generateInteropTransactionHash;
112
+ function getContract(address, contractInterface, signerOrProvider) {
113
+ if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
114
+ throw Error(`Invalid 'address' parameter '${address}'.`);
115
+ }
116
+ const contract = new ethers_1.ethers.Contract(address, contractInterface, signerOrProvider);
117
+ // Make sure the contract properties is writable
118
+ const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
119
+ if (!desc || desc.writable !== true) {
120
+ return contract;
121
+ }
122
+ return new Proxy(contract, {
123
+ get(target, prop, receiver) {
124
+ const value = Reflect.get(target, prop, receiver);
125
+ if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
126
+ return async (...args) => {
127
+ try {
128
+ return await value.bind(contract)(...args);
129
+ }
130
+ catch (error) {
131
+ throw new Error(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`);
132
+ }
133
+ };
134
+ }
135
+ if (typeof value === 'object' && ['populateTransaction', 'estimateGas', 'functions', 'callStatic'].includes(String(prop))) {
136
+ const parentProp = String(prop);
137
+ return new Proxy(value, {
138
+ get(target, prop, receiver) {
139
+ const value = Reflect.get(target, prop, receiver);
140
+ if (typeof value === 'function') {
141
+ return async (...args) => {
142
+ try {
143
+ return await value.bind(contract)(...args);
144
+ }
145
+ catch (error) {
146
+ throw new Error(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`);
147
+ }
148
+ };
149
+ }
150
+ }
151
+ });
152
+ }
153
+ return value;
154
+ },
155
+ });
156
+ }
157
+ exports.getContract = getContract;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.75809ae",
3
+ "version": "0.0.0-dev.7adf1b5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -9,9 +9,11 @@
9
9
  },
10
10
  "scripts": {
11
11
  "start": "yarn build && node bin/interop-x",
12
- "build": "export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/src/**/*.js",
13
- "dev": "NODE_ENV=development nodemon",
14
- "prepublishOnly": "yarn build"
12
+ "build": "yarn generate-abi-types && export GIT_REF=$(git rev-parse --short HEAD) && rimraf ./dist && tsc -p tsconfig.json && replace-in-file '@GIT_SHORT_HASH@' $GIT_REF ./dist/**/*.js",
13
+ "dev": "yarn generate-abi-types && NODE_ENV=development nodemon",
14
+ "generate-abi-types": "typechain --target=ethers-v5 'src/abi/*.json' --out-dir 'src/typechain'",
15
+ "prepublishOnly": "yarn build",
16
+ "postinstall": "patch-package"
15
17
  },
16
18
  "nodemonConfig": {
17
19
  "watch": [
@@ -22,14 +24,18 @@
22
24
  },
23
25
  "dependencies": {
24
26
  "@achingbrain/libp2p-gossipsub": "^0.12.2",
27
+ "@fastify/cors": "^7.0.0",
28
+ "await-spawn": "^4.0.2",
25
29
  "axios": "^0.27.1",
26
30
  "axios-retry": "^3.2.4",
27
- "bignumber.js": "^9.0.2",
28
31
  "chalk": "4.1.2",
29
32
  "dotenv": "^16.0.0",
30
33
  "ethereumjs-util": "^7.1.4",
31
34
  "ethers": "^5.6.4",
32
35
  "ethers-multisend": "^2.1.1",
36
+ "expand-home-dir": "^0.0.3",
37
+ "fastify": "^3.28.0",
38
+ "fs-extra": "^10.1.0",
33
39
  "libp2p": "^0.36.2",
34
40
  "libp2p-bootstrap": "^0.14.0",
35
41
  "libp2p-kad-dht": "^0.28.6",
@@ -40,13 +46,20 @@
40
46
  "libp2p-tcp": "^0.17.2",
41
47
  "libp2p-websockets": "^0.16.2",
42
48
  "luxon": "^2.3.2",
43
- "sequelize": "^6.19.0",
49
+ "module-alias": "^2.2.2",
50
+ "patch-package": "^6.4.7",
51
+ "postinstall-postinstall": "^2.1.0",
52
+ "sequelize": "6.18.0",
53
+ "sqlite3": "^5.0.5",
44
54
  "waait": "^1.0.5"
45
55
  },
46
56
  "bin": {
47
- "interop-node": "bin/interop-x"
57
+ "interop-x": "bin/interop-x",
58
+ "interopx": "bin/interop-x"
48
59
  },
49
60
  "devDependencies": {
61
+ "@typechain/ethers-v5": "^10.0.0",
62
+ "@types/bn.js": "^5.1.0",
50
63
  "@types/fs-extra": "^9.0.13",
51
64
  "@types/node": "^17.0.17",
52
65
  "nodemon": "^2.0.15",
@@ -54,6 +67,7 @@
54
67
  "rimraf": "^3.0.2",
55
68
  "ts-node": "^10.5.0",
56
69
  "tsconfig-paths": "^3.12.0",
70
+ "typechain": "^8.0.0",
57
71
  "typescript": "^4.5.5"
58
72
  }
59
73
  }
@@ -0,0 +1,13 @@
1
+ diff --git a/node_modules/@ethersproject/properties/lib/index.js b/node_modules/@ethersproject/properties/lib/index.js
2
+ index 41e0b52..4c7a9e3 100644
3
+ --- a/node_modules/@ethersproject/properties/lib/index.js
4
+ +++ b/node_modules/@ethersproject/properties/lib/index.js
5
+ @@ -44,7 +44,7 @@ function defineReadOnly(object, name, value) {
6
+ Object.defineProperty(object, name, {
7
+ enumerable: true,
8
+ value: value,
9
+ - writable: false,
10
+ + writable: true,
11
+ });
12
+ }
13
+ exports.defineReadOnly = defineReadOnly;