@taquito/beacon-wallet 17.3.2 → 17.4.0-beta-RC.0

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,10 +4,6 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.taquitoBeaconWallet = {}, global.beaconDapp, global.core, global.toBuffer, global.taquito, global.utils));
5
5
  })(this, (function (exports, beaconDapp, core, toBuffer, taquito, utils) { 'use strict';
6
6
 
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var toBuffer__default = /*#__PURE__*/_interopDefaultLegacy(toBuffer);
10
-
11
7
  /******************************************************************************
12
8
  Copyright (c) Microsoft Corporation.
13
9
 
@@ -22,6 +18,8 @@
22
18
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
19
  PERFORMANCE OF THIS SOFTWARE.
24
20
  ***************************************************************************** */
21
+ /* global Reflect, Promise, SuppressedError, Symbol */
22
+
25
23
 
26
24
  function __awaiter(thisArg, _arguments, P, generator) {
27
25
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -38,225 +36,225 @@
38
36
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
39
37
  };
40
38
 
41
- /**
42
- * @category Error
43
- * @description Error that indicates the Beacon wallet not being initialized
44
- */
45
- class BeaconWalletNotInitialized extends core.PermissionDeniedError {
46
- constructor() {
47
- super();
48
- this.name = 'BeaconWalletNotInitialized';
49
- this.message =
50
- 'BeaconWallet needs to be initialized by calling `await BeaconWallet.requestPermissions({network: {type: "chosen_network"}})` first.';
51
- }
52
- }
53
- /**
54
- * @category Error
55
- * @description Error that indicates missing required persmission scopes
56
- */
57
- class MissingRequiredScopes extends core.PermissionDeniedError {
58
- constructor(requiredScopes) {
59
- super();
60
- this.requiredScopes = requiredScopes;
61
- this.name = 'MissingRequiredScopes';
62
- this.message = `Required permissions scopes: ${requiredScopes.join(',')} were not granted.`;
63
- }
39
+ /**
40
+ * @category Error
41
+ * @description Error that indicates the Beacon wallet not being initialized
42
+ */
43
+ class BeaconWalletNotInitialized extends core.PermissionDeniedError {
44
+ constructor() {
45
+ super();
46
+ this.name = 'BeaconWalletNotInitialized';
47
+ this.message =
48
+ 'BeaconWallet needs to be initialized by calling `await BeaconWallet.requestPermissions({network: {type: "chosen_network"}})` first.';
49
+ }
50
+ }
51
+ /**
52
+ * @category Error
53
+ * @description Error that indicates missing required persmission scopes
54
+ */
55
+ class MissingRequiredScopes extends core.PermissionDeniedError {
56
+ constructor(requiredScopes) {
57
+ super();
58
+ this.requiredScopes = requiredScopes;
59
+ this.name = 'MissingRequiredScopes';
60
+ this.message = `Required permissions scopes: ${requiredScopes.join(',')} were not granted.`;
61
+ }
64
62
  }
65
63
 
66
- // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
67
- const VERSION = {
68
- "commitHash": "a97e506efd61b86e39ae30db588401b8fda46553",
69
- "version": "17.3.2"
64
+ // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
65
+ const VERSION = {
66
+ "commitHash": "4f44dd73b7659554c167acb80f0c20f222f893a5",
67
+ "version": "17.4.0-beta-RC.0"
70
68
  };
71
69
 
72
- /**
73
- * @packageDocumentation
74
- * @module @taquito/beacon-wallet
75
- */
76
- class BeaconWallet {
77
- constructor(options) {
78
- this.client = beaconDapp.getDAppClientInstance(options);
79
- }
80
- validateRequiredScopesOrFail(permissionScopes, requiredScopes) {
81
- const mandatoryScope = new Set(requiredScopes);
82
- for (const scope of permissionScopes) {
83
- if (mandatoryScope.has(scope)) {
84
- mandatoryScope.delete(scope);
85
- }
86
- }
87
- if (mandatoryScope.size > 0) {
88
- throw new MissingRequiredScopes(Array.from(mandatoryScope));
89
- }
90
- }
91
- requestPermissions(request) {
92
- return __awaiter(this, void 0, void 0, function* () {
93
- yield this.client.requestPermissions(request);
94
- });
95
- }
96
- getPKH() {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const account = yield this.client.getActiveAccount();
99
- if (!account) {
100
- throw new BeaconWalletNotInitialized();
101
- }
102
- return account.address;
103
- });
104
- }
105
- mapTransferParamsToWalletParams(params) {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- let walletParams;
108
- yield this.client.showPrepare();
109
- try {
110
- walletParams = yield params();
111
- }
112
- catch (err) {
113
- yield this.client.hideUI();
114
- throw err;
115
- }
116
- return this.removeDefaultParams(walletParams, yield taquito.createTransferOperation(this.formatParameters(walletParams)));
117
- });
118
- }
119
- mapIncreasePaidStorageWalletParams(params) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- let walletParams;
122
- yield this.client.showPrepare();
123
- try {
124
- walletParams = yield params();
125
- }
126
- catch (err) {
127
- yield this.client.hideUI();
128
- throw err;
129
- }
130
- return this.removeDefaultParams(walletParams, yield taquito.createIncreasePaidStorageOperation(this.formatParameters(walletParams)));
131
- });
132
- }
133
- mapOriginateParamsToWalletParams(params) {
134
- return __awaiter(this, void 0, void 0, function* () {
135
- let walletParams;
136
- yield this.client.showPrepare();
137
- try {
138
- walletParams = yield params();
139
- }
140
- catch (err) {
141
- yield this.client.hideUI();
142
- throw err;
143
- }
144
- return this.removeDefaultParams(walletParams, yield taquito.createOriginationOperation(this.formatParameters(walletParams)));
145
- });
146
- }
147
- mapDelegateParamsToWalletParams(params) {
148
- return __awaiter(this, void 0, void 0, function* () {
149
- let walletParams;
150
- yield this.client.showPrepare();
151
- try {
152
- walletParams = yield params();
153
- }
154
- catch (err) {
155
- yield this.client.hideUI();
156
- throw err;
157
- }
158
- return this.removeDefaultParams(walletParams, yield taquito.createSetDelegateOperation(this.formatParameters(walletParams)));
159
- });
160
- }
161
- formatParameters(params) {
162
- if (params.fee) {
163
- params.fee = params.fee.toString();
164
- }
165
- if (params.storageLimit) {
166
- params.storageLimit = params.storageLimit.toString();
167
- }
168
- if (params.gasLimit) {
169
- params.gasLimit = params.gasLimit.toString();
170
- }
171
- return params;
172
- }
173
- removeDefaultParams(params, operatedParams) {
174
- // If fee, storageLimit or gasLimit is undefined by user
175
- // in case of beacon wallet, dont override it by
176
- // defaults.
177
- if (!params.fee) {
178
- delete operatedParams.fee;
179
- }
180
- if (!params.storageLimit) {
181
- delete operatedParams.storage_limit;
182
- }
183
- if (!params.gasLimit) {
184
- delete operatedParams.gas_limit;
185
- }
186
- return operatedParams;
187
- }
188
- sendOperations(params) {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- const account = yield this.client.getActiveAccount();
191
- if (!account) {
192
- throw new BeaconWalletNotInitialized();
193
- }
194
- const permissions = account.scopes;
195
- this.validateRequiredScopesOrFail(permissions, [beaconDapp.PermissionScope.OPERATION_REQUEST]);
196
- const { transactionHash } = yield this.client.requestOperation({ operationDetails: params });
197
- return transactionHash;
198
- });
199
- }
200
- /**
201
- *
202
- * @description Removes all beacon values from the storage. After using this method, this instance is no longer usable.
203
- * You will have to instantiate a new BeaconWallet.
204
- */
205
- disconnect() {
206
- return __awaiter(this, void 0, void 0, function* () {
207
- yield this.client.destroy();
208
- });
209
- }
210
- /**
211
- *
212
- * @description This method removes the active account from local storage by setting it to undefined.
213
- */
214
- clearActiveAccount() {
215
- return __awaiter(this, void 0, void 0, function* () {
216
- yield this.client.setActiveAccount();
217
- });
218
- }
219
- sign(bytes, watermark) {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- let bb = utils.hex2buf(bytes);
222
- if (typeof watermark !== 'undefined') {
223
- bb = utils.mergebuf(watermark, bb);
224
- }
225
- const watermarkedBytes = utils.buf2hex(toBuffer__default["default"](bb));
226
- const signingType = this.getSigningType(watermark);
227
- if (signingType !== beaconDapp.SigningType.OPERATION) {
228
- throw new core.UnsupportedActionError(`Taquito Beacon Wallet currently only supports signing operations, not ${signingType}`);
229
- }
230
- const { signature } = yield this.client.requestSignPayload({
231
- payload: watermarkedBytes,
232
- signingType,
233
- });
234
- return signature;
235
- });
236
- }
237
- getSigningType(watermark) {
238
- if (!watermark || watermark.length === 0) {
239
- return beaconDapp.SigningType.RAW;
240
- }
241
- if (watermark.length === 1) {
242
- if (watermark[0] === 5) {
243
- return beaconDapp.SigningType.MICHELINE;
244
- }
245
- if (watermark[0] === 3) {
246
- return beaconDapp.SigningType.OPERATION;
247
- }
248
- }
249
- throw new Error(`Invalid watermark ${JSON.stringify(watermark)}`);
250
- }
251
- getPK() {
252
- return __awaiter(this, void 0, void 0, function* () {
253
- const account = yield this.client.getActiveAccount();
254
- if (!account) {
255
- throw new BeaconWalletNotInitialized();
256
- }
257
- return account === null || account === void 0 ? void 0 : account.publicKey;
258
- });
259
- }
70
+ /**
71
+ * @packageDocumentation
72
+ * @module @taquito/beacon-wallet
73
+ */
74
+ class BeaconWallet {
75
+ constructor(options) {
76
+ this.client = beaconDapp.getDAppClientInstance(options);
77
+ }
78
+ validateRequiredScopesOrFail(permissionScopes, requiredScopes) {
79
+ const mandatoryScope = new Set(requiredScopes);
80
+ for (const scope of permissionScopes) {
81
+ if (mandatoryScope.has(scope)) {
82
+ mandatoryScope.delete(scope);
83
+ }
84
+ }
85
+ if (mandatoryScope.size > 0) {
86
+ throw new MissingRequiredScopes(Array.from(mandatoryScope));
87
+ }
88
+ }
89
+ requestPermissions(request) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ yield this.client.requestPermissions(request);
92
+ });
93
+ }
94
+ getPKH() {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const account = yield this.client.getActiveAccount();
97
+ if (!account) {
98
+ throw new BeaconWalletNotInitialized();
99
+ }
100
+ return account.address;
101
+ });
102
+ }
103
+ mapTransferParamsToWalletParams(params) {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ let walletParams;
106
+ yield this.client.showPrepare();
107
+ try {
108
+ walletParams = yield params();
109
+ }
110
+ catch (err) {
111
+ yield this.client.hideUI();
112
+ throw err;
113
+ }
114
+ return this.removeDefaultParams(walletParams, yield taquito.createTransferOperation(this.formatParameters(walletParams)));
115
+ });
116
+ }
117
+ mapIncreasePaidStorageWalletParams(params) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ let walletParams;
120
+ yield this.client.showPrepare();
121
+ try {
122
+ walletParams = yield params();
123
+ }
124
+ catch (err) {
125
+ yield this.client.hideUI();
126
+ throw err;
127
+ }
128
+ return this.removeDefaultParams(walletParams, yield taquito.createIncreasePaidStorageOperation(this.formatParameters(walletParams)));
129
+ });
130
+ }
131
+ mapOriginateParamsToWalletParams(params) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ let walletParams;
134
+ yield this.client.showPrepare();
135
+ try {
136
+ walletParams = yield params();
137
+ }
138
+ catch (err) {
139
+ yield this.client.hideUI();
140
+ throw err;
141
+ }
142
+ return this.removeDefaultParams(walletParams, yield taquito.createOriginationOperation(this.formatParameters(walletParams)));
143
+ });
144
+ }
145
+ mapDelegateParamsToWalletParams(params) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ let walletParams;
148
+ yield this.client.showPrepare();
149
+ try {
150
+ walletParams = yield params();
151
+ }
152
+ catch (err) {
153
+ yield this.client.hideUI();
154
+ throw err;
155
+ }
156
+ return this.removeDefaultParams(walletParams, yield taquito.createSetDelegateOperation(this.formatParameters(walletParams)));
157
+ });
158
+ }
159
+ formatParameters(params) {
160
+ if (params.fee) {
161
+ params.fee = params.fee.toString();
162
+ }
163
+ if (params.storageLimit) {
164
+ params.storageLimit = params.storageLimit.toString();
165
+ }
166
+ if (params.gasLimit) {
167
+ params.gasLimit = params.gasLimit.toString();
168
+ }
169
+ return params;
170
+ }
171
+ removeDefaultParams(params, operatedParams) {
172
+ // If fee, storageLimit or gasLimit is undefined by user
173
+ // in case of beacon wallet, dont override it by
174
+ // defaults.
175
+ if (!params.fee) {
176
+ delete operatedParams.fee;
177
+ }
178
+ if (!params.storageLimit) {
179
+ delete operatedParams.storage_limit;
180
+ }
181
+ if (!params.gasLimit) {
182
+ delete operatedParams.gas_limit;
183
+ }
184
+ return operatedParams;
185
+ }
186
+ sendOperations(params) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const account = yield this.client.getActiveAccount();
189
+ if (!account) {
190
+ throw new BeaconWalletNotInitialized();
191
+ }
192
+ const permissions = account.scopes;
193
+ this.validateRequiredScopesOrFail(permissions, [beaconDapp.PermissionScope.OPERATION_REQUEST]);
194
+ const { transactionHash } = yield this.client.requestOperation({ operationDetails: params });
195
+ return transactionHash;
196
+ });
197
+ }
198
+ /**
199
+ *
200
+ * @description Removes all beacon values from the storage. After using this method, this instance is no longer usable.
201
+ * You will have to instantiate a new BeaconWallet.
202
+ */
203
+ disconnect() {
204
+ return __awaiter(this, void 0, void 0, function* () {
205
+ yield this.client.destroy();
206
+ });
207
+ }
208
+ /**
209
+ *
210
+ * @description This method removes the active account from local storage by setting it to undefined.
211
+ */
212
+ clearActiveAccount() {
213
+ return __awaiter(this, void 0, void 0, function* () {
214
+ yield this.client.setActiveAccount();
215
+ });
216
+ }
217
+ sign(bytes, watermark) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ let bb = utils.hex2buf(bytes);
220
+ if (typeof watermark !== 'undefined') {
221
+ bb = utils.mergebuf(watermark, bb);
222
+ }
223
+ const watermarkedBytes = utils.buf2hex(toBuffer(bb));
224
+ const signingType = this.getSigningType(watermark);
225
+ if (signingType !== beaconDapp.SigningType.OPERATION) {
226
+ throw new core.UnsupportedActionError(`Taquito Beacon Wallet currently only supports signing operations, not ${signingType}`);
227
+ }
228
+ const { signature } = yield this.client.requestSignPayload({
229
+ payload: watermarkedBytes,
230
+ signingType,
231
+ });
232
+ return signature;
233
+ });
234
+ }
235
+ getSigningType(watermark) {
236
+ if (!watermark || watermark.length === 0) {
237
+ return beaconDapp.SigningType.RAW;
238
+ }
239
+ if (watermark.length === 1) {
240
+ if (watermark[0] === 5) {
241
+ return beaconDapp.SigningType.MICHELINE;
242
+ }
243
+ if (watermark[0] === 3) {
244
+ return beaconDapp.SigningType.OPERATION;
245
+ }
246
+ }
247
+ throw new Error(`Invalid watermark ${JSON.stringify(watermark)}`);
248
+ }
249
+ getPK() {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ const account = yield this.client.getActiveAccount();
252
+ if (!account) {
253
+ throw new BeaconWalletNotInitialized();
254
+ }
255
+ return account === null || account === void 0 ? void 0 : account.publicKey;
256
+ });
257
+ }
260
258
  }
