@novasamatech/host-api 0.6.0 → 0.6.2-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/hostApi.js CHANGED
@@ -465,5 +465,225 @@ export function createHostApi(transport) {
465
465
  jsonrpcMessageSubscribe(args, callback) {
466
466
  return transport.subscribe('host_jsonrpc_message_subscribe', args, callback);
467
467
  },
468
+ // chain interaction
469
+ chainHeadFollow(args, callback) {
470
+ return transport.subscribe('remote_chain_head_follow', args, callback);
471
+ },
472
+ chainHeadHeader(payload) {
473
+ const response = fromPromise(transport.request('remote_chain_head_header', payload), e => ({
474
+ tag: payload.tag,
475
+ value: new GenericError({ reason: extractErrorMessage(e) }),
476
+ }));
477
+ return response.andThen(response => {
478
+ if (response.value.success) {
479
+ return okAsync({
480
+ tag: response.tag,
481
+ value: response.value.value,
482
+ });
483
+ }
484
+ return errAsync({
485
+ tag: response.tag,
486
+ value: response.value.value,
487
+ });
488
+ });
489
+ },
490
+ chainHeadBody(payload) {
491
+ const response = fromPromise(transport.request('remote_chain_head_body', payload), e => ({
492
+ tag: payload.tag,
493
+ value: new GenericError({ reason: extractErrorMessage(e) }),
494
+ }));
495
+ return response.andThen(response => {
496
+ if (response.value.success) {
497
+ return okAsync({
498
+ tag: response.tag,
499
+ value: response.value.value,
500
+ });
501
+ }
502
+ return errAsync({
503
+ tag: response.tag,
504
+ value: response.value.value,
505
+ });
506
+ });
507
+ },
508
+ chainHeadStorage(payload) {
509
+ const response = fromPromise(transport.request('remote_chain_head_storage', payload), e => ({
510
+ tag: payload.tag,
511
+ value: new GenericError({ reason: extractErrorMessage(e) }),
512
+ }));
513
+ return response.andThen(response => {
514
+ if (response.value.success) {
515
+ return okAsync({
516
+ tag: response.tag,
517
+ value: response.value.value,
518
+ });
519
+ }
520
+ return errAsync({
521
+ tag: response.tag,
522
+ value: response.value.value,
523
+ });
524
+ });
525
+ },
526
+ chainHeadCall(payload) {
527
+ const response = fromPromise(transport.request('remote_chain_head_call', payload), e => ({
528
+ tag: payload.tag,
529
+ value: new GenericError({ reason: extractErrorMessage(e) }),
530
+ }));
531
+ return response.andThen(response => {
532
+ if (response.value.success) {
533
+ return okAsync({
534
+ tag: response.tag,
535
+ value: response.value.value,
536
+ });
537
+ }
538
+ return errAsync({
539
+ tag: response.tag,
540
+ value: response.value.value,
541
+ });
542
+ });
543
+ },
544
+ chainHeadUnpin(payload) {
545
+ const response = fromPromise(transport.request('remote_chain_head_unpin', payload), e => ({
546
+ tag: payload.tag,
547
+ value: new GenericError({ reason: extractErrorMessage(e) }),
548
+ }));
549
+ return response.andThen(response => {
550
+ if (response.value.success) {
551
+ return okAsync({
552
+ tag: response.tag,
553
+ value: response.value.value,
554
+ });
555
+ }
556
+ return errAsync({
557
+ tag: response.tag,
558
+ value: response.value.value,
559
+ });
560
+ });
561
+ },
562
+ chainHeadContinue(payload) {
563
+ const response = fromPromise(transport.request('remote_chain_head_continue', payload), e => ({
564
+ tag: payload.tag,
565
+ value: new GenericError({ reason: extractErrorMessage(e) }),
566
+ }));
567
+ return response.andThen(response => {
568
+ if (response.value.success) {
569
+ return okAsync({
570
+ tag: response.tag,
571
+ value: response.value.value,
572
+ });
573
+ }
574
+ return errAsync({
575
+ tag: response.tag,
576
+ value: response.value.value,
577
+ });
578
+ });
579
+ },
580
+ chainHeadStopOperation(payload) {
581
+ const response = fromPromise(transport.request('remote_chain_head_stop_operation', payload), e => ({
582
+ tag: payload.tag,
583
+ value: new GenericError({ reason: extractErrorMessage(e) }),
584
+ }));
585
+ return response.andThen(response => {
586
+ if (response.value.success) {
587
+ return okAsync({
588
+ tag: response.tag,
589
+ value: response.value.value,
590
+ });
591
+ }
592
+ return errAsync({
593
+ tag: response.tag,
594
+ value: response.value.value,
595
+ });
596
+ });
597
+ },
598
+ chainSpecGenesisHash(payload) {
599
+ const response = fromPromise(transport.request('remote_chain_spec_genesis_hash', payload), e => ({
600
+ tag: payload.tag,
601
+ value: new GenericError({ reason: extractErrorMessage(e) }),
602
+ }));
603
+ return response.andThen(response => {
604
+ if (response.value.success) {
605
+ return okAsync({
606
+ tag: response.tag,
607
+ value: response.value.value,
608
+ });
609
+ }
610
+ return errAsync({
611
+ tag: response.tag,
612
+ value: response.value.value,
613
+ });
614
+ });
615
+ },
616
+ chainSpecChainName(payload) {
617
+ const response = fromPromise(transport.request('remote_chain_spec_chain_name', payload), e => ({
618
+ tag: payload.tag,
619
+ value: new GenericError({ reason: extractErrorMessage(e) }),
620
+ }));
621
+ return response.andThen(response => {
622
+ if (response.value.success) {
623
+ return okAsync({
624
+ tag: response.tag,
625
+ value: response.value.value,
626
+ });
627
+ }
628
+ return errAsync({
629
+ tag: response.tag,
630
+ value: response.value.value,
631
+ });
632
+ });
633
+ },
634
+ chainSpecProperties(payload) {
635
+ const response = fromPromise(transport.request('remote_chain_spec_properties', payload), e => ({
636
+ tag: payload.tag,
637
+ value: new GenericError({ reason: extractErrorMessage(e) }),
638
+ }));
639
+ return response.andThen(response => {
640
+ if (response.value.success) {
641
+ return okAsync({
642
+ tag: response.tag,
643
+ value: response.value.value,
644
+ });
645
+ }
646
+ return errAsync({
647
+ tag: response.tag,
648
+ value: response.value.value,
649
+ });
650
+ });
651
+ },
652
+ chainTransactionBroadcast(payload) {
653
+ const response = fromPromise(transport.request('remote_chain_transaction_broadcast', payload), e => ({
654
+ tag: payload.tag,
655
+ value: new GenericError({ reason: extractErrorMessage(e) }),
656
+ }));
657
+ return response.andThen(response => {
658
+ if (response.value.success) {
659
+ return okAsync({
660
+ tag: response.tag,
661
+ value: response.value.value,
662
+ });
663
+ }
664
+ return errAsync({
665
+ tag: response.tag,
666
+ value: response.value.value,
667
+ });
668
+ });
669
+ },
670
+ chainTransactionStop(payload) {
671
+ const response = fromPromise(transport.request('remote_chain_transaction_stop', payload), e => ({
672
+ tag: payload.tag,
673
+ value: new GenericError({ reason: extractErrorMessage(e) }),
674
+ }));
675
+ return response.andThen(response => {
676
+ if (response.value.success) {
677
+ return okAsync({
678
+ tag: response.tag,
679
+ value: response.value.value,
680
+ });
681
+ }
682
+ return errAsync({
683
+ tag: response.tag,
684
+ value: response.value.value,
685
+ });
686
+ });
687
+ },
468
688
  };
