@@ -13,7 +13,7 @@ const customRpcUrls = {
13
13
describe ( "Wallet provider" , ( ) => {
14
14
let walletProvider : WalletProvider ;
15
15
let pk : `0x${string } `;
16
- let customChains : Record < string , Chain > = { } ;
16
+ const customChains : Record < string , Chain > = { } ;
17
17
18
18
beforeAll ( ( ) => {
19
19
pk = generatePrivateKey ( ) ;
@@ -32,24 +32,24 @@ describe("Wallet provider", () => {
32
32
33
33
walletProvider = new WalletProvider ( pk ) ;
34
34
35
- expect ( walletProvider . getAddress ( ) ) . to . be . eq ( expectedAddress ) ;
35
+ expect ( walletProvider . getAddress ( ) ) . toEqual ( expectedAddress ) ;
36
36
} ) ;
37
37
it ( "sets default chain to ethereum mainnet" , ( ) => {
38
38
walletProvider = new WalletProvider ( pk ) ;
39
39
40
- expect ( walletProvider . chains . mainnet . id ) . to . be . eq ( mainnet . id ) ;
41
- expect ( walletProvider . getCurrentChain ( ) . id ) . to . be . eq ( mainnet . id ) ;
40
+ expect ( walletProvider . chains . mainnet . id ) . toEqual ( mainnet . id ) ;
41
+ expect ( walletProvider . getCurrentChain ( ) . id ) . toEqual ( mainnet . id ) ;
42
42
} ) ;
43
43
it ( "sets custom chains" , ( ) => {
44
44
walletProvider = new WalletProvider ( pk , customChains ) ;
45
45
46
- expect ( walletProvider . chains . iotex . id ) . to . be . eq ( iotex . id ) ;
47
- expect ( walletProvider . chains . arbitrum . id ) . to . be . eq ( arbitrum . id ) ;
46
+ expect ( walletProvider . chains . iotex . id ) . toEqual ( iotex . id ) ;
47
+ expect ( walletProvider . chains . arbitrum . id ) . toEqual ( arbitrum . id ) ;
48
48
} ) ;
49
49
it ( "sets the first provided custom chain as current chain" , ( ) => {
50
50
walletProvider = new WalletProvider ( pk , customChains ) ;
51
51
52
- expect ( walletProvider . getCurrentChain ( ) . id ) . to . be . eq ( iotex . id ) ;
52
+ expect ( walletProvider . getCurrentChain ( ) . id ) . toEqual ( iotex . id ) ;
53
53
} ) ;
54
54
} ) ;
55
55
describe ( "Clients" , ( ) => {
@@ -58,7 +58,7 @@ describe("Wallet provider", () => {
58
58
} ) ;
59
59
it ( "generates public client" , ( ) => {
60
60
const client = walletProvider . getPublicClient ( "mainnet" ) ;
61
- expect ( client . chain . id ) . to . be . equal ( mainnet . id ) ;
61
+ expect ( client . chain . id ) . toEqual ( mainnet . id ) ;
62
62
expect ( client . transport . url ) . toEqual (
63
63
mainnet . rpcUrls . default . http [ 0 ]
64
64
) ;
@@ -71,11 +71,11 @@ describe("Wallet provider", () => {
71
71
const wp = new WalletProvider ( pk , { [ "mainnet" ] : chain } ) ;
72
72
73
73
const client = wp . getPublicClient ( "mainnet" ) ;
74
- expect ( client . chain . id ) . to . be . equal ( mainnet . id ) ;
75
- expect ( client . chain . rpcUrls . default . http [ 0 ] ) . to . eq (
74
+ expect ( client . chain . id ) . toEqual ( mainnet . id ) ;
75
+ expect ( client . chain . rpcUrls . default . http [ 0 ] ) . toEqual (
76
76
mainnet . rpcUrls . default . http [ 0 ]
77
77
) ;
78
- expect ( client . chain . rpcUrls . custom . http [ 0 ] ) . to . eq (
78
+ expect ( client . chain . rpcUrls . custom . http [ 0 ] ) . toEqual (
79
79
customRpcUrls . mainnet
80
80
) ;
81
81
expect ( client . transport . url ) . toEqual ( customRpcUrls . mainnet ) ;
@@ -86,7 +86,7 @@ describe("Wallet provider", () => {
86
86
87
87
const client = walletProvider . getWalletClient ( "mainnet" ) ;
88
88
89
- expect ( client . account . address ) . to . be . equal ( expectedAddress ) ;
89
+ expect ( client . account . address ) . toEqual ( expectedAddress ) ;
90
90
expect ( client . transport . url ) . toEqual (
91
91
mainnet . rpcUrls . default . http [ 0 ]
92
92
) ;
@@ -102,12 +102,12 @@ describe("Wallet provider", () => {
102
102
103
103
const client = wp . getWalletClient ( "mainnet" ) ;
104
104
105
- expect ( client . account . address ) . to . be . equal ( expectedAddress ) ;
106
- expect ( client . chain . id ) . to . be . equal ( mainnet . id ) ;
107
- expect ( client . chain . rpcUrls . default . http [ 0 ] ) . to . eq (
105
+ expect ( client . account . address ) . toEqual ( expectedAddress ) ;
106
+ expect ( client . chain . id ) . toEqual ( mainnet . id ) ;
107
+ expect ( client . chain . rpcUrls . default . http [ 0 ] ) . toEqual (
108
108
mainnet . rpcUrls . default . http [ 0 ]
109
109
) ;
110
- expect ( client . chain . rpcUrls . custom . http [ 0 ] ) . to . eq (
110
+ expect ( client . chain . rpcUrls . custom . http [ 0 ] ) . toEqual (
111
111
customRpcUrls . mainnet
112
112
) ;
113
113
expect ( client . transport . url ) . toEqual ( customRpcUrls . mainnet ) ;
@@ -120,16 +120,16 @@ describe("Wallet provider", () => {
120
120
it ( "should fetch balance" , async ( ) => {
121
121
const bal = await walletProvider . getWalletBalance ( ) ;
122
122
123
- expect ( bal ) . to . be . eq ( "0" ) ;
123
+ expect ( bal ) . toEqual ( "0" ) ;
124
124
} ) ;
125
125
it ( "should fetch balance for a specific added chain" , async ( ) => {
126
126
const bal = await walletProvider . getWalletBalanceForChain ( "iotex" ) ;
127
127
128
- expect ( bal ) . to . be . eq ( "0" ) ;
128
+ expect ( bal ) . toEqual ( "0" ) ;
129
129
} ) ;
130
130
it ( "should return null if chain is not added" , async ( ) => {
131
131
const bal = await walletProvider . getWalletBalanceForChain ( "base" ) ;
132
- expect ( bal ) . to . be . null ;
132
+ expect ( bal ) . toBeNull ( ) ;
133
133
} ) ;
134
134
} ) ;
135
135
describe ( "Chain" , ( ) => {
@@ -140,7 +140,7 @@ describe("Wallet provider", () => {
140
140
const chainName = "iotex" ;
141
141
const chain : Chain = WalletProvider . genChainFromName ( chainName ) ;
142
142
143
- expect ( chain . rpcUrls . default . http [ 0 ] ) . to . eq (
143
+ expect ( chain . rpcUrls . default . http [ 0 ] ) . toEqual (
144
144
iotex . rpcUrls . default . http [ 0 ]
145
145
) ;
146
146
} ) ;
@@ -152,59 +152,63 @@ describe("Wallet provider", () => {
152
152
customRpcUrl
153
153
) ;
154
154
155
- expect ( chain . rpcUrls . default . http [ 0 ] ) . to . eq (
155
+ expect ( chain . rpcUrls . default . http [ 0 ] ) . toEqual (
156
156
iotex . rpcUrls . default . http [ 0 ]
157
157
) ;
158
- expect ( chain . rpcUrls . custom . http [ 0 ] ) . to . eq ( customRpcUrl ) ;
158
+ expect ( chain . rpcUrls . custom . http [ 0 ] ) . toEqual ( customRpcUrl ) ;
159
159
} ) ;
160
160
it ( "switches chain" , ( ) => {
161
161
const initialChain = walletProvider . getCurrentChain ( ) . id ;
162
- expect ( initialChain ) . to . be . eq ( iotex . id ) ;
162
+ expect ( initialChain ) . toEqual ( iotex . id ) ;
163
163
164
164
walletProvider . switchChain ( "mainnet" ) ;
165
165
166
166
const newChain = walletProvider . getCurrentChain ( ) . id ;
167
- expect ( newChain ) . to . be . eq ( mainnet . id ) ;
167
+ expect ( newChain ) . toEqual ( mainnet . id ) ;
168
168
} ) ;
169
169
it ( "switches chain (by adding new chain)" , ( ) => {
170
170
const initialChain = walletProvider . getCurrentChain ( ) . id ;
171
- expect ( initialChain ) . to . be . eq ( iotex . id ) ;
171
+ expect ( initialChain ) . toEqual ( iotex . id ) ;
172
172
173
173
walletProvider . switchChain ( "arbitrum" ) ;
174
174
175
175
const newChain = walletProvider . getCurrentChain ( ) . id ;
176
- expect ( newChain ) . to . be . eq ( arbitrum . id ) ;
176
+ expect ( newChain ) . toEqual ( arbitrum . id ) ;
177
177
} ) ;
178
178
it ( "adds chain" , ( ) => {
179
179
const initialChains = walletProvider . chains ;
180
- expect ( initialChains . base ) . to . be . undefined ;
180
+ expect ( initialChains . base ) . toBeUndefined ( ) ;
181
181
182
182
const base = WalletProvider . genChainFromName ( "base" ) ;
183
183
walletProvider . addChain ( { base } ) ;
184
184
const newChains = walletProvider . chains ;
185
- expect ( newChains . arbitrum . id ) . to . be . eq ( arbitrum . id ) ;
185
+ expect ( newChains . arbitrum . id ) . toEqual ( arbitrum . id ) ;
186
186
} ) ;
187
187
it ( "gets chain configs" , ( ) => {
188
188
const chain = walletProvider . getChainConfigs ( "iotex" ) ;
189
189
190
- expect ( chain . id ) . to . eq ( iotex . id ) ;
190
+ expect ( chain . id ) . toEqual ( iotex . id ) ;
191
191
} ) ;
192
192
it ( "throws if tries to switch to an invalid chain" , ( ) => {
193
193
const initialChain = walletProvider . getCurrentChain ( ) . id ;
194
- expect ( initialChain ) . to . be . eq ( iotex . id ) ;
194
+ expect ( initialChain ) . toEqual ( iotex . id ) ;
195
195
196
+ // intentionally set incorrect chain, ts will complain
197
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
196
198
// @ts -ignore
197
- expect ( ( ) => walletProvider . switchChain ( "eth" ) ) . to . throw ( ) ;
199
+ expect ( ( ) => walletProvider . switchChain ( "eth" ) ) . toThrow ( ) ;
198
200
} ) ;
199
201
it ( "throws if unsupported chain name" , ( ) => {
202
+ // intentionally set incorrect chain, ts will complain
203
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
200
204
// @ts -ignore
201
- expect ( ( ) =>
202
- WalletProvider . genChainFromName ( "ethereum" )
203
- ) . to . throw ( ) ;
205
+ expect ( ( ) => WalletProvider . genChainFromName ( "ethereum" ) ) . toThrow ( ) ;
204
206
} ) ;
205
207
it ( "throws if invalid chain name" , ( ) => {
208
+ // intentionally set incorrect chain, ts will complain
209
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
206
210
// @ts -ignore
207
- expect ( ( ) => WalletProvider . genChainFromName ( "eth" ) ) . to . throw ( ) ;
211
+ expect ( ( ) => WalletProvider . genChainFromName ( "eth" ) ) . toThrow ( ) ;
208
212
} ) ;
209
213
} ) ;
210
214
} ) ;
0 commit comments