@dubsdotapp/expo 0.2.25 → 0.2.27

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/index.js CHANGED
@@ -599,10 +599,24 @@ var MwaWalletAdapter = class {
599
599
  */
600
600
  async connect() {
601
601
  await this.transact(async (wallet) => {
602
- const authResult = this._authToken ? await wallet.reauthorize({ auth_token: this._authToken }) : await wallet.authorize({
603
- identity: this.config.appIdentity,
604
- cluster: this.config.cluster || "mainnet-beta"
605
- });
602
+ let authResult;
603
+ if (this._authToken) {
604
+ try {
605
+ authResult = await wallet.reauthorize({ auth_token: this._authToken });
606
+ } catch {
607
+ console.log("[Dubs:MWA] reauthorize failed, falling back to authorize");
608
+ this._authToken = null;
609
+ authResult = await wallet.authorize({
610
+ identity: this.config.appIdentity,
611
+ cluster: this.config.cluster || "mainnet-beta"
612
+ });
613
+ }
614
+ } else {
615
+ authResult = await wallet.authorize({
616
+ identity: this.config.appIdentity,
617
+ cluster: this.config.cluster || "mainnet-beta"
618
+ });
619
+ }
606
620
  this._mwaAddress = authResult.accounts[0].address;
607
621
  this._publicKey = toPublicKey(this._mwaAddress);
608
622
  this._authToken = authResult.auth_token;
@@ -634,13 +648,14 @@ var MwaWalletAdapter = class {
634
648
  return signed;
635
649
  }
636
650
  async signMessage(message) {
637
- if (!this._connected || !this._publicKey || !this._mwaAddress) throw new Error("Wallet not connected");
651
+ if (!this._connected || !this._publicKey) throw new Error("Wallet not connected");
638
652
  const sig = await this.transact(async (wallet) => {
639
653
  const reauth = await wallet.reauthorize({ auth_token: this._authToken });
640
654
  this._authToken = reauth.auth_token;
655
+ this._mwaAddress = reauth.accounts[0].address;
641
656
  this.config.onAuthTokenChange?.(this._authToken);
642
657
  const result = await wallet.signMessages({
643
- addresses: [this._mwaAddress],
658
+ addresses: [reauth.accounts[0].address],
644
659
  payloads: [message]
645
660
  });
646
661
  return result[0];