@solana-mobile/mobile-wallet-adapter-protocol-web3js 2.1.5 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.browser.js +70 -129
- package/lib/cjs/index.js +70 -129
- package/lib/cjs/index.native.js +70 -129
- package/lib/esm/index.browser.js +71 -130
- package/lib/esm/index.js +71 -130
- package/lib/types/index.browser.d.ts +8 -4
- package/lib/types/index.d.ts +8 -4
- package/lib/types/index.native.d.ts +8 -4
- package/package.json +2 -2
package/lib/cjs/index.browser.js
CHANGED
|
@@ -81,143 +81,84 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
81
81
|
function transact(callback, config) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
const augmentedCallback = (wallet) => {
|
|
84
|
-
|
|
85
|
-
get(target, p) {
|
|
86
|
-
if (target[p] == null) {
|
|
87
|
-
switch (p) {
|
|
88
|
-
case 'signAndSendTransactions':
|
|
89
|
-
target[p] = function (_a) {
|
|
90
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
93
|
-
const options = {
|
|
94
|
-
min_context_slot: minContextSlot,
|
|
95
|
-
commitment: commitment,
|
|
96
|
-
skip_preflight: skipPreflight,
|
|
97
|
-
max_retries: maxRetries,
|
|
98
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
99
|
-
};
|
|
100
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
101
|
-
? { options: options }
|
|
102
|
-
: null)), { payloads }));
|
|
103
|
-
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
|
|
104
|
-
return signatures;
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
break;
|
|
108
|
-
case 'signMessages':
|
|
109
|
-
target[p] = function (_a) {
|
|
110
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
113
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
114
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
115
|
-
return signedMessages;
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
break;
|
|
119
|
-
case 'signTransactions':
|
|
120
|
-
target[p] = function (_a) {
|
|
121
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
124
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
125
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
126
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
127
|
-
return signedTransactions;
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
break;
|
|
131
|
-
default: {
|
|
132
|
-
target[p] = wallet[p];
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return target[p];
|
|
138
|
-
},
|
|
139
|
-
defineProperty() {
|
|
140
|
-
return false;
|
|
141
|
-
},
|
|
142
|
-
deleteProperty() {
|
|
143
|
-
return false;
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
return callback(augmentedAPI);
|
|
84
|
+
return callback(augmentWalletAPI(wallet));
|
|
147
85
|
};
|
|
148
86
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|
|
149
87
|
});
|
|
150
88
|
}
|
|
151
|
-
function
|
|
89
|
+
function startRemoteScenario(config) {
|
|
152
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
177
|
-
break;
|
|
178
|
-
case 'signMessages':
|
|
179
|
-
target[p] = function (_a) {
|
|
180
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
183
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
184
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
185
|
-
return signedMessages;
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
break;
|
|
189
|
-
case 'signTransactions':
|
|
190
|
-
target[p] = function (_a) {
|
|
191
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
194
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
195
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
196
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
197
|
-
return signedTransactions;
|
|
198
|
-
});
|
|
91
|
+
const { wallet, close, associationUrl } = yield mobileWalletAdapterProtocol.startRemoteScenario(config);
|
|
92
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
93
|
+
return augmentWalletAPI(wallet);
|
|
94
|
+
});
|
|
95
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function augmentWalletAPI(wallet) {
|
|
99
|
+
return new Proxy({}, {
|
|
100
|
+
get(target, p) {
|
|
101
|
+
if (target[p] == null) {
|
|
102
|
+
switch (p) {
|
|
103
|
+
case 'signAndSendTransactions':
|
|
104
|
+
target[p] = function (_a) {
|
|
105
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
108
|
+
const options = {
|
|
109
|
+
min_context_slot: minContextSlot,
|
|
110
|
+
commitment: commitment,
|
|
111
|
+
skip_preflight: skipPreflight,
|
|
112
|
+
max_retries: maxRetries,
|
|
113
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
199
114
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
115
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
116
|
+
? { options: options }
|
|
117
|
+
: null)), { payloads }));
|
|
118
|
+
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
|
|
119
|
+
return signatures;
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
break;
|
|
123
|
+
case 'signMessages':
|
|
124
|
+
target[p] = function (_a) {
|
|
125
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
128
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
129
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
130
|
+
return signedMessages;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case 'signTransactions':
|
|
135
|
+
target[p] = function (_a) {
|
|
136
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
139
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
140
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
141
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
142
|
+
return signedTransactions;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
break;
|
|
146
|
+
default: {
|
|
147
|
+
target[p] = wallet[p];
|
|
148
|
+
break;
|
|
206
149
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
return yield mobileWalletAdapterProtocol.transactRemote(augmentedCallback, config);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return target[p];
|
|
153
|
+
},
|
|
154
|
+
defineProperty() {
|
|
155
|
+
return false;
|
|
156
|
+
},
|
|
157
|
+
deleteProperty() {
|
|
158
|
+
return false;
|
|
159
|
+
},
|
|
219
160
|
});
|
|
220
161
|
}
|
|
221
162
|
|
|
163
|
+
exports.startRemoteScenario = startRemoteScenario;
|
|
222
164
|
exports.transact = transact;
|
|
223
|
-
exports.transactRemote = transactRemote;
|
package/lib/cjs/index.js
CHANGED
|
@@ -81,143 +81,84 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
81
81
|
function transact(callback, config) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
const augmentedCallback = (wallet) => {
|
|
84
|
-
|
|
85
|
-
get(target, p) {
|
|
86
|
-
if (target[p] == null) {
|
|
87
|
-
switch (p) {
|
|
88
|
-
case 'signAndSendTransactions':
|
|
89
|
-
target[p] = function (_a) {
|
|
90
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
91
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
93
|
-
const options = {
|
|
94
|
-
min_context_slot: minContextSlot,
|
|
95
|
-
commitment: commitment,
|
|
96
|
-
skip_preflight: skipPreflight,
|
|
97
|
-
max_retries: maxRetries,
|
|
98
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
99
|
-
};
|
|
100
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
101
|
-
? { options: options }
|
|
102
|
-
: null)), { payloads }));
|
|
103
|
-
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
|
|
104
|
-
return signatures;
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
break;
|
|
108
|
-
case 'signMessages':
|
|
109
|
-
target[p] = function (_a) {
|
|
110
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
113
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
114
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
115
|
-
return signedMessages;
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
break;
|
|
119
|
-
case 'signTransactions':
|
|
120
|
-
target[p] = function (_a) {
|
|
121
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
124
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
125
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
126
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
127
|
-
return signedTransactions;
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
break;
|
|
131
|
-
default: {
|
|
132
|
-
target[p] = wallet[p];
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return target[p];
|
|
138
|
-
},
|
|
139
|
-
defineProperty() {
|
|
140
|
-
return false;
|
|
141
|
-
},
|
|
142
|
-
deleteProperty() {
|
|
143
|
-
return false;
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
return callback(augmentedAPI);
|
|
84
|
+
return callback(augmentWalletAPI(wallet));
|
|
147
85
|
};
|
|
148
86
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|
|
149
87
|
});
|
|
150
88
|
}
|
|
151
|
-
function
|
|
89
|
+
function startRemoteScenario(config) {
|
|
152
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
177
|
-
break;
|
|
178
|
-
case 'signMessages':
|
|
179
|
-
target[p] = function (_a) {
|
|
180
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
181
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
183
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
184
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
185
|
-
return signedMessages;
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
break;
|
|
189
|
-
case 'signTransactions':
|
|
190
|
-
target[p] = function (_a) {
|
|
191
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
192
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
194
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
195
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
196
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
197
|
-
return signedTransactions;
|
|
198
|
-
});
|
|
91
|
+
const { wallet, close, associationUrl } = yield mobileWalletAdapterProtocol.startRemoteScenario(config);
|
|
92
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
93
|
+
return augmentWalletAPI(wallet);
|
|
94
|
+
});
|
|
95
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function augmentWalletAPI(wallet) {
|
|
99
|
+
return new Proxy({}, {
|
|
100
|
+
get(target, p) {
|
|
101
|
+
if (target[p] == null) {
|
|
102
|
+
switch (p) {
|
|
103
|
+
case 'signAndSendTransactions':
|
|
104
|
+
target[p] = function (_a) {
|
|
105
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
108
|
+
const options = {
|
|
109
|
+
min_context_slot: minContextSlot,
|
|
110
|
+
commitment: commitment,
|
|
111
|
+
skip_preflight: skipPreflight,
|
|
112
|
+
max_retries: maxRetries,
|
|
113
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
199
114
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
115
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
116
|
+
? { options: options }
|
|
117
|
+
: null)), { payloads }));
|
|
118
|
+
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58__default["default"].encode);
|
|
119
|
+
return signatures;
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
break;
|
|
123
|
+
case 'signMessages':
|
|
124
|
+
target[p] = function (_a) {
|
|
125
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
128
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
129
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
130
|
+
return signedMessages;
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
break;
|
|
134
|
+
case 'signTransactions':
|
|
135
|
+
target[p] = function (_a) {
|
|
136
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
137
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
138
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
139
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
140
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
141
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
142
|
+
return signedTransactions;
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
break;
|
|
146
|
+
default: {
|
|
147
|
+
target[p] = wallet[p];
|
|
148
|
+
break;
|
|
206
149
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
};
|
|
218
|
-
return yield mobileWalletAdapterProtocol.transactRemote(augmentedCallback, config);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return target[p];
|
|
153
|
+
},
|
|
154
|
+
defineProperty() {
|
|
155
|
+
return false;
|
|
156
|
+
},
|
|
157
|
+
deleteProperty() {
|
|
158
|
+
return false;
|
|
159
|
+
},
|
|
219
160
|
});
|
|
220
161
|
}
|
|
221
162
|
|
|
163
|
+
exports.startRemoteScenario = startRemoteScenario;
|
|
222
164
|
exports.transact = transact;
|
|
223
|
-
exports.transactRemote = transactRemote;
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -72,143 +72,84 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
72
72
|
function transact(callback, config) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
const augmentedCallback = (wallet) => {
|
|
75
|
-
|
|
76
|
-
get(target, p) {
|
|
77
|
-
if (target[p] == null) {
|
|
78
|
-
switch (p) {
|
|
79
|
-
case 'signAndSendTransactions':
|
|
80
|
-
target[p] = function (_a) {
|
|
81
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
84
|
-
const options = {
|
|
85
|
-
min_context_slot: minContextSlot,
|
|
86
|
-
commitment: commitment,
|
|
87
|
-
skip_preflight: skipPreflight,
|
|
88
|
-
max_retries: maxRetries,
|
|
89
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
90
|
-
};
|
|
91
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
92
|
-
? { options: options }
|
|
93
|
-
: null)), { payloads }));
|
|
94
|
-
const signatures = base64EncodedSignatures.map(jsBase64.toUint8Array).map(bs58__default["default"].encode);
|
|
95
|
-
return signatures;
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
break;
|
|
99
|
-
case 'signMessages':
|
|
100
|
-
target[p] = function (_a) {
|
|
101
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const base64EncodedPayloads = payloads.map(jsBase64.fromUint8Array);
|
|
104
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
105
|
-
const signedMessages = base64EncodedSignedMessages.map(jsBase64.toUint8Array);
|
|
106
|
-
return signedMessages;
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
break;
|
|
110
|
-
case 'signTransactions':
|
|
111
|
-
target[p] = function (_a) {
|
|
112
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
113
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
115
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
116
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(jsBase64.toUint8Array);
|
|
117
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
118
|
-
return signedTransactions;
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
break;
|
|
122
|
-
default: {
|
|
123
|
-
target[p] = wallet[p];
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return target[p];
|
|
129
|
-
},
|
|
130
|
-
defineProperty() {
|
|
131
|
-
return false;
|
|
132
|
-
},
|
|
133
|
-
deleteProperty() {
|
|
134
|
-
return false;
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
return callback(augmentedAPI);
|
|
75
|
+
return callback(augmentWalletAPI(wallet));
|
|
138
76
|
};
|
|
139
77
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|
|
140
78
|
});
|
|
141
79
|
}
|
|
142
|
-
function
|
|
80
|
+
function startRemoteScenario(config) {
|
|
143
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
};
|
|
168
|
-
break;
|
|
169
|
-
case 'signMessages':
|
|
170
|
-
target[p] = function (_a) {
|
|
171
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
172
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
const base64EncodedPayloads = payloads.map(jsBase64.fromUint8Array);
|
|
174
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
175
|
-
const signedMessages = base64EncodedSignedMessages.map(jsBase64.toUint8Array);
|
|
176
|
-
return signedMessages;
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
break;
|
|
180
|
-
case 'signTransactions':
|
|
181
|
-
target[p] = function (_a) {
|
|
182
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
183
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
185
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
186
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(jsBase64.toUint8Array);
|
|
187
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
188
|
-
return signedTransactions;
|
|
189
|
-
});
|
|
82
|
+
const { wallet, close, associationUrl } = yield mobileWalletAdapterProtocol.startRemoteScenario(config);
|
|
83
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
84
|
+
return augmentWalletAPI(wallet);
|
|
85
|
+
});
|
|
86
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function augmentWalletAPI(wallet) {
|
|
90
|
+
return new Proxy({}, {
|
|
91
|
+
get(target, p) {
|
|
92
|
+
if (target[p] == null) {
|
|
93
|
+
switch (p) {
|
|
94
|
+
case 'signAndSendTransactions':
|
|
95
|
+
target[p] = function (_a) {
|
|
96
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
99
|
+
const options = {
|
|
100
|
+
min_context_slot: minContextSlot,
|
|
101
|
+
commitment: commitment,
|
|
102
|
+
skip_preflight: skipPreflight,
|
|
103
|
+
max_retries: maxRetries,
|
|
104
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
190
105
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
106
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
107
|
+
? { options: options }
|
|
108
|
+
: null)), { payloads }));
|
|
109
|
+
const signatures = base64EncodedSignatures.map(jsBase64.toUint8Array).map(bs58__default["default"].encode);
|
|
110
|
+
return signatures;
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
break;
|
|
114
|
+
case 'signMessages':
|
|
115
|
+
target[p] = function (_a) {
|
|
116
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const base64EncodedPayloads = payloads.map(jsBase64.fromUint8Array);
|
|
119
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
120
|
+
const signedMessages = base64EncodedSignedMessages.map(jsBase64.toUint8Array);
|
|
121
|
+
return signedMessages;
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
break;
|
|
125
|
+
case 'signTransactions':
|
|
126
|
+
target[p] = function (_a) {
|
|
127
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
130
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
131
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(jsBase64.toUint8Array);
|
|
132
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
133
|
+
return signedTransactions;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
break;
|
|
137
|
+
default: {
|
|
138
|
+
target[p] = wallet[p];
|
|
139
|
+
break;
|
|
197
140
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
209
|
-
return yield mobileWalletAdapterProtocol.transactRemote(augmentedCallback, config);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return target[p];
|
|
144
|
+
},
|
|
145
|
+
defineProperty() {
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
deleteProperty() {
|
|
149
|
+
return false;
|
|
150
|
+
},
|
|
210
151
|
});
|
|
211
152
|
}
|
|
212
153
|
|
|
154
|
+
exports.startRemoteScenario = startRemoteScenario;
|
|
213
155
|
exports.transact = transact;
|
|
214
|
-
exports.transactRemote = transactRemote;
|
package/lib/esm/index.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VersionedMessage, Transaction, VersionedTransaction, SIGNATURE_LENGTH_IN_BYTES } from '@solana/web3.js';
|
|
2
|
-
import { transact as transact$1,
|
|
2
|
+
import { transact as transact$1, startRemoteScenario as startRemoteScenario$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -73,142 +73,83 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
73
73
|
function transact(callback, config) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
const augmentedCallback = (wallet) => {
|
|
76
|
-
|
|
77
|
-
get(target, p) {
|
|
78
|
-
if (target[p] == null) {
|
|
79
|
-
switch (p) {
|
|
80
|
-
case 'signAndSendTransactions':
|
|
81
|
-
target[p] = function (_a) {
|
|
82
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
85
|
-
const options = {
|
|
86
|
-
min_context_slot: minContextSlot,
|
|
87
|
-
commitment: commitment,
|
|
88
|
-
skip_preflight: skipPreflight,
|
|
89
|
-
max_retries: maxRetries,
|
|
90
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
91
|
-
};
|
|
92
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
93
|
-
? { options: options }
|
|
94
|
-
: null)), { payloads }));
|
|
95
|
-
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
96
|
-
return signatures;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
break;
|
|
100
|
-
case 'signMessages':
|
|
101
|
-
target[p] = function (_a) {
|
|
102
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
105
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
break;
|
|
111
|
-
case 'signTransactions':
|
|
112
|
-
target[p] = function (_a) {
|
|
113
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
116
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
117
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
118
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
119
|
-
return signedTransactions;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
break;
|
|
123
|
-
default: {
|
|
124
|
-
target[p] = wallet[p];
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return target[p];
|
|
130
|
-
},
|
|
131
|
-
defineProperty() {
|
|
132
|
-
return false;
|
|
133
|
-
},
|
|
134
|
-
deleteProperty() {
|
|
135
|
-
return false;
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
return callback(augmentedAPI);
|
|
76
|
+
return callback(augmentWalletAPI(wallet));
|
|
139
77
|
};
|
|
140
78
|
return yield transact$1(augmentedCallback, config);
|
|
141
79
|
});
|
|
142
80
|
}
|
|
143
|
-
function
|
|
81
|
+
function startRemoteScenario(config) {
|
|
144
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
break;
|
|
170
|
-
case 'signMessages':
|
|
171
|
-
target[p] = function (_a) {
|
|
172
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
173
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
175
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
176
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
177
|
-
return signedMessages;
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
break;
|
|
181
|
-
case 'signTransactions':
|
|
182
|
-
target[p] = function (_a) {
|
|
183
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
186
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
187
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
188
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
189
|
-
return signedTransactions;
|
|
190
|
-
});
|
|
83
|
+
const { wallet, close, associationUrl } = yield startRemoteScenario$1(config);
|
|
84
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
85
|
+
return augmentWalletAPI(wallet);
|
|
86
|
+
});
|
|
87
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function augmentWalletAPI(wallet) {
|
|
91
|
+
return new Proxy({}, {
|
|
92
|
+
get(target, p) {
|
|
93
|
+
if (target[p] == null) {
|
|
94
|
+
switch (p) {
|
|
95
|
+
case 'signAndSendTransactions':
|
|
96
|
+
target[p] = function (_a) {
|
|
97
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
100
|
+
const options = {
|
|
101
|
+
min_context_slot: minContextSlot,
|
|
102
|
+
commitment: commitment,
|
|
103
|
+
skip_preflight: skipPreflight,
|
|
104
|
+
max_retries: maxRetries,
|
|
105
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
191
106
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
107
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
108
|
+
? { options: options }
|
|
109
|
+
: null)), { payloads }));
|
|
110
|
+
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
111
|
+
return signatures;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
break;
|
|
115
|
+
case 'signMessages':
|
|
116
|
+
target[p] = function (_a) {
|
|
117
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
120
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
121
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
122
|
+
return signedMessages;
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
break;
|
|
126
|
+
case 'signTransactions':
|
|
127
|
+
target[p] = function (_a) {
|
|
128
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
131
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
132
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
133
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
134
|
+
return signedTransactions;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
break;
|
|
138
|
+
default: {
|
|
139
|
+
target[p] = wallet[p];
|
|
140
|
+
break;
|
|
198
141
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
return yield transactRemote$1(augmentedCallback, config);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return target[p];
|
|
145
|
+
},
|
|
146
|
+
defineProperty() {
|
|
147
|
+
return false;
|
|
148
|
+
},
|
|
149
|
+
deleteProperty() {
|
|
150
|
+
return false;
|
|
151
|
+
},
|
|
211
152
|
});
|
|
212
153
|
}
|
|
213
154
|
|
|
214
|
-
export {
|
|
155
|
+
export { startRemoteScenario, transact };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VersionedMessage, Transaction, VersionedTransaction, SIGNATURE_LENGTH_IN_BYTES } from '@solana/web3.js';
|
|
2
|
-
import { transact as transact$1,
|
|
2
|
+
import { transact as transact$1, startRemoteScenario as startRemoteScenario$1 } from '@solana-mobile/mobile-wallet-adapter-protocol';
|
|
3
3
|
import bs58 from 'bs58';
|
|
4
4
|
|
|
5
5
|
/******************************************************************************
|
|
@@ -73,142 +73,83 @@ function getTransactionFromWireMessage(byteArray) {
|
|
|
73
73
|
function transact(callback, config) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
const augmentedCallback = (wallet) => {
|
|
76
|
-
|
|
77
|
-
get(target, p) {
|
|
78
|
-
if (target[p] == null) {
|
|
79
|
-
switch (p) {
|
|
80
|
-
case 'signAndSendTransactions':
|
|
81
|
-
target[p] = function (_a) {
|
|
82
|
-
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
85
|
-
const options = {
|
|
86
|
-
min_context_slot: minContextSlot,
|
|
87
|
-
commitment: commitment,
|
|
88
|
-
skip_preflight: skipPreflight,
|
|
89
|
-
max_retries: maxRetries,
|
|
90
|
-
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
91
|
-
};
|
|
92
|
-
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
93
|
-
? { options: options }
|
|
94
|
-
: null)), { payloads }));
|
|
95
|
-
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
96
|
-
return signatures;
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
break;
|
|
100
|
-
case 'signMessages':
|
|
101
|
-
target[p] = function (_a) {
|
|
102
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
105
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
break;
|
|
111
|
-
case 'signTransactions':
|
|
112
|
-
target[p] = function (_a) {
|
|
113
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
116
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
117
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
118
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
119
|
-
return signedTransactions;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
break;
|
|
123
|
-
default: {
|
|
124
|
-
target[p] = wallet[p];
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return target[p];
|
|
130
|
-
},
|
|
131
|
-
defineProperty() {
|
|
132
|
-
return false;
|
|
133
|
-
},
|
|
134
|
-
deleteProperty() {
|
|
135
|
-
return false;
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
return callback(augmentedAPI);
|
|
76
|
+
return callback(augmentWalletAPI(wallet));
|
|
139
77
|
};
|
|
140
78
|
return yield transact$1(augmentedCallback, config);
|
|
141
79
|
});
|
|
142
80
|
}
|
|
143
|
-
function
|
|
81
|
+
function startRemoteScenario(config) {
|
|
144
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
};
|
|
169
|
-
break;
|
|
170
|
-
case 'signMessages':
|
|
171
|
-
target[p] = function (_a) {
|
|
172
|
-
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
173
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
175
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
176
|
-
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
177
|
-
return signedMessages;
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
break;
|
|
181
|
-
case 'signTransactions':
|
|
182
|
-
target[p] = function (_a) {
|
|
183
|
-
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
184
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const payloads = transactions.map(getPayloadFromTransaction);
|
|
186
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
187
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
188
|
-
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
189
|
-
return signedTransactions;
|
|
190
|
-
});
|
|
83
|
+
const { wallet, close, associationUrl } = yield startRemoteScenario$1(config);
|
|
84
|
+
const augmentedPromise = wallet.then((wallet) => {
|
|
85
|
+
return augmentWalletAPI(wallet);
|
|
86
|
+
});
|
|
87
|
+
return { wallet: augmentedPromise, close, associationUrl };
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function augmentWalletAPI(wallet) {
|
|
91
|
+
return new Proxy({}, {
|
|
92
|
+
get(target, p) {
|
|
93
|
+
if (target[p] == null) {
|
|
94
|
+
switch (p) {
|
|
95
|
+
case 'signAndSendTransactions':
|
|
96
|
+
target[p] = function (_a) {
|
|
97
|
+
var { minContextSlot, commitment, skipPreflight, maxRetries, waitForCommitmentToSendNextTransaction, transactions } = _a, rest = __rest(_a, ["minContextSlot", "commitment", "skipPreflight", "maxRetries", "waitForCommitmentToSendNextTransaction", "transactions"]);
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
100
|
+
const options = {
|
|
101
|
+
min_context_slot: minContextSlot,
|
|
102
|
+
commitment: commitment,
|
|
103
|
+
skip_preflight: skipPreflight,
|
|
104
|
+
max_retries: maxRetries,
|
|
105
|
+
wait_for_commitment_to_send_next_transaction: waitForCommitmentToSendNextTransaction
|
|
191
106
|
};
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
107
|
+
const { signatures: base64EncodedSignatures } = yield wallet.signAndSendTransactions(Object.assign(Object.assign(Object.assign({}, rest), (Object.values(options).some(element => element != null)
|
|
108
|
+
? { options: options }
|
|
109
|
+
: null)), { payloads }));
|
|
110
|
+
const signatures = base64EncodedSignatures.map(toUint8Array).map(bs58.encode);
|
|
111
|
+
return signatures;
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
break;
|
|
115
|
+
case 'signMessages':
|
|
116
|
+
target[p] = function (_a) {
|
|
117
|
+
var { payloads } = _a, rest = __rest(_a, ["payloads"]);
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const base64EncodedPayloads = payloads.map(fromUint8Array);
|
|
120
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessages(Object.assign(Object.assign({}, rest), { payloads: base64EncodedPayloads }));
|
|
121
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
122
|
+
return signedMessages;
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
break;
|
|
126
|
+
case 'signTransactions':
|
|
127
|
+
target[p] = function (_a) {
|
|
128
|
+
var { transactions } = _a, rest = __rest(_a, ["transactions"]);
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const payloads = transactions.map(getPayloadFromTransaction);
|
|
131
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransactions(Object.assign(Object.assign({}, rest), { payloads }));
|
|
132
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
133
|
+
const signedTransactions = compiledTransactions.map(getTransactionFromWireMessage);
|
|
134
|
+
return signedTransactions;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
break;
|
|
138
|
+
default: {
|
|
139
|
+
target[p] = wallet[p];
|
|
140
|
+
break;
|
|
198
141
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
return yield transactRemote$1(augmentedCallback, config);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return target[p];
|
|
145
|
+
},
|
|
146
|
+
defineProperty() {
|
|
147
|
+
return false;
|
|
148
|
+
},
|
|
149
|
+
deleteProperty() {
|
|
150
|
+
return false;
|
|
151
|
+
},
|
|
211
152
|
});
|
|
212
153
|
}
|
|
213
154
|
|
|
214
|
-
export {
|
|
155
|
+
export { startRemoteScenario, transact };
|
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.browser.d.ts.map
|
package/lib/types/index.d.ts
CHANGED
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -26,10 +26,14 @@ interface Web3MobileWallet extends AuthorizeAPI, CloneAuthorizationAPI, Deauthor
|
|
|
26
26
|
}
|
|
27
27
|
interface Web3RemoteMobileWallet extends Web3MobileWallet, TerminateSessionAPI {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
type Web3Scenario = Readonly<{
|
|
30
|
+
wallet: Promise<Web3MobileWallet>;
|
|
31
|
+
close: () => void;
|
|
32
|
+
}>;
|
|
33
|
+
type Web3RemoteScenario = Web3Scenario & Readonly<{
|
|
31
34
|
associationUrl: URL;
|
|
32
|
-
result: Promise<TReturn>;
|
|
33
35
|
}>;
|
|
34
|
-
|
|
36
|
+
declare function transact<TReturn>(callback: (wallet: Web3MobileWallet) => TReturn, config?: WalletAssociationConfig): Promise<TReturn>;
|
|
37
|
+
declare function startRemoteScenario(config: RemoteWalletAssociationConfig): Promise<Web3RemoteScenario>;
|
|
38
|
+
export { Web3MobileWallet, Web3RemoteMobileWallet, Web3Scenario, Web3RemoteScenario, transact, startRemoteScenario };
|
|
35
39
|
//# sourceMappingURL=index.native.d.ts.map
|
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": "2.1.
|
|
4
|
+
"version": "2.1.7",
|
|
5
5
|
"author": "Steven Luscher <steven.luscher@solanamobile.com>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@solana/web3.js": "^1.58.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.1.
|
|
47
|
+
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.1.7",
|
|
48
48
|
"bs58": "^5.0.0",
|
|
49
49
|
"js-base64": "^3.7.5"
|
|
50
50
|
},
|