@solana-mobile/mobile-wallet-adapter-protocol-web3js 0.0.1-alpha.7 → 0.9.1

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.
@@ -4,8 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var web3_js = require('@solana/web3.js');
6
6
  var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
7
+ var bs58 = require('bs58');
7
8
 
8
- /******************************************************************************
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
12
+
13
+ /*! *****************************************************************************
9
14
  Copyright (c) Microsoft Corporation.
10
15
 
11
16
  Permission to use, copy, modify, and/or distribute this software for any
@@ -20,6 +25,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
25
  PERFORMANCE OF THIS SOFTWARE.
21
26
  ***************************************************************************** */
22
27
 
28
+ function __rest(s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ }
39
+
23
40
  function __awaiter(thisArg, _arguments, P, generator) {
24
41
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
42
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,81 +64,49 @@ function transact(callback, config) {
47
64
  get(target, p) {
48
65
  if (target[p] == null) {
49
66
  switch (p) {
50
- case 'signAndSendTransaction':
51
- target[p] = function (params) {
67
+ case 'signAndSendTransactions':
68
+ target[p] = function (_a) {
69
+ var { minContextSlot, transactions } = _a, rest = __rest(_a, ["minContextSlot", "transactions"]);
52
70
  return __awaiter(this, void 0, void 0, function* () {
53
- let latestBlockhashPromise;
54
- function getLatestBlockhash(connection) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (latestBlockhashPromise == null) {
57
- latestBlockhashPromise = connection.getLatestBlockhash({
58
- commitment: connection.commitment,
59
- });
60
- }
61
- return yield latestBlockhashPromise;
62
- });
63
- }
64
- const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
65
- if (transaction.feePayer == null) {
66
- transaction.feePayer = params.fee_payer;
67
- }
68
- if (transaction.recentBlockhash == null) {
69
- const { blockhash } = yield getLatestBlockhash(params.connection);
70
- transaction.recentBlockhash = blockhash;
71
- }
72
- const serializedTransaction = transaction.serialize({
71
+ const payloads = yield Promise.all(transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
72
+ const serializedTransaction = yield transaction.serialize({
73
73
  requireAllSignatures: false,
74
74
  verifySignatures: false,
75
75
  });
76
76
  return serializedTransaction.toString('base64');
77
77
  })));
78
- let targetCommitment;
79
- switch (params.connection.commitment) {
80
- case 'confirmed':
81
- case 'finalized':
82
- case 'processed':
83
- targetCommitment = params.connection.commitment;
84
- break;
85
- default:
86
- targetCommitment = 'finalized';
87
- }
88
- const { signatures } = yield wallet.signAndSendTransaction({
89
- auth_token: params.auth_token,
90
- commitment: targetCommitment,
91
- payloads,
92
- });
78
+ const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (minContextSlot != null
79
+ ? { options: { min_context_slot: minContextSlot } }
80
+ : null)), { payloads }));
81
+ const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
93
82
  return signatures;
94
83
  });
95
84
  };
96
85
  break;
97
- case 'signMessage':
98
- target[p] = function (params) {
86
+ case 'signMessages':
87
+ target[p] = function (_a) {
88
+ var { payloads } = _a, rest = __rest(_a, ["payloads"]);
99
89
  return __awaiter(this, void 0, void 0, function* () {
100
- const payloads = params.payloads.map(fromUint8Array);
101
- const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
102
- auth_token: params.auth_token,
103
- payloads,
104
- });
90
+ const base64EncodedPayloads = payloads.map(fromUint8Array);
91
+ const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
105
92
  const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
106
93
  return signedMessages;
107
94
  });
108
95
  };
109
96
  break;
110
- case 'signTransaction':
111
- target[p] = function (params) {
97
+ case 'signTransactions':
98
+ target[p] = function (_a) {
99
+ var { transactions } = _a, rest = __rest(_a, ["transactions"]);
112
100
  return __awaiter(this, void 0, void 0, function* () {
113
- const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
101
+ const serializedTransactions = transactions.map((transaction) => transaction.serialize({
114
102
  requireAllSignatures: false,
115
103
  verifySignatures: false,
116
104
  }));
117
105
  const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
118
- const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
119
- auth_token: params.auth_token,
120
- payloads,
121
- });
106
+ const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
122
107
  const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
123
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
124
- return transactions;
108
+ const signedTransactions = compiledTransactions.map(web3_js.Transaction.from);
109
+ return signedTransactions;
125
110
  });
