@taquito/wallet-connect 24.2.0 → 24.3.0-beta.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.
- package/dist/lib/errors.js +11 -11
- package/dist/lib/taquito-wallet-connect.js +168 -213
- package/dist/lib/version.js +2 -2
- package/dist/taquito-wallet-connect.es6.js +179 -247
- package/dist/taquito-wallet-connect.es6.js.map +1 -1
- package/dist/taquito-wallet-connect.umd.js +651 -719
- package/dist/taquito-wallet-connect.umd.js.map +1 -1
- package/dist/types/errors.d.ts +13 -13
- package/dist/types/taquito-wallet-connect.d.ts +29 -29
- package/package.json +21 -9
- package/LICENSE +0 -202
|
@@ -3,38 +3,6 @@ import { WalletConnectModal } from '@walletconnect/modal';
|
|
|
3
3
|
import { createTransferOperation, createTransferTicketOperation, createOriginationOperation, createSetDelegateOperation, createIncreasePaidStorageOperation, createRegisterGlobalConstantOperation } from '@taquito/taquito';
|
|
4
4
|
import { getSdkError } from '@walletconnect/utils';
|
|
5
5
|
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */
|
|
20
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
-
var e = new Error(message);
|
|
35
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
6
|
var NetworkType;
|
|
39
7
|
(function (NetworkType) {
|
|
40
8
|
NetworkType["MAINNET"] = "mainnet";
|
|
@@ -65,7 +33,7 @@ var SigningType;
|
|
|
65
33
|
|
|
66
34
|
/**
|
|
67
35
|
* @category Error
|
|
68
|
-
*
|
|
36
|
+
* Error that indicates missing required permission scopes
|
|
69
37
|
*/
|
|
70
38
|
class MissingRequiredScope extends Error {
|
|
71
39
|
constructor(requiredScopes) {
|
|
@@ -76,7 +44,7 @@ class MissingRequiredScope extends Error {
|
|
|
76
44
|
}
|
|
77
45
|
/**
|
|
78
46
|
* @category Error
|
|
79
|
-
*
|
|
47
|
+
* Error that indicates the wallet returned an invalid namespace
|
|
80
48
|
*/
|
|
81
49
|
class InvalidReceivedSessionNamespace extends Error {
|
|
82
50
|
constructor(messageWc, codeWc, type, data) {
|
|
@@ -95,7 +63,7 @@ class InvalidReceivedSessionNamespace extends Error {
|
|
|
95
63
|
}
|
|
96
64
|
/**
|
|
97
65
|
* @category Error
|
|
98
|
-
*
|
|
66
|
+
* Error that indicates an invalid session key being passed
|
|
99
67
|
*/
|
|
100
68
|
class InvalidSessionKey extends Error {
|
|
101
69
|
constructor(key) {
|
|
@@ -106,7 +74,7 @@ class InvalidSessionKey extends Error {
|
|
|
106
74
|
}
|
|
107
75
|
/**
|
|
108
76
|
* @category Error
|
|
109
|
-
*
|
|
77
|
+
* Error that indicates the pkh is not part of the active accounts in the session
|
|
110
78
|
*/
|
|
111
79
|
class InvalidAccount extends Error {
|
|
112
80
|
constructor(pkh) {
|
|
@@ -117,7 +85,7 @@ class InvalidAccount extends Error {
|
|
|
117
85
|
}
|
|
118
86
|
/**
|
|
119
87
|
* @category Error
|
|
120
|
-
*
|
|
88
|
+
* Error that indicates the network is not part of the active networks in the session
|
|
121
89
|
*/
|
|
122
90
|
class InvalidNetwork extends Error {
|
|
123
91
|
constructor(network) {
|
|
@@ -128,7 +96,7 @@ class InvalidNetwork extends Error {
|
|
|
128
96
|
}
|
|
129
97
|
/**
|
|
130
98
|
* @category Error
|
|
131
|
-
*
|
|
99
|
+
* Error that indicates the combinaison pkh-network is not part of the active session
|
|
132
100
|
*/
|
|
133
101
|
class InvalidNetworkOrAccount extends Error {
|
|
134
102
|
constructor(network, pkh) {
|
|
@@ -140,7 +108,7 @@ class InvalidNetworkOrAccount extends Error {
|
|
|
140
108
|
}
|
|
141
109
|
/**
|
|
142
110
|
* @category Error
|
|
143
|
-
*
|
|
111
|
+
* Error that indicates the connection could not be established
|
|
144
112
|
*/
|
|
145
113
|
class ConnectionFailed extends Error {
|
|
146
114
|
constructor(originalError) {
|
|
@@ -151,7 +119,7 @@ class ConnectionFailed extends Error {
|
|
|
151
119
|
}
|
|
152
120
|
/**
|
|
153
121
|
* @category Error
|
|
154
|
-
*
|
|
122
|
+
* Error that indicates there is no active session
|
|
155
123
|
*/
|
|
156
124
|
class NotConnected extends Error {
|
|
157
125
|
constructor() {
|
|
@@ -161,7 +129,7 @@ class NotConnected extends Error {
|
|
|
161
129
|
}
|
|
162
130
|
/**
|
|
163
131
|
* @category Error
|
|
164
|
-
*
|
|
132
|
+
* Error that indicates the active account is not specified
|
|
165
133
|
*/
|
|
166
134
|
class ActiveAccountUnspecified extends Error {
|
|
167
135
|
constructor() {
|
|
@@ -171,7 +139,7 @@ class ActiveAccountUnspecified extends Error {
|
|
|
171
139
|
}
|
|
172
140
|
/**
|
|
173
141
|
* @category Error
|
|
174
|
-
*
|
|
142
|
+
* Error that indicates the active network is not specified
|
|
175
143
|
*/
|
|
176
144
|
class ActiveNetworkUnspecified extends Error {
|
|
177
145
|
constructor() {
|
|
@@ -181,7 +149,7 @@ class ActiveNetworkUnspecified extends Error {
|
|
|
181
149
|
}
|
|
182
150
|
/**
|
|
183
151
|
* @category Error
|
|
184
|
-
*
|
|
152
|
+
* Error that indicates the session is invalid
|
|
185
153
|
*/
|
|
186
154
|
class InvalidSession extends Error {
|
|
187
155
|
constructor(message) {
|
|
@@ -202,9 +170,9 @@ class PublicKeyRetrievalError extends Error {
|
|
|
202
170
|
*/
|
|
203
171
|
const TEZOS_PLACEHOLDER = 'tezos';
|
|
204
172
|
/**
|
|
205
|
-
*
|
|
173
|
+
* The `WalletConnect` class implements the `WalletProvider` interface, providing an alternative to `BeaconWallet`.
|
|
206
174
|
* This package enables dapps built with Taquito to connect to wallets via the WalletConnect/Reown protocol.
|
|
207
|
-
|
|
175
|
+
\* @remarks Currently, a QR code is displayed to establish a connection with a wallet. As more Tezos wallets integrate with WalletConnect,
|
|
208
176
|
* we plan showing a list of available wallets alongside the QR code.
|
|
209
177
|
*/
|
|
210
178
|
class WalletConnect {
|
|
@@ -212,20 +180,17 @@ class WalletConnect {
|
|
|
212
180
|
this.signClient = signClient;
|
|
213
181
|
this.walletConnectModal = WalletConnectModal;
|
|
214
182
|
this.signClient.on('session_delete', ({ topic }) => {
|
|
215
|
-
|
|
216
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
183
|
+
if (this.session?.topic === topic) {
|
|
217
184
|
this.session = undefined;
|
|
218
185
|
}
|
|
219
186
|
});
|
|
220
187
|
this.signClient.on('session_expire', ({ topic }) => {
|
|
221
|
-
|
|
222
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
188
|
+
if (this.session?.topic === topic) {
|
|
223
189
|
this.session = undefined;
|
|
224
190
|
}
|
|
225
191
|
});
|
|
226
192
|
this.signClient.on('session_update', ({ params, topic }) => {
|
|
227
|
-
|
|
228
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
193
|
+
if (this.session?.topic === topic) {
|
|
229
194
|
this.session.namespaces = params.namespaces;
|
|
230
195
|
// TODO determine if we need validation on the namespace here
|
|
231
196
|
}
|
|
@@ -235,7 +200,7 @@ class WalletConnect {
|
|
|
235
200
|
});
|
|
236
201
|
}
|
|
237
202
|
/**
|
|
238
|
-
*
|
|
203
|
+
* Initialize a WalletConnect provider
|
|
239
204
|
* (Initialize a WalletConnect client with persisted storage and a network connection)
|
|
240
205
|
*
|
|
241
206
|
* @example
|
|
@@ -251,77 +216,72 @@ class WalletConnect {
|
|
|
251
216
|
* });
|
|
252
217
|
* ```
|
|
253
218
|
*/
|
|
254
|
-
static init(initParams) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
projectId: initParams.projectId,
|
|
262
|
-
});
|
|
263
|
-
return new WalletConnect(client, walletConnectModal);
|
|
219
|
+
static async init(initParams) {
|
|
220
|
+
if (!initParams.projectId) {
|
|
221
|
+
throw new Error('projectId is required');
|
|
222
|
+
}
|
|
223
|
+
const client = await Client.init(initParams);
|
|
224
|
+
const walletConnectModal = new WalletConnectModal({
|
|
225
|
+
projectId: initParams.projectId,
|
|
264
226
|
});
|
|
227
|
+
return new WalletConnect(client, walletConnectModal);
|
|
265
228
|
}
|
|
266
229
|
/**
|
|
267
|
-
*
|
|
230
|
+
* Request permission for a new session and establish a connection.
|
|
268
231
|
*
|
|
269
232
|
* @param connectParams.permissionScope The networks, methods, and events that will be granted permission
|
|
270
233
|
* @param connectParams.pairingTopic Option to connect to an existing active pairing. If pairingTopic is defined, a prompt will appear in the corresponding wallet to accept or decline the session proposal. If no pairingTopic, a QR code modal will open in the dapp, allowing to connect to a wallet.
|
|
271
234
|
* @param connectParams.registryUrl Optional registry of wallet deep links to show in the Modal
|
|
272
|
-
|
|
235
|
+
\* @throws ConnectionFailed is thrown if no connection can be established with a wallet
|
|
273
236
|
*/
|
|
274
|
-
requestPermissions(connectParams) {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
methods: connectParams.permissionScope.methods,
|
|
285
|
-
events: (_a = connectParams.permissionScope.events) !== null && _a !== void 0 ? _a : [],
|
|
286
|
-
},
|
|
237
|
+
async requestPermissions(connectParams) {
|
|
238
|
+
// TODO when Tezos wallets will officially support wallet connect, we need to provide a default value for registryUrl
|
|
239
|
+
try {
|
|
240
|
+
const chains = connectParams.permissionScope.networks.map((network) => `${TEZOS_PLACEHOLDER}:${network}`);
|
|
241
|
+
const { uri, approval } = await this.signClient.connect({
|
|
242
|
+
requiredNamespaces: {
|
|
243
|
+
[TEZOS_PLACEHOLDER]: {
|
|
244
|
+
chains,
|
|
245
|
+
methods: connectParams.permissionScope.methods,
|
|
246
|
+
events: connectParams.permissionScope.events ?? [],
|
|
287
247
|
},
|
|
288
|
-
|
|
248
|
+
},
|
|
249
|
+
pairingTopic: connectParams.pairingTopic,
|
|
250
|
+
});
|
|
251
|
+
if (uri) {
|
|
252
|
+
this.walletConnectModal.openModal({
|
|
253
|
+
uri,
|
|
254
|
+
chains,
|
|
289
255
|
});
|
|
290
|
-
if (uri) {
|
|
291
|
-
this.walletConnectModal.openModal({
|
|
292
|
-
uri,
|
|
293
|
-
chains,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
this.session = yield approval();
|
|
297
|
-
}
|
|
298
|
-
catch (error) {
|
|
299
|
-
throw new ConnectionFailed(error);
|
|
300
|
-
}
|
|
301
|
-
finally {
|
|
302
|
-
this.walletConnectModal.closeModal();
|
|
303
256
|
}
|
|
304
|
-
this.
|
|
305
|
-
|
|
306
|
-
|
|
257
|
+
this.session = await approval();
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
throw new ConnectionFailed(error);
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
this.walletConnectModal.closeModal();
|
|
264
|
+
}
|
|
265
|
+
this.validateReceivedNamespace(connectParams.permissionScope, this.session.namespaces);
|
|
266
|
+
this.setDefaultAccountAndNetwork();
|
|
307
267
|
}
|
|
308
268
|
/**
|
|
309
|
-
*
|
|
269
|
+
* Access all existing active pairings
|
|
310
270
|
*/
|
|
311
271
|
getAvailablePairing() {
|
|
312
272
|
return this.signClient.pairing.getAll({ active: true });
|
|
313
273
|
}
|
|
314
274
|
/**
|
|
315
|
-
*
|
|
275
|
+
* Access all existing sessions
|
|
316
276
|
* @return an array of strings which represent the session keys
|
|
317
277
|
*/
|
|
318
278
|
getAllExistingSessionKeys() {
|
|
319
279
|
return this.signClient.session.keys;
|
|
320
280
|
}
|
|
321
281
|
/**
|
|
322
|
-
*
|
|
282
|
+
* Configure the Client with an existing session.
|
|
323
283
|
* The session is immediately restored without a prompt on the wallet to accept/decline it.
|
|
324
|
-
|
|
284
|
+
\* @throws InvalidSessionKey is thrown if the provided session key doesn't exist
|
|
325
285
|
*/
|
|
326
286
|
configureWithExistingSessionKey(key) {
|
|
327
287
|
const sessions = this.getAllExistingSessionKeys();
|
|
@@ -331,91 +291,85 @@ class WalletConnect {
|
|
|
331
291
|
this.session = this.signClient.session.get(key);
|
|
332
292
|
this.setDefaultAccountAndNetwork();
|
|
333
293
|
}
|
|
334
|
-
disconnect() {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
});
|
|
294
|
+
async disconnect() {
|
|
295
|
+
if (this.session) {
|
|
296
|
+
await this.signClient.disconnect({
|
|
297
|
+
topic: this.session.topic,
|
|
298
|
+
reason: getSdkError('USER_DISCONNECTED'),
|
|
299
|
+
});
|
|
300
|
+
this.clearState();
|
|
301
|
+
}
|
|
344
302
|
}
|
|
345
303
|
getPeerMetadata() {
|
|
346
304
|
return this.getSession().peer.metadata;
|
|
347
305
|
}
|
|
348
306
|
/**
|
|
349
|
-
*
|
|
350
|
-
|
|
307
|
+
* Once the session is establish, send Tezos operations to be approved, signed and inject by the wallet.
|
|
308
|
+
\* @throws MissingRequiredScope is thrown if permission to send operation was not granted
|
|
351
309
|
*/
|
|
352
|
-
sendOperations(params) {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
operations: params,
|
|
369
|
-
},
|
|
310
|
+
async sendOperations(params) {
|
|
311
|
+
const session = this.getSession();
|
|
312
|
+
if (!this.getPermittedMethods().includes(PermissionScopeMethods.TEZOS_SEND)) {
|
|
313
|
+
throw new MissingRequiredScope(PermissionScopeMethods.TEZOS_SEND);
|
|
314
|
+
}
|
|
315
|
+
const network = this.getActiveNetwork();
|
|
316
|
+
const account = await this.getPKH();
|
|
317
|
+
this.validateNetworkAndAccount(network, account);
|
|
318
|
+
const { operationHash } = await this.signClient.request({
|
|
319
|
+
topic: session.topic,
|
|
320
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
321
|
+
request: {
|
|
322
|
+
method: PermissionScopeMethods.TEZOS_SEND,
|
|
323
|
+
params: {
|
|
324
|
+
account,
|
|
325
|
+
operations: params,
|
|
370
326
|
},
|
|
371
|
-
}
|
|
372
|
-
return operationHash;
|
|
327
|
+
},
|
|
373
328
|
});
|
|
329
|
+
return operationHash;
|
|
374
330
|
}
|
|
375
331
|
/**
|
|
376
|
-
*
|
|
377
|
-
|
|
332
|
+
* Once the session is establish, send payload to be signed by the wallet.
|
|
333
|
+
\* @throws MissingRequiredScope is thrown if permission to sign payload was not granted
|
|
378
334
|
*/
|
|
379
|
-
sign(bytes, watermark) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
expression
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
payload: expression,
|
|
401
|
-
},
|
|
335
|
+
async sign(bytes, watermark) {
|
|
336
|
+
const session = this.getSession();
|
|
337
|
+
if (!this.getPermittedMethods().includes(PermissionScopeMethods.TEZOS_SIGN)) {
|
|
338
|
+
throw new MissingRequiredScope(PermissionScopeMethods.TEZOS_SIGN);
|
|
339
|
+
}
|
|
340
|
+
const network = this.getActiveNetwork();
|
|
341
|
+
const account = await this.getPKH();
|
|
342
|
+
this.validateNetworkAndAccount(network, account);
|
|
343
|
+
let expression = bytes;
|
|
344
|
+
if (watermark) {
|
|
345
|
+
expression =
|
|
346
|
+
Array.from(watermark, (byte) => byte.toString(16).padStart(2, '0')).join('') + expression;
|
|
347
|
+
}
|
|
348
|
+
const { signature } = await this.signClient.request({
|
|
349
|
+
topic: session.topic,
|
|
350
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
351
|
+
request: {
|
|
352
|
+
method: PermissionScopeMethods.TEZOS_SIGN,
|
|
353
|
+
params: {
|
|
354
|
+
account: await this.getPKH(),
|
|
355
|
+
payload: expression,
|
|
402
356
|
},
|
|
403
|
-
}
|
|
404
|
-
return signature;
|
|
357
|
+
},
|
|
405
358
|
});
|
|
359
|
+
return signature;
|
|
406
360
|
}
|
|
407
361
|
/**
|
|
408
|
-
*
|
|
409
|
-
|
|
362
|
+
* Return all connected accounts from the active session
|
|
363
|
+
\* @throws NotConnected if no active session
|
|
410
364
|
*/
|
|
411
365
|
getAccounts() {
|
|
412
366
|
return this.getTezosNamespace().accounts.map((account) => account.split(':')[2]);
|
|
413
367
|
}
|
|
414
368
|
/**
|
|
415
|
-
*
|
|
369
|
+
* Set the active account.
|
|
416
370
|
* Must be called if there are multiple accounts in the session and every time the active account is switched
|
|
417
371
|
* @param pkh public key hash of the selected account
|
|
418
|
-
|
|
372
|
+
\* @throws InvalidAccount thrown if the pkh is not part of the active accounts in the session
|
|
419
373
|
*/
|
|
420
374
|
setActiveAccount(pkh) {
|
|
421
375
|
if (!this.getAccounts().includes(pkh)) {
|
|
@@ -424,59 +378,55 @@ class WalletConnect {
|
|
|
424
378
|
this.activeAccount = pkh;
|
|
425
379
|
}
|
|
426
380
|
/**
|
|
427
|
-
*
|
|
428
|
-
|
|
381
|
+
* Access the public key hash of the active account
|
|
382
|
+
\* @throws ActiveAccountUnspecified thrown when there are multiple Tezos account in the session and none is set as the active one
|
|
429
383
|
*/
|
|
430
|
-
getPKH() {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return this.activeAccount;
|
|
437
|
-
});
|
|
384
|
+
async getPKH() {
|
|
385
|
+
if (!this.activeAccount) {
|
|
386
|
+
this.getSession();
|
|
387
|
+
throw new ActiveAccountUnspecified();
|
|
388
|
+
}
|
|
389
|
+
return this.activeAccount;
|
|
438
390
|
}
|
|
439
391
|
/**
|
|
440
|
-
*
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
392
|
+
* Access the public key of the active account
|
|
393
|
+
\* @throws ActiveAccountUnspecified thrown when there are multiple Tezos account in the session and none is set as the active one
|
|
394
|
+
\* @throws MissingRequiredScope is thrown if permission to get accounts was not granted
|
|
395
|
+
\* @throws PublicKeyRetrievalError is thrown if the public key is not found
|
|
444
396
|
*/
|
|
445
|
-
getPK() {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
},
|
|
460
|
-
});
|
|
461
|
-
const selectedAccount = accounts.find((acc) => acc.address === account);
|
|
462
|
-
if (!selectedAccount) {
|
|
463
|
-
throw new PublicKeyRetrievalError();
|
|
464
|
-
}
|
|
465
|
-
return selectedAccount.pubkey;
|
|
397
|
+
async getPK() {
|
|
398
|
+
const session = this.getSession();
|
|
399
|
+
if (!this.getPermittedMethods().includes(PermissionScopeMethods.TEZOS_GET_ACCOUNTS)) {
|
|
400
|
+
throw new MissingRequiredScope(PermissionScopeMethods.TEZOS_GET_ACCOUNTS);
|
|
401
|
+
}
|
|
402
|
+
const network = this.getActiveNetwork();
|
|
403
|
+
const account = await this.getPKH();
|
|
404
|
+
const accounts = await this.signClient.request({
|
|
405
|
+
topic: session.topic,
|
|
406
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
407
|
+
request: {
|
|
408
|
+
method: PermissionScopeMethods.TEZOS_GET_ACCOUNTS,
|
|
409
|
+
params: {},
|
|
410
|
+
},
|
|
466
411
|
});
|
|
412
|
+
const selectedAccount = accounts.find((acc) => acc.address === account);
|
|
413
|
+
if (!selectedAccount) {
|
|
414
|
+
throw new PublicKeyRetrievalError();
|
|
415
|
+
}
|
|
416
|
+
return selectedAccount.pubkey;
|
|
467
417
|
}
|
|
468
418
|
/**
|
|
469
|
-
*
|
|
470
|
-
|
|
419
|
+
* Return all networks from the namespace of the active session
|
|
420
|
+
\* @throws NotConnected if no active session
|
|
471
421
|
*/
|
|
472
422
|
getNetworks() {
|
|
473
423
|
return this.getPermittedNetwork();
|
|
474
424
|
}
|
|
475
425
|
/**
|
|
476
|
-
*
|
|
426
|
+
* Set the active network.
|
|
477
427
|
* Must be called if there are multiple network in the session and every time the active network is switched
|
|
478
428
|
* @param network selected network
|
|
479
|
-
|
|
429
|
+
\* @throws InvalidNetwork thrown if the network is not part of the active networks in the session
|
|
480
430
|
*/
|
|
481
431
|
setActiveNetwork(network) {
|
|
482
432
|
if (!this.getNetworks().includes(network)) {
|
|
@@ -485,8 +435,8 @@ class WalletConnect {
|
|
|
485
435
|
this.activeNetwork = network;
|
|
486
436
|
}
|
|
487
437
|
/**
|
|
488
|
-
*
|
|
489
|
-
|
|
438
|
+
* Access the active network
|
|
439
|
+
\* @throws ActiveNetworkUnspecified thorwn when there are multiple Tezos netwroks in the session and none is set as the active one
|
|
490
440
|
*/
|
|
491
441
|
getActiveNetwork() {
|
|
492
442
|
if (!this.activeNetwork) {
|
|
@@ -653,59 +603,41 @@ class WalletConnect {
|
|
|
653
603
|
}
|
|
654
604
|
return operatedParams;
|
|
655
605
|
}
|
|
656
|
-
mapTransferParamsToWalletParams(params) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
return this.removeDefaultLimits(walletParams, yield createTransferOperation(this.formatParameters(walletParams)));
|
|
660
|
-
});
|
|
606
|
+
async mapTransferParamsToWalletParams(params) {
|
|
607
|
+
const walletParams = await params();
|
|
608
|
+
return this.removeDefaultLimits(walletParams, await createTransferOperation(this.formatParameters(walletParams)));
|
|
661
609
|
}
|
|
662
|
-
mapTransferTicketParamsToWalletParams(params) {
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return this.removeDefaultLimits(walletParams, yield createTransferTicketOperation(this.formatParameters(walletParams)));
|
|
666
|
-
});
|
|
610
|
+
async mapTransferTicketParamsToWalletParams(params) {
|
|
611
|
+
const walletParams = await params();
|
|
612
|
+
return this.removeDefaultLimits(walletParams, await createTransferTicketOperation(this.formatParameters(walletParams)));
|
|
667
613
|
}
|
|
668
|
-
mapStakeParamsToWalletParams(params) {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
return this.removeDefaultLimits(walletParams, yield createTransferOperation(this.formatParameters(walletParams)));
|
|
672
|
-
});
|
|
614
|
+
async mapStakeParamsToWalletParams(params) {
|
|
615
|
+
const walletParams = await params();
|
|
616
|
+
return this.removeDefaultLimits(walletParams, await createTransferOperation(this.formatParameters(walletParams)));
|
|
673
617
|
}
|
|
674
|
-
mapUnstakeParamsToWalletParams(params) {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
return this.removeDefaultLimits(walletParams, yield createTransferOperation(this.formatParameters(walletParams)));
|
|
678
|
-
});
|
|
618
|
+
async mapUnstakeParamsToWalletParams(params) {
|
|
619
|
+
const walletParams = await params();
|
|
620
|
+
return this.removeDefaultLimits(walletParams, await createTransferOperation(this.formatParameters(walletParams)));
|
|
679
621
|
}
|
|
680
|
-
mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
return this.removeDefaultLimits(walletParams, yield createTransferOperation(this.formatParameters(walletParams)));
|
|
684
|
-
});
|
|
622
|
+
async mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
623
|
+
const walletParams = await params();
|
|
624
|
+
return this.removeDefaultLimits(walletParams, await createTransferOperation(this.formatParameters(walletParams)));
|
|
685
625
|
}
|
|
686
|
-
mapOriginateParamsToWalletParams(params) {
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
return this.removeDefaultLimits(walletParams, yield createOriginationOperation(this.formatParameters(walletParams)));
|
|
690
|
-
});
|
|
626
|
+
async mapOriginateParamsToWalletParams(params) {
|
|
627
|
+
const walletParams = await params();
|
|
628
|
+
return this.removeDefaultLimits(walletParams, await createOriginationOperation(this.formatParameters(walletParams)));
|
|
691
629
|
}
|
|
692
|
-
mapDelegateParamsToWalletParams(params) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
return this.removeDefaultLimits(walletParams, yield createSetDelegateOperation(this.formatParameters(walletParams)));
|
|
696
|
-
});
|
|
630
|
+
async mapDelegateParamsToWalletParams(params) {
|
|
631
|
+
const walletParams = await params();
|
|
632
|
+
return this.removeDefaultLimits(walletParams, await createSetDelegateOperation(this.formatParameters(walletParams)));
|
|
697
633
|
}
|
|
698
|
-
mapIncreasePaidStorageWalletParams(params) {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
return this.removeDefaultLimits(walletParams, yield createIncreasePaidStorageOperation(this.formatParameters(walletParams)));
|
|
702
|
-
});
|
|
634
|
+
async mapIncreasePaidStorageWalletParams(params) {
|
|
635
|
+
const walletParams = await params();
|
|
636
|
+
return this.removeDefaultLimits(walletParams, await createIncreasePaidStorageOperation(this.formatParameters(walletParams)));
|
|
703
637
|
}
|
|
704
|
-
mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
return this.removeDefaultLimits(walletParams, yield createRegisterGlobalConstantOperation(this.formatParameters(walletParams)));
|
|
708
|
-
});
|
|
638
|
+
async mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
639
|
+
const walletParams = await params();
|
|
640
|
+
return this.removeDefaultLimits(walletParams, await createRegisterGlobalConstantOperation(this.formatParameters(walletParams)));
|
|
709
641
|
}
|
|
710
642
|
}
|
|
711
643
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-wallet-connect.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"taquito-wallet-connect.es6.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|