@instadapp/avocado-base 0.0.0-dev.083a57a → 0.0.0-dev.0cd0f72
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/components/ActionMetadata.vue +1 -4
- package/components/metadata/Bridge.vue +2 -4
- package/components/metadata/CrossTransfer.vue +1 -3
- package/components/metadata/GasTopup.vue +1 -3
- package/components/metadata/Swap.vue +2 -3
- package/components/metadata/Transfer.vue +5 -8
- package/package.json +1 -1
- package/utils/metadata.ts +178 -206
|
@@ -5,8 +5,6 @@ const props = defineProps<{
|
|
|
5
5
|
chain_id: number | string
|
|
6
6
|
}>();
|
|
7
7
|
|
|
8
|
-
const compact = inject('compact');
|
|
9
|
-
|
|
10
8
|
const toToken = asyncComputed(() =>
|
|
11
9
|
fetchTokenByAddress(props.metadata?.toToken, props.metadata?.toChainId)
|
|
12
10
|
);
|
|
@@ -24,12 +22,12 @@ const bridgeAmountFormatted = computed(() =>
|
|
|
24
22
|
class="flex gap-5 items-center"
|
|
25
23
|
v-if="metadata.type === 'bridge' && toToken"
|
|
26
24
|
>
|
|
27
|
-
<span
|
|
25
|
+
<span class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
28
26
|
<span class="inline-flex gap-2.5 items-center">
|
|
29
27
|
<img width="20" height="20" class="w-5 h-5" :src="toToken.logo_url" />
|
|
30
28
|
{{ bridgeAmountFormatted }}
|
|
31
29
|
<span class="uppercase">{{ toToken?.symbol }}</span>
|
|
32
|
-
<SvgoBridge class="text-slate-400 w-
|
|
30
|
+
<SvgoBridge class="text-slate-400 w-5 h-5" />
|
|
33
31
|
<span class="flex items-center gap-2.5">
|
|
34
32
|
<ChainLogo class="w-5" :chain="metadata.toChainId" />
|
|
35
33
|
<span>{{ chainIdToName(metadata.toChainId) }}</span>
|
|
@@ -5,8 +5,6 @@ const props = defineProps<{
|
|
|
5
5
|
chain_id: number | string
|
|
6
6
|
}>();
|
|
7
7
|
|
|
8
|
-
const compact = inject('compact');
|
|
9
|
-
|
|
10
8
|
const fromToken = asyncComputed(() => {
|
|
11
9
|
if (!props?.chain_id) return null;
|
|
12
10
|
|
|
@@ -29,7 +27,7 @@ const formattedFromAmount = computed(() =>
|
|
|
29
27
|
</div>
|
|
30
28
|
<div class="flex gap-5 flex-col" v-else>
|
|
31
29
|
<div class="flex items-center gap-5">
|
|
32
|
-
<span
|
|
30
|
+
<span class="capitalize text-xs sm:text-sm">Cross-chain send</span>
|
|
33
31
|
<span class="inline-flex gap-2.5 items-center">
|
|
34
32
|
<img width="20" height="20" class="w-5 h-5" :src="fromToken?.logo_url" />
|
|
35
33
|
{{ formattedFromAmount }}
|
|
@@ -9,8 +9,6 @@ const token = asyncComputed(() =>
|
|
|
9
9
|
fetchTokenByAddress(props.metadata?.token, props?.chain_id)
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
const compact = inject('compact');
|
|
13
|
-
|
|
14
12
|
const formattedAmount = computed(() =>
|
|
15
13
|
formatDecimal(
|
|
16
14
|
fromWei(props.metadata?.amount, token?.value?.decimals).toFixed()
|
|
@@ -21,7 +19,7 @@ const formattedAmount = computed(() =>
|
|
|
21
19
|
<template>
|
|
22
20
|
<div v-if="!token" class="rounded-5 w-24 h-4 loading-box" />
|
|
23
21
|
<div class="flex items-center gap-5" v-else>
|
|
24
|
-
<span
|
|
22
|
+
<span class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
25
23
|
<span class="inline-flex gap-2.5 items-center">
|
|
26
24
|
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url" />
|
|
27
25
|
{{ formattedAmount }}
|
|
@@ -5,7 +5,6 @@ const props = defineProps<{
|
|
|
5
5
|
chain_id: number | string
|
|
6
6
|
}>();
|
|
7
7
|
|
|
8
|
-
const compact = inject('compact');
|
|
9
8
|
|
|
10
9
|
const buyToken = asyncComputed(() =>
|
|
11
10
|
fetchTokenByAddress(props.metadata?.buyToken, props?.chain_id)
|
|
@@ -46,7 +45,7 @@ const formatProtocol = (protocol: string) => {
|
|
|
46
45
|
class="flex items-center gap-5"
|
|
47
46
|
v-else
|
|
48
47
|
>
|
|
49
|
-
<span
|
|
48
|
+
<span class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
50
49
|
<span class="inline-flex gap-2.5 items-center">
|
|
51
50
|
<img width="20" height="20" class="w-5 h-5" :src="sellToken?.logo_url" />
|
|
52
51
|
{{ sellAmountFormatted }}
|
|
@@ -57,7 +56,7 @@ const formatProtocol = (protocol: string) => {
|
|
|
57
56
|
<span class="uppercase">{{ buyToken?.symbol }}</span>
|
|
58
57
|
<span
|
|
59
58
|
class="capitalize hidden sm:flex items-center gap-2.5"
|
|
60
|
-
v-if="metadata.protocol
|
|
59
|
+
v-if="metadata.protocol"
|
|
61
60
|
>
|
|
62
61
|
On <ProtocolLogo class="w-5 h-5" :name="metadata.protocol" />
|
|
63
62
|
{{ formatProtocol(metadata.protocol) }}
|
|
@@ -5,7 +5,6 @@ const props = defineProps<{
|
|
|
5
5
|
chain_id: number | string
|
|
6
6
|
}>();
|
|
7
7
|
|
|
8
|
-
const compact = inject('compact');
|
|
9
8
|
|
|
10
9
|
const token = asyncComputed(() => {
|
|
11
10
|
if (!props?.chain_id) return null;
|
|
@@ -26,21 +25,19 @@ const formattedAmount = computed(() =>
|
|
|
26
25
|
<template>
|
|
27
26
|
<div v-if="!token" class="rounded-5 w-24 h-4 loading-box" />
|
|
28
27
|
<div class="flex items-center gap-5" v-else>
|
|
29
|
-
<span
|
|
28
|
+
<span class="capitalize text-xs sm:text-sm">{{ metadata.type }}</span>
|
|
30
29
|
<span class="inline-flex gap-2.5 items-center">
|
|
31
30
|
<img width="20" height="20" class="w-5 h-5" :src="token?.logo_url" />
|
|
32
31
|
{{ formattedAmount }}
|
|
33
32
|
<span class="uppercase">{{ token?.symbol }}</span>
|
|
34
33
|
<SvgoArrowRight class="w-4 h-4 text-slate-400 mx-2" />
|
|
35
|
-
<
|
|
34
|
+
<a
|
|
36
35
|
class="text-primary"
|
|
37
|
-
|
|
38
|
-
external
|
|
39
|
-
:to="
|
|
36
|
+
:href="
|
|
40
37
|
getExplorerUrl(chain_id, `/address/${metadata.receiver}`)
|
|
41
38
|
"
|
|
42
|
-
>{{ shortenHash(metadata.receiver) }}
|
|
43
|
-
|
|
39
|
+
>{{ shortenHash(metadata.receiver) }}</a
|
|
40
|
+
>
|
|
44
41
|
</span>
|
|
45
42
|
</div>
|
|
46
43
|
</template>
|
package/package.json
CHANGED
package/utils/metadata.ts
CHANGED
|
@@ -242,217 +242,189 @@ export const encodeMultipleActions = (...actionData: string[]) => {
|
|
|
242
242
|
return ethers.utils.defaultAbiCoder.encode(multiMetadataTypes, [actionData]);
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
-
export const
|
|
245
|
+
export const decodeMetadata = (data: string) => {
|
|
246
246
|
try {
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
247
|
+
const iface = Forwarder__factory.createInterface();
|
|
248
|
+
let metadata = "0x";
|
|
249
|
+
let payload = {};
|
|
250
|
+
|
|
251
|
+
if (!data) return payload;
|
|
252
|
+
|
|
253
|
+
if (data.startsWith("0x18e7f485")) {
|
|
254
|
+
const executeData = iface.decodeFunctionData("execute", data);
|
|
255
|
+
if (executeData.metadata_ === "0x" || !executeData.metadata_) {
|
|
256
|
+
return null;
|
|
257
|
+
} else {
|
|
258
|
+
metadata = executeData.metadata_;
|
|
259
|
+
}
|
|
260
|
+
} else if (data.startsWith("0x14f80a8d")) {
|
|
261
|
+
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
262
|
+
if (
|
|
263
|
+
executeDataV2.params_.metadata === "0x" ||
|
|
264
|
+
!executeDataV2.params_.metadata
|
|
265
|
+
) {
|
|
266
|
+
return null;
|
|
267
|
+
} else {
|
|
268
|
+
metadata = executeDataV2.params_.metadata;
|
|
269
|
+
}
|
|
270
|
+
} else if (data.startsWith("0x85114d53")) {
|
|
271
|
+
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
272
|
+
if (
|
|
273
|
+
executeDataV3.params_.metadata === "0x" ||
|
|
274
|
+
!executeDataV3.params_.metadata
|
|
275
|
+
) {
|
|
276
|
+
return null;
|
|
277
|
+
} else {
|
|
278
|
+
metadata = executeDataV3.params_.metadata;
|
|
279
|
+
}
|
|
272
280
|
} else {
|
|
273
|
-
|
|
281
|
+
const executeDataMultisigV3 = iface.decodeFunctionData(
|
|
282
|
+
"executeMultisigV3",
|
|
283
|
+
data
|
|
284
|
+
);
|
|
285
|
+
if (
|
|
286
|
+
executeDataMultisigV3.params_.metadata === "0x" ||
|
|
287
|
+
!executeDataMultisigV3.params_.metadata
|
|
288
|
+
) {
|
|
289
|
+
return null;
|
|
290
|
+
} else {
|
|
291
|
+
metadata = executeDataMultisigV3.params_.metadata;
|
|
292
|
+
}
|
|
274
293
|
}
|
|
275
|
-
} else if (data.startsWith("0x14f80a8d")) {
|
|
276
|
-
const executeDataV2 = iface.decodeFunctionData("executeV2", data);
|
|
277
|
-
if (
|
|
278
|
-
executeDataV2.params_.metadata === "0x" ||
|
|
279
|
-
!executeDataV2.params_.metadata
|
|
280
|
-
) {
|
|
281
|
-
return null;
|
|
282
|
-
} else {
|
|
283
|
-
metadata = executeDataV2.params_.metadata;
|
|
284
|
-
}
|
|
285
|
-
} else if (data.startsWith("0x85114d53")) {
|
|
286
|
-
const executeDataV3 = iface.decodeFunctionData("executeV3", data);
|
|
287
|
-
if (
|
|
288
|
-
executeDataV3.params_.metadata === "0x" ||
|
|
289
|
-
!executeDataV3.params_.metadata
|
|
290
|
-
) {
|
|
291
|
-
return null;
|
|
292
|
-
} else {
|
|
293
|
-
metadata = executeDataV3.params_.metadata;
|
|
294
|
-
}
|
|
295
|
-
} else {
|
|
296
|
-
const executeDataMultisigV3 = iface.decodeFunctionData(
|
|
297
|
-
"executeMultisigV3",
|
|
298
|
-
data
|
|
299
|
-
);
|
|
300
|
-
if (
|
|
301
|
-
executeDataMultisigV3.params_.metadata === "0x" ||
|
|
302
|
-
!executeDataMultisigV3.params_.metadata
|
|
303
|
-
) {
|
|
304
|
-
return null;
|
|
305
|
-
} else {
|
|
306
|
-
metadata = executeDataMultisigV3.params_.metadata;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return metadata;
|
|
311
|
-
};
|
|
312
294
|
|
|
313
|
-
const
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
:
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
295
|
+
const metadataArr = [];
|
|
296
|
+
|
|
297
|
+
const [decodedMultiMetadata = []] =
|
|
298
|
+
(ethers.utils.defaultAbiCoder.decode(
|
|
299
|
+
multiMetadataTypes,
|
|
300
|
+
metadata
|
|
301
|
+
) as string[]) || [];
|
|
302
|
+
|
|
303
|
+
for (let metadata of decodedMultiMetadata) {
|
|
304
|
+
const decodedMetadata = ethers.utils.defaultAbiCoder.decode(
|
|
305
|
+
metadataTypes,
|
|
306
|
+
metadata
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
const type = ethers.utils.parseBytes32String(
|
|
310
|
+
decodedMetadata.type
|
|
311
|
+
) as keyof typeof actionMetadataTypes;
|
|
312
|
+
|
|
313
|
+
const decodedData = ethers.utils.defaultAbiCoder.decode(
|
|
314
|
+
actionMetadataTypes[type],
|
|
315
|
+
decodedMetadata.data
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
switch (type) {
|
|
319
|
+
case "transfer":
|
|
320
|
+
payload = {
|
|
321
|
+
type,
|
|
322
|
+
token: decodedData.token,
|
|
323
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
324
|
+
receiver: decodedData.receiver,
|
|
325
|
+
};
|
|
326
|
+
break;
|
|
327
|
+
case "bridge":
|
|
328
|
+
payload = {
|
|
329
|
+
type,
|
|
330
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
331
|
+
receiver: decodedData.receiver,
|
|
332
|
+
toToken: decodedData.toToken,
|
|
333
|
+
fromToken: decodedData.fromToken,
|
|
334
|
+
toChainId: decodedData.toChainId
|
|
335
|
+
? decodedData.toChainId.toString()
|
|
336
|
+
: null,
|
|
337
|
+
bridgeFee: toBN(decodedData.bridgeFee).toFixed(),
|
|
338
|
+
};
|
|
339
|
+
break;
|
|
340
|
+
case "swap":
|
|
341
|
+
payload = {
|
|
342
|
+
type,
|
|
343
|
+
buyAmount: toBN(decodedData.buyAmount).toFixed(),
|
|
344
|
+
sellAmount: toBN(decodedData.sellAmount).toFixed(),
|
|
345
|
+
buyToken: decodedData.buyToken,
|
|
346
|
+
sellToken: decodedData.sellToken,
|
|
347
|
+
receiver: decodedData.receiver,
|
|
348
|
+
protocol: utils.parseBytes32String(decodedData?.protocol || ""),
|
|
349
|
+
};
|
|
350
|
+
break;
|
|
351
|
+
case "upgrade":
|
|
352
|
+
payload = {
|
|
353
|
+
type,
|
|
354
|
+
version: utils.parseBytes32String(decodedData?.version || ""),
|
|
355
|
+
walletImpl: decodedData?.walletImpl,
|
|
356
|
+
};
|
|
357
|
+
break;
|
|
358
|
+
case "gas-topup":
|
|
359
|
+
payload = {
|
|
360
|
+
type,
|
|
361
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
362
|
+
token: decodedData.token,
|
|
363
|
+
onBehalf: decodedData.onBehalf,
|
|
364
|
+
};
|
|
365
|
+
break;
|
|
366
|
+
case "dapp":
|
|
367
|
+
payload = {
|
|
368
|
+
type,
|
|
369
|
+
name: decodedData?.name,
|
|
370
|
+
url: decodedData?.url,
|
|
371
|
+
};
|
|
372
|
+
break;
|
|
373
|
+
case "deploy":
|
|
374
|
+
payload = {
|
|
375
|
+
type,
|
|
376
|
+
};
|
|
377
|
+
break;
|
|
378
|
+
|
|
379
|
+
case "permit2":
|
|
380
|
+
payload = {
|
|
381
|
+
type,
|
|
382
|
+
token: decodedData.token,
|
|
383
|
+
spender: decodedData.spender,
|
|
384
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
385
|
+
expiration: decodedData.expiration,
|
|
386
|
+
};
|
|
387
|
+
break;
|
|
388
|
+
|
|
389
|
+
case "cross-transfer":
|
|
390
|
+
payload = {
|
|
391
|
+
type,
|
|
392
|
+
fromToken: decodedData.fromToken,
|
|
393
|
+
toToken: decodedData.toToken,
|
|
394
|
+
toChainId: decodedData.toChainId
|
|
395
|
+
? decodedData.toChainId.toString()
|
|
396
|
+
: null,
|
|
397
|
+
amount: toBN(decodedData.amount).toFixed(),
|
|
398
|
+
receiver: decodedData.receiver,
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
break;
|
|
402
|
+
case "auth":
|
|
403
|
+
payload = {
|
|
404
|
+
type: decodedData.remove ? "remove-authority" : "add-authority",
|
|
405
|
+
address: decodedData.address,
|
|
406
|
+
chainId: decodedData.chainId
|
|
407
|
+
? decodedData.chainId.toString()
|
|
408
|
+
: null,
|
|
409
|
+
remove: decodedData.remove,
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
break;
|
|
413
|
+
case "instadapp-pro":
|
|
414
|
+
payload = {
|
|
415
|
+
type,
|
|
416
|
+
castDetails: decodedData.castDetails,
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
metadataArr.push(payload);
|
|
438
423
|
}
|
|
439
424
|
|
|
440
|
-
metadataArr
|
|
425
|
+
return metadataArr;
|
|
426
|
+
} catch (e) {
|
|
427
|
+
// console.log(e);
|
|
428
|
+
return null;
|
|
441
429
|
}
|
|
442
|
-
|
|
443
|
-
return metadataArr;
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Replaces hyphens with spaces and capitalizes the first letter of each word in a sentence.
|
|
448
|
-
* @param {string} txType - The input sentence to modify
|
|
449
|
-
*
|
|
450
|
-
* @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
|
|
451
|
-
*/
|
|
452
|
-
export const formatTxType = (txType: string) => {
|
|
453
|
-
const finalSentence = txType
|
|
454
|
-
.replace("-", " ")
|
|
455
|
-
.replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
|
|
456
|
-
|
|
457
|
-
return finalSentence;
|
|
458
430
|
};
|