469
689
  }
package/dist/index.d.ts CHANGED
@@ -24,3 +24,4 @@ export { PushNotification } from './protocol/v1/notification.js';
24
24
  export { NavigateToErr } from './protocol/v1/navigation.js';
25
25
  export { PreimageKey, PreimageSubmitErr, PreimageValue } from './protocol/v1/preimage.js';
26
26
  export { CustomRendererNode } from './protocol/v1/customRenderer.js';
27
+ export { ChainHeadEvent, ChainHeadFollowV1_start, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
package/dist/index.js CHANGED
@@ -19,3 +19,4 @@ export { PushNotification } from './protocol/v1/notification.js';
19
19
  export { NavigateToErr } from './protocol/v1/navigation.js';
20
20
  export { PreimageKey, PreimageSubmitErr, PreimageValue } from './protocol/v1/preimage.js';
21
21
  export { CustomRendererNode } from './protocol/v1/customRenderer.js';
22
+ export { ChainHeadEvent, ChainHeadFollowV1_start, OperationStartedResult, RuntimeType, StorageQueryItem, StorageQueryType, StorageResultItem, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './protocol/v1/chainInteraction.js';
@@ -476,5 +476,237 @@ export declare const hostApiProtocol: {
476
476
  readonly host_jsonrpc_message_subscribe: VersionedProtocolSubscription<{
477
477
  readonly v1: [Codec<`0x${string}`>, Codec<string>];
478
478
  }>;
479
+ readonly remote_chain_head_follow: VersionedProtocolSubscription<{
480
+ readonly v1: [Codec<{
481
+ genesisHash: `0x${string}`;
482
+ withRuntime: boolean;
483
+ }>, Codec<{
484
+ tag: "Initialized";
485
+ value: {
486
+ finalizedBlockHashes: `0x${string}`[];
487
+ finalizedBlockRuntime: {
488
+ tag: "Valid";
489
+ value: {
490
+ specName: string;
491
+ implName: string;
492
+ specVersion: number;
493
+ implVersion: number;
494
+ transactionVersion: number | undefined;
495
+ apis: [string, number][];
496
+ };
497
+ } | {
498
+ tag: "Invalid";
499
+ value: {
500
+ error: string;
501
+ };
502
+ } | undefined;
503
+ };
504
+ } | {
505
+ tag: "NewBlock";
506
+ value: {
507
+ blockHash: `0x${string}`;
508
+ parentBlockHash: `0x${string}`;
509
+ newRuntime: {
510
+ tag: "Valid";
511
+ value: {
512
+ specName: string;
513
+ implName: string;
514
+ specVersion: number;
515
+ implVersion: number;
516
+ transactionVersion: number | undefined;
517
+ apis: [string, number][];
518
+ };
519
+ } | {
520
+ tag: "Invalid";
521
+ value: {
522
+ error: string;
523
+ };
524
+ } | undefined;
525
+ };
526
+ } | {
527
+ tag: "BestBlockChanged";
528
+ value: {
529
+ bestBlockHash: `0x${string}`;
530
+ };
531
+ } | {
532
+ tag: "Finalized";
533
+ value: {
534
+ finalizedBlockHashes: `0x${string}`[];
535
+ prunedBlockHashes: `0x${string}`[];
536
+ };
537
+ } | {
538
+ tag: "OperationBodyDone";
539
+ value: {
540
+ operationId: string;
541
+ value: `0x${string}`[];
542
+ };
543
+ } | {
544
+ tag: "OperationCallDone";
545
+ value: {
546
+ operationId: string;
547
+ output: `0x${string}`;
548
+ };
549
+ } | {
550
+ tag: "OperationStorageItems";
551
+ value: {
552
+ operationId: string;
553
+ items: {
554
+ key: `0x${string}`;
555
+ value: `0x${string}` | null;
556
+ hash: `0x${string}` | null;
557
+ closestDescendantMerkleValue: `0x${string}` | null;
558
+ }[];
559
+ };
560
+ } | {
561
+ tag: "OperationStorageDone";
562
+ value: {
563
+ operationId: string;
564
+ };
565
+ } | {
566
+ tag: "OperationWaitingForContinue";
567
+ value: {
568
+ operationId: string;
569
+ };
570
+ } | {
571
+ tag: "OperationInaccessible";
572
+ value: {
573
+ operationId: string;
574
+ };
575
+ } | {
576
+ tag: "OperationError";
577
+ value: {
578
+ operationId: string;
579
+ error: string;
580
+ };
581
+ } | {
582
+ tag: "Stop";
583
+ value: undefined;
584
+ }>];
585
+ }>;
586
+ readonly remote_chain_head_header: VersionedProtocolRequest<{
587
+ readonly v1: [Codec<{
588
+ genesisHash: `0x${string}`;
589
+ followSubscriptionId: string;
590
+ hash: `0x${string}`;
591
+ }>, Codec<import("scale-ts").ResultPayload<`0x${string}` | null, import("@novasamatech/scale").CodecError<{
592
+ reason: string;
593
+ }, "GenericError">>>];
594
+ }>;
595
+ readonly remote_chain_head_body: VersionedProtocolRequest<{
596
+ readonly v1: [Codec<{
597
+ genesisHash: `0x${string}`;
598
+ followSubscriptionId: string;
599
+ hash: `0x${string}`;
600
+ }>, Codec<import("scale-ts").ResultPayload<{
601
+ tag: "Started";
602
+ value: {
603
+ operationId: string;
604
+ };
605
+ } | {
606
+ tag: "LimitReached";
607
+ value: undefined;
608
+ }, import("@novasamatech/scale").CodecError<{
609
+ reason: string;
610
+ }, "GenericError">>>];
611
+ }>;
612
+ readonly remote_chain_head_storage: VersionedProtocolRequest<{
613
+ readonly v1: [Codec<{
614
+ genesisHash: `0x${string}`;
615
+ followSubscriptionId: string;
616
+ hash: `0x${string}`;
617
+ items: {
618
+ key: `0x${string}`;
619
+ type: "Value" | "Hash" | "ClosestDescendantMerkleValue" | "DescendantsValues" | "DescendantsHashes";
620
+ }[];
621
+ childTrie: `0x${string}` | null;
622
+ }>, Codec<import("scale-ts").ResultPayload<{
623
+ tag: "Started";
624
+ value: {
625
+ operationId: string;
626
+ };
627
+ } | {
628
+ tag: "LimitReached";
629
+ value: undefined;
630
+ }, import("@novasamatech/scale").CodecError<{
631
+ reason: string;
632
+ }, "GenericError">>>];
633
+ }>;
634
+ readonly remote_chain_head_call: VersionedProtocolRequest<{
635
+ readonly v1: [Codec<{
636
+ genesisHash: `0x${string}`;
637
+ followSubscriptionId: string;
638
+ hash: `0x${string}`;
639
+ function: string;
640
+ callParameters: `0x${string}`;
641
+ }>, Codec<import("scale-ts").ResultPayload<{
642
+ tag: "Started";
643
+ value: {
644
+ operationId: string;
645
+ };
646
+ } | {
647
+ tag: "LimitReached";
648
+ value: undefined;
649
+ }, import("@novasamatech/scale").CodecError<{
650
+ reason: string;
651
+ }, "GenericError">>>];
652
+ }>;
653
+ readonly remote_chain_head_unpin: VersionedProtocolRequest<{
654
+ readonly v1: [Codec<{
655
+ genesisHash: `0x${string}`;
656
+ followSubscriptionId: string;
657
+ hashes: `0x${string}`[];
658
+ }>, Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
659
+ reason: string;
660
+ }, "GenericError">>>];
661
+ }>;
662
+ readonly remote_chain_head_continue: VersionedProtocolRequest<{
663
+ readonly v1: [Codec<{
664
+ genesisHash: `0x${string}`;
665
+ followSubscriptionId: string;
666
+ operationId: string;
667
+ }>, Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
668
+ reason: string;
669
+ }, "GenericError">>>];
670
+ }>;
671
+ readonly remote_chain_head_stop_operation: VersionedProtocolRequest<{
672
+ readonly v1: [Codec<{
673
+ genesisHash: `0x${string}`;
674
+ followSubscriptionId: string;
675
+ operationId: string;
676
+ }>, Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
677
+ reason: string;
678
+ }, "GenericError">>>];
679
+ }>;
680
+ readonly remote_chain_spec_genesis_hash: VersionedProtocolRequest<{
681
+ readonly v1: [Codec<`0x${string}`>, Codec<import("scale-ts").ResultPayload<`0x${string}`, import("@novasamatech/scale").CodecError<{
682
+ reason: string;
683
+ }, "GenericError">>>];
684
+ }>;
685
+ readonly remote_chain_spec_chain_name: VersionedProtocolRequest<{
686
+ readonly v1: [Codec<`0x${string}`>, Codec<import("scale-ts").ResultPayload<string, import("@novasamatech/scale").CodecError<{
687
+ reason: string;
688
+ }, "GenericError">>>];
689
+ }>;
690
+ readonly remote_chain_spec_properties: VersionedProtocolRequest<{
691
+ readonly v1: [Codec<`0x${string}`>, Codec<import("scale-ts").ResultPayload<string, import("@novasamatech/scale").CodecError<{
692
+ reason: string;
693
+ }, "GenericError">>>];
694
+ }>;
695
+ readonly remote_chain_transaction_broadcast: VersionedProtocolRequest<{
696
+ readonly v1: [Codec<{
697
+ genesisHash: `0x${string}`;
698
+ transaction: `0x${string}`;
699
+ }>, Codec<import("scale-ts").ResultPayload<string | null, import("@novasamatech/scale").CodecError<{
700
+ reason: string;
701
+ }, "GenericError">>>];
702
+ }>;
703
+ readonly remote_chain_transaction_stop: VersionedProtocolRequest<{
704
+ readonly v1: [Codec<{
705
+ genesisHash: `0x${string}`;
706
+ operationId: string;
707
+ }>, Codec<import("scale-ts").ResultPayload<undefined, import("@novasamatech/scale").CodecError<{
708
+ reason: string;
709
+ }, "GenericError">>>];
710
+ }>;
479
711
  };
