Skip to content

Commit 91a1aa6

Browse files
authored
Merge pull request #191 from paritytech/docs/meaningful-console-log-examples
docs(api): add descriptive labels to console.log in TS examples
2 parents 4aab962 + 5ab1173 commit 91a1aa6

15 files changed

Lines changed: 64 additions & 67 deletions

rust/crates/truapi/src/api/account.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Account: Send + Sync {
2222
/// const status = await firstValueFrom(
2323
/// from(truapi.account.connectionStatusSubscribe()),
2424
/// );
25-
/// console.log(status);
25+
/// console.log("connection status:", status);
2626
/// ```
2727
#[wire(start_id = 18)]
2828
async fn connection_status_subscribe(
@@ -42,7 +42,7 @@ pub trait Account: Send + Sync {
4242
/// },
4343
/// });
4444
/// assert(result.isOk(), "getAccount failed:", result);
45-
/// console.log(result.value);
45+
/// console.log("account retrieved:", result.value);
4646
/// ```
4747
#[wire(request_id = 22)]
4848
async fn get_account(
@@ -63,7 +63,7 @@ pub trait Account: Send + Sync {
6363
/// },
6464
/// });
6565
/// assert(result.isOk(), "getAccountAlias failed:", result);
66-
/// console.log(result.value);
66+
/// console.log("account alias:", result.value);
6767
/// ```
6868
#[wire(request_id = 24)]
6969
async fn get_account_alias(
@@ -92,7 +92,7 @@ pub trait Account: Send + Sync {
9292
/// context: "0x",
9393
/// });
9494
/// assert(result.isOk(), "createAccountProof failed:", result);
95-
/// console.log(result.value);
95+
/// console.log("account proof created:", result.value);
9696
/// ```
9797
#[wire(request_id = 26)]
9898
async fn create_account_proof(
@@ -108,7 +108,7 @@ pub trait Account: Send + Sync {
108108
/// ```ts
109109
/// const result = await truapi.account.getLegacyAccounts();
110110
/// assert(result.isOk(), "getLegacyAccounts failed:", result);
111-
/// console.log(result.value);
111+
/// console.log("legacy accounts:", result.value);
112112
/// ```
113113
#[wire(request_id = 28)]
114114
async fn get_legacy_accounts(
@@ -124,7 +124,7 @@ pub trait Account: Send + Sync {
124124
/// ```ts
125125
/// const result = await truapi.account.getUserId();
126126
/// assert(result.isOk(), "getUserId failed:", result);
127-
/// console.log(result.value);
127+
/// console.log("user id:", result.value);
128128
/// ```
129129
#[wire(request_id = 110)]
130130
async fn get_user_id(
@@ -145,7 +145,7 @@ pub trait Account: Send + Sync {
145145
/// reason: "Sign in to vote on Referendum #42",
146146
/// });
147147
/// assert(result.isOk(), "requestLogin failed:", result);
148-
/// console.log(result.value);
148+
/// console.log("login completed:", result.value);
149149
/// ```
150150
#[wire(request_id = 112)]
151151
async fn request_login(

rust/crates/truapi/src/api/chain.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub trait Chain: Send + Sync {
4040
/// }),
4141
/// ),
4242
/// );
43-
/// console.log(item);
43+
/// console.log("head follow event:", item);
4444
/// ```
4545
#[wire(start_id = 76)]
4646
async fn follow_head_subscribe(
@@ -68,7 +68,7 @@ pub trait Chain: Send + Sync {
6868
/// ),
6969
/// );
7070
/// assert(result.isOk(), "getHeadHeader failed:", result);
71-
/// console.log(result.value);
71+
/// console.log("block header:", result.value);
7272
/// ```
7373
#[wire(request_id = 80)]
7474
async fn get_head_header(
@@ -96,7 +96,7 @@ pub trait Chain: Send + Sync {
9696
/// ),
9797
/// );
9898
/// assert(result.isOk(), "getHeadBody failed:", result);
99-
/// console.log(result.value);
99+
/// console.log("block body:", result.value);
100100
/// ```
101101
#[wire(request_id = 82)]
102102
async fn get_head_body(
@@ -129,7 +129,7 @@ pub trait Chain: Send + Sync {
129129
/// ),
130130
/// );
131131
/// assert(result.isOk(), "getHeadStorage failed:", result);
132-
/// console.log(result.value);
132+
/// console.log("storage value:", result.value);
133133
/// ```
134134
#[wire(request_id = 84)]
135135
async fn get_head_storage(
@@ -164,7 +164,7 @@ pub trait Chain: Send + Sync {
164164
/// ),
165165
/// );
166166
/// assert(result.isOk(), "callHead failed:", result);
167-
/// console.log(result.value);
167+
/// console.log("runtime call result:", result.value);
168168
/// ```
169169
#[wire(request_id = 86)]
170170
async fn call_head(
@@ -196,7 +196,7 @@ pub trait Chain: Send + Sync {
196196
/// ),
197197
/// );
198198
/// assert(result.isOk(), "unpinHead failed:", result);
199-
/// console.log("ok");
199+
/// console.log("blocks unpinned");
200200
/// ```
201201
#[wire(request_id = 88)]
202202
async fn unpin_head(
@@ -228,7 +228,7 @@ pub trait Chain: Send + Sync {
228228
/// ),
229229
/// );
230230
/// assert(result.isOk(), "continueHead failed:", result);
231-
/// console.log("ok");
231+
/// console.log("operation continued");
232232
/// ```
233233
#[wire(request_id = 90)]
234234
async fn continue_head(
@@ -260,7 +260,7 @@ pub trait Chain: Send + Sync {
260260
/// ),
261261
/// );
262262
/// assert(result.isOk(), "stopHeadOperation failed:", result);
263-
/// console.log("ok");
263+
/// console.log("operation stopped");
264264
/// ```
265265
#[wire(request_id = 92)]
266266
async fn stop_head_operation(
@@ -281,7 +281,7 @@ pub trait Chain: Send + Sync {
281281
/// genesisHash: PASEO_NEXT_V2_ASSET_HUB.genesis,
282282
/// });
283283
/// assert(result.isOk(), "getSpecGenesisHash failed:", result);
284-
/// console.log(result.value);
284+
/// console.log("genesis hash:", result.value);
285285
/// ```
286286
#[wire(request_id = 94)]
287287
async fn get_spec_genesis_hash(
@@ -302,7 +302,7 @@ pub trait Chain: Send + Sync {
302302
/// genesisHash: PASEO_NEXT_V2_ASSET_HUB.genesis,
303303
/// });
304304
/// assert(result.isOk(), "getSpecChainName failed:", result);
305-
/// console.log(result.value);
305+
/// console.log("chain name:", result.value);
306306
/// ```
307307
#[wire(request_id = 96)]
308308
async fn get_spec_chain_name(
@@ -322,7 +322,7 @@ pub trait Chain: Send + Sync {
322322
/// genesisHash: PASEO_NEXT_V2_ASSET_HUB.genesis,
323323
/// });
324324
/// assert(result.isOk(), "getSpecProperties failed:", result);
325-
/// console.log(result.value);
325+
/// console.log("chain properties:", result.value);
326326
/// ```
327327
#[wire(request_id = 98)]
328328
async fn get_spec_properties(
@@ -343,7 +343,7 @@ pub trait Chain: Send + Sync {
343343
/// transaction: "0x",
344344
/// });
345345
/// assert(result.isOk(), "broadcastTransaction failed:", result);
346-
/// console.log(result.value);
346+
/// console.log("transaction broadcast:", result.value);
347347
/// ```
348348
#[wire(request_id = 100)]
349349
async fn broadcast_transaction(
@@ -367,7 +367,7 @@ pub trait Chain: Send + Sync {
367367
/// operationId: "op-id",
368368
/// });
369369
/// assert(result.isOk(), "stopTransaction failed:", result);
370-
/// console.log("ok");
370+
/// console.log("transaction broadcast stopped");
371371
/// ```
372372
#[wire(request_id = 102)]
373373
async fn stop_transaction(

rust/crates/truapi/src/api/chat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait Chat: Send + Sync {
2121
/// icon: "",
2222
/// });
2323
/// assert(result.isOk(), "createRoom failed:", result);
24-
/// console.log(result.value);
24+
/// console.log("room created:", result.value);
2525
/// ```
2626
#[wire(request_id = 38)]
2727
async fn create_room(
@@ -41,7 +41,7 @@ pub trait Chat: Send + Sync {
4141
/// icon: "",
4242
/// });
4343
/// assert(result.isOk(), "registerBot failed:", result);
44-
/// console.log(result.value);
44+
/// console.log("bot registered:", result.value);
4545
/// ```
4646
#[wire(request_id = 40)]
4747
async fn register_bot(
@@ -60,7 +60,7 @@ pub trait Chat: Send + Sync {
6060
/// const item = await firstValueFrom(
6161
/// from(truapi.chat.listSubscribe()),
6262
/// );
63-
/// console.log(item);
63+
/// console.log("room list received:", item);
6464
/// ```
6565
#[wire(start_id = 42)]
6666
async fn list_subscribe(&self, _cx: &CallContext) -> Subscription<HostChatListSubscribeItem> {
@@ -75,7 +75,7 @@ pub trait Chat: Send + Sync {
7575
/// payload: { tag: "Text", value: { text: "Hello from playground!" } },
7676
/// });
7777
/// assert(result.isOk(), "postMessage failed:", result);
78-
/// console.log(result.value);
78+
/// console.log("message posted:", result.value);
7979
/// ```
8080
#[wire(request_id = 46)]
8181
async fn post_message(
@@ -94,7 +94,7 @@ pub trait Chat: Send + Sync {
9494
/// const item = await firstValueFrom(
9595
/// from(truapi.chat.actionSubscribe()),
9696
/// );
97-
/// console.log(item);
97+
/// console.log("action received:", item);
9898
/// ```
9999
#[wire(start_id = 48)]
100100
async fn action_subscribe(
@@ -122,7 +122,7 @@ pub trait Chat: Send + Sync {
122122
/// }),
123123
/// ),
124124
/// );
125-
/// console.log(item);
125+
/// console.log("render request received:", item);
126126
/// ```
127127
#[wire(start_id = 52)]
128128
async fn custom_message_render_subscribe(

rust/crates/truapi/src/api/coin_payment.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub trait CoinPayment: Send + Sync {
3030
/// name: "Terminal purse",
3131
/// });
3232
/// assert(result.isOk(), "createPurse failed:", result);
33-
/// console.log(result.value.purse);
33+
/// console.log("purse created:", result.value.purse);
3434
/// ```
3535
#[wire(request_id = 136)]
3636
async fn create_purse(
@@ -47,7 +47,7 @@ pub trait CoinPayment: Send + Sync {
4747
/// ```ts
4848
/// const result = await truapi.coinPayment.queryPurse({ purse: 1 });
4949
/// assert(result.isOk(), "queryPurse failed:", result);
50-
/// console.log(result.value.info);
50+
/// console.log("purse info:", result.value.info);
5151
/// ```
5252
#[wire(request_id = 138)]
5353
async fn query_purse(
@@ -70,7 +70,7 @@ pub trait CoinPayment: Send + Sync {
7070
/// }),
7171
/// ),
7272
/// );
73-
/// console.log(status);
73+
/// console.log("rebalance status:", status);
7474
/// ```
7575
#[wire(start_id = 140)]
7676
async fn rebalance_purse(
@@ -96,7 +96,7 @@ pub trait CoinPayment: Send + Sync {
9696
/// }),
9797
/// ),
9898
/// );
99-
/// console.log(status);
99+
/// console.log("delete status:", status);
100100
/// ```
101101
#[wire(start_id = 144)]
102102
async fn delete_purse(
@@ -115,7 +115,7 @@ pub trait CoinPayment: Send + Sync {
115115
/// ```ts
116116
/// const result = await truapi.coinPayment.createReceivable({ into: 1 });
117117
/// assert(result.isOk(), "createReceivable failed:", result);
118-
/// console.log(result.value.receivable);
118+
/// console.log("receivable created:", result.value.receivable);
119119
/// ```
120120
#[wire(request_id = 148)]
121121
async fn create_receivable(
@@ -138,7 +138,7 @@ pub trait CoinPayment: Send + Sync {
138138
/// amount: 1000,
139139
/// });
140140
/// assert(result.isOk(), "createCheque failed:", result);
141-
/// console.log(result.value.cheque);
141+
/// console.log("cheque created:", result.value.cheque);
142142
/// ```
143143
#[wire(request_id = 150)]
144144
async fn create_cheque(
@@ -165,7 +165,7 @@ pub trait CoinPayment: Send + Sync {
165165
/// const status = await firstValueFrom(
166166
/// from(truapi.coinPayment.deposit({ request: { cheque } })),
167167
/// );
168-
/// console.log(status);
168+
/// console.log("deposit status:", status);
169169
/// ```
170170
#[wire(start_id = 152)]
171171
async fn deposit(
@@ -192,7 +192,7 @@ pub trait CoinPayment: Send + Sync {
192192
/// }),
193193
/// ),
194194
/// );
195-
/// console.log(status);
195+
/// console.log("refund status:", status);
196196
/// ```
197197
#[wire(start_id = 156)]
198198
async fn refund(
@@ -219,7 +219,7 @@ pub trait CoinPayment: Send + Sync {
219219
/// }),
220220
/// ),
221221
/// );
222-
/// console.log(item);
222+
/// console.log("payment received:", item);
223223
/// ```
224224
#[wire(start_id = 160)]
225225
async fn listen_for_payment(

rust/crates/truapi/src/api/entropy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait Entropy: Send + Sync {
1515
/// context: "0x70726f647563742d6b6579",
1616
/// });
1717
/// assert(result.isOk(), "derive failed:", result);
18-
/// console.log(result.value);
18+
/// console.log("entropy derived:", result.value);
1919
/// ```
2020
#[wire(request_id = 108)]
2121
async fn derive(

rust/crates/truapi/src/api/local_storage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait LocalStorage: Send + Sync {
1515
/// ```ts
1616
/// const result = await truapi.localStorage.read({ key: "test-key" });
1717
/// assert(result.isOk(), "read failed:", result);
18-
/// console.log(result.value.value);
18+
/// console.log("storage value read:", result.value.value);
1919
/// ```
2020
#[wire(request_id = 12)]
2121
async fn read(
@@ -32,7 +32,7 @@ pub trait LocalStorage: Send + Sync {
3232
/// value: "0x48656c6c6f",
3333
/// });
3434
/// assert(result.isOk(), "write failed:", result);
35-
/// console.log("ok");
35+
/// console.log("storage write succeeded");
3636
/// ```
3737
#[wire(request_id = 14)]
3838
async fn write(
@@ -46,7 +46,7 @@ pub trait LocalStorage: Send + Sync {
4646
/// ```ts
4747
/// const result = await truapi.localStorage.clear({ key: "test-key" });
4848
/// assert(result.isOk(), "clear failed:", result);
49-
/// console.log("ok");
49+
/// console.log("storage clear succeeded");
5050
/// ```
5151
#[wire(request_id = 16)]
5252
async fn clear(

rust/crates/truapi/src/api/notifications.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub trait Notifications: Send + Sync {
2525
/// text: "Hello!",
2626
/// });
2727
/// assert(result.isOk(), "sendPushNotification failed:", result);
28-
/// console.log(result.value);
28+
/// console.log("notification sent:", result.value);
2929
/// ```
3030
#[wire(request_id = 4)]
3131
async fn send_push_notification(
@@ -46,7 +46,7 @@ pub trait Notifications: Send + Sync {
4646
/// id: 1,
4747
/// });
4848
/// assert(result.isOk(), "cancelPushNotification failed:", result);
49-
/// console.log("ok");
49+
/// console.log("notification cancelled");
5050
/// ```
5151
#[wire(request_id = 134)]
5252
async fn cancel_push_notification(

0 commit comments

Comments
 (0)