@instadapp/interop-x 0.0.0-dev.ef78459 → 0.0.0-dev.f0a6281

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 (98) hide show
  1. package/.env.example +2 -1
  2. package/bin/interop-x +1 -1
  3. package/dist/package.json +73 -0
  4. package/dist/src/abi/erc20.json +350 -0
  5. package/dist/src/abi/gnosisSafe.json +747 -0
  6. package/dist/src/abi/index.js +15 -0
  7. package/dist/src/abi/interopBridgeToken.json +298 -0
  8. package/dist/src/abi/interopXGateway.json +184 -0
  9. package/dist/src/api/index.js +33 -0
  10. package/dist/src/config/index.js +31 -0
  11. package/dist/src/constants/addresses.js +20 -0
  12. package/dist/{constants → src/constants}/index.js +2 -0
  13. package/dist/src/constants/itokens.js +13 -0
  14. package/dist/src/constants/tokens.js +107 -0
  15. package/dist/{db → src/db}/index.js +0 -0
  16. package/dist/{db → src/db}/models/index.js +1 -1
  17. package/dist/src/db/models/transaction.js +54 -0
  18. package/dist/{db → src/db}/sequelize.js +2 -1
  19. package/dist/src/index.js +130 -0
  20. package/dist/{logger → src/logger}/index.js +0 -0
  21. package/dist/{net → src/net}/index.js +0 -0
  22. package/dist/{net → src/net}/peer/index.js +8 -3
  23. package/dist/{net → src/net}/pool/index.js +32 -9
  24. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
  25. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +20 -12
  26. package/dist/src/net/protocol/dial/TransactionStatusDialProtocol.js +28 -0
  27. package/dist/{net → src/net}/protocol/index.js +44 -4
  28. package/dist/src/tasks/AutoUpdateTask.js +70 -0
  29. package/dist/{tasks → src/tasks}/BaseTask.js +13 -5
  30. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +146 -0
  31. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +71 -0
  32. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +161 -0
  33. package/dist/src/tasks/InteropXGateway/SyncDepositEvents.js +74 -0
  34. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
  35. package/dist/src/tasks/index.js +44 -0
  36. package/dist/src/typechain/Erc20.js +2 -0
  37. package/dist/src/typechain/GnosisSafe.js +2 -0
  38. package/dist/src/typechain/InteropBridgeToken.js +2 -0
  39. package/dist/src/typechain/InteropXGateway.js +2 -0
  40. package/dist/src/typechain/common.js +2 -0
  41. package/dist/src/typechain/factories/Erc20__factory.js +367 -0
  42. package/dist/src/typechain/factories/GnosisSafe__factory.js +1174 -0
  43. package/dist/src/typechain/factories/InteropBridgeToken__factory.js +471 -0
  44. package/dist/src/typechain/factories/InteropXGateway__factory.js +265 -0
  45. package/dist/src/typechain/factories/index.js +14 -0
  46. package/dist/src/typechain/index.js +35 -0
  47. package/dist/{types.js → src/types.js} +0 -0
  48. package/dist/src/utils/index.js +238 -0
  49. package/package.json +18 -10
  50. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  51. package/src/abi/erc20.json +350 -0
  52. package/src/abi/gnosisSafe.json +747 -0
  53. package/src/abi/index.ts +11 -0
  54. package/src/abi/interopBridgeToken.json +298 -0
  55. package/src/abi/interopXGateway.json +184 -0
  56. package/src/api/index.ts +33 -0
  57. package/src/config/index.ts +17 -1
  58. package/src/constants/addresses.ts +9 -2
  59. package/src/constants/index.ts +2 -0
  60. package/src/constants/itokens.ts +10 -0
  61. package/src/constants/tokens.ts +104 -0
  62. package/src/db/models/index.ts +1 -1
  63. package/src/db/models/transaction.ts +96 -0
  64. package/src/db/sequelize.ts +2 -1
  65. package/src/index.ts +119 -7
  66. package/src/net/peer/index.ts +9 -7
  67. package/src/net/pool/index.ts +41 -11
  68. package/src/net/protocol/dial/SignatureDialProtocol.ts +24 -15
  69. package/src/net/protocol/dial/TransactionStatusDialProtocol.ts +31 -0
  70. package/src/net/protocol/index.ts +60 -4
  71. package/src/tasks/AutoUpdateTask.ts +82 -0
  72. package/src/tasks/BaseTask.ts +15 -6
  73. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +231 -0
  74. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +121 -0
  75. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +256 -0
  76. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +124 -0
  77. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
  78. package/src/tasks/index.ts +26 -1
  79. package/src/typechain/Erc20.ts +491 -0
  80. package/src/typechain/GnosisSafe.ts +1728 -0
  81. package/src/typechain/InteropBridgeToken.ts +692 -0
  82. package/src/typechain/InteropXGateway.ts +407 -0
  83. package/src/typechain/common.ts +44 -0
  84. package/src/typechain/factories/Erc20__factory.ts +368 -0
  85. package/src/typechain/factories/GnosisSafe__factory.ts +1178 -0
  86. package/src/typechain/factories/InteropBridgeToken__factory.ts +478 -0
  87. package/src/typechain/factories/InteropXGateway__factory.ts +272 -0
  88. package/src/typechain/factories/index.ts +7 -0
  89. package/src/typechain/index.ts +12 -0
  90. package/src/types.ts +1 -1
  91. package/src/utils/index.ts +206 -3
  92. package/dist/config/index.js +0 -17
  93. package/dist/constants/addresses.js +0 -13
  94. package/dist/db/models/execution.js +0 -38
  95. package/dist/index.js +0 -43
  96. package/dist/tasks/index.js +0 -19
  97. package/dist/utils/index.js +0 -89
  98. package/src/db/models/execution.ts +0 -57
