@instadapp/avocado-base 0.0.0-dev.c8c43bc → 0.0.0-dev.d695dce

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/utils/utils.d.ts CHANGED
@@ -1,4 +1,16 @@
1
- type ChainId = 1 | 137 | 42161 | 10 | 56 | 43114 | 100 | 1101 | 634 | 63400;
1
+ type ChainId =
2
+ | 1
3
+ | 137
4
+ | 42161
5
+ | 10
6
+ | 56
7
+ | 43114
8
+ | 100
9
+ | 1101
10
+ | 250
11
+ | 634
12
+ | 1313161554
13
+ | 63400;
2
14
 
3
15
  type ISlackMessageType = "danger" | "error" | "success" | "banner";
4
16
 
@@ -6,16 +18,18 @@ interface Network {
6
18
  name: string;
7
19
  debankName?: string;
8
20
  ankrName?: string;
21
+ zerionName?: string;
9
22
  chainId: ChainId;
23
+ color: string;
10
24
  isAvocado?: boolean;
25
+ serverRpcUrl: string | undefined;
26
+ balanceResolverAddress?: string;
27
+ usdcAddress: string;
28
+ explorerUrl: string;
11
29
  params: {
12
30
  chainName?: string;
13
- rpcUrls: string[];
14
- serverRpcUrl: string | undefined;
15
- balanceResolverAddress?: string;
16
- usdcAddress: string;
17
- explorerUrl: string;
18
31
  iconUrls?: string[];
32
+ rpcUrls: string[];
19
33
  nativeCurrency?: {
20
34
  name: string;
21
35
  symbol: string;
@@ -42,6 +56,20 @@ type SendMetadataProps = {
42
56
  receiver: string;
43
57
  };
44
58
 
59
+ type CrossSendMetadataProps = {
60
+ fromToken: string;
61
+ toToken: string;
62
+ toChainId: string;
63
+ amount: string;
64
+ receiver: string;
65
+ };
66
+
67
+ type AuthMetadataProps = {
68
+ address: string;
69
+ chainId: string;
70
+ remove: boolean;
71
+ };
72
+
45
73
  type UpgradeMetadataProps = {
46
74
  version: string;
47
75
  walletImpl: string;
@@ -82,7 +110,9 @@ type MetadataProps = {
82
110
  | "upgrade"
83
111
  | "dapp"
84
112
  | "deploy"
85
- | "permit2";
113
+ | "permit2"
114
+ | "cross-transfer"
115
+ | "auth";
86
116
  encodedData: string;
87
117
  version?: string;
88
118
  };
package/utils/index.ts DELETED
@@ -1,93 +0,0 @@
1
- import { BigNumber } from "bignumber.js";
2
- import { BigNumber as BN } from "ethers";
3
-
4
- export function shortenHash(hash: string, length: number = 4) {
5
- if (!hash) return;
6
- if (hash.length < 12) return hash;
7
- const beginningChars = hash.startsWith("0x") ? length + 2 : length;
8
- const shortened =
9
- hash.substr(0, beginningChars) + "..." + hash.substr(-length);
10
- return shortened;
11
- }
12
-
13
- export const toBN = (value: BigNumber.Value | BN) =>
14
- new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
15
- export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
16
- export const times = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
17
- toBN(a).times(toBN(b));
18
- export const minus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
19
- toBN(a).minus(toBN(b));
20
- export const plus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
21
- toBN(a).plus(toBN(b));
22
- export const lte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
23
- toBN(a).lte(toBN(b));
24
- export const gte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
25
- toBN(a).gte(toBN(b));
26
- export const div = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
27
- toBN(a).div(toBN(b));
28
- export const lt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
29
- toBN(a).lt(toBN(b));
30
- export const gt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
31
- toBN(a).gt(toBN(b));
32
- export const ensureValue = (value: any) => {
33
- if (!value) return toBN("0");
34
- if (toBN(value).isNaN()) return toBN("0");
35
-
36
- return toBN(value);
37
- };
38
- export const max = (...args: BigNumber.Value[]) => {
39
- return BigNumber.max(...args);
40
- };
41
-
42
- export function onImageError(this: HTMLImageElement) {
43
- const parentElement = this.parentElement;
44
- this.onerror = null;
45
- this.remove();
46
-
47
- if (parentElement) {
48
- parentElement.classList.add("bg-gray-300");
49
- }
50
- }
51
-
52
- const locale = "en-US";
53
-
54
- export function formatUsd(value: any, fractionDigits = 2) {
55
- const formatter = new Intl.NumberFormat(locale, {
56
- style: "currency",
57
- currency: "USD",
58
- minimumFractionDigits: fractionDigits,
59
- maximumFractionDigits: fractionDigits,
60
- });
61
-
62
- return formatter.format(value);
63
- }
64
-
65
- export function cloneDeep<T>(value: T): T {
66
- return JSON.parse(JSON.stringify(value));
67
- }
68
-
69
- export function signedNumber(numb: string | number) {
70
- return new Intl.NumberFormat("en-US", {
71
- signDisplay: "exceptZero",
72
- }).format(toBN(numb).toNumber());
73
- }
74
-
75
- export function formatDecimal(value: string | number, decimalPlaces = 5) {
76
- if (!value) {
77
- value = "0";
78
- }
79
-
80
- return toBN(value).decimalPlaces(decimalPlaces).toFormat();
81
- }
82
-
83
- export function filterArray(array: any, filters: any) {
84
- const filterKeys = Object.keys(filters);
85
- return array.filter((item: any) => {
86
- // validates all filter criteria
87
- return filterKeys.every((key) => {
88
- // ignores non-function predicates
89
- if (typeof filters[key] !== "function") return true;
90
- return filters[key](item[key], item);
91
- });
92
- });
93
- }