File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
packages/thirdweb/src/wallets/in-app/web/lib Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : patch
3+ ---
4+
5+ Migrates existing sharded ecosystem wallets to enclaves
Original file line number Diff line number Diff line change @@ -28,6 +28,9 @@ export type AuthQuerierTypes = {
2828 storedToken : AuthStoredTokenWithCookieReturnType [ "storedToken" ] ;
2929 recoveryCode ?: string ;
3030 } ;
31+ migrateFromShardToEnclave : {
32+ storedToken : AuthStoredTokenWithCookieReturnType [ "storedToken" ] ;
33+ } ;
3134} ;
3235
3336/**
Original file line number Diff line number Diff line change @@ -85,6 +85,23 @@ export class InAppWebConnector implements InAppConnector {
8585 ecosystem,
8686 onAuthSuccess : async ( authResult ) => {
8787 onAuthSuccess ?.( authResult ) ;
88+
89+ if (
90+ this . ecosystem &&
91+ authResult . storedToken . authDetails . walletType === "sharded"
92+ ) {
93+ // If this is an existing sharded ecosystem wallet, we'll need to migrate
94+ const result = await this . querier . call < boolean > ( {
95+ procedureName : "migrateFromShardToEnclave" ,
96+ params : {
97+ storedToken : authResult . storedToken ,
98+ } ,
99+ } ) ;
100+ if ( ! result ) {
101+ throw new Error ( "Failed to migrate from sharded to enclave wallet" ) ;
102+ }
103+ }
104+
88105 await this . initializeWallet ( authResult . storedToken . cookieString ) ;
89106
90107 if ( ! this . wallet ) {
@@ -148,6 +165,7 @@ export class InAppWebConnector implements InAppConnector {
148165 "Cannot initialize wallet, this user does not have a wallet generated yet" ,
149166 ) ;
150167 }
168+
151169 if ( user . wallets [ 0 ] . type === "enclave" ) {
152170 this . wallet = new EnclaveWallet ( {
153171 client : this . client ,
You can’t perform that action at this time.
0 commit comments