@@ -0,0 +1,272 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import { Contract, Signer, utils } from "ethers";
6
+ import type { Provider } from "@ethersproject/providers";
7
+ import type {
8
+ InteropXGateway,
9
+ InteropXGatewayInterface,
10
+ } from "../InteropXGateway";
11
+
12
+ const _abi = [
13
+ {
14
+ inputs: [
15
+ {
16
+ internalType: "address",
17
+ name: "__owner",
18
+ type: "address",
19
+ },
20
+ ],
21
+ stateMutability: "nonpayable",
22
+ type: "constructor",
23
+ },
24
+ {
25
+ anonymous: false,
26
+ inputs: [
27
+ {
28
+ indexed: false,
29
+ internalType: "address",
30
+ name: "user",
31
+ type: "address",
32
+ },
33
+ {
34
+ indexed: true,
35
+ internalType: "address",
36
+ name: "token",
37
+ type: "address",
38
+ },
39
+ {
40
+ indexed: false,
41
+ internalType: "uint256",
42
+ name: "amount",
43
+ type: "uint256",
44
+ },
45
+ {
46
+ indexed: true,
47
+ internalType: "uint256",
48
+ name: "vnonce",
49
+ type: "uint256",
50
+ },
51
+ {
52
+ indexed: false,
53
+ internalType: "uint32",
54
+ name: "sourceChainId",
55
+ type: "uint32",
56
+ },
57
+ {
58
+ indexed: true,
59
+ internalType: "uint32",
60
+ name: "targetChainId",
61
+ type: "uint32",
62
+ },
63
+ ],
64
+ name: "LogGatewayDeposit",
65
+ type: "event",
66
+ },
67
+ {
68
+ anonymous: false,
69
+ inputs: [
70
+ {
71
+ indexed: false,
72
+ internalType: "address",
73
+ name: "user",
74
+ type: "address",
75
+ },
76
+ {
77
+ indexed: true,
78
+ internalType: "address",
79
+ name: "token",
80
+ type: "address",
81
+ },
82
+ {
83
+ indexed: false,
84
+ internalType: "uint256",
85
+ name: "amount",
86
+ type: "uint256",
87
+ },
88
+ {
89
+ indexed: true,
90
+ internalType: "uint32",
91
+ name: "sourceChainId",
92
+ type: "uint32",
93
+ },
94
+ {
95
+ indexed: false,
96
+ internalType: "uint32",
97
+ name: "targetChainId",
98
+ type: "uint32",
99
+ },
100
+ {
101
+ indexed: true,
102
+ internalType: "bytes32",
103
+ name: "transactionHash",
104
+ type: "bytes32",
105
+ },
106
+ ],
107
+ name: "LogGatewayWithdraw",
108
+ type: "event",
109
+ },
110
+ {
111
+ anonymous: false,
112
+ inputs: [
113
+ {
114
+ indexed: true,
115
+ internalType: "address",
116
+ name: "previousOwner",
117
+ type: "address",
118
+ },
119
+ {
120
+ indexed: true,
121
+ internalType: "address",
122
+ name: "newOwner",
123
+ type: "address",
124
+ },
125
+ ],
126
+ name: "OwnershipTransferred",
127
+ type: "event",
128
+ },
129
+ {
130
+ inputs: [],
131
+ name: "_vnonce",
132
+ outputs: [
133
+ {
134
+ internalType: "uint256",
135
+ name: "",
136
+ type: "uint256",
137
+ },
138
+ ],
139
+ stateMutability: "view",
140
+ type: "function",
141
+ },
142
+ {
143
+ inputs: [
144
+ {
145
+ internalType: "address",
146
+ name: "token_",
147
+ type: "address",
148
+ },
149
+ {
150
+ internalType: "uint256",
151
+ name: "amount_",
152
+ type: "uint256",
153
+ },
154
+ {
155
+ internalType: "uint32",
156
+ name: "chainId_",
157
+ type: "uint32",
158
+ },
159
+ ],
160
+ name: "deposit",
161
+ outputs: [],
162
+ stateMutability: "nonpayable",
163
+ type: "function",
164
+ },
165
+ {
166
+ inputs: [
167
+ {
168
+ internalType: "address",
169
+ name: "to_",
170
+ type: "address",
171
+ },
172
+ {
173
+ internalType: "address",
174
+ name: "token_",
175
+ type: "address",
176
+ },
177
+ {
178
+ internalType: "uint256",
179
+ name: "amount_",
180
+ type: "uint256",
181
+ },
182
+ {
183
+ internalType: "uint32",
184
+ name: "chainId_",
185
+ type: "uint32",
186
+ },
187
+ ],
188
+ name: "depositFor",
189
+ outputs: [],
190
+ stateMutability: "nonpayable",
191
+ type: "function",
192
+ },
193
+ {
194
+ inputs: [],
195
+ name: "owner",
196
+ outputs: [
197
+ {
198
+ internalType: "address",
199
+ name: "",
200
+ type: "address",
201
+ },
202
+ ],
203
+ stateMutability: "view",
204
+ type: "function",
205
+ },
206
+ {
207
+ inputs: [],
208
+ name: "renounceOwnership",
209
+ outputs: [],
210
+ stateMutability: "nonpayable",
211
+ type: "function",
212
+ },
213
+ {
214
+ inputs: [
215
+ {
216
+ internalType: "uint256",
217
+ name: "amount_",
218
+ type: "uint256",
219
+ },
220
+ {
221
+ internalType: "address",
222
+ name: "user_",
223
+ type: "address",
224
+ },
225
+ {
226
+ internalType: "address",
227
+ name: "token_",
228
+ type: "address",
229
+ },
230
+ {
231
+ internalType: "uint32",
232
+ name: "chainId_",
233
+ type: "uint32",
234
+ },
235
+ {
236
+ internalType: "bytes32",
237
+ name: "transactionHash_",
238
+ type: "bytes32",
239
+ },
240
+ ],
241
+ name: "systemWithdraw",
242
+ outputs: [],
243
+ stateMutability: "nonpayable",
244
+ type: "function",
245
+ },
246
+ {
247
+ inputs: [
248
+ {
249
+ internalType: "address",
250
+ name: "newOwner",
251
+ type: "address",
252
+ },
253
+ ],
254
+ name: "transferOwnership",
255
+ outputs: [],
256
+ stateMutability: "nonpayable",
257
+ type: "function",
258
+ },
259
+ ];
260
+
261
+ export class InteropXGateway__factory {
262
+ static readonly abi = _abi;
263
+ static createInterface(): InteropXGatewayInterface {
264
+ return new utils.Interface(_abi) as InteropXGatewayInterface;
265
+ }
266
+ static connect(
267
+ address: string,
268
+ signerOrProvider: Signer | Provider
269
+ ): InteropXGateway {
270
+ return new Contract(address, _abi, signerOrProvider) as InteropXGateway;
271
+ }
272
+ }
@@ -0,0 +1,7 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export { Erc20__factory } from "./Erc20__factory";
5
+ export { GnosisSafe__factory } from "./GnosisSafe__factory";
6
+ export { InteropBridgeToken__factory } from "./InteropBridgeToken__factory";
7
+ export { InteropXGateway__factory } from "./InteropXGateway__factory";
@@ -0,0 +1,12 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export type { Erc20 } from "./Erc20";
5
+ export type { GnosisSafe } from "./GnosisSafe";
6
+ export type { InteropBridgeToken } from "./InteropBridgeToken";
7
+ export type { InteropXGateway } from "./InteropXGateway";
8
+ export * as factories from "./factories";
9
+ export { Erc20__factory } from "./factories/Erc20__factory";
10
+ export { GnosisSafe__factory } from "./factories/GnosisSafe__factory";
11
+ export { InteropBridgeToken__factory } from "./factories/InteropBridgeToken__factory";
12
+ export { InteropXGateway__factory } from "./factories/InteropXGateway__factory";
package/src/types.ts CHANGED
@@ -36,4 +36,4 @@ export type EventBusType = EventBus<Event.PEER_CONNECTED> &
36
36
  EventBus<Event.POOL_PEER_BANNED>
