@solana-mobile/wallet-adapter-mobile 0.0.1-alpha.2 → 0.0.1-alpha.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
6
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
7
7
  var web3_js = require('@solana/web3.js');
8
8
 
@@ -40,15 +40,6 @@ function getIsSupported() {
40
40
 
41
41
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
42
42
  const SIGNATURE_LENGTH_IN_BYTES = 64;
43
- function getBase64StringFromByteArray(byteArray) {
44
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
45
- }
46
- function getByteArrayFromBase64String(base64EncodedByteArray) {
47
- return new Uint8Array(window
48
- .atob(base64EncodedByteArray)
49
- .split('')
50
- .map((c) => c.charCodeAt(0)));
51
- }
52
43
  class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalletAdapter {
53
44
  constructor(config) {
54
45
  super();
@@ -72,7 +63,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
72
63
  }
73
64
  get publicKey() {
74
65
  if (this._publicKey == null && this._authorizationResult != null) {
75
- this._publicKey = new web3_js.PublicKey(this._authorizationResult.publicKey);
66
+ this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
76
67
  }
77
68
  return this._publicKey ? this._publicKey : null;
78
69
  }
@@ -107,8 +98,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
107
98
  return;
108
99
  }
109
100
  try {
110
- yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
111
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield mobileWallet('authorize', { identity: this._appIdentity });
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 });
112
103
  try {
113
104
  this._publicKey = new web3_js.PublicKey(base58PublicKey);
114
105
  }
@@ -116,9 +107,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
116
107
  throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
117
108
  }
118
109
  this.handleAuthorizationResult({
119
- authToken: auth_token,
120
- publicKey: base58PublicKey,
121
- walletUriBase: wallet_uri_base,
110
+ auth_token,
111
+ pub_key: base58PublicKey,
112
+ wallet_uri_base: wallet_uri_base,
122
113
  }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
123
114
  this.emit('connect',
124
115
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
@@ -140,14 +131,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
140
131
  yield this._authorizationResultCache.set(authorizationResult);
141
132
  });
142
133
  }
