@solana-mobile/wallet-adapter-mobile 0.9.4 → 0.9.5

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/README.md CHANGED
@@ -18,6 +18,7 @@ new SolanaMobileWalletAdapter({
18
18
  },
19
19
  authorizationResultCache: createDefaultAuthorizationResultCache(),
20
20
  cluster: WalletAdapterNetwork.Devnet,
21
+ onWalletNotFound: createDefaultWalletNotFoundHandler(),
21
22
  });
22
23
  ```
23
24
 
@@ -34,6 +35,7 @@ const wallets = useMemo(() => [
34
35
  },
35
36
  authorizationResultCache: createDefaultAuthorizationResultCache(),
36
37
  cluster: WalletAdapterNetwork.Devnet,
38
+ onWalletNotFound: createDefaultWalletNotFoundHandler(),
37
39
  });
38
40
  new PhantomWalletAdapter(),
39
41
  /* ... other wallets ... */
@@ -88,4 +90,10 @@ Alternatively, you can use the included `createDefaultAuthorizationResultCache()
88
90
 
89
91
  ### Cluster
90
92
 
91
- Each authorization a dApp makes with a wallet is tied to a particular Solana cluster. If a dApp wants to change the cluster on which to transact, it must seek an authorization for that cluster.
93
+ Each authorization a dApp makes with a wallet is tied to a particular Solana cluster. If a dApp wants to change the cluster on which to transact, it must seek an authorization for that cluster.
94
+
95
+ ### Wallet-not-found handler
96
+
97
+ When you call `connect()` but no wallet responds within a reasonable amount of time, it is presumed that no compatible wallet is installed. You must supply an `onWalletNotFound` function to handle this case.
98
+
99
+ Alternatively, you can use the included `createDefaultWalletNotFoundHandler()` method to create a function that opens the Solana Mobile ecosystem wallets webpage.
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
5
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
6
7
  var web3_js = require('@solana/web3.js');
7
- var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
8
8
 