126
111
  };
127
112
  break;
package/lib/cjs/index.js CHANGED
@@ -4,8 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var web3_js = require('@solana/web3.js');
6
6
  var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
7
+ var bs58 = require('bs58');
7
8
 
8
- /******************************************************************************
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
12
+
13
+ /*! *****************************************************************************
9
14
  Copyright (c) Microsoft Corporation.
10
15
 
11
16
  Permission to use, copy, modify, and/or distribute this software for any
@@ -20,6 +25,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
25
  PERFORMANCE OF THIS SOFTWARE.
21
26
  ***************************************************************************** */
22
27
 
28
+ function __rest(s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31
+ t[p] = s[p];
32
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
33
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
34
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
35
+ t[p[i]] = s[p[i]];
36
+ }
37
+ return t;
38
+ }
39
+
23
40
  function __awaiter(thisArg, _arguments, P, generator) {
24
41
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
42
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -47,81 +64,49 @@ function transact(callback, config) {
47
64
  get(target, p) {
48
65
  if (target[p] == null) {
49
66
  switch (p) {
50
- case 'signAndSendTransaction':
51
- target[p] = function (params) {
67
+ case 'signAndSendTransactions':
68
+ target[p] = function (_a) {
69
+ var { minContextSlot, transactions } = _a, rest = __rest(_a, ["minContextSlot", "transactions"]);
52
70
  return __awaiter(this, void 0, void 0, function* () {
53
- let latestBlockhashPromise;
54
- function getLatestBlockhash(connection) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- if (latestBlockhashPromise == null) {
57
- latestBlockhashPromise = connection.getLatestBlockhash({
58
- commitment: connection.commitment,
59
- });
60
- }
61
- return yield latestBlockhashPromise;
62
- });
63
- }
64
- const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
65
- if (transaction.feePayer == null) {
66
- transaction.feePayer = params.fee_payer;
67
- }
68
- if (transaction.recentBlockhash == null) {
69
- const { blockhash } = yield getLatestBlockhash(params.connection);
70
- transaction.recentBlockhash = blockhash;
71
- }
72
- const serializedTransaction = transaction.serialize({
71
+ const payloads = yield Promise.all(transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
72
+ const serializedTransaction = yield transaction.serialize({
73
73
  requireAllSignatures: false,
74
74
  verifySignatures: false,
75
75
  });
76
76
  return serializedTransaction.toString('base64');
77
77
  })));
78
- let targetCommitment;
79
- switch (params.connection.commitment) {
80
- case 'confirmed':
81
- case 'finalized':
82
- case 'processed':
83
- targetCommitment = params.connection.commitment;
84
- break;
85
- default:
86
- targetCommitment = 'finalized';
87
- }
88
- const { signatures } = yield wallet.signAndSendTransaction({
89
- auth_token: params.auth_token,
90
- commitment: targetCommitment,
91
- payloads,
92
- });
78
+ const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (minContextSlot != null
79
+ ? { options: { min_context_slot: minContextSlot } }
80
+ : null)), { payloads }));
81
+ const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
93
82
  return signatures;
94
83
  });
95
84
  };
96
85
  break;
97
- case 'signMessage':
98
- target[p] = function (params) {
86
+ case 'signMessages':
87
+ target[p] = function (_a) {
88
+ var { payloads } = _a, rest = __rest(_a, ["payloads"]);
99
89
  return __awaiter(this, void 0, void 0, function* () {
100
- const payloads = params.payloads.map(fromUint8Array);
101
- const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
102
- auth_token: params.auth_token,
103
- payloads,
104
- });
90
+ const base64EncodedPayloads = payloads.map(fromUint8Array);
91
+ const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
105
92
  const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
106
93
  return signedMessages;
107
94
  });
108
95
  };
109
96
  break;