261
259
 
262
260
  exports.BeaconWallet = BeaconWallet;
@@ -264,7 +262,5 @@
264
262
  exports.MissingRequiredScopes = MissingRequiredScopes;
265
263
  exports.VERSION = VERSION;
266
264
 
267
- Object.defineProperty(exports, '__esModule', { value: true });
268
-
269
265
  }));
270
266
  //# sourceMappingURL=taquito-beacon-wallet.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-beacon-wallet.umd.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-beacon-wallet.ts"],"sourcesContent":["import { PermissionScope } from '@airgap/beacon-dapp';\nimport { PermissionDeniedError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates the Beacon wallet not being initialized\n */\nexport class BeaconWalletNotInitialized extends PermissionDeniedError {\n constructor() {\n super();\n this.name = 'BeaconWalletNotInitialized';\n this.message =\n 'BeaconWallet needs to be initialized by calling `await BeaconWallet.requestPermissions({network: {type: \"chosen_network\"}})` first.';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates missing required persmission scopes\n */\nexport class MissingRequiredScopes extends PermissionDeniedError {\n constructor(public readonly requiredScopes: PermissionScope[]) {\n super();\n this.name = 'MissingRequiredScopes';\n this.message = `Required permissions scopes: ${requiredScopes.join(',')} were not granted.`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"a97e506efd61b86e39ae30db588401b8fda46553\",\n \"version\": \"17.3.2\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/beacon-wallet\n */\n\nimport {\n DAppClient,\n DAppClientOptions,\n RequestPermissionInput,\n PermissionScope,\n getDAppClientInstance,\n SigningType,\n} from '@airgap/beacon-dapp';\nimport { BeaconWalletNotInitialized, MissingRequiredScopes } from './errors';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n createIncreasePaidStorageOperation,\n createOriginationOperation,\n createSetDelegateOperation,\n createTransferOperation,\n WalletDelegateParams,\n WalletIncreasePaidStorageParams,\n WalletOriginateParams,\n WalletProvider,\n WalletTransferParams,\n} from '@taquito/taquito';\nimport { buf2hex, hex2buf, mergebuf } from '@taquito/utils';\nimport { UnsupportedActionError } from '@taquito/core';\n\nexport { VERSION } from './version';\nexport { BeaconWalletNotInitialized, MissingRequiredScopes } from './errors';\n\nexport class BeaconWallet implements WalletProvider {\n public client: DAppClient;\n\n constructor(options: DAppClientOptions) {\n this.client = getDAppClientInstance(options);\n }\n\n private validateRequiredScopesOrFail(\n permissionScopes: PermissionScope[],\n requiredScopes: PermissionScope[]\n ) {\n const mandatoryScope = new Set(requiredScopes);\n\n for (const scope of permissionScopes) {\n if (mandatoryScope.has(scope)) {\n mandatoryScope.delete(scope);\n }\n }\n\n if (mandatoryScope.size > 0) {\n throw new MissingRequiredScopes(Array.from(mandatoryScope));\n }\n }\n\n async requestPermissions(request?: RequestPermissionInput) {\n await this.client.requestPermissions(request);\n }\n\n async getPKH() {\n const account = await this.client.getActiveAccount();\n if (!account) {\n throw new BeaconWalletNotInitialized();\n }\n return account.address;\n }\n\n async mapTransferParamsToWalletParams(params: () => Promise<WalletTransferParams>) {\n let walletParams: WalletTransferParams;\n await this.client.showPrepare();\n try {\n walletParams = await params();\n } catch (err) {\n await this.client.hideUI();\n throw err;\n }\n return this.removeDefaultParams(\n walletParams,\n await createTransferOperation(this.formatParameters(walletParams))\n );\n }\n\n async mapIncreasePaidStorageWalletParams(params: () => Promise<WalletIncreasePaidStorageParams>) {\n let walletParams: WalletIncreasePaidStorageParams;\n await this.client.showPrepare();\n try {\n walletParams = await params();\n } catch (err) {\n await this.client.hideUI();\n throw err;\n }\n return this.removeDefaultParams(\n walletParams,\n await createIncreasePaidStorageOperation(this.formatParameters(walletParams))\n );\n }\n\n async mapOriginateParamsToWalletParams(params: () => Promise<WalletOriginateParams>) {\n let walletParams: WalletOriginateParams;\n await this.client.showPrepare();\n try {\n walletParams = await params();\n } catch (err) {\n await this.client.hideUI();\n throw err;\n }\n return this.removeDefaultParams(\n walletParams,\n await createOriginationOperation(this.formatParameters(walletParams))\n );\n }\n\n async mapDelegateParamsToWalletParams(params: () => Promise<WalletDelegateParams>) {\n let walletParams: WalletDelegateParams;\n await this.client.showPrepare();\n try {\n walletParams = await params();\n } catch (err) {\n await this.client.hideUI();\n throw err;\n }\n return this.removeDefaultParams(\n walletParams,\n await createSetDelegateOperation(this.formatParameters(walletParams))\n );\n }\n\n formatParameters(params: any) {\n if (params.fee) {\n params.fee = params.fee.toString();\n }\n if (params.storageLimit) {\n params.storageLimit = params.storageLimit.toString();\n }\n if (params.gasLimit) {\n params.gasLimit = params.gasLimit.toString();\n }\n return params;\n }\n\n removeDefaultParams(\n params: WalletTransferParams | WalletOriginateParams | WalletDelegateParams,\n operatedParams: any\n ) {\n // If fee, storageLimit or gasLimit is undefined by user\n // in case of beacon wallet, dont override it by\n // defaults.\n if (!params.fee) {\n delete operatedParams.fee;\n }\n if (!params.storageLimit) {\n delete operatedParams.storage_limit;\n }\n if (!params.gasLimit) {\n delete operatedParams.gas_limit;\n }\n return operatedParams;\n }\n\n async sendOperations(params: any[]) {\n const account = await this.client.getActiveAccount();\n if (!account) {\n throw new BeaconWalletNotInitialized();\n }\n const permissions = account.scopes;\n this.validateRequiredScopesOrFail(permissions, [PermissionScope.OPERATION_REQUEST]);\n\n const { transactionHash } = await this.client.requestOperation({ operationDetails: params });\n return transactionHash;\n }\n\n /**\n *\n * @description Removes all beacon values from the storage. After using this method, this instance is no longer usable.\n * You will have to instantiate a new BeaconWallet.\n */\n async disconnect() {\n await this.client.destroy();\n }\n\n /**\n *\n * @description This method removes the active account from local storage by setting it to undefined.\n */\n async clearActiveAccount() {\n await this.client.setActiveAccount();\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n const watermarkedBytes = buf2hex(toBuffer(bb));\n const signingType = this.getSigningType(watermark);\n if (signingType !== SigningType.OPERATION) {\n throw new UnsupportedActionError(\n `Taquito Beacon Wallet currently only supports signing operations, not ${signingType}`\n );\n }\n const { signature } = await this.client.requestSignPayload({\n payload: watermarkedBytes,\n signingType,\n });\n return signature;\n }\n\n private getSigningType(watermark?: Uint8Array) {\n if (!watermark || watermark.length === 0) {\n return SigningType.RAW;\n }\n if (watermark.length === 1) {\n if (watermark[0] === 5) {\n return SigningType.MICHELINE;\n }\n if (watermark[0] === 3) {\n return SigningType.OPERATION;\n }\n }\n throw new Error(`Invalid watermark ${JSON.stringify(watermark)}`);\n }\n\n async getPK() {\n const account = await this.client.getActiveAccount();\n if (!account) {\n throw new BeaconWalletNotInitialized();\n }\n return account?.publicKey;\n }\n}\n"],"names":["PermissionDeniedError","getDAppClientInstance","createTransferOperation","createIncreasePaidStorageOperation","createOriginationOperation","createSetDelegateOperation","PermissionScope","hex2buf","mergebuf","buf2hex","toBuffer","SigningType","UnsupportedActionError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAGA;;;IAGG;IACG,MAAO,0BAA2B,SAAQA,0BAAqB,CAAA;IACnE,IAAA,WAAA,GAAA;IACE,QAAA,KAAK,EAAE,CAAC;IACR,QAAA,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;IACzC,QAAA,IAAI,CAAC,OAAO;IACV,YAAA,qIAAqI,CAAC;SACzI;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,qBAAsB,SAAQA,0BAAqB,CAAA;IAC9D,IAAA,WAAA,CAA4B,cAAiC,EAAA;IAC3D,QAAA,KAAK,EA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IAAI,KAAK,CAAC,CAAA,kBAAA,EAAqB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAE,CAAA,CAAC,CAAC;SACnE;QAEK,KAAK,GAAA;;gBACT,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;gBACrD,IAAI,CAAC,OAAO,EAAE;oBACZ,MAAM,IAAI,0BAA0B,EAAE,CAAC;IACxC,aAAA;IACD,YAAA,OAAO,OAAO,KAAP,IAAA,IAAA,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAC;aAC3B,CAAA,CAAA;IAAA,KAAA;IACF;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-beacon-wallet.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,17 +1,17 @@