9
9
  /*! *****************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -31,13 +31,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
31
31
  });
32
32
  }
33
33
 
34
- function getIsSupported() {
35
- return (typeof window !== 'undefined' &&
36
- window.isSecureContext &&
37
- typeof document !== 'undefined' &&
38
- /android/i.test(navigator.userAgent));
39
- }
40
-
41
34
  function toUint8Array(base64EncodedByteArray) {
42
35
  return new Uint8Array(window
43
36
  .atob(base64EncodedByteArray)
@@ -45,7 +38,14 @@ function toUint8Array(base64EncodedByteArray) {
45
38
  .map((c) => c.charCodeAt(0)));
46
39
  }
47
40
 
48
- const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
41
+ function getIsSupported() {
42
+ return (typeof window !== 'undefined' &&
43
+ window.isSecureContext &&
44
+ typeof document !== 'undefined' &&
45
+ /android/i.test(navigator.userAgent));
46
+ }
47
+
48
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
49
49
  const SIGNATURE_LENGTH_IN_BYTES = 64;
50
50
  function getPublicKeyFromAddress(address) {
51
51
  const publicKeyByteArray = toUint8Array(address);
@@ -58,7 +58,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
58
58
  // FIXME(#244): We can't actually know what versions are supported until we know which wallet we're talking to.
59
59
  ['legacy', 0]);
60
60
  this.name = SolanaMobileWalletAdapterWalletName;
61
- this.url = 'https://solanamobile.com';
61
+ this.url = 'https://solanamobile.com/wallets';
62
62
  this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI4IiB3aWR0aD0iMjgiIHZpZXdCb3g9Ii0zIDAgMjggMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0RDQjhGRiI+PHBhdGggZD0iTTE3LjQgMTcuNEgxNXYyLjRoMi40di0yLjRabTEuMi05LjZoLTIuNHYyLjRoMi40VjcuOFoiLz48cGF0aCBkPSJNMjEuNiAzVjBoLTIuNHYzaC0zLjZWMGgtMi40djNoLTIuNHY2LjZINC41YTIuMSAyLjEgMCAxIDEgMC00LjJoMi43VjNINC41QTQuNSA0LjUgMCAwIDAgMCA3LjVWMjRoMjEuNnYtNi42aC0yLjR2NC4ySDIuNFYxMS41Yy41LjMgMS4yLjQgMS44LjVoNy41QTYuNiA2LjYgMCAwIDAgMjQgOVYzaC0yLjRabTAgNS43YTQuMiA0LjIgMCAxIDEtOC40IDBWNS40aDguNHYzLjNaIi8+PC9nPjwvc3ZnPg==';
63
63
  this._connecting = false;
64
64
  this._readyState = getIsSupported() ? walletAdapterBase.WalletReadyState.Loadable : walletAdapterBase.WalletReadyState.Unsupported;
@@ -66,6 +66,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
66
66
  this._addressSelector = config.addressSelector;
67
67
  this._appIdentity = config.appIdentity;
68
68
  this._cluster = config.cluster;
69
+ this._onWalletNotFound = config.onWalletNotFound;
69
70
  if (this._readyState !== walletAdapterBase.WalletReadyState.Unsupported) {
70
71
  this._authorizationResultCache.get().then((authorizationResult) => {
71
72
  if (authorizationResult) {
@@ -234,7 +235,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
234
235
  return __awaiter(this, void 0, void 0, function* () {
235
236
  const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
236
237
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
237
- return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
238
+ try {
239
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
240
+ }
241
+ catch (e) {
242
+ if (e instanceof Error &&
243
+ e.name === 'SolanaMobileWalletAdapterError' &&
244
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
245
+ yield this._onWalletNotFound(this);
246
+ }
247
+ throw e;
248
+ }
238
249
  });
239
250
  }
240
251
  assertIsAuthorized() {
@@ -433,7 +444,19 @@ function createDefaultAuthorizationResultCache() {
433
444
  };
434
445
  }
435
446
 
447
+ function defaultWalletNotFoundHandler(mobileWalletAdapter) {
448
+ return __awaiter(this, void 0, void 0, function* () {
449
+ if (typeof window !== 'undefined') {
450
+ window.location.assign(mobileWalletAdapter.url);
451
+ }
452
+ });
453
+ }
454
+ function createDefaultWalletNotFoundHandler() {
455
+ return defaultWalletNotFoundHandler;
456
+ }
457
+
436
458
  exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
437
459
  exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
438
460
  exports.createDefaultAddressSelector = createDefaultAddressSelector;
439
461
  exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
462
+ exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
package/lib/cjs/index.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
5
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
6
7
  var web3_js = require('@solana/web3.js');
7
- var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
8
8
 
9
9
  /*! *****************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -31,13 +31,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
31
31
  });
32
32
  }
33
33
 
34
- function getIsSupported() {
35
- return (typeof window !== 'undefined' &&
36
- window.isSecureContext &&
37
- typeof document !== 'undefined' &&
38
- /android/i.test(navigator.userAgent));
39
- }
40
-
41
34
  function toUint8Array(base64EncodedByteArray) {
42
35
  return new Uint8Array(window
43
36
  .atob(base64EncodedByteArray)
@@ -45,7 +38,14 @@ function toUint8Array(base64EncodedByteArray) {
45
38
  .map((c) => c.charCodeAt(0)));
46
39
  }
47
40
 
48
- const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
41
+ function getIsSupported() {
42
+ return (typeof window !== 'undefined' &&
43
+ window.isSecureContext &&
44
+ typeof document !== 'undefined' &&
45
+ /android/i.test(navigator.userAgent));
46
+ }
47
+
48
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
49
49
  const SIGNATURE_LENGTH_IN_BYTES = 64;
50
50
  function getPublicKeyFromAddress(address) {
51
51
  const publicKeyByteArray = toUint8Array(address);
@@ -58,7 +58,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
58
58
  // FIXME(#244): We can't actually know what versions are supported until we know which wallet we're talking to.
59
59
  ['legacy', 0]);
60
60
  this.name = SolanaMobileWalletAdapterWalletName;
61
- this.url = 'https://solanamobile.com';
61
+ this.url = 'https://solanamobile.com/wallets';
62
62
  this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI4IiB3aWR0aD0iMjgiIHZpZXdCb3g9Ii0zIDAgMjggMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0RDQjhGRiI+PHBhdGggZD0iTTE3LjQgMTcuNEgxNXYyLjRoMi40di0yLjRabTEuMi05LjZoLTIuNHYyLjRoMi40VjcuOFoiLz48cGF0aCBkPSJNMjEuNiAzVjBoLTIuNHYzaC0zLjZWMGgtMi40djNoLTIuNHY2LjZINC41YTIuMSAyLjEgMCAxIDEgMC00LjJoMi43VjNINC41QTQuNSA0LjUgMCAwIDAgMCA3LjVWMjRoMjEuNnYtNi42aC0yLjR2NC4ySDIuNFYxMS41Yy41LjMgMS4yLjQgMS44LjVoNy41QTYuNiA2LjYgMCAwIDAgMjQgOVYzaC0yLjRabTAgNS43YTQuMiA0LjIgMCAxIDEtOC40IDBWNS40aDguNHYzLjNaIi8+PC9nPjwvc3ZnPg==';
63
63
  this._connecting = false;
64
64
  this._readyState = getIsSupported() ? walletAdapterBase.WalletReadyState.Loadable : walletAdapterBase.WalletReadyState.Unsupported;
@@ -66,6 +66,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
66
66
  this._addressSelector = config.addressSelector;
67
67
  this._appIdentity = config.appIdentity;
68
68
  this._cluster = config.cluster;
69
+ this._onWalletNotFound = config.onWalletNotFound;
69
70
  if (this._readyState !== walletAdapterBase.WalletReadyState.Unsupported) {
70
71
  this._authorizationResultCache.get().then((authorizationResult) => {
71
72
  if (authorizationResult) {
@@ -234,7 +235,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
234
235
  return __awaiter(this, void 0, void 0, function* () {
235
236
  const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
236
237
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
237
- return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
238
+ try {
239
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
240
+ }
241
+ catch (e) {
242
+ if (e instanceof Error &&
243
+ e.name === 'SolanaMobileWalletAdapterError' &&
244
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
245
+ yield this._onWalletNotFound(this);
246
+ }
247
+ throw e;
248
+ }
238
249
  });
239
250
  }
240
251
  assertIsAuthorized() {
@@ -433,7 +444,19 @@ function createDefaultAuthorizationResultCache() {
433
444
  };
434
445
  }
435
446
 
447
+ function defaultWalletNotFoundHandler(mobileWalletAdapter) {
448
+ return __awaiter(this, void 0, void 0, function* () {
449
+ if (typeof window !== 'undefined') {
450
+ window.location.assign(mobileWalletAdapter.url);
451
+ }
452
+ });
453
+ }
454
+ function createDefaultWalletNotFoundHandler() {
455
+ return defaultWalletNotFoundHandler;
456
+ }
457
+
436
458
  exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
437
459
  exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
438
460
  exports.createDefaultAddressSelector = createDefaultAddressSelector;
439
461
  exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
462
+ exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
@@ -2,11 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
5
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
6
7
  var web3_js = require('@solana/web3.js');
7
- var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
8
- var reactNative = require('react-native');
9
8
  var jsBase64 = require('js-base64');
9
+ var reactNative = require('react-native');
10
10
  var AsyncStorage = require('@react-native-async-storage/async-storage');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -42,7 +42,7 @@ function getIsSupported() {
42
42
  return reactNative.Platform.OS === 'android';
43
43
  }
44
44
 
45
- const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
45
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
46
46
  const SIGNATURE_LENGTH_IN_BYTES = 64;
47
47
  function getPublicKeyFromAddress(address) {
48
48
  const publicKeyByteArray = jsBase64.toUint8Array(address);
@@ -55,7 +55,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
55
55
  // FIXME(#244): We can't actually know what versions are supported until we know which wallet we're talking to.
56
56
  ['legacy', 0]);
57
57
  this.name = SolanaMobileWalletAdapterWalletName;
58
- this.url = 'https://solanamobile.com';
58
+ this.url = 'https://solanamobile.com/wallets';
59
59
  this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI4IiB3aWR0aD0iMjgiIHZpZXdCb3g9Ii0zIDAgMjggMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0RDQjhGRiI+PHBhdGggZD0iTTE3LjQgMTcuNEgxNXYyLjRoMi40di0yLjRabTEuMi05LjZoLTIuNHYyLjRoMi40VjcuOFoiLz48cGF0aCBkPSJNMjEuNiAzVjBoLTIuNHYzaC0zLjZWMGgtMi40djNoLTIuNHY2LjZINC41YTIuMSAyLjEgMCAxIDEgMC00LjJoMi43VjNINC41QTQuNSA0LjUgMCAwIDAgMCA3LjVWMjRoMjEuNnYtNi42aC0yLjR2NC4ySDIuNFYxMS41Yy41LjMgMS4yLjQgMS44LjVoNy41QTYuNiA2LjYgMCAwIDAgMjQgOVYzaC0yLjRabTAgNS43YTQuMiA0LjIgMCAxIDEtOC40IDBWNS40aDguNHYzLjNaIi8+PC9nPjwvc3ZnPg==';
60
60
  this._connecting = false;
61
61
  this._readyState = getIsSupported() ? walletAdapterBase.WalletReadyState.Loadable : walletAdapterBase.WalletReadyState.Unsupported;
@@ -63,6 +63,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
63
63
  this._addressSelector = config.addressSelector;
64
64
  this._appIdentity = config.appIdentity;
65
65
  this._cluster = config.cluster;
66
+ this._onWalletNotFound = config.onWalletNotFound;
66
67
  if (this._readyState !== walletAdapterBase.WalletReadyState.Unsupported) {
67
68
  this._authorizationResultCache.get().then((authorizationResult) => {
68
69
  if (authorizationResult) {
@@ -231,7 +232,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
231
232
  return __awaiter(this, void 0, void 0, function* () {
232
233
  const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
233
234
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
234
- return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
235
+ try {
236
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
237
+ }
238
+ catch (e) {
239
+ if (e instanceof Error &&
240
+ e.name === 'SolanaMobileWalletAdapterError' &&
241
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
242
+ yield this._onWalletNotFound(this);
243
+ }
244
+ throw e;
245
+ }
235
246
  });
236
247
  }
237
248
  assertIsAuthorized() {
@@ -415,7 +426,19 @@ function createDefaultAuthorizationResultCache() {
415
426
  };
416
427
  }
417
428
 
429
+ function defaultWalletNotFoundHandler(mobileWalletAdapter) {
430
+ return __awaiter(this, void 0, void 0, function* () {
431
+ if (typeof window !== 'undefined') {
432
+ window.location.assign(mobileWalletAdapter.url);
433
+ }
434
+ });
435
+ }
436
+ function createDefaultWalletNotFoundHandler() {
437
+ return defaultWalletNotFoundHandler;
438
+ }
439
+
418
440
  exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
419
441
  exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
420
442
  exports.createDefaultAddressSelector = createDefaultAddressSelector;
421
443
  exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
444
+ exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
@@ -1,6 +1,6 @@
1
+ import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
1
2
  import { BaseMessageSignerWalletAdapter, WalletReadyState, WalletPublicKeyError, WalletNotReadyError, WalletConnectionError, WalletDisconnectedError, WalletNotConnectedError, WalletSignTransactionError, WalletSendTransactionError, WalletSignMessageError } from '@solana/wallet-adapter-base';
2
3
  import { PublicKey } from '@solana/web3.js';
3
- import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
@@ -27,13 +27,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
27
27
  });
28
28
  }
29
29
 
30
- function getIsSupported() {
31
- return (typeof window !== 'undefined' &&
32
- window.isSecureContext &&
33
- typeof document !== 'undefined' &&
34
- /android/i.test(navigator.userAgent));
35
- }
36
-
37
30
  function toUint8Array(base64EncodedByteArray) {
38
31
  return new Uint8Array(window
39
32
  .atob(base64EncodedByteArray)
@@ -41,7 +34,14 @@ function toUint8Array(base64EncodedByteArray) {
41
34
  .map((c) => c.charCodeAt(0)));
42
35
  }
43
36
 
44
- const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
37
+ function getIsSupported() {
38
+ return (typeof window !== 'undefined' &&
39
+ window.isSecureContext &&
40
+ typeof document !== 'undefined' &&
41
+ /android/i.test(navigator.userAgent));
42
+ }
43
+
44
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
45
45
  const SIGNATURE_LENGTH_IN_BYTES = 64;
46
46
  function getPublicKeyFromAddress(address) {
47
47
  const publicKeyByteArray = toUint8Array(address);
@@ -54,7 +54,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
54
54
  // FIXME(#244): We can't actually know what versions are supported until we know which wallet we're talking to.
55
55
  ['legacy', 0]);
56
56
  this.name = SolanaMobileWalletAdapterWalletName;
57
- this.url = 'https://solanamobile.com';
57
+ this.url = 'https://solanamobile.com/wallets';
58
58
  this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI4IiB3aWR0aD0iMjgiIHZpZXdCb3g9Ii0zIDAgMjggMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0RDQjhGRiI+PHBhdGggZD0iTTE3LjQgMTcuNEgxNXYyLjRoMi40di0yLjRabTEuMi05LjZoLTIuNHYyLjRoMi40VjcuOFoiLz48cGF0aCBkPSJNMjEuNiAzVjBoLTIuNHYzaC0zLjZWMGgtMi40djNoLTIuNHY2LjZINC41YTIuMSAyLjEgMCAxIDEgMC00LjJoMi43VjNINC41QTQuNSA0LjUgMCAwIDAgMCA3LjVWMjRoMjEuNnYtNi42aC0yLjR2NC4ySDIuNFYxMS41Yy41LjMgMS4yLjQgMS44LjVoNy41QTYuNiA2LjYgMCAwIDAgMjQgOVYzaC0yLjRabTAgNS43YTQuMiA0LjIgMCAxIDEtOC40IDBWNS40aDguNHYzLjNaIi8+PC9nPjwvc3ZnPg==';
59
59
  this._connecting = false;
60
60
  this._readyState = getIsSupported() ? WalletReadyState.Loadable : WalletReadyState.Unsupported;
@@ -62,6 +62,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
62
62
  this._addressSelector = config.addressSelector;
63
63
  this._appIdentity = config.appIdentity;
64
64
  this._cluster = config.cluster;
65
+ this._onWalletNotFound = config.onWalletNotFound;
65
66
  if (this._readyState !== WalletReadyState.Unsupported) {
66
67
  this._authorizationResultCache.get().then((authorizationResult) => {
67
68
  if (authorizationResult) {
@@ -230,7 +231,17 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
230
231
  return __awaiter(this, void 0, void 0, function* () {
231
232
  const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
232
233
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
233
- return yield transact(callback, config);
234
+ try {
235
+ return yield transact(callback, config);
236
+ }
237
+ catch (e) {
238
+ if (e instanceof Error &&
239
+ e.name === 'SolanaMobileWalletAdapterError' &&
240
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
241
+ yield this._onWalletNotFound(this);
242
+ }
243
+ throw e;
244
+ }
234
245
  });
235
246
  }
236
247
  assertIsAuthorized() {
@@ -429,4 +440,15 @@ function createDefaultAuthorizationResultCache() {
429
440
  };
430
441
  }
431
442
 
432
- export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
443
+ function defaultWalletNotFoundHandler(mobileWalletAdapter) {
444
+ return __awaiter(this, void 0, void 0, function* () {
445
+ if (typeof window !== 'undefined') {
446
+ window.location.assign(mobileWalletAdapter.url);
447
+ }
448
+ });
449
+ }
450
+ function createDefaultWalletNotFoundHandler() {
451
+ return defaultWalletNotFoundHandler;
452
+ }
453
+
454
+ export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
package/lib/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
+ import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
1
2
  import { BaseMessageSignerWalletAdapter, WalletReadyState, WalletPublicKeyError, WalletNotReadyError, WalletConnectionError, WalletDisconnectedError, WalletNotConnectedError, WalletSignTransactionError, WalletSendTransactionError, WalletSignMessageError } from '@solana/wallet-adapter-base';
2
3
  import { PublicKey } from '@solana/web3.js';
3
- import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
4
4
 
5
5
  /*! *****************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
@@ -27,13 +27,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
27
27
  });
28
28
  }
29
29
 
30
- function getIsSupported() {
31
- return (typeof window !== 'undefined' &&
32
- window.isSecureContext &&
33
- typeof document !== 'undefined' &&
34
- /android/i.test(navigator.userAgent));
35
- }
36
-
37
30
  function toUint8Array(base64EncodedByteArray) {
38
31
  return new Uint8Array(window
39
32
  .atob(base64EncodedByteArray)
@@ -41,7 +34,14 @@ function toUint8Array(base64EncodedByteArray) {
41
34
  .map((c) => c.charCodeAt(0)));
42
35
  }
43
36
 
44
- const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
37
+ function getIsSupported() {
38
+ return (typeof window !== 'undefined' &&
39
+ window.isSecureContext &&
40
+ typeof document !== 'undefined' &&
41
+ /android/i.test(navigator.userAgent));
42
+ }
43
+
44
+ const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
45
45
  const SIGNATURE_LENGTH_IN_BYTES = 64;
46
46
  function getPublicKeyFromAddress(address) {
47
47
  const publicKeyByteArray = toUint8Array(address);
@@ -54,7 +54,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
54
54
  // FIXME(#244): We can't actually know what versions are supported until we know which wallet we're talking to.
55
55
  ['legacy', 0]);
56
56
  this.name = SolanaMobileWalletAdapterWalletName;
57
- this.url = 'https://solanamobile.com';
57
+ this.url = 'https://solanamobile.com/wallets';
58
58
  this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI4IiB3aWR0aD0iMjgiIHZpZXdCb3g9Ii0zIDAgMjggMjgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0iI0RDQjhGRiI+PHBhdGggZD0iTTE3LjQgMTcuNEgxNXYyLjRoMi40di0yLjRabTEuMi05LjZoLTIuNHYyLjRoMi40VjcuOFoiLz48cGF0aCBkPSJNMjEuNiAzVjBoLTIuNHYzaC0zLjZWMGgtMi40djNoLTIuNHY2LjZINC41YTIuMSAyLjEgMCAxIDEgMC00LjJoMi43VjNINC41QTQuNSA0LjUgMCAwIDAgMCA3LjVWMjRoMjEuNnYtNi42aC0yLjR2NC4ySDIuNFYxMS41Yy41LjMgMS4yLjQgMS44LjVoNy41QTYuNiA2LjYgMCAwIDAgMjQgOVYzaC0yLjRabTAgNS43YTQuMiA0LjIgMCAxIDEtOC40IDBWNS40aDguNHYzLjNaIi8+PC9nPjwvc3ZnPg==';
59
59
  this._connecting = false;
60
60
  this._readyState = getIsSupported() ? WalletReadyState.Loadable : WalletReadyState.Unsupported;
@@ -62,6 +62,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
62
62
  this._addressSelector = config.addressSelector;
63
63
  this._appIdentity = config.appIdentity;
64
64
  this._cluster = config.cluster;
65
+ this._onWalletNotFound = config.onWalletNotFound;
65
66
  if (this._readyState !== WalletReadyState.Unsupported) {
66
67
  this._authorizationResultCache.get().then((authorizationResult) => {
67
68
  if (authorizationResult) {
@@ -230,7 +231,17 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
230
231
  return __awaiter(this, void 0, void 0, function* () {
231
232
  const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
232
233
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
233
- return yield transact(callback, config);
234
+ try {
235
+ return yield transact(callback, config);
236
+ }
237
+ catch (e) {
238
+ if (e instanceof Error &&
239
+ e.name === 'SolanaMobileWalletAdapterError' &&
240
+ e.code === 'ERROR_WALLET_NOT_FOUND') {
241
+ yield this._onWalletNotFound(this);
242
+ }
243
+ throw e;
244
+ }
234
245
  });
235
246
  }
236
247
  assertIsAuthorized() {
@@ -429,4 +440,15 @@ function createDefaultAuthorizationResultCache() {
429
440
  };
430
441
  }
431
442
 
432
- export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
443
+ function defaultWalletNotFoundHandler(mobileWalletAdapter) {
444
+ return __awaiter(this, void 0, void 0, function* () {
445
+ if (typeof window !== 'undefined') {
446
+ window.location.assign(mobileWalletAdapter.url);
447
+ }
448
+ });
449
+ }
450
+ function createDefaultWalletNotFoundHandler() {
451
+ return defaultWalletNotFoundHandler;
452
+ }
453
+
454
+ export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
@@ -22,6 +22,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
22
22
  private _authorizationResultCache;
23
23
  private _connecting;
24
24
  private _cluster;
25
+ private _onWalletNotFound;
25
26
  private _publicKey;
26
27
  private _readyState;
27
28
  private _selectedAddress;
@@ -30,6 +31,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
30
31
  appIdentity: AppIdentity;
31
32
  authorizationResultCache: AuthorizationResultCache;
32
33
  cluster: Cluster;
34
+ onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
33
35
  });
34
36
  get publicKey(): PublicKey | null;
35
37
  get connected(): boolean;
@@ -52,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
52
54
  }
53
55
  declare function createDefaultAddressSelector(): AddressSelector;
54
56
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
55
- export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
57
+ declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
58
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
56
59
  //# sourceMappingURL=index.browser.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/getIsSupported.ts","../../src/base64Utils.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.browser.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/createDefaultWalletNotFoundHandler.ts"],"names":[],"mappings":""}
@@ -22,6 +22,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
22
22
  private _authorizationResultCache;
23
23
  private _connecting;
24
24
  private _cluster;
25
+ private _onWalletNotFound;
25
26
  private _publicKey;
26
27
  private _readyState;
27
28
  private _selectedAddress;
@@ -30,6 +31,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
30
31
  appIdentity: AppIdentity;
31
32
  authorizationResultCache: AuthorizationResultCache;
32
33
  cluster: Cluster;
34
+ onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
33
35
  });
34
36
  get publicKey(): PublicKey | null;
35
37
  get connected(): boolean;
@@ -52,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
52
54
  }
53
55
  declare function createDefaultAddressSelector(): AddressSelector;
54
56
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
55
- export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
57
+ declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
58
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
56
59
  //# sourceMappingURL=index.browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/getIsSupported.ts","../../src/base64Utils.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/createDefaultWalletNotFoundHandler.ts"],"names":[],"mappings":""}
@@ -22,6 +22,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
22
22
  private _authorizationResultCache;
23
23
  private _connecting;
24
24
  private _cluster;
25
+ private _onWalletNotFound;
25
26
  private _publicKey;
26
27
  private _readyState;
27
28
  private _selectedAddress;
@@ -30,6 +31,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
30
31
  appIdentity: AppIdentity;
31
32
  authorizationResultCache: AuthorizationResultCache;
32
33
  cluster: Cluster;
34
+ onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
33
35
  });
34
36
  get publicKey(): PublicKey | null;
35
37
  get connected(): boolean;
@@ -52,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
52
54
  }
53
55
  declare function createDefaultAddressSelector(): AddressSelector;
54
56
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
55
- export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
57
+ declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
58
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
56
59
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/getIsSupported.ts","../../src/base64Utils.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/createDefaultWalletNotFoundHandler.ts"],"names":[],"mappings":""}
@@ -22,6 +22,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
22
22
  private _authorizationResultCache;
23
23
  private _connecting;
24
24
  private _cluster;
25
+ private _onWalletNotFound;
25
26
  private _publicKey;
26
27
  private _readyState;
27
28
  private _selectedAddress;
@@ -30,6 +31,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
30
31
  appIdentity: AppIdentity;
31
32
  authorizationResultCache: AuthorizationResultCache;
32
33
  cluster: Cluster;
34
+ onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
33
35
  });
34
36
  get publicKey(): PublicKey | null;
35
37
  get connected(): boolean;
@@ -52,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
52
54
  }
53
55
  declare function createDefaultAddressSelector(): AddressSelector;
54
56
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
55
- export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
57
+ declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
58
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
56
59
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/getIsSupported.ts","../../src/base64Utils.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/createDefaultWalletNotFoundHandler.ts"],"names":[],"mappings":""}
@@ -22,6 +22,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
22
22
  private _authorizationResultCache;
23
23
  private _connecting;
24
24
  private _cluster;
25
+ private _onWalletNotFound;
25
26
  private _publicKey;
26
27
  private _readyState;
27
28
  private _selectedAddress;
@@ -30,6 +31,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
30
31
  appIdentity: AppIdentity;
31
32
  authorizationResultCache: AuthorizationResultCache;
32
33
  cluster: Cluster;
34
+ onWalletNotFound: (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
33
35
  });
34
36
  get publicKey(): PublicKey | null;
35
37
  get connected(): boolean;
@@ -52,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
52
54
  }
53
55
  declare function createDefaultAddressSelector(): AddressSelector;
54
56
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
55
- export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
57
+ declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
58
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
56
59
  //# sourceMappingURL=index.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/getIsSupported.ts","../../src/base64Utils.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/__forks__/react-native/createDefaultAuthorizationResultCache.ts","../../src/__forks__/react-native/getIsSupported.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.ts","../../src/createDefaultAddressSelector.ts","../../src/createDefaultAuthorizationResultCache.ts","../../src/createDefaultWalletNotFoundHandler.ts","../../src/__forks__/react-native/createDefaultAuthorizationResultCache.ts","../../src/__forks__/react-native/getIsSupported.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solana-mobile/wallet-adapter-mobile",
3
3
  "description": "An adapter for mobile wallet apps that conform to the Solana Mobile Wallet Adapter protocol",
4
- "version": "0.9.4",
4
+ "version": "0.9.5",
5
5
  "author": "Steven Luscher <steven.luscher@solanamobile.com>",
6
6
  "repository": "https://github.com/solana-mobile/mobile-wallet-adapter",
7
7
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@react-native-async-storage/async-storage": "^1.17.7",
44
- "@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^0.9.4",
44
+ "@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^0.9.5",
45
45
  "@solana/wallet-adapter-base": "^0.9.17",
46
46
  "js-base64": "^3.7.2"
47
47
  },
@@ -51,5 +51,5 @@
51
51
  "cross-env": "^7.0.3",
52
52
  "shx": "^0.3.4"
53
53
  },
54
- "gitHead": "83d9987d68083fe62de95a094bea10faa1bce5ea"
54
+ "gitHead": "d3da860526efa336e0bd4c4d680f0f38b1d8f146"
55
55
  }