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

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.
@@ -31,6 +31,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
31
31
  });
32
32
  }
33
33
 
34
+ function toUint8Array(base64EncodedByteArray) {
35
+ return new Uint8Array(window
36
+ .atob(base64EncodedByteArray)
37
+ .split('')
38
+ .map((c) => c.charCodeAt(0)));
39
+ }
40
+
34
41
  function getIsSupported() {
35
42
  return (typeof window !== 'undefined' &&
36
43
  window.isSecureContext &&
@@ -40,6 +47,10 @@ function getIsSupported() {
40
47
 
41
48
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
42
49
  const SIGNATURE_LENGTH_IN_BYTES = 64;
50
+ function getPublicKeyFromAddress(address) {
51
+ const publicKeyByteArray = toUint8Array(address);
52
+ return new web3_js.PublicKey(publicKeyByteArray);
53
+ }
43
54
  class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalletAdapter {
44
55
  constructor(config) {
45
56
  super();
@@ -50,6 +61,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
50
61
  this._readyState = getIsSupported() ? walletAdapterBase.WalletReadyState.Loadable : walletAdapterBase.WalletReadyState.Unsupported;
51
62
  this._authorizationResultCache = config.authorizationResultCache;
52
63
  this._appIdentity = config.appIdentity;
64
+ this._cluster = config.cluster;
53
65
  if (this._readyState !== walletAdapterBase.WalletReadyState.Unsupported) {
54
66
  this._authorizationResultCache.get().then((authorizationResult) => {
55
67
  if (authorizationResult) {
@@ -63,7 +75,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
63
75
  }
64
76
  get publicKey() {
65
77
  if (this._publicKey == null && this._authorizationResult != null) {
66
- this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
78
+ try {
79
+ this._publicKey = getPublicKeyFromAddress(
80
+ // TODO(#44): support multiple addresses
81
+ this._authorizationResult.addresses[0]);
82
+ }
83
+ catch (e) {
84
+ throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
85
+ }
67
86
  }
68
87
  return this._publicKey ? this._publicKey : null;
69
88
  }
@@ -76,71 +95,77 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
76
95
  get readyState() {
77
96
  return this._readyState;
78
97
  }
79
- connect() {
98
+ runWithGuard(callback) {
80
99
  return __awaiter(this, void 0, void 0, function* () {
81
- if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
82
- const err = new walletAdapterBase.WalletNotReadyError();
83
- this.emit('error', err);
84
- throw err;
100
+ try {
101
+ return yield callback();
85
102
  }
86
- this._connecting = true;
87
- const cachedAuthorizationResult = yield this._authorizationResultCache.get();
88
- if (cachedAuthorizationResult) {
89
- this._authorizationResult = cachedAuthorizationResult;
90
- this._connecting = false;
91
- if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
92
- this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
93
- }
94
- this.emit('connect',
95
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- this.publicKey);
98
- return;
103
+ catch (e) {
104
+ this.emit('error', e);
105
+ throw e;
99
106
  }
100
- try {
101
- yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
102
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield walletAPI('authorize', { identity: this._appIdentity });
103
- try {
104
- this._publicKey = new web3_js.PublicKey(base58PublicKey);
105
- }
106
- catch (e) {
107
- throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
107
+ });
108
+ }
109
+ connect() {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
112
+ if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
113
+ throw new walletAdapterBase.WalletNotReadyError();
114
+ }
115
+ this._connecting = true;
116
+ const cachedAuthorizationResult = yield this._authorizationResultCache.get();
117
+ if (cachedAuthorizationResult) {
118
+ this._authorizationResult = cachedAuthorizationResult;
119
+ this._connecting = false;
120
+ if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
121
+ this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
108
122
  }
109
- this.handleAuthorizationResult({
110
- auth_token,
111
- pub_key: base58PublicKey,
112
- wallet_uri_base: wallet_uri_base,
113
- }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
114
123
  this.emit('connect',
115
124
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
116
125
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117
126
  this.publicKey);
118
- }));
119
- }
120
- catch (e) {
121
- throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
122
- }
123
- finally {
124
- this._connecting = false;
125
- }
127
+ return;
128
+ }
129
+ try {
130
+ yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
131
+ const authorizationResult = yield wallet.authorize({
132
+ cluster: this._cluster,
133
+ identity: this._appIdentity,
134
+ });
135
+ this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
136
+ }));
137
+ }
138
+ catch (e) {
139
+ throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
140
+ }
141
+ finally {
142
+ this._connecting = false;
143
+ }
144
+ }));
126
145
  });
