Skip to content

Commit 7126ad0

Browse files
authored
Merge pull request #1902 from aeternity/release/13.2.2
Release 13.2.2
2 parents 5df22dd + 86c6f61 commit 7126ad0

Some content is hidden

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

48 files changed

+514
-332
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22
services:
33
node:
4-
image: aeternity/aeternity:v6.8.1
4+
image: aeternity/aeternity:v6.11.0
55
hostname: node
66
ports: ["3013:3013", "3113:3113", "3014:3014", "3114:3114"]
77
volumes:

docker/aeternity_node_mean16.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ chain:
2020
persist: false
2121
hard_forks:
2222
"1": 0
23-
"6": 1
23+
"5": 1
2424

2525
mining:
2626
autostart: true

docs/CHANGELOG.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [13.2.2](https://github.com/aeternity/aepp-sdk-js/compare/v13.2.1...v13.2.2) (2023-09-20)
6+
7+
8+
### Bug Fixes
9+
10+
* use proper vm version in Ceres ([bcaa5cf](https://github.com/aeternity/aepp-sdk-js/commit/bcaa5cfe0f8a23a641d9db993b312e2d54cfdd60))
11+
* **aepp,wallet:** connect to web-extension if opened over file:/// ([da6a025](https://github.com/aeternity/aepp-sdk-js/commit/da6a0257e995db38e32888390961eb870a482777))
12+
* **aepp:** use complete type of WalletInfo object ([eeba565](https://github.com/aeternity/aepp-sdk-js/commit/eeba56576b97afda6739fa8cd0f9e5c6f039651f))
13+
* **contract:** don't mark contract as deployed if tx failed ([cc4222d](https://github.com/aeternity/aepp-sdk-js/commit/cc4222db8dc979c878e6e51bea9634484b826de7))
14+
* **contract:** use current nonce in static calls ([758bdfc](https://github.com/aeternity/aepp-sdk-js/commit/758bdfc75a1dd8e4ff0646ddeaa10e19b1a4d5d1))
15+
* **node:** don't retry 500 code responses ([696e7db](https://github.com/aeternity/aepp-sdk-js/commit/696e7db88605a385789d741f2704aba2c1cee972))
16+
* **node:** throw clear error message if unsupported protocol ([21dfe34](https://github.com/aeternity/aepp-sdk-js/commit/21dfe34b3645d95b4c54d99e8517a33634b3751f))
17+
* **node:** uncatchable exception if request failed in queue ([dec62a4](https://github.com/aeternity/aepp-sdk-js/commit/dec62a474cad4639b81cbef46ff606c384f7ab53))
18+
* typos in error messages and docs ([5c84671](https://github.com/aeternity/aepp-sdk-js/commit/5c846712a32a110e1a5df25d5c4366046d9558f5))
19+
520
### [13.2.1](https://github.com/aeternity/aepp-sdk-js/compare/v13.2.0...v13.2.1) (2023-07-28)
621

722

@@ -48,7 +63,7 @@ All notable changes to this project will be documented in this file. See [standa
4863
* **contract:** use fallback account if `onAccount` not provided ([9033cd7](https://github.com/aeternity/aepp-sdk-js/commit/9033cd799be5974ebf28a49df181eeb63b1fce84))
4964
* converting proxied options to JSON ([efebbd1](https://github.com/aeternity/aepp-sdk-js/commit/efebbd139ea85c35e28bdcfe907670743f9fc1f4))
5065
* provide types in exports field of package.json ([dbd19e7](https://github.com/aeternity/aepp-sdk-js/commit/dbd19e70bca2d6dbc5b2392db478bb98936b63f2))
51-
* reject prefixes other then provided in isAddressValid ([9462add](https://github.com/aeternity/aepp-sdk-js/commit/9462adde8fab9848fca0a6d9a382dbd34f5e2b8f))
66+
* reject prefixes other than provided in isAddressValid ([9462add](https://github.com/aeternity/aepp-sdk-js/commit/9462adde8fab9848fca0a6d9a382dbd34f5e2b8f))
5267
* **tx-builder:** `buildTx` produces the same type as `unpackTx` accepts ([d3d6c88](https://github.com/aeternity/aepp-sdk-js/commit/d3d6c88607abbfb74acf016fba886540938b216d))
5368
* **tx-builder:** decode tag in entry error message ([db0d96f](https://github.com/aeternity/aepp-sdk-js/commit/db0d96f156f3e8cfe52c6a7d7411c359f6dae35c))
5469
* **wallet:** emit internal error if something broke while broadcast ([332d1b5](https://github.com/aeternity/aepp-sdk-js/commit/332d1b567f69bf6b7d3567af43fb805556ac015b))

docs/guides/address-length.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ Running the above code you would get output like
8181
Therefore the minimum address length is 41 chars. All these addresses valid, for example
8282
`ak_11111111111111111111111111111111273Yts` [used] to collect AENS name fees.
8383
84-
[isAddressValid]: https://docs.aeternity.com/aepp-sdk-js/v13.1.0/api/functions/isAddressValid.html
84+
[isAddressValid]: https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/functions/isAddressValid.html
8585
[used]: https://mainnet.aeternity.io/v3/accounts/ak_11111111111111111111111111111111273Yts

docs/guides/contracts.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,33 @@ The smart contract language of the æternity blockchain is [Sophia](https://docs
55

66
Before interacting with contracts using the SDK you should get familiar with Sophia itself first. Have a look into [aepp-sophia-examples](https://github.com/aeternity/aepp-sophia-examples) and start rapid prototyping using [AEstudio](https://studio.aepps.com).
77

8-
The SDK needs to interact with following components in order to enable smart contract interactions on the æternity blockchain:
9-
10-
- [æternity](https://github.com/aeternity/aeternity) (host your own one or use the public testnet node at `https://testnet.aeternity.io`)
11-
- [aesophia_http](https://github.com/aeternity/aesophia_http) (host your own one or use the public compiler at `https://v7.compiler.aepps.com`)
12-
13-
Note:
14-
15-
- For production deployments you should ***always*** host these services by yourself.
16-
178
## 1. Specify imports
189
```js
1910
// node.js import
20-
const { AeSdk, MemoryAccount, Node, CompilerHttp } = require('@aeternity/aepp-sdk')
11+
const { AeSdk, MemoryAccount, Node } = require('@aeternity/aepp-sdk')
2112
// ES import
22-
import { AeSdk, MemoryAccount, Node, CompilerHttp } from '@aeternity/aepp-sdk'
13+
import { AeSdk, MemoryAccount, Node } from '@aeternity/aepp-sdk'
14+
// additionally you may need to import CompilerCli or CompilerHttp
15+
```
16+
17+
## 2. Setup compiler
18+
Compiler primarily used to generate bytecode to deploy a contract.
19+
Skip this step if you have a contract bytecode or need to interact with an already deployed contract.
20+
Out-of-the-box SDK supports [aesophia_cli](https://github.com/aeternity/aesophia_cli) and [aesophia_http](https://github.com/aeternity/aesophia_http) implemented in [CompilerCli](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/CompilerCli.html) and [CompilerHttp](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/CompilerHttp.html) respectively.
21+
22+
CompilerCli is available only in Node.js and requires Erlang installed (`escript` available in `$PATH`), Windows is supported.
23+
```js
24+
const compiler = new CompilerCli()
2325
```
2426

25-
## 2. Create an instance of the SDK
27+
CompilerHttp requires a hosted compiler service. Preferable to host your own compiler service since [compiler.aepps.com](https://v7.compiler.aepps.com/api) is planned to be decommissioned. An example of how to run it using [docker-compose](https://github.com/aeternity/aepp-sdk-js/blob/cd8dd7f76a6323383349b48400af0d69c2cfd88e/docker-compose.yml#L11-L14).
28+
```js
29+
const compiler = new CompilerHttp('https://v7.compiler.aepps.com') // host your own compiler
30+
```
31+
32+
Both compiler classes implement the [same interface](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/CompilerBase.html) that can be used to generate bytecode and ACI without a Contract instance.
33+
34+
## 3. Create an instance of the SDK
2635
When creating an instance of the SDK you need to provide an account which will be used to sign transactions like `ContractCreateTx` and `ContractCallTx` that will be broadcasted to the network.
2736

2837
```js
@@ -32,7 +41,7 @@ const account = new MemoryAccount(SECRET_KEY)
3241
const aeSdk = new AeSdk({
3342
nodes: [{ name: 'testnet', instance: node }],
3443
accounts: [account],
35-
onCompiler: new CompilerHttp('https://v7.compiler.aepps.com'), // ideally host your own compiler
44+
onCompiler: compiler, // remove if step #2 skipped
3645
})
3746
```
3847

@@ -42,7 +51,7 @@ Note:
4251
- For each transaction you can choose a specific account to use for signing (by default the first account will be used), see [transaction options](../transaction-options.md).
4352
- This is specifically important and useful for writing tests.
4453

45-
## 3. Initialize the contract instance
54+
## 4. Initialize the contract instance
4655

4756
### By source code
4857

@@ -59,6 +68,13 @@ Note:
5968
const contract = await aeSdk.initializeContract({ sourceCode, fileSystem })
6069
```
6170

71+
### By path to source code (available only in Node.js)
72+
It can be used with both CompilerCli and CompilerHttp. This way contract imports would be handled automatically, with no need to provide `fileSystem` option.
73+
```js
74+
const sourceCodePath = './example.aes'
75+
const contract = await aeSdk.initializeContract({ sourceCodePath })
76+
```
77+
6278
### By ACI and bytecode
6379
If you pre-compiled the contracts you can also initialize a contract instance by providing ACI and bytecode:
6480

@@ -80,7 +96,7 @@ const contract = await aeSdk.initializeContract({ aci, address })
8096
### Options
8197

8298
- Following attributes can be provided via `options` to `initializeContract`:
83-
- `aci` (default: obtained via http compiler)
99+
- `aci` (default: obtained via `onCompiler`)
84100
- The Contract ACI.
85101
- `address`
86102
- The address where the contract is located at.
@@ -94,7 +110,11 @@ const contract = await aeSdk.initializeContract({ aci, address })
94110
- You wouldn't want to provide an `amount` to each transaction or use the same `nonce` which would result in invalid transactions.
95111
- For options like `ttl` or `gasPrice` it does absolutely make sense to set this on contract instance level.
96112

97-
## 4. Deploy the contract
113+
### Keep bytecode and ACI for future use
114+
After the contract is initialized you can persist values of `contract._aci` and `contract.$options.bytecode`.
115+
They can be provided for subsequent contract initializations to don't depend on a compiler.
116+
117+
## 5. Deploy the contract
98118

99119
If you have a Sophia contract source code that looks like this:
100120
```sophia
@@ -131,7 +151,7 @@ Note:
131151
- In Sophia all `public functions` are called `entrypoints` and need to be declared as `stateful`
132152
if they should produce changes to the state of the smart contract, see `increment(value: int)`.
133153

134-
## 5. Call contract entrypoints
154+
## 6. Call contract entrypoints
135155

136156
### a) Stateful entrypoints
137157
According to the example above you can call the `stateful` entrypoint `increment` by using one of the following lines:
@@ -187,21 +207,13 @@ const tx = await contract.$call('fund_project', [1], { amount: 50 })
187207
As already stated various times in the guide it is possible to provide [transaction options](../transaction-options.md) as object to a function of the SDK that builds and potentially broadcasts a transaction. This object can be passed as additional param to each of these functions and overrides the default settings.
188208

189209
## Sophia datatype cheatsheet
190-
Sometimes you might wonder how to pass params to the JavaScript method that calls an entrypoint of your Sophia smart contract. The following table may help you out.
191-
192-
| Type | Sophia entrypoint definition | JavaScript method call |
193-
|-----------|-----------------------------------|--------------------------------------------------|
194-
| int | `add_two(one: int, two: int)` | `add_two(1 , 2)` |
195-
| address | `set_owner(owner: address)` | `set_owner('ak_1337...')` |
196-
| bool | `is_it_true(answer: bool)` | `is_it_true(true)` |
197-
| bits | `give_me_bits(input: bits)` | `give_me_bits(0b10110n)` |
198-
| bytes | `get_bytes(test: bytes(3))` | `get_bytes(new Uint8Array([0x1, 0x1f, 0x10]))` |
199-
| string | `hello_world(say_hello: string)` | `hello_world('Hello!')` |
200-
| list | `have_a_few(candy: list(string))` | `have_a_few(['Skittles', 'M&Ms', 'JellyBelly'])` |
201-
| tuple | `a_few_things(things: (string * int * map(address, bool)))` | `a_few_things(['hola', 3, new Map([['ak_1337...', true]])])` |
202-
| record | `record user = {`<br />&nbsp; &nbsp; &nbsp; &nbsp; `firstname: string,` <br /> &nbsp; &nbsp; &nbsp; &nbsp; `lastname: string` <br /> `}` <br /> <br /> `get_firstname(input: user): string` | `get_firstname({'firstname': 'Alfred', 'lastname': 'Mustermann'})` |
203-
| map | `balances(values: map(address, int))` | `balances(new Map([['ak_1337...', 123], ['ak_FCKGW...', 321], ['ak_Rm5U...', 999]]))` |
204-
| option() | `number_defined(value: option(int)): bool = `<br /> &nbsp; &nbsp; &nbsp; &nbsp; `Option.is_some(value)` | `// the datatype in the option()` <br /> `number_defined(1337) // int in this case` |
205-
| hash | `a_gram(of: hash)` | `// 32 bytes signature` <br /> `a_gram('af01...490f')` |
206-
| signature | `one_signature(sig: signature)` | `// 64 bytes signature` <br /> `one_signature('af01...490f')` |
207-
| functions | (Higher order) functions are not allowed in `entrypoint` params | |
210+
Sometimes you might wonder how to pass params to the JavaScript method that calls an entrypoint of your Sophia smart contract.
211+
The conversion between JS and Sophia values is handled by aepp-calldata library.
212+
Refer to [its documentation](https://www.npmjs.com/package/@aeternity/aepp-calldata#data-types) to find the right type to use.
213+
214+
## Generate file system object in Node.js
215+
To do so you can use [getFileSystem](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/functions/getFileSystem.html) function.
216+
In most cases, you don't need to do it explicitly. Prefer to use `sourceCodePath` instead `sourceCode` in
217+
[Contract::initialize](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/_internal_.Contract.html#initialize),
218+
and [compile](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/CompilerBase.html#compile)
219+
instead [compileBySourceCode](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/api/classes/CompilerBase.html#compileBySourceCode) in CompilerBase.

docs/guides/paying-for-tx.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ You can then collect the signed inner transaction, wrap it into a `PayingForTx`
1313
## Usage examples
1414
We provided following two NodeJS examples which you can take a look at:
1515

16-
- [InnerTx: ContractCallTx](https://docs.aeternity.com/aepp-sdk-js/v13.1.0/examples/node/paying-for-contract-call-tx/)
17-
- [InnerTx: SpendTx](https://docs.aeternity.com/aepp-sdk-js/v13.1.0/examples/node/paying-for-spend-tx/)
16+
- [InnerTx: ContractCallTx](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/examples/node/paying-for-contract-call-tx/)
17+
- [InnerTx: SpendTx](https://docs.aeternity.com/aepp-sdk-js/v13.2.2/examples/node/paying-for-spend-tx/)
1818

1919
Note:
2020

docs/guides/typed-data.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ corresponds to the data
3030

3131
## Implementation
3232

33-
- [encodeFateValue](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/utils/typed-data.ts#L44-L52) — use to generate the first argument for `signTypedData`;
34-
- [AccountBase::signTypedData](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/account/Base.ts#L63-L70) — calculates signature, supported in MemoryAccount and in aepp-wallet connection;
33+
- [AccountBase:signTypedData](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/account/Base.ts#L63-L70) — calculates signature, supported in MemoryAccount and in aepp-wallet connection;
3534
- [hashTypedData](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/utils/typed-data.ts#L87-L95) — calculates the overall hash of typed data to sign;
36-
- [decodeFateValue](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/utils/typed-data.ts#L55-L63) — use to preview data to sign on wallet side;
3735
- [hashJson](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/utils/typed-data.ts#L16-L18) — deterministic hashing of an arbitrary JS value, used to calculate `hash(aci)`;
3836
- [hashDomain](https://github.com/aeternity/aepp-sdk-js/blob/5952a7b9f4d0cf30ad7caa0831dfb974d1e91afc/src/utils/typed-data.ts#L68-L85) — use for debugging or to prepare the hash value for smart contract.
3937

docs/quick-start.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Quick Start
2-
In this example we will send 1 _AE_ coin from one account to another
2+
In this example we will send 1 _AE_ coin from one account to another.
3+
For more specific information on setups with Frameworks and TypeScript, please refer to the [installation instructions](./README.md).
34

45
## 1. Specify imports
56
For the following snippets in the guide you need to specify multiple imports.

examples/browser/aepp/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77
"build": "vue-cli-service build"
88
},
99
"dependencies": {
10+
"@aeternity/aepp-calldata": "^1.5.1",
1011
"@aeternity/aepp-sdk": "file:../../..",
1112
"buffer": "^6.0.3",
12-
"core-js": "^3.22.6",
13+
"core-js": "^3.32.1",
1314
"tailwindcss": "^2.2.19",
14-
"vue": "^3.2.36",
15-
"vuex": "^4.0.2"
15+
"vue": "^3.3.4",
16+
"vuex": "^4.1.0"
1617
},
1718
"devDependencies": {
18-
"@vue/cli-plugin-babel": "~5.0.4",
19-
"@vue/cli-service": "~5.0.4",
20-
"sass": "^1.52.1",
21-
"sass-loader": "^13.0.0"
19+
"@vue/cli-plugin-babel": "~5.0.8",
20+
"@vue/cli-service": "~5.0.8",
21+
"sass": "^1.66.1",
22+
"sass-loader": "^13.3.2"
2223
},
2324
"browserslist": [
2425
"> 1%",

examples/browser/aepp/src/Connect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default {
6767
walletConnected: false,
6868
walletConnecting: null,
6969
reverseIframe: null,
70-
reverseIframeWalletUrl: process.env.VUE_APP_WALLET_URL ?? 'http://localhost:9000',
70+
reverseIframeWalletUrl: process.env.VUE_APP_WALLET_URL ?? `http://${location.hostname}:9000`,
7171
walletInfo: null,
7272
cancelWalletDetection: null,
7373
}),

0 commit comments

Comments
 (0)