@taquito/wallet-connect 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 +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
package/dist/lib/errors.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PublicKeyRetrievalError = exports.InvalidSession = exports.ActiveNetworkUnspecified = exports.ActiveAccountUnspecified = exports.NotConnected = exports.ConnectionFailed = exports.InvalidNetworkOrAccount = exports.InvalidNetwork = exports.InvalidAccount = exports.InvalidSessionKey = exports.InvalidReceivedSessionNamespace = exports.MissingRequiredScope = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @category Error
|
|
6
|
-
*
|
|
6
|
+
* Error that indicates missing required permission scopes
|
|
7
7
|
*/
|
|
8
8
|
class MissingRequiredScope extends Error {
|
|
9
9
|
constructor(requiredScopes) {
|
|
@@ -15,7 +15,7 @@ class MissingRequiredScope extends Error {
|
|
|
15
15
|
exports.MissingRequiredScope = MissingRequiredScope;
|
|
16
16
|
/**
|
|
17
17
|
* @category Error
|
|
18
|
-
*
|
|
18
|
+
* Error that indicates the wallet returned an invalid namespace
|
|
19
19
|
*/
|
|
20
20
|
class InvalidReceivedSessionNamespace extends Error {
|
|
21
21
|
constructor(messageWc, codeWc, type, data) {
|
|
@@ -35,7 +35,7 @@ class InvalidReceivedSessionNamespace extends Error {
|
|
|
35
35
|
exports.InvalidReceivedSessionNamespace = InvalidReceivedSessionNamespace;
|
|
36
36
|
/**
|
|
37
37
|
* @category Error
|
|
38
|
-
*
|
|
38
|
+
* Error that indicates an invalid session key being passed
|
|
39
39
|
*/
|
|
40
40
|
class InvalidSessionKey extends Error {
|
|
41
41
|
constructor(key) {
|
|
@@ -47,7 +47,7 @@ class InvalidSessionKey extends Error {
|
|
|
47
47
|
exports.InvalidSessionKey = InvalidSessionKey;
|
|
48
48
|
/**
|
|
49
49
|
* @category Error
|
|
50
|
-
*
|
|
50
|
+
* Error that indicates the pkh is not part of the active accounts in the session
|
|
51
51
|
*/
|
|
52
52
|
class InvalidAccount extends Error {
|
|
53
53
|
constructor(pkh) {
|
|
@@ -59,7 +59,7 @@ class InvalidAccount extends Error {
|
|
|
59
59
|
exports.InvalidAccount = InvalidAccount;
|
|
60
60
|
/**
|
|
61
61
|
* @category Error
|
|
62
|
-
*
|
|
62
|
+
* Error that indicates the network is not part of the active networks in the session
|
|
63
63
|
*/
|
|
64
64
|
class InvalidNetwork extends Error {
|
|
65
65
|
constructor(network) {
|
|
@@ -71,7 +71,7 @@ class InvalidNetwork extends Error {
|
|
|
71
71
|
exports.InvalidNetwork = InvalidNetwork;
|
|
72
72
|
/**
|
|
73
73
|
* @category Error
|
|
74
|
-
*
|
|
74
|
+
* Error that indicates the combinaison pkh-network is not part of the active session
|
|
75
75
|
*/
|
|
76
76
|
class InvalidNetworkOrAccount extends Error {
|
|
77
77
|
constructor(network, pkh) {
|
|
@@ -84,7 +84,7 @@ class InvalidNetworkOrAccount extends Error {
|
|
|
84
84
|
exports.InvalidNetworkOrAccount = InvalidNetworkOrAccount;
|
|
85
85
|
/**
|
|
86
86
|
* @category Error
|
|
87
|
-
*
|
|
87
|
+
* Error that indicates the connection could not be established
|
|
88
88
|
*/
|
|
89
89
|
class ConnectionFailed extends Error {
|
|
90
90
|
constructor(originalError) {
|
|
@@ -96,7 +96,7 @@ class ConnectionFailed extends Error {
|
|
|
96
96
|
exports.ConnectionFailed = ConnectionFailed;
|
|
97
97
|
/**
|
|
98
98
|
* @category Error
|
|
99
|
-
*
|
|
99
|
+
* Error that indicates there is no active session
|
|
100
100
|
*/
|
|
101
101
|
class NotConnected extends Error {
|
|
102
102
|
constructor() {
|
|
@@ -107,7 +107,7 @@ class NotConnected extends Error {
|
|
|
107
107
|
exports.NotConnected = NotConnected;
|
|
108
108
|
/**
|
|
109
109
|
* @category Error
|
|
110
|
-
*
|
|
110
|
+
* Error that indicates the active account is not specified
|
|
111
111
|
*/
|
|
112
112
|
class ActiveAccountUnspecified extends Error {
|
|
113
113
|
constructor() {
|
|
@@ -118,7 +118,7 @@ class ActiveAccountUnspecified extends Error {
|
|
|
118
118
|
exports.ActiveAccountUnspecified = ActiveAccountUnspecified;
|
|
119
119
|
/**
|
|
120
120
|
* @category Error
|
|
121
|
-
*
|
|
121
|
+
* Error that indicates the active network is not specified
|
|
122
122
|
*/
|
|
123
123
|
class ActiveNetworkUnspecified extends Error {
|
|
124
124
|
constructor() {
|
|
@@ -129,7 +129,7 @@ class ActiveNetworkUnspecified extends Error {
|
|
|
129
129
|
exports.ActiveNetworkUnspecified = ActiveNetworkUnspecified;
|
|
130
130
|
/**
|
|
131
131
|
* @category Error
|
|
132
|
-
*
|
|
132
|
+
* Error that indicates the session is invalid
|
|
133
133
|
*/
|
|
134
134
|
class InvalidSession extends Error {
|
|
135
135
|
constructor(message) {
|
|
@@ -17,15 +17,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
17
17
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
23
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
24
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
25
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
21
|
exports.WalletConnect = void 0;
|
|
31
22
|
const sign_client_1 = require("@walletconnect/sign-client");
|
|
@@ -38,9 +29,9 @@ __exportStar(require("./errors"), exports);
|
|
|
38
29
|
__exportStar(require("./types"), exports);
|
|
39
30
|
const TEZOS_PLACEHOLDER = 'tezos';
|
|
40
31
|
/**
|
|
41
|
-
*
|
|
32
|
+
* The `WalletConnect` class implements the `WalletProvider` interface, providing an alternative to `BeaconWallet`.
|
|
42
33
|
* This package enables dapps built with Taquito to connect to wallets via the WalletConnect/Reown protocol.
|
|
43
|
-
|
|
34
|
+
\* @remarks Currently, a QR code is displayed to establish a connection with a wallet. As more Tezos wallets integrate with WalletConnect,
|
|
44
35
|
* we plan showing a list of available wallets alongside the QR code.
|
|
45
36
|
*/
|
|
46
37
|
class WalletConnect {
|
|
@@ -48,20 +39,17 @@ class WalletConnect {
|
|
|
48
39
|
this.signClient = signClient;
|
|
49
40
|
this.walletConnectModal = WalletConnectModal;
|
|
50
41
|
this.signClient.on('session_delete', ({ topic }) => {
|
|
51
|
-
|
|
52
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
42
|
+
if (this.session?.topic === topic) {
|
|
53
43
|
this.session = undefined;
|
|
54
44
|
}
|
|
55
45
|
});
|
|
56
46
|
this.signClient.on('session_expire', ({ topic }) => {
|
|
57
|
-
|
|
58
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
47
|
+
if (this.session?.topic === topic) {
|
|
59
48
|
this.session = undefined;
|
|
60
49
|
}
|
|
61
50
|
});
|
|
62
51
|
this.signClient.on('session_update', ({ params, topic }) => {
|
|
63
|
-
|
|
64
|
-
if (((_a = this.session) === null || _a === void 0 ? void 0 : _a.topic) === topic) {
|
|
52
|
+
if (this.session?.topic === topic) {
|
|
65
53
|
this.session.namespaces = params.namespaces;
|
|
66
54
|
// TODO determine if we need validation on the namespace here
|
|
67
55
|
}
|
|
@@ -71,7 +59,7 @@ class WalletConnect {
|
|
|
71
59
|
});
|
|
72
60
|
}
|
|
73
61
|
/**
|
|
74
|
-
*
|
|
62
|
+
* Initialize a WalletConnect provider
|
|
75
63
|
* (Initialize a WalletConnect client with persisted storage and a network connection)
|
|
76
64
|
*
|
|
77
65
|
* @example
|
|
@@ -87,77 +75,72 @@ class WalletConnect {
|
|
|
87
75
|
* });
|
|
88
76
|
* ```
|
|
89
77
|
*/
|
|
90
|
-
static init(initParams) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
projectId: initParams.projectId,
|
|
98
|
-
});
|
|
99
|
-
return new WalletConnect(client, walletConnectModal);
|
|
78
|
+
static async init(initParams) {
|
|
79
|
+
if (!initParams.projectId) {
|
|
80
|
+
throw new Error('projectId is required');
|
|
81
|
+
}
|
|
82
|
+
const client = await sign_client_1.default.init(initParams);
|
|
83
|
+
const walletConnectModal = new modal_1.WalletConnectModal({
|
|
84
|
+
projectId: initParams.projectId,
|
|
100
85
|
});
|
|
86
|
+
return new WalletConnect(client, walletConnectModal);
|
|
101
87
|
}
|
|
102
88
|
/**
|
|
103
|
-
*
|
|
89
|
+
* Request permission for a new session and establish a connection.
|
|
104
90
|
*
|
|
105
91
|
* @param connectParams.permissionScope The networks, methods, and events that will be granted permission
|
|
106
92
|
* @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.
|
|
107
93
|
* @param connectParams.registryUrl Optional registry of wallet deep links to show in the Modal
|
|
108
|
-
|
|
94
|
+
\* @throws ConnectionFailed is thrown if no connection can be established with a wallet
|
|
109
95
|
*/
|
|
110
|
-
requestPermissions(connectParams) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
methods: connectParams.permissionScope.methods,
|
|
121
|
-
events: (_a = connectParams.permissionScope.events) !== null && _a !== void 0 ? _a : [],
|
|
122
|
-
},
|
|
96
|
+
async requestPermissions(connectParams) {
|
|
97
|
+
// TODO when Tezos wallets will officially support wallet connect, we need to provide a default value for registryUrl
|
|
98
|
+
try {
|
|
99
|
+
const chains = connectParams.permissionScope.networks.map((network) => `${TEZOS_PLACEHOLDER}:${network}`);
|
|
100
|
+
const { uri, approval } = await this.signClient.connect({
|
|
101
|
+
requiredNamespaces: {
|
|
102
|
+
[TEZOS_PLACEHOLDER]: {
|
|
103
|
+
chains,
|
|
104
|
+
methods: connectParams.permissionScope.methods,
|
|
105
|
+
events: connectParams.permissionScope.events ?? [],
|
|
123
106
|
},
|
|
124
|
-
|
|
107
|
+
},
|
|
108
|
+
pairingTopic: connectParams.pairingTopic,
|
|
109
|
+
});
|
|
110
|
+
if (uri) {
|
|
111
|
+
this.walletConnectModal.openModal({
|
|
112
|
+
uri,
|
|
113
|
+
chains,
|
|
125
114
|
});
|
|
126
|
-
if (uri) {
|
|
127
|
-
this.walletConnectModal.openModal({
|
|
128
|
-
uri,
|
|
129
|
-
chains,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
this.session = yield approval();
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
throw new errors_1.ConnectionFailed(error);
|
|
136
|
-
}
|
|
137
|
-
finally {
|
|
138
|
-
this.walletConnectModal.closeModal();
|
|
139
115
|
}
|
|
140
|
-
this.
|
|
141
|
-
|
|
142
|
-
|
|
116
|
+
this.session = await approval();
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw new errors_1.ConnectionFailed(error);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
this.walletConnectModal.closeModal();
|
|
123
|
+
}
|
|
124
|
+
this.validateReceivedNamespace(connectParams.permissionScope, this.session.namespaces);
|
|
125
|
+
this.setDefaultAccountAndNetwork();
|
|
143
126
|
}
|
|
144
127
|
/**
|
|
145
|
-
*
|
|
128
|
+
* Access all existing active pairings
|
|
146
129
|
*/
|
|
147
130
|
getAvailablePairing() {
|
|
148
131
|
return this.signClient.pairing.getAll({ active: true });
|
|
149
132
|
}
|
|
150
133
|
/**
|
|
151
|
-
*
|
|
134
|
+
* Access all existing sessions
|
|
152
135
|
* @return an array of strings which represent the session keys
|
|
153
136
|
*/
|
|
154
137
|
getAllExistingSessionKeys() {
|
|
155
138
|
return this.signClient.session.keys;
|
|
156
139
|
}
|
|
157
140
|
/**
|
|
158
|
-
*
|
|
141
|
+
* Configure the Client with an existing session.
|
|
159
142
|
* The session is immediately restored without a prompt on the wallet to accept/decline it.
|
|
160
|
-
|
|
143
|
+
\* @throws InvalidSessionKey is thrown if the provided session key doesn't exist
|
|
161
144
|
*/
|
|
162
145
|
configureWithExistingSessionKey(key) {
|
|
163
146
|
const sessions = this.getAllExistingSessionKeys();
|
|
@@ -167,91 +150,85 @@ class WalletConnect {
|
|
|
167
150
|
this.session = this.signClient.session.get(key);
|
|
168
151
|
this.setDefaultAccountAndNetwork();
|
|
169
152
|
}
|
|
170
|
-
disconnect() {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
});
|
|
153
|
+
async disconnect() {
|
|
154
|
+
if (this.session) {
|
|
155
|
+
await this.signClient.disconnect({
|
|
156
|
+
topic: this.session.topic,
|
|
157
|
+
reason: (0, utils_1.getSdkError)('USER_DISCONNECTED'),
|
|
158
|
+
});
|
|
159
|
+
this.clearState();
|
|
160
|
+
}
|
|
180
161
|
}
|
|
181
162
|
getPeerMetadata() {
|
|
182
163
|
return this.getSession().peer.metadata;
|
|
183
164
|
}
|
|
184
165
|
/**
|
|
185
|
-
*
|
|
186
|
-
|
|
166
|
+
* Once the session is establish, send Tezos operations to be approved, signed and inject by the wallet.
|
|
167
|
+
\* @throws MissingRequiredScope is thrown if permission to send operation was not granted
|
|
187
168
|
*/
|
|
188
|
-
sendOperations(params) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
operations: params,
|
|
205
|
-
},
|
|
169
|
+
async sendOperations(params) {
|
|
170
|
+
const session = this.getSession();
|
|
171
|
+
if (!this.getPermittedMethods().includes(types_1.PermissionScopeMethods.TEZOS_SEND)) {
|
|
172
|
+
throw new errors_1.MissingRequiredScope(types_1.PermissionScopeMethods.TEZOS_SEND);
|
|
173
|
+
}
|
|
174
|
+
const network = this.getActiveNetwork();
|
|
175
|
+
const account = await this.getPKH();
|
|
176
|
+
this.validateNetworkAndAccount(network, account);
|
|
177
|
+
const { operationHash } = await this.signClient.request({
|
|
178
|
+
topic: session.topic,
|
|
179
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
180
|
+
request: {
|
|
181
|
+
method: types_1.PermissionScopeMethods.TEZOS_SEND,
|
|
182
|
+
params: {
|
|
183
|
+
account,
|
|
184
|
+
operations: params,
|
|
206
185
|
},
|
|
207
|
-
}
|
|
208
|
-
return operationHash;
|
|
186
|
+
},
|
|
209
187
|
});
|
|
188
|
+
return operationHash;
|
|
210
189
|
}
|
|
211
190
|
/**
|
|
212
|
-
*
|
|
213
|
-
|
|
191
|
+
* Once the session is establish, send payload to be signed by the wallet.
|
|
192
|
+
\* @throws MissingRequiredScope is thrown if permission to sign payload was not granted
|
|
214
193
|
*/
|
|
215
|
-
sign(bytes, watermark) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
expression
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
payload: expression,
|
|
237
|
-
},
|
|
194
|
+
async sign(bytes, watermark) {
|
|
195
|
+
const session = this.getSession();
|
|
196
|
+
if (!this.getPermittedMethods().includes(types_1.PermissionScopeMethods.TEZOS_SIGN)) {
|
|
197
|
+
throw new errors_1.MissingRequiredScope(types_1.PermissionScopeMethods.TEZOS_SIGN);
|
|
198
|
+
}
|
|
199
|
+
const network = this.getActiveNetwork();
|
|
200
|
+
const account = await this.getPKH();
|
|
201
|
+
this.validateNetworkAndAccount(network, account);
|
|
202
|
+
let expression = bytes;
|
|
203
|
+
if (watermark) {
|
|
204
|
+
expression =
|
|
205
|
+
Array.from(watermark, (byte) => byte.toString(16).padStart(2, '0')).join('') + expression;
|
|
206
|
+
}
|
|
207
|
+
const { signature } = await this.signClient.request({
|
|
208
|
+
topic: session.topic,
|
|
209
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
210
|
+
request: {
|
|
211
|
+
method: types_1.PermissionScopeMethods.TEZOS_SIGN,
|
|
212
|
+
params: {
|
|
213
|
+
account: await this.getPKH(),
|
|
214
|
+
payload: expression,
|
|
238
215
|
},
|
|
239
|
-
}
|
|
240
|
-
return signature;
|
|
216
|
+
},
|
|
241
217
|
});
|
|
218
|
+
return signature;
|
|
242
219
|
}
|
|
243
220
|
/**
|
|
244
|
-
*
|
|
245
|
-
|
|
221
|
+
* Return all connected accounts from the active session
|
|
222
|
+
\* @throws NotConnected if no active session
|
|
246
223
|
*/
|
|
247
224
|
getAccounts() {
|
|
248
225
|
return this.getTezosNamespace().accounts.map((account) => account.split(':')[2]);
|
|
249
226
|
}
|
|
250
227
|
/**
|
|
251
|
-
*
|
|
228
|
+
* Set the active account.
|
|
252
229
|
* Must be called if there are multiple accounts in the session and every time the active account is switched
|
|
253
230
|
* @param pkh public key hash of the selected account
|
|
254
|
-
|
|
231
|
+
\* @throws InvalidAccount thrown if the pkh is not part of the active accounts in the session
|
|
255
232
|
*/
|
|
256
233
|
setActiveAccount(pkh) {
|
|
257
234
|
if (!this.getAccounts().includes(pkh)) {
|
|
@@ -260,59 +237,55 @@ class WalletConnect {
|
|
|
260
237
|
this.activeAccount = pkh;
|
|
261
238
|
}
|
|
262
239
|
/**
|
|
263
|
-
*
|
|
264
|
-
|
|
240
|
+
* Access the public key hash of the active account
|
|
241
|
+
\* @throws ActiveAccountUnspecified thrown when there are multiple Tezos account in the session and none is set as the active one
|
|
265
242
|
*/
|
|
266
|
-
getPKH() {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return this.activeAccount;
|
|
273
|
-
});
|
|
243
|
+
async getPKH() {
|
|
244
|
+
if (!this.activeAccount) {
|
|
245
|
+
this.getSession();
|
|
246
|
+
throw new errors_1.ActiveAccountUnspecified();
|
|
247
|
+
}
|
|
248
|
+
return this.activeAccount;
|
|
274
249
|
}
|
|
275
250
|
/**
|
|
276
|
-
*
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
251
|
+
* Access the public key of the active account
|
|
252
|
+
\* @throws ActiveAccountUnspecified thrown when there are multiple Tezos account in the session and none is set as the active one
|
|
253
|
+
\* @throws MissingRequiredScope is thrown if permission to get accounts was not granted
|
|
254
|
+
\* @throws PublicKeyRetrievalError is thrown if the public key is not found
|
|
280
255
|
*/
|
|
281
|
-
getPK() {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
},
|
|
296
|
-
});
|
|
297
|
-
const selectedAccount = accounts.find((acc) => acc.address === account);
|
|
298
|
-
if (!selectedAccount) {
|
|
299
|
-
throw new errors_1.PublicKeyRetrievalError();
|
|
300
|
-
}
|
|
301
|
-
return selectedAccount.pubkey;
|
|
256
|
+
async getPK() {
|
|
257
|
+
const session = this.getSession();
|
|
258
|
+
if (!this.getPermittedMethods().includes(types_1.PermissionScopeMethods.TEZOS_GET_ACCOUNTS)) {
|
|
259
|
+
throw new errors_1.MissingRequiredScope(types_1.PermissionScopeMethods.TEZOS_GET_ACCOUNTS);
|
|
260
|
+
}
|
|
261
|
+
const network = this.getActiveNetwork();
|
|
262
|
+
const account = await this.getPKH();
|
|
263
|
+
const accounts = await this.signClient.request({
|
|
264
|
+
topic: session.topic,
|
|
265
|
+
chainId: `${TEZOS_PLACEHOLDER}:${network}`,
|
|
266
|
+
request: {
|
|
267
|
+
method: types_1.PermissionScopeMethods.TEZOS_GET_ACCOUNTS,
|
|
268
|
+
params: {},
|
|
269
|
+
},
|
|
302
270
|
});
|
|
271
|
+
const selectedAccount = accounts.find((acc) => acc.address === account);
|
|
272
|
+
if (!selectedAccount) {
|
|
273
|
+
throw new errors_1.PublicKeyRetrievalError();
|
|
274
|
+
}
|
|
275
|
+
return selectedAccount.pubkey;
|
|
303
276
|
}
|
|
304
277
|
/**
|
|
305
|
-
*
|
|
306
|
-
|
|
278
|
+
* Return all networks from the namespace of the active session
|
|
279
|
+
\* @throws NotConnected if no active session
|
|
307
280
|
*/
|
|
308
281
|
getNetworks() {
|
|
309
282
|
return this.getPermittedNetwork();
|
|
310
283
|
}
|
|
311
284
|
/**
|
|
312
|
-
*
|
|
285
|
+
* Set the active network.
|
|
313
286
|
* Must be called if there are multiple network in the session and every time the active network is switched
|
|
314
287
|
* @param network selected network
|
|
315
|
-
|
|
288
|
+
\* @throws InvalidNetwork thrown if the network is not part of the active networks in the session
|
|
316
289
|
*/
|
|
317
290
|
setActiveNetwork(network) {
|
|
318
291
|
if (!this.getNetworks().includes(network)) {
|
|
@@ -321,8 +294,8 @@ class WalletConnect {
|
|
|
321
294
|
this.activeNetwork = network;
|
|
322
295
|
}
|
|
323
296
|
/**
|
|
324
|
-
*
|
|
325
|
-
|
|
297
|
+
* Access the active network
|
|
298
|
+
\* @throws ActiveNetworkUnspecified thorwn when there are multiple Tezos netwroks in the session and none is set as the active one
|
|
326
299
|
*/
|
|
327
300
|
getActiveNetwork() {
|
|
328
301
|
if (!this.activeNetwork) {
|
|
@@ -489,59 +462,41 @@ class WalletConnect {
|
|
|
489
462
|
}
|
|
490
463
|
return operatedParams;
|
|
491
464
|
}
|
|
492
|
-
mapTransferParamsToWalletParams(params) {
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
496
|
-
});
|
|
465
|
+
async mapTransferParamsToWalletParams(params) {
|
|
466
|
+
const walletParams = await params();
|
|
467
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
497
468
|
}
|
|
498
|
-
mapTransferTicketParamsToWalletParams(params) {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createTransferTicketOperation)(this.formatParameters(walletParams)));
|
|
502
|
-
});
|
|
469
|
+
async mapTransferTicketParamsToWalletParams(params) {
|
|
470
|
+
const walletParams = await params();
|
|
471
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createTransferTicketOperation)(this.formatParameters(walletParams)));
|
|
503
472
|
}
|
|
504
|
-
mapStakeParamsToWalletParams(params) {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
508
|
-
});
|
|
473
|
+
async mapStakeParamsToWalletParams(params) {
|
|
474
|
+
const walletParams = await params();
|
|
475
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
509
476
|
}
|
|
510
|
-
mapUnstakeParamsToWalletParams(params) {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
514
|
-
});
|
|
477
|
+
async mapUnstakeParamsToWalletParams(params) {
|
|
478
|
+
const walletParams = await params();
|
|
479
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
515
480
|
}
|
|
516
|
-
mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
520
|
-
});
|
|
481
|
+
async mapFinalizeUnstakeParamsToWalletParams(params) {
|
|
482
|
+
const walletParams = await params();
|
|
483
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createTransferOperation)(this.formatParameters(walletParams)));
|
|
521
484
|
}
|
|
522
|
-
mapOriginateParamsToWalletParams(params) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createOriginationOperation)(this.formatParameters(walletParams)));
|
|
526
|
-
});
|
|
485
|
+
async mapOriginateParamsToWalletParams(params) {
|
|
486
|
+
const walletParams = await params();
|
|
487
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createOriginationOperation)(this.formatParameters(walletParams)));
|
|
527
488
|
}
|
|
528
|
-
mapDelegateParamsToWalletParams(params) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createSetDelegateOperation)(this.formatParameters(walletParams)));
|
|
532
|
-
});
|
|
489
|
+
async mapDelegateParamsToWalletParams(params) {
|
|
490
|
+
const walletParams = await params();
|
|
491
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createSetDelegateOperation)(this.formatParameters(walletParams)));
|
|
533
492
|
}
|
|
534
|
-
mapIncreasePaidStorageWalletParams(params) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createIncreasePaidStorageOperation)(this.formatParameters(walletParams)));
|
|
538
|
-
});
|
|
493
|
+
async mapIncreasePaidStorageWalletParams(params) {
|
|
494
|
+
const walletParams = await params();
|
|
495
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createIncreasePaidStorageOperation)(this.formatParameters(walletParams)));
|
|
539
496
|
}
|
|
540
|
-
mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return this.removeDefaultLimits(walletParams, yield (0, taquito_1.createRegisterGlobalConstantOperation)(this.formatParameters(walletParams)));
|
|
544
|
-
});
|
|
497
|
+
async mapRegisterGlobalConstantParamsToWalletParams(params) {
|
|
498
|
+
const walletParams = await params();
|
|
499
|
+
return this.removeDefaultLimits(walletParams, await (0, taquito_1.createRegisterGlobalConstantOperation)(this.formatParameters(walletParams)));
|
|
545
500
|
}
|
|
546
501
|
}
|
|
547
502
|
exports.WalletConnect = WalletConnect;
|
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
|
};
|