127
146
  }
128
147
  handleAuthorizationResult(authorizationResult) {
148
+ var _a;
129
149
  return __awaiter(this, void 0, void 0, function* () {
150
+ const didPublicKeyChange = ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.addresses[0]) !== authorizationResult.addresses[0]; // TODO(#44): support multiple addresses
130
151
  this._authorizationResult = authorizationResult;
152
+ if (didPublicKeyChange) {
153
+ delete this._publicKey;
154
+ this.emit('connect',
155
+ // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
156
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157
+ this.publicKey);
158
+ }
131
159
  yield this._authorizationResultCache.set(authorizationResult);
132
160
  });
133
161
  }
134
- performReauthorization(walletAPI, currentAuthorizationResult) {
162
+ performReauthorization(wallet, currentAuthorizationResult) {
135
163
  return __awaiter(this, void 0, void 0, function* () {
136
164
  try {
137
- const { auth_token } = yield walletAPI('reauthorize', {
165
+ const authorizationResult = yield wallet.reauthorize({
138
166
  auth_token: currentAuthorizationResult.auth_token,
139
167
  });
140
- if (currentAuthorizationResult.auth_token !== auth_token) {
141
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
142
- }
143
- return auth_token;
168
+ this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
144
169
  }
145
170
  catch (e) {
146
171
  this.disconnect();
@@ -172,39 +197,31 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
172
197
  }
173
198
  performSignTransactions(transactions) {
174
199
  return __awaiter(this, void 0, void 0, function* () {
200
+ const authorizationResult = this.assertIsAuthorized();
175
201
  try {
176
- const authorizationResult = this.assertIsAuthorized();
177
- try {
178
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
179
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
180
- const signedTransactions = yield walletAPI('sign_transaction', {
181
- auth_token: freshAuthToken,
182
- transactions,
183
- });
184
- return signedTransactions;
185
- }));
186
- }
187
- catch (error) {
188
- throw new walletAdapterBase.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
189
- }
202
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
203
+ yield this.performReauthorization(wallet, authorizationResult);
204
+ const signedTransactions = yield wallet.signTransactions({
205
+ transactions,
206
+ });
207
+ return signedTransactions;
208
+ }));
190
209
  }
191
210
  catch (error) {
192
- this.emit('error', error);
193
- throw error;
211
+ throw new walletAdapterBase.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
194
212
  }
195
213
  });
196
214
  }
197
215
  sendTransaction(transaction, connection, _options) {
198
216
  return __awaiter(this, void 0, void 0, function* () {
199
- try {
217
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
200
218
  const authorizationResult = this.assertIsAuthorized();
201
219
  try {
202
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
203
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
204
- const signatures = yield walletAPI('sign_and_send_transaction', {
205
- auth_token: freshAuthToken,
206
- fee_payer: this.publicKey || undefined,
220
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
221
+ yield this.performReauthorization(wallet, authorizationResult);
222
+ const signatures = yield wallet.signAndSendTransactions({
207
223
  connection,
224
+ fee_payer: transaction.feePayer,
208
225
  transactions: [transaction],
209
226
  });
210
227
  return signatures[0];
@@ -213,34 +230,33 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
213
230
  catch (error) {
214
231
  throw new walletAdapterBase.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
215
232
  }
216
- }
217
- catch (error) {
218
- this.emit('error', error);
219
- throw error;
220
- }
233
+ }));
221
234
  });
222
235
  }