480
712
  export {};
@@ -1,5 +1,6 @@
1
1
  import { Enum } from '@novasamatech/scale';
2
2
  import { AccountConnectionStatusV1_receive, AccountConnectionStatusV1_start, AccountCreateProofV1_request, AccountCreateProofV1_response, AccountGetAliasV1_request, AccountGetAliasV1_response, AccountGetV1_request, AccountGetV1_response, GetNonProductAccountsV1_request, GetNonProductAccountsV1_response, } from './v1/accounts.js';
3
+ import { ChainHeadBodyV1_request, ChainHeadBodyV1_response, ChainHeadCallV1_request, ChainHeadCallV1_response, ChainHeadContinueV1_request, ChainHeadContinueV1_response, ChainHeadFollowV1_receive, ChainHeadFollowV1_start, ChainHeadHeaderV1_request, ChainHeadHeaderV1_response, ChainHeadStopOperationV1_request, ChainHeadStopOperationV1_response, ChainHeadStorageV1_request, ChainHeadStorageV1_response, ChainHeadUnpinV1_request, ChainHeadUnpinV1_response, ChainSpecChainNameV1_request, ChainSpecChainNameV1_response, ChainSpecGenesisHashV1_request, ChainSpecGenesisHashV1_response, ChainSpecPropertiesV1_request, ChainSpecPropertiesV1_response, TransactionBroadcastV1_request, TransactionBroadcastV1_response, TransactionStopV1_request, TransactionStopV1_response, } from './v1/chainInteraction.js';
3
4
  import { ChatActionSubscribeV1_receive, ChatActionSubscribeV1_start, ChatCreateRoomV1_request, ChatCreateRoomV1_response, ChatCustomMessageRenderingV1_receive, ChatCustomMessageRenderingV1_start, ChatListSubscribeV1_receive, ChatListSubscribeV1_start, ChatPostMessageV1_request, ChatPostMessageV1_response, ChatRegisterBotV1_request, ChatRegisterBotV1_response, } from './v1/chat.js';
