@solana-mobile/wallet-adapter-mobile 0.0.1-alpha.8 → 0.9.0

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.
@@ -56,6 +56,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
56
56
  this._connecting = false;
57
57
  this._readyState = getIsSupported() ? WalletReadyState.Loadable : WalletReadyState.Unsupported;
58
58
  this._authorizationResultCache = config.authorizationResultCache;
59
+ this._addressSelector = config.addressSelector;
59
60
  this._appIdentity = config.appIdentity;
60
61
  this._cluster = config.cluster;
61
62
  if (this._readyState !== WalletReadyState.Unsupported) {
@@ -70,11 +71,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
70
71
  }
71
72
  }
72
73
  get publicKey() {
73
- if (this._publicKey == null && this._authorizationResult != null) {
74
+ if (this._publicKey == null && this._selectedAddress != null) {
74
75
  try {
75
- this._publicKey = getPublicKeyFromAddress(
76
- // TODO(#44): support multiple addresses
77
- this._authorizationResult.addresses[0]);
76
+ this._publicKey = getPublicKeyFromAddress(this._selectedAddress);
78
77
  }
79
78
  catch (e) {
80
79
  throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
@@ -116,8 +115,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
116
115
  if (this._readyState !== WalletReadyState.Installed) {
117
116
  this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
118
117
  }
118
+ this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
119
119
  this.emit('connect',
120
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
120
+ // Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
121
121
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122
122
  this.publicKey);
123
123
  return;
@@ -143,23 +143,33 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
143
143
  handleAuthorizationResult(authorizationResult) {
144
144
  var _a;
145
145
  return __awaiter(this, void 0, void 0, function* () {
146
- const didPublicKeyChange = ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.addresses[0]) !== authorizationResult.addresses[0]; // TODO(#44): support multiple addresses
146
+ const didPublicKeysChange =
147
+ // Case 1: We started from having no authorization.
148
+ this._authorizationResult == null ||
149
+ // Case 2: The number of authorized accounts changed.
150
+ ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorizationResult.accounts.length ||
151
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
152
+ this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
147
153
  this._authorizationResult = authorizationResult;
148
- if (didPublicKeyChange) {
149
- delete this._publicKey;
150
- this.emit('connect',
151
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
152
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
153
- this.publicKey);
154
+ if (didPublicKeysChange) {
155
+ const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
156
+ if (nextSelectedAddress !== this._selectedAddress) {
157
+ this._selectedAddress = nextSelectedAddress;
158
+ delete this._publicKey;
159
+ this.emit('connect',
160
+ // Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
161
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
162
+ this.publicKey);
163
+ }
154
164
  }
155
165
  yield this._authorizationResultCache.set(authorizationResult);
156
166
  });
157
167
  }
158
- performReauthorization(wallet, currentAuthorizationResult) {
168
+ performReauthorization(wallet, authToken) {
159
169
  return __awaiter(this, void 0, void 0, function* () {
160
170
  try {
161
171
  const authorizationResult = yield wallet.reauthorize({
162
- auth_token: currentAuthorizationResult.auth_token,
172
+ auth_token: authToken,
163
173
  });
164
174
  this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
165
175
  }
@@ -174,6 +184,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
174
184
  this._authorizationResultCache.clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
175
185
  delete this._authorizationResult;
176
186
  delete this._publicKey;
187
+ delete this._selectedAddress;
177
188
  this.emit('disconnect');
178
189
  });
179
190
  }
@@ -186,17 +197,19 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
186
197
  });
187
198
  }
188
199
  assertIsAuthorized() {
189
- const authorizationResult = this._authorizationResult;
190
- if (!authorizationResult)
200
+ if (!this._authorizationResult || !this._selectedAddress)
191
201
  throw new WalletNotConnectedError();
192
- return authorizationResult;
202
+ return {
203
+ authToken: this._authorizationResult.auth_token,
204
+ selectedAddress: this._selectedAddress,
205
+ };
193
206
  }
194
207
  performSignTransactions(transactions) {
195
208
  return __awaiter(this, void 0, void 0, function* () {
196
- const authorizationResult = this.assertIsAuthorized();
209
+ const { authToken } = this.assertIsAuthorized();
197
210
  try {
198
211
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
199
- yield this.performReauthorization(wallet, authorizationResult);
212
+ yield this.performReauthorization(wallet, authToken);
200
213
  const signedTransactions = yield wallet.signTransactions({
201
214
  transactions,
202
215
  });
@@ -208,16 +221,58 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
208
221
  }
209
222
  });
210
223
  }
211
- sendTransaction(transaction, connection, _options) {
224
+ sendTransaction(transaction, connection, options) {
212
225
  return __awaiter(this, void 0, void 0, function* () {
213
226
  return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
214
- const authorizationResult = this.assertIsAuthorized();
227
+ const { authToken } = this.assertIsAuthorized();
228
+ const minContextSlot = options === null || options === void 0 ? void 0 : options.minContextSlot;
215
229
  try {
216
230
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
217
- yield this.performReauthorization(wallet, authorizationResult);
231
+ var _a;
232
+ let targetCommitment;
233
+ switch (connection.commitment) {
234
+ case 'confirmed':
235
+ case 'finalized':
236
+ case 'processed':
237
+ targetCommitment = connection.commitment;
238
+ break;
239
+ default:
240
+ targetCommitment = 'finalized';
241
+ }
242
+ let targetPreflightCommitment;
243
+ switch (options === null || options === void 0 ? void 0 : options.preflightCommitment) {
244
+ case 'confirmed':
245
+ case 'finalized':
246
+ case 'processed':
247
+ targetPreflightCommitment = options.preflightCommitment;
248
+ break;
249
+ case undefined:
250
+ targetPreflightCommitment = targetCommitment;
251
+ default:
252
+ targetPreflightCommitment = 'finalized';
253
+ }
254
+ yield Promise.all([
255
+ this.performReauthorization(wallet, authToken),
256
+ (() => __awaiter(this, void 0, void 0, function* () {
257
+ if (transaction.recentBlockhash == null) {
258
+ const preflightCommitmentScore = targetPreflightCommitment === 'finalized'
259
+ ? 2
260
+ : targetPreflightCommitment === 'confirmed'
261
+ ? 1
262
+ : 0;
263
+ const targetCommitmentScore = targetCommitment === 'finalized' ? 2 : targetCommitment === 'confirmed' ? 1 : 0;
264
+ const { blockhash } = yield connection.getLatestBlockhash({
265
+ commitment: preflightCommitmentScore < targetCommitmentScore
266
+ ? targetPreflightCommitment
267
+ : targetCommitment,
268
+ });
269
+ transaction.recentBlockhash = blockhash;
270
+ }
271
+ }))(),
272
+ ]);
273
+ transaction.feePayer || (transaction.feePayer = (_a = this.publicKey) !== null && _a !== void 0 ? _a : undefined);
218
274
  const signatures = yield wallet.signAndSendTransactions({
219
- connection,
220
- fee_payer: transaction.feePayer,
275
+ minContextSlot,
221
276
  transactions: [transaction],
222
277
  });
223
278
  return signatures[0];
@@ -248,11 +303,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
248
303
  signMessage(message) {
249
304
  return __awaiter(this, void 0, void 0, function* () {
250
305
  return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
251
- const authorizationResult = this.assertIsAuthorized();
306
+ const { authToken, selectedAddress } = this.assertIsAuthorized();
252
307
  try {
253
308
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
254
- yield this.performReauthorization(wallet, authorizationResult);
309
+ yield this.performReauthorization(wallet, authToken);
255
310
  const [signedMessage] = yield wallet.signMessages({
311
+ addresses: [selectedAddress],
256
312
  payloads: [message],
257
313
  });
258
314
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
@@ -267,6 +323,16 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
267
323
  }
268
324
  }
269
325
 
326
+ function createDefaultAddressSelector() {
327
+ return {
328
+ select(addresses) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ return addresses[0];
331
+ });
332
+ },
333
+ };
334
+ }
335
+
270
336
  const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
271
337
  function createDefaultAuthorizationResultCache() {
272
338
  let storage;
@@ -315,4 +381,4 @@ function createDefaultAuthorizationResultCache() {
315
381
  };
316
382
  }
317
383
 
318
- export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationResultCache };
384
+ export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
package/lib/esm/index.mjs CHANGED
@@ -56,6 +56,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
56
56
  this._connecting = false;
57
57
  this._readyState = getIsSupported() ? WalletReadyState.Loadable : WalletReadyState.Unsupported;
58
58
  this._authorizationResultCache = config.authorizationResultCache;
59
+ this._addressSelector = config.addressSelector;
59
60
  this._appIdentity = config.appIdentity;
60
61
  this._cluster = config.cluster;
61
62
  if (this._readyState !== WalletReadyState.Unsupported) {
@@ -70,11 +71,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
70
71
  }
71
72
  }
72
73
  get publicKey() {
73
- if (this._publicKey == null && this._authorizationResult != null) {
74
+ if (this._publicKey == null && this._selectedAddress != null) {
74
75
  try {
75
- this._publicKey = getPublicKeyFromAddress(
76
- // TODO(#44): support multiple addresses
77
- this._authorizationResult.addresses[0]);
76
+ this._publicKey = getPublicKeyFromAddress(this._selectedAddress);
78
77
  }
79
78
  catch (e) {
80
79
  throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
@@ -116,8 +115,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
116
115
  if (this._readyState !== WalletReadyState.Installed) {
117
116
  this.emit('readyStateChange', (this._readyState = WalletReadyState.Installed));
118
117
  }
118
+ this._selectedAddress = yield this._addressSelector.select(cachedAuthorizationResult.accounts.map(({ address }) => address));
119
119
  this.emit('connect',
120
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
120
+ // Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
121
121
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
122
122
  this.publicKey);
123
123
  return;
@@ -143,23 +143,33 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
143
143
  handleAuthorizationResult(authorizationResult) {
144
144
  var _a;
145
145
  return __awaiter(this, void 0, void 0, function* () {
146
- const didPublicKeyChange = ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.addresses[0]) !== authorizationResult.addresses[0]; // TODO(#44): support multiple addresses
146
+ const didPublicKeysChange =
147
+ // Case 1: We started from having no authorization.
148
+ this._authorizationResult == null ||
149
+ // Case 2: The number of authorized accounts changed.
150
+ ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorizationResult.accounts.length ||
151
+ // Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
152
+ this._authorizationResult.accounts.some((account, ii) => account.address !== authorizationResult.accounts[ii].address);
147
153
  this._authorizationResult = authorizationResult;
148
- if (didPublicKeyChange) {
149
- delete this._publicKey;
150
- this.emit('connect',
151
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
152
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
153
- this.publicKey);
154
+ if (didPublicKeysChange) {
155
+ const nextSelectedAddress = yield this._addressSelector.select(authorizationResult.accounts.map(({ address }) => address));
156
+ if (nextSelectedAddress !== this._selectedAddress) {
157
+ this._selectedAddress = nextSelectedAddress;
158
+ delete this._publicKey;
159
+ this.emit('connect',
160
+ // Having just set `this._selectedAddress`, `this.publicKey` is definitely non-null
161
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
162
+ this.publicKey);
163
+ }
154
164
  }
155
165
  yield this._authorizationResultCache.set(authorizationResult);
156
166
  });
157
167
  }
158
- performReauthorization(wallet, currentAuthorizationResult) {
168
+ performReauthorization(wallet, authToken) {
159
169
  return __awaiter(this, void 0, void 0, function* () {
160
170
  try {
161
171
  const authorizationResult = yield wallet.reauthorize({
162
- auth_token: currentAuthorizationResult.auth_token,
172
+ auth_token: authToken,
163
173
  });
164
174
  this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
165
175
  }
@@ -174,6 +184,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
174
184
  this._authorizationResultCache.clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
175
185
  delete this._authorizationResult;
176
186
  delete this._publicKey;
187
+ delete this._selectedAddress;
177
188
  this.emit('disconnect');
178
189
  });
179
190
  }
@@ -186,17 +197,19 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
186
197
  });
187
198
  }
188
199
  assertIsAuthorized() {
189
- const authorizationResult = this._authorizationResult;
190
- if (!authorizationResult)
200
+ if (!this._authorizationResult || !this._selectedAddress)
191
201
  throw new WalletNotConnectedError();
192
- return authorizationResult;
202
+ return {
203
+ authToken: this._authorizationResult.auth_token,
204
+ selectedAddress: this._selectedAddress,
205
+ };
193
206
  }
194
207
  performSignTransactions(transactions) {
195
208
  return __awaiter(this, void 0, void 0, function* () {
196
- const authorizationResult = this.assertIsAuthorized();
209
+ const { authToken } = this.assertIsAuthorized();
197
210
  try {
198
211
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
199
- yield this.performReauthorization(wallet, authorizationResult);
212
+ yield this.performReauthorization(wallet, authToken);
200
213
  const signedTransactions = yield wallet.signTransactions({
201
214
  transactions,
202
215
  });
@@ -208,16 +221,58 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
208
221
  }
209
222
  });
210
223
  }
211
- sendTransaction(transaction, connection, _options) {
224
+ sendTransaction(transaction, connection, options) {
212
225
  return __awaiter(this, void 0, void 0, function* () {
213
226
  return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
214
- const authorizationResult = this.assertIsAuthorized();
227
+ const { authToken } = this.assertIsAuthorized();
228
+ const minContextSlot = options === null || options === void 0 ? void 0 : options.minContextSlot;
215
229
  try {
216
230
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
217
- yield this.performReauthorization(wallet, authorizationResult);
231
+ var _a;
232
+ let targetCommitment;
233
+ switch (connection.commitment) {
234
+ case 'confirmed':
235
+ case 'finalized':
236
+ case 'processed':
237
+ targetCommitment = connection.commitment;
238
+ break;
239
+ default:
240
+ targetCommitment = 'finalized';
241
+ }
242
+ let targetPreflightCommitment;
243
+ switch (options === null || options === void 0 ? void 0 : options.preflightCommitment) {
244
+ case 'confirmed':
245
+ case 'finalized':
246
+ case 'processed':
247
+ targetPreflightCommitment = options.preflightCommitment;
248
+ break;
249
+ case undefined:
250
+ targetPreflightCommitment = targetCommitment;
251
+ default:
252
+ targetPreflightCommitment = 'finalized';
253
+ }
254
+ yield Promise.all([
255
+ this.performReauthorization(wallet, authToken),
256
+ (() => __awaiter(this, void 0, void 0, function* () {
257
+ if (transaction.recentBlockhash == null) {
258
+ const preflightCommitmentScore = targetPreflightCommitment === 'finalized'
259
+ ? 2
260
+ : targetPreflightCommitment === 'confirmed'
261
+ ? 1
262
+ : 0;
263
+ const targetCommitmentScore = targetCommitment === 'finalized' ? 2 : targetCommitment === 'confirmed' ? 1 : 0;
264
+ const { blockhash } = yield connection.getLatestBlockhash({
265
+ commitment: preflightCommitmentScore < targetCommitmentScore
266
+ ? targetPreflightCommitment
267
+ : targetCommitment,
268
+ });
269
+ transaction.recentBlockhash = blockhash;
270
+ }
271
+ }))(),
272
+ ]);
273
+ transaction.feePayer || (transaction.feePayer = (_a = this.publicKey) !== null && _a !== void 0 ? _a : undefined);
218
274
  const signatures = yield wallet.signAndSendTransactions({
219
- connection,
220
- fee_payer: transaction.feePayer,
275
+ minContextSlot,
221
276
  transactions: [transaction],
222
277
  });
223
278
  return signatures[0];
@@ -248,11 +303,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
248
303
  signMessage(message) {
249
304
  return __awaiter(this, void 0, void 0, function* () {
250
305
  return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
251
- const authorizationResult = this.assertIsAuthorized();
306
+ const { authToken, selectedAddress } = this.assertIsAuthorized();
252
307
  try {
253
308
  return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
254
- yield this.performReauthorization(wallet, authorizationResult);
309
+ yield this.performReauthorization(wallet, authToken);
255
310
  const [signedMessage] = yield wallet.signMessages({
311
+ addresses: [selectedAddress],
256
312
  payloads: [message],
257
313
  });
258
314
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
@@ -267,6 +323,16 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
267
323
  }
268
324
  }
269
325
 
326
+ function createDefaultAddressSelector() {
327
+ return {
328
+ select(addresses) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ return addresses[0];
331
+ });
332
+ },
333
+ };
334
+ }
335
+
270
336
  const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
271
337
  function createDefaultAuthorizationResultCache() {
272
338
  let storage;
@@ -315,4 +381,4 @@ function createDefaultAuthorizationResultCache() {
315
381
  };
316
382
  }
317
383
 
318
- export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationResultCache };
384
+ export { SolanaMobileWalletAdapter, SolanaMobileWalletAdapterWalletName, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
@@ -1,4 +1,4 @@
1
- import { AppIdentity, AuthorizationResult, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
1
+ import { AppIdentity, AuthorizationResult, Base64EncodedAddress, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
2
2
  import { BaseMessageSignerWalletAdapter, WalletName, WalletReadyState } from "@solana/wallet-adapter-base";
3
3
  import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from "@solana/web3.js";
4
4
  interface AuthorizationResultCache {
@@ -6,11 +6,15 @@ interface AuthorizationResultCache {
6
6
  get(): Promise<AuthorizationResult | undefined>;
7
7
  set(authorizationResult: AuthorizationResult): Promise<void>;
8
8
  }
9
+ interface AddressSelector {
10
+ select(addresses: Base64EncodedAddress[]): Promise<Base64EncodedAddress>;
11
+ }
9
12
  declare const SolanaMobileWalletAdapterWalletName: WalletName<string>;
10
13
  declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
11
14
  name: WalletName<string>;
12
15
  url: string;
13
16
  icon: string;
17
+ private _addressSelector;
14
18
  private _appIdentity;
15
19
  private _authorizationResult;
16
20
  private _authorizationResultCache;
@@ -18,7 +22,9 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
18
22
  private _cluster;
19
23
  private _publicKey;
20
24
  private _readyState;
25
+ private _selectedAddress;
21
26
  constructor(config: {
27
+ addressSelector: AddressSelector;
22
28
  appIdentity: AppIdentity;
23
29
  authorizationResultCache: AuthorizationResultCache;
24
30
  cluster: Cluster;
@@ -35,11 +41,12 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
35
41
  private transact;
36
42
  private assertIsAuthorized;
37
43
  private performSignTransactions;
38
- sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
44
+ sendTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<TransactionSignature>;
39
45
  signTransaction(transaction: Transaction): Promise<Transaction>;
40
46
  signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;
41
47
  signMessage(message: Uint8Array): Promise<Uint8Array>;
42
48
  }
49
+ declare function createDefaultAddressSelector(): AddressSelector;
43
50
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
44
- export { AuthorizationResultCache, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAuthorizationResultCache };
51
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
45
52
  //# 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/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"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { AppIdentity, AuthorizationResult, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
1
+ import { AppIdentity, AuthorizationResult, Base64EncodedAddress, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
2
2
  import { BaseMessageSignerWalletAdapter, WalletName, WalletReadyState } from "@solana/wallet-adapter-base";
3
3
  import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from "@solana/web3.js";
4
4
  interface AuthorizationResultCache {
@@ -6,11 +6,15 @@ interface AuthorizationResultCache {
6
6
  get(): Promise<AuthorizationResult | undefined>;
7
7
  set(authorizationResult: AuthorizationResult): Promise<void>;
8
8
  }
9
+ interface AddressSelector {
10
+ select(addresses: Base64EncodedAddress[]): Promise<Base64EncodedAddress>;
11
+ }
9
12
  declare const SolanaMobileWalletAdapterWalletName: WalletName<string>;
10
13
  declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
11
14
  name: WalletName<string>;
12
15
  url: string;
13
16
  icon: string;
17
+ private _addressSelector;
14
18
  private _appIdentity;
15
19
  private _authorizationResult;
16
20
  private _authorizationResultCache;
@@ -18,7 +22,9 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
18
22
  private _cluster;
19
23
  private _publicKey;
20
24
  private _readyState;
25
+ private _selectedAddress;
21
26
  constructor(config: {
27
+ addressSelector: AddressSelector;
22
28
  appIdentity: AppIdentity;
23
29
  authorizationResultCache: AuthorizationResultCache;
24
30
  cluster: Cluster;
@@ -35,11 +41,12 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
35
41
  private transact;
36
42
  private assertIsAuthorized;
37
43
  private performSignTransactions;
38
- sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
44
+ sendTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<TransactionSignature>;
39
45
  signTransaction(transaction: Transaction): Promise<Transaction>;
40
46
  signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;
41
47
  signMessage(message: Uint8Array): Promise<Uint8Array>;
42
48
  }
49
+ declare function createDefaultAddressSelector(): AddressSelector;
43
50
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
44
- export { AuthorizationResultCache, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAuthorizationResultCache };
51
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
45
52
  //# 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/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"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { AppIdentity, AuthorizationResult, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
1
+ import { AppIdentity, AuthorizationResult, Base64EncodedAddress, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
2
2
  import { BaseMessageSignerWalletAdapter, WalletName, WalletReadyState } from "@solana/wallet-adapter-base";
3
3
  import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from "@solana/web3.js";
4
4
  interface AuthorizationResultCache {
@@ -6,11 +6,15 @@ interface AuthorizationResultCache {
6
6
  get(): Promise<AuthorizationResult | undefined>;
7
7
  set(authorizationResult: AuthorizationResult): Promise<void>;
8
8
  }
9
+ interface AddressSelector {
10
+ select(addresses: Base64EncodedAddress[]): Promise<Base64EncodedAddress>;
11
+ }
9
12
  declare const SolanaMobileWalletAdapterWalletName: WalletName<string>;
10
13
  declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
11
14
  name: WalletName<string>;
12
15
  url: string;
13
16
  icon: string;
17
+ private _addressSelector;
14
18
  private _appIdentity;
15
19
  private _authorizationResult;
16
20
  private _authorizationResultCache;
@@ -18,7 +22,9 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
18
22
  private _cluster;
19
23
  private _publicKey;
20
24
  private _readyState;
25
+ private _selectedAddress;
21
26
  constructor(config: {
27
+ addressSelector: AddressSelector;
22
28
  appIdentity: AppIdentity;
23
29
  authorizationResultCache: AuthorizationResultCache;
24
30
  cluster: Cluster;
@@ -35,11 +41,12 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
35
41
  private transact;
36
42
  private assertIsAuthorized;
37
43
  private performSignTransactions;
38
- sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
44
+ sendTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<TransactionSignature>;
39
45
  signTransaction(transaction: Transaction): Promise<Transaction>;
40
46
  signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;
41
47
  signMessage(message: Uint8Array): Promise<Uint8Array>;
42
48
  }
49
+ declare function createDefaultAddressSelector(): AddressSelector;
43
50
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
44
- export { AuthorizationResultCache, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAuthorizationResultCache };
51
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
45
52
  //# 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/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"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { AppIdentity, AuthorizationResult, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
1
+ import { AppIdentity, AuthorizationResult, Base64EncodedAddress, Cluster } from "@solana-mobile/mobile-wallet-adapter-protocol";
2
2
  import { BaseMessageSignerWalletAdapter, WalletName, WalletReadyState } from "@solana/wallet-adapter-base";
3
3
  import { Connection, PublicKey, SendOptions, Transaction, TransactionSignature } from "@solana/web3.js";
4
4
  interface AuthorizationResultCache {
@@ -6,11 +6,15 @@ interface AuthorizationResultCache {
6
6
  get(): Promise<AuthorizationResult | undefined>;
7
7
  set(authorizationResult: AuthorizationResult): Promise<void>;
8
8
  }
9
+ interface AddressSelector {
10
+ select(addresses: Base64EncodedAddress[]): Promise<Base64EncodedAddress>;
11
+ }
9
12
  declare const SolanaMobileWalletAdapterWalletName: WalletName<string>;
10
13
  declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
11
14
  name: WalletName<string>;
12
15
  url: string;
13
16
  icon: string;
17
+ private _addressSelector;
14
18
  private _appIdentity;
15
19
  private _authorizationResult;
16
20
  private _authorizationResultCache;
@@ -18,7 +22,9 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
18
22
  private _cluster;
19
23
  private _publicKey;
20
24
  private _readyState;
25
+ private _selectedAddress;
21
26
  constructor(config: {
27
+ addressSelector: AddressSelector;
22
28
  appIdentity: AppIdentity;
23
29
  authorizationResultCache: AuthorizationResultCache;
24
30
  cluster: Cluster;
@@ -35,11 +41,12 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
35
41
  private transact;
36
42
  private assertIsAuthorized;
37
43
  private performSignTransactions;
38
- sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
44
+ sendTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<TransactionSignature>;
39
45
  signTransaction(transaction: Transaction): Promise<Transaction>;
40
46
  signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;
41
47
  signMessage(message: Uint8Array): Promise<Uint8Array>;
42
48
  }
49
+ declare function createDefaultAddressSelector(): AddressSelector;
43
50
  declare function createDefaultAuthorizationResultCache(): AuthorizationResultCache;
44
- export { AuthorizationResultCache, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAuthorizationResultCache };
51
+ export { AuthorizationResultCache, AddressSelector, SolanaMobileWalletAdapterWalletName, SolanaMobileWalletAdapter, createDefaultAddressSelector, createDefaultAuthorizationResultCache };
45
52
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts","../../src/base64Utils.ts","../../src/getIsSupported.ts","../../src/adapter.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"],"names":[],"mappings":""}