@instadapp/interop-x 0.0.0-dev.0520d2e → 0.0.0-dev.0bace53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.0520d2e",
3
+ "version": "0.0.0-dev.0bace53",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -25,17 +25,16 @@
25
25
  "dependencies": {
26
26
  "@achingbrain/libp2p-gossipsub": "^0.12.2",
27
27
  "@fastify/cors": "^7.0.0",
28
- "async-retry": "^1.3.3",
29
28
  "await-spawn": "^4.0.2",
30
- "axios": "^0.27.2",
31
- "axios-retry": "^3.2.5",
29
+ "axios": "^0.27.1",
30
+ "axios-retry": "^3.2.4",
32
31
  "chalk": "4.1.2",
33
- "dotenv": "^16.0.1",
32
+ "dotenv": "^16.0.0",
34
33
  "ethereumjs-util": "^7.1.4",
35
- "ethers": "^5.6.5",
34
+ "ethers": "^5.6.4",
36
35
  "ethers-multisend": "^2.1.1",
37
36
  "expand-home-dir": "^0.0.3",
38
- "fastify": "^3.29.0",
37
+ "fastify": "^3.28.0",
39
38
  "fs-extra": "^10.1.0",
40
39
  "libp2p": "^0.36.2",
41
40
  "libp2p-bootstrap": "^0.14.0",
@@ -46,12 +45,12 @@
46
45
  "libp2p-pubsub-peer-discovery": "^4.0.0",
47
46
  "libp2p-tcp": "^0.17.2",
48
47
  "libp2p-websockets": "^0.16.2",
49
- "luxon": "^2.4.0",
48
+ "luxon": "^2.3.2",
50
49
  "module-alias": "^2.2.2",
51
50
  "patch-package": "^6.4.7",
52
51
  "postinstall-postinstall": "^2.1.0",
53
52
  "sequelize": "6.18.0",
54
- "sqlite3": "^5.0.8",
53
+ "sqlite3": "^5.0.5",
55
54
  "waait": "^1.0.5"
56
55
  },
57
56
  "bin": {
@@ -62,13 +61,13 @@
62
61
  "@typechain/ethers-v5": "^10.0.0",
63
62
  "@types/bn.js": "^5.1.0",
64
63
  "@types/fs-extra": "^9.0.13",
65
- "@types/node": "^17.0.33",
66
- "nodemon": "^2.0.16",
64
+ "@types/node": "^17.0.17",
65
+ "nodemon": "^2.0.15",
67
66
  "replace-in-file": "^6.3.2",
68
67
  "rimraf": "^3.0.2",
69
68
  "ts-node": "^10.5.0",
70
69
  "tsconfig-paths": "^3.12.0",
71
70
  "typechain": "^8.0.0",
72
- "typescript": "^4.6.4"
71
+ "typescript": "^4.5.5"
73
72
  }
74
73
  }
