Skip to content

Commit 2c45259

Browse files
committed
Merge pull request #2072 from aeternity/api-docs-fixes
API docs fixes, deprecate and rename some exports
2 parents 409f7e8 + dc35f2c commit 2c45259

File tree

102 files changed

+551
-351
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+551
-351
lines changed

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = {
116116
### Vue@3
117117

118118
Reactivity in Vue@3 [based on] Proxy class. Proxy is [not compatible] with private fields of ES
119-
classes. AeSdk, Contract and MemoryAccount classes uses private fields, so if you make an instance of these
119+
classes. AeSdk, Contract and AccountMemory classes uses private fields, so if you make an instance of these
120120
classes reactive then the app may fail with
121121

122122
> TypeError: attempted to get private field on non-instance
@@ -126,7 +126,7 @@ to solve this issue we suggest to avoid making their instances reactive using
126126
Vue's integrated utility: [shallowRef]. The idea is to make reactive only the
127127
instance value, to don't make it reactive in deep.
128128

129-
Alternatively, [toRaw] can unwrap the proxy object, returning an unmodified instance and allowing access to its private properties by its methods. It can be useful if you need a reactive array of MemoryAccount.
129+
Alternatively, [toRaw] can unwrap the proxy object, returning an unmodified instance and allowing access to its private properties by its methods. It can be useful if you need a reactive array of AccountMemory.
130130

131131
You can find both approaches used in the [æpp example].
132132

docs/guides/address-length.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ base58 it depends on the exact data to encode, e.g. it is shorter if encoded dat
55
leading zeroes.
66

77
Building an aepp you may need to know the range of possible address lengths to validate an
8-
user-provided addresses (though better to use [isAddressValid]) or for designs of address-related
8+
user-provided addresses (though better to use [isEncoded]) or for designs of address-related
99
components. Doing manual tests you may conclude that account address length is between 52 and 53
1010
chars, but it is not correct.
1111

1212
```js
13-
import { MemoryAccount } from '@aeternity/aepp-sdk';
13+
import { AccountMemory } from '@aeternity/aepp-sdk';
1414

1515
const result = new Array(10000)
1616
.fill()
17-
.map(() => MemoryAccount.generate().address.length)
17+
.map(() => AccountMemory.generate().address.length)
1818
.reduce((p, n) => ({ ...p, [n]: (p[n] ?? 0) + 1 }), {});
1919

2020
console.log(result);
@@ -28,9 +28,9 @@ Theoretically there can be even shorter addresses if they lucky to be prefixed w
2828
sequence of `0`.
2929
3030
```js
31-
import { MemoryAccount, Encoding, encode, decode } from '@aeternity/aepp-sdk';
31+
import { AccountMemory, Encoding, encode, decode } from '@aeternity/aepp-sdk';
3232

33-
const publicKey = decode(MemoryAccount.generate().address);
33+
const publicKey = decode(AccountMemory.generate().address);
3434

3535
for (let i = -1; i < publicKey.length; i += 1) {
3636
if (i >= 0) publicKey[i] = 0;
@@ -80,5 +80,5 @@ Running the above code you would get output like
8080
Therefore the minimum address length is 41 chars. All these addresses valid, for example
8181
`ak_11111111111111111111111111111111273Yts` [used] to collect AENS name fees.
8282
83-
[isAddressValid]: https://sdk.aeternity.io/v14.0.0/api/functions/isAddressValid.html
83+
[isEncoded]: https://sdk.aeternity.io/v14.1.0/api/functions/isEncoded.html
8484
[used]: https://mainnet.aeternity.io/v3/accounts/ak_11111111111111111111111111111111273Yts

docs/guides/contracts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Before interacting with contracts using the SDK you should get familiar with Sop
1010

1111
```js
1212
// node.js import
13-
const { AeSdk, MemoryAccount, Node } = require('@aeternity/aepp-sdk');
13+
const { AeSdk, AccountMemory, Node } = require('@aeternity/aepp-sdk');
1414
// ES import
15-
import { AeSdk, MemoryAccount, Node } from '@aeternity/aepp-sdk';
15+
import { AeSdk, AccountMemory, Node } from '@aeternity/aepp-sdk';
1616
// additionally you may need to import CompilerCli or CompilerHttp
1717
```
1818

@@ -42,7 +42,7 @@ When creating an instance of the SDK you need to provide an account which will b
4242

4343
```js
4444
const node = new Node('https://testnet.aeternity.io'); // ideally host your own node
45-
const account = new MemoryAccount(SECRET_KEY);
45+
const account = new AccountMemory(SECRET_KEY);
4646

4747
const aeSdk = new AeSdk({
4848
nodes: [{ name: 'testnet', instance: node }],

docs/guides/error-handling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ BaseError
109109
import {
110110
AeSdk,
111111
Node,
112-
MemoryAccount,
112+
AccountMemory,
113113
ArgumentError,
114114
InvalidAensNameError,
115115
} from '@aeternity/aepp-sdk';
116116

117117
// setup
118-
const payerAccount = MemoryAccount.generate();
119-
const newUserAccount = MemoryAccount.generate();
118+
const payerAccount = AccountMemory.generate();
119+
const newUserAccount = AccountMemory.generate();
120120
const node = new Node('https://testnet.aeternity.io');
121121
const aeSdk = new AeSdk({
122122
nodes: [{ name: 'testnet', instance: node }],

docs/guides/jwt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
Use `signJwt` to generate a JWT signed by an account provided in arguments.
66

77
```ts
8-
import { MemoryAccount, signJwt } from '@aeternity/aepp-sdk';
8+
import { AccountMemory, signJwt } from '@aeternity/aepp-sdk';
99

10-
const account = MemoryAccount.generate();
10+
const account = AccountMemory.generate();
1111
const payload = { test: 'data' };
1212
const jwt = await signJwt(payload, account);
1313
```

docs/guides/oracles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { AeSdk, Oracle } from '@aeternity/aepp-sdk'
1616
// init an instance of the SDK using the AeSdk class
1717
const aeSdk = new AeSdk({ ... })
1818
// it should be an instance of AccountBase with non-zero balance
19-
const oracleAccount = new MemoryAccount(...)
19+
const oracleAccount = new AccountMemory(...)
2020

2121
const oracle = new Oracle(oracleAccount, aeSdk.getContext())
2222
```

docs/guides/typed-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ corresponds to the data
3434

3535
## Implementation
3636

37-
- [AccountBase:signTypedData](https://github.com/aeternity/aepp-sdk-js/blob/568c291b92c030011ca9e68169f328be6ff79488/src/account/Base.ts#L63-L70) — calculates signature, supported in MemoryAccount and in aepp-wallet connection;
37+
- [AccountBase:signTypedData](https://github.com/aeternity/aepp-sdk-js/blob/568c291b92c030011ca9e68169f328be6ff79488/src/account/Base.ts#L63-L70) — calculates signature, supported in AccountMemory and in aepp-wallet connection;
3838
- [hashTypedData](https://github.com/aeternity/aepp-sdk-js/blob/568c291b92c030011ca9e68169f328be6ff79488/src/utils/typed-data.ts#L82-L96) — calculates the overall hash of typed data to sign;
3939
- [hashJson](https://github.com/aeternity/aepp-sdk-js/blob/568c291b92c030011ca9e68169f328be6ff79488/src/utils/typed-data.ts#L10-L12) — deterministic hashing of an arbitrary JS value, used to calculate `hash(aci)`;
4040
- [hashDomain](https://github.com/aeternity/aepp-sdk-js/blob/568c291b92c030011ca9e68169f328be6ff79488/src/utils/typed-data.ts#L56-L80) — use for debugging or to prepare the hash value for smart contract.

docs/guides/typescript.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,46 +144,46 @@ The problem is that TypeScript won't check if `address` is an `ak_`-encoded stri
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
147-
import { isAddressValid } from '@aeternity/aepp-sdk';
147+
import { isEncoded, Encoding } from '@aeternity/aepp-sdk';
148148

149-
if (!isAddressValid(address)) {
149+
if (!isEncoded(address, Encoding.AccountAddress)) {
150150
alert('The address is not valid');
151151
return;
152152
}
153153

154154
await aeSdk.spend(100, address);
155155
```
156156

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

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

161161
```ts
162162
import { Encoding } from '@aeternity/aepp-sdk';
163163

164-
isAddressValid(address, Encoding.ContractAddress, Encoding.OracleAddress);
164+
isEncoded(address, Encoding.ContractAddress, Encoding.OracleAddress);
165165
```
166166

167167
Or encoding types in general:
168168

169169
```ts
170-
isAddressValid(address, Encoding.Transaction);
170+
isEncoded(address, Encoding.Transaction);
171171
```
172172

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

177177
### AENS name validation
178178

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

181181
```ts
182-
import { isNameValid } from '@aeternity/aepp-sdk';
182+
import { isName } from '@aeternity/aepp-sdk';
183183

184-
console.log(isNameValid('name.chain')); // true
185-
console.log(isNameValid('мир.chain')); // true
186-
console.log(isNameValid('🙂.chain')); // false
184+
console.log(isName('name.chain')); // true
185+
console.log(isName('мир.chain')); // true
186+
console.log(isName('🙂.chain')); // false
187187
```
188188

189189
If you don't need to handle invalid names specially then you can use [`ensureName`]:
@@ -198,7 +198,7 @@ const name = new Name(nameAsString, options);
198198

199199
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.
200200

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

204204
## Check types of contract methods

docs/quick-start.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ For more specific information on setups with Frameworks and TypeScript, please r
88
For the following snippets in the guide you need to specify multiple imports.
99

1010
```js
11-
const { AeSdk, MemoryAccount, Node, AE_AMOUNT_FORMATS } = require('@aeternity/aepp-sdk');
11+
const { AeSdk, AccountMemory, Node } = require('@aeternity/aepp-sdk');
1212
```
1313

1414
## 2. Create a sender account
1515

1616
```js
17-
const sender = MemoryAccount.generate();
17+
const sender = AccountMemory.generate();
1818
console.log('Sender address:', sender.address);
1919
console.log('Sender secret key:', sender.secretKey);
2020
```
@@ -28,12 +28,12 @@ To receive some _AE_ you can use the [Faucet](https://faucet.aepps.com/). Just p
2828
This example shows:
2929

3030
- how to create an instance of the SDK using the `AeSdk` class
31-
- how to spend (send) 1 AE from the account the SDK instance was initialized with to some other AE address
31+
- how to spend (send) 1 _AE_ from the account the SDK instance was initialized with to some other AE address
3232

3333
```js
3434
const NODE_URL = 'https://testnet.aeternity.io';
3535
// replace <SENDER_SECRET_KEY> with the generated secretKey from step 2
36-
const sender = new MemoryAccount('<SENDER_SECRET_KEY>');
36+
const sender = new AccountMemory('<SENDER_SECRET_KEY>');
3737

3838
(async function () {
3939
const node = new Node(NODE_URL);
@@ -43,16 +43,13 @@ const sender = new MemoryAccount('<SENDER_SECRET_KEY>');
4343
});
4444

4545
// spend one AE
46-
await aeSdk.spend(1, '<RECIPIENT_ADDRESS>', {
47-
// replace <RECIPIENT_ADDRESS>, Ideally you use address from Superhero Wallet you have created before
48-
denomination: AE_AMOUNT_FORMATS.AE,
49-
});
46+
await aeSdk.spend(1e18, '<RECIPIENT_ADDRESS>');
47+
// replace <RECIPIENT_ADDRESS>, Ideally you use address from Superhero Wallet you have created before
5048
})();
5149
```
5250

5351
Note:
5452

5553
- You may remove code from Step 2 as this serves only for one-time creation
56-
- By default the `spend` function expects the amount to be spent in `aettos` (the smallest possible unit)
57-
- Following the example snippet you would specify `AE` as denomination
54+
- The `spend` function expects the amount to be spent in `aettos` (the smallest possible unit, 1 _AE_ equal to 1 000 000 000 000 000 000 `aettos`)
5855
- See [Testnet Explorer](https://testnet.aescan.io/) and track your transactions

examples/browser/aepp/src/TypedData.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393

9494
<script>
9595
import { mapState } from 'vuex';
96-
import { hashTypedData, verify, decode } from '@aeternity/aepp-sdk';
96+
import { hashTypedData, verifySignature, decode } from '@aeternity/aepp-sdk';
9797
import { TypeResolver, ContractByteArrayEncoder } from '@aeternity/aepp-calldata';
9898
import Value from './components/Value.vue';
9999
import FieldAction from './components/FieldAction.vue';
@@ -148,7 +148,7 @@ export default {
148148
return this.aeSdk.signTypedData(this.dataEncoded, this.aciParsed, this.domain);
149149
},
150150
async verifyTypedData() {
151-
return verify(this.hash, decode(this.verifySignature), this.verifyAddress);
151+
return verifySignature(this.hash, decode(this.verifySignature), this.verifyAddress);
152152
},
153153
},
154154
};

0 commit comments

Comments
 (0)