@instadapp/avocado-base 0.1.2 → 0.1.4

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.
@@ -6,4 +6,5 @@ export { BalanceResolver__factory } from "./BalanceResolver__factory";
6
6
  export { Erc20__factory } from "./Erc20__factory";
7
7
  export { Forwarder__factory } from "./Forwarder__factory";
8
8
  export { GaslessWallet__factory } from "./GaslessWallet__factory";
9
+ export { MultisigAgnosticForwarder__factory } from "./MultisigAgnosticForwarder__factory";
9
10
  export { MultisigForwarder__factory } from "./MultisigForwarder__factory";
@@ -6,6 +6,7 @@ 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 { MultisigAgnosticForwarder } from "./MultisigAgnosticForwarder";
9
10
  export type { MultisigForwarder } from "./MultisigForwarder";
10
11
  export * as factories from "./factories";
11
12
  export { AvoFactoryProxy__factory } from "./factories/AvoFactoryProxy__factory";
@@ -13,4 +14,5 @@ export { BalanceResolver__factory } from "./factories/BalanceResolver__factory";
13
14
  export { Erc20__factory } from "./factories/Erc20__factory";
14
15
  export { Forwarder__factory } from "./factories/Forwarder__factory";
15
16
  export { GaslessWallet__factory } from "./factories/GaslessWallet__factory";
17
+ export { MultisigAgnosticForwarder__factory } from "./factories/MultisigAgnosticForwarder__factory";
16
18
  export { MultisigForwarder__factory } from "./factories/MultisigForwarder__factory";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
@@ -29,7 +29,7 @@
29
29
  "@vueuse/nuxt": "^10.2.0",
30
30
  "bignumber.js": "^9.1.1",
31
31
  "ethers": "^5.7.2",
32
- "viem": "^2.7.16",
32
+ "viem": "^2.10.5",
33
33
  "xxhashjs": "^0.2.2"
34
34
  }
35
35
  }
package/utils/metadata.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { ethers, utils } from "ethers";
2
- import { Forwarder__factory, MultisigForwarder__factory } from "../contracts";
2
+ import { Forwarder__factory, MultisigForwarder__factory, MultisigAgnosticForwarder__factory } from "../contracts";
3
3
  import { toBN } from "./bignumber";
4
4
 