4
5
  import { CreateTransactionV1_request, CreateTransactionV1_response, CreateTransactionWithNonProductAccountV1_request, CreateTransactionWithNonProductAccountV1_response, } from './v1/createTransaction.js';
5
6
  import { DevicePermissionV1_request, DevicePermissionV1_response } from './v1/devicePermission.js';
@@ -126,11 +127,51 @@ export const hostApiProtocol = {
126
127
  remote_preimage_submit: versionedRequest({
127
128
  v1: [PreimageSubmitV1_request, PreimageSubmitV1_response],
128
129
  }),
129
- // json rpc (temporary, kept until chain methods are added)
130
+ // json rpc (deprecated: use remote_chain_* methods instead)
130
131
  host_jsonrpc_message_send: versionedRequest({
131
132
  v1: [JsonRpcMessageSendV1_request, JsonRpcMessageSendV1_response],
132
133
  }),
133
134
  host_jsonrpc_message_subscribe: versionedSubscription({
134
135
  v1: [JsonRpcMessageSubscribeV1_start, JsonRpcMessageSubscribeV1_receive],
135
136
  }),
137
+ // chain interaction (remote namespace)
138
+ remote_chain_head_follow: versionedSubscription({
139
+ v1: [ChainHeadFollowV1_start, ChainHeadFollowV1_receive],
140
+ }),
141
+ remote_chain_head_header: versionedRequest({
142
+ v1: [ChainHeadHeaderV1_request, ChainHeadHeaderV1_response],
143
+ }),
144
+ remote_chain_head_body: versionedRequest({
145
+ v1: [ChainHeadBodyV1_request, ChainHeadBodyV1_response],
146
+ }),
147
+ remote_chain_head_storage: versionedRequest({
148
+ v1: [ChainHeadStorageV1_request, ChainHeadStorageV1_response],
149
+ }),
150
+ remote_chain_head_call: versionedRequest({
151
+ v1: [ChainHeadCallV1_request, ChainHeadCallV1_response],
152
+ }),
153
+ remote_chain_head_unpin: versionedRequest({
154
+ v1: [ChainHeadUnpinV1_request, ChainHeadUnpinV1_response],
155
+ }),
156
+ remote_chain_head_continue: versionedRequest({
157
+ v1: [ChainHeadContinueV1_request, ChainHeadContinueV1_response],
158
+ }),
159
+ remote_chain_head_stop_operation: versionedRequest({
160
+ v1: [ChainHeadStopOperationV1_request, ChainHeadStopOperationV1_response],
161
+ }),
162
+ remote_chain_spec_genesis_hash: versionedRequest({
163
+ v1: [ChainSpecGenesisHashV1_request, ChainSpecGenesisHashV1_response],
164
+ }),
165
+ remote_chain_spec_chain_name: versionedRequest({
166
+ v1: [ChainSpecChainNameV1_request, ChainSpecChainNameV1_response],
167
+ }),
168
+ remote_chain_spec_properties: versionedRequest({
169
+ v1: [ChainSpecPropertiesV1_request, ChainSpecPropertiesV1_response],
170
+ }),
171
+ remote_chain_transaction_broadcast: versionedRequest({
172
+ v1: [TransactionBroadcastV1_request, TransactionBroadcastV1_response],
173
+ }),
174
+ remote_chain_transaction_stop: versionedRequest({
175
+ v1: [TransactionStopV1_request, TransactionStopV1_response],
176
+ }),
136
177
  };