@parity/product-sdk-host 0.17.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/index.d.ts +45 -12
- package/dist/index.js +166 -69
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/accounts.ts +311 -109
- package/src/errors.ts +46 -0
- package/src/index.ts +2 -0
- package/src/truapi.ts +139 -3
package/dist/index.d.ts
CHANGED
|
@@ -250,6 +250,29 @@ declare class HostCallFailedError extends HostError {
|
|
|
250
250
|
readonly payload: HostErrorPayload;
|
|
251
251
|
constructor(label: string, payload: HostErrorPayload);
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* A host call could not be processed to completion: the `ResultAsync` the
|
|
255
|
+
* truapi client returns rejected instead of resolving to an ok/err. The usual
|
|
256
|
+
* cause is a response the client's SCALE codec can't decode (a
|
|
257
|
+
* `RangeError: Offset is outside the bounds of the DataView`) because the host
|
|
258
|
+
* and the `@parity/truapi` version the product is built against disagree on the
|
|
259
|
+
* wire shape of that call — a protocol-version skew. A host channel that closed
|
|
260
|
+
* mid-call looks identical from here, so this does not assert the skew; the
|
|
261
|
+
* real error is preserved on {@link cause}.
|
|
262
|
+
*
|
|
263
|
+
* The truapi client catches the decode throw in its message handler and turns
|
|
264
|
+
* it into a promise rejection, then wraps the call with
|
|
265
|
+
* `ResultAsync.fromSafePromise`, which installs no rejection handler — so the
|
|
266
|
+
* rejection escapes the `Result` channel rather than landing on its err side.
|
|
267
|
+
* Without this boundary that surfaces as a raw `RangeError` with a stack naming
|
|
268
|
+
* neither the call nor the cause. This names the call, so a bug report has
|
|
269
|
+
* somewhere to start.
|
|
270
|
+
*/
|
|
271
|
+
declare class HostResponseDecodeError extends HostError {
|
|
272
|
+
/** The host-API call whose response failed to decode, e.g. `"createRingVRFProof"`. */
|
|
273
|
+
readonly call: string;
|
|
274
|
+
constructor(call: string, cause: unknown);
|
|
275
|
+
}
|
|
253
276
|
/** Check whether a value is any {@link HostError}. */
|
|
254
277
|
declare function isHostError(error: unknown): error is HostError;
|
|
255
278
|
|
|
@@ -495,6 +518,13 @@ type VrfTranscriptItem = {
|
|
|
495
518
|
type VrfSignature = {
|
|
496
519
|
[K in keyof VrfSignature$1]: Uint8Array;
|
|
497
520
|
};
|
|
521
|
+
/**
|
|
522
|
+
* A call's declared `Err` channel, plus {@link HostResponseDecodeError}: any
|
|
523
|
+
* host reply can fail to decode if the host and the product's `@parity/truapi`
|
|
524
|
+
* client are on different protocol versions, so every decoded call can surface
|
|
525
|
+
* it in addition to its own typed errors.
|
|
526
|
+
*/
|
|
527
|
+
type WithDecodeError<E> = E | HostResponseDecodeError;
|
|
498
528
|
/**
|
|
499
529
|
* Accounts provider handle, backed by `truApi.account.*` / `truApi.signing.*`.
|
|
500
530
|
* Surfaces the user's wallet accounts, app-scoped product accounts, Ring VRF,
|
|
@@ -503,14 +533,17 @@ type VrfSignature = {
|
|
|
503
533
|
* Lookup methods return a neverthrow `ResultAsync` (use `.match(ok, err)`);
|
|
504
534
|
* the signer factories return a synchronous PAPI `PolkadotSigner`. The `err`
|
|
505
535
|
* channel carries truapi's canonical `CallErrorValue` envelope around the
|
|
506
|
-
* per-call versioned domain error, exactly as the generated client returns it
|
|
536
|
+
* per-call versioned domain error, exactly as the generated client returns it,
|
|
537
|
+
* plus a {@link HostResponseDecodeError} for the case where the host's reply
|
|
538
|
+
* cannot be decoded at all (a host/client protocol-version skew) — see
|
|
539
|
+
* {@link WithDecodeError}.
|
|
507
540
|
*/
|
|
508
541
|
interface AccountsProvider {
|
|
509
542
|
getUserId(): ResultAsync$1<{
|
|
510
543
|
primaryUsername: string;
|
|
511
|
-
}, scale.CallErrorValue<VersionedHostGetUserIdError
|
|
512
|
-
requestLogin(reason?: string): ResultAsync$1<HostRequestLoginResponse, scale.CallErrorValue<VersionedHostRequestLoginError
|
|
513
|
-
getProductAccount(dotNsIdentifier: string, derivationIndex?: number): ResultAsync$1<ProductAccount, scale.CallErrorValue<VersionedHostAccountGetError
|
|
544
|
+
}, WithDecodeError<scale.CallErrorValue<VersionedHostGetUserIdError>>>;
|
|
545
|
+
requestLogin(reason?: string): ResultAsync$1<HostRequestLoginResponse, WithDecodeError<scale.CallErrorValue<VersionedHostRequestLoginError>>>;
|
|
546
|
+
getProductAccount(dotNsIdentifier: string, derivationIndex?: number): ResultAsync$1<ProductAccount, WithDecodeError<scale.CallErrorValue<VersionedHostAccountGetError>>>;
|
|
514
547
|
/**
|
|
515
548
|
* Register a ring-VRF key owned by the calling product.
|
|
516
549
|
*
|
|
@@ -520,17 +553,17 @@ interface AccountsProvider {
|
|
|
520
553
|
* Registration returns the key's public key. Call {@link listRingVrfKeys}
|
|
521
554
|
* afterward to obtain the opaque handle required by alias and proof calls.
|
|
522
555
|
*/
|
|
523
|
-
registerRingVrfKey(index: number, ring: RingLocation): ResultAsync$1<RingVrfPublicKey, scale.CallErrorValue<VersionedHostAccountRegisterRingVrfKeyError
|
|
556
|
+
registerRingVrfKey(index: number, ring: RingLocation): ResultAsync$1<RingVrfPublicKey, WithDecodeError<scale.CallErrorValue<VersionedHostAccountRegisterRingVrfKeyError>>>;
|
|
524
557
|
/** List an owner's registered ring-VRF keys. */
|
|
525
|
-
listRingVrfKeys(owner: string, disclosure?: RingVrfKeyDisclosure): ResultAsync$1<RegisteredRingVrfKey[], scale.CallErrorValue<VersionedHostAccountListRingVrfKeysError
|
|
558
|
+
listRingVrfKeys(owner: string, disclosure?: RingVrfKeyDisclosure): ResultAsync$1<RegisteredRingVrfKey[], WithDecodeError<scale.CallErrorValue<VersionedHostAccountListRingVrfKeysError>>>;
|
|
526
559
|
/** Derive a contextual alias with an explicitly registered ring-VRF key. */
|
|
527
|
-
getProductAccountAlias(keyHandle: RingVrfKeyHandle, context: ProductProofContext, location: RingLocation): ResultAsync$1<ContextualAlias, scale.CallErrorValue<VersionedHostAccountGetAliasError
|
|
528
|
-
getLegacyAccounts(): ResultAsync$1<HostAccount[], scale.CallErrorValue<VersionedHostGetLegacyAccountsError
|
|
560
|
+
getProductAccountAlias(keyHandle: RingVrfKeyHandle, context: ProductProofContext, location: RingLocation): ResultAsync$1<ContextualAlias, WithDecodeError<scale.CallErrorValue<VersionedHostAccountGetAliasError>>>;
|
|
561
|
+
getLegacyAccounts(): ResultAsync$1<HostAccount[], WithDecodeError<scale.CallErrorValue<VersionedHostGetLegacyAccountsError>>>;
|
|
529
562
|
/**
|
|
530
563
|
* Generate a Ring VRF proof with an explicitly registered key, binding
|
|
531
564
|
* `message` to the product-scoped `context`.
|
|
532
565
|
*/
|
|
533
|
-
createRingVRFProof(keyHandle: RingVrfKeyHandle, context: ProductProofContext, location: RingLocation, message: Uint8Array): ResultAsync$1<RingVRFProof, scale.CallErrorValue<VersionedHostAccountCreateProofError
|
|
566
|
+
createRingVRFProof(keyHandle: RingVrfKeyHandle, context: ProductProofContext, location: RingLocation, message: Uint8Array): ResultAsync$1<RingVRFProof, WithDecodeError<scale.CallErrorValue<VersionedHostAccountCreateProofError>>>;
|
|
534
567
|
/**
|
|
535
568
|
* Sign `message` directly with an explicitly registered ring-VRF key.
|
|
536
569
|
*
|
|
@@ -538,7 +571,7 @@ interface AccountsProvider {
|
|
|
538
571
|
* membership; it is the plain signature under the member key, for
|
|
539
572
|
* protocols that carry their own proof.
|
|
540
573
|
*/
|
|
541
|
-
ringVrfSign(keyHandle: RingVrfKeyHandle, message: Uint8Array): ResultAsync$1<Uint8Array, scale.CallErrorValue<VersionedHostAccountRingVrfSignError
|
|
574
|
+
ringVrfSign(keyHandle: RingVrfKeyHandle, message: Uint8Array): ResultAsync$1<Uint8Array, WithDecodeError<scale.CallErrorValue<VersionedHostAccountRingVrfSignError>>>;
|
|
542
575
|
/**
|
|
543
576
|
* Produce an sr25519 VRF signature from a product account (RFC-0023).
|
|
544
577
|
*
|
|
@@ -558,7 +591,7 @@ interface AccountsProvider {
|
|
|
558
591
|
*
|
|
559
592
|
* Hosts predating the call reject it through the error channel.
|
|
560
593
|
*/
|
|
561
|
-
signVrf(account: ProductAccountLookup, transcriptLabel: Uint8Array, items: VrfTranscriptItem[]): ResultAsync$1<VrfSignature, scale.CallErrorValue<VersionedHostAccountSignVrfError
|
|
594
|
+
signVrf(account: ProductAccountLookup, transcriptLabel: Uint8Array, items: VrfTranscriptItem[]): ResultAsync$1<VrfSignature, WithDecodeError<scale.CallErrorValue<VersionedHostAccountSignVrfError>>>;
|
|
562
595
|
/**
|
|
563
596
|
* Build a `PolkadotSigner` for a product account. Signing routes through the
|
|
564
597
|
* host's `createTransaction` path: the host decodes the metadata and forwards
|
|
@@ -1110,4 +1143,4 @@ declare function broadcastTransaction(genesisHash: HexString, transaction: HexSt
|
|
|
1110
1143
|
*/
|
|
1111
1144
|
declare function stopTransaction(genesisHash: HexString, operationId: string): Promise<Result<void, HostError>>;
|
|
1112
1145
|
|
|
1113
|
-
export { type AccountsProvider, BULLETIN_RPCS, ChainNotSupportedError, type ChainProperties, type ChainSpec, type ChatBotRegistrationResult, type ChatManager, type ChatReceivedAction, type ChatRoomRegistrationResult, type ContextualAlias, DEFAULT_BULLETIN_ENDPOINT, type DevicePermissionKind, type Feature, type HostAccount, HostCallFailedError, HostError, type HostErrorPayload, type HostLocalStorage, type HostStatementStore, type HostSubscription, HostUnavailableError, type NotificationManager, type PaymentManager, type PreimageManager, type ProductAccount, type ProductAccountLookup, type PushNotificationInput, type RegisteredRingVrfKey, type RemotePermissionItem, type ResultAsync, type RingVRFProof, type RingVrfKeyHandle, type RingVrfPublicKey, type StatementTopicFilter, type StatementsPage, type ThemeMode, type ThemeProvider, type TruApi, type VrfSignature, type VrfTranscriptItem, broadcastTransaction, createHostLocalStorage, createHostPreimageManager, createProofAuthorized, deriveEntropy, featureSupported, findRingVrfKeyHandle, formatHostError, fromHex, getAccountsProvider, getChainSpec, getChatManager, getHostLocalStorage, getHostProvider, getNotificationManager, getPaymentManager, getPreimageManager, getStatementStore, getThemeProvider, getTruApi, isChainSupported, isHostError, isInsideContainer, navigateTo, requestDevicePermission, requestPermission, requestResourceAllocation, stopTransaction, toHex };
|
|
1146
|
+
export { type AccountsProvider, BULLETIN_RPCS, ChainNotSupportedError, type ChainProperties, type ChainSpec, type ChatBotRegistrationResult, type ChatManager, type ChatReceivedAction, type ChatRoomRegistrationResult, type ContextualAlias, DEFAULT_BULLETIN_ENDPOINT, type DevicePermissionKind, type Feature, type HostAccount, HostCallFailedError, HostError, type HostErrorPayload, type HostLocalStorage, HostResponseDecodeError, type HostStatementStore, type HostSubscription, HostUnavailableError, type NotificationManager, type PaymentManager, type PreimageManager, type ProductAccount, type ProductAccountLookup, type PushNotificationInput, type RegisteredRingVrfKey, type RemotePermissionItem, type ResultAsync, type RingVRFProof, type RingVrfKeyHandle, type RingVrfPublicKey, type StatementTopicFilter, type StatementsPage, type ThemeMode, type ThemeProvider, type TruApi, type VrfSignature, type VrfTranscriptItem, type WithDecodeError, broadcastTransaction, createHostLocalStorage, createHostPreimageManager, createProofAuthorized, deriveEntropy, featureSupported, findRingVrfKeyHandle, formatHostError, fromHex, getAccountsProvider, getChainSpec, getChatManager, getHostLocalStorage, getHostProvider, getNotificationManager, getPaymentManager, getPreimageManager, getStatementStore, getThemeProvider, getTruApi, isChainSupported, isHostError, isInsideContainer, navigateTo, requestDevicePermission, requestPermission, requestResourceAllocation, stopTransaction, toHex };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ 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,6 +63,18 @@ 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
|
}
|
|
@@ -486,18 +499,59 @@ function createHostPapiProvider(client, genesisHash) {
|
|
|
486
499
|
|
|
487
500
|
// src/truapi.ts
|
|
488
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
|
+
};
|
|
489
533
|
function unwrapHostResult(result, label) {
|
|
490
|
-
return
|
|
534
|
+
return matchGuarded(
|
|
535
|
+
result,
|
|
536
|
+
label,
|
|
491
537
|
(value) => value,
|
|
492
538
|
(error) => {
|
|
493
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;
|
|
494
545
|
}
|
|
495
546
|
);
|
|
496
547
|
}
|
|
497
548
|
function mapHostResult(result, map, label) {
|
|
498
|
-
return
|
|
549
|
+
return matchGuarded(
|
|
550
|
+
result,
|
|
551
|
+
label,
|
|
499
552
|
(value) => ok(map(value)),
|
|
500
|
-
(error) => err(new HostCallFailedError(label, error))
|
|
553
|
+
(error) => err(new HostCallFailedError(label, error)),
|
|
554
|
+
(decodeError) => err(decodeError)
|
|
501
555
|
);
|
|
502
556
|
}
|
|
503
557
|
function toHex(bytes) {
|
|
@@ -749,18 +803,25 @@ function sameRingLocation(a, b) {
|
|
|
749
803
|
function findRingVrfKeyHandle(keys, ring) {
|
|
750
804
|
return keys.find((key) => key.rings.some((candidate) => sameRingLocation(candidate, ring)))?.handle;
|
|
751
805
|
}
|
|
752
|
-
|
|
753
|
-
|
|
806
|
+
var GENERAL_TX_EXT_VERSION = 5;
|
|
807
|
+
function selectHostTxExtVersion(formatVersions, txExtVersions) {
|
|
808
|
+
if (formatVersions.length === 0) {
|
|
754
809
|
throw new Error("No extrinsic version found in metadata");
|
|
755
810
|
}
|
|
756
|
-
if (
|
|
811
|
+
if (formatVersions.includes(4)) {
|
|
757
812
|
return 0;
|
|
758
813
|
}
|
|
759
|
-
|
|
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
|
+
);
|
|
760
820
|
}
|
|
761
821
|
function deriveTxExtVersion(metadata) {
|
|
762
|
-
const
|
|
763
|
-
|
|
822
|
+
const extrinsic = unifyMetadata(decAnyMetadata(metadata)).extrinsic;
|
|
823
|
+
const txExtVersions = Object.keys(extrinsic.signedExtensions).map(Number);
|
|
824
|
+
return selectHostTxExtVersion(extrinsic.version, txExtVersions);
|
|
764
825
|
}
|
|
765
826
|
var deps = { deriveTxExtVersion };
|
|
766
827
|
function toHostExtensions(signedExtensions) {
|
|
@@ -776,91 +837,127 @@ function toWireProductAccountId({
|
|
|
776
837
|
}) {
|
|
777
838
|
return { dotNsIdentifier, derivationIndex: { tag: "Index", value: derivationIndex } };
|
|
778
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
|
+
}
|
|
779
846
|
function adaptAccountsProvider(client) {
|
|
780
847
|
const account = client.account;
|
|
781
848
|
const signing = client.signing;
|
|
782
849
|
return {
|
|
783
850
|
getUserId() {
|
|
784
|
-
return
|
|
785
|
-
|
|
786
|
-
|
|
851
|
+
return guardDecode(
|
|
852
|
+
"getUserId",
|
|
853
|
+
account.getUserId().map((response) => ({
|
|
854
|
+
primaryUsername: response.primaryUsername
|
|
855
|
+
}))
|
|
856
|
+
);
|
|
787
857
|
},
|
|
788
858
|
requestLogin(reason) {
|
|
789
|
-
return account.requestLogin({ reason });
|
|
859
|
+
return guardDecode("requestLogin", account.requestLogin({ reason }));
|
|
790
860
|
},
|
|
791
861
|
getProductAccount(dotNsIdentifier, derivationIndex = 0) {
|
|
792
|
-
return
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
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
|
+
);
|
|
799
875
|
},
|
|
800
876
|
registerRingVrfKey(index, ring) {
|
|
801
|
-
return
|
|
877
|
+
return guardDecode(
|
|
878
|
+
"registerRingVrfKey",
|
|
879
|
+
account.registerRingVrfKey({ index: { tag: "Index", value: index }, ring }).map(fromHex)
|
|
880
|
+
);
|
|
802
881
|
},
|
|
803
882
|
listRingVrfKeys(owner, disclosure = "Anonymized") {
|
|
804
|
-
return
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
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
|
+
)
|
|
810
892
|
);
|
|
811
893
|
},
|
|
812
894
|
getProductAccountAlias(keyHandle, context, location) {
|
|
813
|
-
return
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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
|
+
);
|
|
821
906
|
},
|
|
822
907
|
getLegacyAccounts() {
|
|
823
|
-
return
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
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
|
+
)
|
|
828
916
|
);
|
|
829
917
|
},
|
|
830
918
|
createRingVRFProof(keyHandle, context, location, message) {
|
|
831
|
-
return
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
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
|
+
);
|
|
845
936
|
},
|
|
846
937
|
ringVrfSign(keyHandle, message) {
|
|
847
|
-
return
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
938
|
+
return guardDecode(
|
|
939
|
+
"ringVrfSign",
|
|
940
|
+
account.ringVrfSign({
|
|
941
|
+
keyHandle,
|
|
942
|
+
message: toHex(message)
|
|
943
|
+
}).map(fromHex)
|
|
944
|
+
);
|
|
851
945
|
},
|
|
852
946
|
signVrf(account_, transcriptLabel, items) {
|
|
853
|
-
return
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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)
|
|
859
959
|
}))
|
|
860
|
-
|
|
861
|
-
preOutput: fromHex(response.preOutput),
|
|
862
|
-
proof: fromHex(response.proof)
|
|
863
|
-
}));
|
|
960
|
+
);
|
|
864
961
|
},
|
|
865
962
|
getProductAccountSigner(account_) {
|
|
866
963
|
const productAccountId = toWireProductAccountId(account_);
|
|
@@ -1189,6 +1286,6 @@ async function stopTransaction(genesisHash, operationId) {
|
|
|
1189
1286
|
);
|
|
1190
1287
|
}
|
|
1191
1288
|
|
|
1192
|
-
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 };
|
|
1193
1290
|
//# sourceMappingURL=index.js.map
|
|
1194
1291
|
//# sourceMappingURL=index.js.map
|