37
37
 
38
38
 
39
- export type ChainId = 1 | 137;
39
+ export type ChainId = 1 | 137 | 43114;
@@ -3,14 +3,32 @@
3
3
  */
4
4
  import axios from 'axios'
5
5
  import axiosRetry from "axios-retry";
6
- import { addresses } from '@/constants';
6
+ import { addresses, itokens, tokens } from '@/constants';
7
7
  import { ChainId } from '@/types'
8
+ import { ethers } from 'ethers';
9
+ import { encodeMulti, MetaTransaction, OperationType } from 'ethers-multisend';
10
+ import { Transaction } from '@/db';
11
+ import config from '@/config';
12
+ import abi from '@/abi';
13
+ import { InteropBridgeToken, InteropXGateway } from '@/typechain';
8
14
 
9
15
  export const http = axios.create();
10
16
 
11
17
  axiosRetry(http, { retries: 3, retryDelay: axiosRetry.exponentialDelay });
12
18
 
13
19
 
20
+ export function shortenHash(hash: string, length: number = 4) {
21
+ if (!hash) return;
22
+
23
+ if (hash.length < 12) return hash;
24
+
25
+ const beginningChars = hash.startsWith("0x") ? length + 2 : length;
26
+
27
+ const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
28
+
29
+ return shortened;
30
+ }
31
+
14
32
  export function short(buffer: Buffer): string {
15
33
  return buffer.toString('hex').slice(0, 8) + '...'
16
34
  }
