@parity/truapi 0.1.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/LICENSE +21 -0
- package/README.md +102 -0
- package/dist/client.d.ts +20 -0
- package/dist/client.js +320 -0
- package/dist/generated/client.d.ts +243 -0
- package/dist/generated/client.js +1081 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/index.js +2 -0
- package/dist/generated/types.d.ts +2666 -0
- package/dist/generated/types.js +877 -0
- package/dist/generated/wire-table.d.ts +246 -0
- package/dist/generated/wire-table.js +249 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/playground/codegen/services.d.ts +2 -0
- package/dist/playground/codegen/services.js +456 -0
- package/dist/playground/services-types.d.ts +12 -0
- package/dist/playground/services-types.js +1 -0
- package/dist/scale.d.ts +77 -0
- package/dist/scale.js +121 -0
- package/dist/transport.d.ts +237 -0
- package/dist/transport.js +238 -0
- package/package.json +57 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { type Result } from "neverthrow";
|
|
2
|
+
import type { HexString } from "../scale.js";
|
|
3
|
+
import { SubscriptionError } from "../transport.js";
|
|
4
|
+
import type { ObservableLike, Observer, Subscription, TrUApiTransport } from "../transport.js";
|
|
5
|
+
import * as T from "./types.js";
|
|
6
|
+
export { Result, SubscriptionError };
|
|
7
|
+
export type { ObservableLike, Observer, Subscription, TrUApiTransport };
|
|
8
|
+
export declare const TRUAPI_VERSION: 1;
|
|
9
|
+
export declare const TRUAPI_CODEC_VERSION: 1;
|
|
10
|
+
/** Account lookup, aliasing, and proof generation. */
|
|
11
|
+
export declare class AccountClient {
|
|
12
|
+
private readonly transport;
|
|
13
|
+
constructor(transport: TrUApiTransport);
|
|
14
|
+
/** Subscribe to account connection status changes. */
|
|
15
|
+
connectionStatusSubscribe(): ObservableLike<T.HostAccountConnectionStatusSubscribeItem>;
|
|
16
|
+
/** Retrieve a product-scoped account. */
|
|
17
|
+
getAccount(request: T.HostAccountGetRequest): Promise<Result<T.HostAccountGetResponse, T.HostAccountGetError>>;
|
|
18
|
+
/** Retrieve a contextual alias for a product account. */
|
|
19
|
+
getAccountAlias(request: T.HostAccountGetAliasRequest): Promise<Result<T.HostAccountGetAliasResponse, T.HostAccountGetError>>;
|
|
20
|
+
/** Generate a ring VRF proof for a product account. */
|
|
21
|
+
createAccountProof(request: T.HostAccountCreateProofRequest): Promise<Result<T.HostAccountCreateProofResponse, T.HostAccountCreateProofError>>;
|
|
22
|
+
/** List non-product accounts the user owns. */
|
|
23
|
+
getLegacyAccounts(): Promise<Result<T.HostGetLegacyAccountsResponse, T.HostAccountGetError>>;
|
|
24
|
+
/** Fetch the user's primary identity. */
|
|
25
|
+
getUserId(): Promise<Result<T.HostGetUserIdResponse, T.HostGetUserIdError>>;
|
|
26
|
+
/**
|
|
27
|
+
* Request the host to present the login flow to the user.
|
|
28
|
+
*
|
|
29
|
+
* Products should call this in response to a user action (e.g. tapping a
|
|
30
|
+
* "Sign in" button), not automatically on load.
|
|
31
|
+
*/
|
|
32
|
+
requestLogin(request: T.HostRequestLoginRequest): Promise<Result<T.HostRequestLoginResponse, T.HostRequestLoginError>>;
|
|
33
|
+
}
|
|
34
|
+
/** Chain interaction methods. */
|
|
35
|
+
export declare class ChainClient {
|
|
36
|
+
private readonly transport;
|
|
37
|
+
constructor(transport: TrUApiTransport);
|
|
38
|
+
/** Follow the chain head and receive block events. */
|
|
39
|
+
followHeadSubscribe({ request, }: {
|
|
40
|
+
request: T.RemoteChainHeadFollowRequest;
|
|
41
|
+
}): ObservableLike<T.RemoteChainHeadFollowItem>;
|
|
42
|
+
/** Fetch a block header. */
|
|
43
|
+
getHeadHeader(request: T.RemoteChainHeadHeaderRequest): Promise<Result<T.RemoteChainHeadHeaderResponse, T.GenericError>>;
|
|
44
|
+
/** Fetch a block body. */
|
|
45
|
+
getHeadBody(request: T.RemoteChainHeadBodyRequest): Promise<Result<T.RemoteChainHeadBodyResponse, T.GenericError>>;
|
|
46
|
+
/** Query runtime storage at a specific block. */
|
|
47
|
+
getHeadStorage(request: T.RemoteChainHeadStorageRequest): Promise<Result<T.RemoteChainHeadStorageResponse, T.GenericError>>;
|
|
48
|
+
/** Invoke a runtime call at a specific block. */
|
|
49
|
+
callHead(request: T.RemoteChainHeadCallRequest): Promise<Result<T.RemoteChainHeadCallResponse, T.GenericError>>;
|
|
50
|
+
/** Release pinned blocks. */
|
|
51
|
+
unpinHead(request: T.RemoteChainHeadUnpinRequest): Promise<Result<undefined, T.GenericError>>;
|
|
52
|
+
/** Continue a paused chain-head operation. */
|
|
53
|
+
continueHead(request: T.RemoteChainHeadContinueRequest): Promise<Result<undefined, T.GenericError>>;
|
|
54
|
+
/** Stop a chain-head operation. */
|
|
55
|
+
stopHeadOperation(request: T.RemoteChainHeadStopOperationRequest): Promise<Result<undefined, T.GenericError>>;
|
|
56
|
+
/** Fetch the canonical genesis hash for a chain. */
|
|
57
|
+
getSpecGenesisHash(request: T.RemoteChainSpecGenesisHashRequest): Promise<Result<T.RemoteChainSpecGenesisHashResponse, T.GenericError>>;
|
|
58
|
+
/** Fetch the display name of a chain. */
|
|
59
|
+
getSpecChainName(request: T.RemoteChainSpecChainNameRequest): Promise<Result<T.RemoteChainSpecChainNameResponse, T.GenericError>>;
|
|
60
|
+
/** Fetch the JSON-encoded properties of a chain. */
|
|
61
|
+
getSpecProperties(request: T.RemoteChainSpecPropertiesRequest): Promise<Result<T.RemoteChainSpecPropertiesResponse, T.GenericError>>;
|
|
62
|
+
/** Broadcast a signed transaction. */
|
|
63
|
+
broadcastTransaction(request: T.RemoteChainTransactionBroadcastRequest): Promise<Result<T.RemoteChainTransactionBroadcastResponse, T.GenericError>>;
|
|
64
|
+
/** Stop a transaction broadcast. */
|
|
65
|
+
stopTransaction(request: T.RemoteChainTransactionStopRequest): Promise<Result<undefined, T.GenericError>>;
|
|
66
|
+
}
|
|
67
|
+
/** Chat room, bot, and message APIs. */
|
|
68
|
+
export declare class ChatClient {
|
|
69
|
+
private readonly transport;
|
|
70
|
+
constructor(transport: TrUApiTransport);
|
|
71
|
+
/** Create a chat room. */
|
|
72
|
+
createRoom(request: T.HostChatCreateRoomRequest): Promise<Result<T.HostChatCreateRoomResponse, T.HostChatCreateRoomError>>;
|
|
73
|
+
/** Register a chat bot. */
|
|
74
|
+
registerBot(request: T.HostChatRegisterBotRequest): Promise<Result<T.HostChatRegisterBotResponse, T.HostChatRegisterBotError>>;
|
|
75
|
+
/** Subscribe to the list of chat rooms. */
|
|
76
|
+
listSubscribe(): ObservableLike<T.HostChatListSubscribeItem>;
|
|
77
|
+
/** Post a message to a chat room. */
|
|
78
|
+
postMessage(request: T.HostChatPostMessageRequest): Promise<Result<T.HostChatPostMessageResponse, T.HostChatPostMessageError>>;
|
|
79
|
+
/** Subscribe to received chat actions. */
|
|
80
|
+
actionSubscribe(): ObservableLike<T.HostChatActionSubscribeItem>;
|
|
81
|
+
/**
|
|
82
|
+
* Subscribe to custom message render requests from the host. Each
|
|
83
|
+
* emitted item is a [`CustomRendererNode`](crate::v01::CustomRendererNode)
|
|
84
|
+
* tree describing the rendered UI.
|
|
85
|
+
*/
|
|
86
|
+
customMessageRenderSubscribe({ request, }: {
|
|
87
|
+
request: T.ProductChatCustomMessageRenderSubscribeRequest;
|
|
88
|
+
}): ObservableLike<T.CustomRendererNode>;
|
|
89
|
+
}
|
|
90
|
+
/** Deterministic entropy derivation. */
|
|
91
|
+
export declare class EntropyClient {
|
|
92
|
+
private readonly transport;
|
|
93
|
+
constructor(transport: TrUApiTransport);
|
|
94
|
+
/** Derive deterministic entropy. */
|
|
95
|
+
derive(request: T.HostDeriveEntropyRequest): Promise<Result<T.HostDeriveEntropyResponse, T.HostDeriveEntropyError>>;
|
|
96
|
+
}
|
|
97
|
+
/** JSON-RPC transport methods. */
|
|
98
|
+
export declare class JsonRpcClient {
|
|
99
|
+
private readonly transport;
|
|
100
|
+
constructor(transport: TrUApiTransport);
|
|
101
|
+
/** Send a JSON-RPC message. */
|
|
102
|
+
sendMessage(request: T.HostJsonrpcMessageSendRequest): Promise<Result<undefined, T.GenericError>>;
|
|
103
|
+
/** Subscribe to inbound JSON-RPC messages. */
|
|
104
|
+
subscribeMessages({ request, }: {
|
|
105
|
+
request: T.HostJsonrpcMessageSubscribeRequest;
|
|
106
|
+
}): ObservableLike<T.HostJsonrpcMessageSubscribeItem>;
|
|
107
|
+
}
|
|
108
|
+
/** Local key/value storage scoped to the calling product. */
|
|
109
|
+
export declare class LocalStorageClient {
|
|
110
|
+
private readonly transport;
|
|
111
|
+
constructor(transport: TrUApiTransport);
|
|
112
|
+
/** Read a value by key. */
|
|
113
|
+
read(request: T.HostLocalStorageReadRequest): Promise<Result<T.HostLocalStorageReadResponse, T.HostLocalStorageReadError>>;
|
|
114
|
+
/** Write a value to a key. */
|
|
115
|
+
write(request: T.HostLocalStorageWriteRequest): Promise<Result<undefined, T.HostLocalStorageReadError>>;
|
|
116
|
+
/** Clear a value by key. */
|
|
117
|
+
clear(request: T.HostLocalStorageClearRequest): Promise<Result<undefined, T.HostLocalStorageReadError>>;
|
|
118
|
+
}
|
|
119
|
+
/** Payment request and balance/status subscription methods. */
|
|
120
|
+
export declare class PaymentClient {
|
|
121
|
+
private readonly transport;
|
|
122
|
+
constructor(transport: TrUApiTransport);
|
|
123
|
+
/** Subscribe to payment balance updates. */
|
|
124
|
+
balanceSubscribe(): ObservableLike<T.HostPaymentBalanceSubscribeItem, T.HostPaymentBalanceSubscribeError>;
|
|
125
|
+
/** Request a payment from the user. */
|
|
126
|
+
request(request: T.HostPaymentRequestRequest): Promise<Result<T.HostPaymentRequestResponse, T.HostPaymentRequestError>>;
|
|
127
|
+
/** Subscribe to payment lifecycle updates for a specific payment. */
|
|
128
|
+
statusSubscribe({ request, }: {
|
|
129
|
+
request: T.HostPaymentStatusSubscribeRequest;
|
|
130
|
+
}): ObservableLike<T.HostPaymentStatusSubscribeItem, T.HostPaymentStatusSubscribeError>;
|
|
131
|
+
/** Top up the user's payment balance. */
|
|
132
|
+
topUp(request: T.HostPaymentTopUpRequest): Promise<Result<undefined, T.HostPaymentTopUpError>>;
|
|
133
|
+
}
|
|
134
|
+
/** Permission request methods. */
|
|
135
|
+
export declare class PermissionsClient {
|
|
136
|
+
private readonly transport;
|
|
137
|
+
constructor(transport: TrUApiTransport);
|
|
138
|
+
/** Request a device-capability permission from the user. */
|
|
139
|
+
requestDevicePermission(request: T.HostDevicePermissionRequest): Promise<Result<T.HostDevicePermissionResponse, T.GenericError>>;
|
|
140
|
+
/** Request one or more remote-operation permissions. */
|
|
141
|
+
requestRemotePermission(request: T.RemotePermissionRequest): Promise<Result<T.RemotePermissionResponse, T.GenericError>>;
|
|
142
|
+
}
|
|
143
|
+
/** Preimage lookup and submission methods. */
|
|
144
|
+
export declare class PreimageClient {
|
|
145
|
+
private readonly transport;
|
|
146
|
+
constructor(transport: TrUApiTransport);
|
|
147
|
+
/** Subscribe to preimage lookups for a given key. */
|
|
148
|
+
lookupSubscribe({ request, }: {
|
|
149
|
+
request: T.RemotePreimageLookupSubscribeRequest;
|
|
150
|
+
}): ObservableLike<T.RemotePreimageLookupSubscribeItem>;
|
|
151
|
+
/** Submit a preimage. Returns the preimage key (hash) on success. */
|
|
152
|
+
submit(request: HexString): Promise<Result<HexString, T.PreimageSubmitError>>;
|
|
153
|
+
}
|
|
154
|
+
/** Resource pre-allocation (allowance management). */
|
|
155
|
+
export declare class ResourceAllocationClient {
|
|
156
|
+
private readonly transport;
|
|
157
|
+
constructor(transport: TrUApiTransport);
|
|
158
|
+
/** Request the host to pre-allocate one or more resources. */
|
|
159
|
+
request(request: T.HostRequestResourceAllocationRequest): Promise<Result<T.HostRequestResourceAllocationResponse, T.ResourceAllocationError>>;
|
|
160
|
+
}
|
|
161
|
+
/** Signing operations. */
|
|
162
|
+
export declare class SigningClient {
|
|
163
|
+
private readonly transport;
|
|
164
|
+
constructor(transport: TrUApiTransport);
|
|
165
|
+
/** Construct a signed transaction for a product account. */
|
|
166
|
+
createTransaction(request: T.HostCreateTransactionRequest): Promise<Result<T.HostCreateTransactionResponse, T.HostCreateTransactionError>>;
|
|
167
|
+
/** Construct a signed transaction for a non-product account. */
|
|
168
|
+
createTransactionWithLegacyAccount(request: T.HostCreateTransactionWithLegacyAccountRequest): Promise<Result<T.HostCreateTransactionWithLegacyAccountResponse, T.HostCreateTransactionError>>;
|
|
169
|
+
/** Sign raw bytes with a non-product account. */
|
|
170
|
+
signRawWithLegacyAccount(request: T.HostSignRawWithLegacyAccountRequest): Promise<Result<T.HostSignPayloadResponse, T.HostSignPayloadError>>;
|
|
171
|
+
/** Sign an extrinsic payload with a non-product account. */
|
|
172
|
+
signPayloadWithLegacyAccount(request: T.HostSignPayloadWithLegacyAccountRequest): Promise<Result<T.HostSignPayloadResponse, T.HostSignPayloadError>>;
|
|
173
|
+
/** Sign raw bytes or a message. */
|
|
174
|
+
signRaw(request: T.HostSignRawRequest): Promise<Result<T.HostSignPayloadResponse, T.HostSignPayloadError>>;
|
|
175
|
+
/** Sign an extrinsic payload. */
|
|
176
|
+
signPayload(request: T.HostSignPayloadRequest): Promise<Result<T.HostSignPayloadResponse, T.HostSignPayloadError>>;
|
|
177
|
+
}
|
|
178
|
+
/** Statement store methods. */
|
|
179
|
+
export declare class StatementStoreClient {
|
|
180
|
+
private readonly transport;
|
|
181
|
+
constructor(transport: TrUApiTransport);
|
|
182
|
+
/** Subscribe to statements matching a topic filter. */
|
|
183
|
+
subscribe({ request, }: {
|
|
184
|
+
request: T.RemoteStatementStoreSubscribeRequest;
|
|
185
|
+
}): ObservableLike<T.RemoteStatementStoreSubscribeItem>;
|
|
186
|
+
/** Create a proof for a statement. */
|
|
187
|
+
createProof(request: T.RemoteStatementStoreCreateProofRequest): Promise<Result<T.RemoteStatementStoreCreateProofResponse, T.RemoteStatementStoreCreateProofError>>;
|
|
188
|
+
/**
|
|
189
|
+
* Create a proof for a statement using a pre-allocated allowance account,
|
|
190
|
+
* bypassing the per-call signing prompt.
|
|
191
|
+
*/
|
|
192
|
+
createProofAuthorized(request: T.Statement): Promise<Result<T.RemoteStatementStoreCreateProofResponse, T.RemoteStatementStoreCreateProofError>>;
|
|
193
|
+
/**
|
|
194
|
+
* Submit a signed statement to the network. The request body is the
|
|
195
|
+
* [`SignedStatement`](crate::v01::SignedStatement) directly (no wrapping
|
|
196
|
+
* struct), matching upstream `triangle-js-sdks`.
|
|
197
|
+
*/
|
|
198
|
+
submit(request: T.SignedStatement): Promise<Result<undefined, T.GenericError>>;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* General-purpose TrUAPI methods for handshake, feature detection,
|
|
202
|
+
* navigation, and notifications.
|
|
203
|
+
*/
|
|
204
|
+
export declare class SystemClient {
|
|
205
|
+
private readonly transport;
|
|
206
|
+
constructor(transport: TrUApiTransport);
|
|
207
|
+
/** Negotiate the wire codec version with the product. */
|
|
208
|
+
handshake(): Promise<Result<undefined, T.HostHandshakeError>>;
|
|
209
|
+
/** Query whether the host supports a specific feature. */
|
|
210
|
+
featureSupported(request: T.HostFeatureSupportedRequest): Promise<Result<T.HostFeatureSupportedResponse, T.GenericError>>;
|
|
211
|
+
/** Send a push notification to the user. */
|
|
212
|
+
pushNotification(request: T.HostPushNotificationRequest): Promise<Result<undefined, T.GenericError>>;
|
|
213
|
+
/** Request the host to open a URL. */
|
|
214
|
+
navigateTo(request: T.HostNavigateToRequest): Promise<Result<undefined, T.HostNavigateToError>>;
|
|
215
|
+
}
|
|
216
|
+
/** Host theme subscription. */
|
|
217
|
+
export declare class ThemeClient {
|
|
218
|
+
private readonly transport;
|
|
219
|
+
constructor(transport: TrUApiTransport);
|
|
220
|
+
/** Subscribe to host theme changes. */
|
|
221
|
+
subscribe(): ObservableLike<T.HostThemeSubscribeItem>;
|
|
222
|
+
}
|
|
223
|
+
export interface TrUApiClient {
|
|
224
|
+
readonly account: AccountClient;
|
|
225
|
+
readonly chain: ChainClient;
|
|
226
|
+
readonly chat: ChatClient;
|
|
227
|
+
readonly entropy: EntropyClient;
|
|
228
|
+
readonly jsonRpc: JsonRpcClient;
|
|
229
|
+
readonly localStorage: LocalStorageClient;
|
|
230
|
+
readonly payment: PaymentClient;
|
|
231
|
+
readonly permissions: PermissionsClient;
|
|
232
|
+
readonly preimage: PreimageClient;
|
|
233
|
+
readonly resourceAllocation: ResourceAllocationClient;
|
|
234
|
+
readonly signing: SigningClient;
|
|
235
|
+
readonly statementStore: StatementStoreClient;
|
|
236
|
+
readonly system: SystemClient;
|
|
237
|
+
readonly theme: ThemeClient;
|
|
238
|
+
}
|
|
239
|
+
export type Client = TrUApiClient;
|
|
240
|
+
export type GeneratedClientTransport = Omit<TrUApiTransport, "truapiVersion" | "codecVersion"> & Partial<Pick<TrUApiTransport, "truapiVersion" | "codecVersion">>;
|
|
241
|
+
/** Creates the generated client facade by binding each service namespace to the
|
|
242
|
+
* shared transport instance. */
|
|
243
|
+
export declare function createClient(transport: GeneratedClientTransport): TrUApiClient;
|