@aeternity/aepp-sdk 9.0.1 → 10.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
- package/dist/aepp-sdk.browser-script.js.map +1 -1
- package/dist/aepp-sdk.browser.js +1 -1
- package/dist/aepp-sdk.browser.js.map +1 -1
- package/dist/aepp-sdk.js +1 -1
- package/dist/aepp-sdk.js.map +1 -1
- package/es/account/base.js +30 -122
- package/es/account/base.js.map +1 -1
- package/es/account/memory.js +17 -19
- package/es/account/memory.js.map +1 -1
- package/es/account/multiple.js +73 -164
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +164 -599
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +82 -759
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +78 -315
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +130 -498
- package/es/ae/oracle.js.map +1 -1
- package/es/chain/index.js +1 -1
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +288 -1008
- package/es/chain/node.js.map +1 -1
- package/es/channel/handlers.js +597 -1086
- package/es/channel/handlers.js.map +1 -1
- package/es/channel/index.js +203 -451
- package/es/channel/index.js.map +1 -1
- package/es/channel/internal.js +129 -301
- package/es/channel/internal.js.map +1 -1
- package/es/contract/aci/index.js +319 -480
- package/es/contract/aci/index.js.map +1 -1
- package/es/contract/aci/transformation.js +35 -711
- package/es/contract/aci/transformation.js.map +1 -1
- package/es/contract/compiler.js +129 -203
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +16 -114
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +101 -242
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +1 -1
- package/es/contract/index.js.map +1 -1
- package/es/index.js +1 -2
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +54 -73
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +56 -157
- package/es/node.js.map +1 -1
- package/es/other.d.ts +1 -1
- package/es/tx/builder/helpers.js +38 -75
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +196 -294
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +577 -459
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +1 -1
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +105 -132
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +808 -1628
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +132 -268
- package/es/tx/validator.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
- package/es/utils/aepp-wallet-communication/helpers.js +60 -105
- package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +353 -600
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/schema.js +43 -39
- package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
- package/es/utils/amount-formatter.js +41 -61
- package/es/utils/amount-formatter.js.map +1 -1
- package/es/utils/async-init.js +28 -64
- package/es/utils/async-init.js.map +1 -1
- package/es/utils/bignumber.js +3 -11
- package/es/utils/bignumber.js.map +1 -1
- package/es/utils/bytes.js +5 -9
- package/es/utils/bytes.js.map +1 -1
- package/es/utils/crypto.js +47 -62
- package/es/utils/crypto.js.map +1 -1
- package/es/utils/hd-wallet.js +45 -81
- package/es/utils/hd-wallet.js.map +1 -1
- package/es/utils/json-big.js +16 -49
- package/es/utils/json-big.js.map +1 -1
- package/es/utils/keystore.js +81 -246
- package/es/utils/keystore.js.map +1 -1
- package/es/utils/mptree.js +88 -134
- package/es/utils/mptree.js.map +1 -1
- package/es/utils/other.js +10 -60
- package/es/utils/other.js.map +1 -1
- package/es/utils/semver-satisfies.js +9 -28
- package/es/utils/semver-satisfies.js.map +1 -1
- package/es/utils/string.js +4 -13
- package/es/utils/string.js.map +1 -1
- package/es/utils/swagger.js +85 -224
- package/es/utils/swagger.js.map +1 -1
- package/package.json +44 -40
- package/src/account/multiple.js +18 -19
- package/src/ae/aens.js +25 -21
- package/src/ae/contract.js +32 -163
- package/src/ae/index.js +3 -3
- package/src/ae/oracle.js +18 -14
- package/src/chain/node.js +2 -4
- package/src/channel/handlers.js +0 -1
- package/src/channel/index.js +4 -5
- package/src/contract/aci/index.js +221 -102
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +45 -4
- package/src/contract/ga/helpers.js +1 -8
- package/src/contract/ga/index.js +13 -11
- package/src/index.js +0 -2
- package/src/node-pool/index.js +21 -12
- package/src/node.js +22 -26
- package/src/tx/builder/index.js +2 -1
- package/src/tx/builder/schema.js +2 -1
- package/src/tx/tx.js +147 -143
- package/src/tx/validator.js +9 -7
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +3 -3
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +14 -7
- package/src/contract/aci/helpers.js +0 -140
package/src/node-pool/index.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @example import { NodePool } from '@aeternity/aepp-sdk'
|
|
6
6
|
*/
|
|
7
7
|
import stampit from '@stamp/it'
|
|
8
|
-
import Joi from 'joi-browser'
|
|
9
8
|
import { getNetworkId } from '../node'
|
|
10
9
|
|
|
11
10
|
/**
|
|
@@ -141,17 +140,27 @@ export default stampit({
|
|
|
141
140
|
}))
|
|
142
141
|
},
|
|
143
142
|
validateNodes (nodes) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
// TODO: validate it on TypeScript level instead (to speedup development, save runtime resources)
|
|
144
|
+
if (!Array.isArray(nodes)) throw new Error('"nodes" should be an array')
|
|
145
|
+
const notObject = nodes.map(n => typeof n).find(t => t !== 'object')
|
|
146
|
+
if (notObject) throw new Error(`Each node should be an object, got ${notObject} instead`)
|
|
147
|
+
const wrongFields = nodes.find(n => typeof n.name !== 'string' || typeof n.instance !== 'object')
|
|
148
|
+
if (notObject) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
'Each node should have name (string), instance (object) ' +
|
|
151
|
+
`fields, got ${JSON.stringify(wrongFields)} instead`
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
const wrongInstanceFields = nodes
|
|
155
|
+
.map(n => n.instance)
|
|
156
|
+
.find(i => typeof i.api !== 'object' || typeof i.genesisHash !== 'string' ||
|
|
157
|
+
typeof i.consensusProtocolVersion !== 'number')
|
|
158
|
+
if (wrongInstanceFields) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
'Each node instance should have api (object), consensusProtocolVersion (number), ' +
|
|
161
|
+
`genesisHash (string) fields, got ${JSON.stringify(wrongInstanceFields)} instead`
|
|
162
|
+
)
|
|
163
|
+
}
|
|
155
164
|
}
|
|
156
165
|
},
|
|
157
166
|
props: {
|
package/src/node.js
CHANGED
|
@@ -39,26 +39,6 @@ export function getNetworkId ({ networkId, force = false } = {}) {
|
|
|
39
39
|
return networkId || this.networkId || this.selectedNode.networkId
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* get consensus protocol version
|
|
44
|
-
* @param {Array} protocols Array of protocols
|
|
45
|
-
* @param {Number} height Height
|
|
46
|
-
* @return {Number} version Protocol version
|
|
47
|
-
*/
|
|
48
|
-
async function getConsensusProtocolVersion (protocols = [], height) {
|
|
49
|
-
if (!protocols) throw new Error('Protocols must be an array')
|
|
50
|
-
if (!height) height = (await this.api.getCurrentKeyBlock()).height
|
|
51
|
-
if (height < 0) throw new Error('height must be a number >= 0')
|
|
52
|
-
|
|
53
|
-
return protocols
|
|
54
|
-
.filter(({ effectiveAtHeight }) => height >= effectiveAtHeight)
|
|
55
|
-
.reduce(
|
|
56
|
-
(acc, p) => p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc,
|
|
57
|
-
{ effectiveAtHeight: -1, version: 0 }
|
|
58
|
-
)
|
|
59
|
-
.version
|
|
60
|
-
}
|
|
61
|
-
|
|
62
42
|
/**
|
|
63
43
|
* {@link genSwaggerClient} based Node remote API Stamp
|
|
64
44
|
* @function
|
|
@@ -76,7 +56,15 @@ const Node = AsyncInit.compose({
|
|
|
76
56
|
if (!url) throw new Error('"url" required')
|
|
77
57
|
this.url = url.replace(/\/$/, '')
|
|
78
58
|
this.internalUrl = internalUrl ? internalUrl.replace(/\/$/, '') : this.url
|
|
79
|
-
const client = await genSwaggerClient(`${this.url}/api?oas3`, {
|
|
59
|
+
const client = await genSwaggerClient(`${this.url}/api?oas3`, {
|
|
60
|
+
internalUrl: this.internalUrl,
|
|
61
|
+
responseInterceptor: response => {
|
|
62
|
+
if (response.ok) return
|
|
63
|
+
return Object.assign(response, {
|
|
64
|
+
statusText: `${new URL(response.url).pathname.slice(1)} error: ` + response.body.reason
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
})
|
|
80
68
|
this.version = client.spec.info.version
|
|
81
69
|
if (
|
|
82
70
|
!semverSatisfies(this.version, NODE_GE_VERSION, NODE_LT_VERSION) &&
|
|
@@ -89,8 +77,17 @@ const Node = AsyncInit.compose({
|
|
|
89
77
|
}
|
|
90
78
|
this.api = client.api
|
|
91
79
|
|
|
92
|
-
const {
|
|
93
|
-
|
|
80
|
+
const {
|
|
81
|
+
nodeRevision: revision, genesisKeyBlockHash: genesisHash, networkId,
|
|
82
|
+
protocols, topBlockHeight
|
|
83
|
+
} = await this.api.getStatus()
|
|
84
|
+
this.consensusProtocolVersion = protocols
|
|
85
|
+
.filter(({ effectiveAtHeight }) => topBlockHeight >= effectiveAtHeight)
|
|
86
|
+
.reduce(
|
|
87
|
+
(acc, p) => p.effectiveAtHeight > acc.effectiveAtHeight ? p : acc,
|
|
88
|
+
{ effectiveAtHeight: -1, version: 0 }
|
|
89
|
+
)
|
|
90
|
+
.version
|
|
94
91
|
this.nodeNetworkId = networkId
|
|
95
92
|
return Object.assign(this, { revision, genesisHash })
|
|
96
93
|
},
|
|
@@ -103,8 +100,7 @@ const Node = AsyncInit.compose({
|
|
|
103
100
|
version: this.version,
|
|
104
101
|
consensusProtocolVersion: this.consensusProtocolVersion
|
|
105
102
|
}
|
|
106
|
-
}
|
|
107
|
-
getConsensusProtocolVersion
|
|
103
|
+
}
|
|
108
104
|
},
|
|
109
105
|
props: {
|
|
110
106
|
version: null,
|
|
@@ -113,7 +109,7 @@ const Node = AsyncInit.compose({
|
|
|
113
109
|
}
|
|
114
110
|
})
|
|
115
111
|
|
|
116
|
-
const NODE_GE_VERSION = '6.
|
|
112
|
+
const NODE_GE_VERSION = '6.2.0'
|
|
117
113
|
const NODE_LT_VERSION = '7.0.0'
|
|
118
114
|
|
|
119
115
|
export default Node
|
package/src/tx/builder/index.js
CHANGED
|
@@ -256,7 +256,8 @@ function buildFee (txType, { params, gas = 0, multiplier, vsn }) {
|
|
|
256
256
|
.plus(TX_FEE_OTHER_GAS(txType, txSize, {
|
|
257
257
|
relativeTtl: getOracleRelativeTtl(params, txType),
|
|
258
258
|
innerTxSize: [TX_TYPE.gaMeta, TX_TYPE.payingFor].includes(txType)
|
|
259
|
-
? params.tx.tx.encodedTx.rlpEncoded.length
|
|
259
|
+
? params.tx.tx.encodedTx.rlpEncoded.length
|
|
260
|
+
: 0
|
|
260
261
|
}))
|
|
261
262
|
.times(multiplier)
|
|
262
263
|
}
|
package/src/tx/builder/schema.js
CHANGED
|
@@ -48,7 +48,8 @@ export const NAME_ID_KEY = {
|
|
|
48
48
|
ct: 'contract_pubkey',
|
|
49
49
|
ch: 'channel'
|
|
50
50
|
}
|
|
51
|
-
// #
|
|
51
|
+
// # https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L290
|
|
52
|
+
// # https://github.com/aeternity/protocol/blob/master/AENS.md#protocol-fees-and-protection-times
|
|
52
53
|
// # bid ranges:
|
|
53
54
|
export const NAME_BID_RANGES = {
|
|
54
55
|
31: BigNumber(3).times(NAME_FEE_MULTIPLIER),
|