@taquito/beacon-wallet 24.2.0 → 24.3.0-beta.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.
- package/dist/lib/errors.js +2 -2
- package/dist/lib/taquito-beacon-wallet.js +147 -187
- package/dist/lib/version.js +2 -2
- package/dist/taquito-beacon-wallet.es6.js +152 -215
- package/dist/taquito-beacon-wallet.es6.js.map +1 -1
- package/dist/taquito-beacon-wallet.umd.js +328 -391
- package/dist/taquito-beacon-wallet.umd.js.map +1 -1
- package/dist/types/errors.d.ts +2 -2
- package/dist/types/taquito-beacon-wallet.d.ts +2 -2
- package/package.json +23 -10
- package/LICENSE +0 -202
package/dist/lib/errors.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.MissingRequiredScopes = exports.BeaconWalletNotInitialized = void 0;
|
|
|
4
4
|
const core_1 = require("@taquito/core");
|
|
5
5
|
/**
|
|
6
6
|
* @category Error
|
|
7
|
-
*
|
|
7
|
+
* Error that indicates the Beacon wallet not being initialized
|
|
8
8
|
*/
|
|
9
9
|
class BeaconWalletNotInitialized extends core_1.PermissionDeniedError {
|
|
10
10
|
constructor() {
|
|
@@ -17,7 +17,7 @@ class BeaconWalletNotInitialized extends core_1.PermissionDeniedError {
|
|
|
17
17
|
exports.BeaconWalletNotInitialized = BeaconWalletNotInitialized;
|
|
18
18
|
/**
|
|
19
19
|
* @category Error
|
|
20
|
-
*
|
|
20
|
+
* Error that indicates missing required permission scopes
|
|
21
21
|
*/
|
|
22
22
|
class MissingRequiredScopes extends core_1.PermissionDeniedError {
|
|
23
23
|
constructor(requiredScopes) {
|
|
@@ -3,15 +3,6 @@
|
|
|
3
3
|
* @packageDocumentation
|
|
4
4
|
* @module @taquito/beacon-wallet
|
|
5
5
|
*/
|
|
6
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
7
|
exports.BeaconWallet = exports.BeaconEvent = exports.MissingRequiredScopes = exports.BeaconWalletNotInitialized = exports.VERSION = void 0;
|
|
17
8
|
const beacon_dapp_1 = require("@ecadlabs/beacon-dapp");
|
|
@@ -74,9 +65,11 @@ const TAQUITO_CURATED_MATRIX_NODES = {
|
|
|
74
65
|
};
|
|
75
66
|
class BeaconWallet {
|
|
76
67
|
constructor(options) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
68
|
+
const matrixNodes = {
|
|
69
|
+
...TAQUITO_CURATED_MATRIX_NODES,
|
|
70
|
+
...(options.matrixNodes ?? {}),
|
|
71
|
+
};
|
|
72
|
+
this.client = (0, beacon_dapp_1.getDAppClientInstance)({ ...options, matrixNodes });
|
|
80
73
|
}
|
|
81
74
|
validateRequiredScopesOrFail(permissionScopes, requiredScopes) {
|
|
82
75
|
const mandatoryScope = new Set(requiredScopes);
|
|
@@ -89,155 +82,130 @@ class BeaconWallet {
|
|
|
89
82
|
throw new errors_1.MissingRequiredScopes(Array.from(mandatoryScope));
|
|
90
83
|
}
|
|
91
84
|
}
|
|
92
|
-
requestPermissions(request) {
|
|
93
|
-
|
|
94
|
-
yield this.client.requestPermissions(request);
|
|
95
|
-
});
|
|
85
|
+
async requestPermissions(request) {
|
|
86
|
+
await this.client.requestPermissions(request);
|
|
96
87
|
}
|
|
97
|
-
getPKH() {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return account.address;
|
|
104
|
-
});
|
|
88
|
+
async getPKH() {
|
|
89
|
+
const account = await this.client.getActiveAccount();
|
|
90
|
+
if (!account) {
|
|
91
|
+
throw new errors_1.BeaconWalletNotInitialized();
|
|
92
|
+
}
|
|
93
|
+
return account.address;
|
|
105
94
|
}
|
|
106
|
-
getPK() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
return (_a = account.publicKey) !== null && _a !== void 0 ? _a : '';
|
|
114
|
-
});
|
|
95
|
+
async getPK() {
|
|
96
|
+
const account = await this.client.getActiveAccount();
|
|
97
|
+
if (!account) {
|
|
98
|
+
throw new errors_1.BeaconWalletNotInitialized();
|
|
99
|
+
}
|
|
100
|
+
return account.publicKey ?? '';
|
|
115
101
|
}
|
|
116
|
-
mapTransferParamsToWalletParams(params) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
128
|
-
});
|
|
102
|
+
async mapTransferParamsToWalletParams(params) {
|
|
103
|
+
let walletParams;
|
|
104
|
+
await this.client.showPrepare();
|
|
105
|
+
try {
|
|
106
|
+
walletParams = await params();
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
await this.client.hideUI(['alert']);
|
|
110
|
+
throw err;
|
|
111
|
+
}
|
|
112
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
129
113
|
}
|
|
130
|
-
mapTransferTicketParamsToWalletParams(params) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createTransferTicketOperation)(this.formatParameters(walletParams)));
|
|
142
|
-
});
|
|
114
|
+
async mapTransferTicketParamsToWalletParams(params) {
|
|
115
|
+
let walletParams;
|
|
116
|
+
await this.client.showPrepare();
|
|
117
|
+
try {
|
|
118
|
+
walletParams = await params();
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
await this.client.hideUI(['alert']);
|
|
122
|
+
throw err;
|
|
123
|
+
}
|
|
124
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createTransferTicketOperation)(this.formatParameters(walletParams)));
|
|
143
125
|
}
|
|
144
|
-
mapStakeParamsToWalletParams(params) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
156
|
-
});
|
|
126
|
+
async mapStakeParamsToWalletParams(params) {
|
|
127
|
+
let walletParams;
|
|
128
|
+
await this.client.showPrepare();
|
|
129
|
+
try {
|
|
130
|
+
walletParams = await params();
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
await this.client.hideUI(['alert']);
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
157
137
|
}
|
|
158
|
-
mapUnstakeParamsToWalletParams(params) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
170
|
-
});
|
|
138
|
+
async mapUnstakeParamsToWalletParams(params) {
|
|
139
|
+
let walletParams;
|
|
140
|
+
await this.client.showPrepare();
|
|
141
|
+
try {
|
|
142
|
+
walletParams = await params();
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
await this.client.hideUI(['alert']);
|
|
146
|
+
throw err;
|
|
147
|
+
}
|
|
148
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
171
149
|
}
|
|
172
|
-
mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
184
|
-
});
|
|
150
|
+
async mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
151
|
+
let walletParams;
|
|
152
|
+
await this.client.showPrepare();
|
|
153
|
+
try {
|
|
154
|
+
walletParams = await params();
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
await this.client.hideUI(['alert']);
|
|
158
|
+
throw err;
|
|
159
|
+
}
|
|
160
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
185
161
|
}
|
|
186
|
-
mapIncreasePaidStorageWalletParams(params) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createIncreasePaidStorageOperation)(this.formatParameters(walletParams)));
|
|
198
|
-
});
|
|
162
|
+
async mapIncreasePaidStorageWalletParams(params) {
|
|
163
|
+
let walletParams;
|
|
164
|
+
await this.client.showPrepare();
|
|
165
|
+
try {
|
|
166
|
+
walletParams = await params();
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
await this.client.hideUI(['alert']);
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createIncreasePaidStorageOperation)(this.formatParameters(walletParams)));
|
|
199
173
|
}
|
|
200
|
-
mapOriginateParamsToWalletParams(params) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createOriginationOperation)(this.formatParameters(walletParams)));
|
|
212
|
-
});
|
|
174
|
+
async mapOriginateParamsToWalletParams(params) {
|
|
175
|
+
let walletParams;
|
|
176
|
+
await this.client.showPrepare();
|
|
177
|
+
try {
|
|
178
|
+
walletParams = await params();
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
await this.client.hideUI(['alert']);
|
|
182
|
+
throw err;
|
|
183
|
+
}
|
|
184
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createOriginationOperation)(this.formatParameters(walletParams)));
|
|
213
185
|
}
|
|
214
|
-
mapDelegateParamsToWalletParams(params) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createSetDelegateOperation)(this.formatParameters(walletParams)));
|
|
226
|
-
});
|
|
186
|
+
async mapDelegateParamsToWalletParams(params) {
|
|
187
|
+
let walletParams;
|
|
188
|
+
await this.client.showPrepare();
|
|
189
|
+
try {
|
|
190
|
+
walletParams = await params();
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
await this.client.hideUI(['alert']);
|
|
194
|
+
throw err;
|
|
195
|
+
}
|
|
196
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createSetDelegateOperation)(this.formatParameters(walletParams)));
|
|
227
197
|
}
|
|
228
|
-
mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return this.removeDefaultParams(walletParams, yield (0, taquito_1.createRegisterGlobalConstantOperation)(this.formatParameters(walletParams)));
|
|
240
|
-
});
|
|
198
|
+
async mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
199
|
+
let walletParams;
|
|
200
|
+
await this.client.showPrepare();
|
|
201
|
+
try {
|
|
202
|
+
walletParams = await params();
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
await this.client.hideUI(['alert']);
|
|
206
|
+
throw err;
|
|
207
|
+
}
|
|
208
|
+
return this.removeDefaultParams(walletParams, await (0, taquito_1.createRegisterGlobalConstantOperation)(this.formatParameters(walletParams)));
|
|
241
209
|
}
|
|
242
210
|
formatParameters(params) {
|
|
243
211
|
if (params.fee) {
|
|
@@ -266,20 +234,18 @@ class BeaconWallet {
|
|
|
266
234
|
}
|
|
267
235
|
return operatedParams;
|
|
268
236
|
}
|
|
269
|
-
sendOperations(params) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
return transactionHash;
|
|
279
|
-
});
|
|
237
|
+
async sendOperations(params) {
|
|
238
|
+
const account = await this.client.getActiveAccount();
|
|
239
|
+
if (!account) {
|
|
240
|
+
throw new errors_1.BeaconWalletNotInitialized();
|
|
241
|
+
}
|
|
242
|
+
const permissions = account.scopes;
|
|
243
|
+
this.validateRequiredScopesOrFail(permissions, [beacon_dapp_1.PermissionScope.OPERATION_REQUEST]);
|
|
244
|
+
const { transactionHash } = await this.client.requestOperation({ operationDetails: params });
|
|
245
|
+
return transactionHash;
|
|
280
246
|
}
|
|
281
247
|
/**
|
|
282
|
-
*
|
|
248
|
+
* Disconnect the wallet and remove all Beacon data from localStorage.
|
|
283
249
|
*
|
|
284
250
|
* This is the recommended way to end a user session (logout). It calls
|
|
285
251
|
* `client.destroy()` under the hood, which clears the active account,
|
|
@@ -291,13 +257,11 @@ class BeaconWallet {
|
|
|
291
257
|
*
|
|
292
258
|
* For switching accounts without a full logout, use {@link clearActiveAccount} instead.
|
|
293
259
|
*/
|
|
294
|
-
disconnect() {
|
|
295
|
-
|
|
296
|
-
yield this.client.destroy();
|
|
297
|
-
});
|
|
260
|
+
async disconnect() {
|
|
261
|
+
await this.client.destroy();
|
|
298
262
|
}
|
|
299
263
|
/**
|
|
300
|
-
*
|
|
264
|
+
* Clear the active account without destroying the Beacon session.
|
|
301
265
|
*
|
|
302
266
|
* This removes the active account reference from local storage but does
|
|
303
267
|
* **not** clear other Beacon state such as the cached relay node
|
|
@@ -308,28 +272,24 @@ class BeaconWallet {
|
|
|
308
272
|
*
|
|
309
273
|
* @see {@link disconnect}
|
|
310
274
|
*/
|
|
311
|
-
clearActiveAccount() {
|
|
312
|
-
|
|
313
|
-
yield this.client.setActiveAccount();
|
|
314
|
-
});
|
|
275
|
+
async clearActiveAccount() {
|
|
276
|
+
await this.client.setActiveAccount();
|
|
315
277
|
}
|
|
316
|
-
sign(bytes, watermark) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
signingType,
|
|
330
|
-
});
|
|
331
|
-
return signature;
|
|
278
|
+
async sign(bytes, watermark) {
|
|
279
|
+
let bb = (0, utils_1.hex2buf)(bytes);
|
|
280
|
+
if (typeof watermark !== 'undefined') {
|
|
281
|
+
bb = (0, utils_1.mergebuf)(watermark, bb);
|
|
282
|
+
}
|
|
283
|
+
const watermarkedBytes = (0, utils_1.buf2hex)((0, typedarray_to_buffer_1.default)(bb));
|
|
284
|
+
const signingType = this.getSigningType(watermark);
|
|
285
|
+
if (signingType !== beacon_dapp_1.SigningType.OPERATION) {
|
|
286
|
+
throw new core_1.UnsupportedActionError(`Taquito Beacon Wallet currently only supports signing operations, not ${signingType}`);
|
|
287
|
+
}
|
|
288
|
+
const { signature } = await this.client.requestSignPayload({
|
|
289
|
+
payload: watermarkedBytes,
|
|
290
|
+
signingType,
|
|
332
291
|
});
|
|
292
|
+
return signature;
|
|
333
293
|
}
|
|
334
294
|
getSigningType(watermark) {
|
|
335
295
|
if (!watermark || watermark.length === 0) {
|
package/dist/lib/version.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "24.
|
|
6
|
+
"commitHash": "05df48fee92f846cba793920d6fa829afd6a1847",
|
|
7
|
+
"version": "24.3.0-beta.1"
|
|
8
8
|
};
|