@@ -111,7 +111,7 @@ export class MultichainAccountAdapter implements MultichainAccount {
111
111
112
112
readonly #providers: AccountProvider [ ] ;
113
113
114
- #accounts: InternalAccount [ ] ;
114
+ readonly #accounts: InternalAccount [ ] ;
115
115
116
116
constructor ( {
117
117
groupIndex,
@@ -127,9 +127,7 @@ export class MultichainAccountAdapter implements MultichainAccount {
127
127
this . #wallet = wallet ;
128
128
this . #providers = providers ;
129
129
this . #accounts = [ ] ;
130
- }
131
130
132
- async init ( ) : Promise < void > {
133
131
let accounts : InternalAccount [ ] = [ ] ;
134
132
135
133
for ( const provider of this . #providers) {
@@ -144,18 +142,6 @@ export class MultichainAccountAdapter implements MultichainAccount {
144
142
this . #accounts = accounts ;
145
143
}
146
144
147
- static async from ( args : {
148
- groupIndex : number ;
149
- wallet : MultichainAccountWallet ;
150
- providers : AccountProvider [ ] ;
151
- } ) : Promise < MultichainAccount > {
152
- const multichainAccount = new MultichainAccountAdapter ( args ) ;
153
-
154
- await multichainAccount . init ( ) ;
155
-
156
- return multichainAccount ;
157
- }
158
-
159
145
get id ( ) : MultichainAccountId {
160
146
return this . #id;
161
147
}
@@ -269,11 +255,8 @@ export class MultichainAccountWalletAdapter implements MultichainAccountWallet {
269
255
this . #id = toMultichainAccountWalletId ( entropySource ) ;
270
256
this . #providers = providers ;
271
257
this . #entropySource = entropySource ;
272
-
273
258
this . #accounts = new Map ( ) ;
274
- }
275
259
276
- async init ( ) : Promise < void > {
277
260
let index = 0 ;
278
261
let hasAccounts = false ;
279
262
@@ -292,7 +275,7 @@ export class MultichainAccountWalletAdapter implements MultichainAccountWallet {
292
275
} ) ;
293
276
294
277
if ( hasAccounts ) {
295
- const multichainAccount = await MultichainAccountAdapter . from ( {
278
+ const multichainAccount = new MultichainAccountAdapter ( {
296
279
groupIndex,
297
280
wallet : this ,
298
281
providers : this . #providers,
@@ -317,10 +300,8 @@ export class MultichainAccountWalletAdapter implements MultichainAccountWallet {
317
300
return Array . from ( this . #accounts. values ( ) ) ; // TODO: Prevent copy here.
318
301
}
319
302
320
- async #createMultichainAccount(
321
- groupIndex : number ,
322
- ) : Promise < MultichainAccount > {
323
- const multichainAccount = await MultichainAccountAdapter . from ( {
303
+ #createMultichainAccount( groupIndex : number ) : MultichainAccount {
304
+ const multichainAccount = new MultichainAccountAdapter ( {
324
305
wallet : this ,
325
306
providers : this . #providers,
326
307
groupIndex,
@@ -357,7 +338,7 @@ export class MultichainAccountWalletAdapter implements MultichainAccountWallet {
357
338
// Re-create and "refresh" the multichain account (we assume all account creations are
358
339
// idempotent, so we should get the same accounts and potentially some new accounts (if
359
340
// some account providers decide to return more of them this time).
360
- return await this . #createMultichainAccount( groupIndex ) ;
341
+ return this . #createMultichainAccount( groupIndex ) ;
361
342
}
362
343
363
344
async createNextMultichainAccount ( ) : Promise < MultichainAccount > {
@@ -404,9 +385,7 @@ export class MultichainAccountWalletAdapter implements MultichainAccountWallet {
404
385
}
405
386
406
387
// We've got all the accounts now, we can create our multichain account.
407
- multichainAccounts . push (
408
- await this . #createMultichainAccount( groupIndex ) ,
409
- ) ;
388
+ multichainAccounts . push ( this . #createMultichainAccount( groupIndex ) ) ;
410
389
411
390
// We have accounts, we need to check the next index.
412
391
groupIndex += 1 ;
0 commit comments