@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.
@@ -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
- * @description Error that indicates the Beacon wallet not being initialized
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
- * @description Error that indicates missing required permission scopes
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
- var _a;
78
- const matrixNodes = Object.assign(Object.assign({}, TAQUITO_CURATED_MATRIX_NODES), ((_a = options.matrixNodes) !== null && _a !== void 0 ? _a : {}));
79
- this.client = (0, beacon_dapp_1.getDAppClientInstance)(Object.assign(Object.assign({}, options), { matrixNodes }));
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
- return __awaiter(this, void 0, void 0, function* () {
94
- yield this.client.requestPermissions(request);
95
- });
85
+ async requestPermissions(request) {
86
+ await this.client.requestPermissions(request);
96
87
  }
97
- getPKH() {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const account = yield this.client.getActiveAccount();
100
- if (!account) {
101
- throw new errors_1.BeaconWalletNotInitialized();
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
- return __awaiter(this, void 0, void 0, function* () {
108
- var _a;
109
- const account = yield this.client.getActiveAccount();
110
- if (!account) {
111
- throw new errors_1.BeaconWalletNotInitialized();
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
- return __awaiter(this, void 0, void 0, function* () {
118
- let walletParams;
119
- yield this.client.showPrepare();
120
- try {
121
- walletParams = yield params();
122
- }
123
- catch (err) {
124
- yield this.client.hideUI(['alert']);
125
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
132
- let walletParams;
133
- yield this.client.showPrepare();
134
- try {
135
- walletParams = yield params();
136
- }
137
- catch (err) {
138
- yield this.client.hideUI(['alert']);
139
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
146
- let walletParams;
147
- yield this.client.showPrepare();
148
- try {
149
- walletParams = yield params();
150
- }
151
- catch (err) {
152
- yield this.client.hideUI(['alert']);
153
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
160
- let walletParams;
161
- yield this.client.showPrepare();
162
- try {
163
- walletParams = yield params();
164
- }
165
- catch (err) {
166
- yield this.client.hideUI(['alert']);
167
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
174
- let walletParams;
175
- yield this.client.showPrepare();
176
- try {
177
- walletParams = yield params();
178
- }
179
- catch (err) {
180
- yield this.client.hideUI(['alert']);
181
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
188
- let walletParams;
189
- yield this.client.showPrepare();
190
- try {
191
- walletParams = yield params();
192
- }
193
- catch (err) {
194
- yield this.client.hideUI(['alert']);
195
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
202
- let walletParams;
203
- yield this.client.showPrepare();
204
- try {
205
- walletParams = yield params();
206
- }
207
- catch (err) {
208
- yield this.client.hideUI(['alert']);
209
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
216
- let walletParams;
217
- yield this.client.showPrepare();
218
- try {
219
- walletParams = yield params();
220
- }
221
- catch (err) {
222
- yield this.client.hideUI(['alert']);
223
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
230
- let walletParams;
231
- yield this.client.showPrepare();
232
- try {
233
- walletParams = yield params();
234
- }
235
- catch (err) {
236
- yield this.client.hideUI(['alert']);
237
- throw err;
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
- return __awaiter(this, void 0, void 0, function* () {
271
- const account = yield this.client.getActiveAccount();
272
- if (!account) {
273
- throw new errors_1.BeaconWalletNotInitialized();
274
- }
275
- const permissions = account.scopes;
276
- this.validateRequiredScopesOrFail(permissions, [beacon_dapp_1.PermissionScope.OPERATION_REQUEST]);
277
- const { transactionHash } = yield this.client.requestOperation({ operationDetails: params });
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
- * @description Disconnect the wallet and remove all Beacon data from localStorage.
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
- return __awaiter(this, void 0, void 0, function* () {
296
- yield this.client.destroy();
297
- });
260
+ async disconnect() {
261
+ await this.client.destroy();
298
262
  }
299
263
  /**
300
- * @description Clear the active account without destroying the Beacon session.
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
- return __awaiter(this, void 0, void 0, function* () {
313
- yield this.client.setActiveAccount();
314
- });
275
+ async clearActiveAccount() {
276
+ await this.client.setActiveAccount();
315
277
  }
316
- sign(bytes, watermark) {
317
- return __awaiter(this, void 0, void 0, function* () {
318
- let bb = (0, utils_1.hex2buf)(bytes);
319
- if (typeof watermark !== 'undefined') {
320
- bb = (0, utils_1.mergebuf)(watermark, bb);
321
- }
322
- const watermarkedBytes = (0, utils_1.buf2hex)((0, typedarray_to_buffer_1.default)(bb));
323
- const signingType = this.getSigningType(watermark);
324
- if (signingType !== beacon_dapp_1.SigningType.OPERATION) {
325
- throw new core_1.UnsupportedActionError(`Taquito Beacon Wallet currently only supports signing operations, not ${signingType}`);
326
- }
327
- const { signature } = yield this.client.requestSignPayload({
328
- payload: watermarkedBytes,
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) {
@@ -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": "105a7b15cfb862a0732c204e0e9741098d697775",
7
- "version": "24.2.0"
6
+ "commitHash": "05df48fee92f846cba793920d6fa829afd6a1847",
7
+ "version": "24.3.0-beta.1"
8
8
  };