1
- import { PermissionScope } from '@airgap/beacon-dapp';
2
- import { PermissionDeniedError } from '@taquito/core';
3
- /**
4
- * @category Error
5
- * @description Error that indicates the Beacon wallet not being initialized
6
- */
7
- export declare class BeaconWalletNotInitialized extends PermissionDeniedError {
8
- constructor();
9
- }
10
- /**
11
- * @category Error
12
- * @description Error that indicates missing required persmission scopes
13
- */
14
- export declare class MissingRequiredScopes extends PermissionDeniedError {
15
- readonly requiredScopes: PermissionScope[];
16
- constructor(requiredScopes: PermissionScope[]);
17
- }
1
+ import { PermissionScope } from '@airgap/beacon-dapp';
2
+ import { PermissionDeniedError } from '@taquito/core';
3
+ /**
4
+ * @category Error
5
+ * @description Error that indicates the Beacon wallet not being initialized
6
+ */
7
+ export declare class BeaconWalletNotInitialized extends PermissionDeniedError {
8
+ constructor();
9
+ }
10
+ /**
11
+ * @category Error
12
+ * @description Error that indicates missing required persmission scopes
13
+ */
14
+ export declare class MissingRequiredScopes extends PermissionDeniedError {
15
+ readonly requiredScopes: PermissionScope[];
16
+ constructor(requiredScopes: PermissionScope[]);
17
+ }
@@ -1,36 +1,36 @@
1
- /**
2
- * @packageDocumentation
3
- * @module @taquito/beacon-wallet
4
- */
5
- import { DAppClient, DAppClientOptions, RequestPermissionInput } from '@airgap/beacon-dapp';
6
- import { WalletDelegateParams, WalletIncreasePaidStorageParams, WalletOriginateParams, WalletProvider, WalletTransferParams } from '@taquito/taquito';
7
- export { VERSION } from './version';
8
- export { BeaconWalletNotInitialized, MissingRequiredScopes } from './errors';
9
- export declare class BeaconWallet implements WalletProvider {
10
- client: DAppClient;
11
- constructor(options: DAppClientOptions);
12
- private validateRequiredScopesOrFail;
13
- requestPermissions(request?: RequestPermissionInput): Promise<void>;
14
- getPKH(): Promise<string>;
15
- mapTransferParamsToWalletParams(params: () => Promise<WalletTransferParams>): Promise<any>;
16
- mapIncreasePaidStorageWalletParams(params: () => Promise<WalletIncreasePaidStorageParams>): Promise<any>;
17
- mapOriginateParamsToWalletParams(params: () => Promise<WalletOriginateParams>): Promise<any>;
18
- mapDelegateParamsToWalletParams(params: () => Promise<WalletDelegateParams>): Promise<any>;
19
- formatParameters(params: any): any;
20
- removeDefaultParams(params: WalletTransferParams | WalletOriginateParams | WalletDelegateParams, operatedParams: any): any;
21
- sendOperations(params: any[]): Promise<string>;
22
- /**
23
- *
24
- * @description Removes all beacon values from the storage. After using this method, this instance is no longer usable.
25
- * You will have to instantiate a new BeaconWallet.
26
- */
27
- disconnect(): Promise<void>;
28
- /**
29
- *
30
- * @description This method removes the active account from local storage by setting it to undefined.
31
- */
32
- clearActiveAccount(): Promise<void>;
33
- sign(bytes: string, watermark?: Uint8Array): Promise<string>;
34
- private getSigningType;
35
- getPK(): Promise<string>;
36
- }
1
+ /**
2
+ * @packageDocumentation
3
+ * @module @taquito/beacon-wallet
4
+ */
5
+ import { DAppClient, DAppClientOptions, RequestPermissionInput } from '@airgap/beacon-dapp';
6
+ import { WalletDelegateParams, WalletIncreasePaidStorageParams, WalletOriginateParams, WalletProvider, WalletTransferParams } from '@taquito/taquito';
7
+ export { VERSION } from './version';
8
+ export { BeaconWalletNotInitialized, MissingRequiredScopes } from './errors';
9
+ export declare class BeaconWallet implements WalletProvider {
10
+ client: DAppClient;
11
+ constructor(options: DAppClientOptions);
12
+ private validateRequiredScopesOrFail;
13
+ requestPermissions(request?: RequestPermissionInput): Promise<void>;
14
+ getPKH(): Promise<string>;
15
+ mapTransferParamsToWalletParams(params: () => Promise<WalletTransferParams>): Promise<any>;
16
+ mapIncreasePaidStorageWalletParams(params: () => Promise<WalletIncreasePaidStorageParams>): Promise<any>;
17
+ mapOriginateParamsToWalletParams(params: () => Promise<WalletOriginateParams>): Promise<any>;
18
+ mapDelegateParamsToWalletParams(params: () => Promise<WalletDelegateParams>): Promise<any>;
19
+ formatParameters(params: any): any;
20
+ removeDefaultParams(params: WalletTransferParams | WalletOriginateParams | WalletDelegateParams, operatedParams: any): any;
21
+ sendOperations(params: any[]): Promise<string>;
22
+ /**
23
+ *
24
+ * @description Removes all beacon values from the storage. After using this method, this instance is no longer usable.
25
+ * You will have to instantiate a new BeaconWallet.
26
+ */
27
+ disconnect(): Promise<void>;
28
+ /**
29
+ *
30
+ * @description This method removes the active account from local storage by setting it to undefined.
31
+ */
32
+ clearActiveAccount(): Promise<void>;
33
+ sign(bytes: string, watermark?: Uint8Array): Promise<string>;
34
+ private getSigningType;
35
+ getPK(): Promise<string>;
36
+ }
@@ -1,4 +1,4 @@
1
- export declare const VERSION: {
2
- commitHash: string;
3
- version: string;
4
- };
1
+ export declare const VERSION: {
2
+ commitHash: string;
3
+ version: string;
4
+ };