110
- case 'signTransaction':
111
- target[p] = function (params) {
97
+ case 'signTransactions':
98
+ target[p] = function (_a) {
99
+ var { transactions } = _a, rest = __rest(_a, ["transactions"]);
112
100
  return __awaiter(this, void 0, void 0, function* () {
113
- const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
101
+ const serializedTransactions = transactions.map((transaction) => transaction.serialize({
114
102
  requireAllSignatures: false,
115
103
  verifySignatures: false,
116
104
  }));
117
105
  const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
118
- const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
119
- auth_token: params.auth_token,
120
- payloads,
121
- });
106
+ const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
122
107
  const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
123
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
124
- return transactions;
108
+ const signedTransactions = compiledTransactions.map(web3_js.Transaction.from);
109
+ return signedTransactions;
125
110
  });
126
111
  };
127
112
  break;
@@ -4,9 +4,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var web3_js = require('@solana/web3.js');
6
6
  var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
7
+ var bs58 = require('bs58');
7
8
  var jsBase64 = require('js-base64');
8
9
 
9
- /******************************************************************************
10
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
+
12
+ var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
13
+
14
+ /*! *****************************************************************************
10
15
  Copyright (c) Microsoft Corporation.
11
16
 
12
17
  Permission to use, copy, modify, and/or distribute this software for any
@@ -21,6 +26,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
26
  PERFORMANCE OF THIS SOFTWARE.
22
27
  ***************************************************************************** */
23
28
 
29
+ function __rest(s, e) {
30
+ var t = {};
31
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
32
+ t[p] = s[p];
33
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
34
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
35
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
36
+ t[p[i]] = s[p[i]];
37
+ }
38
+ return t;
39
+ }
40
+
24
41
  function __awaiter(thisArg, _arguments, P, generator) {
25
42
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
26
43
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -38,81 +55,49 @@ function transact(callback, config) {
38
55
  get(target, p) {
39
56
  if (target[p] == null) {
40
57
  switch (p) {
41
- case 'signAndSendTransaction':
42
- target[p] = function (params) {
58
+ case 'signAndSendTransactions':
59
+ target[p] = function (_a) {
60
+ var { minContextSlot, transactions } = _a, rest = __rest(_a, ["minContextSlot", "transactions"]);
43
61
  return __awaiter(this, void 0, void 0, function* () {
44
- let latestBlockhashPromise;
45
- function getLatestBlockhash(connection) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- if (latestBlockhashPromise == null) {
48
- latestBlockhashPromise = connection.getLatestBlockhash({
49
- commitment: connection.commitment,
50
- });
51
- }
52
- return yield latestBlockhashPromise;
53
- });
54
- }
55
- const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
56
- if (transaction.feePayer == null) {
57
- transaction.feePayer = params.fee_payer;
58
- }
59
- if (transaction.recentBlockhash == null) {
60
- const { blockhash } = yield getLatestBlockhash(params.connection);
61
- transaction.recentBlockhash = blockhash;
62
- }
63
- const serializedTransaction = transaction.serialize({
62
+ const payloads = yield Promise.all(transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
63
+ const serializedTransaction = yield transaction.serialize({
64
64
  requireAllSignatures: false,
65
65
  verifySignatures: false,
66
66
  });
67
67
  return serializedTransaction.toString('base64');
68
68
  })));
69
- let targetCommitment;
70
- switch (params.connection.commitment) {
71
- case 'confirmed':
72
- case 'finalized':
73
- case 'processed':
74
- targetCommitment = params.connection.commitment;
75
- break;
76
- default:
77
- targetCommitment = 'finalized';
78
- }
79
- const { signatures } = yield wallet.signAndSendTransaction({
80
- auth_token: params.auth_token,
81
- commitment: targetCommitment,
82
- payloads,
83
- });
69
+ const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (minContextSlot != null
70
+ ? { options: { min_context_slot: minContextSlot } }
71
+ : null)), { payloads }));
72
+ const signatures = base64EncodedSignatures.map(jsBase64.toUint8Array).map(bs58__default["default"].encode);
84
73
  return signatures;
85
74
  });
86
75
  };
87
76
  break;