223
236
  signTransaction(transaction) {
224
237
  return __awaiter(this, void 0, void 0, function* () {
225
- const [signedTransaction] = yield this.performSignTransactions([transaction]);
226
- return signedTransaction;
238
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
239
+ const [signedTransaction] = yield this.performSignTransactions([transaction]);
240
+ return signedTransaction;
241
+ }));
227
242
  });
228
243
  }
229
244
  signAllTransactions(transactions) {
230
245
  return __awaiter(this, void 0, void 0, function* () {
231
- const signedTransactions = yield this.performSignTransactions(transactions);
232
- return signedTransactions;
246
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
247
+ const signedTransactions = yield this.performSignTransactions(transactions);
248
+ return signedTransactions;
249
+ }));
233
250
  });
234
251
  }
235
252
  signMessage(message) {
236
253
  return __awaiter(this, void 0, void 0, function* () {
237
- try {
254
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
238
255
  const authorizationResult = this.assertIsAuthorized();
239
256
  try {
240
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
241
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
242
- const [signedMessage] = yield walletAPI('sign_message', {
243
- auth_token: freshAuthToken,
257
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
258
+ yield this.performReauthorization(wallet, authorizationResult);
259
+ const [signedMessage] = yield wallet.signMessages({
244
260
  payloads: [message],
245
261
  });
246
262
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
@@ -250,11 +266,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
250
266
  catch (error) {
251
267
  throw new walletAdapterBase.WalletSignMessageError(error === null || error === void 0 ? void 0 : error.message, error);
252
268
  }
253
- }
254
- catch (error) {
255
- this.emit('error', error);
256
- throw error;
257
- }
269
+ }));
258
270
  });
259
271
  }
260
272
  }
package/lib/cjs/index.js CHANGED
@@ -31,6 +31,13 @@ function __awaiter(thisArg, _arguments, P, generator) {
31
31
  });
32
32
  }
33
33
 