5
5
  export const MetadataEnums = {
6
6
  transfer: "transfer",
7
7
  bridge: "bridge",
8
+ 'bridge-v2': 'bridge-v2',
8
9
  swap: "swap",
9
10
  "gas-topup": "gas-topup",
10
11
  upgrade: "upgrade",
@@ -12,6 +13,7 @@ export const MetadataEnums = {
12
13
  deploy: "deploy",
13
14
  permit2: "permit2",
14
15
  "cross-transfer": "cross-transfer",
16
+ 'cross-transfer-v2': 'cross-transfer-v2',
15
17
  auth: "auth",
16
18
  rejection: "rejection",
17
19
  "instadapp-pro": "instadapp-pro",
@@ -37,6 +39,14 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
37
39
  "uint256 amount",
38
40
  "address receiver",
39
41
  ],
42
+ "cross-transfer-v2": [
43
+ "address fromToken",
44
+ "address toToken",
45
+ "uint256 toChainId",
46
+ "uint256 amount",
47
+ "address receiver",
48
+ "bytes32 provider",
49
+ ],
40
50
  bridge: [
41
51
  "uint256 amount",
42
52
  "address receiver",
@@ -46,6 +56,16 @@ const actionMetadataTypes: Record<MetadataTypes, string[]> = {
46
56
  "uint256 bridgeFee",
47
57
  "address nativeToken",
48
58
  ],
59
+ 'bridge-v2': [
60
+ "uint256 amount",
61
+ "address receiver",
62
+ "address fromToken",
63
+ "address toToken",
64
+ "uint256 toChainId",
65
+ "uint256 bridgeFee",
66
+ "address nativeToken",
67
+ "bytes32 provider",
68
+ ],
49
69
  swap: [
50
70
  "address sellToken",
51
71
  "address buyToken",
@@ -154,8 +174,21 @@ export const encodeCrossTransferMetadata = (
154
174
  params: CrossSendMetadataProps,
155
175
  single = true
156
176
  ) => {
157
- const encodedData = ethers.utils.defaultAbiCoder.encode(
158
- actionMetadataTypes["cross-transfer"],
177
+
178
+ const type = params.provider ? MetadataEnums["cross-transfer-v2"] : MetadataEnums["cross-transfer"]
179
+
180
+ const encodedData = params.provider ? ethers.utils.defaultAbiCoder.encode(
181
+ actionMetadataTypes[type],
182
+ [
183
+ params.fromToken,
184
+ params.toToken,
185
+ params.toChainId,
186
+ params.amount,
187
+ params.receiver,
188
+ params.provider
189
+ ]
190
+ ) : ethers.utils.defaultAbiCoder.encode(
191
+ actionMetadataTypes[type],
159
192
  [
160
193
  params.fromToken,
161
194
  params.toToken,
@@ -166,7 +199,7 @@ export const encodeCrossTransferMetadata = (
166
199
  );
167
200
 
168
201
  const data = encodeMetadata({
169
- type: MetadataEnums["cross-transfer"],
202
+ type: MetadataEnums[type],
170
203
  encodedData,
171
204
  });
172
205
 
@@ -295,7 +328,21 @@ export const encodeBridgeMetadata = (
295
328
  params: BridgeMetadataProps,
296
329
  single = true
297
330
  ) => {
298
- const encodedData = ethers.utils.defaultAbiCoder.encode(
331
+ const type = params.version === '2' ? MetadataEnums["bridge-v2"] : MetadataEnums.bridge
332
+
333
+ const encodedData = params.version === '2' ? ethers.utils.defaultAbiCoder.encode(
334
+ actionMetadataTypes["bridge-v2"],
335
+ [
336
+ params.amount,
337
+ params.receiver,
338
+ params.fromToken,
339
+ params.toToken,
340
+ params.toChainId,
341
+ params.bridgeFee,
342
+ params.nativeToken,
343
+ params.provider
344
+ ]
345
+ ): ethers.utils.defaultAbiCoder.encode(
299
346
  actionMetadataTypes.bridge,
300
347
  [
301
348
  params.amount,
@@ -309,7 +356,7 @@ export const encodeBridgeMetadata = (
309
356
  );
310
357
 
311
358
  const data = encodeMetadata({
312
- type: MetadataEnums.bridge,
359
+ type,
313
360
  encodedData,
314
361
  });
315
362
 
@@ -419,11 +466,21 @@ export const decodeMetadata = (metadata: string) => {
419
466
 
420
467
  const iface = Forwarder__factory.createInterface();
421
468
  const ifaceMultisig = MultisigForwarder__factory.createInterface();
469
+ const ifaceAgnostic = MultisigAgnosticForwarder__factory.createInterface();
422
470
 
423
471
  const getMetadataFromData = (data: string) => {
424
472
  let metadata = "0x";
425
473
 
426
- if (data.startsWith("0x18e7f485")) {
474
+
475
+ if(data.startsWith('0x320036b4')) {
476
+ const executeData = ifaceAgnostic.decodeFunctionData("executeChainAgnosticV1", data);
477
+
478
+ const metadata = executeData?.params_?.params?.metadata
479
+
480
+ return metadata === '0x' || !metadata ? null : metadata
481
+ }
482
+
483
+ else if (data.startsWith("0x18e7f485")) {
427
484
  const executeData = iface.decodeFunctionData("execute", data);
428
485
  if (executeData.metadata_ === "0x" || !executeData.metadata_) {
429
486
  return null;
@@ -479,6 +536,16 @@ const typesPayload: IPayload = {
479
536
  toChainId: data.toChainId ? data.toChainId.toString() : null,
480
537
  bridgeFee: toBN(data.bridgeFee).toFixed(),
481
538
  }),
539
+ 'bridge-v2': (data, type) => ({
540
+ type: 'bridge',
541
+ amount: toBN(data.amount).toFixed(),
542
+ receiver: data.receiver,
543
+ toToken: data.toToken,
544
+ fromToken: data.fromToken,
545
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
546
+ bridgeFee: toBN(data.bridgeFee).toFixed(),
547
+ provider: utils.parseBytes32String(data.provider || ""),
548
+ }),
482
549
  swap: (data, type) => ({
483
550
  type,
484
551
  buyAmount: toBN(data.buyAmount).toFixed(),
@@ -526,6 +593,15 @@ const typesPayload: IPayload = {
526
593
  amount: toBN(data.amount).toFixed(),
527
594
  receiver: data.receiver,
528
595
  }),
596
+ "cross-transfer-v2": (data, type) => ({
597
+ type: 'cross-transfer',
598
+ fromToken: data.fromToken,
599
+ toToken: data.toToken,
600
+ toChainId: data.toChainId ? data.toChainId.toString() : null,
601
+ amount: toBN(data.amount).toFixed(),
602
+ receiver: data.receiver,
603
+ provider: utils.parseBytes32String(data.provider || ""),
604
+ }),
529
605
  auth: (data) => ({
530
606
  type: data.remove ? "remove-authority" : "add-authority",
531
607
  address: data.address,
@@ -605,6 +681,10 @@ const parseMetadata = (metadata: string) => {
605
681
  * @returns {string} - The modified sentence with hyphens replaced with spaces and the first letter of each word capitalized.
606
682
  */
607
683
  export const formatTxType = (txType: string) => {
684
+ if(txType === 'mass') {
685
+ return 'Chain Agnostic Payments'
686
+ }
687
+
608
688
  const finalSentence = txType
609
689
  .replace("-", " ")
610
690
  .replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
package/utils/network.ts CHANGED
@@ -15,6 +15,7 @@ import {
15
15
  scroll,
16
16
  opBNB,
17
17
  mode,
18
+ blast
18
19
  } from "viem/chains";
19
20
  import {
20
21
  AVO_PROD_CHAIN_NAME,
@@ -439,6 +440,26 @@ export const networks: Network[] = [
439
440
  },
440
441
  viemChain: mode,
441
442
  },
443
+ {
444
+ chainId: 81457,
445
+ name: "Blast",
446
+ color: "#78d64b",
447
+ explorerUrl: 'https://blastscan.io',
448
+ fakeTransactionHash: '0x934ed8516242f8c08bb9e0e90bb1f989d92ceb6b0333e86ac2d555f25ac27e58',
449
+ params: {
450
+ rpcUrls: ['https://rpc.ankr.com/blast'],
451
+ chainName: "Blast",
452
+ nativeCurrency: {
453
+ name: "Ethereum",
454
+ symbol: "ETH",
455
+ decimals: 18,
456
+ }
457
+ },
458
+ get serverRpcUrl() {
459
+ return process.env?.BLAST_RPC_URL || this.params.rpcUrls[0];
460
+ },
461
+ viemChain: blast,
462
+ },
442
463
  // {
443
464
  // name: "Manta Pacific",
444
465
  // chainId: 169,
package/utils/utils.d.ts CHANGED
@@ -20,6 +20,7 @@ declare global {
20
20
  | 63400
21
21
  | 169
22
22
  | 34443
23
+ | 81457
23
24
 
24
25
  type ISlackMessageType = "danger" | "error" | "success" | "banner";
25
26
 
@@ -80,8 +81,10 @@ declare global {
80
81
  toChainId: string;
81
82
  amount: string;
82
83
  receiver: string;
84
+ provider?: string;
83
85
  };
84
86
 
87
+
85
88
  type AuthMetadataProps = {
86
89
  address: string;
87
90
  chainId: string;
@@ -107,6 +110,8 @@ declare global {
107
110
  toChainId: string;
108
111
  bridgeFee: string;
109
112
  nativeToken: string;
113
+ version?: string;
114
+ provider: string;
110
115
  };
111
116
 
112
117
  type SwapMetadataProps = {