@@ -70,9 +88,11 @@ export const signGnosisSafeTx = async ({
70
88
  export const getRpcProviderUrl = (chainId: ChainId) => {
71
89
  switch (chainId) {
72
90
  case 1:
73
- return 'https://rpc.instadapp.io/mainnet';
91
+ return 'https://rpc.ankr.com/eth';
74
92
  case 137:
75
- return 'https://rpc.instadapp.io/polygon';
93
+ return 'https://rpc.ankr.com/polygon';
94
+ case 43114:
95
+ return 'https://rpc.ankr.com/avalanche';
76
96
  default:
77
97
  throw new Error(`Unknown chainId: ${chainId}`);
78
98
  }
@@ -113,4 +133,187 @@ export const asyncCallWithTimeout = async <T>(asyncPromise: Promise<T>, timeout:
113
133
  clearTimeout(timeoutHandle);
114
134
  return result;
115
135
  }) as Promise<T>
136
+ }
137
+
138
+
139
+ export const generateInteropTransactionHash = (data: { action: string, submitTransactionHash: string, sourceChainId: string | number, targetChainId: string | number }) => {
140
+ return ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
141
+ String(data.action),
142
+ String(data.submitTransactionHash),
143
+ String(data.sourceChainId),
144
+ String(data.targetChainId),
145
+ ]);
146
+ }
147
+
148
+ export const buildDataForTransaction = async (transaction: Transaction, type?: 'source' | 'target') => {
149
+ type = type || transaction.sourceStatus === 'pending' ? 'source' : 'target';
150
+
151
+ switch (transaction.action) {
152
+ case "deposit":
153
+ return await buildDepositDataForTransaction(transaction, type);
154
+ case "withdraw":
155
+ return await buildWithdrawDataForTransaction(transaction, type);
156
+ default:
157
+ throw new Error(`Unknown action: ${transaction.action}`);
158
+ }
159
+ }
160
+
161
+ export const buildDepositDataForTransaction = async (transaction: Transaction, type: 'source' | 'target') => {
162
+ const transactions: MetaTransaction[] = [];
163
+
164
+ if (transaction.action !== 'deposit') {
165
+ throw new Error(`Invalid action: ${transaction.action}`)
166
+ }
167
+
168
+ if (transaction.action === 'deposit' && transaction.sourceStatus === 'pending') {
169
+ throw Error('Cannot build data for pending deposit transaction');
170
+ }
171
+
172
+ if (!transaction.submitEvent) {
173
+ throw Error('Cannot build data for transaction without submitEvent');
174
+ }
175
+
176
+
177
+ const token = tokens[transaction.sourceChainId].find(token => token.address.toLowerCase() === transaction.submitEvent.token.toLowerCase());
178
+
179
+ if (!token) {
180
+ throw Error('Cannot build data for transaction without token');
181
+ }
182
+
183
+ const itoken = itokens[transaction.targetChainId].find(itoken => itoken.symbol.toLowerCase() === token.symbol.toLowerCase());
184
+
185
+ if (!itoken) {
186
+ throw Error('Cannot build data for transaction without itoken');
187
+ }
188
+
189
+ const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(transaction.targetChainId as ChainId));
190
+ const targetWallet = new ethers.Wallet(config.privateKey, targetChainProvider);
191
+ const interopBridgeContract = getContract<InteropBridgeToken>(itoken.address, abi.interopBridgeToken, targetWallet);
192
+
193
+ const { data } = await interopBridgeContract.populateTransaction.mint(
194
+ transaction.submitEvent.user,
195
+ ethers.BigNumber.from(transaction.submitEvent.amount.toString()),
196
+ ethers.BigNumber.from(transaction.submitEvent.sourceChainId.toString()),
197
+ transaction.submitTransactionHash,
198
+ );
199
+
200
+ transactions.push({
201
+ to: itoken.address,
202
+ data: data!,
203
+ value: '0',
204
+ operation: OperationType.Call,
205
+ });
206
+
207
+ return encodeMulti(transactions).data
208
+ }
209
+
210
+ export const buildWithdrawDataForTransaction = async (transaction: Transaction, type: 'source' | 'target') => {
211
+ const transactions: MetaTransaction[] = [];
212
+
213
+ if (transaction.action !== 'withdraw') {
214
+ throw new Error(`Invalid action: ${transaction.action}`)
215
+ }
216
+
217
+ if (transaction.action === 'withdraw' && transaction.sourceStatus === 'pending') {
218
+ throw Error('Cannot build data for pending withdraw transaction');
219
+ }
220
+
221
+ if (!transaction.submitEvent) {
222
+ throw Error('Cannot build data for transaction without submitEvent');
223
+ }
224
+
225
+ const { to, amount, sourceChainId, targetChainId, itoken: itokenAddress } = transaction.submitEvent;
226
+
227
+ const itoken = itokens[sourceChainId].find(token => token.address.toLowerCase() === itokenAddress.toLowerCase());
228
+
229
+ if (!itoken) {
230
+ throw Error('Cannot build data for transaction without itoken');
231
+ }
232
+
233
+ const token = tokens[targetChainId].find(t => t.symbol.toLowerCase() === itoken.symbol.toLowerCase());
234
+
235
+ if (!token) {
236
+ throw Error('Cannot build data for transaction without token');
237
+ }
238
+
239
+ const targetChainProvider = new ethers.providers.JsonRpcProvider(getRpcProviderUrl(targetChainId as ChainId));
240
+ const targetWallet = new ethers.Wallet(config.privateKey, targetChainProvider);
241
+ const gatewayAddress = addresses[targetChainId].interopXGateway;
242
+ const interopBridgeContract = getContract<InteropXGateway>(gatewayAddress, abi.interopXGateway, targetWallet);
243
+
244
+ const { data } = await interopBridgeContract.populateTransaction.systemWithdraw(
245
+ ethers.BigNumber.from(amount.toString()),
246
+ to,
247
+ token.address,
248
+ ethers.BigNumber.from(sourceChainId.toString()),
249
+ transaction.submitTransactionHash,
250
+ );
251
+
252
+ transactions.push({
253
+ to: gatewayAddress,
254
+ data: data!,
255
+ value: '0',
256
+ operation: OperationType.Call,
257
+ });
258
+
259
+ return encodeMulti(transactions).data
260
+ }
261
+
262
+
263
+ export function getContract<TContract extends ethers.Contract>(address: string, contractInterface: ethers.ContractInterface | any, signerOrProvider?: ethers.Signer | ethers.providers.Provider) {
264
+ if (!ethers.utils.getAddress(address) || address === ethers.constants.AddressZero) {
265
+ throw Error(`Invalid 'address' parameter '${address}'.`)
266
+ }
267
+
268
+ const contract = new ethers.Contract(
269
+ address,
270
+ contractInterface,
271
+ signerOrProvider
272
+ ) as TContract
273
+
274
+ // Make sure the contract properties is writable
275
+ const desc = Object.getOwnPropertyDescriptor(contract, 'functions');
276
+
277
+ if (!desc || desc.writable !== true) {
278
+ return contract
279
+ }
280
+
281
+ return new Proxy(contract, {
282
+ get(target, prop, receiver) {
283
+ const value = Reflect.get(target, prop, receiver);
284
+
285
+ if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
286
+ return async (...args: any[]) => {
287
+ try {
288
+ return await value.bind(contract)(...args);
289
+ } catch (error) {
290
+ throw new Error(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`)
291
+ }
292
+ }
293
+ }
294
+
295
+
296
+ if (typeof value === 'object' && ['populateTransaction', 'estimateGas', 'functions', 'callStatic'].includes(String(prop))) {
297
+ const parentProp = String(prop);
298
+
299
+ return new Proxy(value, {
300
+ get(target, prop, receiver) {
301
+ const value = Reflect.get(target, prop, receiver);
302
+
303
+ if (typeof value === 'function') {
304
+ return async (...args: any[]) => {
305
+ try {
306
+ return await value.bind(contract)(...args);
307
+ } catch (error) {
308
+ throw new Error(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`)
309
+ }
310
+ }
311
+ }
312
+ }
313
+ })
314
+ }
315
+
316
+ return value;
317
+ },
318
+ });
116
319
  }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ethers_1 = require("ethers");
