Skip to content

Commit 24f55cb

Browse files
authored
Merge pull request #1462 from aeternity/release/11.0.1
Release 11.0.1
2 parents 996dc29 + 804a0bf commit 24f55cb

File tree

18 files changed

+295
-186
lines changed

18 files changed

+295
-186
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
ignoreRegExpLiterals: true,
2424
ignoreStrings: true,
2525
ignoreTemplateLiterals: true
26-
}]
26+
}],
27+
'import/no-cycle': 2
2728
}
2829
}

docs/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
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+
### [11.0.1](https://github.com/aeternity/aepp-sdk-js/compare/v11.0.0...v11.0.1) (2022-04-07)
6+
7+
8+
### Bug Fixes
9+
10+
* **contract:** do not check payable if contract call is init ([c09fc0c](https://github.com/aeternity/aepp-sdk-js/commit/c09fc0c40bef8668066697567182a75f7a484886))
11+
* importing in mjs ([01d493b](https://github.com/aeternity/aepp-sdk-js/commit/01d493b0556897bdeb3bd04796f482702b175b36))
12+
* **oracle:** do not include address for oracle respond signature ([ad4bddc](https://github.com/aeternity/aepp-sdk-js/commit/ad4bddc43f139e44f33fcde8051ad64f52a734c2))
13+
514
## [11.0.0](https://github.com/aeternity/aepp-sdk-js/compare/v10.0.0...v11.0.0) (2022-03-18)
615

716
### Request batching: SDK now supports [batching transactions](guides/batch-requests.md)

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mkdocs==1.2.3
1+
mkdocs==1.2.4
22
mkdocs-simple-hooks==0.1.3
33
mkdocs-material==7.1.9
44
mike==1.0.1

package-lock.json

Lines changed: 40 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aeternity/aepp-sdk",
3-
"version": "11.0.0",
3+
"version": "11.0.1",
44
"description": "SDK for the æternity blockchain",
55
"main": "dist/aepp-sdk.js",
66
"types": "es/index.d.ts",
@@ -22,7 +22,7 @@
2222
"test:watch": "mocha './test/unit/' './test/integration/' --watch",
2323
"prepare": "npm run build",
2424
"prepublishOnly": "npm run docs:examples",
25-
"release": "standard-version --skip.tag"
25+
"release": "standard-version --skip.tag --infile docs/CHANGELOG.md"
2626
},
2727
"license": "ISC",
2828
"keywords": [
@@ -70,9 +70,11 @@
7070
"@commitlint/cli": "^16.1.0",
7171
"@commitlint/config-conventional": "^16.0.0",
7272
"@types/bn.js": "^5.1.0",
73+
"@types/bs58": "^4.0.1",
7374
"@types/chai": "^4.3.0",
7475
"@types/mocha": "^9.1.0",
7576
"@types/node": "^17.0.17",
77+
"@types/sha.js": "^2.4.0",
7678
"@typescript-eslint/eslint-plugin": "^5.11.0",
7779
"@typescript-eslint/parser": "^5.11.0",
7880
"babel-loader": "^8.2.3",

src/ae/contract.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function createAensDelegationSignature ({ contractId, name }, opt = {}) {
106106
* const respondSig = await contract.createOracleDelegationSignature(params, queryId)
107107
*/
108108
async function createOracleDelegationSignature ({ contractId, queryId }, opt = {}) {
109-
return this.delegateSignatureCommon([...queryId ? [queryId] : [], contractId], opt)
109+
return this.delegateSignatureCommon([queryId ?? await this.address(opt), contractId], opt)
110110
}
111111

112112
/**

src/channel/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,12 @@ async function reconnect (options, txParams) {
863863
*/
864864
const Channel = AsyncInit.compose({
865865
async init (options) {
866-
initialize(this, options)
866+
await initialize(
867+
this,
868+
options.existingFsmId ? handlers.awaitingReconnection : handlers.awaitingConnection,
869+
handlers.channelOpen,
870+
options
871+
)
867872
},
868873
methods: {
869874
on,

src/channel/internal.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { w3cwebsocket as W3CWebSocket } from 'websocket'
1919
import { EventEmitter } from 'events'
2020
import JsonBig from '../utils/json-big'
2121
import { pascalToSnake } from '../utils/string'
22-
import { awaitingConnection, awaitingReconnection, channelOpen } from './handlers'
2322
import { ChannelCallError, ChannelPingTimedOutError, UnknownChannelStateError } from '../utils/errors'
2423

2524
// Send ping message every 10 seconds
@@ -196,11 +195,11 @@ export function disconnect (channel) {
196195
clearTimeout(pongTimeoutId.get(channel))
197196
}
198197

199-
export async function initialize (channel, { url, ...channelOptions }) {
198+
export async function initialize (
199+
channel, connectionHandler, openHandler, { url, ...channelOptions }
200+
) {
200201
options.set(channel, channelOptions)
201-
fsm.set(channel, {
202-
handler: channelOptions.existingFsmId ? awaitingReconnection : awaitingConnection
203-
})
202+
fsm.set(channel, { handler: connectionHandler })
204203
eventEmitters.set(channel, new EventEmitter())
205204
sequence.set(channel, 0)
206205
rpcCallbacks.set(channel, new Map())
@@ -219,7 +218,7 @@ export async function initialize (channel, { url, ...channelOptions }) {
219218
resolve()
220219
changeStatus(channel, 'connected')
221220
if (channelOptions.reconnectTx) {
222-
enterState(channel, { handler: channelOpen })
221+
enterState(channel, { handler: openHandler })
223222
setTimeout(async () => changeState(channel,
224223
(await call(channel, 'channels.get.offchain_state', {})).signed_tx
225224
))

src/contract/aci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export default async function getContractInstance ({
235235
if (!fn) throw new MissingFunctionNameError()
236236
if (fn === 'init' && !opt.callStatic) throw new InvalidMethodInvocationError('"init" can be called only via dryRun')
237237
if (!contractId && fn !== 'init') throw new InvalidMethodInvocationError('You need to deploy contract before calling!')
238-
if (opt.amount > 0 && fnACI.payable === false) throw new NotPayableFunctionError(`You try to pay "${opt.amount}" to function "${fn}" which is not payable. Only payable function can accept coins`)
238+
if (fn !== 'init' && opt.amount > 0 && fnACI.payable === false) throw new NotPayableFunctionError(`You try to pay "${opt.amount}" to function "${fn}" which is not payable. Only payable function can accept coins`)
239239

240240
const callerId = await this.address(opt).catch(error => {
241241
if (opt.callStatic) return DRY_RUN_ACCOUNT.pub

src/tx/builder/constants.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import BigNumber from 'bignumber.js'
2+
import { mapObject } from '../../utils/other'
3+
4+
// # AENS
5+
export const NAME_TTL = 180000
6+
// # max number of block into the future that the name is going to be available
7+
// # https://github.com/aeternity/protocol/blob/epoch-v0.22.0/AENS.md#update
8+
// # https://github.com/aeternity/protocol/blob/44a93d3aab957ca820183c3520b9daf6b0fedff4/AENS.md#aens-entry
9+
export const NAME_MAX_TTL = 36000
10+
export const NAME_MAX_CLIENT_TTL = 84600
11+
export const CLIENT_TTL = NAME_MAX_CLIENT_TTL
12+
// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67
13+
export const NAME_FEE_MULTIPLIER = 1e14 // 100000000000000
14+
export const NAME_FEE_BID_INCREMENT = 0.05 // # the increment is in percentage
15+
// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L272
16+
export const NAME_BID_TIMEOUT_BLOCKS = 480 // # ~1 day
17+
// # this is the max length for a domain that requires a base fee to be paid
18+
export const NAME_MAX_LENGTH_FEE = 31
19+
export const NAME_BID_MAX_LENGTH = 12 // # this is the max length for a domain to be part of a bid
20+
export const POINTER_KEY_BY_PREFIX = {
21+
ak: 'account_pubkey',
22+
ok: 'oracle_pubkey',
23+
ct: 'contract_pubkey',
24+
ch: 'channel'
25+
}
26+
// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290
27+
// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times
28+
// # bid ranges:
29+
export const NAME_BID_RANGES = mapObject({
30+
31: 3,
31+
30: 5,
32+
29: 8,
33+
28: 13,
34+
27: 21,
35+
26: 34,
36+
25: 55,
37+
24: 89,
38+
23: 144,
39+
22: 233,
40+
21: 377,
41+
20: 610,
42+
19: 987,
43+
18: 1597,
44+
17: 2584,
45+
16: 4181,
46+
15: 6765,
47+
14: 10946,
48+
13: 17711,
49+
12: 28657,
50+
11: 46368,
51+
10: 75025,
52+
9: 121393,
53+
8: 196418,
54+
7: 317811,
55+
6: 514229,
56+
5: 832040,
57+
4: 1346269,
58+
3: 2178309,
59+
2: 3524578,
60+
1: 5702887
61+
}, ([key, value]) => [key, new BigNumber(value).times(NAME_FEE_MULTIPLIER)])
62+
63+
// # ref: https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L273
64+
// # name bid timeouts
65+
export const NAME_BID_TIMEOUTS = {
66+
13: BigNumber(0),
67+
12: BigNumber(NAME_BID_TIMEOUT_BLOCKS), // # 480 blocks
68+
8: BigNumber(31).times(NAME_BID_TIMEOUT_BLOCKS), // # 14880 blocks
69+
4: BigNumber(62).times(NAME_BID_TIMEOUT_BLOCKS) // # 29760 blocks
70+
}
71+
72+
// # Tag constant for ids (type uint8)
73+
// # see https://github.com/aeternity/protocol/blob/master/serializations.md#the-id-type
74+
// # <<Tag:1/unsigned-integer-unit:8, Hash:32/binary-unit:8>>
75+
const ID_TAG_ACCOUNT = 1
76+
const ID_TAG_NAME = 2
77+
const ID_TAG_COMMITMENT = 3
78+
const ID_TAG_ORACLE = 4
79+
const ID_TAG_CONTRACT = 5
80+
const ID_TAG_CHANNEL = 6
81+
82+
export const ID_TAG = {
83+
account: ID_TAG_ACCOUNT,
84+
name: ID_TAG_NAME,
85+
commitment: ID_TAG_COMMITMENT,
86+
oracle: ID_TAG_ORACLE,
87+
contract: ID_TAG_CONTRACT,
88+
channel: ID_TAG_CHANNEL
89+
}
90+
91+
export const PREFIX_ID_TAG = {
92+
ak: ID_TAG.account,
93+
nm: ID_TAG.name,
94+
cm: ID_TAG.commitment,
95+
ok: ID_TAG.oracle,
96+
ct: ID_TAG.contract,
97+
ch: ID_TAG.channel
98+
}
99+
100+
export const ID_TAG_PREFIX = mapObject(PREFIX_ID_TAG, ([key, value]) => [value, key])

0 commit comments

Comments
 (0)