34
+ function toUint8Array(base64EncodedByteArray) {
35
+ return new Uint8Array(window
36
+ .atob(base64EncodedByteArray)
37
+ .split('')
38
+ .map((c) => c.charCodeAt(0)));
39
+ }
40
+
34
41
  function getIsSupported() {
35
42
  return (typeof window !== 'undefined' &&
36
43
  window.isSecureContext &&
@@ -40,6 +47,10 @@ function getIsSupported() {
40
47
 
41
48
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
42
49
  const SIGNATURE_LENGTH_IN_BYTES = 64;
50
+ function getPublicKeyFromAddress(address) {
51
+ const publicKeyByteArray = toUint8Array(address);
52
+ return new web3_js.PublicKey(publicKeyByteArray);
53
+ }
43
54
  class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalletAdapter {
44
55
  constructor(config) {
45
56
  super();
@@ -50,6 +61,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
50
61
  this._readyState = getIsSupported() ? walletAdapterBase.WalletReadyState.Loadable : walletAdapterBase.WalletReadyState.Unsupported;
51
62
  this._authorizationResultCache = config.authorizationResultCache;
52
63
  this._appIdentity = config.appIdentity;
64
+ this._cluster = config.cluster;
53
65
  if (this._readyState !== walletAdapterBase.WalletReadyState.Unsupported) {
54
66
  this._authorizationResultCache.get().then((authorizationResult) => {
55
67
  if (authorizationResult) {
@@ -63,7 +75,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
63
75
  }
64
76
  get publicKey() {
65
77
  if (this._publicKey == null && this._authorizationResult != null) {
66
- this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
78
+ try {
79
+ this._publicKey = getPublicKeyFromAddress(
80
+ // TODO(#44): support multiple addresses
81
+ this._authorizationResult.addresses[0]);
82
+ }
83
+ catch (e) {
84
+ throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
85
+ }
67
86
  }
68
87
  return this._publicKey ? this._publicKey : null;
69
88
  }
@@ -76,71 +95,77 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
76
95
  get readyState() {
77
96
  return this._readyState;
78
97
  }
79
- connect() {
98
+ runWithGuard(callback) {
80
99
  return __awaiter(this, void 0, void 0, function* () {
81
- if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
82
- const err = new walletAdapterBase.WalletNotReadyError();
83
- this.emit('error', err);
84
- throw err;
100
+ try {
101
+ return yield callback();
85
102
  }
86
- this._connecting = true;
87
- const cachedAuthorizationResult = yield this._authorizationResultCache.get();
88
- if (cachedAuthorizationResult) {
89
- this._authorizationResult = cachedAuthorizationResult;
90
- this._connecting = false;
91
- if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
92
- this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
93
- }
94
- this.emit('connect',
95
- // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- this.publicKey);
98
- return;
103
+ catch (e) {
104
+ this.emit('error', e);
105
+ throw e;
99
106
  }
100
- try {
101
- yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
102
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield walletAPI('authorize', { identity: this._appIdentity });
103
- try {
104
- this._publicKey = new web3_js.PublicKey(base58PublicKey);
105
- }
106
- catch (e) {
107
- throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
107
+ });
108
+ }
109
+ connect() {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
112
+ if (this._readyState !== walletAdapterBase.WalletReadyState.Installed && this._readyState !== walletAdapterBase.WalletReadyState.Loadable) {
113
+ throw new walletAdapterBase.WalletNotReadyError();
114
+ }
115
+ this._connecting = true;
116
+ const cachedAuthorizationResult = yield this._authorizationResultCache.get();
117
+ if (cachedAuthorizationResult) {
118
+ this._authorizationResult = cachedAuthorizationResult;
119
+ this._connecting = false;
120
+ if (this._readyState !== walletAdapterBase.WalletReadyState.Installed) {
121
+ this.emit('readyStateChange', (this._readyState = walletAdapterBase.WalletReadyState.Installed));
108
122
  }
109
- this.handleAuthorizationResult({
110
- auth_token,
111
- pub_key: base58PublicKey,
112
- wallet_uri_base: wallet_uri_base,
113
- }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
114
123
  this.emit('connect',
115
124
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
116
125
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
117
126
  this.publicKey);
118
- }));
119
- }
120
- catch (e) {
121
- throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
122
- }
123
- finally {
124
- this._connecting = false;
125
- }
127
+ return;
128
+ }
129
+ try {
130
+ yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
131
+ const authorizationResult = yield wallet.authorize({
132
+ cluster: this._cluster,
133
+ identity: this._appIdentity,
134
+ });
135
+ this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
136
+ }));
137
+ }
138
+ catch (e) {
139
+ throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
140
+ }
141
+ finally {
142
+ this._connecting = false;
143
+ }
144
+ }));
126
145
  });
127
146
  }
128
147
  handleAuthorizationResult(authorizationResult) {
148
+ var _a;
129
149
  return __awaiter(this, void 0, void 0, function* () {
150
+ const didPublicKeyChange = ((_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.addresses[0]) !== authorizationResult.addresses[0]; // TODO(#44): support multiple addresses
130
151
  this._authorizationResult = authorizationResult;
152
+ if (didPublicKeyChange) {
153
+ delete this._publicKey;
154
+ this.emit('connect',
155
+ // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
156
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157
+ this.publicKey);
158
+ }
131
159
  yield this._authorizationResultCache.set(authorizationResult);
132
160
  });
133
161
  }
134
- performReauthorization(walletAPI, currentAuthorizationResult) {
162
+ performReauthorization(wallet, currentAuthorizationResult) {
135
163
  return __awaiter(this, void 0, void 0, function* () {
136
164
  try {
137
- const { auth_token } = yield walletAPI('reauthorize', {
165
+ const authorizationResult = yield wallet.reauthorize({
138
166
  auth_token: currentAuthorizationResult.auth_token,
139
167
  });
140
- if (currentAuthorizationResult.auth_token !== auth_token) {
141
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
142
- }
143
- return auth_token;
168
+ this.handleAuthorizationResult(authorizationResult); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
144
169
  }
145
170
  catch (e) {
146
171
  this.disconnect();
@@ -172,39 +197,31 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
172
197
  }
173
198
  performSignTransactions(transactions) {
174
199
  return __awaiter(this, void 0, void 0, function* () {
200
+ const authorizationResult = this.assertIsAuthorized();
175
201
  try {
176
- const authorizationResult = this.assertIsAuthorized();
177
- try {
178
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
179
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
180
- const signedTransactions = yield walletAPI('sign_transaction', {
181
- auth_token: freshAuthToken,
182
- transactions,
183
- });
184
- return signedTransactions;
185
- }));
186
- }
187
- catch (error) {
188
- throw new walletAdapterBase.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
189
- }
202
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
203
+ yield this.performReauthorization(wallet, authorizationResult);
204
+ const signedTransactions = yield wallet.signTransactions({
205
+ transactions,
206
+ });
207
+ return signedTransactions;
208
+ }));
190
209
  }
191
210
  catch (error) {
192
- this.emit('error', error);
193
- throw error;
211
+ throw new walletAdapterBase.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
194
212
  }
195
213
  });
196
214
  }
197
215
  sendTransaction(transaction, connection, _options) {
198
216
  return __awaiter(this, void 0, void 0, function* () {
199
- try {
217
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
200
218
  const authorizationResult = this.assertIsAuthorized();
201
219
  try {
202
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
203
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
204
- const signatures = yield walletAPI('sign_and_send_transaction', {
205
- auth_token: freshAuthToken,
206
- fee_payer: this.publicKey || undefined,
220
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
221
+ yield this.performReauthorization(wallet, authorizationResult);
222
+ const signatures = yield wallet.signAndSendTransactions({
207
223
  connection,
224
+ fee_payer: transaction.feePayer,
208
225
  transactions: [transaction],
209
226
  });
210
227
  return signatures[0];
@@ -213,34 +230,33 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
213
230
  catch (error) {
214
231
  throw new walletAdapterBase.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
215
232
  }
216
- }
217
- catch (error) {
218
- this.emit('error', error);
219
- throw error;
220
- }
233
+ }));
221
234
  });
222
235
  }
223
236
  signTransaction(transaction) {
224
237
  return __awaiter(this, void 0, void 0, function* () {
225
- const [signedTransaction] = yield this.performSignTransactions([transaction]);
226
- return signedTransaction;
238
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
239
+ const [signedTransaction] = yield this.performSignTransactions([transaction]);
240
+ return signedTransaction;
241
+ }));
227
242
  });
