@solana-mobile/wallet-adapter-mobile 0.9.3 → 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 +9 -1
- package/lib/cjs/index.browser.js +77 -20
- package/lib/cjs/index.js +77 -20
- package/lib/cjs/index.native.js +77 -20
- package/lib/esm/index.browser.mjs +77 -21
- package/lib/esm/index.mjs +77 -21
- package/lib/types/index.browser.d.mts +6 -1
- package/lib/types/index.browser.d.mts.map +1 -1
- package/lib/types/index.browser.d.ts +6 -1
- package/lib/types/index.browser.d.ts.map +1 -1
- package/lib/types/index.d.mts +6 -1
- package/lib/types/index.d.mts.map +1 -1
- package/lib/types/index.d.ts +6 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.native.d.ts +6 -1
- package/lib/types/index.native.d.ts.map +1 -1
- package/package.json +3 -3
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.
|
package/lib/cjs/index.browser.js
CHANGED
|
@@ -45,7 +45,7 @@ function getIsSupported() {
|
|
|
45
45
|
/android/i.test(navigator.userAgent));
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const SolanaMobileWalletAdapterWalletName = '
|
|
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,13 +66,14 @@ 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) {
|
|
72
73
|
// Having a prior authorization result is, right now, the best
|
|
73
74
|
// indication that a mobile wallet is installed. There is no API
|
|
74
75
|
// we can use to test for whether the association URI is supported.
|
|
75
|
-
this.
|
|
76
|
+
this.declareWalletAsInstalled();
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
}
|
|
@@ -97,6 +98,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
97
98
|
get readyState() {
|
|
98
99
|
return this._readyState;
|
|
99
100
|
}
|
|
101
|
+
declareWalletAsInstalled() {
|
|
102
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
|
|
103
|
+
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
100
106
|
runWithGuard(callback) {
|
|
101
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
108
|
try {
|
|
@@ -108,34 +114,59 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
108
114
|
}
|
|
109
115
|
});
|
|
110
116
|
}
|
|
111
|
-
|
|
117
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
112
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
if (this.connecting || this.connected) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
113
122
|
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
114
123
|
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
115
124
|
throw new walletAdapterBase.WalletNotReadyError();
|
|
116
125
|
}
|
|
117
126
|
this._connecting = true;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
127
|
+
try {
|
|
128
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
129
|
+
if (cachedAuthorizationResult) {
|
|
130
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
131
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
124
132
|
}
|
|
125
|
-
this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
|
|
126
|
-
this.emit('connect',
|
|
127
|
-
// Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
|
-
this.publicKey);
|
|
130
|
-
return;
|
|
131
133
|
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this._connecting = false;
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
connect() {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (this.connecting || this.connected) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
150
|
+
throw new walletAdapterBase.WalletNotReadyError();
|
|
151
|
+
}
|
|
152
|
+
this._connecting = true;
|
|
132
153
|
try {
|
|
154
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
155
|
+
if (cachedAuthorizationResult) {
|
|
156
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
157
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
133
160
|
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
134
161
|
const authorizationResult = yield wallet.authorize({
|
|
135
162
|
cluster: this._cluster,
|
|
136
163
|
identity: this._appIdentity,
|
|
137
164
|
});
|
|
138
|
-
|
|
165
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
166
|
+
Promise.all([
|
|
167
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
168
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
169
|
+
]);
|
|
139
170
|
}));
|
|
140
171
|
}
|
|
141
172
|
catch (e) {
|
|
@@ -158,6 +189,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
158
189
|
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
159
190
|
this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
|
|
160
191
|
this._authorizationResult = authorizationResult;
|
|
192
|
+
this.declareWalletAsInstalled();
|
|
161
193
|
if (didPublicKeysChange) {
|
|
162
194
|
const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
|
|
163
195
|
if (nextSelectedAddress !== this._selectedAddress) {
|
|
@@ -169,7 +201,6 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
169
201
|
this.publicKey);
|
|
170
202
|
}
|
|
171
203
|
}
|
|
172
|
-
yield this._authorizationResultCache.set(authorizationResult);
|
|
173
204
|
});
|
|
174
205
|
}
|
|
175
206
|
performReauthorization(wallet, authToken) {
|
|
@@ -178,7 +209,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
178
209
|
const authorizationResult = yield wallet.reauthorize({
|
|
179
210
|
auth_token: authToken,
|
|
180
211
|
});
|
|
181
|
-
|
|
212
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
213
|
+
Promise.all([
|
|
214
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
215
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
216
|
+
]);
|
|
182
217
|
}
|
|
183
218
|
catch (e) {
|
|
184
219
|
this.disconnect();
|
|
@@ -200,7 +235,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
200
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
236
|
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
202
237
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
203
|
-
|
|
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
|
+
}
|
|
204
249
|
});
|
|
205
250
|
}
|
|
206
251
|
assertIsAuthorized() {
|
|
@@ -399,7 +444,19 @@ function createDefaultAuthorizationResultCache() {
|
|
|
399
444
|
};
|
|
400
445
|
}
|
|
401
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
|
+
|
|
402
458
|
exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
|
|
403
459
|
exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
|
|
404
460
|
exports.createDefaultAddressSelector = createDefaultAddressSelector;
|
|
405
461
|
exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
|
|
462
|
+
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
package/lib/cjs/index.js
CHANGED
|
@@ -45,7 +45,7 @@ function getIsSupported() {
|
|
|
45
45
|
/android/i.test(navigator.userAgent));
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
const SolanaMobileWalletAdapterWalletName = '
|
|
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,13 +66,14 @@ 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) {
|
|
72
73
|
// Having a prior authorization result is, right now, the best
|
|
73
74
|
// indication that a mobile wallet is installed. There is no API
|
|
74
75
|
// we can use to test for whether the association URI is supported.
|
|
75
|
-
this.
|
|
76
|
+
this.declareWalletAsInstalled();
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
}
|
|
@@ -97,6 +98,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
97
98
|
get readyState() {
|
|
98
99
|
return this._readyState;
|
|
99
100
|
}
|
|
101
|
+
declareWalletAsInstalled() {
|
|
102
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
|
|
103
|
+
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
104
|
+
}
|
|
105
|
+
}
|
|
100
106
|
runWithGuard(callback) {
|
|
101
107
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
108
|
try {
|
|
@@ -108,34 +114,59 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
108
114
|
}
|
|
109
115
|
});
|
|
110
116
|
}
|
|
111
|
-
|
|
117
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
112
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
if (this.connecting || this.connected) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
113
122
|
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
114
123
|
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
115
124
|
throw new walletAdapterBase.WalletNotReadyError();
|
|
116
125
|
}
|
|
117
126
|
this._connecting = true;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
127
|
+
try {
|
|
128
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
129
|
+
if (cachedAuthorizationResult) {
|
|
130
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
131
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
124
132
|
}
|
|
125
|
-
this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
|
|
126
|
-
this.emit('connect',
|
|
127
|
-
// Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
|
-
this.publicKey);
|
|
130
|
-
return;
|
|
131
133
|
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this._connecting = false;
|
|
139
|
+
}
|
|
140
|
+
}));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
connect() {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (this.connecting || this.connected) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
150
|
+
throw new walletAdapterBase.WalletNotReadyError();
|
|
151
|
+
}
|
|
152
|
+
this._connecting = true;
|
|
132
153
|
try {
|
|
154
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
155
|
+
if (cachedAuthorizationResult) {
|
|
156
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
157
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
133
160
|
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
134
161
|
const authorizationResult = yield wallet.authorize({
|
|
135
162
|
cluster: this._cluster,
|
|
136
163
|
identity: this._appIdentity,
|
|
137
164
|
});
|
|
138
|
-
|
|
165
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
166
|
+
Promise.all([
|
|
167
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
168
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
169
|
+
]);
|
|
139
170
|
}));
|
|
140
171
|
}
|
|
141
172
|
catch (e) {
|
|
@@ -158,6 +189,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
158
189
|
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
159
190
|
this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
|
|
160
191
|
this._authorizationResult = authorizationResult;
|
|
192
|
+
this.declareWalletAsInstalled();
|
|
161
193
|
if (didPublicKeysChange) {
|
|
162
194
|
const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
|
|
163
195
|
if (nextSelectedAddress !== this._selectedAddress) {
|
|
@@ -169,7 +201,6 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
169
201
|
this.publicKey);
|
|
170
202
|
}
|
|
171
203
|
}
|
|
172
|
-
yield this._authorizationResultCache.set(authorizationResult);
|
|
173
204
|
});
|
|
174
205
|
}
|
|
175
206
|
performReauthorization(wallet, authToken) {
|
|
@@ -178,7 +209,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
178
209
|
const authorizationResult = yield wallet.reauthorize({
|
|
179
210
|
auth_token: authToken,
|
|
180
211
|
});
|
|
181
|
-
|
|
212
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
213
|
+
Promise.all([
|
|
214
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
215
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
216
|
+
]);
|
|
182
217
|
}
|
|
183
218
|
catch (e) {
|
|
184
219
|
this.disconnect();
|
|
@@ -200,7 +235,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
200
235
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
236
|
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
202
237
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
203
|
-
|
|
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
|
+
}
|
|
204
249
|
});
|
|
205
250
|
}
|
|
206
251
|
assertIsAuthorized() {
|
|
@@ -399,7 +444,19 @@ function createDefaultAuthorizationResultCache() {
|
|
|
399
444
|
};
|
|
400
445
|
}
|
|
401
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
|
+
|
|
402
458
|
exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
|
|
403
459
|
exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
|
|
404
460
|
exports.createDefaultAddressSelector = createDefaultAddressSelector;
|
|
405
461
|
exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
|
|
462
|
+
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -42,7 +42,7 @@ function getIsSupported() {
|
|
|
42
42
|
return reactNative.Platform.OS === 'android';
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const SolanaMobileWalletAdapterWalletName = '
|
|
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,13 +63,14 @@ 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) {
|
|
69
70
|
// Having a prior authorization result is, right now, the best
|
|
70
71
|
// indication that a mobile wallet is installed. There is no API
|
|
71
72
|
// we can use to test for whether the association URI is supported.
|
|
72
|
-
this.
|
|
73
|
+
this.declareWalletAsInstalled();
|
|
73
74
|
}
|
|
74
75
|
});
|
|
75
76
|
}
|
|
@@ -94,6 +95,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
94
95
|
get readyState() {
|
|
95
96
|
return this._readyState;
|
|
96
97
|
}
|
|
98
|
+
declareWalletAsInstalled() {
|
|
99
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
|
|
100
|
+
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
97
103
|
runWithGuard(callback) {
|
|
98
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
105
|
try {
|
|
@@ -105,34 +111,59 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
105
111
|
}
|
|
106
112
|
});
|
|
107
113
|
}
|
|
108
|
-
|
|
114
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
109
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
if (this.connecting || this.connected) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
110
119
|
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
111
120
|
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
112
121
|
throw new walletAdapterBase.WalletNotReadyError();
|
|
113
122
|
}
|
|
114
123
|
this._connecting = true;
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
|
|
124
|
+
try {
|
|
125
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
126
|
+
if (cachedAuthorizationResult) {
|
|
127
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
128
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
121
129
|
}
|
|
122
|
-
this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
|
|
123
|
-
this.emit('connect',
|
|
124
|
-
// Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
|
|
125
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
126
|
-
this.publicKey);
|
|
127
|
-
return;
|
|
128
130
|
}
|
|
131
|
+
catch (e) {
|
|
132
|
+
throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
this._connecting = false;
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
connect() {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
+
if (this.connecting || this.connected) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
147
|
+
throw new walletAdapterBase.WalletNotReadyError();
|
|
148
|
+
}
|
|
149
|
+
this._connecting = true;
|
|
129
150
|
try {
|
|
151
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
152
|
+
if (cachedAuthorizationResult) {
|
|
153
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
154
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
130
157
|
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
131
158
|
const authorizationResult = yield wallet.authorize({
|
|
132
159
|
cluster: this._cluster,
|
|
133
160
|
identity: this._appIdentity,
|
|
134
161
|
});
|
|
135
|
-
|
|
162
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
163
|
+
Promise.all([
|
|
164
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
165
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
166
|
+
]);
|
|
136
167
|
}));
|
|
137
168
|
}
|
|
138
169
|
catch (e) {
|
|
@@ -155,6 +186,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
155
186
|
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
156
187
|
this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
|
|
157
188
|
this._authorizationResult = authorizationResult;
|
|
189
|
+
this.declareWalletAsInstalled();
|
|
158
190
|
if (didPublicKeysChange) {
|
|
159
191
|
const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
|
|
160
192
|
if (nextSelectedAddress !== this._selectedAddress) {
|
|
@@ -166,7 +198,6 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
166
198
|
this.publicKey);
|
|
167
199
|
}
|
|
168
200
|
}
|
|
169
|
-
yield this._authorizationResultCache.set(authorizationResult);
|
|
170
201
|
});
|
|
171
202
|
}
|
|
172
203
|
performReauthorization(wallet, authToken) {
|
|
@@ -175,7 +206,11 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
175
206
|
const authorizationResult = yield wallet.reauthorize({
|
|
176
207
|
auth_token: authToken,
|
|
177
208
|
});
|
|
178
|
-
|
|
209
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
210
|
+
Promise.all([
|
|
211
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
212
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
213
|
+
]);
|
|
179
214
|
}
|
|
180
215
|
catch (e) {
|
|
181
216
|
this.disconnect();
|
|
@@ -197,7 +232,17 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
|
|
|
197
232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
198
233
|
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
199
234
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
200
|
-
|
|
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
|
+
}
|
|
201
246
|
});
|
|
202
247
|
}
|
|
203
248
|
assertIsAuthorized() {
|
|
@@ -381,7 +426,19 @@ function createDefaultAuthorizationResultCache() {
|
|
|
381
426
|
};
|
|
382
427
|
}
|
|
383
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
|
+
|
|
384
440
|
exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
|
|
385
441
|
exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletName;
|
|
386
442
|
exports.createDefaultAddressSelector = createDefaultAddressSelector;
|
|
387
443
|
exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
|
|
444
|
+
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
|
@@ -41,7 +41,7 @@ function getIsSupported() {
|
|
|
41
41
|
/android/i.test(navigator.userAgent));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const SolanaMobileWalletAdapterWalletName = '
|
|
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,13 +62,14 @@ 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) {
|
|
68
69
|
// Having a prior authorization result is, right now, the best
|
|
69
70
|
// indication that a mobile wallet is installed. There is no API
|
|
70
71
|
// we can use to test for whether the association URI is supported.
|
|
71
|
-
this.
|
|
72
|
+
this.declareWalletAsInstalled();
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
}
|
|
@@ -93,6 +94,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
93
94
|
get readyState() {
|
|
94
95
|
return this._readyState;
|
|
95
96
|
}
|
|
97
|
+
declareWalletAsInstalled() {
|
|
98
|
+
if (this._readyState !== WalletReadyState.Installed) {
|
|
99
|
+
this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
96
102
|
runWithGuard(callback) {
|
|
97
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
104
|
try {
|
|
@@ -104,34 +110,59 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
104
110
|
}
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
|
|
113
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
108
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (this.connecting || this.connected) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
109
118
|
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
110
119
|
if (this._readyState !== WalletReadyState.Installed && this._readyState !== WalletReadyState.Loadable) {
|
|
111
120
|
throw new WalletNotReadyError();
|
|
112
121
|
}
|
|
113
122
|
this._connecting = true;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
|
|
123
|
+
try {
|
|
124
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
125
|
+
if (cachedAuthorizationResult) {
|
|
126
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
127
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
120
128
|
}
|
|
121
|
-
this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
|
|
122
|
-
this.emit('connect',
|
|
123
|
-
// Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
|
-
this.publicKey);
|
|
126
|
-
return;
|
|
127
129
|
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
throw new WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this._connecting = false;
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
connect() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
if (this.connecting || this.connected) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (this._readyState !== WalletReadyState.Installed && this._readyState !== WalletReadyState.Loadable) {
|
|
146
|
+
throw new WalletNotReadyError();
|
|
147
|
+
}
|
|
148
|
+
this._connecting = true;
|
|
128
149
|
try {
|
|
150
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
151
|
+
if (cachedAuthorizationResult) {
|
|
152
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
153
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
129
156
|
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
130
157
|
const authorizationResult = yield wallet.authorize({
|
|
131
158
|
cluster: this._cluster,
|
|
132
159
|
identity: this._appIdentity,
|
|
133
160
|
});
|
|
134
|
-
|
|
161
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
162
|
+
Promise.all([
|
|
163
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
164
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
165
|
+
]);
|
|
135
166
|
}));
|
|
136
167
|
}
|
|
137
168
|
catch (e) {
|
|
@@ -154,6 +185,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
154
185
|
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
155
186
|
this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
|
|
156
187
|
this._authorizationResult = authorizationResult;
|
|
188
|
+
this.declareWalletAsInstalled();
|
|
157
189
|
if (didPublicKeysChange) {
|
|
158
190
|
const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
|
|
159
191
|
if (nextSelectedAddress !== this._selectedAddress) {
|
|
@@ -165,7 +197,6 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
165
197
|
this.publicKey);
|
|
166
198
|
}
|
|
167
199
|
}
|
|
168
|
-
yield this._authorizationResultCache.set(authorizationResult);
|
|
169
200
|
});
|
|
170
201
|
}
|
|
171
202
|
performReauthorization(wallet, authToken) {
|
|
@@ -174,7 +205,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
174
205
|
const authorizationResult = yield wallet.reauthorize({
|
|
175
206
|
auth_token: authToken,
|
|
176
207
|
});
|
|
177
|
-
|
|
208
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
209
|
+
Promise.all([
|
|
210
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
211
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
212
|
+
]);
|
|
178
213
|
}
|
|
179
214
|
catch (e) {
|
|
180
215
|
this.disconnect();
|
|
@@ -196,7 +231,17 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
196
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
232
|
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
198
233
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
199
|
-
|
|
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
|
+
}
|
|
200
245
|
});
|
|
201
246
|
}
|
|
202
247
|
assertIsAuthorized() {
|
|
@@ -395,4 +440,15 @@ function createDefaultAuthorizationResultCache() {
|
|
|
395
440
|
};
|
|
396
441
|
}
|
|
397
442
|
|
|
398
|
-
|
|
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
|
@@ -41,7 +41,7 @@ function getIsSupported() {
|
|
|
41
41
|
/android/i.test(navigator.userAgent));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const SolanaMobileWalletAdapterWalletName = '
|
|
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,13 +62,14 @@ 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) {
|
|
68
69
|
// Having a prior authorization result is, right now, the best
|
|
69
70
|
// indication that a mobile wallet is installed. There is no API
|
|
70
71
|
// we can use to test for whether the association URI is supported.
|
|
71
|
-
this.
|
|
72
|
+
this.declareWalletAsInstalled();
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
}
|
|
@@ -93,6 +94,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
93
94
|
get readyState() {
|
|
94
95
|
return this._readyState;
|
|
95
96
|
}
|
|
97
|
+
declareWalletAsInstalled() {
|
|
98
|
+
if (this._readyState !== WalletReadyState.Installed) {
|
|
99
|
+
this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
|
|
100
|
+
}
|
|
101
|
+
}
|
|
96
102
|
runWithGuard(callback) {
|
|
97
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
98
104
|
try {
|
|
@@ -104,34 +110,59 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
104
110
|
}
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
|
-
|
|
113
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
108
114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (this.connecting || this.connected) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
109
118
|
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
110
119
|
if (this._readyState !== WalletReadyState.Installed && this._readyState !== WalletReadyState.Loadable) {
|
|
111
120
|
throw new WalletNotReadyError();
|
|
112
121
|
}
|
|
113
122
|
this._connecting = true;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
|
|
123
|
+
try {
|
|
124
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
125
|
+
if (cachedAuthorizationResult) {
|
|
126
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
127
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
120
128
|
}
|
|
121
|
-
this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
|
|
122
|
-
this.emit('connect',
|
|
123
|
-
// Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
|
-
this.publicKey);
|
|
126
|
-
return;
|
|
127
129
|
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
throw new WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
this._connecting = false;
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
connect() {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
if (this.connecting || this.connected) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
if (this._readyState !== WalletReadyState.Installed && this._readyState !== WalletReadyState.Loadable) {
|
|
146
|
+
throw new WalletNotReadyError();
|
|
147
|
+
}
|
|
148
|
+
this._connecting = true;
|
|
128
149
|
try {
|
|
150
|
+
const cachedAuthorizationResult = yield this._authorizationResultCache.get();
|
|
151
|
+
if (cachedAuthorizationResult) {
|
|
152
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
153
|
+
this.handleAuthorizationResult(cachedAuthorizationResult);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
129
156
|
yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
130
157
|
const authorizationResult = yield wallet.authorize({
|
|
131
158
|
cluster: this._cluster,
|
|
132
159
|
identity: this._appIdentity,
|
|
133
160
|
});
|
|
134
|
-
|
|
161
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
162
|
+
Promise.all([
|
|
163
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
164
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
165
|
+
]);
|
|
135
166
|
}));
|
|
136
167
|
}
|
|
137
168
|
catch (e) {
|
|
@@ -154,6 +185,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
154
185
|
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
155
186
|
this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
|
|
156
187
|
this._authorizationResult = authorizationResult;
|
|
188
|
+
this.declareWalletAsInstalled();
|
|
157
189
|
if (didPublicKeysChange) {
|
|
158
190
|
const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
|
|
159
191
|
if (nextSelectedAddress !== this._selectedAddress) {
|
|
@@ -165,7 +197,6 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
165
197
|
this.publicKey);
|
|
166
198
|
}
|
|
167
199
|
}
|
|
168
|
-
yield this._authorizationResultCache.set(authorizationResult);
|
|
169
200
|
});
|
|
170
201
|
}
|
|
171
202
|
performReauthorization(wallet, authToken) {
|
|
@@ -174,7 +205,11 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
174
205
|
const authorizationResult = yield wallet.reauthorize({
|
|
175
206
|
auth_token: authToken,
|
|
176
207
|
});
|
|
177
|
-
|
|
208
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
209
|
+
Promise.all([
|
|
210
|
+
this._authorizationResultCache.set(authorizationResult),
|
|
211
|
+
this.handleAuthorizationResult(authorizationResult),
|
|
212
|
+
]);
|
|
178
213
|
}
|
|
179
214
|
catch (e) {
|
|
180
215
|
this.disconnect();
|
|
@@ -196,7 +231,17 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
196
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
232
|
const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
|
|
198
233
|
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
199
|
-
|
|
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
|
+
}
|
|
200
245
|
});
|
|
201
246
|
}
|
|
202
247
|
assertIsAuthorized() {
|
|
@@ -395,4 +440,15 @@ function createDefaultAuthorizationResultCache() {
|
|
|
395
440
|
};
|
|
396
441
|
}
|
|
397
442
|
|
|
398
|
-
|
|
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,12 +31,15 @@ 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;
|
|
36
38
|
get connecting(): boolean;
|
|
37
39
|
get readyState(): WalletReadyState;
|
|
40
|
+
private declareWalletAsInstalled;
|
|
38
41
|
private runWithGuard;
|
|
42
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(): Promise<void>;
|
|
39
43
|
connect(): Promise<void>;
|
|
40
44
|
private handleAuthorizationResult;
|
|
41
45
|
private performReauthorization;
|
|
@@ -50,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
50
54
|
}
|
|
51
55
|
declare function createDefaultAddressSelector(): AddressSelector;
|
|
52
56
|
declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
|
|
53
|
-
|
|
57
|
+
declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
|
|
58
|
+
export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
|
|
54
59
|
//# sourceMappingURL=index.browser.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
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"],"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,12 +31,15 @@ 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;
|
|
36
38
|
get connecting(): boolean;
|
|
37
39
|
get readyState(): WalletReadyState;
|
|
40
|
+
private declareWalletAsInstalled;
|
|
38
41
|
private runWithGuard;
|
|
42
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(): Promise<void>;
|
|
39
43
|
connect(): Promise<void>;
|
|
40
44
|
private handleAuthorizationResult;
|
|
41
45
|
private performReauthorization;
|
|
@@ -50,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
50
54
|
}
|
|
51
55
|
declare function createDefaultAddressSelector(): AddressSelector;
|
|
52
56
|
declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
|
|
53
|
-
|
|
57
|
+
declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
|
|
58
|
+
export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
|
|
54
59
|
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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"],"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":""}
|
package/lib/types/index.d.mts
CHANGED
|
@@ -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,12 +31,15 @@ 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;
|
|
36
38
|
get connecting(): boolean;
|
|
37
39
|
get readyState(): WalletReadyState;
|
|
40
|
+
private declareWalletAsInstalled;
|
|
38
41
|
private runWithGuard;
|
|
42
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(): Promise<void>;
|
|
39
43
|
connect(): Promise<void>;
|
|
40
44
|
private handleAuthorizationResult;
|
|
41
45
|
private performReauthorization;
|
|
@@ -50,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
50
54
|
}
|
|
51
55
|
declare function createDefaultAddressSelector(): AddressSelector;
|
|
52
56
|
declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
|
|
53
|
-
|
|
57
|
+
declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
|
|
58
|
+
export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
|
|
54
59
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
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"],"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":""}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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,12 +31,15 @@ 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;
|
|
36
38
|
get connecting(): boolean;
|
|
37
39
|
get readyState(): WalletReadyState;
|
|
40
|
+
private declareWalletAsInstalled;
|
|
38
41
|
private runWithGuard;
|
|
42
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(): Promise<void>;
|
|
39
43
|
connect(): Promise<void>;
|
|
40
44
|
private handleAuthorizationResult;
|
|
41
45
|
private performReauthorization;
|
|
@@ -50,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
50
54
|
}
|
|
51
55
|
declare function createDefaultAddressSelector(): AddressSelector;
|
|
52
56
|
declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
|
|
53
|
-
|
|
57
|
+
declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
|
|
58
|
+
export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
|
|
54
59
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"],"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,12 +31,15 @@ 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;
|
|
36
38
|
get connecting(): boolean;
|
|
37
39
|
get readyState(): WalletReadyState;
|
|
40
|
+
private declareWalletAsInstalled;
|
|
38
41
|
private runWithGuard;
|
|
42
|
+
autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(): Promise<void>;
|
|
39
43
|
connect(): Promise<void>;
|
|
40
44
|
private handleAuthorizationResult;
|
|
41
45
|
private performReauthorization;
|
|
@@ -50,5 +54,6 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
50
54
|
}
|
|
51
55
|
declare function createDefaultAddressSelector(): AddressSelector;
|
|
52
56
|
declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
|
|
53
|
-
|
|
57
|
+
declare function createDefaultWalletNotFoundHandler(): (mobileWalletAdapter: SolanaMobileWalletAdapter) => Promise<void>;
|
|
58
|
+
export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache, createDefaultWalletNotFoundHandler };
|
|
54
59
|
//# sourceMappingURL=index.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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/__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
|
+
"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.
|
|
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": "
|
|
54
|
+
"gitHead": "d3da860526efa336e0bd4c4d680f0f38b1d8f146"
|
|
55
55
|
}
|