@@ -4,42 +4,30 @@ exports.tokens = void 0;
4
4
  exports.tokens = {
5
5
  1: [
6
6
  {
7
- aliases: ['eth'],
8
7
  symbol: "ETH",
9
8
  name: "Ethereum",
10
9
  address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
11
10
  decimals: 18,
12
11
  },
13
12
  {
14
- aliases: ['weth'],
15
- symbol: "WETH",
16
- name: "Wrapped Ethereum",
17
- address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
18
- decimals: 18,
19
- },
20
- {
21
- aliases: ['dai'],
22
13
  symbol: "DAI",
23
14
  name: "DAI Stable",
24
15
  address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
25
16
  decimals: 18,
26
17
  },
27
18
  {
28
- aliases: ['usdc'],
29
19
  symbol: "USDC",
30
20
  name: "USD Coin",
31
21
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
32
22
  decimals: 6,
33
23
  },
34
24
  {
35
- aliases: ['usdt'],
36
25
  symbol: "USDT",
37
26
  name: "Tether USD Coin",
38
27
  address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
39
28
  decimals: 6,
40
29
  },
41
30
  {
42
- aliases: ['wbtc'],
43
31
  symbol: "WBTC",
44
32
  name: "Wrapped BTC",
45
33
  address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
@@ -48,42 +36,36 @@ exports.tokens = {
48
36
  ],
49
37
  137: [
50
38
  {
51
- aliases: ['eth', 'weth'],
52
39
  symbol: "ETH",
53
40
  name: "Ethereum",
54
41
  address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
55
42
  decimals: 18,
56
43
  },
57
44
  {
58
- aliases: ['dai'],
59
45
  symbol: "DAI",
60
46
  name: "DAI Stable",
61
47
  address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
62
48
  decimals: 18,
63
49
  },
64
50
  {
65
- aliases: ['usdc'],
66
51
  symbol: "USDC",
67
52
  name: "USD Coin",
68
53
  address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
69
54
  decimals: 6,
70
55
  },
71
56
  {
72
- aliases: ['usdt'],
73
57
  symbol: "USDT",
74
58
  name: "Tether USD Coin",
75
59
  address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
76
60
  decimals: 6,
77
61
  },
78
62
  {
79
- aliases: ['wbtc'],
80
63
  symbol: "WBTC",
81
64
  name: "Wrapped BTC",
82
65
  address: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
83
66
  decimals: 8,
84
67
  },
85
68
  {
86
- aliases: ['avax'],
87
69
  symbol: "AVAX",
88
70
  name: "Avalanche Token",
89
71
  address: "0x2C89bbc92BD86F8075d1DEcc58C7F4E0107f286b",
@@ -92,42 +74,30 @@ exports.tokens = {
92
74
  ],
93
75
  43114: [
94
76
  {
95
- aliases: ['eth', 'weth'],
96
77
  symbol: "ETH",
97
78
  name: "Ethereum",
98
79
  address: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
99
80
  decimals: 18,
100
81
  },
101
82
  {
102
- aliases: ['dai'],
103
83
  symbol: "DAI",
104
84
  name: "DAI Stable",
105
85
  address: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
106
86
  decimals: 18,
107
87
  },
108
88
  {
109
- aliases: ['usdc'],
110
89
  symbol: "USDC",
111
90
  name: "USD Coin",
112
91
  address: "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
113
92
  decimals: 6,
114
93
  },
115
94
  {
116
- aliases: ['usdt'],
117
- symbol: "USDt",
95
+ symbol: "USDT",
118
96
  name: "Tether USD Coin",
119
- address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
120
- decimals: 6,
121
- },
122
- {
123
- aliases: ['usdt'],
124
- symbol: "USDT.e",
125
- name: "Tether USD",
126
97
  address: "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
127
98
  decimals: 6,
128
99
  },
129
100
  {
130
- aliases: ["wbtc"],
131
101
  symbol: "WBTC",
132
102
  name: "Wrapped BTC",
133
103
  address: "0x50b7545627a5162F82A992c33b87aDc75187B218",
@@ -16,33 +16,19 @@ async function default_1(transaction, type) {
16
16
  throw new Error(`Invalid action: ${transaction.action}`);
17
17
  }
18
18
  if (type !== 'source') {
19
- throw new Error(`[WIP] Type not supported: ${type}`);
19
+ throw new Error(`Type not supported: ${type}`);
20
20
  }
21
- if (transaction.sourceStatus === 'pending') {
22
- throw Error('Source transaction already processesing');
23
- }
24
- if (transaction.sourceStatus === 'pending') {
25
- throw Error('Source transaction already processed');
21
+ if (transaction.action === 'withdraw' && transaction.sourceStatus === 'pending') {
22
+ throw Error('Cannot build data for pending withdraw transaction');
26
23
  }
27
24
  if (!transaction.requestEvent) {
28
- throw Error('Something went wrong, source transaction has no request event');
25
+ throw Error('Cannot build data for transaction without requestEvent');
29
26
  }
30
27
  const { bridger, position, sourceChainId, targetChainId, metadata, } = transaction.requestEvent;
31
28
  const sourceChainProvider = new ethers_1.ethers.providers.JsonRpcProvider((0, utils_1.getRpcProviderUrl)(targetChainId));
32
29
  const sourceWallet = new ethers_1.ethers.Wallet(config_1.default.privateKey, sourceChainProvider);
33
30
  const contractAddress = constants_1.addresses[sourceChainId].interopXContract;
34
31
  const contract = (0, utils_1.getContract)(contractAddress, abi_1.default.interopXContract, sourceWallet);
35
- const sourceToken = constants_1.tokens[sourceChainId].find(t => t.address.toLowerCase() === position.withdraw[0].sourceToken.toLowerCase());
36
- if (!sourceToken) {
37
- throw Error('Source token not found');
38
- }
39
- const targetToken = constants_1.tokens[targetChainId].find(t => t.address.toLowerCase() === position.withdraw[0].targetToken.toLowerCase());
40
- if (!targetToken) {
41
- throw Error('Target token not found');
42
- }
43
- if (sourceToken.aliases.some(alias => targetToken.aliases.includes(alias))) {
44
- throw Error('Source and target token must be the same');
45
- }
46
32
  const { data } = await contract.populateTransaction.withdrawRequested(bridger, position.withdraw[0].sourceToken, position.withdraw[0].targetToken, position.withdraw[0].amount, targetChainId, transaction.requestTransactionHash, metadata);
47
33
  transactions.push({
48
34
  to: contractAddress,
package/dist/src/index.js CHANGED
@@ -13,7 +13,7 @@ const package_json_1 = __importDefault(require("../package.json"));
13
13
  dotenv_1.default.config();
14
14
  const logger_1 = __importDefault(require("@/logger"));
15
15
  const logger = new logger_1.default('Process');
16
- const GIT_SHORT_HASH = '0520d2e';
16
+ const GIT_SHORT_HASH = '0bace53';
17
17
  const printUsage = () => {
18
18
  console.log();
19
19
  console.log(`Interop X Node (v${package_json_1.default.version} - rev.${GIT_SHORT_HASH})`);
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateGnosisTransaction = exports.getContract = exports.ContractError = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
6
+ exports.generateGnosisTransaction = exports.getContract = exports.generateInteropTransactionHash = exports.asyncCallWithTimeout = exports.buildSignatureBytes = exports.getRpcProviderUrl = exports.signGnosisSafeTx = exports.short = exports.shortenHash = exports.http = void 0;
7
7
  /**
8
8
  * @module util
9
9
  */
@@ -11,7 +11,6 @@ const axios_1 = __importDefault(require("axios"));
11
11
  const axios_retry_1 = __importDefault(require("axios-retry"));
12
12
  const constants_1 = require("@/constants");
13
13
  const ethers_1 = require("ethers");
14
- const async_retry_1 = __importDefault(require("async-retry"));
15
14
  exports.http = axios_1.default.create();
16
15
  (0, axios_retry_1.default)(exports.http, { retries: 3, retryDelay: axios_retry_1.default.exponentialDelay });
17
16
  function shortenHash(hash, length = 4) {
@@ -111,9 +110,6 @@ const generateInteropTransactionHash = (data) => {
111
110
  ]);
112
111
  };
113
112
  exports.generateInteropTransactionHash = generateInteropTransactionHash;
114
- class ContractError extends Error {
115
- }
116
- exports.ContractError = ContractError;
117
113
  function getContract(address, contractInterface, signerOrProvider) {
118
114
  if (!ethers_1.ethers.utils.getAddress(address) || address === ethers_1.ethers.constants.AddressZero) {
119
115
  throw Error(`Invalid 'address' parameter '${address}'.`);
@@ -128,22 +124,12 @@ function getContract(address, contractInterface, signerOrProvider) {
128
124
  get(target, prop, receiver) {
129
125
  const value = Reflect.get(target, prop, receiver);
130
126
  if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
131
- let isConstant = false;
132
- try {
133
- isConstant = contract.interface.getFunction(String(prop)).constant;
134
- }
135
- catch (error) {
136
- }
137
127
  return async (...args) => {
138
128
  try {
139
- return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: isConstant ? 1 : 3 });
129
+ return await value.bind(contract)(...args);
140
130
  }
141
131
  catch (error) {
142
- const err = new ContractError(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`);
143
- err.method = String(prop);
144
- err.address = address;
145
- err.args = [...args];
146
- throw err;
132
+ throw new Error(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`);
147
133
  }
148
134
  };
149
135
  }
@@ -155,14 +141,10 @@ function getContract(address, contractInterface, signerOrProvider) {
155
141
  if (typeof value === 'function') {
156
142
  return async (...args) => {
157
143
  try {
158
- return await (0, async_retry_1.default)(async () => await value.bind(contract)(...args), { retries: parentProp === 'callStatic' ? 3 : 1 });
144
+ return await value.bind(contract)(...args);
159
145
  }
160
146
  catch (error) {
161
- const err = new ContractError(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`);
162
- err.method = String(prop);
163
- err.address = address;
164
- err.args = [...args];
165
- throw err;
147
+ throw new Error(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`);
166
148
  }
167
149
  };
168
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/interop-x",
3
- "version": "0.0.0-dev.0520d2e",
3
+ "version": "0.0.0-dev.0bace53",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -25,17 +25,16 @@
25
25
  "dependencies": {
26
26
  "@achingbrain/libp2p-gossipsub": "^0.12.2",
27
27
  "@fastify/cors": "^7.0.0",
28
- "async-retry": "^1.3.3",
29
28
  "await-spawn": "^4.0.2",
30
- "axios": "^0.27.2",
31
- "axios-retry": "^3.2.5",
29
+ "axios": "^0.27.1",
30
+ "axios-retry": "^3.2.4",
32
31
  "chalk": "4.1.2",
33
- "dotenv": "^16.0.1",
32
+ "dotenv": "^16.0.0",
34
33
  "ethereumjs-util": "^7.1.4",
35
- "ethers": "^5.6.5",
34
+ "ethers": "^5.6.4",
36
35
  "ethers-multisend": "^2.1.1",
37
36
  "expand-home-dir": "^0.0.3",
38
- "fastify": "^3.29.0",
37
+ "fastify": "^3.28.0",
39
38
  "fs-extra": "^10.1.0",
40
39
  "libp2p": "^0.36.2",
41
40
  "libp2p-bootstrap": "^0.14.0",
@@ -46,12 +45,12 @@
46
45
  "libp2p-pubsub-peer-discovery": "^4.0.0",
47
46
  "libp2p-tcp": "^0.17.2",
48
47
  "libp2p-websockets": "^0.16.2",
49
- "luxon": "^2.4.0",
48
+ "luxon": "^2.3.2",
50
49
  "module-alias": "^2.2.2",
51
50
  "patch-package": "^6.4.7",
52
51
  "postinstall-postinstall": "^2.1.0",
53
52
  "sequelize": "6.18.0",
54
- "sqlite3": "^5.0.8",
53
+ "sqlite3": "^5.0.5",
55
54
  "waait": "^1.0.5"
56
55
  },
57
56
  "bin": {
@@ -62,13 +61,13 @@
62
61
  "@typechain/ethers-v5": "^10.0.0",
63
62
  "@types/bn.js": "^5.1.0",
64
63
  "@types/fs-extra": "^9.0.13",
65
- "@types/node": "^17.0.33",
66
- "nodemon": "^2.0.16",
64
+ "@types/node": "^17.0.17",
65
+ "nodemon": "^2.0.15",
67
66
  "replace-in-file": "^6.3.2",
68
67
  "rimraf": "^3.0.2",
69
68
  "ts-node": "^10.5.0",
70
69
  "tsconfig-paths": "^3.12.0",
71
70
  "typechain": "^8.0.0",
72
- "typescript": "^4.6.4"
71
+ "typescript": "^4.5.5"
73
72
  }
74
73
  }
@@ -1,42 +1,30 @@
1
1
  export const tokens = {
2
2
  1: [
3
3
  {
4
- aliases: ['eth'],
5
4
  symbol: "ETH",
6
5
  name: "Ethereum",
7
6
  address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
8
7
  decimals: 18,
9
8
  },
10
9
  {
11
- aliases: ['weth'],
12
- symbol: "WETH",
13
- name: "Wrapped Ethereum",
14
- address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
15
- decimals: 18,
16
- },
17
- {
18
- aliases: ['dai'],
19
10
  symbol: "DAI",
20
11
  name: "DAI Stable",
21
12
  address: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
22
13
  decimals: 18,
23
14
  },
24
15
  {
25
- aliases: ['usdc'],
26
16
  symbol: "USDC",
27
17
  name: "USD Coin",
28
18
  address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
29
19
  decimals: 6,
30
20
  },
31
21
  {
32
- aliases: ['usdt'],
33
22
  symbol: "USDT",
34
23
  name: "Tether USD Coin",
35
24
  address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
36
25
  decimals: 6,
37
26
  },
38
27
  {
39
- aliases: ['wbtc'],
40
28
  symbol: "WBTC",
41
29
  name: "Wrapped BTC",
42
30
  address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
@@ -45,42 +33,36 @@ export const tokens = {
45
33
  ],
46
34
  137: [
47
35
  {
48
- aliases: ['eth', 'weth'],
49
36
  symbol: "ETH",
50
37
  name: "Ethereum",
51
38
  address: "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
52
39
  decimals: 18,
53
40
  },
54
41
  {
55
- aliases: ['dai'],
56
42
  symbol: "DAI",
57
43
  name: "DAI Stable",
58
44
  address: "0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",
59
45
  decimals: 18,
60
46
  },
61
47
  {
62
- aliases: ['usdc'],
63
48
  symbol: "USDC",
64
49
  name: "USD Coin",
65
50
  address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
66
51
  decimals: 6,
67
52
  },
68
53
  {
69
- aliases: ['usdt'],
70
54
  symbol: "USDT",
71
55
  name: "Tether USD Coin",
72
56
  address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
73
57
  decimals: 6,
74
58
  },
75
59
  {
76
- aliases: ['wbtc'],
77
60
  symbol: "WBTC",
78
61
  name: "Wrapped BTC",
79
62
  address: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
80
63
  decimals: 8,
81
64
  },
82
65
  {
83
- aliases: ['avax'],
84
66
  symbol: "AVAX",
85
67
  name: "Avalanche Token",
86
68
  address: "0x2C89bbc92BD86F8075d1DEcc58C7F4E0107f286b",
@@ -89,46 +71,34 @@ export const tokens = {
89
71
  ],
90
72
  43114: [
91
73
  {
92
- aliases: ['eth', 'weth'],
93
74
  symbol: "ETH",
94
75
  name: "Ethereum",
95
76
  address: "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
96
77
  decimals: 18,
97
78
  },
98
79
  {
99
- aliases: ['dai'],
100
80
  symbol: "DAI",
101
81
  name: "DAI Stable",
102
82
  address: "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",
103
83
  decimals: 18,
104
84
  },
105
85
  {
106
- aliases: ['usdc'],
107
86
  symbol: "USDC",
108
87
  name: "USD Coin",
109
88
  address: "0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664",
110
89
  decimals: 6,
111
90
  },
112
91
  {
113
- aliases: ['usdt'],
114
- symbol: "USDt",
92
+ symbol: "USDT",
115
93
  name: "Tether USD Coin",
116
- address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
117
- decimals: 6,
118
- },
119
- {
120
- aliases: ['usdt'],
121
- symbol: "USDT.e",
122
- name: "Tether USD",
123
94
  address: "0xc7198437980c041c805A1EDcbA50c1Ce5db95118",
124
95
  decimals: 6,
125
96
  },
126
97
  {
127
- aliases: ["wbtc"],
128
98
  symbol: "WBTC",
129
99
  name: "Wrapped BTC",
130
100
  address: "0x50b7545627a5162F82A992c33b87aDc75187B218",
131
101
  decimals: 8,
132
102
  },
133
103
  ],
134
- } as Record<number, { aliases: string[], symbol: string, name: string, address: string, decimals: number }[]>;
104
+ };
@@ -17,19 +17,15 @@ export default async function (transaction: Transaction, type: 'source' | 'targe
17
17
  }
18
18
 
19
19
  if (type !== 'source') {
20
- throw new Error(`[WIP] Type not supported: ${type}`)
20
+ throw new Error(`Type not supported: ${type}`)
21
21
  }
22
22
 
23
- if (transaction.sourceStatus === 'pending') {
24
- throw Error('Source transaction already processesing')
25
- }
26
-
27
- if (transaction.sourceStatus === 'pending') {
28
- throw Error('Source transaction already processed')
23
+ if (transaction.action === 'withdraw' && transaction.sourceStatus === 'pending') {
24
+ throw Error('Cannot build data for pending withdraw transaction');
29
25
  }
30
26
 
31
27
  if (!transaction.requestEvent) {
32
- throw Error('Something went wrong, source transaction has no request event')
28
+ throw Error('Cannot build data for transaction without requestEvent');
33
29
  }
34
30
 
35
31
  const { bridger, position, sourceChainId, targetChainId, metadata, } = transaction.requestEvent;
@@ -39,22 +35,6 @@ export default async function (transaction: Transaction, type: 'source' | 'targe
39
35
  const contractAddress = addresses[sourceChainId].interopXContract;
40
36
  const contract = getContract<InteropXContract>(contractAddress, abi.interopXContract, sourceWallet);
41
37
 
42
- const sourceToken = tokens[sourceChainId].find( t => t.address.toLowerCase() === position.withdraw[0].sourceToken.toLowerCase());
43
-
44
- if(!sourceToken) {
45
- throw Error('Source token not found')
46
- }
47
-
48
- const targetToken = tokens[targetChainId].find( t => t.address.toLowerCase() === position.withdraw[0].targetToken.toLowerCase());
49
-
50
- if(!targetToken) {
51
- throw Error('Target token not found')
52
- }
53
-
54
- if(sourceToken.aliases.some(alias => targetToken.aliases.includes(alias))) {
55
- throw Error('Source and target token must be the same')
56
- }
57
-
58
38
  const { data } = await contract.populateTransaction.withdrawRequested(
59
39
  bridger,
60
40
  position.withdraw[0].sourceToken,
@@ -7,8 +7,6 @@ import { addresses } from '@/constants';
7
7
  import { ChainId } from '@/types'
8
8
  import { ethers } from 'ethers';
9
9
  import { GnosisSafe } from '@/typechain';
10
- import retry from 'async-retry'
11
-
12
10
  export const http = axios.create();
13
11
 
14
12
  axiosRetry(http, { retries: 3, retryDelay: axiosRetry.exponentialDelay });
@@ -143,13 +141,6 @@ export const generateInteropTransactionHash = (data: { action: string, bridger:
143
141
  ]);
144
142
  }
145
143
 
146
-
147
- export class ContractError extends Error {
148
- method: string;
149
- address: string;
150
- args: any[];
151
- }
152
-
153
144
  export function getContract<TContract extends ethers.Contract>(address: string, contractInterface: ethers.ContractInterface | any, signerOrProvider?: ethers.Signer | ethers.providers.Provider) {
154
145
  if (!ethers.utils.getAddress(address) || address === ethers.constants.AddressZero) {
155
146
  throw Error(`Invalid 'address' parameter '${address}'.`)
@@ -173,24 +164,11 @@ export function getContract<TContract extends ethers.Contract>(address: string,
173
164
  const value = Reflect.get(target, prop, receiver);
174
165
 
175
166
  if (typeof value === 'function' && (contract.functions.hasOwnProperty(prop) || ['queryFilter'].includes(String(prop)))) {
176
- let isConstant = false;
177
-
178
- try {
179
- isConstant = contract.interface.getFunction(String(prop)).constant
180
- } catch (error) {
181
- }
182
-
183
167
  return async (...args: any[]) => {
184
168
  try {
185
- return await retry(async () => await value.bind(contract)(...args), { retries: isConstant ? 1 : 3 });
169
+ return await value.bind(contract)(...args);
186
170
  } catch (error) {
187
- const err = new ContractError(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`)
188
-
189
- err.method = String(prop)
190
- err.address = address
191
- err.args = [...args]
192
-
193
- throw err
171
+ throw new Error(`Error calling "${String(prop)}" on "${address}": ${error.reason || error.message}`)
194
172
  }
195
173
  }
196
174
  }
@@ -206,15 +184,9 @@ export function getContract<TContract extends ethers.Contract>(address: string,
206
184
  if (typeof value === 'function') {
207
185
  return async (...args: any[]) => {
208
186
  try {
209
- return await retry(async () => await value.bind(contract)(...args), { retries: parentProp === 'callStatic' ? 3 : 1 });
187
+ return await value.bind(contract)(...args);
210
188
  } catch (error) {
211
- const err = new ContractError(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`)
212
-
213
- err.method = String(prop)
214
- err.address = address
215
- err.args = [...args]
216
-
217
- throw err
189
+ throw new Error(`Error calling "${String(prop)}" using "${parentProp}" on "${address}": ${error.reason || error.message}`)
218
190
  }
219
191
  }
220
192
  }
@@ -231,37 +203,37 @@ export const generateGnosisTransaction = async (transactionData: any, safeContra
231
203
  console.log(transactionData);
232
204
 
233
205
  let isExecuted = await safeContract.dataHashes(
234
- await safeContract.getTransactionHash(
235
- transactionData.to,
236
- transactionData.value,
237
- transactionData.data,
238
- transactionData.operation,
239
- transactionData.safeTxGas,
240
- transactionData.baseGas,
241
- transactionData.gasPrice,
242
- transactionData.gasToken,
243
- transactionData.refundReceiver,
244
- transactionData.nonce
245
- )
206
+ await safeContract.getTransactionHash(
207
+ transactionData.to,
208
+ transactionData.value,
209
+ transactionData.data,
210
+ transactionData.operation,
211
+ transactionData.safeTxGas,
212
+ transactionData.baseGas,
213
+ transactionData.gasPrice,
214
+ transactionData.gasToken,
215
+ transactionData.refundReceiver,
216
+ transactionData.nonce
217
+ )
246
218
  )
247
219
 
248
220
  while (isExecuted == 1) {
249
- transactionData.safeTxGas = ethers.BigNumber.from(String(transactionData.safeTxGas)).add(1).toString()
250
-
251
- isExecuted = await safeContract.dataHashes(
252
- await safeContract.getTransactionHash(
253
- transactionData.to,
254
- transactionData.value,
255
- transactionData.data,
256
- transactionData.operation,
257
- transactionData.safeTxGas,
258
- transactionData.baseGas,
259
- transactionData.gasPrice,
260
- transactionData.gasToken,
261
- transactionData.refundReceiver,
262
- transactionData.nonce
221
+ transactionData.safeTxGas = ethers.BigNumber.from(String(transactionData.safeTxGas)).add(1).toString()
222
+
223
+ isExecuted = await safeContract.dataHashes(
224
+ await safeContract.getTransactionHash(
225
+ transactionData.to,
226
+ transactionData.value,
227
+ transactionData.data,
228
+ transactionData.operation,
229
+ transactionData.safeTxGas,
230
+ transactionData.baseGas,
231
+ transactionData.gasPrice,
232
+ transactionData.gasToken,
233
+ transactionData.refundReceiver,
234
+ transactionData.nonce
235
+ )
263
236
  )
264
- )
265
237
  }
266
238
 
267
239
  return transactionData