@parity/truapi 0.1.0 → 0.3.1
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/client.js +5 -2
- package/dist/explorer/codegen/types.d.ts +2 -0
- package/dist/explorer/codegen/types.js +3610 -0
- package/dist/explorer/codegen/versions/0.2.0/services.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.2.0/services.js +644 -0
- package/dist/explorer/codegen/versions/0.2.0/types.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.2.0/types.js +3960 -0
- package/dist/explorer/codegen/versions/0.3.0/services.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.3.0/services.js +644 -0
- package/dist/explorer/codegen/versions/0.3.0/types.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.3.0/types.js +3610 -0
- package/dist/explorer/codegen/versions/0.3.1/services.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.3.1/services.js +644 -0
- package/dist/explorer/codegen/versions/0.3.1/types.d.ts +2 -0
- package/dist/explorer/codegen/versions/0.3.1/types.js +3610 -0
- package/dist/explorer/data-types.d.ts +49 -0
- package/dist/explorer/data-types.js +1 -0
- package/dist/explorer/versions.d.ts +9 -0
- package/dist/explorer/versions.js +21 -0
- package/dist/generated/client.d.ts +86 -65
- package/dist/generated/client.js +166 -194
- package/dist/generated/types.d.ts +442 -232
- package/dist/generated/types.js +110 -94
- package/dist/generated/wire-table.d.ts +5 -11
- package/dist/generated/wire-table.js +5 -11
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/playground/codegen/services.js +327 -84
- package/dist/playground/codegen/truapi-dts.d.ts +1 -0
- package/dist/playground/codegen/truapi-dts.js +4310 -0
- package/dist/playground/services-types.d.ts +11 -2
- package/dist/scale.d.ts +8 -1
- package/dist/scale.js +19 -1
- package/dist/transport.d.ts +33 -6
- package/dist/transport.js +150 -71
- package/dist/well-known-chains.d.ts +13 -0
- package/dist/well-known-chains.js +7 -0
- package/package.json +28 -6
package/dist/generated/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Auto-generated by truapi-codegen. Do not edit.
|
|
2
|
-
import {
|
|
2
|
+
import { ResultAsync } from "neverthrow";
|
|
3
3
|
import * as S from "../scale.js";
|
|
4
4
|
import { SubscriptionError } from "../transport.js";
|
|
5
5
|
import * as T from "./types.js";
|
|
6
6
|
import * as W from "./wire-table.js";
|
|
7
|
-
export { SubscriptionError };
|
|
7
|
+
export { ResultAsync, SubscriptionError };
|
|
8
8
|
export const TRUAPI_VERSION = 1;
|
|
9
9
|
export const TRUAPI_CODEC_VERSION = 1;
|
|
10
10
|
function toSubscriptionError(error) {
|
|
@@ -13,8 +13,13 @@ function toSubscriptionError(error) {
|
|
|
13
13
|
const cause = error instanceof Error ? error : new Error(String(error));
|
|
14
14
|
return new SubscriptionError(cause.message, { cause });
|
|
15
15
|
}
|
|
16
|
+
// ES Observable interop key (rxjs reads Symbol.observable, falling
|
|
17
|
+
// back to "@@observable" on platforms without the well-known symbol).
|
|
18
|
+
const OBSERVABLE_INTEROP = (typeof Symbol === "function" &&
|
|
19
|
+
Symbol.observable) ||
|
|
20
|
+
"@@observable";
|
|
16
21
|
function createObservable({ transport, ids, payload, decodeItem, decodeInterrupt, }) {
|
|
17
|
-
|
|
22
|
+
const observable = {
|
|
18
23
|
subscribe(observer = {}) {
|
|
19
24
|
let closed = false;
|
|
20
25
|
let raw;
|
|
@@ -75,7 +80,11 @@ function createObservable({ transport, ids, payload, decodeItem, decodeInterrupt
|
|
|
75
80
|
},
|
|
76
81
|
};
|
|
77
82
|
},
|
|
83
|
+
[OBSERVABLE_INTEROP]() {
|
|
84
|
+
return observable;
|
|
85
|
+
},
|
|
78
86
|
};
|
|
87
|
+
return observable;
|
|
79
88
|
}
|
|
80
89
|
/** Account lookup, aliasing, and proof generation. */
|
|
81
90
|
export class AccountClient {
|
|
@@ -96,8 +105,8 @@ export class AccountClient {
|
|
|
96
105
|
});
|
|
97
106
|
}
|
|
98
107
|
/** Retrieve a product-scoped account. */
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
getAccount(request) {
|
|
109
|
+
return this.transport.request({
|
|
101
110
|
ids: W.ACCOUNT_GET_ACCOUNT,
|
|
102
111
|
payload: T.VersionedHostAccountGetRequest.enc({
|
|
103
112
|
tag: "V1",
|
|
@@ -110,11 +119,10 @@ export class AccountClient {
|
|
|
110
119
|
],
|
|
111
120
|
}).dec(payload).value,
|
|
112
121
|
});
|
|
113
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
114
122
|
}
|
|
115
123
|
/** Retrieve a contextual alias for a product account. */
|
|
116
|
-
|
|
117
|
-
|
|
124
|
+
getAccountAlias(request) {
|
|
125
|
+
return this.transport.request({
|
|
118
126
|
ids: W.ACCOUNT_GET_ACCOUNT_ALIAS,
|
|
119
127
|
payload: T.VersionedHostAccountGetAliasRequest.enc({
|
|
120
128
|
tag: "V1",
|
|
@@ -127,11 +135,10 @@ export class AccountClient {
|
|
|
127
135
|
],
|
|
128
136
|
}).dec(payload).value,
|
|
129
137
|
});
|
|
130
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
131
138
|
}
|
|
132
139
|
/** Generate a ring VRF proof for a product account. */
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
createAccountProof(request) {
|
|
141
|
+
return this.transport.request({
|
|
135
142
|
ids: W.ACCOUNT_CREATE_ACCOUNT_PROOF,
|
|
136
143
|
payload: T.VersionedHostAccountCreateProofRequest.enc({
|
|
137
144
|
tag: "V1",
|
|
@@ -144,11 +151,10 @@ export class AccountClient {
|
|
|
144
151
|
],
|
|
145
152
|
}).dec(payload).value,
|
|
146
153
|
});
|
|
147
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
148
154
|
}
|
|
149
155
|
/** List non-product accounts the user owns. */
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
getLegacyAccounts() {
|
|
157
|
+
return this.transport.request({
|
|
152
158
|
ids: W.ACCOUNT_GET_LEGACY_ACCOUNTS,
|
|
153
159
|
payload: T.VersionedHostGetLegacyAccountsRequest.enc({
|
|
154
160
|
tag: "V1",
|
|
@@ -161,11 +167,10 @@ export class AccountClient {
|
|
|
161
167
|
],
|
|
162
168
|
}).dec(payload).value,
|
|
163
169
|
});
|
|
164
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
165
170
|
}
|
|
166
171
|
/** Fetch the user's primary identity. */
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
getUserId() {
|
|
173
|
+
return this.transport.request({
|
|
169
174
|
ids: W.ACCOUNT_GET_USER_ID,
|
|
170
175
|
payload: T.VersionedHostGetUserIdRequest.enc({
|
|
171
176
|
tag: "V1",
|
|
@@ -178,7 +183,6 @@ export class AccountClient {
|
|
|
178
183
|
],
|
|
179
184
|
}).dec(payload).value,
|
|
180
185
|
});
|
|
181
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
182
186
|
}
|
|
183
187
|
/**
|
|
184
188
|
* Request the host to present the login flow to the user.
|
|
@@ -186,8 +190,8 @@ export class AccountClient {
|
|
|
186
190
|
* Products should call this in response to a user action (e.g. tapping a
|
|
187
191
|
* "Sign in" button), not automatically on load.
|
|
188
192
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
requestLogin(request) {
|
|
194
|
+
return this.transport.request({
|
|
191
195
|
ids: W.ACCOUNT_REQUEST_LOGIN,
|
|
192
196
|
payload: T.VersionedHostRequestLoginRequest.enc({
|
|
193
197
|
tag: "V1",
|
|
@@ -200,7 +204,6 @@ export class AccountClient {
|
|
|
200
204
|
],
|
|
201
205
|
}).dec(payload).value,
|
|
202
206
|
});
|
|
203
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
/** Chain interaction methods. */
|
|
@@ -222,8 +225,8 @@ export class ChainClient {
|
|
|
222
225
|
});
|
|
223
226
|
}
|
|
224
227
|
/** Fetch a block header. */
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
getHeadHeader(request) {
|
|
229
|
+
return this.transport.request({
|
|
227
230
|
ids: W.CHAIN_GET_HEAD_HEADER,
|
|
228
231
|
payload: T.VersionedRemoteChainHeadHeaderRequest.enc({
|
|
229
232
|
tag: "V1",
|
|
@@ -236,11 +239,10 @@ export class ChainClient {
|
|
|
236
239
|
],
|
|
237
240
|
}).dec(payload).value,
|
|
238
241
|
});
|
|
239
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
240
242
|
}
|
|
241
243
|
/** Fetch a block body. */
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
getHeadBody(request) {
|
|
245
|
+
return this.transport.request({
|
|
244
246
|
ids: W.CHAIN_GET_HEAD_BODY,
|
|
245
247
|
payload: T.VersionedRemoteChainHeadBodyRequest.enc({
|
|
246
248
|
tag: "V1",
|
|
@@ -253,11 +255,10 @@ export class ChainClient {
|
|
|
253
255
|
],
|
|
254
256
|
}).dec(payload).value,
|
|
255
257
|
});
|
|
256
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
257
258
|
}
|
|
258
259
|
/** Query runtime storage at a specific block. */
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
getHeadStorage(request) {
|
|
261
|
+
return this.transport.request({
|
|
261
262
|
ids: W.CHAIN_GET_HEAD_STORAGE,
|
|
262
263
|
payload: T.VersionedRemoteChainHeadStorageRequest.enc({
|
|
263
264
|
tag: "V1",
|
|
@@ -270,11 +271,10 @@ export class ChainClient {
|
|
|
270
271
|
],
|
|
271
272
|
}).dec(payload).value,
|
|
272
273
|
});
|
|
273
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
274
274
|
}
|
|
275
275
|
/** Invoke a runtime call at a specific block. */
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
callHead(request) {
|
|
277
|
+
return this.transport.request({
|
|
278
278
|
ids: W.CHAIN_CALL_HEAD,
|
|
279
279
|
payload: T.VersionedRemoteChainHeadCallRequest.enc({
|
|
280
280
|
tag: "V1",
|
|
@@ -287,11 +287,10 @@ export class ChainClient {
|
|
|
287
287
|
],
|
|
288
288
|
}).dec(payload).value,
|
|
289
289
|
});
|
|
290
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
291
290
|
}
|
|
292
291
|
/** Release pinned blocks. */
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
unpinHead(request) {
|
|
293
|
+
return this.transport.request({
|
|
295
294
|
ids: W.CHAIN_UNPIN_HEAD,
|
|
296
295
|
payload: T.VersionedRemoteChainHeadUnpinRequest.enc({
|
|
297
296
|
tag: "V1",
|
|
@@ -301,11 +300,10 @@ export class ChainClient {
|
|
|
301
300
|
V1: [0, S.Result(S._void, T.GenericError)],
|
|
302
301
|
}).dec(payload).value,
|
|
303
302
|
});
|
|
304
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
305
303
|
}
|
|
306
304
|
/** Continue a paused chain-head operation. */
|
|
307
|
-
|
|
308
|
-
|
|
305
|
+
continueHead(request) {
|
|
306
|
+
return this.transport.request({
|
|
309
307
|
ids: W.CHAIN_CONTINUE_HEAD,
|
|
310
308
|
payload: T.VersionedRemoteChainHeadContinueRequest.enc({
|
|
311
309
|
tag: "V1",
|
|
@@ -315,11 +313,10 @@ export class ChainClient {
|
|
|
315
313
|
V1: [0, S.Result(S._void, T.GenericError)],
|
|
316
314
|
}).dec(payload).value,
|
|
317
315
|
});
|
|
318
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
319
316
|
}
|
|
320
317
|
/** Stop a chain-head operation. */
|
|
321
|
-
|
|
322
|
-
|
|
318
|
+
stopHeadOperation(request) {
|
|
319
|
+
return this.transport.request({
|
|
323
320
|
ids: W.CHAIN_STOP_HEAD_OPERATION,
|
|
324
321
|
payload: T.VersionedRemoteChainHeadStopOperationRequest.enc({
|
|
325
322
|
tag: "V1",
|
|
@@ -329,11 +326,10 @@ export class ChainClient {
|
|
|
329
326
|
V1: [0, S.Result(S._void, T.GenericError)],
|
|
330
327
|
}).dec(payload).value,
|
|
331
328
|
});
|
|
332
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
333
329
|
}
|
|
334
330
|
/** Fetch the canonical genesis hash for a chain. */
|
|
335
|
-
|
|
336
|
-
|
|
331
|
+
getSpecGenesisHash(request) {
|
|
332
|
+
return this.transport.request({
|
|
337
333
|
ids: W.CHAIN_GET_SPEC_GENESIS_HASH,
|
|
338
334
|
payload: T.VersionedRemoteChainSpecGenesisHashRequest.enc({
|
|
339
335
|
tag: "V1",
|
|
@@ -346,11 +342,10 @@ export class ChainClient {
|
|
|
346
342
|
],
|
|
347
343
|
}).dec(payload).value,
|
|
348
344
|
});
|
|
349
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
350
345
|
}
|
|
351
346
|
/** Fetch the display name of a chain. */
|
|
352
|
-
|
|
353
|
-
|
|
347
|
+
getSpecChainName(request) {
|
|
348
|
+
return this.transport.request({
|
|
354
349
|
ids: W.CHAIN_GET_SPEC_CHAIN_NAME,
|
|
355
350
|
payload: T.VersionedRemoteChainSpecChainNameRequest.enc({
|
|
356
351
|
tag: "V1",
|
|
@@ -363,11 +358,10 @@ export class ChainClient {
|
|
|
363
358
|
],
|
|
364
359
|
}).dec(payload).value,
|
|
365
360
|
});
|
|
366
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
367
361
|
}
|
|
368
362
|
/** Fetch the JSON-encoded properties of a chain. */
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
getSpecProperties(request) {
|
|
364
|
+
return this.transport.request({
|
|
371
365
|
ids: W.CHAIN_GET_SPEC_PROPERTIES,
|
|
372
366
|
payload: T.VersionedRemoteChainSpecPropertiesRequest.enc({
|
|
373
367
|
tag: "V1",
|
|
@@ -380,11 +374,10 @@ export class ChainClient {
|
|
|
380
374
|
],
|
|
381
375
|
}).dec(payload).value,
|
|
382
376
|
});
|
|
383
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
384
377
|
}
|
|
385
378
|
/** Broadcast a signed transaction. */
|
|
386
|
-
|
|
387
|
-
|
|
379
|
+
broadcastTransaction(request) {
|
|
380
|
+
return this.transport.request({
|
|
388
381
|
ids: W.CHAIN_BROADCAST_TRANSACTION,
|
|
389
382
|
payload: T.VersionedRemoteChainTransactionBroadcastRequest.enc({
|
|
390
383
|
tag: "V1",
|
|
@@ -397,11 +390,10 @@ export class ChainClient {
|
|
|
397
390
|
],
|
|
398
391
|
}).dec(payload).value,
|
|
399
392
|
});
|
|
400
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
401
393
|
}
|
|
402
394
|
/** Stop a transaction broadcast. */
|
|
403
|
-
|
|
404
|
-
|
|
395
|
+
stopTransaction(request) {
|
|
396
|
+
return this.transport.request({
|
|
405
397
|
ids: W.CHAIN_STOP_TRANSACTION,
|
|
406
398
|
payload: T.VersionedRemoteChainTransactionStopRequest.enc({
|
|
407
399
|
tag: "V1",
|
|
@@ -411,7 +403,6 @@ export class ChainClient {
|
|
|
411
403
|
V1: [0, S.Result(S._void, T.GenericError)],
|
|
412
404
|
}).dec(payload).value,
|
|
413
405
|
});
|
|
414
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
415
406
|
}
|
|
416
407
|
}
|
|
417
408
|
/** Chat room, bot, and message APIs. */
|
|
@@ -421,8 +412,8 @@ export class ChatClient {
|
|
|
421
412
|
this.transport = transport;
|
|
422
413
|
}
|
|
423
414
|
/** Create a chat room. */
|
|
424
|
-
|
|
425
|
-
|
|
415
|
+
createRoom(request) {
|
|
416
|
+
return this.transport.request({
|
|
426
417
|
ids: W.CHAT_CREATE_ROOM,
|
|
427
418
|
payload: T.VersionedHostChatCreateRoomRequest.enc({
|
|
428
419
|
tag: "V1",
|
|
@@ -435,11 +426,10 @@ export class ChatClient {
|
|
|
435
426
|
],
|
|
436
427
|
}).dec(payload).value,
|
|
437
428
|
});
|
|
438
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
439
429
|
}
|
|
440
430
|
/** Register a chat bot. */
|
|
441
|
-
|
|
442
|
-
|
|
431
|
+
registerBot(request) {
|
|
432
|
+
return this.transport.request({
|
|
443
433
|
ids: W.CHAT_REGISTER_BOT,
|
|
444
434
|
payload: T.VersionedHostChatRegisterBotRequest.enc({
|
|
445
435
|
tag: "V1",
|
|
@@ -452,7 +442,6 @@ export class ChatClient {
|
|
|
452
442
|
],
|
|
453
443
|
}).dec(payload).value,
|
|
454
444
|
});
|
|
455
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
456
445
|
}
|
|
457
446
|
/** Subscribe to the list of chat rooms. */
|
|
458
447
|
listSubscribe() {
|
|
@@ -467,8 +456,8 @@ export class ChatClient {
|
|
|
467
456
|
});
|
|
468
457
|
}
|
|
469
458
|
/** Post a message to a chat room. */
|
|
470
|
-
|
|
471
|
-
|
|
459
|
+
postMessage(request) {
|
|
460
|
+
return this.transport.request({
|
|
472
461
|
ids: W.CHAT_POST_MESSAGE,
|
|
473
462
|
payload: T.VersionedHostChatPostMessageRequest.enc({
|
|
474
463
|
tag: "V1",
|
|
@@ -481,7 +470,6 @@ export class ChatClient {
|
|
|
481
470
|
],
|
|
482
471
|
}).dec(payload).value,
|
|
483
472
|
});
|
|
484
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
485
473
|
}
|
|
486
474
|
/** Subscribe to received chat actions. */
|
|
487
475
|
actionSubscribe() {
|
|
@@ -519,8 +507,8 @@ export class EntropyClient {
|
|
|
519
507
|
this.transport = transport;
|
|
520
508
|
}
|
|
521
509
|
/** Derive deterministic entropy. */
|
|
522
|
-
|
|
523
|
-
|
|
510
|
+
derive(request) {
|
|
511
|
+
return this.transport.request({
|
|
524
512
|
ids: W.ENTROPY_DERIVE,
|
|
525
513
|
payload: T.VersionedHostDeriveEntropyRequest.enc({
|
|
526
514
|
tag: "V1",
|
|
@@ -533,40 +521,6 @@ export class EntropyClient {
|
|
|
533
521
|
],
|
|
534
522
|
}).dec(payload).value,
|
|
535
523
|
});
|
|
536
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
/** JSON-RPC transport methods. */
|
|
540
|
-
export class JsonRpcClient {
|
|
541
|
-
transport;
|
|
542
|
-
constructor(transport) {
|
|
543
|
-
this.transport = transport;
|
|
544
|
-
}
|
|
545
|
-
/** Send a JSON-RPC message. */
|
|
546
|
-
async sendMessage(request) {
|
|
547
|
-
const result = await this.transport.request({
|
|
548
|
-
ids: W.JSON_RPC_SEND_MESSAGE,
|
|
549
|
-
payload: T.VersionedHostJsonrpcMessageSendRequest.enc({
|
|
550
|
-
tag: "V1",
|
|
551
|
-
value: request,
|
|
552
|
-
}),
|
|
553
|
-
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
554
|
-
V1: [0, S.Result(S._void, T.GenericError)],
|
|
555
|
-
}).dec(payload).value,
|
|
556
|
-
});
|
|
557
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
558
|
-
}
|
|
559
|
-
/** Subscribe to inbound JSON-RPC messages. */
|
|
560
|
-
subscribeMessages({ request, }) {
|
|
561
|
-
return createObservable({
|
|
562
|
-
transport: this.transport,
|
|
563
|
-
ids: W.JSON_RPC_SUBSCRIBE_MESSAGES,
|
|
564
|
-
payload: T.VersionedHostJsonrpcMessageSubscribeRequest.enc({
|
|
565
|
-
tag: "V1",
|
|
566
|
-
value: request,
|
|
567
|
-
}),
|
|
568
|
-
decodeItem: (payload) => T.VersionedHostJsonrpcMessageSubscribeItem.dec(payload).value,
|
|
569
|
-
});
|
|
570
524
|
}
|
|
571
525
|
}
|
|
572
526
|
/** Local key/value storage scoped to the calling product. */
|
|
@@ -576,8 +530,8 @@ export class LocalStorageClient {
|
|
|
576
530
|
this.transport = transport;
|
|
577
531
|
}
|
|
578
532
|
/** Read a value by key. */
|
|
579
|
-
|
|
580
|
-
|
|
533
|
+
read(request) {
|
|
534
|
+
return this.transport.request({
|
|
581
535
|
ids: W.LOCAL_STORAGE_READ,
|
|
582
536
|
payload: T.VersionedHostLocalStorageReadRequest.enc({
|
|
583
537
|
tag: "V1",
|
|
@@ -590,11 +544,10 @@ export class LocalStorageClient {
|
|
|
590
544
|
],
|
|
591
545
|
}).dec(payload).value,
|
|
592
546
|
});
|
|
593
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
594
547
|
}
|
|
595
548
|
/** Write a value to a key. */
|
|
596
|
-
|
|
597
|
-
|
|
549
|
+
write(request) {
|
|
550
|
+
return this.transport.request({
|
|
598
551
|
ids: W.LOCAL_STORAGE_WRITE,
|
|
599
552
|
payload: T.VersionedHostLocalStorageWriteRequest.enc({
|
|
600
553
|
tag: "V1",
|
|
@@ -604,11 +557,10 @@ export class LocalStorageClient {
|
|
|
604
557
|
V1: [0, S.Result(S._void, T.HostLocalStorageReadError)],
|
|
605
558
|
}).dec(payload).value,
|
|
606
559
|
});
|
|
607
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
608
560
|
}
|
|
609
561
|
/** Clear a value by key. */
|
|
610
|
-
|
|
611
|
-
|
|
562
|
+
clear(request) {
|
|
563
|
+
return this.transport.request({
|
|
612
564
|
ids: W.LOCAL_STORAGE_CLEAR,
|
|
613
565
|
payload: T.VersionedHostLocalStorageClearRequest.enc({
|
|
614
566
|
tag: "V1",
|
|
@@ -618,7 +570,59 @@ export class LocalStorageClient {
|
|
|
618
570
|
V1: [0, S.Result(S._void, T.HostLocalStorageReadError)],
|
|
619
571
|
}).dec(payload).value,
|
|
620
572
|
});
|
|
621
|
-
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
/** Notification methods for locally-rendered push notifications. */
|
|
576
|
+
export class NotificationsClient {
|
|
577
|
+
transport;
|
|
578
|
+
constructor(transport) {
|
|
579
|
+
this.transport = transport;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Send a push notification to the user.
|
|
583
|
+
*
|
|
584
|
+
* Returns a [`NotificationId`](crate::v01::NotificationId) that can be
|
|
585
|
+
* passed to [`cancel_push_notification`](Self::cancel_push_notification)
|
|
586
|
+
* to retract a scheduled notification. When `scheduled_at` is set the host
|
|
587
|
+
* persists the notification across restarts and fires it through the
|
|
588
|
+
* platform-native scheduler. See [RFC 0019].
|
|
589
|
+
*
|
|
590
|
+
* [RFC 0019]: https://github.com/paritytech/truapi/blob/main/docs/rfcs/0019-scheduled-notifications.md
|
|
591
|
+
*/
|
|
592
|
+
sendPushNotification(request) {
|
|
593
|
+
return this.transport.request({
|
|
594
|
+
ids: W.NOTIFICATIONS_SEND_PUSH_NOTIFICATION,
|
|
595
|
+
payload: T.VersionedHostPushNotificationRequest.enc({
|
|
596
|
+
tag: "V1",
|
|
597
|
+
value: request,
|
|
598
|
+
}),
|
|
599
|
+
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
600
|
+
V1: [
|
|
601
|
+
0,
|
|
602
|
+
S.Result(T.HostPushNotificationResponse, T.HostPushNotificationError),
|
|
603
|
+
],
|
|
604
|
+
}).dec(payload).value,
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Cancels a previously issued push notification.
|
|
609
|
+
*
|
|
610
|
+
* Cancellation is idempotent: returns `Ok(())` whether the notification is
|
|
611
|
+
* still pending, already fired, or was never issued. See [RFC 0019].
|
|
612
|
+
*
|
|
613
|
+
* [RFC 0019]: https://github.com/paritytech/truapi/blob/main/docs/rfcs/0019-scheduled-notifications.md
|
|
614
|
+
*/
|
|
615
|
+
cancelPushNotification(request) {
|
|
616
|
+
return this.transport.request({
|
|
617
|
+
ids: W.NOTIFICATIONS_CANCEL_PUSH_NOTIFICATION,
|
|
618
|
+
payload: T.VersionedHostPushNotificationCancelRequest.enc({
|
|
619
|
+
tag: "V1",
|
|
620
|
+
value: request,
|
|
621
|
+
}),
|
|
622
|
+
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
623
|
+
V1: [0, S.Result(S._void, T.GenericError)],
|
|
624
|
+
}).dec(payload).value,
|
|
625
|
+
});
|
|
622
626
|
}
|
|
623
627
|
}
|
|
624
628
|
/** Payment request and balance/status subscription methods. */
|
|
@@ -628,34 +632,27 @@ export class PaymentClient {
|
|
|
628
632
|
this.transport = transport;
|
|
629
633
|
}
|
|
630
634
|
/** Subscribe to payment balance updates. */
|
|
631
|
-
balanceSubscribe() {
|
|
635
|
+
balanceSubscribe({ request, }) {
|
|
632
636
|
return createObservable({
|
|
633
637
|
transport: this.transport,
|
|
634
638
|
ids: W.PAYMENT_BALANCE_SUBSCRIBE,
|
|
635
639
|
payload: T.VersionedHostPaymentBalanceSubscribeRequest.enc({
|
|
636
640
|
tag: "V1",
|
|
637
|
-
value:
|
|
641
|
+
value: request,
|
|
638
642
|
}),
|
|
639
643
|
decodeItem: (payload) => T.VersionedHostPaymentBalanceSubscribeItem.dec(payload).value,
|
|
640
644
|
decodeInterrupt: (payload) => T.VersionedHostPaymentBalanceSubscribeError.dec(payload).value,
|
|
641
645
|
});
|
|
642
646
|
}
|
|
643
647
|
/** Request a payment from the user. */
|
|
644
|
-
|
|
645
|
-
|
|
648
|
+
request(request) {
|
|
649
|
+
return this.transport.request({
|
|
646
650
|
ids: W.PAYMENT_REQUEST,
|
|
647
|
-
payload: T.
|
|
648
|
-
tag: "V1",
|
|
649
|
-
value: request,
|
|
650
|
-
}),
|
|
651
|
+
payload: T.VersionedHostPaymentRequest.enc({ tag: "V1", value: request }),
|
|
651
652
|
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
652
|
-
V1: [
|
|
653
|
-
0,
|
|
654
|
-
S.Result(T.HostPaymentRequestResponse, T.HostPaymentRequestError),
|
|
655
|
-
],
|
|
653
|
+
V1: [0, S.Result(T.HostPaymentResponse, T.HostPaymentError)],
|
|
656
654
|
}).dec(payload).value,
|
|
657
655
|
});
|
|
658
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
659
656
|
}
|
|
660
657
|
/** Subscribe to payment lifecycle updates for a specific payment. */
|
|
661
658
|
statusSubscribe({ request, }) {
|
|
@@ -671,8 +668,8 @@ export class PaymentClient {
|
|
|
671
668
|
});
|
|
672
669
|
}
|
|
673
670
|
/** Top up the user's payment balance. */
|
|
674
|
-
|
|
675
|
-
|
|
671
|
+
topUp(request) {
|
|
672
|
+
return this.transport.request({
|
|
676
673
|
ids: W.PAYMENT_TOP_UP,
|
|
677
674
|
payload: T.VersionedHostPaymentTopUpRequest.enc({
|
|
678
675
|
tag: "V1",
|
|
@@ -682,7 +679,6 @@ export class PaymentClient {
|
|
|
682
679
|
V1: [0, S.Result(S._void, T.HostPaymentTopUpError)],
|
|
683
680
|
}).dec(payload).value,
|
|
684
681
|
});
|
|
685
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
686
682
|
}
|
|
687
683
|
}
|
|
688
684
|
/** Permission request methods. */
|
|
@@ -692,8 +688,8 @@ export class PermissionsClient {
|
|
|
692
688
|
this.transport = transport;
|
|
693
689
|
}
|
|
694
690
|
/** Request a device-capability permission from the user. */
|
|
695
|
-
|
|
696
|
-
|
|
691
|
+
requestDevicePermission(request) {
|
|
692
|
+
return this.transport.request({
|
|
697
693
|
ids: W.PERMISSIONS_REQUEST_DEVICE_PERMISSION,
|
|
698
694
|
payload: T.VersionedHostDevicePermissionRequest.enc({
|
|
699
695
|
tag: "V1",
|
|
@@ -706,11 +702,10 @@ export class PermissionsClient {
|
|
|
706
702
|
],
|
|
707
703
|
}).dec(payload).value,
|
|
708
704
|
});
|
|
709
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
710
705
|
}
|
|
711
|
-
/** Request
|
|
712
|
-
|
|
713
|
-
|
|
706
|
+
/** Request a remote-operation permission. */
|
|
707
|
+
requestRemotePermission(request) {
|
|
708
|
+
return this.transport.request({
|
|
714
709
|
ids: W.PERMISSIONS_REQUEST_REMOTE_PERMISSION,
|
|
715
710
|
payload: T.VersionedRemotePermissionRequest.enc({
|
|
716
711
|
tag: "V1",
|
|
@@ -723,7 +718,6 @@ export class PermissionsClient {
|
|
|
723
718
|
],
|
|
724
719
|
}).dec(payload).value,
|
|
725
720
|
});
|
|
726
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
727
721
|
}
|
|
728
722
|
}
|
|
729
723
|
/** Preimage lookup and submission methods. */
|
|
@@ -745,8 +739,8 @@ export class PreimageClient {
|
|
|
745
739
|
});
|
|
746
740
|
}
|
|
747
741
|
/** Submit a preimage. Returns the preimage key (hash) on success. */
|
|
748
|
-
|
|
749
|
-
|
|
742
|
+
submit(request) {
|
|
743
|
+
return this.transport.request({
|
|
750
744
|
ids: W.PREIMAGE_SUBMIT,
|
|
751
745
|
payload: T.VersionedRemotePreimageSubmitRequest.enc({
|
|
752
746
|
tag: "V1",
|
|
@@ -756,7 +750,6 @@ export class PreimageClient {
|
|
|
756
750
|
V1: [0, S.Result(S.Hex(), T.PreimageSubmitError)],
|
|
757
751
|
}).dec(payload).value,
|
|
758
752
|
});
|
|
759
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
760
753
|
}
|
|
761
754
|
}
|
|
762
755
|
/** Resource pre-allocation (allowance management). */
|
|
@@ -766,8 +759,8 @@ export class ResourceAllocationClient {
|
|
|
766
759
|
this.transport = transport;
|
|
767
760
|
}
|
|
768
761
|
/** Request the host to pre-allocate one or more resources. */
|
|
769
|
-
|
|
770
|
-
|
|
762
|
+
request(request) {
|
|
763
|
+
return this.transport.request({
|
|
771
764
|
ids: W.RESOURCE_ALLOCATION_REQUEST,
|
|
772
765
|
payload: T.VersionedHostRequestResourceAllocationRequest.enc({
|
|
773
766
|
tag: "V1",
|
|
@@ -780,7 +773,6 @@ export class ResourceAllocationClient {
|
|
|
780
773
|
],
|
|
781
774
|
}).dec(payload).value,
|
|
782
775
|
});
|
|
783
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
784
776
|
}
|
|
785
777
|
}
|
|
786
778
|
/** Signing operations. */
|
|
@@ -790,8 +782,8 @@ export class SigningClient {
|
|
|
790
782
|
this.transport = transport;
|
|
791
783
|
}
|
|
792
784
|
/** Construct a signed transaction for a product account. */
|
|
793
|
-
|
|
794
|
-
|
|
785
|
+
createTransaction(request) {
|
|
786
|
+
return this.transport.request({
|
|
795
787
|
ids: W.SIGNING_CREATE_TRANSACTION,
|
|
796
788
|
payload: T.VersionedHostCreateTransactionRequest.enc({
|
|
797
789
|
tag: "V1",
|
|
@@ -804,11 +796,10 @@ export class SigningClient {
|
|
|
804
796
|
],
|
|
805
797
|
}).dec(payload).value,
|
|
806
798
|
});
|
|
807
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
808
799
|
}
|
|
809
|
-
/** Construct a signed transaction for a non-product account. */
|
|
810
|
-
|
|
811
|
-
|
|
800
|
+
/** Construct a signed transaction for a non-product (legacy) account. */
|
|
801
|
+
createTransactionWithLegacyAccount(request) {
|
|
802
|
+
return this.transport.request({
|
|
812
803
|
ids: W.SIGNING_CREATE_TRANSACTION_WITH_LEGACY_ACCOUNT,
|
|
813
804
|
payload: T.VersionedHostCreateTransactionWithLegacyAccountRequest.enc({
|
|
814
805
|
tag: "V1",
|
|
@@ -821,11 +812,10 @@ export class SigningClient {
|
|
|
821
812
|
],
|
|
822
813
|
}).dec(payload).value,
|
|
823
814
|
});
|
|
824
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
825
815
|
}
|
|
826
816
|
/** Sign raw bytes with a non-product account. */
|
|
827
|
-
|
|
828
|
-
|
|
817
|
+
signRawWithLegacyAccount(request) {
|
|
818
|
+
return this.transport.request({
|
|
829
819
|
ids: W.SIGNING_SIGN_RAW_WITH_LEGACY_ACCOUNT,
|
|
830
820
|
payload: T.VersionedHostSignRawWithLegacyAccountRequest.enc({
|
|
831
821
|
tag: "V1",
|
|
@@ -838,11 +828,10 @@ export class SigningClient {
|
|
|
838
828
|
],
|
|
839
829
|
}).dec(payload).value,
|
|
840
830
|
});
|
|
841
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
842
831
|
}
|
|
843
832
|
/** Sign an extrinsic payload with a non-product account. */
|
|
844
|
-
|
|
845
|
-
|
|
833
|
+
signPayloadWithLegacyAccount(request) {
|
|
834
|
+
return this.transport.request({
|
|
846
835
|
ids: W.SIGNING_SIGN_PAYLOAD_WITH_LEGACY_ACCOUNT,
|
|
847
836
|
payload: T.VersionedHostSignPayloadWithLegacyAccountRequest.enc({
|
|
848
837
|
tag: "V1",
|
|
@@ -855,11 +844,10 @@ export class SigningClient {
|
|
|
855
844
|
],
|
|
856
845
|
}).dec(payload).value,
|
|
857
846
|
});
|
|
858
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
859
847
|
}
|
|
860
848
|
/** Sign raw bytes or a message. */
|
|
861
|
-
|
|
862
|
-
|
|
849
|
+
signRaw(request) {
|
|
850
|
+
return this.transport.request({
|
|
863
851
|
ids: W.SIGNING_SIGN_RAW,
|
|
864
852
|
payload: T.VersionedHostSignRawRequest.enc({ tag: "V1", value: request }),
|
|
865
853
|
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
@@ -869,11 +857,10 @@ export class SigningClient {
|
|
|
869
857
|
],
|
|
870
858
|
}).dec(payload).value,
|
|
871
859
|
});
|
|
872
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
873
860
|
}
|
|
874
861
|
/** Sign an extrinsic payload. */
|
|
875
|
-
|
|
876
|
-
|
|
862
|
+
signPayload(request) {
|
|
863
|
+
return this.transport.request({
|
|
877
864
|
ids: W.SIGNING_SIGN_PAYLOAD,
|
|
878
865
|
payload: T.VersionedHostSignPayloadRequest.enc({
|
|
879
866
|
tag: "V1",
|
|
@@ -886,7 +873,6 @@ export class SigningClient {
|
|
|
886
873
|
],
|
|
887
874
|
}).dec(payload).value,
|
|
888
875
|
});
|
|
889
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
890
876
|
}
|
|
891
877
|
}
|
|
892
878
|
/** Statement store methods. */
|
|
@@ -907,9 +893,15 @@ export class StatementStoreClient {
|
|
|
907
893
|
decodeItem: (payload) => T.VersionedRemoteStatementStoreSubscribeItem.dec(payload).value,
|
|
908
894
|
});
|
|
909
895
|
}
|
|
910
|
-
/**
|
|
911
|
-
|
|
912
|
-
|
|
896
|
+
/**
|
|
897
|
+
* Create a proof for a statement.
|
|
898
|
+
*
|
|
899
|
+
* **Deprecated:** use [`create_proof_authorized`](Self::create_proof_authorized)
|
|
900
|
+
* instead, which uses a pre-allocated allowance account and does not
|
|
901
|
+
* require a per-call signing prompt.
|
|
902
|
+
*/
|
|
903
|
+
createProof(request) {
|
|
904
|
+
return this.transport.request({
|
|
913
905
|
ids: W.STATEMENT_STORE_CREATE_PROOF,
|
|
914
906
|
payload: T.VersionedRemoteStatementStoreCreateProofRequest.enc({
|
|
915
907
|
tag: "V1",
|
|
@@ -922,14 +914,13 @@ export class StatementStoreClient {
|
|
|
922
914
|
],
|
|
923
915
|
}).dec(payload).value,
|
|
924
916
|
});
|
|
925
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
926
917
|
}
|
|
927
918
|
/**
|
|
928
919
|
* Create a proof for a statement using a pre-allocated allowance account,
|
|
929
920
|
* bypassing the per-call signing prompt.
|
|
930
921
|
*/
|
|
931
|
-
|
|
932
|
-
|
|
922
|
+
createProofAuthorized(request) {
|
|
923
|
+
return this.transport.request({
|
|
933
924
|
ids: W.STATEMENT_STORE_CREATE_PROOF_AUTHORIZED,
|
|
934
925
|
payload: T.VersionedRemoteStatementStoreCreateProofAuthorizedRequest.enc({
|
|
935
926
|
tag: "V1",
|
|
@@ -942,15 +933,14 @@ export class StatementStoreClient {
|
|
|
942
933
|
],
|
|
943
934
|
}).dec(payload).value,
|
|
944
935
|
});
|
|
945
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
946
936
|
}
|
|
947
937
|
/**
|
|
948
938
|
* Submit a signed statement to the network. The request body is the
|
|
949
939
|
* [`SignedStatement`](crate::v01::SignedStatement) directly (no wrapping
|
|
950
940
|
* struct), matching upstream `triangle-js-sdks`.
|
|
951
941
|
*/
|
|
952
|
-
|
|
953
|
-
|
|
942
|
+
submit(request) {
|
|
943
|
+
return this.transport.request({
|
|
954
944
|
ids: W.STATEMENT_STORE_SUBMIT,
|
|
955
945
|
payload: T.VersionedRemoteStatementStoreSubmitRequest.enc({
|
|
956
946
|
tag: "V1",
|
|
@@ -960,12 +950,11 @@ export class StatementStoreClient {
|
|
|
960
950
|
V1: [0, S.Result(S._void, T.GenericError)],
|
|
961
951
|
}).dec(payload).value,
|
|
962
952
|
});
|
|
963
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
964
953
|
}
|
|
965
954
|
}
|
|
966
955
|
/**
|
|
967
956
|
* General-purpose TrUAPI methods for handshake, feature detection,
|
|
968
|
-
*
|
|
957
|
+
* and navigation.
|
|
969
958
|
*/
|
|
970
959
|
export class SystemClient {
|
|
971
960
|
transport;
|
|
@@ -973,8 +962,8 @@ export class SystemClient {
|
|
|
973
962
|
this.transport = transport;
|
|
974
963
|
}
|
|
975
964
|
/** Negotiate the wire codec version with the product. */
|
|
976
|
-
|
|
977
|
-
|
|
965
|
+
handshake() {
|
|
966
|
+
return this.transport.request({
|
|
978
967
|
ids: W.SYSTEM_HANDSHAKE,
|
|
979
968
|
payload: T.VersionedHostHandshakeRequest.enc({
|
|
980
969
|
tag: "V1",
|
|
@@ -984,11 +973,10 @@ export class SystemClient {
|
|
|
984
973
|
V1: [0, S.Result(S._void, T.HostHandshakeError)],
|
|
985
974
|
}).dec(payload).value,
|
|
986
975
|
});
|
|
987
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
988
976
|
}
|
|
989
977
|
/** Query whether the host supports a specific feature. */
|
|
990
|
-
|
|
991
|
-
|
|
978
|
+
featureSupported(request) {
|
|
979
|
+
return this.transport.request({
|
|
992
980
|
ids: W.SYSTEM_FEATURE_SUPPORTED,
|
|
993
981
|
payload: T.VersionedHostFeatureSupportedRequest.enc({
|
|
994
982
|
tag: "V1",
|
|
@@ -1001,25 +989,10 @@ export class SystemClient {
|
|
|
1001
989
|
],
|
|
1002
990
|
}).dec(payload).value,
|
|
1003
991
|
});
|
|
1004
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
1005
|
-
}
|
|
1006
|
-
/** Send a push notification to the user. */
|
|
1007
|
-
async pushNotification(request) {
|
|
1008
|
-
const result = await this.transport.request({
|
|
1009
|
-
ids: W.SYSTEM_PUSH_NOTIFICATION,
|
|
1010
|
-
payload: T.VersionedHostPushNotificationRequest.enc({
|
|
1011
|
-
tag: "V1",
|
|
1012
|
-
value: request,
|
|
1013
|
-
}),
|
|
1014
|
-
decodeResponse: (payload) => S.indexedTaggedUnion({
|
|
1015
|
-
V1: [0, S.Result(S._void, T.GenericError)],
|
|
1016
|
-
}).dec(payload).value,
|
|
1017
|
-
});
|
|
1018
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
1019
992
|
}
|
|
1020
993
|
/** Request the host to open a URL. */
|
|
1021
|
-
|
|
1022
|
-
|
|
994
|
+
navigateTo(request) {
|
|
995
|
+
return this.transport.request({
|
|
1023
996
|
ids: W.SYSTEM_NAVIGATE_TO,
|
|
1024
997
|
payload: T.VersionedHostNavigateToRequest.enc({
|
|
1025
998
|
tag: "V1",
|
|
@@ -1029,7 +1002,6 @@ export class SystemClient {
|
|
|
1029
1002
|
V1: [0, S.Result(S._void, T.HostNavigateToError)],
|
|
1030
1003
|
}).dec(payload).value,
|
|
1031
1004
|
});
|
|
1032
|
-
return result.success ? ok(result.value) : err(result.value);
|
|
1033
1005
|
}
|
|
1034
1006
|
}
|
|
1035
1007
|
/** Host theme subscription. */
|
|
@@ -1067,8 +1039,8 @@ export function createClient(transport) {
|
|
|
1067
1039
|
chain: new ChainClient(versionedTransport),
|
|
1068
1040
|
chat: new ChatClient(versionedTransport),
|
|
1069
1041
|
entropy: new EntropyClient(versionedTransport),
|
|
1070
|
-
jsonRpc: new JsonRpcClient(versionedTransport),
|
|
1071
1042
|
localStorage: new LocalStorageClient(versionedTransport),
|
|
1043
|
+
notifications: new NotificationsClient(versionedTransport),
|
|
1072
1044
|
payment: new PaymentClient(versionedTransport),
|
|
1073
1045
|
permissions: new PermissionsClient(versionedTransport),
|
|
1074
1046
|
preimage: new PreimageClient(versionedTransport),
|