88
- case 'signMessage':
89
- target[p] = function (params) {
77
+ case 'signMessages':
78
+ target[p] = function (_a) {
79
+ var { payloads } = _a, rest = __rest(_a, ["payloads"]);
90
80
  return __awaiter(this, void 0, void 0, function* () {
91
- const payloads = params.payloads.map(jsBase64.fromUint8Array);
92
- const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
93
- auth_token: params.auth_token,
94
- payloads,
95
- });
81
+ const base64EncodedPayloads = payloads.map(jsBase64.fromUint8Array);
82
+ const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
96
83
  const signedMessages = base64EncodedSignedMessages.map(jsBase64.toUint8Array);
97
84
  return signedMessages;
98
85
  });
99
86
  };
100
87
  break;
101
- case 'signTransaction':
102
- target[p] = function (params) {
88
+ case 'signTransactions':
89
+ target[p] = function (_a) {
90
+ var { transactions } = _a, rest = __rest(_a, ["transactions"]);
103
91
  return __awaiter(this, void 0, void 0, function* () {
104
- const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
92
+ const serializedTransactions = transactions.map((transaction) => transaction.serialize({
105
93
  requireAllSignatures: false,
106
94
  verifySignatures: false,
107
95
  }));
108
96
  const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
109
- const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
110
- auth_token: params.auth_token,
111
- payloads,
112
- });
97
+ const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
113
98
  const compiledTransactions = base64EncodedCompiledTransactions.map(jsBase64.toUint8Array);
114
- const transactions = compiledTransactions.map(web3_js.Transaction.from);
115
- return transactions;
99
+ const signedTransactions = compiledTransactions.map(web3_js.Transaction.from);
100
+ return signedTransactions;
116
101
  });
117
102
  };
118
103
  break;
@@ -1,7 +1,8 @@
1
1
  import { Transaction } from '@solana/web3.js';
2
2
  import { transact as transact$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
3
+ import bs58 from 'bs58';
3
4
 
4
- /******************************************************************************
5
+ /*! *****************************************************************************
5
6
  Copyright (c) Microsoft Corporation.
6
7
 
7
8
  Permission to use, copy, modify, and/or distribute this software for any
@@ -16,6 +17,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
17
  PERFORMANCE OF THIS SOFTWARE.
17
18
  ***************************************************************************** */
18
19
 
20
+ function __rest(s, e) {
21
+ var t = {};
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23
+ t[p] = s[p];
24
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
25
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
27
+ t[p[i]] = s[p[i]];
28
+ }
29
+ return t;
30
+ }
31
+
19
32
  function __awaiter(thisArg, _arguments, P, generator) {
20
33
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
34
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,81 +56,49 @@ function transact(callback, config) {
43
56
  get(target, p) {
44
57
  if (target[p] == null) {
45
58
  switch (p) {
46
- case 'signAndSendTransaction':
47
- target[p] = function (params) {
59
+ case 'signAndSendTransactions':
60
+ target[p] = function (_a) {
61
+ var { minContextSlot, transactions } = _a, rest = __rest(_a, ["minContextSlot", "transactions"]);
48
62
  return __awaiter(this, void 0, void 0, function* () {
49
- let latestBlockhashPromise;
50
- function getLatestBlockhash(connection) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- if (latestBlockhashPromise == null) {
53
- latestBlockhashPromise = connection.getLatestBlockhash({
54
- commitment: connection.commitment,
55
- });
56
- }
57
- return yield latestBlockhashPromise;
58
- });
59
- }
60
- const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
61
- if (transaction.feePayer == null) {
62
- transaction.feePayer = params.fee_payer;
63
- }
64
- if (transaction.recentBlockhash == null) {
65
- const { blockhash } = yield getLatestBlockhash(params.connection);
66
- transaction.recentBlockhash = blockhash;
67
- }
68
- const serializedTransaction = transaction.serialize({
63
+ const payloads = yield Promise.all(transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
64
+ const serializedTransaction = yield transaction.serialize({
69
65
  requireAllSignatures: false,
70
66
  verifySignatures: false,
71
67
  });
72
68
  return serializedTransaction.toString('base64');
73
69
  })));
74
- let targetCommitment;
75
- switch (params.connection.commitment) {
76
- case 'confirmed':
77
- case 'finalized':
78
- case 'processed':
79
- targetCommitment = params.connection.commitment;
80
- break;
81
- default:
82
- targetCommitment = 'finalized';
83
- }
84
- const { signatures } = yield wallet.signAndSendTransaction({
85
- auth_token: params.auth_token,
86
- commitment: targetCommitment,
87
- payloads,
88
- });
70
+ const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (minContextSlot != null
71
+ ? { options: { min_context_slot: minContextSlot } }
72
+ : null)), { payloads }));
73
+ const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
89
74
  return signatures;
90
75
  });
