@reown/appkit-common-react-native 1.0.2 → 1.1.0
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/lib/commonjs/contracts/erc20.js +77 -0
- package/lib/commonjs/contracts/erc20.js.map +1 -0
- package/lib/commonjs/contracts/usdt.js +38 -0
- package/lib/commonjs/contracts/usdt.js.map +1 -0
- package/lib/commonjs/index.js +72 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/ConstantsUtil.js +18 -1
- package/lib/commonjs/utils/ConstantsUtil.js.map +1 -1
- package/lib/commonjs/utils/ContractUtil.js +18 -0
- package/lib/commonjs/utils/ContractUtil.js.map +1 -0
- package/lib/commonjs/utils/DateUtil.js +48 -0
- package/lib/commonjs/utils/DateUtil.js.map +1 -0
- package/lib/commonjs/utils/ErrorUtil.js +41 -0
- package/lib/commonjs/utils/ErrorUtil.js.map +1 -0
- package/lib/commonjs/utils/NamesUtil.js +13 -0
- package/lib/commonjs/utils/NamesUtil.js.map +1 -0
- package/lib/commonjs/utils/NumberUtil.js +33 -0
- package/lib/commonjs/utils/NumberUtil.js.map +1 -0
- package/lib/commonjs/utils/StringUtil.js +15 -0
- package/lib/commonjs/utils/StringUtil.js.map +1 -0
- package/lib/commonjs/utils/TypeUtil.js +2 -0
- package/lib/commonjs/utils/TypeUtil.js.map +1 -0
- package/lib/module/contracts/erc20.js +71 -0
- package/lib/module/contracts/erc20.js.map +1 -0
- package/lib/module/contracts/usdt.js +32 -0
- package/lib/module/contracts/usdt.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/ConstantsUtil.js +18 -1
- package/lib/module/utils/ConstantsUtil.js.map +1 -1
- package/lib/module/utils/ContractUtil.js +12 -0
- package/lib/module/utils/ContractUtil.js.map +1 -0
- package/lib/module/utils/DateUtil.js +41 -0
- package/lib/module/utils/DateUtil.js.map +1 -0
- package/lib/module/utils/ErrorUtil.js +35 -0
- package/lib/module/utils/ErrorUtil.js.map +1 -0
- package/lib/module/utils/NamesUtil.js +7 -0
- package/lib/module/utils/NamesUtil.js.map +1 -0
- package/lib/module/utils/NumberUtil.js +25 -0
- package/lib/module/utils/NumberUtil.js.map +1 -0
- package/lib/module/utils/StringUtil.js +9 -0
- package/lib/module/utils/StringUtil.js.map +1 -0
- package/lib/module/utils/TypeUtil.js +2 -0
- package/lib/module/utils/TypeUtil.js.map +1 -0
- package/lib/typescript/contracts/erc20.d.ts +30 -0
- package/lib/typescript/contracts/erc20.d.ts.map +1 -0
- package/lib/typescript/contracts/usdt.d.ts +14 -0
- package/lib/typescript/contracts/usdt.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +8 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/ConstantsUtil.d.ts +3 -0
- package/lib/typescript/utils/ConstantsUtil.d.ts.map +1 -1
- package/lib/typescript/utils/ContractUtil.d.ts +16 -0
- package/lib/typescript/utils/ContractUtil.d.ts.map +1 -0
- package/lib/typescript/utils/DateUtil.d.ts +7 -0
- package/lib/typescript/utils/DateUtil.d.ts.map +1 -0
- package/lib/typescript/utils/ErrorUtil.d.ts +35 -0
- package/lib/typescript/utils/ErrorUtil.d.ts.map +1 -0
- package/lib/typescript/utils/NamesUtil.d.ts +4 -0
- package/lib/typescript/utils/NamesUtil.d.ts.map +1 -0
- package/lib/typescript/utils/NumberUtil.d.ts +13 -0
- package/lib/typescript/utils/NumberUtil.d.ts.map +1 -0
- package/lib/typescript/utils/StringUtil.d.ts +4 -0
- package/lib/typescript/utils/StringUtil.d.ts.map +1 -0
- package/lib/typescript/utils/TypeUtil.d.ts +79 -0
- package/lib/typescript/utils/TypeUtil.d.ts.map +1 -0
- package/package.json +8 -4
- package/readme.md +1 -1
- package/src/contracts/erc20.ts +95 -0
- package/src/contracts/usdt.ts +43 -0
- package/src/index.ts +8 -0
- package/src/utils/ConstantsUtil.ts +19 -1
- package/src/utils/ContractUtil.ts +13 -0
- package/src/utils/DateUtil.ts +47 -0
- package/src/utils/ErrorUtil.ts +35 -0
- package/src/utils/NamesUtil.ts +10 -0
- package/src/utils/NumberUtil.ts +31 -0
- package/src/utils/StringUtil.ts +9 -0
- package/src/utils/TypeUtil.ts +89 -0
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
export const ConstantsUtil = {
|
|
2
|
+
WC_NAME_SUFFIX: '.reown.id',
|
|
3
|
+
WC_NAME_SUFFIX_LEGACY: '.wcn.id',
|
|
2
4
|
BLOCKCHAIN_API_RPC_URL: 'https://rpc.walletconnect.org',
|
|
3
5
|
PULSE_API_URL: 'https://pulse.walletconnect.org',
|
|
4
6
|
API_URL: 'https://api.web3modal.org',
|
|
5
7
|
COINBASE_CONNECTOR_ID: 'coinbaseWallet',
|
|
6
|
-
COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa'
|
|
8
|
+
COINBASE_EXPLORER_ID: 'fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa',
|
|
9
|
+
USDT_CONTRACT_ADDRESSES: [
|
|
10
|
+
// Mainnet
|
|
11
|
+
'0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
12
|
+
// Polygon
|
|
13
|
+
'0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
|
|
14
|
+
// Avalanche
|
|
15
|
+
'0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
|
16
|
+
// Cosmos
|
|
17
|
+
'0x919C1c267BC06a7039e03fcc2eF738525769109c',
|
|
18
|
+
// Celo
|
|
19
|
+
'0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
|
|
20
|
+
// Binance
|
|
21
|
+
'0x55d398326f99059fF775485246999027B3197955',
|
|
22
|
+
// Arbitrum
|
|
23
|
+
'0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9'
|
|
24
|
+
]
|
|
7
25
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { erc20ABI } from '../contracts/erc20';
|
|
2
|
+
import { usdtABI } from '../contracts/usdt';
|
|
3
|
+
import { ConstantsUtil } from './ConstantsUtil';
|
|
4
|
+
|
|
5
|
+
export const ContractUtil = {
|
|
6
|
+
getERC20Abi: (tokenAddress: string) => {
|
|
7
|
+
if (ConstantsUtil.USDT_CONTRACT_ADDRESSES.includes(tokenAddress)) {
|
|
8
|
+
return usdtABI;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return erc20ABI;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import englishLocale from 'dayjs/locale/en.js';
|
|
3
|
+
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
4
|
+
import updateLocale from 'dayjs/plugin/updateLocale.js';
|
|
5
|
+
|
|
6
|
+
dayjs.extend(relativeTime);
|
|
7
|
+
dayjs.extend(updateLocale);
|
|
8
|
+
|
|
9
|
+
const localeObject = {
|
|
10
|
+
...englishLocale,
|
|
11
|
+
name: 'en-web3-modal',
|
|
12
|
+
relativeTime: {
|
|
13
|
+
future: 'in %s',
|
|
14
|
+
past: '%s ago',
|
|
15
|
+
s: '%d sec',
|
|
16
|
+
m: '1 min',
|
|
17
|
+
mm: '%d min',
|
|
18
|
+
h: '1 hr',
|
|
19
|
+
hh: '%d hrs',
|
|
20
|
+
d: '1 d',
|
|
21
|
+
dd: '%d d',
|
|
22
|
+
M: '1 mo',
|
|
23
|
+
MM: '%d mo',
|
|
24
|
+
y: '1 yr',
|
|
25
|
+
yy: '%d yr'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
dayjs.locale('en-appkit', localeObject);
|
|
30
|
+
|
|
31
|
+
export const DateUtil = {
|
|
32
|
+
getYear(date: string = new Date().toISOString()) {
|
|
33
|
+
return dayjs(date).year();
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
getRelativeDateFromNow(date: string | number) {
|
|
37
|
+
return dayjs(date).locale('en-appkit').fromNow(true);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
formatDate(date: string | number, format = 'DD MMM') {
|
|
41
|
+
return dayjs(date).format(format);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
getMonth(month: number) {
|
|
45
|
+
return dayjs().month(month).format('MMMM');
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const ErrorUtil = {
|
|
2
|
+
UniversalProviderErrors: {
|
|
3
|
+
UNAUTHORIZED_DOMAIN_NOT_ALLOWED: {
|
|
4
|
+
message: 'Unauthorized: origin not allowed',
|
|
5
|
+
alertErrorKey: 'INVALID_APP_CONFIGURATION'
|
|
6
|
+
},
|
|
7
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
8
|
+
message: 'Project ID is missing',
|
|
9
|
+
alertErrorKey: 'PROJECT_ID_NOT_CONFIGURED'
|
|
10
|
+
},
|
|
11
|
+
JWT_VALIDATION_ERROR: {
|
|
12
|
+
message: 'JWT validation error: JWT Token is not yet valid',
|
|
13
|
+
alertErrorKey: 'JWT_TOKEN_NOT_VALID'
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
ALERT_ERRORS: {
|
|
17
|
+
INVALID_APP_CONFIGURATION: {
|
|
18
|
+
shortMessage: 'Invalid App Configuration',
|
|
19
|
+
longMessage: `Bundle ID not found on Allowlist - Please verify that your bundle ID is allowed at https://cloud.reown.com`
|
|
20
|
+
},
|
|
21
|
+
SOCIALS_TIMEOUT: {
|
|
22
|
+
shortMessage: 'Invalid App Configuration',
|
|
23
|
+
longMessage:
|
|
24
|
+
'There was an issue loading the embedded wallet. Please verify that your bundle ID is allowed at https://cloud.reown.com'
|
|
25
|
+
},
|
|
26
|
+
JWT_TOKEN_NOT_VALID: {
|
|
27
|
+
shortMessage: 'Session Expired',
|
|
28
|
+
longMessage: 'Invalid session found - please check your time settings and connect again'
|
|
29
|
+
},
|
|
30
|
+
PROJECT_ID_NOT_CONFIGURED: {
|
|
31
|
+
shortMessage: 'Project ID Not Configured',
|
|
32
|
+
longMessage: 'Project ID Not Configured - update configuration'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as BigNumber from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
export const NumberUtil = {
|
|
4
|
+
bigNumber(value: BigNumber.BigNumber.Value) {
|
|
5
|
+
return new BigNumber.BigNumber(value);
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Multiply two numbers represented as strings with BigNumber to handle decimals correctly
|
|
10
|
+
* @param a string
|
|
11
|
+
* @param b string
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
multiply(a: BigNumber.BigNumber.Value | undefined, b: BigNumber.BigNumber.Value | undefined) {
|
|
15
|
+
if (a === undefined || b === undefined) {
|
|
16
|
+
return BigNumber.BigNumber(0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const aBigNumber = new BigNumber.BigNumber(a);
|
|
20
|
+
const bBigNumber = new BigNumber.BigNumber(b);
|
|
21
|
+
|
|
22
|
+
return aBigNumber.multipliedBy(bBigNumber);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
roundNumber(number: number, threshold: number, fixed: number) {
|
|
26
|
+
const roundedNumber =
|
|
27
|
+
number.toString().length >= threshold ? Number(number).toFixed(fixed) : number;
|
|
28
|
+
|
|
29
|
+
return roundedNumber;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export interface Balance {
|
|
2
|
+
name: string;
|
|
3
|
+
symbol: string;
|
|
4
|
+
chainId: string;
|
|
5
|
+
address?: string;
|
|
6
|
+
value?: number;
|
|
7
|
+
price: number;
|
|
8
|
+
quantity: BalanceQuantity;
|
|
9
|
+
iconUrl: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type BalanceQuantity = {
|
|
13
|
+
decimals: string;
|
|
14
|
+
numeric: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type TransactionStatus = 'confirmed' | 'failed' | 'pending';
|
|
18
|
+
export type TransactionDirection = 'in' | 'out' | 'self';
|
|
19
|
+
export type TransactionImage = {
|
|
20
|
+
type: 'FUNGIBLE' | 'NFT' | undefined;
|
|
21
|
+
url: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface Transaction {
|
|
25
|
+
id: string;
|
|
26
|
+
metadata: TransactionMetadata;
|
|
27
|
+
transfers: TransactionTransfer[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface TransactionMetadata {
|
|
31
|
+
application: {
|
|
32
|
+
iconUrl: string | null;
|
|
33
|
+
name: string | null;
|
|
34
|
+
};
|
|
35
|
+
operationType: string;
|
|
36
|
+
hash: string;
|
|
37
|
+
minedAt: string;
|
|
38
|
+
sentFrom: string;
|
|
39
|
+
sentTo: string;
|
|
40
|
+
status: TransactionStatus;
|
|
41
|
+
nonce: number;
|
|
42
|
+
chain?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface TransactionTransfer {
|
|
46
|
+
fungible_info?: {
|
|
47
|
+
name?: string;
|
|
48
|
+
symbol?: string;
|
|
49
|
+
icon?: {
|
|
50
|
+
url: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
nft_info?: TransactionNftInfo;
|
|
54
|
+
direction: TransactionDirection;
|
|
55
|
+
quantity: TransactionQuantity;
|
|
56
|
+
value?: number;
|
|
57
|
+
price?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface TransactionNftInfo {
|
|
61
|
+
name?: string;
|
|
62
|
+
content?: TransactionContent;
|
|
63
|
+
flags: TransactionNftInfoFlags;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface TransactionNftInfoFlags {
|
|
67
|
+
is_spam: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface TransactionContent {
|
|
71
|
+
preview?: TransactionPreview;
|
|
72
|
+
detail?: TransactionDetail;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface TransactionPreview {
|
|
76
|
+
url: string;
|
|
77
|
+
content_type?: null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TransactionDetail {
|
|
81
|
+
url: string;
|
|
82
|
+
content_type?: null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface TransactionQuantity {
|
|
86
|
+
numeric: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type SocialProvider = 'apple' | 'x' | 'discord' | 'farcaster';
|