@instadapp/interop-x 0.0.0-dev.fd6776c → 0.0.0-dev.fd7fd6f

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 (68) hide show
  1. package/bin/interop-x +1 -1
  2. package/dist/package.json +72 -0
  3. package/dist/{abi → src/abi}/erc20.json +0 -0
  4. package/dist/{abi → src/abi}/gnosisSafe.json +0 -0
  5. package/dist/{abi → src/abi}/index.js +0 -0
  6. package/dist/{abi → src/abi}/interopBridgeToken.json +0 -0
  7. package/dist/{abi → src/abi}/interopXGateway.json +0 -0
  8. package/dist/src/api/index.js +33 -0
  9. package/dist/{config → src/config}/index.js +1 -0
  10. package/dist/{constants → src/constants}/addresses.js +0 -8
  11. package/dist/{constants → src/constants}/index.js +1 -0
  12. package/dist/src/constants/itokens.js +13 -0
  13. package/dist/{constants → src/constants}/tokens.js +0 -0
  14. package/dist/{db → src/db}/index.js +0 -0
  15. package/dist/{db → src/db}/models/index.js +0 -0
  16. package/dist/{db → src/db}/models/transaction.js +3 -1
  17. package/dist/{db → src/db}/sequelize.js +0 -0
  18. package/dist/src/index.js +103 -0
  19. package/dist/{logger → src/logger}/index.js +0 -0
  20. package/dist/{net → src/net}/index.js +0 -0
  21. package/dist/{net → src/net}/peer/index.js +6 -2
  22. package/dist/{net → src/net}/pool/index.js +27 -9
  23. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
  24. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -12
  25. package/dist/{net → src/net}/protocol/index.js +30 -1
  26. package/dist/src/tasks/AutoUpdateTask.js +44 -0
  27. package/dist/{tasks → src/tasks}/BaseTask.js +1 -1
  28. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +147 -0
  29. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +70 -0
  30. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +150 -0
  31. package/dist/{tasks → src/tasks}/InteropXGateway/SyncDepositEvents.js +16 -20
  32. package/dist/{tasks → src/tasks}/index.js +15 -0
  33. package/dist/{typechain → src/typechain}/Erc20.js +0 -0
  34. package/dist/{typechain → src/typechain}/GnosisSafe.js +0 -0
  35. package/dist/{typechain → src/typechain}/InteropBridgeToken.js +0 -0
  36. package/dist/{typechain → src/typechain}/InteropXGateway.js +0 -0
  37. package/dist/{typechain → src/typechain}/common.js +0 -0
  38. package/dist/{typechain → src/typechain}/factories/Erc20__factory.js +0 -0
  39. package/dist/{typechain → src/typechain}/factories/GnosisSafe__factory.js +0 -0
  40. package/dist/{typechain → src/typechain}/factories/InteropBridgeToken__factory.js +0 -0
  41. package/dist/{typechain → src/typechain}/factories/InteropXGateway__factory.js +0 -0
  42. package/dist/{typechain → src/typechain}/factories/index.js +0 -0
  43. package/dist/{typechain → src/typechain}/index.js +0 -0
  44. package/dist/{types.js → src/types.js} +0 -0
  45. package/dist/src/utils/index.js +228 -0
  46. package/package.json +10 -4
  47. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  48. package/src/api/index.ts +33 -0
  49. package/src/config/index.ts +2 -0
  50. package/src/constants/addresses.ts +0 -8
  51. package/src/constants/index.ts +1 -0
  52. package/src/constants/itokens.ts +10 -0
  53. package/src/db/models/transaction.ts +8 -4
  54. package/src/index.ts +56 -6
  55. package/src/net/peer/index.ts +7 -6
  56. package/src/net/pool/index.ts +37 -11
  57. package/src/net/protocol/dial/SignatureDialProtocol.ts +25 -13
  58. package/src/net/protocol/index.ts +45 -1
  59. package/src/tasks/AutoUpdateTask.ts +53 -0
  60. package/src/tasks/BaseTask.ts +1 -1
  61. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +233 -0
  62. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +121 -0
  63. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +245 -0
  64. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +23 -11
  65. package/src/tasks/index.ts +22 -2
  66. package/src/utils/index.ts +182 -4
  67. package/dist/index.js +0 -63
  68. package/dist/utils/index.js +0 -101