91
76
  };
92
77
  break;
93
- case 'signMessage':
94
- target[p] = function (params) {
78
+ case 'signMessages':
79
+ target[p] = function (_a) {
80
+ var { payloads } = _a, rest = __rest(_a, ["payloads"]);
95
81
  return __awaiter(this, void 0, void 0, function* () {
96
- const payloads = params.payloads.map(fromUint8Array);
97
- const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
98
- auth_token: params.auth_token,
99
- payloads,
100
- });
82
+ const base64EncodedPayloads = payloads.map(fromUint8Array);
83
+ const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
101
84
  const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
102
85
  return signedMessages;
103
86
  });
104
87
  };
105
88
  break;
106
- case 'signTransaction':
107
- target[p] = function (params) {
89
+ case 'signTransactions':
90
+ target[p] = function (_a) {
91
+ var { transactions } = _a, rest = __rest(_a, ["transactions"]);
108
92
  return __awaiter(this, void 0, void 0, function* () {
109
- const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
93
+ const serializedTransactions = transactions.map((transaction) => transaction.serialize({
110
94
  requireAllSignatures: false,
111
95
  verifySignatures: false,
112
96
  }));
113
97
  const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
114
- const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
115
- auth_token: params.auth_token,
116
- payloads,
117
- });
98
+ const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
118
99
  const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
119
- const transactions = compiledTransactions.map(Transaction.from);
120
- return transactions;
100
+ const signedTransactions = compiledTransactions.map(Transaction.from);
101
+ return signedTransactions;
121
102
  });
122
103
  };
123
104
  break;
package/lib/esm/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Transaction } from '@solana/web3.js';
2
2
  import { transact as transact$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
3
+ import bs58 from 'bs58';
3
4
 
4
- /******************************************************************************
5
+ /*! *****************************************************************************
5
6
  Copyright (c) Microsoft Corporation.
6
7
 
7
8
  Permission to use, copy, modify, and/or distribute this software for any
@@ -16,6 +17,18 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
17
  PERFORMANCE OF THIS SOFTWARE.
17
18
  ***************************************************************************** */
18
19
 
20
+ function __rest(s, e) {
21
+ var t = {};
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23
+ t[p] = s[p];
24
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
25
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
27
+ t[p[i]] = s[p[i]];
28
+ }
29
+ return t;
30
+ }
31
+
19
32
  function __awaiter(thisArg, _arguments, P, generator) {
20
33
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
34
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -43,81 +56,49 @@ function transact(callback, config) {
43
56
  get(target, p) {
44
57
  if (target[p] == null) {
45
58
  switch (p) {
46
- case 'signAndSendTransaction':
47
- target[p] = function (params) {
59
+ case 'signAndSendTransactions':
60
+ target[p] = function (_a) {
61
+ var { minContextSlot, transactions } = _a, rest = __rest(_a, ["minContextSlot", "transactions"]);
48
62
  return __awaiter(this, void 0, void 0, function* () {
49
- let latestBlockhashPromise;
50
- function getLatestBlockhash(connection) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- if (latestBlockhashPromise == null) {
53
- latestBlockhashPromise = connection.getLatestBlockhash({
54
- commitment: connection.commitment,
55
- });
56
- }
57
- return yield latestBlockhashPromise;
58
- });
59
- }
60
- const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
61
- if (transaction.feePayer == null) {
62
- transaction.feePayer = params.fee_payer;
63
- }
64
- if (transaction.recentBlockhash == null) {
65
- const { blockhash } = yield getLatestBlockhash(params.connection);
66
- transaction.recentBlockhash = blockhash;
67
- }
68
- const serializedTransaction = transaction.serialize({
63
+ const payloads = yield Promise.all(transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
64
+ const serializedTransaction = yield transaction.serialize({
69
65
  requireAllSignatures: false,
70
66
  verifySignatures: false,
71
67
  });
72
68
  return serializedTransaction.toString('base64');
73
69
  })));
74
- let targetCommitment;
75
- switch (params.connection.commitment) {
76
- case 'confirmed':
77
- case 'finalized':
78
- case 'processed':
79
- targetCommitment = params.connection.commitment;
80
- break;
81
- default:
82
- targetCommitment = 'finalized';
83
- }
84
- const { signatures } = yield wallet.signAndSendTransaction({
85
- auth_token: params.auth_token,
86
- commitment: targetCommitment,
87
- payloads,
88
- });
70
+ const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (minContextSlot != null
71
+ ? { options: { min_context_slot: minContextSlot } }
72
+ : null)), { payloads }));
73
+ const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
89
74
  return signatures;
90
75
  });
