@reown/appkit 1.0.7 → 1.1.1-40d0859f0.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/dist/esm/exports/constants.js +2 -0
- package/dist/esm/exports/constants.js.map +1 -0
- package/dist/esm/exports/index.js +4 -4
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/react.js +3 -3
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/vue.js +3 -3
- package/dist/esm/exports/vue.js.map +1 -1
- package/dist/esm/package.json +8 -7
- package/dist/esm/src/client.js +81 -37
- package/dist/esm/src/client.js.map +1 -1
- package/dist/esm/src/library/react/index.js +2 -0
- package/dist/esm/src/library/react/index.js.map +1 -1
- package/dist/esm/src/library/vue/index.js +3 -13
- package/dist/esm/src/library/vue/index.js.map +1 -1
- package/dist/esm/src/networks/index.js +5 -175
- package/dist/esm/src/networks/index.js.map +1 -1
- package/dist/esm/src/networks/solana/index.js +4 -0
- package/dist/esm/src/networks/solana/index.js.map +1 -0
- package/dist/esm/src/networks/solana/solana.js +15 -0
- package/dist/esm/src/networks/solana/solana.js.map +1 -0
- package/dist/esm/src/networks/solana/solanaDevnet.js +15 -0
- package/dist/esm/src/networks/solana/solanaDevnet.js.map +1 -0
- package/dist/esm/src/networks/solana/solanaTestnet.js +15 -0
- package/dist/esm/src/networks/solana/solanaTestnet.js.map +1 -0
- package/dist/esm/src/networks/utils.js +9 -0
- package/dist/esm/src/networks/utils.js.map +1 -0
- package/dist/esm/src/tests/appkit.test.js +345 -0
- package/dist/esm/src/tests/appkit.test.js.map +1 -0
- package/dist/esm/src/tests/mocks/AppKit.js +23 -0
- package/dist/esm/src/tests/mocks/AppKit.js.map +1 -0
- package/dist/esm/src/tests/mocks/Options.js +14 -0
- package/dist/esm/src/tests/mocks/Options.js.map +1 -0
- package/dist/esm/src/tests/mocks/UniversalProvider.js +131 -0
- package/dist/esm/src/tests/mocks/UniversalProvider.js.map +1 -0
- package/dist/esm/src/tests/universal-adapter.test.js +151 -0
- package/dist/esm/src/tests/universal-adapter.test.js.map +1 -0
- package/dist/esm/src/tests/utils/HelpersUtil.test.js +148 -0
- package/dist/esm/src/tests/utils/HelpersUtil.test.js.map +1 -0
- package/dist/esm/src/universal-adapter/client.js +76 -44
- package/dist/esm/src/universal-adapter/client.js.map +1 -1
- package/dist/esm/src/utils/HelpersUtil.js +7 -5
- package/dist/esm/src/utils/HelpersUtil.js.map +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/dist/types/exports/constants.d.ts +1 -0
- package/dist/types/exports/index.d.ts +1 -1
- package/dist/types/exports/react.d.ts +1 -1
- package/dist/types/exports/vue.d.ts +1 -1
- package/dist/types/src/client.d.ts +20 -14
- package/dist/types/src/library/react/index.d.ts +2 -2
- package/dist/types/src/library/vue/index.d.ts +6 -12
- package/dist/types/src/networks/index.d.ts +4 -20
- package/dist/types/src/networks/solana/index.d.ts +3 -0
- package/dist/types/src/networks/solana/solana.d.ts +41 -0
- package/dist/types/src/networks/solana/solanaDevnet.d.ts +41 -0
- package/dist/types/src/networks/solana/solanaTestnet.d.ts +41 -0
- package/dist/types/src/networks/utils.d.ts +3 -0
- package/dist/types/src/store/ProviderUtil.d.ts +1 -2
- package/dist/types/src/store/index.d.ts +1 -1
- package/dist/types/src/tests/appkit.test.d.ts +1 -0
- package/dist/types/src/tests/mocks/AppKit.d.ts +3 -0
- package/dist/types/src/tests/mocks/Options.d.ts +18 -0
- package/dist/types/src/tests/mocks/UniversalProvider.d.ts +3 -0
- package/dist/types/src/tests/universal-adapter.test.d.ts +1 -0
- package/dist/types/src/tests/utils/HelpersUtil.test.d.ts +1 -0
- package/dist/types/src/universal-adapter/client.d.ts +6 -6
- package/dist/types/src/utils/TypesUtil.d.ts +9 -5
- package/package.json +14 -13
|
@@ -1,176 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
chainId: 1,
|
|
7
|
-
name: 'Ethereum',
|
|
8
|
-
currency: 'ETH',
|
|
9
|
-
explorerUrl: 'https://etherscan.io',
|
|
10
|
-
rpcUrl: getBlockchainApiRpcUrl(1, 'eip155'),
|
|
11
|
-
chainNamespace: 'eip155'
|
|
12
|
-
};
|
|
13
|
-
export const arbitrum = {
|
|
14
|
-
id: 'eip155:42161',
|
|
15
|
-
chainId: 42161,
|
|
16
|
-
name: 'Arbitrum',
|
|
17
|
-
currency: 'ETH',
|
|
18
|
-
explorerUrl: 'https://arbiscan.io',
|
|
19
|
-
rpcUrl: getBlockchainApiRpcUrl(42161, 'eip155'),
|
|
20
|
-
chainNamespace: 'eip155'
|
|
21
|
-
};
|
|
22
|
-
export const avalanche = {
|
|
23
|
-
id: 'eip155:43114',
|
|
24
|
-
chainId: 43114,
|
|
25
|
-
name: 'Avalanche',
|
|
26
|
-
currency: 'AVAX',
|
|
27
|
-
explorerUrl: 'https://snowtrace.io',
|
|
28
|
-
rpcUrl: getBlockchainApiRpcUrl(43114, 'eip155'),
|
|
29
|
-
chainNamespace: 'eip155'
|
|
30
|
-
};
|
|
31
|
-
export const binanceSmartChain = {
|
|
32
|
-
id: 'eip155:56',
|
|
33
|
-
chainId: 56,
|
|
34
|
-
name: 'Binance Smart Chain',
|
|
35
|
-
currency: 'BNB',
|
|
36
|
-
explorerUrl: 'https://bscscan.com',
|
|
37
|
-
rpcUrl: getBlockchainApiRpcUrl(56, 'eip155'),
|
|
38
|
-
chainNamespace: 'eip155'
|
|
39
|
-
};
|
|
40
|
-
export const optimism = {
|
|
41
|
-
id: 'eip155:10',
|
|
42
|
-
chainId: 10,
|
|
43
|
-
name: 'Optimism',
|
|
44
|
-
currency: 'ETH',
|
|
45
|
-
explorerUrl: 'https://optimistic.etherscan.io',
|
|
46
|
-
rpcUrl: getBlockchainApiRpcUrl(10, 'eip155'),
|
|
47
|
-
chainNamespace: 'eip155'
|
|
48
|
-
};
|
|
49
|
-
export const polygon = {
|
|
50
|
-
id: 'eip155:137',
|
|
51
|
-
chainId: 137,
|
|
52
|
-
name: 'Polygon',
|
|
53
|
-
currency: 'MATIC',
|
|
54
|
-
explorerUrl: 'https://polygonscan.com',
|
|
55
|
-
rpcUrl: getBlockchainApiRpcUrl(137, 'eip155'),
|
|
56
|
-
chainNamespace: 'eip155'
|
|
57
|
-
};
|
|
58
|
-
export const gnosis = {
|
|
59
|
-
id: 'eip155:100',
|
|
60
|
-
chainId: 100,
|
|
61
|
-
name: 'Gnosis',
|
|
62
|
-
currency: 'xDAI',
|
|
63
|
-
explorerUrl: 'https://gnosis.blockscout.com',
|
|
64
|
-
rpcUrl: getBlockchainApiRpcUrl(100, 'eip155'),
|
|
65
|
-
chainNamespace: 'eip155'
|
|
66
|
-
};
|
|
67
|
-
export const zkSync = {
|
|
68
|
-
id: 'eip155:324',
|
|
69
|
-
chainId: 324,
|
|
70
|
-
name: 'ZkSync',
|
|
71
|
-
currency: 'ETH',
|
|
72
|
-
explorerUrl: 'https://explorer.zksync.io',
|
|
73
|
-
rpcUrl: getBlockchainApiRpcUrl(324, 'eip155'),
|
|
74
|
-
chainNamespace: 'eip155'
|
|
75
|
-
};
|
|
76
|
-
export const zora = {
|
|
77
|
-
id: 'eip155:7777777',
|
|
78
|
-
chainId: 7777777,
|
|
79
|
-
name: 'Zora',
|
|
80
|
-
currency: 'ETH',
|
|
81
|
-
explorerUrl: 'https://explorer.zora.energy',
|
|
82
|
-
rpcUrl: getBlockchainApiRpcUrl(7777777, 'eip155'),
|
|
83
|
-
chainNamespace: 'eip155'
|
|
84
|
-
};
|
|
85
|
-
export const celo = {
|
|
86
|
-
id: 'eip155:42220',
|
|
87
|
-
chainId: 42220,
|
|
88
|
-
name: 'Celo',
|
|
89
|
-
currency: 'CELO',
|
|
90
|
-
explorerUrl: 'https://explorer.celo.org/mainnet',
|
|
91
|
-
rpcUrl: getBlockchainApiRpcUrl(42220, 'eip155'),
|
|
92
|
-
chainNamespace: 'eip155'
|
|
93
|
-
};
|
|
94
|
-
export const base = {
|
|
95
|
-
id: 'eip155:8453',
|
|
96
|
-
chainId: 8453,
|
|
97
|
-
name: 'Base',
|
|
98
|
-
currency: 'BASE',
|
|
99
|
-
explorerUrl: 'https://basescan.org',
|
|
100
|
-
rpcUrl: getBlockchainApiRpcUrl(8453, 'eip155'),
|
|
101
|
-
chainNamespace: 'eip155'
|
|
102
|
-
};
|
|
103
|
-
export const aurora = {
|
|
104
|
-
id: 'eip155:1313161554',
|
|
105
|
-
chainId: 1313161554,
|
|
106
|
-
name: 'Aurora',
|
|
107
|
-
currency: 'ETH',
|
|
108
|
-
explorerUrl: 'https://explorer.aurora.dev',
|
|
109
|
-
rpcUrl: getBlockchainApiRpcUrl(1313161554, 'eip155'),
|
|
110
|
-
chainNamespace: 'eip155'
|
|
111
|
-
};
|
|
112
|
-
export const sepolia = {
|
|
113
|
-
id: 'eip155:11155111',
|
|
114
|
-
chainId: 11155111,
|
|
115
|
-
name: 'Sepolia',
|
|
116
|
-
currency: 'ETH',
|
|
117
|
-
explorerUrl: 'https://sepolia.etherscan.io',
|
|
118
|
-
rpcUrl: getBlockchainApiRpcUrl(11155111, 'eip155'),
|
|
119
|
-
chainNamespace: 'eip155'
|
|
120
|
-
};
|
|
121
|
-
export const baseSepolia = {
|
|
122
|
-
id: 'eip155:84532',
|
|
123
|
-
chainId: 84532,
|
|
124
|
-
name: 'Base Sepolia',
|
|
125
|
-
currency: 'BASE',
|
|
126
|
-
explorerUrl: 'https://sepolia.basescan.org',
|
|
127
|
-
rpcUrl: getBlockchainApiRpcUrl(84532, 'eip155'),
|
|
128
|
-
chainNamespace: 'eip155'
|
|
129
|
-
};
|
|
130
|
-
export const solana = {
|
|
131
|
-
id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
132
|
-
chainId: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
133
|
-
name: 'Solana',
|
|
134
|
-
currency: 'SOL',
|
|
135
|
-
explorerUrl: 'https://solscan.io',
|
|
136
|
-
rpcUrl: getBlockchainApiRpcUrl('5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', 'solana'),
|
|
137
|
-
chainNamespace: 'solana'
|
|
138
|
-
};
|
|
139
|
-
export const solanaTestnet = {
|
|
140
|
-
id: 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
|
|
141
|
-
chainId: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
|
|
142
|
-
name: 'Solana Testnet',
|
|
143
|
-
currency: 'SOL',
|
|
144
|
-
explorerUrl: 'https://explorer.solana.com/?cluster=testnet',
|
|
145
|
-
rpcUrl: getBlockchainApiRpcUrl('4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z', 'solana'),
|
|
146
|
-
chainNamespace: 'solana'
|
|
147
|
-
};
|
|
148
|
-
export const solanaDevnet = {
|
|
149
|
-
id: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
150
|
-
chainId: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
151
|
-
name: 'Solana Devnet',
|
|
152
|
-
currency: 'SOL',
|
|
153
|
-
explorerUrl: 'https://explorer.solana.com/?cluster=devnet',
|
|
154
|
-
rpcUrl: getBlockchainApiRpcUrl('EtWTRABZaYq6iMfeYKouRu166VU2xqa1', 'solana'),
|
|
155
|
-
chainNamespace: 'solana'
|
|
156
|
-
};
|
|
157
|
-
export const allChains = [
|
|
158
|
-
mainnet,
|
|
159
|
-
arbitrum,
|
|
160
|
-
avalanche,
|
|
161
|
-
binanceSmartChain,
|
|
162
|
-
optimism,
|
|
163
|
-
polygon,
|
|
164
|
-
gnosis,
|
|
165
|
-
zkSync,
|
|
166
|
-
zora,
|
|
167
|
-
celo,
|
|
168
|
-
base,
|
|
169
|
-
aurora,
|
|
170
|
-
sepolia,
|
|
171
|
-
baseSepolia,
|
|
172
|
-
solana,
|
|
173
|
-
solanaTestnet,
|
|
174
|
-
solanaDevnet
|
|
175
|
-
];
|
|
1
|
+
// -- Networks ---------------------------------------------------------------
|
|
2
|
+
export * from 'viem/chains';
|
|
3
|
+
export * from './solana/index.js';
|
|
4
|
+
// -- Utils ------------------------------------------------------------------
|
|
5
|
+
export * from './utils.js';
|
|
176
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/networks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/networks/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AAEjC,8EAA8E;AAC9E,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/networks/solana/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineChain } from '../utils.js';
|
|
2
|
+
export const solana = defineChain({
|
|
3
|
+
id: '5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
4
|
+
name: 'Solana',
|
|
5
|
+
network: 'solana-mainnet',
|
|
6
|
+
nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: { http: ['https://rpc.walletconnect.org/v1'] }
|
|
9
|
+
},
|
|
10
|
+
blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
|
|
11
|
+
testnet: false,
|
|
12
|
+
chainNamespace: 'solana',
|
|
13
|
+
caipNetworkId: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=solana.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solana.js","sourceRoot":"","sources":["../../../../../src/networks/solana/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG,WAAW,CAAC;IAChC,EAAE,EAAE,kCAAkC;IACtC,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,gBAAgB;IACzB,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,kCAAkC,CAAC,EAAE;KACxD;IACD,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,oBAAoB,EAAE,EAAE;IAC3E,OAAO,EAAE,KAAK;IACd,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,yCAAyC;CACzD,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineChain } from '../utils.js';
|
|
2
|
+
export const solanaDevnet = defineChain({
|
|
3
|
+
id: 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
4
|
+
name: 'Solana Devnet',
|
|
5
|
+
network: 'solana-devnet',
|
|
6
|
+
nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: { http: ['https://rpc.walletconnect.org/v1'] }
|
|
9
|
+
},
|
|
10
|
+
blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
|
|
11
|
+
testnet: true,
|
|
12
|
+
chainNamespace: 'solana',
|
|
13
|
+
caipNetworkId: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1'
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=solanaDevnet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaDevnet.js","sourceRoot":"","sources":["../../../../../src/networks/solana/solanaDevnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;IACtC,EAAE,EAAE,kCAAkC;IACtC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,eAAe;IACxB,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,kCAAkC,CAAC,EAAE;KACxD;IACD,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,oBAAoB,EAAE,EAAE;IAC3E,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,yCAAyC;CACzD,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineChain } from '../utils.js';
|
|
2
|
+
export const solanaTestnet = defineChain({
|
|
3
|
+
id: '4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z',
|
|
4
|
+
name: 'Solana Testnet',
|
|
5
|
+
network: 'solana-testnet',
|
|
6
|
+
nativeCurrency: { name: 'Solana', symbol: 'SOL', decimals: 9 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: { http: ['https://rpc.walletconnect.org/v1'] }
|
|
9
|
+
},
|
|
10
|
+
blockExplorers: { default: { name: 'Solscan', url: 'https://solscan.io' } },
|
|
11
|
+
testnet: true,
|
|
12
|
+
chainNamespace: 'solana',
|
|
13
|
+
caipNetworkId: 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z'
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=solanaTestnet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solanaTestnet.js","sourceRoot":"","sources":["../../../../../src/networks/solana/solanaTestnet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC;IACvC,EAAE,EAAE,kCAAkC;IACtC,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,gBAAgB;IACzB,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE;IAC9D,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,kCAAkC,CAAC,EAAE;KACxD;IACD,cAAc,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,oBAAoB,EAAE,EAAE;IAC3E,OAAO,EAAE,IAAI;IACb,cAAc,EAAE,QAAQ;IACxB,aAAa,EAAE,yCAAyC;CACzD,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/networks/utils.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,WAAW,CAGzB,KAAY;IACZ,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,SAAS;QACtB,GAAG,KAAK;KACgC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { AccountController, AssetUtil, BlockchainApiController, ChainController, ConnectionController, ConnectorController, EnsController, EventsController, ModalController, NetworkController, OptionsController, PublicStateController, RouterController, SnackController, ThemeController } from '@reown/appkit-core';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { AppKit } from '../client';
|
|
4
|
+
import { mockOptions } from './mocks/Options';
|
|
5
|
+
// Mock all controllers and UniversalAdapterClient
|
|
6
|
+
vi.mock('@reown/appkit-core');
|
|
7
|
+
vi.mock('../universal-adapter/client');
|
|
8
|
+
describe('Base', () => {
|
|
9
|
+
let appKit;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
vi.resetAllMocks();
|
|
12
|
+
appKit = new AppKit(mockOptions);
|
|
13
|
+
});
|
|
14
|
+
describe('Base Initialization', () => {
|
|
15
|
+
it('should initialize controllers with required provided options', () => {
|
|
16
|
+
expect(OptionsController.setSdkVersion).toHaveBeenCalledWith(mockOptions.sdkVersion);
|
|
17
|
+
expect(OptionsController.setProjectId).toHaveBeenCalledWith(mockOptions.projectId);
|
|
18
|
+
expect(OptionsController.setMetadata).toHaveBeenCalled();
|
|
19
|
+
});
|
|
20
|
+
it('should initialize adapters in ChainController', () => {
|
|
21
|
+
expect(ChainController.initialize).toHaveBeenCalledWith(mockOptions.adapters);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('Base Public methods', () => {
|
|
25
|
+
it('should open modal', async () => {
|
|
26
|
+
await appKit.open();
|
|
27
|
+
expect(ModalController.open).toHaveBeenCalled();
|
|
28
|
+
});
|
|
29
|
+
it('should close modal', async () => {
|
|
30
|
+
await appKit.close();
|
|
31
|
+
expect(ModalController.close).toHaveBeenCalled();
|
|
32
|
+
});
|
|
33
|
+
it('should set loading state', () => {
|
|
34
|
+
appKit.setLoading(true);
|
|
35
|
+
expect(ModalController.setLoading).toHaveBeenCalledWith(true);
|
|
36
|
+
});
|
|
37
|
+
it('should get theme mode', () => {
|
|
38
|
+
vi.mocked(ThemeController).state = { themeMode: 'dark' };
|
|
39
|
+
expect(appKit.getThemeMode()).toBe('dark');
|
|
40
|
+
});
|
|
41
|
+
it('should set theme mode', () => {
|
|
42
|
+
appKit.setThemeMode('light');
|
|
43
|
+
expect(ThemeController.setThemeMode).toHaveBeenCalledWith('light');
|
|
44
|
+
});
|
|
45
|
+
it('should get theme variables', () => {
|
|
46
|
+
vi.mocked(ThemeController).state = {
|
|
47
|
+
themeVariables: { '--w3m-accent': '#000' }
|
|
48
|
+
};
|
|
49
|
+
expect(appKit.getThemeVariables()).toEqual({ '--w3m-accent': '#000' });
|
|
50
|
+
});
|
|
51
|
+
it('should set theme variables', () => {
|
|
52
|
+
const themeVariables = { '--w3m-accent': '#fff' };
|
|
53
|
+
appKit.setThemeVariables(themeVariables);
|
|
54
|
+
expect(ThemeController.setThemeVariables).toHaveBeenCalledWith(themeVariables);
|
|
55
|
+
});
|
|
56
|
+
it('should subscribe to theme changes', () => {
|
|
57
|
+
const callback = vi.fn();
|
|
58
|
+
appKit.subscribeTheme(callback);
|
|
59
|
+
expect(ThemeController.subscribe).toHaveBeenCalledWith(callback);
|
|
60
|
+
});
|
|
61
|
+
it('should get wallet info', () => {
|
|
62
|
+
vi.mocked(AccountController).state = { connectedWalletInfo: { name: 'Test Wallet' } };
|
|
63
|
+
expect(appKit.getWalletInfo()).toEqual({ name: 'Test Wallet' });
|
|
64
|
+
});
|
|
65
|
+
it('should subscribe to wallet info changes', () => {
|
|
66
|
+
const callback = vi.fn();
|
|
67
|
+
appKit.subscribeWalletInfo(callback);
|
|
68
|
+
expect(AccountController.subscribeKey).toHaveBeenCalledWith('connectedWalletInfo', callback);
|
|
69
|
+
});
|
|
70
|
+
it('should subscribe to address updates', () => {
|
|
71
|
+
const callback = vi.fn();
|
|
72
|
+
appKit.subscribeShouldUpdateToAddress(callback);
|
|
73
|
+
expect(AccountController.subscribeKey).toHaveBeenCalledWith('shouldUpdateToAddress', callback);
|
|
74
|
+
});
|
|
75
|
+
it('should subscribe to CAIP network changes', () => {
|
|
76
|
+
const callback = vi.fn();
|
|
77
|
+
appKit.subscribeCaipNetworkChange(callback);
|
|
78
|
+
expect(NetworkController.subscribeKey).toHaveBeenCalledWith('caipNetwork', callback);
|
|
79
|
+
});
|
|
80
|
+
it('should get state', () => {
|
|
81
|
+
vi.mocked(PublicStateController).state = { isConnected: true };
|
|
82
|
+
expect(appKit.getState()).toEqual({ isConnected: true });
|
|
83
|
+
});
|
|
84
|
+
it('should subscribe to state changes', () => {
|
|
85
|
+
const callback = vi.fn();
|
|
86
|
+
appKit.subscribeState(callback);
|
|
87
|
+
expect(PublicStateController.subscribe).toHaveBeenCalledWith(callback);
|
|
88
|
+
});
|
|
89
|
+
it('should show error message', () => {
|
|
90
|
+
appKit.showErrorMessage('Test error');
|
|
91
|
+
expect(SnackController.showError).toHaveBeenCalledWith('Test error');
|
|
92
|
+
});
|
|
93
|
+
it('should show success message', () => {
|
|
94
|
+
appKit.showSuccessMessage('Test success');
|
|
95
|
+
expect(SnackController.showSuccess).toHaveBeenCalledWith('Test success');
|
|
96
|
+
});
|
|
97
|
+
it('should get event', () => {
|
|
98
|
+
vi.mocked(EventsController).state = { name: 'test_event' };
|
|
99
|
+
expect(appKit.getEvent()).toEqual({ name: 'test_event' });
|
|
100
|
+
});
|
|
101
|
+
it('should subscribe to events', () => {
|
|
102
|
+
const callback = vi.fn();
|
|
103
|
+
appKit.subscribeEvents(callback);
|
|
104
|
+
expect(EventsController.subscribe).toHaveBeenCalledWith(callback);
|
|
105
|
+
});
|
|
106
|
+
it('should replace route', () => {
|
|
107
|
+
appKit.replace('Connect');
|
|
108
|
+
expect(RouterController.replace).toHaveBeenCalledWith('Connect');
|
|
109
|
+
});
|
|
110
|
+
it('should redirect to route', () => {
|
|
111
|
+
appKit.redirect('Networks');
|
|
112
|
+
expect(RouterController.push).toHaveBeenCalledWith('Networks');
|
|
113
|
+
});
|
|
114
|
+
it('should pop transaction stack', () => {
|
|
115
|
+
appKit.popTransactionStack(true);
|
|
116
|
+
expect(RouterController.popTransactionStack).toHaveBeenCalledWith(true);
|
|
117
|
+
});
|
|
118
|
+
it('should check if modal is open', () => {
|
|
119
|
+
vi.mocked(ModalController).state = { open: true };
|
|
120
|
+
expect(appKit.isOpen()).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
it('should check if transaction stack is empty', () => {
|
|
123
|
+
vi.mocked(RouterController).state = { transactionStack: [] };
|
|
124
|
+
expect(appKit.isTransactionStackEmpty()).toBe(true);
|
|
125
|
+
});
|
|
126
|
+
it('should check if transaction should replace view', () => {
|
|
127
|
+
vi.mocked(RouterController).state = { transactionStack: [{ replace: true }] };
|
|
128
|
+
expect(appKit.isTransactionShouldReplaceView()).toBe(true);
|
|
129
|
+
});
|
|
130
|
+
it('should set status', () => {
|
|
131
|
+
appKit.setStatus('connected', 'eip155');
|
|
132
|
+
expect(AccountController.setStatus).toHaveBeenCalledWith('connected', 'eip155');
|
|
133
|
+
});
|
|
134
|
+
it('should set all accounts', () => {
|
|
135
|
+
const addresses = ['0x123', '0x456'];
|
|
136
|
+
appKit.setAllAccounts(addresses, 'eip155');
|
|
137
|
+
expect(AccountController.setAllAccounts).toHaveBeenCalledWith(addresses, 'eip155');
|
|
138
|
+
expect(OptionsController.setHasMultipleAddresses).toHaveBeenCalledWith(true);
|
|
139
|
+
});
|
|
140
|
+
it('should add address label', () => {
|
|
141
|
+
appKit.addAddressLabel('0x123', 'eip155 Address', 'eip155');
|
|
142
|
+
expect(AccountController.addAddressLabel).toHaveBeenCalledWith('0x123', 'eip155 Address', 'eip155');
|
|
143
|
+
});
|
|
144
|
+
it('should remove address label', () => {
|
|
145
|
+
appKit.removeAddressLabel('0x123', 'eip155');
|
|
146
|
+
expect(AccountController.removeAddressLabel).toHaveBeenCalledWith('0x123', 'eip155');
|
|
147
|
+
});
|
|
148
|
+
it('should get CAIP address', () => {
|
|
149
|
+
vi.mocked(ChainController).state = {
|
|
150
|
+
activeChain: 'eip155',
|
|
151
|
+
activeCaipAddress: 'eip155:1:0x123'
|
|
152
|
+
};
|
|
153
|
+
expect(appKit.getCaipAddress()).toBe('eip155:1:0x123');
|
|
154
|
+
});
|
|
155
|
+
it('should get address', () => {
|
|
156
|
+
vi.mocked(AccountController).state = { address: '0x123' };
|
|
157
|
+
expect(appKit.getAddress()).toBe('0x123');
|
|
158
|
+
});
|
|
159
|
+
it('should get provider', () => {
|
|
160
|
+
const mockProvider = { request: vi.fn() };
|
|
161
|
+
vi.mocked(AccountController).state = { provider: mockProvider };
|
|
162
|
+
expect(appKit.getProvider()).toBe(mockProvider);
|
|
163
|
+
});
|
|
164
|
+
it('should get preferred account type', () => {
|
|
165
|
+
vi.mocked(AccountController).state = { preferredAccountType: 'eoa' };
|
|
166
|
+
expect(appKit.getPreferredAccountType()).toBe('eoa');
|
|
167
|
+
});
|
|
168
|
+
it('should set CAIP address', () => {
|
|
169
|
+
appKit.setCaipAddress('eip155:1:0x123', 'eip155');
|
|
170
|
+
expect(appKit.getIsConnectedState()).toBe(true);
|
|
171
|
+
expect(AccountController.setCaipAddress).toHaveBeenCalledWith('eip155:1:0x123', 'eip155');
|
|
172
|
+
});
|
|
173
|
+
it('should set provider', () => {
|
|
174
|
+
const mockProvider = {
|
|
175
|
+
request: vi.fn()
|
|
176
|
+
};
|
|
177
|
+
appKit.setProvider(mockProvider, 'eip155');
|
|
178
|
+
expect(AccountController.setProvider).toHaveBeenCalledWith(mockProvider, 'eip155');
|
|
179
|
+
});
|
|
180
|
+
it('should set balance', () => {
|
|
181
|
+
appKit.setBalance('1.5', 'ETH', 'eip155');
|
|
182
|
+
expect(AccountController.setBalance).toHaveBeenCalledWith('1.5', 'ETH', 'eip155');
|
|
183
|
+
});
|
|
184
|
+
it('should set profile name', () => {
|
|
185
|
+
appKit.setProfileName('John Doe', 'eip155');
|
|
186
|
+
expect(AccountController.setProfileName).toHaveBeenCalledWith('John Doe', 'eip155');
|
|
187
|
+
});
|
|
188
|
+
it('should set profile image', () => {
|
|
189
|
+
appKit.setProfileImage('https://example.com/image.png', 'eip155');
|
|
190
|
+
expect(AccountController.setProfileImage).toHaveBeenCalledWith('https://example.com/image.png', 'eip155');
|
|
191
|
+
});
|
|
192
|
+
it('should reset account', () => {
|
|
193
|
+
appKit.resetAccount('eip155');
|
|
194
|
+
expect(AccountController.resetAccount).toHaveBeenCalledWith('eip155');
|
|
195
|
+
});
|
|
196
|
+
it('should set CAIP network', () => {
|
|
197
|
+
const caipNetwork = { id: 'eip155:1', name: 'Ethereum' };
|
|
198
|
+
appKit.setCaipNetwork(caipNetwork);
|
|
199
|
+
expect(ChainController.setActiveCaipNetwork).toHaveBeenCalledWith(caipNetwork);
|
|
200
|
+
});
|
|
201
|
+
it('should get CAIP network', () => {
|
|
202
|
+
vi.mocked(ChainController).state = {
|
|
203
|
+
activeCaipNetwork: { id: 'eip155:1', name: 'Ethereum' }
|
|
204
|
+
};
|
|
205
|
+
expect(appKit.getCaipNetwork()).toEqual({ id: 'eip155:1', name: 'Ethereum' });
|
|
206
|
+
});
|
|
207
|
+
it('should set requested CAIP networks', () => {
|
|
208
|
+
const requestedNetworks = [{ id: 'eip155:1', name: 'Ethereum' }];
|
|
209
|
+
appKit.setRequestedCaipNetworks(requestedNetworks, 'eip155');
|
|
210
|
+
expect(NetworkController.setRequestedCaipNetworks).toHaveBeenCalledWith(requestedNetworks, 'eip155');
|
|
211
|
+
});
|
|
212
|
+
it('should set connectors', () => {
|
|
213
|
+
const existingConnectors = [
|
|
214
|
+
{ id: 'phantom', name: 'Phantom', chain: 'eip155', type: 'INJECTED' }
|
|
215
|
+
];
|
|
216
|
+
vi.mocked(ConnectorController.getConnectors).mockReturnValue(existingConnectors);
|
|
217
|
+
const connectors = [
|
|
218
|
+
{ id: 'metamask', name: 'MetaMask', chain: 'eip155', type: 'INJECTED' }
|
|
219
|
+
];
|
|
220
|
+
appKit.setConnectors(connectors);
|
|
221
|
+
expect(ConnectorController.setConnectors).toHaveBeenCalledWith([
|
|
222
|
+
...existingConnectors,
|
|
223
|
+
...connectors
|
|
224
|
+
]);
|
|
225
|
+
});
|
|
226
|
+
it('should add connector', () => {
|
|
227
|
+
const connector = {
|
|
228
|
+
id: 'metamask',
|
|
229
|
+
name: 'MetaMask',
|
|
230
|
+
chain: 'eip155',
|
|
231
|
+
type: 'INJECTED'
|
|
232
|
+
};
|
|
233
|
+
appKit.addConnector(connector);
|
|
234
|
+
expect(ConnectorController.addConnector).toHaveBeenCalledWith(connector);
|
|
235
|
+
});
|
|
236
|
+
it('should get connectors', () => {
|
|
237
|
+
const mockConnectors = [
|
|
238
|
+
{ id: 'metamask', name: 'MetaMask', chain: 'eip155:1', type: 'INJECTED' }
|
|
239
|
+
];
|
|
240
|
+
vi.mocked(ConnectorController.getConnectors).mockReturnValue(mockConnectors);
|
|
241
|
+
expect(appKit.getConnectors()).toEqual(mockConnectors);
|
|
242
|
+
});
|
|
243
|
+
it('should get approved CAIP network IDs', () => {
|
|
244
|
+
vi.mocked(NetworkController.getApprovedCaipNetworkIds).mockReturnValue(['eip155:1']);
|
|
245
|
+
expect(appKit.getApprovedCaipNetworkIds()).toEqual(['eip155:1']);
|
|
246
|
+
});
|
|
247
|
+
it('should set approved CAIP networks data', () => {
|
|
248
|
+
appKit.setApprovedCaipNetworksData('eip155');
|
|
249
|
+
expect(NetworkController.setApprovedCaipNetworksData).toHaveBeenCalledWith('eip155');
|
|
250
|
+
});
|
|
251
|
+
it('should reset network', () => {
|
|
252
|
+
appKit.resetNetwork();
|
|
253
|
+
expect(NetworkController.resetNetwork).toHaveBeenCalled();
|
|
254
|
+
});
|
|
255
|
+
it('should reset WC connection', () => {
|
|
256
|
+
appKit.resetWcConnection();
|
|
257
|
+
expect(ConnectionController.resetWcConnection).toHaveBeenCalled();
|
|
258
|
+
});
|
|
259
|
+
it('should fetch identity', async () => {
|
|
260
|
+
const mockRequest = { caipChainId: 'eip155:1', address: '0x123' };
|
|
261
|
+
vi.mocked(BlockchainApiController.fetchIdentity).mockResolvedValue({
|
|
262
|
+
name: 'John Doe',
|
|
263
|
+
avatar: null
|
|
264
|
+
});
|
|
265
|
+
const result = await appKit.fetchIdentity(mockRequest);
|
|
266
|
+
expect(BlockchainApiController.fetchIdentity).toHaveBeenCalledWith(mockRequest);
|
|
267
|
+
expect(result).toEqual({ name: 'John Doe', avatar: null });
|
|
268
|
+
});
|
|
269
|
+
it('should set address explorer URL', () => {
|
|
270
|
+
appKit.setAddressExplorerUrl('https://etherscan.io/address/0x123', 'eip155');
|
|
271
|
+
expect(AccountController.setAddressExplorerUrl).toHaveBeenCalledWith('https://etherscan.io/address/0x123', 'eip155');
|
|
272
|
+
});
|
|
273
|
+
it('should set smart account deployed', () => {
|
|
274
|
+
appKit.setSmartAccountDeployed(true, 'eip155');
|
|
275
|
+
expect(AccountController.setSmartAccountDeployed).toHaveBeenCalledWith(true, 'eip155');
|
|
276
|
+
});
|
|
277
|
+
it('should set connected wallet info', () => {
|
|
278
|
+
const walletInfo = { name: 'MetaMask', icon: 'icon-url' };
|
|
279
|
+
appKit.setConnectedWalletInfo(walletInfo, 'eip155');
|
|
280
|
+
expect(AccountController.setConnectedWalletInfo).toHaveBeenCalledWith(walletInfo, 'eip155');
|
|
281
|
+
});
|
|
282
|
+
it('should set smart account enabled networks', () => {
|
|
283
|
+
const networks = [1, 137];
|
|
284
|
+
appKit.setSmartAccountEnabledNetworks(networks, 'eip155');
|
|
285
|
+
expect(NetworkController.setSmartAccountEnabledNetworks).toHaveBeenCalledWith(networks, 'eip155');
|
|
286
|
+
});
|
|
287
|
+
it('should set preferred account type', () => {
|
|
288
|
+
appKit.setPreferredAccountType('eoa', 'eip155');
|
|
289
|
+
expect(AccountController.setPreferredAccountType).toHaveBeenCalledWith('eoa', 'eip155');
|
|
290
|
+
});
|
|
291
|
+
it('should get Reown name', async () => {
|
|
292
|
+
vi.mocked(EnsController.getNamesForAddress).mockResolvedValue([
|
|
293
|
+
{
|
|
294
|
+
name: 'john.reown.id',
|
|
295
|
+
addresses: { eip155: { address: '0x123', created: '0' } },
|
|
296
|
+
attributes: [],
|
|
297
|
+
registered: 0,
|
|
298
|
+
updated: 0
|
|
299
|
+
}
|
|
300
|
+
]);
|
|
301
|
+
const result = await appKit.getReownName('john.reown.id');
|
|
302
|
+
expect(EnsController.getNamesForAddress).toHaveBeenCalledWith('john.reown.id');
|
|
303
|
+
expect(result).toEqual([
|
|
304
|
+
{
|
|
305
|
+
name: 'john.reown.id',
|
|
306
|
+
addresses: { eip155: { address: '0x123', created: '0' } },
|
|
307
|
+
attributes: [],
|
|
308
|
+
registered: 0,
|
|
309
|
+
updated: 0
|
|
310
|
+
}
|
|
311
|
+
]);
|
|
312
|
+
});
|
|
313
|
+
it('should resolve Reown name', async () => {
|
|
314
|
+
vi.mocked(EnsController.resolveName).mockResolvedValue({
|
|
315
|
+
addresses: { eip155: { address: '0x123', created: '0' } },
|
|
316
|
+
name: 'john.reown.id',
|
|
317
|
+
registered: 0,
|
|
318
|
+
updated: 0,
|
|
319
|
+
attributes: []
|
|
320
|
+
});
|
|
321
|
+
const result = await appKit.resolveReownName('john.reown.id');
|
|
322
|
+
expect(EnsController.resolveName).toHaveBeenCalledWith('john.reown.id');
|
|
323
|
+
expect(result).toBe('0x123');
|
|
324
|
+
});
|
|
325
|
+
it('should set EIP6963 enabled', () => {
|
|
326
|
+
appKit.setEIP6963Enabled(true);
|
|
327
|
+
expect(OptionsController.setEIP6963Enabled).toHaveBeenCalledWith(true);
|
|
328
|
+
});
|
|
329
|
+
it('should set client ID', () => {
|
|
330
|
+
appKit.setClientId('client-123');
|
|
331
|
+
expect(BlockchainApiController.setClientId).toHaveBeenCalledWith('client-123');
|
|
332
|
+
});
|
|
333
|
+
it('should get connector image', () => {
|
|
334
|
+
vi.mocked(AssetUtil.getConnectorImage).mockReturnValue('connector-image-url');
|
|
335
|
+
const result = appKit.getConnectorImage({ id: 'metamask', type: 'INJECTED', chain: 'eip155' });
|
|
336
|
+
expect(AssetUtil.getConnectorImage).toHaveBeenCalledWith({
|
|
337
|
+
id: 'metamask',
|
|
338
|
+
type: 'INJECTED',
|
|
339
|
+
chain: 'eip155'
|
|
340
|
+
});
|
|
341
|
+
expect(result).toBe('connector-image-url');
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
//# sourceMappingURL=appkit.test.js.map
|