@novasamatech/host-api 0.5.0-9 → 0.5.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/README.md +103 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/helpers.d.ts +33 -0
- package/dist/helpers.js +46 -0
- package/dist/hostApi.d.ts +31 -0
- package/dist/hostApi.js +345 -0
- package/dist/index.d.ts +18 -7
- package/dist/index.js +14 -6
- package/dist/protocol/commonCodecs.d.ts +42 -0
- package/dist/protocol/commonCodecs.js +64 -0
- package/dist/protocol/commonCodecs.spec.d.ts +1 -0
- package/dist/protocol/commonCodecs.spec.js +72 -0
- package/dist/protocol/impl.d.ts +93 -0
- package/dist/protocol/impl.js +97 -0
- package/dist/protocol/messageCodec.d.ts +1245 -0
- package/dist/protocol/messageCodec.js +24 -0
- package/dist/protocol/types.d.ts +1 -0
- package/dist/protocol/types.js +1 -0
- package/dist/protocol/v1/accounts.d.ts +265 -0
- package/dist/protocol/v1/accounts.js +51 -0
- package/dist/protocol/v1/chat.d.ts +341 -0
- package/dist/protocol/v1/chat.js +71 -0
- package/dist/protocol/v1/createTransaction.d.ts +238 -0
- package/dist/protocol/v1/createTransaction.js +58 -0
- package/dist/protocol/v1/feature.d.ts +15 -0
- package/dist/protocol/v1/feature.js +7 -0
- package/dist/protocol/v1/handshake.d.ts +85 -0
- package/dist/protocol/v1/handshake.js +12 -0
- package/dist/protocol/v1/jsonRpc.d.ts +10 -0
- package/dist/protocol/v1/jsonRpc.js +6 -0
- package/dist/protocol/v1/permission.d.ts +90 -0
- package/dist/protocol/v1/permission.js +18 -0
- package/dist/protocol/v1/sign.d.ts +152 -0
- package/dist/protocol/v1/sign.js +43 -0
- package/dist/protocol/v1/statementStore.d.ts +175 -0
- package/dist/protocol/v1/statementStore.js +47 -0
- package/dist/protocol/v1/storage.d.ts +87 -0
- package/dist/protocol/v1/storage.js +16 -0
- package/dist/provider.d.ts +8 -0
- package/dist/provider.js +1 -0
- package/dist/transport.d.ts +3 -0
- package/dist/transport.js +248 -0
- package/dist/types.d.ts +15 -15
- package/package.json +2 -4
- package/dist/commonEncoders.d.ts +0 -9
- package/dist/commonEncoders.js +0 -14
- package/dist/createTransport.d.ts +0 -6
- package/dist/createTransport.js +0 -183
- package/dist/createTransportEncoder.d.ts +0 -7
- package/dist/createTransportEncoder.js +0 -5
- package/dist/interactions/accounts.d.ts +0 -12
- package/dist/interactions/accounts.js +0 -39
- package/dist/interactions/features.d.ts +0 -13
- package/dist/interactions/features.js +0 -13
- package/dist/interactions/handshake.d.ts +0 -2
- package/dist/interactions/handshake.js +0 -3
- package/dist/interactions/papiProvider.d.ts +0 -8
- package/dist/interactions/papiProvider.js +0 -9
- package/dist/interactions/sign.d.ts +0 -101
- package/dist/interactions/sign.js +0 -169
- package/dist/messageEncoder.d.ts +0 -217
- package/dist/messageEncoder.js +0 -37
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Option, Result, Struct, Vector, _void, str, u64 } from 'scale-ts';
|
|
2
|
+
import { Enum, ErrEnum, GenericErr, Status } from '../commonCodecs.js';
|
|
3
|
+
// contact
|
|
4
|
+
export const ChatContactRegistrationErr = ErrEnum('ChatContactRegistrationErr', {
|
|
5
|
+
Unknown: [GenericErr, 'Unknown error while chat registration'],
|
|
6
|
+
});
|
|
7
|
+
export const ChatContactRegistrationStatus = Status('New', 'Exists');
|
|
8
|
+
export const ChatContact = Struct({
|
|
9
|
+
name: str,
|
|
10
|
+
icon: str, // url or base64 encoded image for contact
|
|
11
|
+
});
|
|
12
|
+
export const ChatCreateContactV1_request = ChatContact;
|
|
13
|
+
export const ChatCreateContactV1_response = Result(ChatContactRegistrationStatus, ChatContactRegistrationErr);
|
|
14
|
+
// message format
|
|
15
|
+
export const ChatAction = Struct({
|
|
16
|
+
actionId: str,
|
|
17
|
+
title: str,
|
|
18
|
+
});
|
|
19
|
+
export const ChatActionLayout = Status('Column', 'Grid');
|
|
20
|
+
export const ChatActions = Struct({
|
|
21
|
+
text: Option(str),
|
|
22
|
+
actions: Vector(ChatAction),
|
|
23
|
+
layout: ChatActionLayout,
|
|
24
|
+
});
|
|
25
|
+
export const ChatMedia = Struct({
|
|
26
|
+
url: str,
|
|
27
|
+
});
|
|
28
|
+
export const ChatRichText = Struct({
|
|
29
|
+
text: Option(str),
|
|
30
|
+
media: Vector(ChatMedia),
|
|
31
|
+
});
|
|
32
|
+
export const ChatFile = Struct({
|
|
33
|
+
url: str,
|
|
34
|
+
fileName: str,
|
|
35
|
+
mimeType: str,
|
|
36
|
+
sizeBytes: u64,
|
|
37
|
+
text: Option(str),
|
|
38
|
+
});
|
|
39
|
+
export const ChatReaction = Struct({
|
|
40
|
+
messageId: str,
|
|
41
|
+
emoji: str,
|
|
42
|
+
});
|
|
43
|
+
export const ChatMessage = Enum({
|
|
44
|
+
Text: str,
|
|
45
|
+
RichText: ChatRichText,
|
|
46
|
+
Actions: ChatActions,
|
|
47
|
+
File: ChatFile,
|
|
48
|
+
Reaction: ChatReaction,
|
|
49
|
+
ReactionRemoved: ChatReaction,
|
|
50
|
+
});
|
|
51
|
+
// sending message
|
|
52
|
+
export const ChatMessagePostingErr = ErrEnum('ChatMessagePostingErr', {
|
|
53
|
+
MessageTooLarge: [_void, 'ChatMessagePosting: message too large'],
|
|
54
|
+
Unknown: [GenericErr, 'ChatMessagePosting: unknown error'],
|
|
55
|
+
});
|
|
56
|
+
export const ChatPostMessageResult = Struct({
|
|
57
|
+
messageId: str,
|
|
58
|
+
});
|
|
59
|
+
export const ChatPostMessageV1_request = ChatMessage;
|
|
60
|
+
export const ChatPostMessageV1_response = Result(ChatPostMessageResult, ChatMessagePostingErr);
|
|
61
|
+
// receiving a message
|
|
62
|
+
export const ActionTrigger = Struct({
|
|
63
|
+
messageId: str,
|
|
64
|
+
actionId: str,
|
|
65
|
+
});
|
|
66
|
+
export const ReceivedChatAction = Enum({
|
|
67
|
+
MessagePosted: ChatMessage,
|
|
68
|
+
ActionTriggered: ActionTrigger,
|
|
69
|
+
});
|
|
70
|
+
export const ChatActionSubscribeV1_start = _void;
|
|
71
|
+
export const ChatActionSubscribeV1_receive = ReceivedChatAction;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { HexString } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* createTransaction implementation
|
|
4
|
+
* @see https://github.com/polkadot-js/api/issues/6213
|
|
5
|
+
*/
|
|
6
|
+
export declare const CreateTransactionErr: [import("scale-ts").Encoder<(Error & {
|
|
7
|
+
name: "CreateTransactionErr::Rejected";
|
|
8
|
+
className: string;
|
|
9
|
+
payload: undefined;
|
|
10
|
+
}) | (Error & {
|
|
11
|
+
name: "CreateTransactionErr::Unknown";
|
|
12
|
+
className: string;
|
|
13
|
+
payload: {
|
|
14
|
+
reason: string;
|
|
15
|
+
};
|
|
16
|
+
}) | (Error & {
|
|
17
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
18
|
+
className: string;
|
|
19
|
+
payload: undefined;
|
|
20
|
+
}) | (Error & {
|
|
21
|
+
name: "CreateTransactionErr::NotSupported";
|
|
22
|
+
className: string;
|
|
23
|
+
payload: string;
|
|
24
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
25
|
+
name: "CreateTransactionErr::Rejected";
|
|
26
|
+
className: string;
|
|
27
|
+
payload: undefined;
|
|
28
|
+
}) | (Error & {
|
|
29
|
+
name: "CreateTransactionErr::Unknown";
|
|
30
|
+
className: string;
|
|
31
|
+
payload: {
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
}) | (Error & {
|
|
35
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
36
|
+
className: string;
|
|
37
|
+
payload: undefined;
|
|
38
|
+
}) | (Error & {
|
|
39
|
+
name: "CreateTransactionErr::NotSupported";
|
|
40
|
+
className: string;
|
|
41
|
+
payload: string;
|
|
42
|
+
})>] & {
|
|
43
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
44
|
+
name: "CreateTransactionErr::Rejected";
|
|
45
|
+
className: string;
|
|
46
|
+
payload: undefined;
|
|
47
|
+
}) | (Error & {
|
|
48
|
+
name: "CreateTransactionErr::Unknown";
|
|
49
|
+
className: string;
|
|
50
|
+
payload: {
|
|
51
|
+
reason: string;
|
|
52
|
+
};
|
|
53
|
+
}) | (Error & {
|
|
54
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
55
|
+
className: string;
|
|
56
|
+
payload: undefined;
|
|
57
|
+
}) | (Error & {
|
|
58
|
+
name: "CreateTransactionErr::NotSupported";
|
|
59
|
+
className: string;
|
|
60
|
+
payload: string;
|
|
61
|
+
})>;
|
|
62
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
63
|
+
name: "CreateTransactionErr::Rejected";
|
|
64
|
+
className: string;
|
|
65
|
+
payload: undefined;
|
|
66
|
+
}) | (Error & {
|
|
67
|
+
name: "CreateTransactionErr::Unknown";
|
|
68
|
+
className: string;
|
|
69
|
+
payload: {
|
|
70
|
+
reason: string;
|
|
71
|
+
};
|
|
72
|
+
}) | (Error & {
|
|
73
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
74
|
+
className: string;
|
|
75
|
+
payload: undefined;
|
|
76
|
+
}) | (Error & {
|
|
77
|
+
name: "CreateTransactionErr::NotSupported";
|
|
78
|
+
className: string;
|
|
79
|
+
payload: string;
|
|
80
|
+
})>;
|
|
81
|
+
} & {
|
|
82
|
+
readonly FailedToDecode: import("../commonCodecs.js").ErrCodec<undefined, "CreateTransactionErr::FailedToDecode">;
|
|
83
|
+
readonly Rejected: import("../commonCodecs.js").ErrCodec<undefined, "CreateTransactionErr::Rejected">;
|
|
84
|
+
readonly NotSupported: import("../commonCodecs.js").ErrCodec<string, "CreateTransactionErr::NotSupported">;
|
|
85
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
86
|
+
reason: string;
|
|
87
|
+
}, "CreateTransactionErr::Unknown">;
|
|
88
|
+
};
|
|
89
|
+
export declare const TxPayloadExtensionV1: import("scale-ts").Codec<{
|
|
90
|
+
id: string;
|
|
91
|
+
extra: `0x${string}`;
|
|
92
|
+
additionalSigned: `0x${string}`;
|
|
93
|
+
}>;
|
|
94
|
+
export declare const TxPayloadContextV1: import("scale-ts").Codec<{
|
|
95
|
+
metadata: `0x${string}`;
|
|
96
|
+
tokenSymbol: string;
|
|
97
|
+
tokenDecimals: number;
|
|
98
|
+
bestBlockHeight: number;
|
|
99
|
+
}>;
|
|
100
|
+
export declare const TxPayloadV1: import("scale-ts").Codec<{
|
|
101
|
+
signer: string | null;
|
|
102
|
+
callData: `0x${string}`;
|
|
103
|
+
extensions: {
|
|
104
|
+
id: string;
|
|
105
|
+
extra: `0x${string}`;
|
|
106
|
+
additionalSigned: `0x${string}`;
|
|
107
|
+
}[];
|
|
108
|
+
txExtVersion: number;
|
|
109
|
+
context: {
|
|
110
|
+
metadata: `0x${string}`;
|
|
111
|
+
tokenSymbol: string;
|
|
112
|
+
tokenDecimals: number;
|
|
113
|
+
bestBlockHeight: number;
|
|
114
|
+
};
|
|
115
|
+
}>;
|
|
116
|
+
export declare const VersionedTxPayload: import("scale-ts").Codec<{
|
|
117
|
+
tag: "v1";
|
|
118
|
+
value: {
|
|
119
|
+
signer: string | null;
|
|
120
|
+
callData: `0x${string}`;
|
|
121
|
+
extensions: {
|
|
122
|
+
id: string;
|
|
123
|
+
extra: `0x${string}`;
|
|
124
|
+
additionalSigned: `0x${string}`;
|
|
125
|
+
}[];
|
|
126
|
+
txExtVersion: number;
|
|
127
|
+
context: {
|
|
128
|
+
metadata: `0x${string}`;
|
|
129
|
+
tokenSymbol: string;
|
|
130
|
+
tokenDecimals: number;
|
|
131
|
+
bestBlockHeight: number;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
}>;
|
|
135
|
+
export declare const VersionedPublicTxPayload: import("scale-ts").Codec<TxPayloadV1Public>;
|
|
136
|
+
export declare const CreateTransactionV1_request: import("scale-ts").Codec<[[string, number], TxPayloadV1Public]>;
|
|
137
|
+
export declare const CreateTransactionV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, (Error & {
|
|
138
|
+
name: "CreateTransactionErr::Rejected";
|
|
139
|
+
className: string;
|
|
140
|
+
payload: undefined;
|
|
141
|
+
}) | (Error & {
|
|
142
|
+
name: "CreateTransactionErr::Unknown";
|
|
143
|
+
className: string;
|
|
144
|
+
payload: {
|
|
145
|
+
reason: string;
|
|
146
|
+
};
|
|
147
|
+
}) | (Error & {
|
|
148
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
149
|
+
className: string;
|
|
150
|
+
payload: undefined;
|
|
151
|
+
}) | (Error & {
|
|
152
|
+
name: "CreateTransactionErr::NotSupported";
|
|
153
|
+
className: string;
|
|
154
|
+
payload: string;
|
|
155
|
+
})>>;
|
|
156
|
+
export declare const CreateTransactionWithNonProductAccountV1_request: import("scale-ts").Codec<TxPayloadV1Public>;
|
|
157
|
+
export declare const CreateTransactionWithNonProductAccountV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<Uint8Array<ArrayBufferLike>, (Error & {
|
|
158
|
+
name: "CreateTransactionErr::Rejected";
|
|
159
|
+
className: string;
|
|
160
|
+
payload: undefined;
|
|
161
|
+
}) | (Error & {
|
|
162
|
+
name: "CreateTransactionErr::Unknown";
|
|
163
|
+
className: string;
|
|
164
|
+
payload: {
|
|
165
|
+
reason: string;
|
|
166
|
+
};
|
|
167
|
+
}) | (Error & {
|
|
168
|
+
name: "CreateTransactionErr::FailedToDecode";
|
|
169
|
+
className: string;
|
|
170
|
+
payload: undefined;
|
|
171
|
+
}) | (Error & {
|
|
172
|
+
name: "CreateTransactionErr::NotSupported";
|
|
173
|
+
className: string;
|
|
174
|
+
payload: string;
|
|
175
|
+
})>>;
|
|
176
|
+
export interface TxPayloadV1Public {
|
|
177
|
+
/** Payload version. MUST be 1. */
|
|
178
|
+
version: 1;
|
|
179
|
+
/**
|
|
180
|
+
* Signer selection hint. Allows the implementer to identify which private-key / scheme to use.
|
|
181
|
+
* - Use a wallet-defined handle (e.g., address/SS58, account-name, etc). This identifier
|
|
182
|
+
* was previously made available to the consumer.
|
|
183
|
+
* - Set `null` to let the implementer pick the signer (or if the signer is implied).
|
|
184
|
+
*/
|
|
185
|
+
signer: string | null;
|
|
186
|
+
/**
|
|
187
|
+
* SCALE-encoded Call (module indicator + function indicator + params).
|
|
188
|
+
*/
|
|
189
|
+
callData: HexString;
|
|
190
|
+
/**
|
|
191
|
+
* Transaction extensions supplied by the caller (order irrelevant).
|
|
192
|
+
* The consumer SHOULD provide every extension that is relevant to them.
|
|
193
|
+
* The implementer MAY infer missing ones.
|
|
194
|
+
*/
|
|
195
|
+
extensions: Array<{
|
|
196
|
+
/** Identifier as defined in metadata (e.g., "CheckSpecVersion", "ChargeAssetTxPayment"). */
|
|
197
|
+
id: string;
|
|
198
|
+
/**
|
|
199
|
+
* Explicit "extra" to sign (goes into the extrinsic body).
|
|
200
|
+
* SCALE-encoded per the extension's "extra" type as defined in the metadata.
|
|
201
|
+
*/
|
|
202
|
+
extra: HexString;
|
|
203
|
+
/**
|
|
204
|
+
* "Implicit" data to sign (known by the chain, not included into the extrinsic body).
|
|
205
|
+
* SCALE-encoded per the extension's "additionalSigned" type as defined in the metadata.
|
|
206
|
+
*/
|
|
207
|
+
additionalSigned: HexString;
|
|
208
|
+
}>;
|
|
209
|
+
/**
|
|
210
|
+
* Transaction Extension Version.
|
|
211
|
+
* - For Extrinsic V4 MUST be 0.
|
|
212
|
+
* - For Extrinsic V5, set to any version supported by the runtime.
|
|
213
|
+
* The implementer:
|
|
214
|
+
* - MUST use this field to determine the required extensions for creating the extrinsic.
|
|
215
|
+
* - MAY use this field to infer missing extensions that the implementer could know how to handle.
|
|
216
|
+
*/
|
|
217
|
+
txExtVersion: number;
|
|
218
|
+
/**
|
|
219
|
+
* Context needed for decoding, display, and (optionally) inferring certain extensions.
|
|
220
|
+
*/
|
|
221
|
+
context: {
|
|
222
|
+
/**
|
|
223
|
+
* RuntimeMetadataPrefixed blob (SCALE), starting with ASCII "meta" magic (`0x6d657461`),
|
|
224
|
+
* then a metadata version (V14+). For V5+ versioned extensions, MUST provide V16+.
|
|
225
|
+
*/
|
|
226
|
+
metadata: HexString;
|
|
227
|
+
/**
|
|
228
|
+
* Native token display info (used by some implementers), also needed to compute
|
|
229
|
+
* the `CheckMetadataHash` value.
|
|
230
|
+
*/
|
|
231
|
+
tokenSymbol: string;
|
|
232
|
+
tokenDecimals: number;
|
|
233
|
+
/**
|
|
234
|
+
* Highest known block number to aid mortality UX.
|
|
235
|
+
*/
|
|
236
|
+
bestBlockHeight: number;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Bytes, Result, Struct, Tuple, Vector, _void, enhanceCodec, str, u32, u8 } from 'scale-ts';
|
|
2
|
+
import { Enum, ErrEnum, GenericErr, Hex, Nullable } from '../commonCodecs.js';
|
|
3
|
+
import { ProductAccountId } from './accounts.js';
|
|
4
|
+
/**
|
|
5
|
+
* createTransaction implementation
|
|
6
|
+
* @see https://github.com/polkadot-js/api/issues/6213
|
|
7
|
+
*/
|
|
8
|
+
export const CreateTransactionErr = ErrEnum('CreateTransactionErr', {
|
|
9
|
+
FailedToDecode: [_void, 'CreateTransaction: failed to decode'],
|
|
10
|
+
Rejected: [_void, 'CreateTransaction: rejected'],
|
|
11
|
+
// Unsupported payload version
|
|
12
|
+
// Failed to infer missing extensions, some extension is unsupported, etc.
|
|
13
|
+
NotSupported: [str, 'CreateTransaction: not supported'],
|
|
14
|
+
Unknown: [GenericErr, 'CreateTransaction: unknown error'],
|
|
15
|
+
});
|
|
16
|
+
export const TxPayloadExtensionV1 = Struct({
|
|
17
|
+
id: str,
|
|
18
|
+
extra: Hex(),
|
|
19
|
+
additionalSigned: Hex(),
|
|
20
|
+
});
|
|
21
|
+
export const TxPayloadContextV1 = Struct({
|
|
22
|
+
metadata: Hex(),
|
|
23
|
+
tokenSymbol: str,
|
|
24
|
+
tokenDecimals: u32,
|
|
25
|
+
bestBlockHeight: u32,
|
|
26
|
+
});
|
|
27
|
+
export const TxPayloadV1 = Struct({
|
|
28
|
+
signer: Nullable(str),
|
|
29
|
+
callData: Hex(),
|
|
30
|
+
extensions: Vector(TxPayloadExtensionV1),
|
|
31
|
+
txExtVersion: u8,
|
|
32
|
+
context: TxPayloadContextV1,
|
|
33
|
+
});
|
|
34
|
+
export const VersionedTxPayload = Enum({
|
|
35
|
+
v1: TxPayloadV1,
|
|
36
|
+
});
|
|
37
|
+
export const VersionedPublicTxPayload = enhanceCodec(VersionedTxPayload, v => {
|
|
38
|
+
if (v.version !== 1) {
|
|
39
|
+
throw new Error(`Unsupported transaction version: ${v}`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
tag: 'v1',
|
|
43
|
+
value: v,
|
|
44
|
+
};
|
|
45
|
+
}, v => {
|
|
46
|
+
if (v.tag !== 'v1') {
|
|
47
|
+
throw new Error(`Unsupported transaction version: ${v}`);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
version: 1,
|
|
51
|
+
...v.value,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
// transaction in the context of a host api account model
|
|
55
|
+
export const CreateTransactionV1_request = Tuple(ProductAccountId, VersionedPublicTxPayload);
|
|
56
|
+
export const CreateTransactionV1_response = Result(Bytes(), CreateTransactionErr);
|
|
57
|
+
export const CreateTransactionWithNonProductAccountV1_request = VersionedPublicTxPayload;
|
|
58
|
+
export const CreateTransactionWithNonProductAccountV1_response = Result(Bytes(), CreateTransactionErr);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const Feature: import("scale-ts").Codec<{
|
|
2
|
+
tag: "Chain";
|
|
3
|
+
value: `0x${string}`;
|
|
4
|
+
}>;
|
|
5
|
+
export declare const FeatureV1_request: import("scale-ts").Codec<{
|
|
6
|
+
tag: "Chain";
|
|
7
|
+
value: `0x${string}`;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const FeatureV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<boolean, Error & {
|
|
10
|
+
name: "GenericError";
|
|
11
|
+
className: string;
|
|
12
|
+
payload: {
|
|
13
|
+
reason: string;
|
|
14
|
+
};
|
|
15
|
+
}>>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Result, bool } from 'scale-ts';
|
|
2
|
+
import { Enum, GenericError, GenesisHash } from '../commonCodecs.js';
|
|
3
|
+
export const Feature = Enum({
|
|
4
|
+
Chain: GenesisHash,
|
|
5
|
+
});
|
|
6
|
+
export const FeatureV1_request = Feature;
|
|
7
|
+
export const FeatureV1_response = Result(bool, GenericError);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export declare const HandshakeErr: [import("scale-ts").Encoder<(Error & {
|
|
2
|
+
name: "HandshakeErr::Unknown";
|
|
3
|
+
className: string;
|
|
4
|
+
payload: {
|
|
5
|
+
reason: string;
|
|
6
|
+
};
|
|
7
|
+
}) | (Error & {
|
|
8
|
+
name: "HandshakeErr::Timeout";
|
|
9
|
+
className: string;
|
|
10
|
+
payload: undefined;
|
|
11
|
+
}) | (Error & {
|
|
12
|
+
name: "HandshakeErr::UnsupportedProtocolVersion";
|
|
13
|
+
className: string;
|
|
14
|
+
payload: undefined;
|
|
15
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
16
|
+
name: "HandshakeErr::Unknown";
|
|
17
|
+
className: string;
|
|
18
|
+
payload: {
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
}) | (Error & {
|
|
22
|
+
name: "HandshakeErr::Timeout";
|
|
23
|
+
className: string;
|
|
24
|
+
payload: undefined;
|
|
25
|
+
}) | (Error & {
|
|
26
|
+
name: "HandshakeErr::UnsupportedProtocolVersion";
|
|
27
|
+
className: string;
|
|
28
|
+
payload: undefined;
|
|
29
|
+
})>] & {
|
|
30
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
31
|
+
name: "HandshakeErr::Unknown";
|
|
32
|
+
className: string;
|
|
33
|
+
payload: {
|
|
34
|
+
reason: string;
|
|
35
|
+
};
|
|
36
|
+
}) | (Error & {
|
|
37
|
+
name: "HandshakeErr::Timeout";
|
|
38
|
+
className: string;
|
|
39
|
+
payload: undefined;
|
|
40
|
+
}) | (Error & {
|
|
41
|
+
name: "HandshakeErr::UnsupportedProtocolVersion";
|
|
42
|
+
className: string;
|
|
43
|
+
payload: undefined;
|
|
44
|
+
})>;
|
|
45
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
46
|
+
name: "HandshakeErr::Unknown";
|
|
47
|
+
className: string;
|
|
48
|
+
payload: {
|
|
49
|
+
reason: string;
|
|
50
|
+
};
|
|
51
|
+
}) | (Error & {
|
|
52
|
+
name: "HandshakeErr::Timeout";
|
|
53
|
+
className: string;
|
|
54
|
+
payload: undefined;
|
|
55
|
+
}) | (Error & {
|
|
56
|
+
name: "HandshakeErr::UnsupportedProtocolVersion";
|
|
57
|
+
className: string;
|
|
58
|
+
payload: undefined;
|
|
59
|
+
})>;
|
|
60
|
+
} & {
|
|
61
|
+
readonly Timeout: import("../commonCodecs.js").ErrCodec<undefined, "HandshakeErr::Timeout">;
|
|
62
|
+
readonly UnsupportedProtocolVersion: import("../commonCodecs.js").ErrCodec<undefined, "HandshakeErr::UnsupportedProtocolVersion">;
|
|
63
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
64
|
+
reason: string;
|
|
65
|
+
}, "HandshakeErr::Unknown">;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* HandshakeV1_request = 1 - JAM codec
|
|
69
|
+
*/
|
|
70
|
+
export declare const HandshakeV1_request: import("scale-ts").Codec<number>;
|
|
71
|
+
export declare const HandshakeV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, (Error & {
|
|
72
|
+
name: "HandshakeErr::Unknown";
|
|
73
|
+
className: string;
|
|
74
|
+
payload: {
|
|
75
|
+
reason: string;
|
|
76
|
+
};
|
|
77
|
+
}) | (Error & {
|
|
78
|
+
name: "HandshakeErr::Timeout";
|
|
79
|
+
className: string;
|
|
80
|
+
payload: undefined;
|
|
81
|
+
}) | (Error & {
|
|
82
|
+
name: "HandshakeErr::UnsupportedProtocolVersion";
|
|
83
|
+
className: string;
|
|
84
|
+
payload: undefined;
|
|
85
|
+
})>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Result, _void, u8 } from 'scale-ts';
|
|
2
|
+
import { ErrEnum, GenericErr } from '../commonCodecs.js';
|
|
3
|
+
export const HandshakeErr = ErrEnum('HandshakeErr', {
|
|
4
|
+
Timeout: [_void, 'Handshake: timeout'],
|
|
5
|
+
UnsupportedProtocolVersion: [_void, 'Handshake: unsupported protocol version'],
|
|
6
|
+
Unknown: [GenericErr, 'Handshake: unknown error'],
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* HandshakeV1_request = 1 - JAM codec
|
|
10
|
+
*/
|
|
11
|
+
export const HandshakeV1_request = u8;
|
|
12
|
+
export const HandshakeV1_response = Result(_void, HandshakeErr);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const JsonRpcMessageSendV1_request: import("scale-ts").Codec<[`0x${string}`, string]>;
|
|
2
|
+
export declare const JsonRpcMessageSendV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, Error & {
|
|
3
|
+
name: "GenericError";
|
|
4
|
+
className: string;
|
|
5
|
+
payload: {
|
|
6
|
+
reason: string;
|
|
7
|
+
};
|
|
8
|
+
}>>;
|
|
9
|
+
export declare const JsonRpcMessageSubscribeV1_start: import("scale-ts").Codec<`0x${string}`>;
|
|
10
|
+
export declare const JsonRpcMessageSubscribeV1_receive: import("scale-ts").Codec<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Result, Tuple, _void, str } from 'scale-ts';
|
|
2
|
+
import { GenericError, GenesisHash } from '../commonCodecs.js';
|
|
3
|
+
export const JsonRpcMessageSendV1_request = Tuple(GenesisHash, str);
|
|
4
|
+
export const JsonRpcMessageSendV1_response = Result(_void, GenericError);
|
|
5
|
+
export const JsonRpcMessageSubscribeV1_start = GenesisHash;
|
|
6
|
+
export const JsonRpcMessageSubscribeV1_receive = str;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const PermissionErr: [import("scale-ts").Encoder<(Error & {
|
|
2
|
+
name: "PermissionErr::Rejected";
|
|
3
|
+
className: string;
|
|
4
|
+
payload: undefined;
|
|
5
|
+
}) | (Error & {
|
|
6
|
+
name: "PermissionErr::Unknown";
|
|
7
|
+
className: string;
|
|
8
|
+
payload: {
|
|
9
|
+
reason: string;
|
|
10
|
+
};
|
|
11
|
+
})>, import("scale-ts").Decoder<(Error & {
|
|
12
|
+
name: "PermissionErr::Rejected";
|
|
13
|
+
className: string;
|
|
14
|
+
payload: undefined;
|
|
15
|
+
}) | (Error & {
|
|
16
|
+
name: "PermissionErr::Unknown";
|
|
17
|
+
className: string;
|
|
18
|
+
payload: {
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
})>] & {
|
|
22
|
+
enc: import("scale-ts").Encoder<(Error & {
|
|
23
|
+
name: "PermissionErr::Rejected";
|
|
24
|
+
className: string;
|
|
25
|
+
payload: undefined;
|
|
26
|
+
}) | (Error & {
|
|
27
|
+
name: "PermissionErr::Unknown";
|
|
28
|
+
className: string;
|
|
29
|
+
payload: {
|
|
30
|
+
reason: string;
|
|
31
|
+
};
|
|
32
|
+
})>;
|
|
33
|
+
dec: import("scale-ts").Decoder<(Error & {
|
|
34
|
+
name: "PermissionErr::Rejected";
|
|
35
|
+
className: string;
|
|
36
|
+
payload: undefined;
|
|
37
|
+
}) | (Error & {
|
|
38
|
+
name: "PermissionErr::Unknown";
|
|
39
|
+
className: string;
|
|
40
|
+
payload: {
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
})>;
|
|
44
|
+
} & {
|
|
45
|
+
readonly Rejected: import("../commonCodecs.js").ErrCodec<undefined, "PermissionErr::Rejected">;
|
|
46
|
+
readonly Unknown: import("../commonCodecs.js").ErrCodec<{
|
|
47
|
+
reason: string;
|
|
48
|
+
}, "PermissionErr::Unknown">;
|
|
49
|
+
};
|
|
50
|
+
export declare const ChainConnectPermission: import("scale-ts").Codec<{
|
|
51
|
+
genesisHash: `0x${string}`;
|
|
52
|
+
name: string;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const Permission: import("scale-ts").Codec<{
|
|
55
|
+
tag: "ChainSubmit";
|
|
56
|
+
value: `0x${string}`;
|
|
57
|
+
} | {
|
|
58
|
+
tag: "ChainConnect";
|
|
59
|
+
value: {
|
|
60
|
+
genesisHash: `0x${string}`;
|
|
61
|
+
name: string;
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
tag: "NetworkRequest";
|
|
65
|
+
value: string[];
|
|
66
|
+
}>;
|
|
67
|
+
export declare const PermissionRequestV1_request: import("scale-ts").Codec<{
|
|
68
|
+
tag: "ChainSubmit";
|
|
69
|
+
value: `0x${string}`;
|
|
70
|
+
} | {
|
|
71
|
+
tag: "ChainConnect";
|
|
72
|
+
value: {
|
|
73
|
+
genesisHash: `0x${string}`;
|
|
74
|
+
name: string;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
tag: "NetworkRequest";
|
|
78
|
+
value: string[];
|
|
79
|
+
}>;
|
|
80
|
+
export declare const PermissionRequestV1_response: import("scale-ts").Codec<import("scale-ts").ResultPayload<undefined, (Error & {
|
|
81
|
+
name: "PermissionErr::Rejected";
|
|
82
|
+
className: string;
|
|
83
|
+
payload: undefined;
|
|
84
|
+
}) | (Error & {
|
|
85
|
+
name: "PermissionErr::Unknown";
|
|
86
|
+
className: string;
|
|
87
|
+
payload: {
|
|
88
|
+
reason: string;
|
|
89
|
+
};
|
|
90
|
+
})>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result, Struct, Vector, _void, str } from 'scale-ts';
|
|
2
|
+
import { Enum, ErrEnum, GenericErr, GenesisHash } from '../commonCodecs.js';
|
|
3
|
+
export const PermissionErr = ErrEnum('PermissionErr', {
|
|
4
|
+
Rejected: [_void, 'Permission: rejected'],
|
|
5
|
+
Unknown: [GenericErr, 'Permission: unknown error'],
|
|
6
|
+
});
|
|
7
|
+
export const ChainConnectPermission = Struct({
|
|
8
|
+
genesisHash: GenesisHash,
|
|
9
|
+
name: str,
|
|
10
|
+
});
|
|
11
|
+
export const Permission = Enum({
|
|
12
|
+
ChainSubmit: GenesisHash,
|
|
13
|
+
ChainConnect: ChainConnectPermission,
|
|
14
|
+
NetworkRequest: Vector(str),
|
|
15
|
+
// TBD
|
|
16
|
+
});
|
|
17
|
+
export const PermissionRequestV1_request = Permission;
|
|
18
|
+
export const PermissionRequestV1_response = Result(_void, PermissionErr);
|