91
76
  };
92
77
  break;
93
- case 'signMessage':
94
- target[p] = function (params) {
78
+ case 'signMessages':
79
+ target[p] = function (_a) {
80
+ var { payloads } = _a, rest = __rest(_a, ["payloads"]);
95
81
  return __awaiter(this, void 0, void 0, function* () {
96
- const payloads = params.payloads.map(fromUint8Array);
97
- const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
98
- auth_token: params.auth_token,
99
- payloads,
100
- });
82
+ const base64EncodedPayloads = payloads.map(fromUint8Array);
83
+ const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
101
84
  const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
102
85
  return signedMessages;
103
86
  });
104
87
  };
105
88
  break;
106
- case 'signTransaction':
107
- target[p] = function (params) {
89
+ case 'signTransactions':
90
+ target[p] = function (_a) {
91
+ var { transactions } = _a, rest = __rest(_a, ["transactions"]);
108
92
  return __awaiter(this, void 0, void 0, function* () {
109
- const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
93
+ const serializedTransactions = transactions.map((transaction) => transaction.serialize({
110
94
  requireAllSignatures: false,
111
95
  verifySignatures: false,
112
96
  }));
113
97
  const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
114
- const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
115
- auth_token: params.auth_token,
116
- payloads,
117
- });
98
+ const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
118
99
  const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
119
- const transactions = compiledTransactions.map(Transaction.from);
120
- return transactions;
100
+ const signedTransactions = compiledTransactions.map(Transaction.from);
101
+ return signedTransactions;
121
102
  });
122
103
  };
123
104
  break;
