@instadapp/interop-x 0.0.0-dev.f9253db → 0.0.0-dev.fabee70

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 (73) hide show
  1. package/bin/interop-x +1 -1
  2. package/dist/package.json +73 -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 +107 -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 +8 -3
  22. package/dist/{net → src/net}/pool/index.js +32 -9
  23. package/dist/{net → src/net}/protocol/dial/BaseDialProtocol.js +0 -0
  24. package/dist/src/net/protocol/dial/SignatureDialProtocol.1.js +28 -0
  25. package/dist/{net → src/net}/protocol/dial/SignatureDialProtocol.js +22 -12
  26. package/dist/{net → src/net}/protocol/index.js +41 -1
  27. package/dist/src/tasks/AutoUpdateTask.js +57 -0
  28. package/dist/{tasks → src/tasks}/BaseTask.js +8 -4
  29. package/dist/src/tasks/InteropBridge/ProcessWithdrawEvents.js +146 -0
  30. package/dist/src/tasks/InteropBridge/SyncWithdrawEvents.js +69 -0
  31. package/dist/src/tasks/InteropXGateway/ProcessDepositEvents.js +149 -0
  32. package/dist/{tasks → src/tasks}/InteropXGateway/SyncDepositEvents.js +16 -21
  33. package/dist/src/tasks/Transactions/SyncTransactionStatusTask.js +53 -0
  34. package/dist/src/tasks/index.js +44 -0
  35. package/dist/{typechain → src/typechain}/Erc20.js +0 -0
  36. package/dist/{typechain → src/typechain}/GnosisSafe.js +0 -0
  37. package/dist/{typechain → src/typechain}/InteropBridgeToken.js +0 -0
  38. package/dist/{typechain → src/typechain}/InteropXGateway.js +0 -0
  39. package/dist/{typechain → src/typechain}/common.js +0 -0
  40. package/dist/{typechain → src/typechain}/factories/Erc20__factory.js +0 -0
  41. package/dist/{typechain → src/typechain}/factories/GnosisSafe__factory.js +0 -0
  42. package/dist/{typechain → src/typechain}/factories/InteropBridgeToken__factory.js +0 -0
  43. package/dist/{typechain → src/typechain}/factories/InteropXGateway__factory.js +0 -0
  44. package/dist/{typechain → src/typechain}/factories/index.js +0 -0
  45. package/dist/{typechain → src/typechain}/index.js +0 -0
  46. package/dist/{types.js → src/types.js} +0 -0
  47. package/dist/src/utils/index.js +238 -0
  48. package/package.json +9 -3
  49. package/patches/@ethersproject+properties+5.6.0.patch +13 -0
  50. package/src/api/index.ts +33 -0
  51. package/src/config/index.ts +2 -0
  52. package/src/constants/addresses.ts +0 -8
  53. package/src/constants/index.ts +1 -0
  54. package/src/constants/itokens.ts +10 -0
  55. package/src/db/models/transaction.ts +8 -4
  56. package/src/index.ts +62 -6
  57. package/src/net/peer/index.ts +9 -7
  58. package/src/net/pool/index.ts +41 -11
  59. package/src/net/protocol/dial/SignatureDialProtocol.1.ts +31 -0
  60. package/src/net/protocol/dial/SignatureDialProtocol.ts +25 -13
  61. package/src/net/protocol/index.ts +57 -1
  62. package/src/tasks/AutoUpdateTask.ts +73 -0
  63. package/src/tasks/BaseTask.ts +9 -4
  64. package/src/tasks/InteropBridge/ProcessWithdrawEvents.ts +231 -0
  65. package/src/tasks/InteropBridge/SyncWithdrawEvents.ts +119 -0
  66. package/src/tasks/InteropXGateway/ProcessDepositEvents.ts +243 -0
  67. package/src/tasks/InteropXGateway/SyncDepositEvents.ts +23 -13
  68. package/src/tasks/Transactions/SyncTransactionStatusTask.ts +65 -0
  69. package/src/tasks/index.ts +24 -2
  70. package/src/utils/index.ts +197 -7
  71. package/dist/index.js +0 -63
  72. package/dist/tasks/index.js +0 -27
  73. package/dist/utils/index.js +0 -101
package/dist/index.js DELETED
@@ -1,63 +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
- const module_alias_1 = __importDefault(require("module-alias"));
7
- module_alias_1.default.addAliases({
8
- "@/": __dirname + "/",
9
- "@/logger": __dirname + "/logger",
10
- "@/tasks": __dirname + "/tasks",
11
- "@/utils": __dirname + "/utils",
12
- "@/net": __dirname + "/net",
13
- "@/db": __dirname + "/db",
14
- "@/config": __dirname + "/config",
15
- "@/types": __dirname + "/types",
16
- "@/abi": __dirname + "/abi",
17
- "@/constants": __dirname + "/constants",
18
- "@/typechain": __dirname + "/typechain"
19
- });
20
- (0, module_alias_1.default)();
21
- const assert_1 = __importDefault(require("assert"));
22
- const dotenv_1 = __importDefault(require("dotenv"));
23
- const ethers_1 = require("ethers");
24
- dotenv_1.default.config();
25
- const logger_1 = __importDefault(require("@/logger"));
26
- const logger = new logger_1.default('Process');
27
- if (process.argv.at(-1) === 'help') {
28
- console.log('Usage:');
29
- console.log(' PRIVATE_KEY=abcd1234 interop-x');
30
- console.log(' PRIVATE_KEY=abcd1234 STAGING=true interop-x');
31
- process.exit(0);
32
- }
33
- (0, assert_1.default)(process.env.PRIVATE_KEY, "PRIVATE_KEY is not defined");
34
- try {
35
- new ethers_1.ethers.Wallet(process.env.PRIVATE_KEY);
36
- }
37
- catch (e) {
38
- logger.error('Invalid private key');
39
- process.exit(1);
40
- }
41
- const tasks_1 = require("@/tasks");
42
- const net_1 = require("@/net");
43
- async function main() {
44
- (0, net_1.startPeer)({});
45
- const tasks = new tasks_1.Tasks();
46
- tasks.start();
47
- }
48
- main()
49
- .then(() => {
50
- }).catch(err => {
51
- console.error(err);
52
- });
53
- process.on('SIGINT', () => {
54
- logger.debug('received SIGINT signal. exiting.');
55
- process.exit(0);
56
- });
57
- process.on('SIGTERM', () => {
58
- logger.debug('received SIGTERM signal. exiting.');
59
- process.exit(0);
60
- });
61
- process.on('unhandledRejection', (reason, p) => {
62
- logger.error('unhandled rejection: promise:', p, 'reason:', reason);
63
- });
@@ -1,27 +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.Tasks = void 0;
7
- const SyncDepositEvents_1 = __importDefault(require("./InteropXGateway/SyncDepositEvents"));
8
- class Tasks {
9
- constructor() {
10
- this.tasks = [
11
- new SyncDepositEvents_1.default({
12
- chainId: 43114
13
- })
14
- ];
15
- }
16
- async start() {
17
- for (const task of this.tasks) {
18
- try {
19
- task.start();
20
- }
21
- catch (error) {
22
- console.error(`Error starting task: ${task.constructor.name}`);
23
- }
24
- }
25
- }
26
- }
27
- exports.Tasks = Tasks;
@@ -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;