@instadapp/avocado-base 0.0.0-dev.e144f0f → 0.0.0-dev.e698742
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/abi/forwarder.json +1253 -149
- package/abi/multisigForwarder.json +697 -0
- package/app.vue +7 -0
- package/assets/images/icons/arrow-left.svg +5 -0
- package/assets/images/icons/arrow-right.svg +5 -0
- package/assets/images/icons/avocado.svg +4 -0
- package/assets/images/icons/bridge-2.svg +3 -0
- package/assets/images/icons/bridge.svg +7 -0
- package/assets/images/icons/calendar.svg +8 -0
- package/assets/images/icons/change-threshold.svg +4 -0
- package/assets/images/icons/check-circle.svg +4 -0
- package/assets/images/icons/chevron-down.svg +4 -0
- package/assets/images/icons/clipboard.svg +7 -0
- package/assets/images/icons/clock-circle.svg +5 -0
- package/assets/images/icons/copy.svg +5 -0
- package/assets/images/icons/cross-transfer.svg +7 -0
- package/assets/images/icons/dapp.svg +4 -0
- package/assets/images/icons/deploy.svg +12 -0
- package/assets/images/icons/error-circle.svg +6 -0
- package/assets/images/icons/exclamation-circle.svg +13 -0
- package/assets/images/icons/exclamation-octagon.svg +13 -0
- package/assets/images/icons/exclamation-triangle.svg +5 -0
- package/assets/images/icons/external-link.svg +6 -0
- package/assets/images/icons/eye.svg +4 -0
- package/assets/images/icons/flowers.svg +8 -0
- package/assets/images/icons/gas-emoji.svg +193 -0
- package/assets/images/icons/gas.svg +14 -0
- package/assets/images/icons/gift.svg +153 -0
- package/assets/images/icons/globe.svg +110 -0
- package/assets/images/icons/hamburger.svg +6 -0
- package/assets/images/icons/info-2.svg +12 -0
- package/assets/images/icons/instadapp-pro.svg +4 -0
- package/assets/images/icons/logout.svg +3 -0
- package/assets/images/icons/moon.svg +3 -0
- package/assets/images/icons/multi-send.svg +7 -0
- package/assets/images/icons/network.svg +13 -0
- package/assets/images/icons/options.svg +5 -0
- package/assets/images/icons/permit-sign.svg +11 -0
- package/assets/images/icons/plus-circle.svg +6 -0
- package/assets/images/icons/plus.svg +5 -0
- package/assets/images/icons/power-off-bg.svg +24 -0
- package/assets/images/icons/power-off.svg +19 -0
- package/assets/images/icons/power-on.svg +19 -0
- package/assets/images/icons/qr.svg +20 -0
- package/assets/images/icons/question-circle.svg +14 -0
- package/assets/images/icons/refresh.svg +6 -0
- package/assets/images/icons/reject-proposal.svg +6 -0
- package/assets/images/icons/search.svg +12 -0
- package/assets/images/icons/sun.svg +3 -0
- package/assets/images/icons/transfer.svg +5 -0
- package/assets/images/icons/trash-2.svg +8 -0
- package/assets/images/icons/upgrade.svg +4 -0
- package/assets/images/icons/wave.svg +214 -0
- package/assets/images/icons/x.svg +5 -0
- package/components/ActionLogo.vue +38 -0
- package/components/ActionMetadata.vue +72 -0
- package/components/AuthorityAvatar.vue +38 -0
- package/components/ChainLogo.vue +14 -556
- package/components/CopyClipboard.vue +64 -0
- package/components/metadata/Bridge.vue +59 -0
- package/components/metadata/CrossTransfer.vue +71 -0
- package/components/metadata/GasTopup.vue +39 -0
- package/components/metadata/Permit2.vue +42 -0
- package/components/metadata/Signers.vue +62 -0
- package/components/metadata/Swap.vue +74 -0
- package/components/metadata/Transfer.vue +50 -0
- package/components.d.ts +13 -0
- package/contracts/Forwarder.ts +856 -2
- package/contracts/MultisigForwarder.ts +859 -0
- package/contracts/factories/Forwarder__factory.ts +816 -16
- package/contracts/factories/MultisigForwarder__factory.ts +721 -0
- package/contracts/factories/index.ts +1 -0
- package/contracts/index.ts +2 -0
- package/nuxt.config.ts +17 -1
- package/package.json +9 -4
- package/utils/avocado.ts +2 -0
- package/utils/bignumber.ts +20 -0
- package/utils/formatter.ts +1 -1
- package/utils/helper.ts +8 -0
- package/utils/metadata.ts +316 -136
- package/utils/network.ts +155 -87
- package/utils/services.ts +21 -0
- package/utils/utils.d.ts +129 -105
package/contracts/index.ts
CHANGED
|
@@ -6,9 +6,11 @@ export type { BalanceResolver } from "./BalanceResolver";
|
|
|
6
6
|
export type { Erc20 } from "./Erc20";
|
|
7
7
|
export type { Forwarder } from "./Forwarder";
|
|
8
8
|
export type { GaslessWallet } from "./GaslessWallet";
|
|
9
|
+
export type { MultisigForwarder } from "./MultisigForwarder";
|
|
9
10
|
export * as factories from "./factories";
|
|
10
11
|
export { AvoFactoryProxy__factory } from "./factories/AvoFactoryProxy__factory";
|
|
11
12
|
export { BalanceResolver__factory } from "./factories/BalanceResolver__factory";
|
|
12
13
|
export { Erc20__factory } from "./factories/Erc20__factory";
|
|
13
14
|
export { Forwarder__factory } from "./factories/Forwarder__factory";
|
|
14
15
|
export { GaslessWallet__factory } from "./factories/GaslessWallet__factory";
|
|
16
|
+
export { MultisigForwarder__factory } from "./factories/MultisigForwarder__factory";
|
package/nuxt.config.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
|
2
|
+
import ViteComponents from "unplugin-vue-components/vite";
|
|
3
|
+
|
|
2
4
|
export default defineNuxtConfig({
|
|
3
|
-
modules: ["@nuxtjs/tailwindcss"],
|
|
5
|
+
modules: ["@nuxtjs/tailwindcss", "nuxt-svgo", "@vueuse/nuxt"],
|
|
6
|
+
svgo: {
|
|
7
|
+
defaultImport: "component",
|
|
8
|
+
autoImportPath: "./assets/images/icons",
|
|
9
|
+
svgoConfig: {
|
|
10
|
+
plugins: ["prefixIds"],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
vite: {
|
|
14
|
+
plugins: [
|
|
15
|
+
ViteComponents({
|
|
16
|
+
dts: true,
|
|
17
|
+
}),
|
|
18
|
+
],
|
|
19
|
+
},
|
|
4
20
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instadapp/avocado-base",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.e698742",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"types": "global.d.ts",
|
|
@@ -16,12 +16,17 @@
|
|
|
16
16
|
"@instadapp/avocado-dev": "npm:@instadapp/avocado@dev",
|
|
17
17
|
"@nuxtjs/tailwindcss": "^6.6.5",
|
|
18
18
|
"@typechain/ethers-v5": "^10.2.0",
|
|
19
|
-
"nuxt": "^3.
|
|
19
|
+
"nuxt": "^3.6.1",
|
|
20
|
+
"nuxt-svgo": "^3.1.0",
|
|
20
21
|
"rimraf": "^3.0.2",
|
|
21
|
-
"typechain": "^8.1.1"
|
|
22
|
+
"typechain": "^8.1.1",
|
|
23
|
+
"unplugin-vue-components": "^0.25.1",
|
|
24
|
+
"vue-tippy": "^6.0.0"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
27
|
+
"@vueuse/nuxt": "^10.2.0",
|
|
24
28
|
"bignumber.js": "^9.1.1",
|
|
25
|
-
"ethers": "^5.7.2"
|
|
29
|
+
"ethers": "^5.7.2",
|
|
30
|
+
"xxhashjs": "^0.2.2"
|
|
26
31
|
}
|
|
27
32
|
}
|
package/utils/avocado.ts
CHANGED
package/utils/bignumber.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { BigNumber } from "bignumber.js";
|
|
2
2
|
import { BigNumber as BN } from "ethers";
|
|
3
3
|
|
|
4
|
+
type CombinedBigNumber = BigNumber | string | number;
|
|
5
|
+
|
|
4
6
|
export const toBN = (value: BigNumber.Value | BN) =>
|
|
5
7
|
new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
|
|
6
8
|
export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
|
|
@@ -29,3 +31,21 @@ export const ensureValue = (value: any) => {
|
|
|
29
31
|
export const max = (...args: BigNumber.Value[]) => {
|
|
30
32
|
return BigNumber.max(...args);
|
|
31
33
|
};
|
|
34
|
+
|
|
35
|
+
export function pow(value: CombinedBigNumber, exponent: string | number) {
|
|
36
|
+
return toBN(value).pow(toBN(exponent));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function toWei(val: CombinedBigNumber, decimals: number): string {
|
|
40
|
+
const num = toBN(val);
|
|
41
|
+
const multiplier = pow(10, decimals);
|
|
42
|
+
return times(num, multiplier).toFixed(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function fromWei(val: CombinedBigNumber, decimal = 18) {
|
|
46
|
+
return toBN(val).div(new BigNumber(10).pow(decimal));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function abs(value: CombinedBigNumber) {
|
|
50
|
+
return toBN(value).abs();
|
|
51
|
+
}
|
package/utils/formatter.ts
CHANGED
package/utils/helper.ts
CHANGED
|
@@ -52,3 +52,11 @@ export function onImageError(this: HTMLImageElement) {
|
|
|
52
52
|
parentElement.classList.add("bg-gray-300");
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
export function formatMultipleAddresses(addresses: string[], shorten = true) {
|
|
57
|
+
const formatter = new Intl.ListFormat('en', { style: 'long', type: 'conjunction' })
|
|
58
|
+
const formattedString = formatter.format(addresses.map(i => shorten ? shortenHash(i) || '' : i))
|
|
59
|
+
|
|
60
|
+
return formattedString
|
|
61
|
+
}
|
|
62
|
+
|
package/utils/metadata.ts
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
import { ethers, utils } from "ethers";
|
|
2
|
-
import { Forwarder__factory } from "
|
|
2
|
+
import { Forwarder__factory, MultisigForwarder__factory } from "../contracts";
|
|
3
|
+
import { toBN } from "./bignumber";
|
|
4
|
+
|
|
5
|
+
export const MetadataEnums = {
|
|
6
|
+
"transfer": "transfer",
|
|
7
|
+
"bridge": "bridge",
|
|
8
|
+
"swap": "swap",
|
|
9
|
+
"gas-topup": "gas-topup",
|
|
10
|
+
"upgrade": "upgrade",
|
|
11
|
+
"dapp": "dapp",
|
|
12
|
+
"deploy": "deploy",
|
|
13
|
+
"permit2": "permit2",
|
|
14
|
+
"cross-transfer": "cross-transfer",
|
|
15
|
+
"auth": "auth",
|
|
16
|
+
"rejection": "rejection",
|
|
17
|
+
"instadapp-pro": "instadapp-pro",
|
|
18
|
+
"add-signers": "add-signers",
|
|
19
|
+
"remove-signers": "remove-signers",
|
|
20
|
+
"change-threshold": "change-threshold",
|
|
21
|
+
} as const;
|
|
3
22
|
|
|
4
23
|
const multiMetadataTypes = ["bytes[]"];
|
|
5
24
|
|
|
6
25
|
const metadataTypes = ["bytes32 type", "uint8 version", "bytes data"];
|
|
7
26
|
|
|
8
|
-
const actionMetadataTypes = {
|
|
27
|
+
const actionMetadataTypes: Record<MetadataTypes, string[]> = {
|
|
9
28
|
transfer: ["address token", "uint256 amount", "address receiver"],
|
|
10
29
|
"cross-transfer": [
|
|
11
30
|
"address fromToken",
|
|
12
31
|
"address toToken",
|
|
32
|
+
"uint256 toChainId",
|
|
13
33
|
"uint256 amount",
|
|
14
34
|
"address receiver",
|
|
15
35
|
],
|
|
@@ -33,6 +53,7 @@ const actionMetadataTypes = {
|
|
|
33
53
|
"gas-topup": ["uint256 amount", "address token", "address onBehalf"],
|
|
34
54
|
upgrade: ["bytes32 version", "address walletImpl"],
|
|
35
55
|
dapp: ["string name", "string url"],
|
|
56
|
+
auth: ["address address", "uint256 chainId", "bool remove"],
|
|
36
57
|
deploy: [],
|
|
37
58
|
permit2: [
|
|
38
59
|
"address token",
|
|
@@ -40,6 +61,11 @@ const actionMetadataTypes = {
|
|
|
40
61
|
"uint160 amount",
|
|
41
62
|
"uint48 expiration",
|
|
42
63
|
],
|
|
64
|
+
"instadapp-pro": ["string castDetails"],
|
|
65
|
+
'add-signers': ['address[] signers'],
|
|
66
|
+
'remove-signers': ['address[] signers'],
|
|
67
|
+
'change-threshold': ['uint8 count'],
|
|
68
|
+
'rejection': ['bytes32 id'],
|
|
43
69
|
};
|
|
44
70
|
|
|
45
71
|
const encodeMetadata = (props: MetadataProps) => {
|
|
@@ -60,7 +86,7 @@ export const encodeDappMetadata = (
|
|
|
60
86
|
);
|
|
61
87
|
|
|
62
88
|
const data = encodeMetadata({
|
|
63
|
-
type:
|
|
89
|
+
type: MetadataEnums.dapp,
|
|
64
90
|
encodedData,
|
|
65
91
|
});
|
|
66
92
|
|
|
@@ -77,7 +103,21 @@ export const encodeTransferMetadata = (
|
|
|
77
103
|
);
|
|
78
104
|
|
|
79
105
|
const data = encodeMetadata({
|
|
80
|
-
type:
|
|
106
|
+
type: MetadataEnums.transfer,
|
|
107
|
+
encodedData,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return single ? encodeMultipleActions(data) : data;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const encodeRejectionMetadata = (id: string, single = true) => {
|
|
114
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
115
|
+
actionMetadataTypes.rejection,
|
|
116
|
+
[id]
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const data = encodeMetadata({
|
|
120
|
+
type: MetadataEnums.rejection,
|
|
81
121
|
encodedData,
|
|
82
122
|
});
|
|
83
123
|
|
|
@@ -85,16 +125,39 @@ export const encodeTransferMetadata = (
|
|
|
85
125
|
};
|
|
86
126
|
|
|
87
127
|
export const encodeCrossTransferMetadata = (
|
|
88
|
-
params:
|
|
128
|
+
params: CrossSendMetadataProps,
|
|
89
129
|
single = true
|
|
90
130
|
) => {
|
|
91
131
|
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
92
132
|
actionMetadataTypes["cross-transfer"],
|
|
93
|
-
[
|
|
133
|
+
[
|
|
134
|
+
params.fromToken,
|
|
135
|
+
params.toToken,
|
|
136
|
+
params.toChainId,
|
|
137
|
+
params.amount,
|
|
138
|
+
params.receiver,
|
|
139
|
+
]
|
|
94
140
|
);
|
|
95
141
|
|
|
96
142
|
const data = encodeMetadata({
|
|
97
|
-
type: "cross-transfer",
|
|
143
|
+
type: MetadataEnums["cross-transfer"],
|
|
144
|
+
encodedData,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
return single ? encodeMultipleActions(data) : data;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const encodeAuthMetadata = (
|
|
151
|
+
params: AuthMetadataProps,
|
|
152
|
+
single = true
|
|
153
|
+
) => {
|
|
154
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
155
|
+
actionMetadataTypes["auth"],
|
|
156
|
+
[params.address, params.chainId, params.remove]
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const data = encodeMetadata({
|
|
160
|
+
type: MetadataEnums.auth,
|
|
98
161
|
encodedData,
|
|
99
162
|
});
|
|
100
163
|
|
|
@@ -103,7 +166,7 @@ export const encodeCrossTransferMetadata = (
|
|
|
103
166
|
|
|
104
167
|
export const encodeDeployMetadata = (single = true) => {
|
|
105
168
|
const data = encodeMetadata({
|
|
106
|
-
type:
|
|
169
|
+
type: MetadataEnums.deploy,
|
|
107
170
|
encodedData: "0x",
|
|
108
171
|
});
|
|
109
172
|
|
|
@@ -120,7 +183,7 @@ export const encodeWCSignMetadata = (
|
|
|
120
183
|
);
|
|
121
184
|
|
|
122
185
|
const data = encodeMetadata({
|
|
123
|
-
type:
|
|
186
|
+
type: MetadataEnums.permit2,
|
|
124
187
|
encodedData,
|
|
125
188
|
});
|
|
126
189
|
|
|
@@ -137,7 +200,7 @@ export const encodeUpgradeMetadata = (
|
|
|
137
200
|
);
|
|
138
201
|
|
|
139
202
|
const data = encodeMetadata({
|
|
140
|
-
type:
|
|
203
|
+
type: MetadataEnums.upgrade,
|
|
141
204
|
encodedData,
|
|
142
205
|
});
|
|
143
206
|
|
|
@@ -161,7 +224,7 @@ export const encodeSwapMetadata = (
|
|
|
161
224
|
);
|
|
162
225
|
|
|
163
226
|
const data = encodeMetadata({
|
|
164
|
-
type:
|
|
227
|
+
type: MetadataEnums.swap,
|
|
165
228
|
encodedData,
|
|
166
229
|
});
|
|
167
230
|
|
|
@@ -177,10 +240,8 @@ export const encodeTopupMetadata = (
|
|
|
177
240
|
[params.amount, params.token, params.onBehalf]
|
|
178
241
|
);
|
|
179
242
|
|
|
180
|
-
console.log(params);
|
|
181
|
-
|
|
182
243
|
const data = encodeMetadata({
|
|
183
|
-
type: "gas-topup",
|
|
244
|
+
type: MetadataEnums["gas-topup"],
|
|
184
245
|
encodedData,
|
|
185
246
|
});
|
|
186
247
|
|
|
@@ -205,7 +266,58 @@ export const encodeBridgeMetadata = (
|
|
|
205
266
|
);
|
|
206
267
|
|
|
207
268
|
const data = encodeMetadata({
|
|
208
|
-
type:
|
|
269
|
+
type: MetadataEnums.bridge,
|
|
270
|
+
encodedData,
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
return single ? encodeMultipleActions(data) : data;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const encodeChangeThresholdMetadata = (
|
|
277
|
+
threshold: string | number,
|
|
278
|
+
single = true
|
|
279
|
+
) => {
|
|
280
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
281
|
+
actionMetadataTypes["change-threshold"],
|
|
282
|
+
[toBN(threshold).toNumber()]
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
const data = encodeMetadata({
|
|
286
|
+
type: MetadataEnums["change-threshold"],
|
|
287
|
+
encodedData,
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return single ? encodeMultipleActions(data) : data;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export const encodeRemoveSignersMetadata = (
|
|
294
|
+
addresses: string[],
|
|
295
|
+
single = true
|
|
296
|
+
) => {
|
|
297
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
298
|
+
actionMetadataTypes["remove-signers"],
|
|
299
|
+
[addresses]
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
const data = encodeMetadata({
|
|
303
|
+
type: MetadataEnums["remove-signers"],
|
|
304
|
+
encodedData,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
return single ? encodeMultipleActions(data) : data;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
export const encodeAddSignersMetadata = (
|
|
311
|
+
addresses: string[],
|
|
312
|
+
single = true
|
|
313
|
+
) => {
|
|
314
|
+
const encodedData = ethers.utils.defaultAbiCoder.encode(
|
|
315
|
+
actionMetadataTypes["add-signers"],
|
|
316
|
+
[addresses]
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
const data = encodeMetadata({
|
|
320
|
+
type: MetadataEnums["add-signers"],
|
|
209
321
|
encodedData,
|
|
210
322
|
});
|
|
211
323
|
|
|
@@ -216,134 +328,202 @@ export const encodeMultipleActions = (...actionData: string[]) => {
|
|
|
216
328
|
return ethers.utils.defaultAbiCoder.encode(multiMetadataTypes, [actionData]);
|
|
217
329
|
};
|
|
218
330
|
|
|
219
|
-
export const
|
|
331
|
+
export const decodeData = (data: string) => {
|
|
332
|
+
try {
|
|
333
|
+
const metadata = getMetadataFromData(data) || "0x";
|
|
334
|
+
|
|
335
|
+
return parseMetadata(metadata);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
// console.log(e);
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export const decodeMetadata = (metadata: string) => {
|
|
220
343
|
try {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
344
|
+
return parseMetadata(metadata);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
return null;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const iface = Forwarder__factory.createInterface();
|
|
351
|
+
const ifaceMultisig = MultisigForwarder__factory.createInterface();
|
|
352
|
+
|
|
353
|
+
const getMetadataFromData = (data: string) => {
|
|
354
|
+
let metadata = "0x";
|
|
355
|
+
|
|
356
|
+
if (data.startsWith("0x18e7f485")) {
|
|
357
|
+
const executeData = iface.decodeFunctionData("execute", data);
|
|
358
|
+
if (executeData.metadata_ === "0x" || !executeData.metadata_) {
|
|
359
|
+
return null;
|
|
360
|
+
} else {
|
|
361
|
+
metadata = executeData.metadata_;
|
|
362
|
+
}
|
|
363
|
+
} else if (data.startsWith("0x14f80a8d")) {
|
|
364
|
+
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
365
|
+
if (
|
|
366
|
+
executeDataV2.params_.metadata === "0x" ||
|
|
367
|
+
!executeDataV2.params_.metadata
|
|
368
|
+
) {
|
|
369
|
+
return null;
|
|
234
370
|
} else {
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
executeDataV2.params_.metadata === "0x" ||
|
|
238
|
-
!executeDataV2.params_.metadata
|
|
239
|
-
) {
|
|
240
|
-
return null;
|
|
241
|
-
} else {
|
|
242
|
-
metadata = executeDataV2.params_.metadata;
|
|
243
|
-
}
|
|
371
|
+
metadata = executeDataV2.params_.metadata;
|
|
244
372
|
}
|
|
373
|
+
} else {
|
|
374
|
+
const executeDataMultisig = ifaceMultisig.decodeFunctionData(
|
|
375
|
+
"executeV1",
|
|
376
|
+
data
|
|
377
|
+
);
|
|
378
|
+
if (
|
|
379
|
+
executeDataMultisig.params_.metadata === "0x" ||
|
|
380
|
+
!executeDataMultisig.params_.metadata
|
|
381
|
+
) {
|
|
382
|
+
return null;
|
|
383
|
+
} else {
|
|
384
|
+
metadata = executeDataMultisig.params_.metadata;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
245
387
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
388
|
+
return metadata;
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
const typesPayload: IPayload = {
|
|
393
|
+
transfer: (data, type) => ({
|
|
394
|
+
type,
|
|
395
|
+
token: data.token,
|
|
396
|
+
amount: toBN(data.amount).toFixed(),
|
|
397
|
+
receiver: data.receiver,
|
|
398
|
+
}),
|
|
399
|
+
bridge: (data, type) => ({
|
|
400
|
+
type,
|
|
401
|
+
amount: toBN(data.amount).toFixed(),
|
|
402
|
+
receiver: data.receiver,
|
|
403
|
+
toToken: data.toToken,
|
|
404
|
+
fromToken: data.fromToken,
|
|
405
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
406
|
+
bridgeFee: toBN(data.bridgeFee).toFixed(),
|
|
407
|
+
}),
|
|
408
|
+
swap: (data, type) => ({
|
|
409
|
+
type,
|
|
410
|
+
buyAmount: toBN(data.buyAmount).toFixed(),
|
|
411
|
+
sellAmount: toBN(data.sellAmount).toFixed(),
|
|
412
|
+
buyToken: data.buyToken,
|
|
413
|
+
sellToken: data.sellToken,
|
|
414
|
+
receiver: data.receiver,
|
|
415
|
+
protocol: utils.parseBytes32String(data.protocol || ""),
|
|
416
|
+
}),
|
|
417
|
+
upgrade: (data, type) => ({
|
|
418
|
+
type,
|
|
419
|
+
version: utils.parseBytes32String(data.version || ""),
|
|
420
|
+
walletImpl: data.walletImpl,
|
|
421
|
+
}),
|
|
422
|
+
"gas-topup": (data, type) => ({
|
|
423
|
+
type,
|
|
424
|
+
amount: toBN(data.amount).toFixed(),
|
|
425
|
+
token: data.token,
|
|
426
|
+
onBehalf: data.onBehalf,
|
|
427
|
+
}),
|
|
428
|
+
"dapp": (data, type) => ({
|
|
429
|
+
type,
|
|
430
|
+
name: data.name,
|
|
431
|
+
url: data.url,
|
|
432
|
+
}),
|
|
433
|
+
"deploy": (data, type) => ({
|
|
434
|
+
type,
|
|
435
|
+
}),
|
|
436
|
+
"permit2": (data, type) => ({
|
|
437
|
+
type,
|
|
438
|
+
token: data.token,
|
|
439
|
+
spender: data.spender,
|
|
440
|
+
amount: toBN(data.amount).toFixed(),
|
|
441
|
+
expiration: data.expiration,
|
|
442
|
+
}),
|
|
443
|
+
"cross-transfer": (data, type) => ({
|
|
444
|
+
type,
|
|
445
|
+
fromToken: data.fromToken,
|
|
446
|
+
toToken: data.toToken,
|
|
447
|
+
toChainId: data.toChainId ? data.toChainId.toString() : null,
|
|
448
|
+
amount: toBN(data.amount).toFixed(),
|
|
449
|
+
receiver: data.receiver,
|
|
450
|
+
}),
|
|
451
|
+
"auth": (data) => ({
|
|
452
|
+
type: data.remove ? "remove-authority" : "add-authority",
|
|
453
|
+
address: data.address,
|
|
454
|
+
chainId: data.chainId ? data.chainId.toString() : null,
|
|
455
|
+
remove: data.remove,
|
|
456
|
+
}),
|
|
457
|
+
"instadapp-pro": (data, type) => ({
|
|
458
|
+
type,
|
|
459
|
+
castDetails: data.castDetails,
|
|
460
|
+
}),
|
|
461
|
+
"rejection": (data, type) => ({
|
|
462
|
+
type,
|
|
463
|
+
id: data.id,
|
|
464
|
+
}),
|
|
465
|
+
"add-signers": (data, type) => ({
|
|
466
|
+
type,
|
|
467
|
+
addresses: data.signers,
|
|
468
|
+
}),
|
|
469
|
+
"remove-signers": (data, type) => ({
|
|
470
|
+
type,
|
|
471
|
+
addresses: data.signers,
|
|
472
|
+
}),
|
|
473
|
+
"change-threshold": (data, type) => ({
|
|
474
|
+
type,
|
|
475
|
+
count: data.count,
|
|
476
|
+
}),
|
|
477
|
+
};
|
|
340
478
|
|
|
479
|
+
const parseMetadata = (metadata: string) => {
|
|
480
|
+
const metadataArr = [];
|
|
481
|
+
|
|
482
|
+
const [decodedMultiMetadata = []] =
|
|
483
|
+
(ethers.utils.defaultAbiCoder.decode(
|
|
484
|
+
multiMetadataTypes,
|
|
485
|
+
metadata
|
|
486
|
+
) as string[]) || [];
|
|
487
|
+
|
|
488
|
+
for (let metadata of decodedMultiMetadata) {
|
|
489
|
+
const decodedMetadata = ethers.utils.defaultAbiCoder.decode(
|
|
490
|
+
metadataTypes,
|
|
491
|
+
metadata
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
const type = ethers.utils.parseBytes32String(
|
|
495
|
+
decodedMetadata.type
|
|
496
|
+
) as keyof typeof actionMetadataTypes;
|
|
497
|
+
|
|
498
|
+
const decodedData = ethers.utils.defaultAbiCoder.decode(
|
|
499
|
+
actionMetadataTypes[type],
|
|
500
|
+
decodedMetadata.data
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
const payloadFunc = typesPayload[type]
|
|
504
|
+
|
|
505
|
+
if (payloadFunc) {
|
|
506
|
+
const payload = payloadFunc(decodedData, type)
|
|
341
507
|
metadataArr.push(payload);
|
|
342
508
|
}
|
|
343
509
|
|
|
344
|
-
return metadataArr;
|
|
345
|
-
} catch (e) {
|
|
346
|
-
console.log(e);
|
|
347
|
-
return null;
|
|
348
510
|
}
|
|
511
|
+
|
|
512
|
+
return metadataArr;
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
|
|
519
|
+
* @param {string} txType - The input sentence to modify
|
|
520
|
+
*
|
|
521
|
+
* @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
|
|
522
|
+
*/
|
|
523
|
+
export const formatTxType = (txType: string) => {
|
|
524
|
+
const finalSentence = txType
|
|
525
|
+
.replace("-", " ")
|
|
526
|
+
.replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
|
|
527
|
+
|
|
528
|
+
return finalSentence;
|
|
349
529
|
};
|