@@ -1,101 +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
- exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = 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 short(buffer) {
17
- return buffer.toString('hex').slice(0, 8) + '...';
18
- }
19
- exports.short = short;
20
- 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 }) => {
21
- const gnosisSafe = constants_1.addresses[chainId].gnosisSafe;
22
- const domain = {
23
- verifyingContract: gnosisSafe,
24
- chainId,
25
- };
26
- const types = {
27
- SafeTx: [
28
- { type: 'address', name: 'to' },
29
- { type: 'uint256', name: 'value' },
30
- { type: 'bytes', name: 'data' },
31
- { type: 'uint8', name: 'operation' },
32
- { type: 'uint256', name: 'safeTxGas' },
33
- { type: 'uint256', name: 'baseGas' },
34
- { type: 'uint256', name: 'gasPrice' },
35
- { type: 'address', name: 'gasToken' },
36
- { type: 'address', name: 'refundReceiver' },
37
- { type: 'uint256', name: 'nonce' },
38
- ],
39
- };
40
- const message = {
41
- baseGas,
42
- data,
43
- gasPrice,
44
- gasToken,
45
- nonce: Number(nonce),
46
- operation,
47
- refundReceiver,
48
- safeAddress: gnosisSafe,
49
- safeTxGas: String(safeTxGas),
50
- to,
51
- value,
52
- };
53
- return await signer._signTypedData(domain, types, message);
54
- };
55
- exports.signGnosisSafeTx = signGnosisSafeTx;
56
- const getRpcProviderUrl = (chainId) => {
57
- switch (chainId) {
58
- case 1:
59
- return 'https://rpc.instadapp.io/mainnet';
60
- case 137:
61
- return 'https://rpc.instadapp.io/polygon';
62
- case 43114:
63
- return 'https://rpc.instadapp.io/avalanche';
64
- default:
65
- throw new Error(`Unknown chainId: ${chainId}`);
66
- }
67
- };
68
- exports.getRpcProviderUrl = getRpcProviderUrl;
69
- const buildSignatureBytes = (signatures) => {
70
- signatures.sort((left, right) => left.signer.toLowerCase().localeCompare(right.signer.toLowerCase()));
71
- let signatureBytes = "0x";
72
- for (const sig of signatures) {
73
- signatureBytes += sig.data.slice(2);
74
- }
75
- return signatureBytes;
76
- };
77
- exports.buildSignatureBytes = buildSignatureBytes;
78
- /**
79
- * Call an async function with a maximum time limit (in milliseconds) for the timeout
80
- * Resolved promise for async function call, or an error if time limit reached
81
- */
82
- const asyncCallWithTimeout = async (asyncPromise, timeout) => {
83
- let timeoutHandle;
84
- const timeoutPromise = new Promise((_resolve, reject) => {
85
- timeoutHandle = setTimeout(() => reject(new Error('Async call timeout limit reached')), timeout);
86
- });
87
- return Promise.race([asyncPromise, timeoutPromise]).then(result => {
88
- clearTimeout(timeoutHandle);
89
- return result;
90
- });
91
- };
92
- exports.asyncCallWithTimeout = asyncCallWithTimeout;
93
- const generateInteropTransactionHash = (data) => {
94
- return ethers_1.ethers.utils.solidityKeccak256(['string', 'string', 'string', 'string'], [
95
- String(data.type),
96
- String(data.sourceTransactionHash),
97
- String(data.sourceChainId),
98
- String(data.targetChainId),
99
- ]);
100
- };
101
- exports.generateInteropTransactionHash = generateInteropTransactionHash;