@instadapp/interop-x 0.0.0-dev.ee3d74b → 0.0.0-dev.ef38dfb
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 +3 -1
- package/dist/src/abi/index.js +2 -0
- package/dist/src/abi/instList.json +232 -0
- package/dist/src/api/index.js +7 -0
- package/dist/src/constants/addresses.js +4 -2
- package/dist/src/db/models/transaction.js +15 -7
- package/dist/src/errors/index.js +10 -0
- package/dist/src/gnosis/actions/aaveV2/source.js +15 -4
- package/dist/src/gnosis/actions/aaveV2/target.js +78 -0
- package/dist/src/index.js +1 -1
- package/dist/src/tasks/InteropX/ProcessSubmitSubmitEvents.js +15 -3
- package/dist/src/tasks/InteropX/ProcessValidateEvents.js +184 -0
- package/dist/src/tasks/InteropX/SyncLogExecuteEvents.js +112 -0
- package/dist/src/tasks/InteropX/SyncLogSubmitEvents.js +1 -0
- package/dist/src/tasks/InteropX/SyncLogValidateEvents.js +105 -0
- package/dist/src/tasks/index.js +10 -1
- package/dist/src/typechain/InstList.js +2 -0
- package/dist/src/typechain/factories/InstList__factory.js +249 -0
- package/dist/src/typechain/factories/index.js +3 -1
- package/dist/src/typechain/index.js +3 -1
- package/dist/src/utils/async.js +18 -0
- package/dist/src/utils/dsa.js +24 -0
- package/dist/src/utils/formatting.js +17 -0
- package/dist/src/utils/gnosis.js +62 -0
- package/dist/src/utils/http.js +10 -0
- package/dist/src/utils/index.js +20 -219
- package/dist/src/utils/interop.js +16 -0
- package/dist/src/utils/web3.js +92 -0
- package/package.json +3 -1
- package/src/abi/index.ts +2 -0
- package/src/abi/instList.json +232 -0
- package/src/api/index.ts +8 -0
- package/src/constants/addresses.ts +5 -3
- package/src/db/models/transaction.ts +134 -80
- package/src/errors/index.ts +6 -0
- package/src/gnosis/actions/aaveV2/source.ts +19 -5
- package/src/gnosis/actions/aaveV2/target.ts +130 -2
- package/src/tasks/InteropX/ProcessSubmitSubmitEvents.ts +20 -3
- package/src/tasks/InteropX/ProcessValidateEvents.ts +274 -0
- package/src/tasks/InteropX/SyncLogExecuteEvents.ts +162 -0
- package/src/tasks/InteropX/SyncLogSubmitEvents.ts +1 -0
- package/src/tasks/InteropX/SyncLogValidateEvents.ts +152 -0
- package/src/tasks/index.ts +13 -1
- package/src/typechain/InstList.ts +402 -0
- package/src/typechain/factories/InstList__factory.ts +253 -0
- package/src/typechain/factories/index.ts +1 -0
- package/src/typechain/index.ts +2 -0
- package/src/utils/async.ts +22 -0
- package/src/utils/dsa.ts +30 -0
- package/src/utils/formatting.ts +15 -0
- package/src/utils/gnosis.ts +123 -0
- package/src/utils/http.ts +6 -0
- package/src/utils/index.ts +7 -365
- package/src/utils/interop.ts +28 -0
- package/src/utils/web3.ts +131 -0
|
@@ -0,0 +1,253 @@
|
|
|
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 { InstList, InstListInterface } from "../InstList";
|
|
8
|
+
|
|
9
|
+
const _abi = [
|
|
10
|
+
{
|
|
11
|
+
inputs: [
|
|
12
|
+
{
|
|
13
|
+
internalType: "address",
|
|
14
|
+
name: "_instaIndex",
|
|
15
|
+
type: "address",
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
stateMutability: "nonpayable",
|
|
19
|
+
type: "constructor",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
inputs: [
|
|
23
|
+
{
|
|
24
|
+
internalType: "uint64",
|
|
25
|
+
name: "",
|
|
26
|
+
type: "uint64",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
name: "accountAddr",
|
|
30
|
+
outputs: [
|
|
31
|
+
{
|
|
32
|
+
internalType: "address",
|
|
33
|
+
name: "",
|
|
34
|
+
type: "address",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
stateMutability: "view",
|
|
38
|
+
type: "function",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
inputs: [
|
|
42
|
+
{
|
|
43
|
+
internalType: "address",
|
|
44
|
+
name: "",
|
|
45
|
+
type: "address",
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
name: "accountID",
|
|
49
|
+
outputs: [
|
|
50
|
+
{
|
|
51
|
+
internalType: "uint64",
|
|
52
|
+
name: "",
|
|
53
|
+
type: "uint64",
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
stateMutability: "view",
|
|
57
|
+
type: "function",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
inputs: [
|
|
61
|
+
{
|
|
62
|
+
internalType: "uint64",
|
|
63
|
+
name: "",
|
|
64
|
+
type: "uint64",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
name: "accountLink",
|
|
68
|
+
outputs: [
|
|
69
|
+
{
|
|
70
|
+
internalType: "address",
|
|
71
|
+
name: "first",
|
|
72
|
+
type: "address",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
internalType: "address",
|
|
76
|
+
name: "last",
|
|
77
|
+
type: "address",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
internalType: "uint64",
|
|
81
|
+
name: "count",
|
|
82
|
+
type: "uint64",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
stateMutability: "view",
|
|
86
|
+
type: "function",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
inputs: [
|
|
90
|
+
{
|
|
91
|
+
internalType: "uint64",
|
|
92
|
+
name: "",
|
|
93
|
+
type: "uint64",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
internalType: "address",
|
|
97
|
+
name: "",
|
|
98
|
+
type: "address",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
name: "accountList",
|
|
102
|
+
outputs: [
|
|
103
|
+
{
|
|
104
|
+
internalType: "address",
|
|
105
|
+
name: "prev",
|
|
106
|
+
type: "address",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
internalType: "address",
|
|
110
|
+
name: "next",
|
|
111
|
+
type: "address",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
stateMutability: "view",
|
|
115
|
+
type: "function",
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
inputs: [],
|
|
119
|
+
name: "accounts",
|
|
120
|
+
outputs: [
|
|
121
|
+
{
|
|
122
|
+
internalType: "uint64",
|
|
123
|
+
name: "",
|
|
124
|
+
type: "uint64",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
stateMutability: "view",
|
|
128
|
+
type: "function",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
inputs: [
|
|
132
|
+
{
|
|
133
|
+
internalType: "address",
|
|
134
|
+
name: "_owner",
|
|
135
|
+
type: "address",
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
name: "addAuth",
|
|
139
|
+
outputs: [],
|
|
140
|
+
stateMutability: "nonpayable",
|
|
141
|
+
type: "function",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
inputs: [
|
|
145
|
+
{
|
|
146
|
+
internalType: "address",
|
|
147
|
+
name: "_account",
|
|
148
|
+
type: "address",
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
name: "init",
|
|
152
|
+
outputs: [],
|
|
153
|
+
stateMutability: "nonpayable",
|
|
154
|
+
type: "function",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
inputs: [],
|
|
158
|
+
name: "instaIndex",
|
|
159
|
+
outputs: [
|
|
160
|
+
{
|
|
161
|
+
internalType: "address",
|
|
162
|
+
name: "",
|
|
163
|
+
type: "address",
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
stateMutability: "view",
|
|
167
|
+
type: "function",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
inputs: [
|
|
171
|
+
{
|
|
172
|
+
internalType: "address",
|
|
173
|
+
name: "_owner",
|
|
174
|
+
type: "address",
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
name: "removeAuth",
|
|
178
|
+
outputs: [],
|
|
179
|
+
stateMutability: "nonpayable",
|
|
180
|
+
type: "function",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
inputs: [
|
|
184
|
+
{
|
|
185
|
+
internalType: "address",
|
|
186
|
+
name: "",
|
|
187
|
+
type: "address",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
name: "userLink",
|
|
191
|
+
outputs: [
|
|
192
|
+
{
|
|
193
|
+
internalType: "uint64",
|
|
194
|
+
name: "first",
|
|
195
|
+
type: "uint64",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
internalType: "uint64",
|
|
199
|
+
name: "last",
|
|
200
|
+
type: "uint64",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
internalType: "uint64",
|
|
204
|
+
name: "count",
|
|
205
|
+
type: "uint64",
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
stateMutability: "view",
|
|
209
|
+
type: "function",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
inputs: [
|
|
213
|
+
{
|
|
214
|
+
internalType: "address",
|
|
215
|
+
name: "",
|
|
216
|
+
type: "address",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
internalType: "uint64",
|
|
220
|
+
name: "",
|
|
221
|
+
type: "uint64",
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
name: "userList",
|
|
225
|
+
outputs: [
|
|
226
|
+
{
|
|
227
|
+
internalType: "uint64",
|
|
228
|
+
name: "prev",
|
|
229
|
+
type: "uint64",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
internalType: "uint64",
|
|
233
|
+
name: "next",
|
|
234
|
+
type: "uint64",
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
stateMutability: "view",
|
|
238
|
+
type: "function",
|
|
239
|
+
},
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
export class InstList__factory {
|
|
243
|
+
static readonly abi = _abi;
|
|
244
|
+
static createInterface(): InstListInterface {
|
|
245
|
+
return new utils.Interface(_abi) as InstListInterface;
|
|
246
|
+
}
|
|
247
|
+
static connect(
|
|
248
|
+
address: string,
|
|
249
|
+
signerOrProvider: Signer | Provider
|
|
250
|
+
): InstList {
|
|
251
|
+
return new Contract(address, _abi, signerOrProvider) as InstList;
|
|
252
|
+
}
|
|
253
|
+
}
|
package/src/typechain/index.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
export type { Erc20 } from "./Erc20";
|
|
5
5
|
export type { GnosisSafe } from "./GnosisSafe";
|
|
6
|
+
export type { InstList } from "./InstList";
|
|
6
7
|
export type { InteropX } from "./InteropX";
|
|
7
8
|
export * as factories from "./factories";
|
|
8
9
|
export { Erc20__factory } from "./factories/Erc20__factory";
|
|
9
10
|
export { GnosisSafe__factory } from "./factories/GnosisSafe__factory";
|
|
11
|
+
export { InstList__factory } from "./factories/InstList__factory";
|
|
10
12
|
export { InteropX__factory } from "./factories/InteropX__factory";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Call an async function with a maximum time limit (in milliseconds) for the timeout
|
|
3
|
+
* Resolved promise for async function call, or an error if time limit reached
|
|
4
|
+
*/
|
|
5
|
+
export const asyncCallWithTimeout = async <T>(
|
|
6
|
+
asyncPromise: Promise<T>,
|
|
7
|
+
timeout: number
|
|
8
|
+
) => {
|
|
9
|
+
let timeoutHandle;
|
|
10
|
+
|
|
11
|
+
const timeoutPromise = new Promise((_resolve, reject) => {
|
|
12
|
+
timeoutHandle = setTimeout(
|
|
13
|
+
() => reject(new Error("Async call timeout limit reached")),
|
|
14
|
+
timeout
|
|
15
|
+
);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return Promise.race([asyncPromise, timeoutPromise]).then((result) => {
|
|
19
|
+
clearTimeout(timeoutHandle);
|
|
20
|
+
return result;
|
|
21
|
+
}) as Promise<T>;
|
|
22
|
+
};
|
package/src/utils/dsa.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Web3EthAbi from "web3-eth-abi";
|
|
2
|
+
import { connectors } from "@/abi/connectors";
|
|
3
|
+
|
|
4
|
+
export const encodeConnectorMethod = (params: {
|
|
5
|
+
connector: string;
|
|
6
|
+
method: string;
|
|
7
|
+
args: string[];
|
|
8
|
+
}) => {
|
|
9
|
+
const connectorInterface = getInterface(
|
|
10
|
+
connectors.versions[2][params.connector],
|
|
11
|
+
params.method
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
if (!connectorInterface)
|
|
15
|
+
throw new Error(`ConnectorInterface '${params.method}' not found`);
|
|
16
|
+
|
|
17
|
+
//@ts-ignore
|
|
18
|
+
return Web3EthAbi.encodeFunctionCall(connectorInterface, params.args);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getInterface = (abiItems: any[], method: string) => {
|
|
22
|
+
const abiItem = abiItems.find((abiItem) => abiItem.name === method);
|
|
23
|
+
|
|
24
|
+
if (!abiItem) {
|
|
25
|
+
console.error(`${method} is an invalid method.`);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return abiItem;
|
|
30
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function shortenHash(hash: string, length: number = 4) {
|
|
2
|
+
if (!hash) return;
|
|
3
|
+
|
|
4
|
+
if (hash.length < 12) return hash;
|
|
5
|
+
|
|
6
|
+
const beginningChars = hash.startsWith("0x") ? length + 2 : length;
|
|
7
|
+
|
|
8
|
+
const shortened = hash.substr(0, beginningChars) + "…" + hash.substr(-length);
|
|
9
|
+
|
|
10
|
+
return shortened;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function short(buffer: Buffer): string {
|
|
14
|
+
return buffer.toString("hex").slice(0, 8) + "...";
|
|
15
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { addresses } from "@/constants";
|
|
2
|
+
import { GnosisSafe } from "@/typechain";
|
|
3
|
+
import { ChainId } from "@/types";
|
|
4
|
+
import { ethers, Wallet } from "ethers";
|
|
5
|
+
|
|
6
|
+
export interface Signature {
|
|
7
|
+
signer: string;
|
|
8
|
+
hash?: string;
|
|
9
|
+
data: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const buildSignatureBytes = (signatures: Signature[]): string => {
|
|
13
|
+
signatures.sort((left, right) =>
|
|
14
|
+
left.signer.toLowerCase().localeCompare(right.signer.toLowerCase())
|
|
15
|
+
);
|
|
16
|
+
let signatureBytes = "0x";
|
|
17
|
+
for (const sig of signatures) {
|
|
18
|
+
signatureBytes += sig.data.slice(2);
|
|
19
|
+
}
|
|
20
|
+
return signatureBytes;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const signGnosisSafeTx = async (
|
|
24
|
+
{
|
|
25
|
+
to,
|
|
26
|
+
data = null as any,
|
|
27
|
+
value = "0",
|
|
28
|
+
operation = "1",
|
|
29
|
+
baseGas = "0",
|
|
30
|
+
gasPrice = "0",
|
|
31
|
+
gasToken = "0x0000000000000000000000000000000000000000",
|
|
32
|
+
refundReceiver = "0x0000000000000000000000000000000000000000",
|
|
33
|
+
safeTxGas = "79668" as string | number,
|
|
34
|
+
nonce = "0",
|
|
35
|
+
chainId = 137 as ChainId,
|
|
36
|
+
},
|
|
37
|
+
{ signer }: { signer: Wallet }
|
|
38
|
+
) => {
|
|
39
|
+
const gnosisSafe = addresses[chainId].gnosisSafe;
|
|
40
|
+
|
|
41
|
+
const domain = {
|
|
42
|
+
verifyingContract: gnosisSafe,
|
|
43
|
+
chainId,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const types = {
|
|
47
|
+
SafeTx: [
|
|
48
|
+
{ type: "address", name: "to" },
|
|
49
|
+
{ type: "uint256", name: "value" },
|
|
50
|
+
{ type: "bytes", name: "data" },
|
|
51
|
+
{ type: "uint8", name: "operation" },
|
|
52
|
+
{ type: "uint256", name: "safeTxGas" },
|
|
53
|
+
{ type: "uint256", name: "baseGas" },
|
|
54
|
+
{ type: "uint256", name: "gasPrice" },
|
|
55
|
+
{ type: "address", name: "gasToken" },
|
|
56
|
+
{ type: "address", name: "refundReceiver" },
|
|
57
|
+
{ type: "uint256", name: "nonce" },
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const message = {
|
|
62
|
+
baseGas,
|
|
63
|
+
data,
|
|
64
|
+
gasPrice,
|
|
65
|
+
gasToken,
|
|
66
|
+
nonce: Number(nonce),
|
|
67
|
+
operation,
|
|
68
|
+
refundReceiver,
|
|
69
|
+
safeAddress: gnosisSafe,
|
|
70
|
+
safeTxGas: String(safeTxGas),
|
|
71
|
+
to,
|
|
72
|
+
value,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return await signer._signTypedData(domain, types, message);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const generateGnosisTransaction = async (
|
|
79
|
+
transactionData: any,
|
|
80
|
+
safeContract: GnosisSafe
|
|
81
|
+
) => {
|
|
82
|
+
console.log(transactionData);
|
|
83
|
+
|
|
84
|
+
let isExecuted = await safeContract.dataHashes(
|
|
85
|
+
await safeContract.getTransactionHash(
|
|
86
|
+
transactionData.to,
|
|
87
|
+
transactionData.value,
|
|
88
|
+
transactionData.data,
|
|
89
|
+
transactionData.operation,
|
|
90
|
+
transactionData.safeTxGas,
|
|
91
|
+
transactionData.baseGas,
|
|
92
|
+
transactionData.gasPrice,
|
|
93
|
+
transactionData.gasToken,
|
|
94
|
+
transactionData.refundReceiver,
|
|
95
|
+
transactionData.nonce
|
|
96
|
+
)
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
while (isExecuted == 1) {
|
|
100
|
+
transactionData.safeTxGas = ethers.BigNumber.from(
|
|
101
|
+
String(transactionData.safeTxGas)
|
|
102
|
+
)
|
|
103
|
+
.add(1)
|
|
104
|
+
.toString();
|
|
105
|
+
|
|
106
|
+
isExecuted = await safeContract.dataHashes(
|
|
107
|
+
await safeContract.getTransactionHash(
|
|
108
|
+
transactionData.to,
|
|
109
|
+
transactionData.value,
|
|
110
|
+
transactionData.data,
|
|
111
|
+
transactionData.operation,
|
|
112
|
+
transactionData.safeTxGas,
|
|
113
|
+
transactionData.baseGas,
|
|
114
|
+
transactionData.gasPrice,
|
|
115
|
+
transactionData.gasToken,
|
|
116
|
+
transactionData.refundReceiver,
|
|
117
|
+
transactionData.nonce
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return transactionData;
|
|
123
|
+
};
|