4
- const types_1 = require("@/types");
5
- class Config {
6
- constructor() {
7
- this.events = new types_1.EventBus();
8
- this.maxPeers = 10;
9
- this.privateKey = process.env.PRIVATE_KEY;
10
- this.wallet = new ethers_1.Wallet(this.privateKey);
11
- this.leadNodeAddress = '0x910E413DBF3F6276Fe8213fF656726bDc142E08E';
12
- }
13
- isLeadNode() {
14
- return ethers_1.ethers.utils.getAddress(this.leadNodeAddress) === ethers_1.ethers.utils.getAddress(this.wallet.address);
15
- }
16
- }
17
- exports.default = new Config();
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addresses = void 0;
4
- exports.addresses = {
5
- 1: {
6
- gnosisSafe: '0x811Bff6eF88dAAA0aD6438386B534A81cE3F160F',
7
- multisend: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
8
- },
9
- 137: {
10
- gnosisSafe: '0x5635d2910e51da33d9DC0422c893CF4F28B69A25',
11
- multisend: "0xA238CBeb142c10Ef7Ad8442C6D1f9E89e07e7761",
12
- },
13
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Execution = void 0;
4
- const sequelize_1 = require("@/db/sequelize");
5
- const sequelize_2 = require("sequelize");
6
- class Execution extends sequelize_2.Model {
7
- }
8
- exports.Execution = Execution;
9
- Execution.init({
10
- id: {
11
- type: sequelize_2.DataTypes.INTEGER,
12
- autoIncrement: true,
13
- primaryKey: true
14
- },
15
- transactionHash: sequelize_2.DataTypes.STRING,
16
- from: sequelize_2.DataTypes.STRING,
17
- executions: sequelize_2.DataTypes.JSON,
18
- chainId: sequelize_2.DataTypes.NUMBER,
19
- gas: sequelize_2.DataTypes.STRING,
20
- maxGasPrice: sequelize_2.DataTypes.STRING,
21
- assets: sequelize_2.DataTypes.JSON,
22
- metadata: sequelize_2.DataTypes.STRING,
23
- vnonce: sequelize_2.DataTypes.STRING,
24
- txHash: sequelize_2.DataTypes.STRING,
25
- blockNumber: sequelize_2.DataTypes.STRING,
26
- status: {
27
- type: sequelize_2.DataTypes.STRING,
28
- defaultValue: 'pending'
29
- },
30
- delayUntil: sequelize_2.DataTypes.DATE,
31
- delayedCount: {
32
- type: sequelize_2.DataTypes.INTEGER,
33
- defaultValue: 0
34
- },
35
- error: sequelize_2.DataTypes.STRING,
36
- createdAt: sequelize_2.DataTypes.DATE,
37
- updatedAt: sequelize_2.DataTypes.DATE,
38
- }, { sequelize: sequelize_1.sequelize, tableName: 'executions' });
package/dist/index.js DELETED
@@ -1,43 +0,0 @@
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
- require("module-alias/register");
7
- const assert_1 = __importDefault(require("assert"));
8
- const dotenv_1 = __importDefault(require("dotenv"));
9
- const logger_1 = __importDefault(require("@/logger"));
10
- const ethers_1 = require("ethers");
11
- dotenv_1.default.config();
12
- const logger = new logger_1.default('Process');
13
- (0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
14
- try {
15
- new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
16
- }
17
- catch (e) {
18
- logger.error('Invalid private key');
19
- process.exit(1);
20
- }
21
- const tasks_1 = require("@/tasks");
22
- const net_1 = require("@/net");
23
- async function main() {
24
- (0, net_1.startPeer)({});
25
- const tasks = new tasks_1.Tasks();
26
- tasks.start();
27
- }
28
- main()
29
- .then(() => {
30
- }).catch(err => {
31
- console.error(err);
32
- });
33
- process.on('SIGINT', () => {
34
- logger.debug('received SIGINT signal. exiting.');
35
- process.exit(0);
36
- });
37
- process.on('SIGTERM', () => {
38
- logger.debug('received SIGTERM signal. exiting.');
39
- process.exit(0);
40
- });
41
- process.on('unhandledRejection', (reason, p) => {
42
- logger.error('unhandled rejection: promise:', p, 'reason:', reason);
43
- });
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tasks = void 0;
4
- class Tasks {
5
- constructor() {
6
- this.tasks = [];
7
- }
8
- async start() {
9
- for (const task of this.tasks) {
10
- try {
11
- task.start();
12
- }
13
- catch (error) {
14
- console.error(`Error starting task: ${task.constructor.name}`);
15
- }
16
- }
17
- }
18
- }
19
- exports.Tasks = Tasks;