@@ -1,26 +1,23 @@
1
- import { Connection, PublicKey, Transaction, TransactionSignature } from "@solana/web3.js";
2
- import { AuthorizeAPI, AuthToken, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
- interface Web3SignAndSendTransactionAPI {
4
- signAndSendTransaction(params: {
5
- auth_token: AuthToken;
6
- connection: Connection;
7
- fee_payer?: PublicKey;
1
+ import { Transaction, TransactionSignature } from "@solana/web3.js";
2
+ import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
+ interface Web3SignAndSendTransactionsAPI {
4
+ signAndSendTransactions(params: {
5
+ minContextSlot?: number;
8
6
  transactions: Transaction[];
9
7
  }): Promise<TransactionSignature[]>;
10
8
  }
11
- interface Web3SignTransactionAPI {
12
- signTransaction(params: {
13
- auth_token: AuthToken;
9
+ interface Web3SignTransactionsAPI {
10
+ signTransactions(params: {
14
11
  transactions: Transaction[];
15
12
  }): Promise<Transaction[]>;
16
13
  }
17
- interface Web3SignMessageAPI {
18
- signMessage(params: {
19
- auth_token: AuthToken;
14
+ interface Web3SignMessagesAPI {
15
+ signMessages(params: {
16
+ addresses: Base64EncodedAddress[];
20
17
  payloads: Uint8Array[];
21
18
  }): Promise<Uint8Array[]>;
22
19
  }
23
- interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionAPI, Web3SignTransactionAPI, Web3SignMessageAPI {
20
+ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
24
21
  }
25
22
  declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
26
23
  export { Web3MobileWallet, transact };
@@ -1,26 +1,23 @@
1
- import { Connection, PublicKey, Transaction, TransactionSignature } from "@solana/web3.js";
2
- import { AuthorizeAPI, AuthToken, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
- interface Web3SignAndSendTransactionAPI {
4
- signAndSendTransaction(params: {
5
- auth_token: AuthToken;
6
- connection: Connection;
7
- fee_payer?: PublicKey;
1
+ import { Transaction, TransactionSignature } from "@solana/web3.js";
2
+ import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
+ interface Web3SignAndSendTransactionsAPI {
4
+ signAndSendTransactions(params: {
5
+ minContextSlot?: number;
8
6
  transactions: Transaction[];
9
7
  }): Promise<TransactionSignature[]>;
10
8
  }
11
- interface Web3SignTransactionAPI {
12
- signTransaction(params: {
13
- auth_token: AuthToken;
9
+ interface Web3SignTransactionsAPI {
10
+ signTransactions(params: {
14
11
  transactions: Transaction[];
15
12
  }): Promise<Transaction[]>;
16
13
  }
17
- interface Web3SignMessageAPI {
18
- signMessage(params: {
19
- auth_token: AuthToken;
14
+ interface Web3SignMessagesAPI {
15
+ signMessages(params: {
16
+ addresses: Base64EncodedAddress[];
20
17
  payloads: Uint8Array[];
21
18
  }): Promise<Uint8Array[]>;
22
19
  }
23
- interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionAPI, Web3SignTransactionAPI, Web3SignMessageAPI {
20
+ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
24
21
  }
25
22
  declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
26
23
  export { Web3MobileWallet, transact };
@@ -1,26 +1,23 @@
1
- import { Connection, PublicKey, Transaction, TransactionSignature } from "@solana/web3.js";
2
- import { AuthorizeAPI, AuthToken, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
- interface Web3SignAndSendTransactionAPI {
4
- signAndSendTransaction(params: {
5
- auth_token: AuthToken;
6
- connection: Connection;
7
- fee_payer?: PublicKey;
1
+ import { Transaction, TransactionSignature } from "@solana/web3.js";
2
+ import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
+ interface Web3SignAndSendTransactionsAPI {
4
+ signAndSendTransactions(params: {
5
+ minContextSlot?: number;
8
6
  transactions: Transaction[];
9
7
  }): Promise<TransactionSignature[]>;
10
8
  }
11
- interface Web3SignTransactionAPI {
12
- signTransaction(params: {
13
- auth_token: AuthToken;
9
+ interface Web3SignTransactionsAPI {
10
+ signTransactions(params: {
14
11
  transactions: Transaction[];
15
12
  }): Promise<Transaction[]>;
16
13
  }
17
- interface Web3SignMessageAPI {
18
- signMessage(params: {
19
- auth_token: AuthToken;
14
+ interface Web3SignMessagesAPI {
15
+ signMessages(params: {
16
+ addresses: Base64EncodedAddress[];
20
17
  payloads: Uint8Array[];
21
18
  }): Promise<Uint8Array[]>;
22
19
  }
23
- interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionAPI, Web3SignTransactionAPI, Web3SignMessageAPI {
20
+ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
24
21
  }
25
22
  declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
26
23
  export { Web3MobileWallet, transact };
@@ -1,26 +1,23 @@
1
- import { Connection, PublicKey, Transaction, TransactionSignature } from "@solana/web3.js";
2
- import { AuthorizeAPI, AuthToken, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
- interface Web3SignAndSendTransactionAPI {
4
- signAndSendTransaction(params: {
5
- auth_token: AuthToken;
6
- connection: Connection;
7
- fee_payer?: PublicKey;
1
+ import { Transaction, TransactionSignature } from "@solana/web3.js";
2
+ import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
+ interface Web3SignAndSendTransactionsAPI {
4
+ signAndSendTransactions(params: {
5
+ minContextSlot?: number;
8
6
  transactions: Transaction[];
9
7
  }): Promise<TransactionSignature[]>;
10
8
  }
11
- interface Web3SignTransactionAPI {
12
- signTransaction(params: {
13
- auth_token: AuthToken;
9
+ interface Web3SignTransactionsAPI {
10
+ signTransactions(params: {
14
11
  transactions: Transaction[];
15
12
  }): Promise<Transaction[]>;
16
13
  }
17
- interface Web3SignMessageAPI {
18
- signMessage(params: {
19
- auth_token: AuthToken;
14
+ interface Web3SignMessagesAPI {
15
+ signMessages(params: {
16
+ addresses: Base64EncodedAddress[];
20
17
  payloads: Uint8Array[];
21
18
  }): Promise<Uint8Array[]>;
22
19
  }
23
- interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionAPI, Web3SignTransactionAPI, Web3SignMessageAPI {
20
+ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
24
21
  }
25
22
  declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
26
23
  export { Web3MobileWallet, transact };
@@ -1,26 +1,23 @@
1
- import { Connection, PublicKey, Transaction, TransactionSignature } from "@solana/web3.js";
2
- import { AuthorizeAPI, AuthToken, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
- interface Web3SignAndSendTransactionAPI {
4
- signAndSendTransaction(params: {
5
- auth_token: AuthToken;
6
- connection: Connection;
7
- fee_payer?: PublicKey;
1
+ import { Transaction, TransactionSignature } from "@solana/web3.js";
2
+ import { AuthorizeAPI, Base64EncodedAddress, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, WalletAssociationConfig } from "@solana-mobile/mobile-wallet-adapter-protocol";
3
+ interface Web3SignAndSendTransactionsAPI {
4
+ signAndSendTransactions(params: {
5
+ minContextSlot?: number;
8
6
  transactions: Transaction[];
9
7
  }): Promise<TransactionSignature[]>;
10
8
  }
11
- interface Web3SignTransactionAPI {
12
- signTransaction(params: {
13
- auth_token: AuthToken;
9
+ interface Web3SignTransactionsAPI {
10
+ signTransactions(params: {
14
11
  transactions: Transaction[];
15
12
  }): Promise<Transaction[]>;
16
13
  }
17
- interface Web3SignMessageAPI {
18
- signMessage(params: {
19
- auth_token: AuthToken;
14
+ interface Web3SignMessagesAPI {
15
+ signMessages(params: {
16
+ addresses: Base64EncodedAddress[];
20
17
  payloads: Uint8Array[];
21
18
  }): Promise<Uint8Array[]>;
22
19
  }
23
- interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionAPI, Web3SignTransactionAPI, Web3SignMessageAPI {
20
+ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, DeauthorizeAPI, ReauthorizeAPI, Web3SignAndSendTransactionsAPI, Web3SignTransactionsAPI, Web3SignMessagesAPI {
24
21
  }
25
22
  declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
26
23
  export { Web3MobileWallet, transact };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solana-mobile/mobile-wallet-adapter-protocol-web3js",
3
3
  "description": "A convenience wrapper that enables you to call Solana Mobile Stack protocol methods using objects from @solana/web3.js",
4
- "version": "0.0.1-alpha.7",
4
+ "version": "0.9.1",
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",
@@ -33,18 +33,20 @@
33
33
  "clean": "shx rm -rf lib/*",
34
34
  "build": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts",
35
35
  "build:watch": "yarn clean && rollup --config ../../rollup.config.ts --configPlugin rollup-plugin-ts --watch",
36
- "postbuild": "echo '{\"type\":\"commonjs\"}' | npx json > lib/cjs/package.json && echo '{\"type\":\"module\"} ' | npx json > lib/esm/package.json",
36
+ "postbuild": "cross-env echo {\\\"type\\\":\\\"commonjs\\\"} | npx json > lib/cjs/package.json && echo {\\\"type\\\":\\\"module\\\"} | npx json > lib/esm/package.json",
37
37
  "prepublishOnly": "agadoo"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@solana/web3.js": "^1.48.0"
41
41
  },
42
42
  "dependencies": {
43
- "@solana-mobile/mobile-wallet-adapter-protocol": "^0.0.1-alpha.7",
43
+ "@solana-mobile/mobile-wallet-adapter-protocol": "^0.9.1",
44
+ "bs58": "^5.0.0",
44
45
  "js-base64": "^3.7.2"
45
46
  },
46
47
  "devDependencies": {
47
- "agadoo": "^2.0.0"
48
+ "agadoo": "^2.0.0",
49
+ "cross-env": "^7.0.3"
48
50
  },
49
- "gitHead": "3af26689f4dddaa208fc32ea9c7cf4046c767c78"
51
+ "gitHead": "d28b8fafad0d373a6f7245954a341e768a2b6f1e"
50
52
  }