143
- performReauthorization(mobileWallet, currentAuthorizationResult) {
134
+ performReauthorization(walletAPI, currentAuthorizationResult) {
144
135
  return __awaiter(this, void 0, void 0, function* () {
145
136
  try {
146
- const { auth_token } = yield mobileWallet('reauthorize', {
147
- auth_token: currentAuthorizationResult.authToken,
137
+ const { auth_token } = yield walletAPI('reauthorize', {
138
+ auth_token: currentAuthorizationResult.auth_token,
148
139
  });
149
- if (currentAuthorizationResult.authToken !== auth_token) {
150
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { authToken: auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
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
151
142
  }
152
143
  return auth_token;
153
144
  }
@@ -165,12 +156,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
165
156
  this.emit('disconnect');
166
157
  });
167
158
  }
168
- withWallet(callback) {
159
+ transact(callback) {
169
160
  var _a;
170
161
  return __awaiter(this, void 0, void 0, function* () {
171
- const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.walletUriBase;
162
+ const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
172
163
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
173
- return yield mobileWalletAdapterProtocol.withLocalWallet(callback, config);
164
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
174
165
  });
175
166
  }
176
167
  assertIsAuthorized() {
@@ -184,17 +175,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
184
175
  try {
185
176
  const authorizationResult = this.assertIsAuthorized();
186
177
  try {
187
- const serializedTransactions = transactions.map((transaction) => transaction.serialize({
188
- requireAllSignatures: false,
189
- verifySignatures: false,
190
- }));
191
- const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
192
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
193
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
194
- const { signed_payloads: base64EncodedCompiledTransactions } = yield mobileWallet('sign_transaction', { auth_token: freshAuthToken, payloads });
195
- const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
196
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
197
- return transactions;
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;
198
185
  }));
199
186
  }
200
187
  catch (error) {
@@ -212,34 +199,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
212
199
  try {
213
200
  const authorizationResult = this.assertIsAuthorized();
214
201
  try {
215
- if (transaction.feePayer == null) {
216
- transaction.feePayer = this.publicKey || undefined;
217
- }
218
- if (transaction.recentBlockhash == null) {
219
- const { blockhash } = yield connection.getRecentBlockhash(connection.commitment);
220
- transaction.recentBlockhash = blockhash;
221
- }
222
- const serializedTransaction = transaction.serialize({
223
- requireAllSignatures: false,
224
- verifySignatures: false,
225
- });
226
- const payloads = [serializedTransaction.toString('base64')];
227
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
228
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
229
- let targetCommitment;
230
- switch (connection.commitment) {
231
- case 'confirmed':
232
- case 'finalized':
233
- case 'processed':
234
- targetCommitment = connection.commitment;
235
- break;
236
- default:
237
- targetCommitment = 'finalized';
238
- }
239
- const { signatures } = yield mobileWallet('sign_and_send_transaction', {
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', {
240
205
  auth_token: freshAuthToken,
241
- commitment: targetCommitment,
242
- payloads,
206
+ fee_payer: this.publicKey || undefined,
207
+ connection,
208
+ transactions: [transaction],
243
209
  });
244
210
  return signatures[0];
245
211
  }));
@@ -271,13 +237,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
271
237
  try {
272
238
  const authorizationResult = this.assertIsAuthorized();
273
239
  try {
274
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
275
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
276
- const { signed_payloads: [base64EncodedSignedMessage], } = yield mobileWallet('sign_message', {
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', {
277
243
  auth_token: freshAuthToken,
278
- payloads: [getBase64StringFromByteArray(message)],
244
+ payloads: [message],
279
245
  });
280
- const signedMessage = getByteArrayFromBase64String(base64EncodedSignedMessage);
281
246
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
282
247
  return signature;
283
248
  }));
package/lib/cjs/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
6
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
7
7
  var web3_js = require('@solana/web3.js');
8
8
 
@@ -40,15 +40,6 @@ function getIsSupported() {
40
40
 
41
41
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
42
42
  const SIGNATURE_LENGTH_IN_BYTES = 64;
43
- function getBase64StringFromByteArray(byteArray) {
44
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
45
- }
46
- function getByteArrayFromBase64String(base64EncodedByteArray) {
47
- return new Uint8Array(window
48
- .atob(base64EncodedByteArray)
49
- .split('')
50
- .map((c) => c.charCodeAt(0)));
51
- }
52
43
  class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalletAdapter {
53
44
  constructor(config) {
54
45
  super();
@@ -72,7 +63,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
72
63
  }
73
64
  get publicKey() {
74
65
  if (this._publicKey == null && this._authorizationResult != null) {
75
- this._publicKey = new web3_js.PublicKey(this._authorizationResult.publicKey);
66
+ this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
76
67
  }
77
68
  return this._publicKey ? this._publicKey : null;
78
69
  }
@@ -107,8 +98,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
107
98
  return;
108
99
  }
109
100
  try {
110
- yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
111
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield mobileWallet('authorize', { identity: this._appIdentity });
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 });
112
103
  try {
113
104
  this._publicKey = new web3_js.PublicKey(base58PublicKey);
114
105
  }
@@ -116,9 +107,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
116
107
  throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
117
108
  }
118
109
  this.handleAuthorizationResult({
119
- authToken: auth_token,
120
- publicKey: base58PublicKey,
121
- walletUriBase: wallet_uri_base,
110
+ auth_token,
111
+ pub_key: base58PublicKey,
112
+ wallet_uri_base: wallet_uri_base,
122
113
  }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
123
114
  this.emit('connect',
124
115
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
@@ -140,14 +131,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
140
131
  yield this._authorizationResultCache.set(authorizationResult);
141
132
  });
142
133
  }
143
- performReauthorization(mobileWallet, currentAuthorizationResult) {
134
+ performReauthorization(walletAPI, currentAuthorizationResult) {
144
135
  return __awaiter(this, void 0, void 0, function* () {
145
136
  try {
146
- const { auth_token } = yield mobileWallet('reauthorize', {
147
- auth_token: currentAuthorizationResult.authToken,
137
+ const { auth_token } = yield walletAPI('reauthorize', {
138
+ auth_token: currentAuthorizationResult.auth_token,
148
139
  });
149
- if (currentAuthorizationResult.authToken !== auth_token) {
150
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { authToken: auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
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
151
142
  }
152
143
  return auth_token;
153
144
  }
@@ -165,12 +156,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
165
156
  this.emit('disconnect');
166
157
  });
167
158
  }
168
- withWallet(callback) {
159
+ transact(callback) {
169
160
  var _a;
170
161
  return __awaiter(this, void 0, void 0, function* () {
171
- const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.walletUriBase;
162
+ const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
172
163
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
173
- return yield mobileWalletAdapterProtocol.withLocalWallet(callback, config);
164
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
174
165
  });
175
166
  }
176
167
  assertIsAuthorized() {
@@ -184,17 +175,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
184
175
  try {
185
176
  const authorizationResult = this.assertIsAuthorized();
186
177
  try {
187
- const serializedTransactions = transactions.map((transaction) => transaction.serialize({
188
- requireAllSignatures: false,
189
- verifySignatures: false,
190
- }));
191
- const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
192
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
193
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
194
- const { signed_payloads: base64EncodedCompiledTransactions } = yield mobileWallet('sign_transaction', { auth_token: freshAuthToken, payloads });
195
- const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
196
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
197
- return transactions;
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;
198
185
  }));
199
186
  }
200
187
  catch (error) {
@@ -212,34 +199,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
212
199
  try {
213
200
  const authorizationResult = this.assertIsAuthorized();
214
201
  try {
215
- if (transaction.feePayer == null) {
216
- transaction.feePayer = this.publicKey || undefined;
217
- }
218
- if (transaction.recentBlockhash == null) {
219
- const { blockhash } = yield connection.getRecentBlockhash(connection.commitment);
220
- transaction.recentBlockhash = blockhash;
221
- }
222
- const serializedTransaction = transaction.serialize({
223
- requireAllSignatures: false,
224
- verifySignatures: false,
225
- });
226
- const payloads = [serializedTransaction.toString('base64')];
227
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
228
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
229
- let targetCommitment;
230
- switch (connection.commitment) {
231
- case 'confirmed':
232
- case 'finalized':
233
- case 'processed':
234
- targetCommitment = connection.commitment;
235
- break;
236
- default:
237
- targetCommitment = 'finalized';
238
- }
239
- const { signatures } = yield mobileWallet('sign_and_send_transaction', {
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', {
240
205
  auth_token: freshAuthToken,
241
- commitment: targetCommitment,
242
- payloads,
206
+ fee_payer: this.publicKey || undefined,
207
+ connection,
208
+ transactions: [transaction],
243
209
  });
244
210
  return signatures[0];
245
211
  }));
@@ -271,13 +237,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
271
237
  try {
272
238
  const authorizationResult = this.assertIsAuthorized();
273
239
  try {
274
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
275
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
276
- const { signed_payloads: [base64EncodedSignedMessage], } = yield mobileWallet('sign_message', {
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', {
277
243
  auth_token: freshAuthToken,
278
- payloads: [getBase64StringFromByteArray(message)],
244
+ payloads: [message],
279
245
  });
280
- const signedMessage = getByteArrayFromBase64String(base64EncodedSignedMessage);
281
246
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
282
247
  return signature;
283
248
  }));
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
5
+ var mobileWalletAdapterProtocolWeb3js = require('@solana-mobile/mobile-wallet-adapter-protocol-web3js');
6
6
  var walletAdapterBase = require('@solana/wallet-adapter-base');
7
7
  var web3_js = require('@solana/web3.js');
8
8
  var reactNative = require('react-native');
@@ -43,15 +43,6 @@ function getIsSupported() {
43
43
 
44
44
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
45
45
  const SIGNATURE_LENGTH_IN_BYTES = 64;
46
- function getBase64StringFromByteArray(byteArray) {
47
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
48
- }
49
- function getByteArrayFromBase64String(base64EncodedByteArray) {
50
- return new Uint8Array(window
51
- .atob(base64EncodedByteArray)
52
- .split('')
53
- .map((c) => c.charCodeAt(0)));
54
- }
55
46
  class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalletAdapter {
56
47
  constructor(config) {
57
48
  super();
@@ -75,7 +66,7 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
75
66
  }
76
67
  get publicKey() {
77
68
  if (this._publicKey == null && this._authorizationResult != null) {
78
- this._publicKey = new web3_js.PublicKey(this._authorizationResult.publicKey);
69
+ this._publicKey = new web3_js.PublicKey(this._authorizationResult.pub_key);
79
70
  }
80
71
  return this._publicKey ? this._publicKey : null;
81
72
  }
@@ -110,8 +101,8 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
110
101
  return;
111
102
  }
112
103
  try {
113
- yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
114
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield mobileWallet('authorize', { identity: this._appIdentity });
104
+ yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
105
+ const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield walletAPI('authorize', { identity: this._appIdentity });
115
106
  try {
116
107
  this._publicKey = new web3_js.PublicKey(base58PublicKey);
117
108
  }
@@ -119,9 +110,9 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
119
110
  throw new walletAdapterBase.WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
120
111
  }
121
112
  this.handleAuthorizationResult({
122
- authToken: auth_token,
123
- publicKey: base58PublicKey,
124
- walletUriBase: wallet_uri_base,
113
+ auth_token,
114
+ pub_key: base58PublicKey,
115
+ wallet_uri_base: wallet_uri_base,
125
116
  }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
126
117
  this.emit('connect',
127
118
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
@@ -143,14 +134,14 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
143
134
  yield this._authorizationResultCache.set(authorizationResult);
144
135
  });
145
136
  }
146
- performReauthorization(mobileWallet, currentAuthorizationResult) {
137
+ performReauthorization(walletAPI, currentAuthorizationResult) {
147
138
  return __awaiter(this, void 0, void 0, function* () {
148
139
  try {
149
- const { auth_token } = yield mobileWallet('reauthorize', {
150
- auth_token: currentAuthorizationResult.authToken,
140
+ const { auth_token } = yield walletAPI('reauthorize', {
141
+ auth_token: currentAuthorizationResult.auth_token,
151
142
  });
152
- if (currentAuthorizationResult.authToken !== auth_token) {
153
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { authToken: auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
143
+ if (currentAuthorizationResult.auth_token !== auth_token) {
144
+ this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
154
145
  }
155
146
  return auth_token;
156
147
  }
@@ -168,12 +159,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
168
159
  this.emit('disconnect');
169
160
  });
170
161
  }
171
- withWallet(callback) {
162
+ transact(callback) {
172
163
  var _a;
173
164
  return __awaiter(this, void 0, void 0, function* () {
174
- const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.walletUriBase;
165
+ const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
175
166
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
176
- return yield mobileWalletAdapterProtocol.withLocalWallet(callback, config);
167
+ return yield mobileWalletAdapterProtocolWeb3js.transact(callback, config);
177
168
  });
178
169
  }
179
170
  assertIsAuthorized() {
@@ -187,17 +178,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
187
178
  try {
188
179
  const authorizationResult = this.assertIsAuthorized();
189
180
  try {
190
- const serializedTransactions = transactions.map((transaction) => transaction.serialize({
191
- requireAllSignatures: false,
192
- verifySignatures: false,
193
- }));
194
- const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
195
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
196
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
197
- const { signed_payloads: base64EncodedCompiledTransactions } = yield mobileWallet('sign_transaction', { auth_token: freshAuthToken, payloads });
198
- const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
199
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
200
- return transactions;
181
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
182
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
183
+ const signedTransactions = yield walletAPI('sign_transaction', {
184
+ auth_token: freshAuthToken,
185
+ transactions,
186
+ });
187
+ return signedTransactions;
201
188
  }));
202
189
  }
203
190
  catch (error) {
@@ -215,34 +202,13 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
215
202
  try {
216
203
  const authorizationResult = this.assertIsAuthorized();
217
204
  try {
218
- if (transaction.feePayer == null) {
219
- transaction.feePayer = this.publicKey || undefined;
220
- }
221
- if (transaction.recentBlockhash == null) {
222
- const { blockhash } = yield connection.getRecentBlockhash(connection.commitment);
223
- transaction.recentBlockhash = blockhash;
224
- }
225
- const serializedTransaction = transaction.serialize({
226
- requireAllSignatures: false,
227
- verifySignatures: false,
228
- });
229
- const payloads = [serializedTransaction.toString('base64')];
230
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
231
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
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
- const { signatures } = yield mobileWallet('sign_and_send_transaction', {
205
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
206
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
207
+ const signatures = yield walletAPI('sign_and_send_transaction', {
243
208
  auth_token: freshAuthToken,
244
- commitment: targetCommitment,
245
- payloads,
209
+ fee_payer: this.publicKey || undefined,
210
+ connection,
211
+ transactions: [transaction],
246
212
  });
247
213
  return signatures[0];
248
214
  }));
@@ -274,13 +240,12 @@ class SolanaMobileWalletAdapter extends walletAdapterBase.BaseMessageSignerWalle
274
240
  try {
275
241
  const authorizationResult = this.assertIsAuthorized();
276
242
  try {
277
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
278
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
279
- const { signed_payloads: [base64EncodedSignedMessage], } = yield mobileWallet('sign_message', {
243
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
244
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
245
+ const [signedMessage] = yield walletAPI('sign_message', {
280
246
  auth_token: freshAuthToken,
281
- payloads: [getBase64StringFromByteArray(message)],
247
+ payloads: [message],
282
248
  });
283
- const signedMessage = getByteArrayFromBase64String(base64EncodedSignedMessage);
284
249
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
285
250
  return signature;
286
251
  }));
@@ -1,6 +1,6 @@
1
- import { withLocalWallet } from '@solana-mobile/mobile-wallet-adapter-protocol';
1
+ import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
2
2
  import { BaseMessageSignerWalletAdapter, WalletReadyState, WalletNotReadyError, WalletPublicKeyError, WalletConnectionError, WalletDisconnectedError, WalletNotConnectedError, WalletSignTransactionError, WalletSendTransactionError, WalletSignMessageError } from '@solana/wallet-adapter-base';
3
- import { PublicKey, Transaction } from '@solana/web3.js';
3
+ import { PublicKey } from '@solana/web3.js';
4
4
 
5
5
  /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
@@ -36,15 +36,6 @@ function getIsSupported() {
36
36
 
37
37
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
38
38
  const SIGNATURE_LENGTH_IN_BYTES = 64;
39
- function getBase64StringFromByteArray(byteArray) {
40
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
41
- }
42
- function getByteArrayFromBase64String(base64EncodedByteArray) {
43
- return new Uint8Array(window
44
- .atob(base64EncodedByteArray)
45
- .split('')
46
- .map((c) => c.charCodeAt(0)));
47
- }
48
39
  class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
49
40
  constructor(config) {
50
41
  super();
@@ -68,7 +59,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
68
59
  }
69
60
  get publicKey() {
70
61
  if (this._publicKey == null && this._authorizationResult != null) {
71
- this._publicKey = new PublicKey(this._authorizationResult.publicKey);
62
+ this._publicKey = new PublicKey(this._authorizationResult.pub_key);
72
63
  }
73
64
  return this._publicKey ? this._publicKey : null;
74
65
  }
@@ -103,8 +94,8 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
103
94
  return;
104
95
  }
105
96
  try {
106
- yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
107
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield mobileWallet('authorize', { identity: this._appIdentity });
97
+ yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
98
+ const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield walletAPI('authorize', { identity: this._appIdentity });
108
99
  try {
109
100
  this._publicKey = new PublicKey(base58PublicKey);
110
101
  }
@@ -112,9 +103,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
112
103
  throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
113
104
  }
114
105
  this.handleAuthorizationResult({
115
- authToken: auth_token,
116
- publicKey: base58PublicKey,
117
- walletUriBase: wallet_uri_base,
106
+ auth_token,
107
+ pub_key: base58PublicKey,
108
+ wallet_uri_base: wallet_uri_base,
118
109
  }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
119
110
  this.emit('connect',
120
111
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
@@ -136,14 +127,14 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
136
127
  yield this._authorizationResultCache.set(authorizationResult);
137
128
  });
138
129
  }
139
- performReauthorization(mobileWallet, currentAuthorizationResult) {
130
+ performReauthorization(walletAPI, currentAuthorizationResult) {
140
131
  return __awaiter(this, void 0, void 0, function* () {
141
132
  try {
142
- const { auth_token } = yield mobileWallet('reauthorize', {
143
- auth_token: currentAuthorizationResult.authToken,
133
+ const { auth_token } = yield walletAPI('reauthorize', {
134
+ auth_token: currentAuthorizationResult.auth_token,
144
135
  });
145
- if (currentAuthorizationResult.authToken !== auth_token) {
146
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { authToken: auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
136
+ if (currentAuthorizationResult.auth_token !== auth_token) {
137
+ this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
147
138
  }
148
139
  return auth_token;
149
140
  }
@@ -161,12 +152,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
161
152
  this.emit('disconnect');
162
153
  });
163
154
  }
164
- withWallet(callback) {
155
+ transact(callback) {
165
156
  var _a;
166
157
  return __awaiter(this, void 0, void 0, function* () {
167
- const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.walletUriBase;
158
+ const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
168
159
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
169
- return yield withLocalWallet(callback, config);
160
+ return yield transact(callback, config);
170
161
  });
171
162
  }
172
163
  assertIsAuthorized() {
@@ -180,17 +171,13 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
180
171
  try {
181
172
  const authorizationResult = this.assertIsAuthorized();
182
173
  try {
183
- const serializedTransactions = transactions.map((transaction) => transaction.serialize({
184
- requireAllSignatures: false,
185
- verifySignatures: false,
186
- }));
187
- const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
188
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
189
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
190
- const { signed_payloads: base64EncodedCompiledTransactions } = yield mobileWallet('sign_transaction', { auth_token: freshAuthToken, payloads });
191
- const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
192
- const transactions = compiledTransactions.map(Transaction.from);
193
- return transactions;
174
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
175
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
176
+ const signedTransactions = yield walletAPI('sign_transaction', {
177
+ auth_token: freshAuthToken,
178
+ transactions,
179
+ });
180
+ return signedTransactions;
194
181
  }));
195
182
  }
196
183
  catch (error) {
@@ -208,34 +195,13 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
208
195
  try {
209
196
  const authorizationResult = this.assertIsAuthorized();
210
197
  try {
211
- if (transaction.feePayer == null) {
212
- transaction.feePayer = this.publicKey || undefined;
213
- }
214
- if (transaction.recentBlockhash == null) {
215
- const { blockhash } = yield connection.getRecentBlockhash(connection.commitment);
216
- transaction.recentBlockhash = blockhash;
217
- }
218
- const serializedTransaction = transaction.serialize({
219
- requireAllSignatures: false,
220
- verifySignatures: false,
221
- });
222
- const payloads = [serializedTransaction.toString('base64')];
223
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
224
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
225
- let targetCommitment;
226
- switch (connection.commitment) {
227
- case 'confirmed':
228
- case 'finalized':
229
- case 'processed':
230
- targetCommitment = connection.commitment;
231
- break;
232
- default:
233
- targetCommitment = 'finalized';
234
- }
235
- const { signatures } = yield mobileWallet('sign_and_send_transaction', {
198
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
199
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
200
+ const signatures = yield walletAPI('sign_and_send_transaction', {
236
201
  auth_token: freshAuthToken,
237
- commitment: targetCommitment,
238
- payloads,
202
+ fee_payer: this.publicKey || undefined,
203
+ connection,
204
+ transactions: [transaction],
239
205
  });
240
206
  return signatures[0];
241
207
  }));
@@ -267,13 +233,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
267
233
  try {
268
234
  const authorizationResult = this.assertIsAuthorized();
269
235
  try {
270
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
271
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
272
- const { signed_payloads: [base64EncodedSignedMessage], } = yield mobileWallet('sign_message', {
236
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
237
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
238
+ const [signedMessage] = yield walletAPI('sign_message', {
273
239
  auth_token: freshAuthToken,
274
- payloads: [getBase64StringFromByteArray(message)],
240
+ payloads: [message],
275
241
  });
276
- const signedMessage = getByteArrayFromBase64String(base64EncodedSignedMessage);
277
242
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
278
243
  return signature;
279
244
  }));
package/lib/esm/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { withLocalWallet } from '@solana-mobile/mobile-wallet-adapter-protocol';
1
+ import { transact } from '@solana-mobile/mobile-wallet-adapter-protocol-web3js';
2
2
  import { BaseMessageSignerWalletAdapter, WalletReadyState, WalletNotReadyError, WalletPublicKeyError, WalletConnectionError, WalletDisconnectedError, WalletNotConnectedError, WalletSignTransactionError, WalletSendTransactionError, WalletSignMessageError } from '@solana/wallet-adapter-base';
3
- import { PublicKey, Transaction } from '@solana/web3.js';
3
+ import { PublicKey } from '@solana/web3.js';
4
4
 
5
5
  /******************************************************************************
6
6
  Copyright (c) Microsoft Corporation.
@@ -36,15 +36,6 @@ function getIsSupported() {
36
36
 
37
37
  const SolanaMobileWalletAdapterWalletName = 'Default wallet app';
38
38
  const SIGNATURE_LENGTH_IN_BYTES = 64;
39
- function getBase64StringFromByteArray(byteArray) {
40
- return window.btoa(String.fromCharCode.call(null, ...byteArray));
41
- }
42
- function getByteArrayFromBase64String(base64EncodedByteArray) {
43
- return new Uint8Array(window
44
- .atob(base64EncodedByteArray)
45
- .split('')
46
- .map((c) => c.charCodeAt(0)));
47
- }
48
39
  class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
49
40
  constructor(config) {
50
41
  super();
@@ -68,7 +59,7 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
68
59
  }
69
60
  get publicKey() {
70
61
  if (this._publicKey == null && this._authorizationResult != null) {
71
- this._publicKey = new PublicKey(this._authorizationResult.publicKey);
62
+ this._publicKey = new PublicKey(this._authorizationResult.pub_key);
72
63
  }
73
64
  return this._publicKey ? this._publicKey : null;
74
65
  }
@@ -103,8 +94,8 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
103
94
  return;
104
95
  }
105
96
  try {
106
- yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
107
- const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield mobileWallet('authorize', { identity: this._appIdentity });
97
+ yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
98
+ const { auth_token, pub_key: base58PublicKey, wallet_uri_base, } = yield walletAPI('authorize', { identity: this._appIdentity });
108
99
  try {
109
100
  this._publicKey = new PublicKey(base58PublicKey);
110
101
  }
@@ -112,9 +103,9 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
112
103
  throw new WalletPublicKeyError((e instanceof Error && (e === null || e === void 0 ? void 0 : e.message)) || 'Unknown error', e);
113
104
  }
114
105
  this.handleAuthorizationResult({
115
- authToken: auth_token,
116
- publicKey: base58PublicKey,
117
- walletUriBase: wallet_uri_base,
106
+ auth_token,
107
+ pub_key: base58PublicKey,
108
+ wallet_uri_base: wallet_uri_base,
118
109
  }); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
119
110
  this.emit('connect',
120
111
  // Having just set an `authorizationResult`, `this.publicKey` is definitely non-null
@@ -136,14 +127,14 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
136
127
  yield this._authorizationResultCache.set(authorizationResult);
137
128
  });
138
129
  }
139
- performReauthorization(mobileWallet, currentAuthorizationResult) {
130
+ performReauthorization(walletAPI, currentAuthorizationResult) {
140
131
  return __awaiter(this, void 0, void 0, function* () {
141
132
  try {
142
- const { auth_token } = yield mobileWallet('reauthorize', {
143
- auth_token: currentAuthorizationResult.authToken,
133
+ const { auth_token } = yield walletAPI('reauthorize', {
134
+ auth_token: currentAuthorizationResult.auth_token,
144
135
  });
145
- if (currentAuthorizationResult.authToken !== auth_token) {
146
- this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { authToken: auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
136
+ if (currentAuthorizationResult.auth_token !== auth_token) {
137
+ this.handleAuthorizationResult(Object.assign(Object.assign({}, currentAuthorizationResult), { auth_token })); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
147
138
  }
148
139
  return auth_token;
149
140
  }
@@ -161,12 +152,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
161
152
  this.emit('disconnect');
162
153
  });
163
154
  }
164
- withWallet(callback) {
155
+ transact(callback) {
165
156
  var _a;
166
157
  return __awaiter(this, void 0, void 0, function* () {
167
- const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.walletUriBase;
158
+ const walletUriBase = (_a = this._authorizationResult) === null || _a === void 0 ? void 0 : _a.wallet_uri_base;
168
159
  const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
169
- return yield withLocalWallet(callback, config);
160
+ return yield transact(callback, config);
170
161
  });
171
162
  }
172
163
  assertIsAuthorized() {
@@ -180,17 +171,13 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
180
171
  try {
181
172
  const authorizationResult = this.assertIsAuthorized();
182
173
  try {
183
- const serializedTransactions = transactions.map((transaction) => transaction.serialize({
184
- requireAllSignatures: false,
185
- verifySignatures: false,
186
- }));
187
- const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
188
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
189
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
190
- const { signed_payloads: base64EncodedCompiledTransactions } = yield mobileWallet('sign_transaction', { auth_token: freshAuthToken, payloads });
191
- const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
192
- const transactions = compiledTransactions.map(Transaction.from);
193
- return transactions;
174
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
175
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
176
+ const signedTransactions = yield walletAPI('sign_transaction', {
177
+ auth_token: freshAuthToken,
178
+ transactions,
179
+ });
180
+ return signedTransactions;
194
181
  }));
195
182
  }
196
183
  catch (error) {
@@ -208,34 +195,13 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
208
195
  try {
209
196
  const authorizationResult = this.assertIsAuthorized();
210
197
  try {
211
- if (transaction.feePayer == null) {
212
- transaction.feePayer = this.publicKey || undefined;
213
- }
214
- if (transaction.recentBlockhash == null) {
215
- const { blockhash } = yield connection.getRecentBlockhash(connection.commitment);
216
- transaction.recentBlockhash = blockhash;
217
- }
218
- const serializedTransaction = transaction.serialize({
219
- requireAllSignatures: false,
220
- verifySignatures: false,
221
- });
222
- const payloads = [serializedTransaction.toString('base64')];
223
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
224
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
225
- let targetCommitment;
226
- switch (connection.commitment) {
227
- case 'confirmed':
228
- case 'finalized':
229
- case 'processed':
230
- targetCommitment = connection.commitment;
231
- break;
232
- default:
233
- targetCommitment = 'finalized';
234
- }
235
- const { signatures } = yield mobileWallet('sign_and_send_transaction', {
198
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
199
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
200
+ const signatures = yield walletAPI('sign_and_send_transaction', {
236
201
  auth_token: freshAuthToken,
237
- commitment: targetCommitment,
238
- payloads,
202
+ fee_payer: this.publicKey || undefined,
203
+ connection,
204
+ transactions: [transaction],
239
205
  });
240
206
  return signatures[0];
241
207
  }));
@@ -267,13 +233,12 @@ class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
267
233
  try {
268
234
  const authorizationResult = this.assertIsAuthorized();
269
235
  try {
270
- return yield this.withWallet((mobileWallet) => __awaiter(this, void 0, void 0, function* () {
271
- const freshAuthToken = yield this.performReauthorization(mobileWallet, authorizationResult);
272
- const { signed_payloads: [base64EncodedSignedMessage], } = yield mobileWallet('sign_message', {
236
+ return yield this.transact((walletAPI) => __awaiter(this, void 0, void 0, function* () {
237
+ const freshAuthToken = yield this.performReauthorization(walletAPI, authorizationResult);
238
+ const [signedMessage] = yield walletAPI('sign_message', {
273
239
  auth_token: freshAuthToken,
274
- payloads: [getBase64StringFromByteArray(message)],
240
+ payloads: [message],
275
241
  });
276
- const signedMessage = getByteArrayFromBase64String(base64EncodedSignedMessage);
277
242
  const signature = signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES);
278
243
  return signature;
279
244
  }));
@@ -29,7 +29,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
29
29
  private handleAuthorizationResult;
30
30
  private performReauthorization;
31
31
  disconnect(): Promise<void>;
32
- private withWallet;
32
+ private transact;
33
33
  private assertIsAuthorized;
34
34
  private performSignTransactions;
35
35
  sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
@@ -29,7 +29,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
29
29
  private handleAuthorizationResult;
30
30
  private performReauthorization;
31
31
  disconnect(): Promise<void>;
32
- private withWallet;
32
+ private transact;
33
33
  private assertIsAuthorized;
34
34
  private performSignTransactions;
35
35
  sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
@@ -29,7 +29,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
29
29
  private handleAuthorizationResult;
30
30
  private performReauthorization;
31
31
  disconnect(): Promise<void>;
32
- private withWallet;
32
+ private transact;
33
33
  private assertIsAuthorized;
34
34
  private performSignTransactions;
35
35
  sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
@@ -29,7 +29,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
29
29
  private handleAuthorizationResult;
30
30
  private performReauthorization;
31
31
  disconnect(): Promise<void>;
32
- private withWallet;
32
+ private transact;
33
33
  private assertIsAuthorized;
34
34
  private performSignTransactions;
35
35
  sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
@@ -29,7 +29,7 @@ declare class SolanaMobileWalletAdapter extends BaseMessageSignerWalletAdapter {
29
29
  private handleAuthorizationResult;
30
30
  private performReauthorization;
31
31
  disconnect(): Promise<void>;
32
- private withWallet;
32
+ private transact;
33
33
  private assertIsAuthorized;
34
34
  private performSignTransactions;
35
35
  sendTransaction(transaction: Transaction, connection: Connection, _options?: SendOptions): Promise<TransactionSignature>;
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.0.1-alpha.2",
4
+ "version": "0.0.1-alpha.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": "^0.0.1-alpha.1",
44
+ "@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^0.0.1-alpha.5",
45
45
  "@solana/wallet-adapter-base": "^0.9.8",
46
46
  "@solana/web3.js": "^1.20.0"
47
47
  },
@@ -49,5 +49,5 @@
49
49
  "agadoo": "^2.0.0",
50
50
  "shx": "^0.3.4"
51
51
  },
52
- "gitHead": "36b3d666b74d12f8121a892d0ea154d9a5ba1586"
52
+ "gitHead": "7df380859bd4a3e6acc4f4b7385e9604919c76a8"
53
53
  }