@parity/product-sdk-host 0.16.0 → 0.18.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/{chain-discovery-nLrPzb3d.d.ts → chain-discovery-BEvu7HaV.d.ts} +42 -5
- package/dist/chunk-PAKEUP2Q.js +89 -0
- package/dist/chunk-PAKEUP2Q.js.map +1 -0
- package/dist/index.d.ts +52 -16
- package/dist/index.js +279 -93
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +9 -2
- package/dist/testing.js +3 -2
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
- package/src/accounts.ts +327 -101
- package/src/chains.ts +10 -3
- package/src/errors.ts +46 -0
- package/src/index.ts +7 -0
- package/src/papi-provider.ts +370 -37
- package/src/testing.ts +9 -2
- package/src/transport.ts +228 -4
- package/src/truapi.ts +139 -3
- package/dist/chunk-GDXSV7JV.js +0 -50
- package/dist/chunk-GDXSV7JV.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { getClient, isCorrectEnvironment, subscribeWithInterrupt } from './chunk-
|
|
2
|
-
export { isCorrectEnvironment as isInsideContainerSync } from './chunk-
|
|
1
|
+
import { getClient, isCorrectEnvironment, subscribeWithInterrupt } from './chunk-PAKEUP2Q.js';
|
|
2
|
+
export { isCorrectEnvironment as isInsideContainerSync, subscribeConnectionStatus } from './chunk-PAKEUP2Q.js';
|
|
3
3
|
import { createLogger } from '@parity/product-sdk-logger';
|
|
4
4
|
import { scale } from '@parity/truapi';
|
|
5
5
|
import { err, ok } from '@parity/result';
|
|
6
6
|
export { err, ok } from '@parity/result';
|
|
7
7
|
export { isSdkError } from '@parity/product-sdk-errors';
|
|
8
8
|
import { unifyMetadata, decAnyMetadata } from '@polkadot-api/substrate-bindings';
|
|
9
|
+
import { ResultAsync } from 'neverthrow';
|
|
9
10
|
import { AccountId } from 'polkadot-api';
|
|
10
11
|
|
|
11
12
|
// src/errors.ts
|
|
@@ -62,12 +63,41 @@ var HostCallFailedError = class extends HostError {
|
|
|
62
63
|
this.payload = payload;
|
|
63
64
|
}
|
|
64
65
|
};
|
|
66
|
+
var HostResponseDecodeError = class extends HostError {
|
|
67
|
+
/** The host-API call whose response failed to decode, e.g. `"createRingVRFProof"`. */
|
|
68
|
+
call;
|
|
69
|
+
constructor(call, cause) {
|
|
70
|
+
super(
|
|
71
|
+
`Could not process the host's response to ${call}: ${formatHostError(cause)}. The usual cause is a protocol-version skew between the host app and the @parity/truapi version this product is built against; a host channel that closed mid-call looks the same.`,
|
|
72
|
+
{ cause }
|
|
73
|
+
);
|
|
74
|
+
this.name = "HostResponseDecodeError";
|
|
75
|
+
this.call = call;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
65
78
|
function isHostError(error) {
|
|
66
79
|
return error instanceof HostError;
|
|
67
80
|
}
|
|
68
81
|
var log = createLogger("host:papi");
|
|
69
82
|
var JSON_RPC_INTERNAL_ERROR = -32603;
|
|
70
83
|
var JSON_RPC_METHOD_NOT_FOUND = -32601;
|
|
84
|
+
function followOperationId(item) {
|
|
85
|
+
switch (item.tag) {
|
|
86
|
+
case "OperationBodyDone":
|
|
87
|
+
case "OperationCallDone":
|
|
88
|
+
case "OperationStorageItems":
|
|
89
|
+
case "OperationStorageDone":
|
|
90
|
+
case "OperationWaitingForContinue":
|
|
91
|
+
case "OperationInaccessible":
|
|
92
|
+
case "OperationError":
|
|
93
|
+
return item.value.operationId;
|
|
94
|
+
default:
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function isTerminalOperationItem(item) {
|
|
99
|
+
return item.tag === "OperationBodyDone" || item.tag === "OperationCallDone" || item.tag === "OperationStorageDone" || item.tag === "OperationInaccessible" || item.tag === "OperationError";
|
|
100
|
+
}
|
|
71
101
|
var STORAGE_TYPE_MAP = {
|
|
72
102
|
value: "Value",
|
|
73
103
|
hash: "Hash",
|
|
@@ -174,6 +204,8 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
174
204
|
return (onMessage) => {
|
|
175
205
|
const activeFollows = /* @__PURE__ */ new Map();
|
|
176
206
|
const activeBroadcasts = /* @__PURE__ */ new Set();
|
|
207
|
+
const followOperations = /* @__PURE__ */ new Map();
|
|
208
|
+
const pendingOperationStarts = /* @__PURE__ */ new Map();
|
|
177
209
|
function sendJsonRpcResponse(id, result) {
|
|
178
210
|
onMessage({ jsonrpc: "2.0", id, result });
|
|
179
211
|
}
|
|
@@ -187,6 +219,72 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
187
219
|
params: { subscription, result: event }
|
|
188
220
|
});
|
|
189
221
|
}
|
|
222
|
+
function forwardFollowItem(followSubscriptionId, item) {
|
|
223
|
+
const operationId = followOperationId(item);
|
|
224
|
+
if (operationId === void 0) {
|
|
225
|
+
sendFollowEvent(followSubscriptionId, convertFollowEventToJsonRpc(item));
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const operations = followOperations.get(followSubscriptionId);
|
|
229
|
+
if (!operations) return;
|
|
230
|
+
let operation = operations.get(operationId);
|
|
231
|
+
if (!operation) {
|
|
232
|
+
if ((pendingOperationStarts.get(followSubscriptionId) ?? 0) === 0) {
|
|
233
|
+
sendFollowEvent(followSubscriptionId, convertFollowEventToJsonRpc(item));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
operation = { announced: false, items: [] };
|
|
237
|
+
operations.set(operationId, operation);
|
|
238
|
+
}
|
|
239
|
+
if (!operation.announced) {
|
|
240
|
+
operation.items.push(item);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
sendFollowEvent(followSubscriptionId, convertFollowEventToJsonRpc(item));
|
|
244
|
+
if (isTerminalOperationItem(item)) {
|
|
245
|
+
operations.delete(operationId);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function sendOperationStartedResponse(id, followSubscriptionId, result) {
|
|
249
|
+
sendJsonRpcResponse(id, convertOperationResultToJsonRpc(result));
|
|
250
|
+
if (result.tag !== "Started") return;
|
|
251
|
+
const operations = followOperations.get(followSubscriptionId);
|
|
252
|
+
if (!operations) return;
|
|
253
|
+
const operationId = result.value.operationId;
|
|
254
|
+
let operation = operations.get(operationId);
|
|
255
|
+
if (!operation) {
|
|
256
|
+
operation = { announced: true, items: [] };
|
|
257
|
+
operations.set(operationId, operation);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
operation.announced = true;
|
|
261
|
+
const pendingItems = operation.items;
|
|
262
|
+
operation.items = [];
|
|
263
|
+
for (const item of pendingItems) {
|
|
264
|
+
forwardFollowItem(followSubscriptionId, item);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function startOperationRequest(id, followSubscriptionId) {
|
|
268
|
+
const pending = pendingOperationStarts.get(followSubscriptionId);
|
|
269
|
+
if (pending !== void 0) {
|
|
270
|
+
pendingOperationStarts.set(followSubscriptionId, pending + 1);
|
|
271
|
+
}
|
|
272
|
+
const settle = () => {
|
|
273
|
+
const outstanding = pendingOperationStarts.get(followSubscriptionId);
|
|
274
|
+
if (outstanding === void 0) return;
|
|
275
|
+
pendingOperationStarts.set(followSubscriptionId, Math.max(0, outstanding - 1));
|
|
276
|
+
};
|
|
277
|
+
return {
|
|
278
|
+
ok: (response) => {
|
|
279
|
+
settle();
|
|
280
|
+
sendOperationStartedResponse(id, followSubscriptionId, response.operation);
|
|
281
|
+
},
|
|
282
|
+
err: (error) => {
|
|
283
|
+
settle();
|
|
284
|
+
hostError(id)(error);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
190
288
|
const hostError = (id) => (error) => sendJsonRpcError(id, JSON_RPC_INTERNAL_ERROR, formatHostError(error));
|
|
191
289
|
function handleMessage(message) {
|
|
192
290
|
const { id, method } = message;
|
|
@@ -199,8 +297,10 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
199
297
|
const forwardItem = (followSubscriptionId2, item) => {
|
|
200
298
|
if (item.tag === "Stop" && activeFollows.delete(followSubscriptionId2)) {
|
|
201
299
|
ref.handle?.unsubscribe();
|
|
300
|
+
followOperations.delete(followSubscriptionId2);
|
|
301
|
+
pendingOperationStarts.delete(followSubscriptionId2);
|
|
202
302
|
}
|
|
203
|
-
|
|
303
|
+
forwardFollowItem(followSubscriptionId2, item);
|
|
204
304
|
};
|
|
205
305
|
ref.handle = subscribeWithInterrupt(
|
|
206
306
|
chain.followHeadSubscribe({ request: { genesisHash, withRuntime } }),
|
|
@@ -224,11 +324,15 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
224
324
|
break;
|
|
225
325
|
}
|
|
226
326
|
ref.handle.onInterrupt(() => {
|
|
327
|
+
followOperations.delete(followSubscriptionId);
|
|
328
|
+
pendingOperationStarts.delete(followSubscriptionId);
|
|
227
329
|
if (activeFollows.delete(followSubscriptionId)) {
|
|
228
330
|
sendFollowEvent(followSubscriptionId, { event: "stop" });
|
|
229
331
|
}
|
|
230
332
|
});
|
|
231
333
|
activeFollows.set(followSubscriptionId, ref.handle);
|
|
334
|
+
followOperations.set(followSubscriptionId, /* @__PURE__ */ new Map());
|
|
335
|
+
pendingOperationStarts.set(followSubscriptionId, 0);
|
|
232
336
|
sendJsonRpcResponse(id, followSubscriptionId);
|
|
233
337
|
for (const item of pendingItems) {
|
|
234
338
|
forwardItem(followSubscriptionId, item);
|
|
@@ -242,6 +346,8 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
242
346
|
follow.unsubscribe();
|
|
243
347
|
activeFollows.delete(followSubId);
|
|
244
348
|
}
|
|
349
|
+
followOperations.delete(followSubId);
|
|
350
|
+
pendingOperationStarts.delete(followSubId);
|
|
245
351
|
sendJsonRpcResponse(id, null);
|
|
246
352
|
break;
|
|
247
353
|
}
|
|
@@ -255,13 +361,8 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
255
361
|
}
|
|
256
362
|
case "chainHead_v1_body": {
|
|
257
363
|
const [followSubscriptionId, hash] = params;
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
id,
|
|
261
|
-
convertOperationResultToJsonRpc(response.operation)
|
|
262
|
-
),
|
|
263
|
-
hostError(id)
|
|
264
|
-
);
|
|
364
|
+
const bodyStart = startOperationRequest(id, followSubscriptionId);
|
|
365
|
+
chain.getHeadBody({ genesisHash, followSubscriptionId, hash }).match(bodyStart.ok, bodyStart.err);
|
|
265
366
|
break;
|
|
266
367
|
}
|
|
267
368
|
case "chainHead_v1_storage": {
|
|
@@ -270,6 +371,7 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
270
371
|
key: item.key,
|
|
271
372
|
queryType: convertStorageType(item.type)
|
|
272
373
|
}));
|
|
374
|
+
const storageStart = startOperationRequest(id, followSubscriptionId);
|
|
273
375
|
chain.getHeadStorage({
|
|
274
376
|
genesisHash,
|
|
275
377
|
followSubscriptionId,
|
|
@@ -281,30 +383,19 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
281
383
|
// the inner Hex codec on `null`, which throws
|
|
282
384
|
// (`null.startsWith`). Coerce `null` → `undefined`.
|
|
283
385
|
childTrie: childTrie ?? void 0
|
|
284
|
-
}).match(
|
|
285
|
-
(response) => sendJsonRpcResponse(
|
|
286
|
-
id,
|
|
287
|
-
convertOperationResultToJsonRpc(response.operation)
|
|
288
|
-
),
|
|
289
|
-
hostError(id)
|
|
290
|
-
);
|
|
386
|
+
}).match(storageStart.ok, storageStart.err);
|
|
291
387
|
break;
|
|
292
388
|
}
|
|
293
389
|
case "chainHead_v1_call": {
|
|
294
390
|
const [followSubscriptionId, hash, fn, callParameters] = params;
|
|
391
|
+
const callStart = startOperationRequest(id, followSubscriptionId);
|
|
295
392
|
chain.callHead({
|
|
296
393
|
genesisHash,
|
|
297
394
|
followSubscriptionId,
|
|
298
395
|
hash,
|
|
299
396
|
function: fn,
|
|
300
397
|
callParameters
|
|
301
|
-
}).match(
|
|
302
|
-
(response) => sendJsonRpcResponse(
|
|
303
|
-
id,
|
|
304
|
-
convertOperationResultToJsonRpc(response.operation)
|
|
305
|
-
),
|
|
306
|
-
hostError(id)
|
|
307
|
-
);
|
|
398
|
+
}).match(callStart.ok, callStart.err);
|
|
308
399
|
break;
|
|
309
400
|
}
|
|
310
401
|
case "chainHead_v1_unpin": {
|
|
@@ -320,7 +411,10 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
320
411
|
}
|
|
321
412
|
case "chainHead_v1_stopOperation": {
|
|
322
413
|
const [followSubscriptionId, operationId] = params;
|
|
323
|
-
chain.stopHeadOperation({ genesisHash, followSubscriptionId, operationId }).match(() =>
|
|
414
|
+
chain.stopHeadOperation({ genesisHash, followSubscriptionId, operationId }).match(() => {
|
|
415
|
+
followOperations.get(followSubscriptionId)?.delete(operationId);
|
|
416
|
+
sendJsonRpcResponse(id, null);
|
|
417
|
+
}, hostError(id));
|
|
324
418
|
break;
|
|
325
419
|
}
|
|
326
420
|
case "chainSpec_v1_genesisHash": {
|
|
@@ -387,6 +481,8 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
387
481
|
handle.unsubscribe();
|
|
388
482
|
}
|
|
389
483
|
activeFollows.clear();
|
|
484
|
+
followOperations.clear();
|
|
485
|
+
pendingOperationStarts.clear();
|
|
390
486
|
for (const operationId of activeBroadcasts) {
|
|
391
487
|
chain.stopTransaction({ genesisHash, operationId }).match(
|
|
392
488
|
() => {
|
|
@@ -403,18 +499,59 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
403
499
|
|
|
404
500
|
// src/truapi.ts
|
|
405
501
|
var log2 = createLogger("host");
|
|
502
|
+
async function matchGuarded(result, label, onOk, onErr, onDecode) {
|
|
503
|
+
try {
|
|
504
|
+
return await result.match(
|
|
505
|
+
(value) => {
|
|
506
|
+
try {
|
|
507
|
+
return onOk(value);
|
|
508
|
+
} catch (thrown) {
|
|
509
|
+
throw new HandlerThrow(thrown);
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
(error) => {
|
|
513
|
+
try {
|
|
514
|
+
return onErr(error);
|
|
515
|
+
} catch (thrown) {
|
|
516
|
+
throw new HandlerThrow(thrown);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
} catch (cause) {
|
|
521
|
+
if (cause instanceof HandlerThrow) throw cause.thrown;
|
|
522
|
+
return onDecode(
|
|
523
|
+
cause instanceof HostResponseDecodeError ? cause : new HostResponseDecodeError(label, cause)
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
var HandlerThrow = class {
|
|
528
|
+
constructor(thrown) {
|
|
529
|
+
this.thrown = thrown;
|
|
530
|
+
}
|
|
531
|
+
thrown;
|
|
532
|
+
};
|
|
406
533
|
function unwrapHostResult(result, label) {
|
|
407
|
-
return
|
|
534
|
+
return matchGuarded(
|
|
535
|
+
result,
|
|
536
|
+
label,
|
|
408
537
|
(value) => value,
|
|
409
538
|
(error) => {
|
|
410
539
|
throw new Error(`${label}: ${formatHostError(error)}`, { cause: error });
|
|
540
|
+
},
|
|
541
|
+
// A response the client can't decode would otherwise reject with a raw
|
|
542
|
+
// `RangeError`; throw it as a typed, named error instead.
|
|
543
|
+
(decodeError) => {
|
|
544
|
+
throw decodeError;
|
|
411
545
|
}
|
|
412
546
|
);
|
|
413
547
|
}
|
|
414
548
|
function mapHostResult(result, map, label) {
|
|
415
|
-
return
|
|
549
|
+
return matchGuarded(
|
|
550
|
+
result,
|
|
551
|
+
label,
|
|
416
552
|
(value) => ok(map(value)),
|
|
417
|
-
(error) => err(new HostCallFailedError(label, error))
|
|
553
|
+
(error) => err(new HostCallFailedError(label, error)),
|
|
554
|
+
(decodeError) => err(decodeError)
|
|
418
555
|
);
|
|
419
556
|
}
|
|
420
557
|
function toHex(bytes) {
|
|
@@ -575,6 +712,7 @@ async function getStatementStore() {
|
|
|
575
712
|
// src/chains.ts
|
|
576
713
|
var BULLETIN_RPCS = {
|
|
577
714
|
paseo: ["wss://paseo-bulletin-next-rpc.polkadot.io"],
|
|
715
|
+
previewnet: ["wss://previewnet.substrate.dev/bulletin"],
|
|
578
716
|
devnet: ["wss://bulletin-paseo.tservices.es:8443"],
|
|
579
717
|
polkadot: [],
|
|
580
718
|
kusama: []
|
|
@@ -665,13 +803,25 @@ function sameRingLocation(a, b) {
|
|
|
665
803
|
function findRingVrfKeyHandle(keys, ring) {
|
|
666
804
|
return keys.find((key) => key.rings.some((candidate) => sameRingLocation(candidate, ring)))?.handle;
|
|
667
805
|
}
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
if (
|
|
806
|
+
var GENERAL_TX_EXT_VERSION = 5;
|
|
807
|
+
function selectHostTxExtVersion(formatVersions, txExtVersions) {
|
|
808
|
+
if (formatVersions.length === 0) {
|
|
671
809
|
throw new Error("No extrinsic version found in metadata");
|
|
672
810
|
}
|
|
673
|
-
|
|
674
|
-
|
|
811
|
+
if (formatVersions.includes(4)) {
|
|
812
|
+
return 0;
|
|
813
|
+
}
|
|
814
|
+
if (txExtVersions.includes(GENERAL_TX_EXT_VERSION)) {
|
|
815
|
+
return GENERAL_TX_EXT_VERSION;
|
|
816
|
+
}
|
|
817
|
+
throw new Error(
|
|
818
|
+
`Runtime offers no V4 extrinsic and no transaction-extension version ${GENERAL_TX_EXT_VERSION} (supported: ${txExtVersions.join(", ") || "none"}); cannot select a txExtVersion the host can assemble.`
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
function deriveTxExtVersion(metadata) {
|
|
822
|
+
const extrinsic = unifyMetadata(decAnyMetadata(metadata)).extrinsic;
|
|
823
|
+
const txExtVersions = Object.keys(extrinsic.signedExtensions).map(Number);
|
|
824
|
+
return selectHostTxExtVersion(extrinsic.version, txExtVersions);
|
|
675
825
|
}
|
|
676
826
|
var deps = { deriveTxExtVersion };
|
|
677
827
|
function toHostExtensions(signedExtensions) {
|
|
@@ -687,91 +837,127 @@ function toWireProductAccountId({
|
|
|
687
837
|
}) {
|
|
688
838
|
return { dotNsIdentifier, derivationIndex: { tag: "Index", value: derivationIndex } };
|
|
689
839
|
}
|
|
840
|
+
function guardDecode(call, result) {
|
|
841
|
+
return ResultAsync.fromPromise(
|
|
842
|
+
Promise.resolve(result),
|
|
843
|
+
(cause) => new HostResponseDecodeError(call, cause)
|
|
844
|
+
).andThen((inner) => inner);
|
|
845
|
+
}
|
|
690
846
|
function adaptAccountsProvider(client) {
|
|
691
847
|
const account = client.account;
|
|
692
848
|
const signing = client.signing;
|
|
693
849
|
return {
|
|
694
850
|
getUserId() {
|
|
695
|
-
return
|
|
696
|
-
|
|
697
|
-
|
|
851
|
+
return guardDecode(
|
|
852
|
+
"getUserId",
|
|
853
|
+
account.getUserId().map((response) => ({
|
|
854
|
+
primaryUsername: response.primaryUsername
|
|
855
|
+
}))
|
|
856
|
+
);
|
|
698
857
|
},
|
|
699
858
|
requestLogin(reason) {
|
|
700
|
-
return account.requestLogin({ reason });
|
|
859
|
+
return guardDecode("requestLogin", account.requestLogin({ reason }));
|
|
701
860
|
},
|
|
702
861
|
getProductAccount(dotNsIdentifier, derivationIndex = 0) {
|
|
703
|
-
return
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
862
|
+
return guardDecode(
|
|
863
|
+
"getProductAccount",
|
|
864
|
+
account.getAccount({
|
|
865
|
+
productAccountId: toWireProductAccountId({
|
|
866
|
+
dotNsIdentifier,
|
|
867
|
+
derivationIndex
|
|
868
|
+
})
|
|
869
|
+
}).map((response) => ({
|
|
870
|
+
publicKey: fromHex(response.account.publicKey),
|
|
871
|
+
dotNsIdentifier,
|
|
872
|
+
derivationIndex
|
|
873
|
+
}))
|
|
874
|
+
);
|
|
710
875
|
},
|
|
711
876
|
registerRingVrfKey(index, ring) {
|
|
712
|
-
return
|
|
877
|
+
return guardDecode(
|
|
878
|
+
"registerRingVrfKey",
|
|
879
|
+
account.registerRingVrfKey({ index: { tag: "Index", value: index }, ring }).map(fromHex)
|
|
880
|
+
);
|
|
713
881
|
},
|
|
714
882
|
listRingVrfKeys(owner, disclosure = "Anonymized") {
|
|
715
|
-
return
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
883
|
+
return guardDecode(
|
|
884
|
+
"listRingVrfKeys",
|
|
885
|
+
account.listRingVrfKeys({ owner, disclosure }).map(
|
|
886
|
+
(keys) => keys.map((key) => ({
|
|
887
|
+
...key,
|
|
888
|
+
handle: key.handle,
|
|
889
|
+
publicKey: key.publicKey === void 0 ? void 0 : fromHex(key.publicKey)
|
|
890
|
+
}))
|
|
891
|
+
)
|
|
721
892
|
);
|
|
722
893
|
},
|
|
723
894
|
getProductAccountAlias(keyHandle, context, location) {
|
|
724
|
-
return
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
895
|
+
return guardDecode(
|
|
896
|
+
"getProductAccountAlias",
|
|
897
|
+
account.getAccountAlias({
|
|
898
|
+
keyHandle,
|
|
899
|
+
context,
|
|
900
|
+
ringLocation: location
|
|
901
|
+
}).map((response) => ({
|
|
902
|
+
context: fromHex(response.context),
|
|
903
|
+
alias: fromHex(response.alias)
|
|
904
|
+
}))
|
|
905
|
+
);
|
|
732
906
|
},
|
|
733
907
|
getLegacyAccounts() {
|
|
734
|
-
return
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
908
|
+
return guardDecode(
|
|
909
|
+
"getLegacyAccounts",
|
|
910
|
+
account.getLegacyAccounts().map(
|
|
911
|
+
(response) => response.accounts.map((a) => ({
|
|
912
|
+
publicKey: fromHex(a.publicKey),
|
|
913
|
+
name: a.name
|
|
914
|
+
}))
|
|
915
|
+
)
|
|
739
916
|
);
|
|
740
917
|
},
|
|
741
918
|
createRingVRFProof(keyHandle, context, location, message) {
|
|
742
|
-
return
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
919
|
+
return guardDecode(
|
|
920
|
+
"createRingVRFProof",
|
|
921
|
+
account.createAccountProof({
|
|
922
|
+
keyHandle,
|
|
923
|
+
context,
|
|
924
|
+
ringLocation: location,
|
|
925
|
+
message: toHex(message)
|
|
926
|
+
}).map((response) => ({
|
|
927
|
+
proof: fromHex(response.proof),
|
|
928
|
+
contextualAlias: {
|
|
929
|
+
context: fromHex(response.contextualAlias.context),
|
|
930
|
+
alias: fromHex(response.contextualAlias.alias)
|
|
931
|
+
},
|
|
932
|
+
ringIndex: response.ringIndex,
|
|
933
|
+
ringRevision: response.ringRevision
|
|
934
|
+
}))
|
|
935
|
+
);
|
|
756
936
|
},
|
|
757
937
|
ringVrfSign(keyHandle, message) {
|
|
758
|
-
return
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
938
|
+
return guardDecode(
|
|
939
|
+
"ringVrfSign",
|
|
940
|
+
account.ringVrfSign({
|
|
941
|
+
keyHandle,
|
|
942
|
+
message: toHex(message)
|
|
943
|
+
}).map(fromHex)
|
|
944
|
+
);
|
|
762
945
|
},
|
|
763
946
|
signVrf(account_, transcriptLabel, items) {
|
|
764
|
-
return
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
947
|
+
return guardDecode(
|
|
948
|
+
"signVrf",
|
|
949
|
+
account.signVrf({
|
|
950
|
+
account: toWireProductAccountId(account_),
|
|
951
|
+
transcriptLabel: toHex(transcriptLabel),
|
|
952
|
+
items: items.map(({ label, value }) => ({
|
|
953
|
+
label: toHex(label),
|
|
954
|
+
value: toHex(value)
|
|
955
|
+
}))
|
|
956
|
+
}).map((response) => ({
|
|
957
|
+
preOutput: fromHex(response.preOutput),
|
|
958
|
+
proof: fromHex(response.proof)
|
|
770
959
|
}))
|
|
771
|
-
|
|
772
|
-
preOutput: fromHex(response.preOutput),
|
|
773
|
-
proof: fromHex(response.proof)
|
|
774
|
-
}));
|
|
960
|
+
);
|
|
775
961
|
},
|
|
776
962
|
getProductAccountSigner(account_) {
|
|
777
963
|
const productAccountId = toWireProductAccountId(account_);
|
|
@@ -1100,6 +1286,6 @@ async function stopTransaction(genesisHash, operationId) {
|
|
|
1100
1286
|
);
|
|
1101
1287
|
}
|
|
1102
1288
|
|
|
1103
|
-
export { BULLETIN_RPCS, ChainNotSupportedError, DEFAULT_BULLETIN_ENDPOINT, HostCallFailedError, HostError, HostUnavailableError, broadcastTransaction, createHostLocalStorage, createHostPreimageManager, createProofAuthorized, deriveEntropy, featureSupported, findRingVrfKeyHandle, formatHostError, fromHex, getAccountsProvider, getChainSpec, getChatManager, getHostChainInfo, getHostLocalStorage, getHostProvider, getNotificationManager, getPaymentManager, getPreimageManager, getStatementStore, getThemeProvider, getTruApi, isChainSupported, isHostError, isInsideContainer, navigateTo, requestDevicePermission, requestPermission, requestResourceAllocation, stopTransaction, toHex };
|
|
1289
|
+
export { BULLETIN_RPCS, ChainNotSupportedError, DEFAULT_BULLETIN_ENDPOINT, HostCallFailedError, HostError, HostResponseDecodeError, HostUnavailableError, broadcastTransaction, createHostLocalStorage, createHostPreimageManager, createProofAuthorized, deriveEntropy, featureSupported, findRingVrfKeyHandle, formatHostError, fromHex, getAccountsProvider, getChainSpec, getChatManager, getHostChainInfo, getHostLocalStorage, getHostProvider, getNotificationManager, getPaymentManager, getPreimageManager, getStatementStore, getThemeProvider, getTruApi, isChainSupported, isHostError, isInsideContainer, navigateTo, requestDevicePermission, requestPermission, requestResourceAllocation, stopTransaction, toHex };
|
|
1104
1290
|
//# sourceMappingURL=index.js.map
|
|
1105
1291
|
//# sourceMappingURL=index.js.map
|