228
243
  }
229
244
  signAllTransactions(transactions) {
230
245
  return __awaiter(this, void 0, void 0, function* () {
231
- const signedTransactions = yield this.performSignTransactions(transactions);
232
- return signedTransactions;
246
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
247
+ const signedTransactions = yield this.performSignTransactions(transactions);
248
+ return signedTransactions;
249
+ }));
233
250
  });
234
251
  }
235
252
  signMessage(message) {
236
253
  return __awaiter(this, void 0, void 0, function* () {
237
- try {
254
+ return yield this.runWithGuard(() => __awaiter(this, void 0, void 0, function* () {
238
255
  const authorizationResult = this.assertIsAuthorized();
239
256
  try {
240
- return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
241
- const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
242
- const [signedMessage] = yield walletAPI('sign_message', {
243
- auth_token: freshAuthToken,
257
+ return yield this.transact((wallet) => __awaiter(this, void 0, void 0, function* () {
258
+ yield this.performReauthorization(wallet, authorizationResult);
259
+ const [signedMessage] = yield wallet.signMessages({
244
260
  payloads: [message],
245
261
  });
246
262
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
@@ -250,11 +266,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
250
266
  catch (error) {
251
267
  throw new walletAdapterBase.WalletSignMessageError(error === null || error === void 0 ? void 0 : error.message, error);
252
268
  }
253
- }
254
- catch (error) {
255
- this.emit('error', error);
256
- throw error;
257
- }
269
+ }));
258
270
  });
259
271
  }
260
272
  }