Skip to content

Commit 0381855

Browse files
authored
Merge pull request #2089 from aeternity/fix-links-in-mkdocs
docs: fix links with code blocks in mkdocs
2 parents c337c52 + b54ddfb commit 0381855

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,24 @@ Usage guides:
2727
- [Contract Events](docs/guides/contract-events.md)
2828
- [Oracles](docs/guides/oracles.md)
2929
- [PayingForTx](docs/guides/paying-for-tx.md) (Meta-Transactions)
30-
- [Batch Transactions](docs/guides//batch-requests.md)
30+
- [Batch Transactions](docs/guides/batch-requests.md)
3131
- [Error Handling](docs/guides/error-handling.md)
3232
- [Low vs High level API](docs/guides/low-vs-high-usage.md)
33+
- [Typed data hashing and signing](docs/guides/typed-data.md)
34+
- [Usage with TypeScript](docs/guides/typescript.md)
35+
- [JWT usage](docs/guides/jwt.md)
36+
- [Transaction options](docs/transaction-options.md)
37+
- [Range of possible address length](docs/guides/address-length.md)
3338
- Wallet Interaction
3439
- [Connect an æpp to a wallet](docs/guides/connect-aepp-to-wallet.md)
3540
- [How to build a wallet](docs/guides/build-wallet.md)
41+
- [Ledger Hardware Wallet](docs/guides/ledger-wallet.md)
42+
- [Aeternity snap for MetaMask](docs/guides/metamask-snap.md)
3643

3744
There are also [examples](examples/README.md) that you can directly use and play with.
3845

46+
### [API Reference](https://sdk.aeternity.io/v14.0.0/api/)
47+
3948
## CLI - Command Line Interface
4049

4150
To quickly test _all_ of æternity's blockchain features from your terminal, you can install and use the [CLI](https://github.com/aeternity/aepp-cli-js) by running:

docs/guides/low-vs-high-usage.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ But there is also low-level interfaces. It's excellent for additional control, a
88

99
### Node API
1010

11-
The aeternity node exposes [a REST API]. This API is described in the [OpenAPI document]. SDK uses this document to generate a TypeScript client. The result client (implemented in [`Node` class]) a basically a mapping of all node endpoints as functions.
11+
The aeternity node exposes [a REST API]. This API is described in the [OpenAPI document]. SDK uses this document to generate a TypeScript client. The result client (implemented in [`Node` class][node]) a basically a mapping of all node endpoints as functions.
1212

1313
[a REST API]: https://api-docs.aeternity.io/
1414
[OpenAPI document]: https://mainnet.aeternity.io/api?oas3
15-
[`Node` class]: https://sdk.aeternity.io/v14.0.0/api/classes/Node.html
15+
[node]: https://sdk.aeternity.io/v14.0.0/api/classes/Node.html
1616

1717
So to get a transaction based on its hash you would invoke `node.getTransactionByHash('th_fWEsg152BNYcrqA9jDh9VVpacYojCUb1yu45zUnqhmQ3dAAC6')`. In this way the SDK is simply a mapping of the raw API calls into JavaScript.
1818

1919
### Transaction builder
2020

21-
Any blockchain state change requires signing a transaction. Transaction should be built according to the [protocol]. SDK implements it in [`buildTx`], [`buildTxAsync`], and [`unpackTx`]. [`buildTxAsync`] requires fewer arguments than [`buildTx`], but it expects the node instance provided in arguments.
21+
Any blockchain state change requires signing a transaction. Transaction should be built according to the [protocol]. SDK implements it in [`buildTx`][buildTx], [`buildTxAsync`][buildTxAsync], and [`unpackTx`][unpackTx]. [`buildTxAsync`][buildTxAsync] requires fewer arguments than [`buildTx`][buildTx], but it expects the node instance provided in arguments.
2222

2323
[protocol]: https://github.com/aeternity/protocol/blob/c007deeac4a01e401238412801ac7084ac72d60e/serializations.md#accounts-version-1-basic-accounts
24-
[`buildTx`]: https://sdk.aeternity.io/v14.0.0/api/functions/buildTx.html
25-
[`buildTxAsync`]: https://sdk.aeternity.io/v14.0.0/api/functions/buildTxAsync.html
26-
[`unpackTx`]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackTx.html
24+
[buildTx]: https://sdk.aeternity.io/v14.0.0/api/functions/buildTx.html
25+
[buildTxAsync]: https://sdk.aeternity.io/v14.0.0/api/functions/buildTxAsync.html
26+
[unpackTx]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackTx.html
2727

2828
## High-level SDK usage (preferable)
2929

docs/guides/typescript.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Firstly, ensure you've set up TypeScript according to the [installation guide].
88

99
## Extract types of methods exposed by SDK
1010

11-
SDK doesn't expose types separately to reduce the number of exports and simplify tracking of breaking changes. But you may need these types to prepare parameters or to hold the return value. In such cases, it is advised to use TypeScript-provided generics [`Parameters`] and [`ReturnType`]. For example,
11+
SDK doesn't expose types separately to reduce the number of exports and simplify tracking of breaking changes. But you may need these types to prepare parameters or to hold the return value. In such cases, it is advised to use TypeScript-provided generics [`Parameters`][Parameters] and [`ReturnType`][ReturnType]. For example,
1212

1313
```ts
1414
import { walletDetector } from '@aeternity/aepp-sdk';
@@ -23,7 +23,7 @@ const stop = walletDetector(connection, ({ newWallet }) => {
2323
});
2424
```
2525

26-
The same for [`ReturnType`]:
26+
The same for [`ReturnType`][ReturnType]:
2727

2828
```ts
2929
import { unpackDelegation } from '@aeternity/aepp-sdk';
@@ -36,8 +36,8 @@ delegation = unpackDelegation(
3636
);
3737
```
3838

39-
[`Parameters`]: https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype
40-
[`ReturnType`]: https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype
39+
[Parameters]: https://www.typescriptlang.org/docs/handbook/utility-types.html#parameterstype
40+
[ReturnType]: https://www.typescriptlang.org/docs/handbook/utility-types.html#returntypetype
4141

4242
## Initialize parameters with specific types
4343

@@ -55,7 +55,7 @@ const gaAuthData = {
5555
const gaAuthDataPacked = packEntry(gaAuthData);
5656
```
5757

58-
The problem in this case, is that TypeScript will generalize the type of `unpackedEntry.txHash` to `string` instead of `th_${string}` making it incompatible with arguments of [`packEntry`]. To fix this you may define `gaAuthData`'s type explicitly, like:
58+
The problem in this case, is that TypeScript will generalize the type of `unpackedEntry.txHash` to `string` instead of `th_${string}` making it incompatible with arguments of [`packEntry`][packEntry]. To fix this you may define `gaAuthData`'s type explicitly, like:
5959

6060
```ts
6161
import { Tag, Encoded } from '@aeternity/aepp-sdk';
@@ -83,13 +83,13 @@ const gaAuthData = {
8383
} as const;
8484
```
8585

86-
In the last case, `txHash`'s type will be exactly `"th_2CKnN6EorvNiwwqRjSzXLrPLiHmcwo4Ny22dwCrSYRoD6MVGK1"`, making it compatible with [`packEntry`].
86+
In the last case, `txHash`'s type will be exactly `"th_2CKnN6EorvNiwwqRjSzXLrPLiHmcwo4Ny22dwCrSYRoD6MVGK1"`, making it compatible with [`packEntry`][packEntry].
8787

88-
[`packEntry`]: https://sdk.aeternity.io/v14.0.0/api/functions/packEntry.html
88+
[packEntry]: https://sdk.aeternity.io/v14.0.0/api/functions/packEntry.html
8989

90-
## Narrow the union type returned by [`unpackTx`], [`unpackDelegation`], and [`unpackEntry`]
90+
## Narrow the union type returned by [`unpackTx`][unpackTx], [`unpackDelegation`][unpackDelegation], and [`unpackEntry`][unpackEntry]
9191

92-
Some sdk methods return a [union] of multiple types. For example, [`unpackTx`] returns a union of [all supported transaction] fields. To work correctly you need to narrow this type to a specific transaction before accessing its fields. For example,
92+
Some sdk methods return a [union] of multiple types. For example, [`unpackTx`][unpackTx] returns a union of [all supported transaction] fields. To work correctly you need to narrow this type to a specific transaction before accessing its fields. For example,
9393

9494
```ts
9595
import { unpackTx, Tag } from '@aeternity/aepp-sdk';
@@ -110,15 +110,15 @@ Without checking the `tx.tag` TypeScript will fail with
110110

111111
> Property 'amount' does not exist on type 'TxUnpackedSignedTx1 & { tag: Tag; }'.
112112
113-
The above check is also implemented in [`unpackTx`] itself, instead of checking the `tx.tag` you can provide Tag in the second argument:
113+
The above check is also implemented in [`unpackTx`][unpackTx] itself, instead of checking the `tx.tag` you can provide Tag in the second argument:
114114

115115
```ts
116116
const tx = unpackTx(encodedTx, Tag.SpendTx);
117117
```
118118

119119
But if you need to get SpendTx properties inside a SignedTx you still need to use the above `tag` check.
120120

121-
You may find that [`unpackTx`] is a generic function so that it can be executed as
121+
You may find that [`unpackTx`][unpackTx] is a generic function so that it can be executed as
122122

123123
```ts
124124
const tx = unpackTx<Tag.SpendTx>(encodedTx);
@@ -127,20 +127,20 @@ const tx = unpackTx<Tag.SpendTx>(encodedTx);
127127
The problem is that JavaScript won't check if the transaction is a SpendTx, so provide `Tag.SpendTx` as the second argument instead (as the above).
128128

129129
[union]: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#union-types
130-
[`unpackTx`]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackTx.html
131-
[`unpackDelegation`]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackDelegation.html
132-
[`unpackEntry`]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackEntry.html
130+
[unpackTx]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackTx.html
131+
[unpackDelegation]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackDelegation.html
132+
[unpackEntry]: https://sdk.aeternity.io/v14.0.0/api/functions/unpackEntry.html
133133
[all supported transaction]: https://sdk.aeternity.io/v14.0.0/api/types/_internal_.TxUnpacked.html
134134

135135
## Functions to assert types of user-provided data
136136

137-
Let's assume we need to receive an address from the user to send some coins to it. The user enters an address in a text box, we can get it as a string. [`spend`] method accepts the address as [`Encoded.AccountAddress`], it won't accept a general string. We can overcome this restriction by adding a type assertion, like:
137+
Let's assume we need to receive an address from the user to send some coins to it. The user enters an address in a text box, we can get it as a string. [`spend`][spend] method accepts the address as [`Encoded.AccountAddress`][Encoded.AccountAddress], it won't accept a general string. We can overcome this restriction by adding a type assertion, like:
138138

139139
```ts
140140
await aeSdk.spend(100, address as Encoded.AccountAddress);
141141
```
142142

143-
The problem is that TypeScript won't check if `address` is an `ak_`-encoded string, and the [`spend`] method will fail in this case.
143+
The problem is that TypeScript won't check if `address` is an `ak_`-encoded string, and the [`spend`][spend] method will fail in this case.
144144
A more accurate solution would be to check the `address` in advance, providing user feedback if it is incorrect. For example:
145145

146146
```ts
@@ -154,9 +154,9 @@ if (!isEncoded(address, Encoding.AccountAddress)) {
154154
await aeSdk.spend(100, address);
155155
```
156156

157-
Please note that this method doesn't require explicit casting `string` to [`Encoded.AccountAddress`] because [`isEncoded`] implicitly marks `address` as `ak_${string}` in case it returns `true`.
157+
Please note that this method doesn't require explicit casting `string` to [`Encoded.AccountAddress`][Encoded.AccountAddress] because [`isEncoded`][isEncoded] implicitly marks `address` as `ak_${string}` in case it returns `true`.
158158

159-
Additionally, you can use [`isEncoded`] to validate data against other address types:
159+
Additionally, you can use [`isEncoded`][isEncoded] to validate data against other address types:
160160

161161
```ts
162162
import { Encoding } from '@aeternity/aepp-sdk';
@@ -170,13 +170,13 @@ Or encoding types in general:
170170
isEncoded(address, Encoding.Transaction);
171171
```
172172

173-
[`spend`]: https://sdk.aeternity.io/v14.0.0/api/functions/spend.html
174-
[`Encoded.AccountAddress`]: https://sdk.aeternity.io/v14.0.0/api/types/Encoded.AccountAddress.html
175-
[`isEncoded`]: https://sdk.aeternity.io/v14.0.0/api/functions/isEncoded.html
173+
[spend]: https://sdk.aeternity.io/v14.0.0/api/functions/spend.html
174+
[Encoded.AccountAddress]: https://sdk.aeternity.io/v14.0.0/api/types/Encoded.AccountAddress.html
175+
[isEncoded]: https://sdk.aeternity.io/v14.0.0/api/functions/isEncoded.html
176176

177177
### AENS name validation
178178

179-
The similar way [`isName`] can be used
179+
The similar way [`isName`][isName] can be used
180180

181181
```ts
182182
import { isName } from '@aeternity/aepp-sdk';
@@ -186,7 +186,7 @@ console.log(isName('мир.chain')); // true
186186
console.log(isName('🙂.chain')); // false
187187
```
188188

189-
If you don't need to handle invalid names specially then you can use [`ensureName`]:
189+
If you don't need to handle invalid names specially then you can use [`ensureName`][ensureName]:
190190

191191
```ts
192192
import { ensureName, Name } from '@aeternity/aepp-sdk';
@@ -196,14 +196,14 @@ ensureName(nameAsString);
196196
const name = new Name(nameAsString, options);
197197
```
198198

199-
Doing this way, [`ensureName`] will throw an exception if `nameAsString` is not a proper AENS name. TypeScript will handle `nameAsString` as `${string}.chain` in lines below [`ensureName`] invocation.
199+
Doing this way, [`ensureName`][ensureName] will throw an exception if `nameAsString` is not a proper AENS name. TypeScript will handle `nameAsString` as `${string}.chain` in lines below [`ensureName`][ensureName] invocation.
200200

201-
[`isName`]: https://sdk.aeternity.io/v14.1.0/api/functions/isName.html
202-
[`ensureName`]: https://sdk.aeternity.io/v14.0.0/api/functions/ensureName.html
201+
[isName]: https://sdk.aeternity.io/v14.1.0/api/functions/isName.html
202+
[ensureName]: https://sdk.aeternity.io/v14.0.0/api/functions/ensureName.html
203203

204204
## Check types of contract methods
205205

206-
By default, it is allowed to call any method of the [`Contract`] instance. You can enable type-checking by providing a contract interface in a generic parameter of [`Contract`]. For example:
206+
By default, it is allowed to call any method of the [`Contract`][Contract] instance. You can enable type-checking by providing a contract interface in a generic parameter of [`Contract`][Contract]. For example:
207207

208208
```ts
209209
import { Contract } from '@aeternity/aepp-sdk';
@@ -239,7 +239,7 @@ console.log((await contract.bar(new Map([['test', 10n]]))).decodedResult); // Ma
239239
console.log((await contract.baz({ FirstName: ['Nikita'] })).decodedResult); // 6
240240
```
241241

242-
If you need to define the contract interface separately then extend [`ContractMethodsBase`]:
242+
If you need to define the contract interface separately then extend [`ContractMethodsBase`][ContractMethodsBase]:
243243

244244
```ts
245245
import { ContractMethodsBase } from '@aeternity/aepp-sdk';
@@ -259,5 +259,5 @@ const contract = await Contract.initialize<FooContract>({
259259
It is theoretically possible to generate a contract interface by ACI. But unfortunately, it is [not supported] currently.
260260

261261
[not supported]: https://github.com/aeternity/aepp-calldata-js/issues/97
262-
[`Contract`]: https://sdk.aeternity.io/v14.0.0/api/types/Contract.html
263-
[`ContractMethodsBase`]: https://sdk.aeternity.io/v14.0.0/api/interfaces/ContractMethodsBase.html
262+
[Contract]: https://sdk.aeternity.io/v14.0.0/api/types/Contract.html
263+
[ContractMethodsBase]: https://sdk.aeternity.io/v14.0.0/api/interfaces/ContractMethodsBase.html

0 commit comments

Comments
 (0)