@dubsdotapp/expo 0.2.26 → 0.2.28
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.d.mts +3 -10
- package/dist/index.d.ts +3 -10
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/managed-wallet.tsx +1 -1
- package/src/wallet/mwa-adapter.ts +35 -31
package/dist/index.d.mts
CHANGED
|
@@ -562,16 +562,6 @@ interface MwaAdapterConfig {
|
|
|
562
562
|
/**
|
|
563
563
|
* Mobile Wallet Adapter implementation.
|
|
564
564
|
* Wraps @solana-mobile/mobile-wallet-adapter-protocol-web3js.
|
|
565
|
-
*
|
|
566
|
-
* Usage:
|
|
567
|
-
* ```ts
|
|
568
|
-
* import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
|
|
569
|
-
*
|
|
570
|
-
* const adapter = new MwaWalletAdapter({
|
|
571
|
-
* transact,
|
|
572
|
-
* appIdentity: { name: 'My App' },
|
|
573
|
-
* });
|
|
574
|
-
* ```
|
|
575
565
|
*/
|
|
576
566
|
declare class MwaWalletAdapter implements WalletAdapter {
|
|
577
567
|
private _publicKey;
|
|
@@ -588,6 +578,8 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
588
578
|
setAuthToken(token: string | null): void;
|
|
589
579
|
/**
|
|
590
580
|
* Connect to a mobile wallet. Call this before any signing.
|
|
581
|
+
* Tries reauthorize first (if we have a saved token), then falls back to
|
|
582
|
+
* a fresh authorize in a SEPARATE transact session.
|
|
591
583
|
*/
|
|
592
584
|
connect(): Promise<void>;
|
|
593
585
|
/**
|
|
@@ -597,6 +589,7 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
597
589
|
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
598
590
|
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
599
591
|
signAndSendTransaction(transaction: Transaction): Promise<string>;
|
|
592
|
+
private applyAuthResult;
|
|
600
593
|
}
|
|
601
594
|
|
|
602
595
|
/** Serializable session state — save this to restore without a deeplink round-trip. */
|
package/dist/index.d.ts
CHANGED
|
@@ -562,16 +562,6 @@ interface MwaAdapterConfig {
|
|
|
562
562
|
/**
|
|
563
563
|
* Mobile Wallet Adapter implementation.
|
|
564
564
|
* Wraps @solana-mobile/mobile-wallet-adapter-protocol-web3js.
|
|
565
|
-
*
|
|
566
|
-
* Usage:
|
|
567
|
-
* ```ts
|
|
568
|
-
* import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
|
|
569
|
-
*
|
|
570
|
-
* const adapter = new MwaWalletAdapter({
|
|
571
|
-
* transact,
|
|
572
|
-
* appIdentity: { name: 'My App' },
|
|
573
|
-
* });
|
|
574
|
-
* ```
|
|
575
565
|
*/
|
|
576
566
|
declare class MwaWalletAdapter implements WalletAdapter {
|
|
577
567
|
private _publicKey;
|
|
@@ -588,6 +578,8 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
588
578
|
setAuthToken(token: string | null): void;
|
|
589
579
|
/**
|
|
590
580
|
* Connect to a mobile wallet. Call this before any signing.
|
|
581
|
+
* Tries reauthorize first (if we have a saved token), then falls back to
|
|
582
|
+
* a fresh authorize in a SEPARATE transact session.
|
|
591
583
|
*/
|
|
592
584
|
connect(): Promise<void>;
|
|
593
585
|
/**
|
|
@@ -597,6 +589,7 @@ declare class MwaWalletAdapter implements WalletAdapter {
|
|
|
597
589
|
signTransaction(transaction: Transaction): Promise<Transaction>;
|
|
598
590
|
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
599
591
|
signAndSendTransaction(transaction: Transaction): Promise<string>;
|
|
592
|
+
private applyAuthResult;
|
|
600
593
|
}
|
|
601
594
|
|
|
602
595
|
/** Serializable session state — save this to restore without a deeplink round-trip. */
|
package/dist/index.js
CHANGED
|
@@ -596,18 +596,29 @@ var MwaWalletAdapter = class {
|
|
|
596
596
|
}
|
|
597
597
|
/**
|
|
598
598
|
* Connect to a mobile wallet. Call this before any signing.
|
|
599
|
+
* Tries reauthorize first (if we have a saved token), then falls back to
|
|
600
|
+
* a fresh authorize in a SEPARATE transact session.
|
|
599
601
|
*/
|
|
600
602
|
async connect() {
|
|
603
|
+
if (this._authToken) {
|
|
604
|
+
try {
|
|
605
|
+
await this.transact(async (wallet) => {
|
|
606
|
+
const authResult = await wallet.reauthorize({ auth_token: this._authToken });
|
|
607
|
+
this.applyAuthResult(authResult);
|
|
608
|
+
});
|
|
609
|
+
return;
|
|
610
|
+
} catch {
|
|
611
|
+
console.log("[Dubs:MWA] reauthorize failed, clearing token and doing fresh authorize");
|
|
612
|
+
this._authToken = null;
|
|
613
|
+
this.config.onAuthTokenChange?.(null);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
601
616
|
await this.transact(async (wallet) => {
|
|
602
|
-
const authResult =
|
|
617
|
+
const authResult = await wallet.authorize({
|
|
603
618
|
identity: this.config.appIdentity,
|
|
604
619
|
cluster: this.config.cluster || "mainnet-beta"
|
|
605
620
|
});
|
|
606
|
-
this.
|
|
607
|
-
this._publicKey = toPublicKey(this._mwaAddress);
|
|
608
|
-
this._authToken = authResult.auth_token;
|
|
609
|
-
this._connected = true;
|
|
610
|
-
this.config.onAuthTokenChange?.(this._authToken);
|
|
621
|
+
this.applyAuthResult(authResult);
|
|
611
622
|
});
|
|
612
623
|
}
|
|
613
624
|
/**
|
|
@@ -624,8 +635,7 @@ var MwaWalletAdapter = class {
|
|
|
624
635
|
if (!this._connected) throw new Error("Wallet not connected");
|
|
625
636
|
const signed = await this.transact(async (wallet) => {
|
|
626
637
|
const reauth = await wallet.reauthorize({ auth_token: this._authToken });
|
|
627
|
-
this.
|
|
628
|
-
this.config.onAuthTokenChange?.(this._authToken);
|
|
638
|
+
this.applyAuthResult(reauth);
|
|
629
639
|
const result = await wallet.signTransactions({
|
|
630
640
|
transactions: [transaction]
|
|
631
641
|
});
|
|
@@ -637,9 +647,7 @@ var MwaWalletAdapter = class {
|
|
|
637
647
|
if (!this._connected || !this._publicKey) throw new Error("Wallet not connected");
|
|
638
648
|
const sig = await this.transact(async (wallet) => {
|
|
639
649
|
const reauth = await wallet.reauthorize({ auth_token: this._authToken });
|
|
640
|
-
this.
|
|
641
|
-
this._mwaAddress = reauth.accounts[0].address;
|
|
642
|
-
this.config.onAuthTokenChange?.(this._authToken);
|
|
650
|
+
this.applyAuthResult(reauth);
|
|
643
651
|
const result = await wallet.signMessages({
|
|
644
652
|
addresses: [reauth.accounts[0].address],
|
|
645
653
|
payloads: [message]
|
|
@@ -652,8 +660,7 @@ var MwaWalletAdapter = class {
|
|
|
652
660
|
if (!this._connected) throw new Error("Wallet not connected");
|
|
653
661
|
const signature = await this.transact(async (wallet) => {
|
|
654
662
|
const reauth = await wallet.reauthorize({ auth_token: this._authToken });
|
|
655
|
-
this.
|
|
656
|
-
this.config.onAuthTokenChange?.(this._authToken);
|
|
663
|
+
this.applyAuthResult(reauth);
|
|
657
664
|
const result = await wallet.signAndSendTransactions({
|
|
658
665
|
transactions: [transaction]
|
|
659
666
|
});
|
|
@@ -664,6 +671,13 @@ var MwaWalletAdapter = class {
|
|
|
664
671
|
}
|
|
665
672
|
return String(signature);
|
|
666
673
|
}
|
|
674
|
+
applyAuthResult(authResult) {
|
|
675
|
+
this._mwaAddress = authResult.accounts[0].address;
|
|
676
|
+
this._publicKey = toPublicKey(this._mwaAddress);
|
|
677
|
+
this._authToken = authResult.auth_token;
|
|
678
|
+
this._connected = true;
|
|
679
|
+
this.config.onAuthTokenChange?.(this._authToken);
|
|
680
|
+
}
|
|
667
681
|
};
|
|
668
682
|
|
|
669
683
|
// src/wallet/phantom-deeplink/phantom-deeplink-adapter.ts
|
|
@@ -1365,7 +1379,7 @@ function ManagedWalletProvider({
|
|
|
1365
1379
|
}
|
|
1366
1380
|
return transactRef.current(...args);
|
|
1367
1381
|
},
|
|
1368
|
-
appIdentity: { name: appName },
|
|
1382
|
+
appIdentity: { name: appName, uri: appUrl },
|
|
1369
1383
|
cluster,
|
|
1370
1384
|
onAuthTokenChange: (token) => {
|
|
1371
1385
|
if (token) {
|