@aeternity/aepp-sdk 10.0.0 → 11.0.0
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/README.md +15 -14
- package/dist/aepp-sdk.browser-script.js +1 -1
- package/dist/aepp-sdk.browser-script.js.LICENSE.txt +7 -27
- 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 → base.mjs} +20 -10
- package/es/account/base.mjs.map +1 -0
- package/es/account/{memory.js → memory.mjs} +29 -14
- package/es/account/memory.mjs.map +1 -0
- package/es/account/{multiple.js → multiple.mjs} +10 -9
- package/es/account/multiple.mjs.map +1 -0
- package/es/ae/{aens.js → aens.mjs} +18 -22
- package/es/ae/aens.mjs.map +1 -0
- package/es/ae/{aepp.js → aepp.mjs} +9 -9
- package/es/ae/aepp.mjs.map +1 -0
- package/es/ae/contract.mjs +159 -0
- package/es/ae/contract.mjs.map +1 -0
- package/es/ae/{index.js → index.mjs} +8 -7
- package/es/ae/index.mjs.map +1 -0
- package/es/ae/{oracle.js → oracle.mjs} +33 -16
- package/es/ae/oracle.mjs.map +1 -0
- package/es/ae/{universal.js → universal.mjs} +10 -10
- package/es/ae/universal.mjs.map +1 -0
- package/es/ae/{wallet.js → wallet.mjs} +10 -10
- package/es/ae/wallet.mjs.map +1 -0
- package/es/aepp-wallet-communication/schema.d.ts +74 -0
- package/es/bignumber.d.ts +1 -7
- package/es/chain/{index.js → index.mjs} +20 -4
- package/es/chain/index.mjs.map +1 -0
- package/es/chain/{node.js → node.mjs} +121 -73
- package/es/chain/node.mjs.map +1 -0
- package/es/channel/{handlers.js → handlers.mjs} +18 -20
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/{index.js → index.mjs} +7 -7
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/{internal.js → internal.mjs} +49 -32
- package/es/channel/internal.mjs.map +1 -0
- package/es/contract/aci.mjs +477 -0
- package/es/contract/aci.mjs.map +1 -0
- package/es/contract/compiler.mjs +115 -0
- package/es/contract/compiler.mjs.map +1 -0
- package/es/contract/ga/helpers.mjs +30 -0
- package/es/contract/ga/helpers.mjs.map +1 -0
- package/es/contract/ga/{index.js → index.mjs} +36 -28
- package/es/contract/ga/index.mjs.map +1 -0
- package/es/errors.d.ts +284 -0
- package/es/index.mjs +57 -0
- package/es/index.mjs.map +1 -0
- package/es/node-pool/{index.js → index.mjs} +11 -10
- package/es/node-pool/index.mjs.map +1 -0
- package/es/{node.js → node.mjs} +9 -8
- package/es/node.mjs.map +1 -0
- package/es/tx/builder/field-types.mjs +74 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/{helpers.js → helpers.mjs} +114 -56
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/{index.js → index.mjs} +79 -68
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/{schema.js → schema.mjs} +11 -65
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/{index.js → index.mjs} +5 -2
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/{tx-object.js → tx-object.mjs} +22 -15
- package/es/tx/tx-object.mjs.map +1 -0
- package/es/tx/{tx.js → tx.mjs} +15 -14
- package/es/tx/tx.mjs.map +1 -0
- package/es/tx/{validator.js → validator.mjs} +72 -33
- package/es/tx/validator.mjs.map +1 -0
- package/es/typings/blakejs/index.d.mjs +2 -0
- package/es/typings/blakejs/{index.d.js.map → index.d.mjs.map} +1 -1
- package/es/utils/aepp-wallet-communication/connection/{browser-runtime.js → browser-runtime.mjs} +7 -6
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/{browser-window-message.js → browser-window-message.mjs} +10 -11
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/{index.js → index.mjs} +5 -2
- package/es/utils/aepp-wallet-communication/connection/index.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{content-script-bridge.js → content-script-bridge.mjs} +6 -5
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{helpers.js → helpers.mjs} +3 -14
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/{aepp-rpc.js → aepp-rpc.mjs} +113 -67
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/{rpc-client.js → rpc-client.mjs} +14 -9
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/{wallet-rpc.js → wallet-rpc.mjs} +71 -63
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/schema.mjs +102 -0
- package/es/utils/aepp-wallet-communication/schema.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/{wallet-detector.js → wallet-detector.mjs} +6 -5
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/utils/{amount-formatter.js → amount-formatter.mjs} +14 -7
- package/es/utils/amount-formatter.mjs.map +1 -0
- package/es/utils/{async-init.js → async-init.mjs} +8 -11
- package/es/utils/async-init.mjs.map +1 -0
- package/es/utils/{bignumber.js → bignumber.mjs} +2 -9
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/utils/{bytes.js → bytes.mjs} +16 -8
- package/es/utils/bytes.mjs.map +1 -0
- package/es/utils/{crypto-ts.js → crypto-ts.mjs} +11 -3
- package/es/utils/crypto-ts.mjs.map +1 -0
- package/es/utils/{crypto.js → crypto.mjs} +40 -105
- package/es/utils/crypto.mjs.map +1 -0
- package/es/utils/errors.mjs +689 -0
- package/es/utils/errors.mjs.map +1 -0
- package/es/utils/{hd-wallet.js → hd-wallet.mjs} +33 -34
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/{json-big.js → json-big.mjs} +1 -1
- package/es/utils/{json-big.js.map → json-big.mjs.map} +1 -1
- package/es/utils/{keystore.js → keystore.mjs} +63 -51
- package/es/utils/keystore.mjs.map +1 -0
- package/es/utils/{mptree.js → mptree.mjs} +21 -12
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/{other.js → other.mjs} +2 -2
- package/es/utils/other.mjs.map +1 -0
- package/es/utils/{semver-satisfies.js → semver-satisfies.mjs} +1 -1
- package/es/utils/{semver-satisfies.js.map → semver-satisfies.mjs.map} +1 -1
- package/es/utils/{string.js → string.mjs} +1 -1
- package/es/utils/{string.js.map → string.mjs.map} +1 -1
- package/es/utils/{swagger.js → swagger.mjs} +46 -14
- package/es/utils/swagger.mjs.map +1 -0
- package/package.json +46 -55
- package/src/account/memory.js +13 -8
- package/src/account/multiple.js +12 -4
- package/src/ae/aens.js +12 -17
- package/src/ae/aepp.js +2 -2
- package/src/ae/contract.js +15 -152
- package/src/ae/index.js +2 -1
- package/src/ae/oracle.js +25 -10
- package/src/ae/universal.js +2 -2
- package/src/ae/wallet.js +2 -2
- package/src/chain/index.js +21 -2
- package/src/chain/node.js +80 -53
- package/src/channel/handlers.js +20 -17
- package/src/channel/internal.js +30 -24
- package/src/contract/{aci/index.js → aci.js} +152 -93
- package/src/contract/compiler.js +22 -117
- package/src/contract/ga/helpers.js +7 -5
- package/src/contract/ga/index.js +27 -24
- package/src/index.js +7 -8
- package/src/node-pool/index.js +9 -8
- package/src/node.js +5 -7
- package/src/tx/builder/field-types.js +61 -0
- package/src/tx/builder/helpers.js +113 -58
- package/src/tx/builder/index.js +39 -34
- package/src/tx/builder/schema.js +11 -25
- package/src/tx/tx-object.js +10 -9
- package/src/tx/tx.js +17 -8
- package/src/tx/validator.js +25 -5
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +8 -3
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +10 -6
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +5 -4
- package/src/utils/aepp-wallet-communication/helpers.js +2 -12
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +81 -55
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +15 -6
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +60 -49
- package/src/utils/aepp-wallet-communication/schema.ts +80 -0
- package/src/utils/aepp-wallet-communication/wallet-detector.js +3 -2
- package/src/utils/amount-formatter.ts +4 -3
- package/src/utils/async-init.js +10 -6
- package/src/utils/bignumber.ts +1 -9
- package/src/utils/bytes.ts +3 -2
- package/src/utils/crypto-ts.ts +2 -2
- package/src/utils/crypto.js +9 -92
- package/src/utils/errors.ts +683 -0
- package/src/utils/hd-wallet.js +11 -26
- package/src/utils/keystore.js +47 -51
- package/src/utils/mptree.ts +12 -6
- package/src/utils/swagger.js +67 -44
- package/CHANGELOG.md +0 -1603
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -312
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js.map +0 -1
- package/es/ae/universal.js.map +0 -1
- package/es/ae/wallet.js.map +0 -1
- package/es/chain/index.js.map +0 -1
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js.map +0 -1
- package/es/contract/aci/helpers.js +0 -298
- package/es/contract/aci/helpers.js.map +0 -1
- package/es/contract/aci/index.js +0 -361
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -66
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -244
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -22
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -162
- package/es/contract/index.js.map +0 -1
- package/es/index.js +0 -57
- package/es/index.js.map +0 -1
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js.map +0 -1
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js.map +0 -1
- package/es/typings/blakejs/index.d.js +0 -2
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +0 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +0 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +0 -1
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -107
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js.map +0 -1
- package/es/utils/bytes.js.map +0 -1
- package/es/utils/crypto-ts.js.map +0 -1
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js.map +0 -1
- package/es/utils/swagger.js.map +0 -1
- package/src/contract/aci/transformation.js +0 -72
- package/src/contract/index.js +0 -163
- package/src/utils/aepp-wallet-communication/schema.js +0 -108
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import * as R from 'ramda'
|
|
2
1
|
import BigNumber from 'bignumber.js'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
decodeBase58Check,
|
|
6
|
-
decodeBase64Check,
|
|
7
|
-
encodeBase58Check, encodeBase64Check,
|
|
8
|
-
hash,
|
|
9
|
-
salt
|
|
10
|
-
} from '../../utils/crypto'
|
|
2
|
+
import bs58 from 'bs58'
|
|
3
|
+
import { hash, salt, sha256hash } from '../../utils/crypto'
|
|
11
4
|
import { toBytes } from '../../utils/bytes'
|
|
12
5
|
import {
|
|
13
6
|
ID_TAG_PREFIX,
|
|
14
7
|
PREFIX_ID_TAG,
|
|
15
8
|
NAME_BID_RANGES,
|
|
16
|
-
NAME_BID_MAX_LENGTH,
|
|
17
|
-
NAME_FEE,
|
|
18
9
|
NAME_FEE_BID_INCREMENT,
|
|
19
10
|
NAME_BID_TIMEOUTS,
|
|
20
11
|
NAME_MAX_LENGTH_FEE,
|
|
21
12
|
POINTER_KEY_BY_PREFIX
|
|
22
13
|
} from './schema'
|
|
23
14
|
import { ceil } from '../../utils/bignumber'
|
|
15
|
+
import {
|
|
16
|
+
PrefixMismatchError,
|
|
17
|
+
DecodeError,
|
|
18
|
+
EncodeError,
|
|
19
|
+
PayloadLengthError,
|
|
20
|
+
TagNotFoundError,
|
|
21
|
+
PrefixNotFoundError,
|
|
22
|
+
InvalidNameError,
|
|
23
|
+
IllegalBidFeeError,
|
|
24
|
+
NoDefaultAensPointerError,
|
|
25
|
+
ArgumentError,
|
|
26
|
+
InvalidChecksumError
|
|
27
|
+
} from '../../utils/errors'
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* JavaScript-based Transaction builder helper function's
|
|
@@ -31,8 +35,6 @@ import { ceil } from '../../utils/bignumber'
|
|
|
31
35
|
|
|
32
36
|
export const createSalt = salt
|
|
33
37
|
|
|
34
|
-
const base64Types = ['tx', 'st', 'ss', 'pi', 'ov', 'or', 'cb', 'cs', 'ba']
|
|
35
|
-
|
|
36
38
|
/**
|
|
37
39
|
* Build a contract public key
|
|
38
40
|
* @function
|
|
@@ -78,11 +80,11 @@ export function formatSalt (salt) {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
/**
|
|
81
|
-
* Encode
|
|
83
|
+
* Encode an AENS name
|
|
82
84
|
* @function
|
|
83
85
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
84
86
|
* @param {String} name Name to encode
|
|
85
|
-
* @return {String} `nm_` prefixed encoded
|
|
87
|
+
* @return {String} `nm_` prefixed encoded AENS name
|
|
86
88
|
*/
|
|
87
89
|
export function produceNameId (name) {
|
|
88
90
|
ensureNameValid(name)
|
|
@@ -103,7 +105,46 @@ export function produceNameId (name) {
|
|
|
103
105
|
*/
|
|
104
106
|
export function commitmentHash (name, salt = createSalt()) {
|
|
105
107
|
ensureNameValid(name)
|
|
106
|
-
return
|
|
108
|
+
return encode(hash(Buffer.concat([Buffer.from(name.toLowerCase()), formatSalt(salt)])), 'cm')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// based on https://github.com/aeternity/protocol/blob/master/node/api/api_encoding.md
|
|
112
|
+
const base64Types = ['ba', 'cb', 'or', 'ov', 'pi', 'ss', 'cs', 'ck', 'cv', 'st', 'tx']
|
|
113
|
+
const base58Types = ['ak', 'bf', 'bs', 'bx', 'ch', 'cm', 'ct', 'kh', 'mh', 'nm', 'ok', 'oq', 'pp', 'sg', 'th']
|
|
114
|
+
// TODO: add all types with a fixed length
|
|
115
|
+
const typesLength = {
|
|
116
|
+
ak: 32,
|
|
117
|
+
ct: 32,
|
|
118
|
+
ok: 32
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function ensureValidLength (data, type) {
|
|
122
|
+
if (!typesLength[type]) return
|
|
123
|
+
if (data.length === typesLength[type]) return
|
|
124
|
+
throw new PayloadLengthError(`Payload should be ${typesLength[type]} bytes, got ${data.length} instead`)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const getChecksum = payload => sha256hash(sha256hash(payload)).slice(0, 4)
|
|
128
|
+
|
|
129
|
+
const addChecksum = (input) => {
|
|
130
|
+
const payload = Buffer.from(input)
|
|
131
|
+
return Buffer.concat([payload, getChecksum(payload)])
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function getPayload (buffer) {
|
|
135
|
+
const payload = buffer.slice(0, -4)
|
|
136
|
+
if (!getChecksum(payload).equals(buffer.slice(-4))) throw new InvalidChecksumError()
|
|
137
|
+
return payload
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const base64 = {
|
|
141
|
+
encode: buffer => addChecksum(buffer).toString('base64'),
|
|
142
|
+
decode: string => getPayload(Buffer.from(string, 'base64'))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const base58 = {
|
|
146
|
+
encode: buffer => bs58.encode(addChecksum(buffer)),
|
|
147
|
+
decode: string => getPayload(bs58.decode(string))
|
|
107
148
|
}
|
|
108
149
|
|
|
109
150
|
/**
|
|
@@ -115,13 +156,21 @@ export function commitmentHash (name, salt = createSalt()) {
|
|
|
115
156
|
* @return {Buffer} Decoded data
|
|
116
157
|
*/
|
|
117
158
|
export function decode (data, requiredPrefix) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
if (
|
|
159
|
+
if (typeof data !== 'string') throw new DecodeError(`Encoded should be a string, got ${data} instead`)
|
|
160
|
+
const [prefix, encodedPayload, extra] = data.split('_')
|
|
161
|
+
if (!encodedPayload) throw new DecodeError(`Encoded string missing payload: ${data}`)
|
|
162
|
+
if (extra) throw new DecodeError(`Encoded string have extra parts: ${data}`)
|
|
121
163
|
if (requiredPrefix && requiredPrefix !== prefix) {
|
|
122
|
-
throw new
|
|
164
|
+
throw new PrefixMismatchError(prefix, requiredPrefix)
|
|
165
|
+
}
|
|
166
|
+
const decoder = (base64Types.includes(prefix) && base64.decode) ||
|
|
167
|
+
(base58Types.includes(prefix) && base58.decode)
|
|
168
|
+
if (!decoder) {
|
|
169
|
+
throw new DecodeError(`Encoded string have unknown type: ${prefix}`)
|
|
123
170
|
}
|
|
124
|
-
|
|
171
|
+
const payload = decoder(encodedPayload)
|
|
172
|
+
ensureValidLength(payload, prefix)
|
|
173
|
+
return payload
|
|
125
174
|
}
|
|
126
175
|
|
|
127
176
|
/**
|
|
@@ -133,9 +182,13 @@ export function decode (data, requiredPrefix) {
|
|
|
133
182
|
* @return {String} Encoded string Base58check or Base64check data
|
|
134
183
|
*/
|
|
135
184
|
export function encode (data, type) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
185
|
+
const encoder = (base64Types.includes(type) && base64.encode) ||
|
|
186
|
+
(base58Types.includes(type) && base58.encode)
|
|
187
|
+
if (!encoder) {
|
|
188
|
+
throw new EncodeError(`Unknown type: ${type}`)
|
|
189
|
+
}
|
|
190
|
+
ensureValidLength(data, type)
|
|
191
|
+
return `${type}_${encoder(data)}`
|
|
139
192
|
}
|
|
140
193
|
|
|
141
194
|
/**
|
|
@@ -146,12 +199,10 @@ export function encode (data, type) {
|
|
|
146
199
|
* @return {Buffer} Buffer Buffer with ID tag and decoded HASh
|
|
147
200
|
*/
|
|
148
201
|
export function writeId (hashId) {
|
|
149
|
-
if (typeof hashId !== 'string')
|
|
150
|
-
throw new Error(`Address should be a string, got ${hashId} instead`)
|
|
151
|
-
}
|
|
202
|
+
if (typeof hashId !== 'string') throw new ArgumentError('hashId', 'a string', hashId)
|
|
152
203
|
const prefix = hashId.slice(0, 2)
|
|
153
204
|
const idTag = PREFIX_ID_TAG[prefix]
|
|
154
|
-
if (!idTag) throw new
|
|
205
|
+
if (!idTag) throw new TagNotFoundError(prefix)
|
|
155
206
|
return Buffer.from([...toBytes(idTag), ...decode(hashId, prefix)])
|
|
156
207
|
}
|
|
157
208
|
|
|
@@ -163,9 +214,9 @@ export function writeId (hashId) {
|
|
|
163
214
|
* @return {String} Encoided hash string with prefix
|
|
164
215
|
*/
|
|
165
216
|
export function readId (buf) {
|
|
166
|
-
const tag = buf.readUIntBE(0, 1)
|
|
217
|
+
const tag = Buffer.from(buf).readUIntBE(0, 1)
|
|
167
218
|
const prefix = ID_TAG_PREFIX[tag]
|
|
168
|
-
if (!prefix) throw new
|
|
219
|
+
if (!prefix) throw new PrefixNotFoundError(tag)
|
|
169
220
|
return encode(buf.slice(1, buf.length), prefix)
|
|
170
221
|
}
|
|
171
222
|
|
|
@@ -188,7 +239,7 @@ export function writeInt (val) {
|
|
|
188
239
|
* @return {String} Buffer Buffer from number(BigEndian)
|
|
189
240
|
*/
|
|
190
241
|
export function readInt (buf = Buffer.from([])) {
|
|
191
|
-
return BigNumber(buf.toString('hex'), 16).toString(10)
|
|
242
|
+
return new BigNumber(Buffer.from(buf).toString('hex'), 16).toString(10)
|
|
192
243
|
}
|
|
193
244
|
|
|
194
245
|
/**
|
|
@@ -225,8 +276,10 @@ export function readPointers (pointers) {
|
|
|
225
276
|
)
|
|
226
277
|
}
|
|
227
278
|
|
|
279
|
+
const AENS_SUFFIX = '.chain'
|
|
280
|
+
|
|
228
281
|
/**
|
|
229
|
-
* Ensure that name is valid
|
|
282
|
+
* Ensure that AENS name is valid
|
|
230
283
|
* @function
|
|
231
284
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
232
285
|
* @param {string} name
|
|
@@ -234,12 +287,12 @@ export function readPointers (pointers) {
|
|
|
234
287
|
* @throws Error
|
|
235
288
|
*/
|
|
236
289
|
export function ensureNameValid (name) {
|
|
237
|
-
if (!name || typeof name !== 'string') throw new
|
|
238
|
-
if (!name.endsWith(
|
|
290
|
+
if (!name || typeof name !== 'string') throw new InvalidNameError('Name must be a string')
|
|
291
|
+
if (!name.endsWith(AENS_SUFFIX)) throw new InvalidNameError(`Name should end with ${AENS_SUFFIX}: ${name}`)
|
|
239
292
|
}
|
|
240
293
|
|
|
241
294
|
/**
|
|
242
|
-
* Is name valid
|
|
295
|
+
* Is AENS name valid
|
|
243
296
|
* @function
|
|
244
297
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
245
298
|
* @param {string} name
|
|
@@ -263,36 +316,36 @@ export function getDefaultPointerKey (identifier) {
|
|
|
263
316
|
decode(identifier)
|
|
264
317
|
const prefix = identifier.substr(0, 2)
|
|
265
318
|
return POINTER_KEY_BY_PREFIX[prefix] ||
|
|
266
|
-
(() => { throw new
|
|
319
|
+
(() => { throw new NoDefaultAensPointerError(prefix) })()
|
|
267
320
|
}
|
|
268
321
|
|
|
269
322
|
/**
|
|
270
|
-
* Get the minimum name fee
|
|
323
|
+
* Get the minimum AENS name fee
|
|
271
324
|
* @function
|
|
272
325
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
273
|
-
* @param {String}
|
|
274
|
-
* @return {String} the minimum fee for the
|
|
326
|
+
* @param {String} name the AENS name to get the fee for
|
|
327
|
+
* @return {String} the minimum fee for the AENS name auction
|
|
275
328
|
*/
|
|
276
|
-
export function getMinimumNameFee (
|
|
277
|
-
|
|
278
|
-
|
|
329
|
+
export function getMinimumNameFee (name) {
|
|
330
|
+
ensureNameValid(name)
|
|
331
|
+
const nameLength = name.length - AENS_SUFFIX.length
|
|
332
|
+
return NAME_BID_RANGES[Math.min(nameLength, NAME_MAX_LENGTH_FEE)]
|
|
279
333
|
}
|
|
280
334
|
|
|
281
335
|
/**
|
|
282
336
|
* Compute bid fee for AENS auction
|
|
283
337
|
* @function
|
|
284
338
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
285
|
-
* @param {String}
|
|
339
|
+
* @param {String} name the AENS name to get the fee for
|
|
286
340
|
* @param {Number|String} startFee Auction start fee
|
|
287
341
|
* @param {Number} [increment=0.5] Bid multiplier(In percentage, must be between 0 and 1)
|
|
288
342
|
* @return {String} Bid fee
|
|
289
343
|
*/
|
|
290
|
-
export function computeBidFee (
|
|
291
|
-
if (!(Number(increment) === increment && increment % 1 !== 0)) throw new
|
|
292
|
-
if (increment < NAME_FEE_BID_INCREMENT) throw new
|
|
344
|
+
export function computeBidFee (name, startFee, increment = NAME_FEE_BID_INCREMENT) {
|
|
345
|
+
if (!(Number(increment) === increment && increment % 1 !== 0)) throw new IllegalBidFeeError(`Increment must be float. Current increment ${increment}`)
|
|
346
|
+
if (increment < NAME_FEE_BID_INCREMENT) throw new IllegalBidFeeError(`minimum increment percentage is ${NAME_FEE_BID_INCREMENT}`)
|
|
293
347
|
return ceil(
|
|
294
|
-
BigNumber(
|
|
295
|
-
.times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1))
|
|
348
|
+
BigNumber(startFee ?? getMinimumNameFee(name)).times(BigNumber(NAME_FEE_BID_INCREMENT).plus(1))
|
|
296
349
|
)
|
|
297
350
|
}
|
|
298
351
|
|
|
@@ -300,26 +353,28 @@ export function computeBidFee (domain, startFee = NAME_FEE, increment = NAME_FEE
|
|
|
300
353
|
* Compute auction end height
|
|
301
354
|
* @function
|
|
302
355
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
303
|
-
* @param {String}
|
|
356
|
+
* @param {String} name
|
|
304
357
|
* @param {Number|String} claimHeight Auction starting height
|
|
305
358
|
* @return {String} Auction end height
|
|
306
359
|
*/
|
|
307
|
-
export function computeAuctionEndBlock (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
[
|
|
313
|
-
|
|
360
|
+
export function computeAuctionEndBlock (name, claimHeight) {
|
|
361
|
+
ensureNameValid(name)
|
|
362
|
+
const length = name.length - AENS_SUFFIX.length
|
|
363
|
+
const h = (length <= 4 && NAME_BID_TIMEOUTS[4]) ||
|
|
364
|
+
(length <= 8 && NAME_BID_TIMEOUTS[8]) ||
|
|
365
|
+
(length <= 12 && NAME_BID_TIMEOUTS[12]) ||
|
|
366
|
+
NAME_BID_TIMEOUTS[13]
|
|
367
|
+
return h.plus(claimHeight).toString(10)
|
|
314
368
|
}
|
|
315
369
|
|
|
316
370
|
/**
|
|
317
371
|
* Is name accept going to auction
|
|
318
372
|
* @function
|
|
319
373
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder/helpers
|
|
320
|
-
* @param {String} name
|
|
374
|
+
* @param {String} name
|
|
321
375
|
* @return {Boolean}
|
|
322
376
|
*/
|
|
323
377
|
export function isAuctionName (name) {
|
|
324
|
-
|
|
378
|
+
ensureNameValid(name)
|
|
379
|
+
return name.length < 13 + AENS_SUFFIX.length
|
|
325
380
|
}
|
package/src/tx/builder/index.js
CHANGED
|
@@ -2,18 +2,17 @@ import BigNumber from 'bignumber.js'
|
|
|
2
2
|
import { decode as rlpDecode, encode as rlpEncode } from 'rlp'
|
|
3
3
|
import { AE_AMOUNT_FORMATS, formatAmount } from '../../utils/amount-formatter'
|
|
4
4
|
import { hash } from '../../utils/crypto'
|
|
5
|
+
import { Field } from './field-types'
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
DEFAULT_FEE,
|
|
8
9
|
FIELD_TYPES,
|
|
9
10
|
OBJECT_ID_TX_TYPE,
|
|
10
|
-
PREFIX_ID_TAG,
|
|
11
11
|
TX_DESERIALIZATION_SCHEMA,
|
|
12
12
|
TX_FEE_BASE_GAS,
|
|
13
13
|
TX_FEE_OTHER_GAS,
|
|
14
14
|
TX_SERIALIZATION_SCHEMA,
|
|
15
15
|
TX_TYPE,
|
|
16
|
-
VALIDATION_MESSAGE,
|
|
17
16
|
VSN
|
|
18
17
|
} from './schema'
|
|
19
18
|
import {
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
} from './helpers'
|
|
29
28
|
import { toBytes } from '../../utils/bytes'
|
|
30
29
|
import MPTree from '../../utils/mptree'
|
|
30
|
+
import { InvalidTxParamsError, SchemaNotFoundError } from '../../utils/errors'
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* JavaScript-based Transaction builder
|
|
@@ -50,7 +50,6 @@ function deserializeField (value, type, prefix) {
|
|
|
50
50
|
return { vmVersion: readInt(Buffer.from([vm])), abiVersion: readInt(Buffer.from([abi])) }
|
|
51
51
|
}
|
|
52
52
|
case FIELD_TYPES.amount:
|
|
53
|
-
return readInt(value)
|
|
54
53
|
case FIELD_TYPES.int:
|
|
55
54
|
return readInt(value)
|
|
56
55
|
case FIELD_TYPES.id:
|
|
@@ -99,11 +98,12 @@ function deserializeField (value, type, prefix) {
|
|
|
99
98
|
{}
|
|
100
99
|
)
|
|
101
100
|
default:
|
|
101
|
+
if (type.prototype instanceof Field) return type.deserialize(value)
|
|
102
102
|
return value
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
function serializeField (value, type, prefix) {
|
|
106
|
+
function serializeField (value, type, prefix, params) {
|
|
107
107
|
switch (type) {
|
|
108
108
|
case FIELD_TYPES.amount:
|
|
109
109
|
case FIELD_TYPES.int:
|
|
@@ -144,40 +144,45 @@ function serializeField (value, type, prefix) {
|
|
|
144
144
|
default: return value
|
|
145
145
|
}
|
|
146
146
|
default:
|
|
147
|
+
if (type.prototype instanceof Field) return type.serialize(value, params)
|
|
147
148
|
return value
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
function validateField (value,
|
|
152
|
-
const assert = (valid, params) => valid ? {} : { [key]: VALIDATION_MESSAGE[type](params) }
|
|
152
|
+
function validateField (value, type, prefix) {
|
|
153
153
|
// All fields are required
|
|
154
|
-
if (value === undefined || value === null) return
|
|
154
|
+
if (value === undefined || value === null) return 'Field is required'
|
|
155
155
|
|
|
156
156
|
// Validate type of value
|
|
157
157
|
switch (type) {
|
|
158
158
|
case FIELD_TYPES.amount:
|
|
159
159
|
case FIELD_TYPES.int: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
if (isNaN(value) && !BigNumber.isBigNumber(value)) {
|
|
161
|
+
return `${value} is not of type Number or BigNumber`
|
|
162
|
+
}
|
|
163
|
+
if (new BigNumber(value).lt(0)) return `${value} must be >= 0`
|
|
164
|
+
return
|
|
165
165
|
}
|
|
166
166
|
case FIELD_TYPES.id: {
|
|
167
167
|
const prefixes = Array.isArray(prefix) ? prefix : [prefix]
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
if (!prefixes.includes(value.split('_')[0])) {
|
|
169
|
+
return `'${value}' prefix doesn't match expected prefix '${prefix}'`
|
|
170
|
+
}
|
|
171
|
+
return
|
|
170
172
|
}
|
|
171
|
-
case FIELD_TYPES.binary:
|
|
172
|
-
return assert(value.split('_')[0] === prefix, { prefix, value })
|
|
173
|
-
case FIELD_TYPES.string:
|
|
174
|
-
return assert(true)
|
|
175
173
|
case FIELD_TYPES.ctVersion:
|
|
176
|
-
|
|
174
|
+
if (!value?.abiVersion || !value?.vmVersion) {
|
|
175
|
+
return 'Value must be an object with "vmVersion" and "abiVersion" fields'
|
|
176
|
+
}
|
|
177
|
+
return
|
|
177
178
|
case FIELD_TYPES.pointers:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
if (!Array.isArray(value)) return 'Value must be of type Array'
|
|
180
|
+
if (value.some(p => !p?.key || !p?.id)) {
|
|
181
|
+
return 'Value must contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\''
|
|
182
|
+
}
|
|
183
|
+
if (value.length > 32) {
|
|
184
|
+
return `Expected 32 pointers or less, got ${value.length} instead`
|
|
185
|
+
}
|
|
181
186
|
}
|
|
182
187
|
}
|
|
183
188
|
|
|
@@ -297,14 +302,14 @@ export function calculateFee (fee = 0, txType, { gas = 0, params, showWarning =
|
|
|
297
302
|
* @return {Object} Object with validation errors
|
|
298
303
|
*/
|
|
299
304
|
export function validateParams (params, schema, { excludeKeys = [] }) {
|
|
300
|
-
return
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
(
|
|
304
|
-
|
|
305
|
-
),
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
return Object.fromEntries(
|
|
306
|
+
schema
|
|
307
|
+
// TODO: allow optional keys in schema
|
|
308
|
+
.filter(([key]) => !excludeKeys.includes(key) &&
|
|
309
|
+
!['payload', 'nameFee', 'deposit'].includes(key))
|
|
310
|
+
.map(([key, type, prefix]) => [key, validateField(params[key], type, prefix)])
|
|
311
|
+
.filter(([, message]) => message)
|
|
312
|
+
)
|
|
308
313
|
}
|
|
309
314
|
|
|
310
315
|
/**
|
|
@@ -331,11 +336,11 @@ export function buildRawTx (
|
|
|
331
336
|
// Validation
|
|
332
337
|
const valid = validateParams(params, schema, { excludeKeys })
|
|
333
338
|
if (Object.keys(valid).length) {
|
|
334
|
-
throw new
|
|
339
|
+
throw new InvalidTxParamsError('Transaction build error. ' + JSON.stringify(valid))
|
|
335
340
|
}
|
|
336
341
|
|
|
337
342
|
return filteredSchema
|
|
338
|
-
.map(([key, fieldType, prefix]) => serializeField(params[key], fieldType, prefix))
|
|
343
|
+
.map(([key, fieldType, prefix]) => serializeField(params[key], fieldType, prefix, params))
|
|
339
344
|
}
|
|
340
345
|
|
|
341
346
|
/**
|
|
@@ -371,10 +376,10 @@ const getSchema = ({ vsn, objId, type }) => {
|
|
|
371
376
|
const schema = isDeserialize ? TX_DESERIALIZATION_SCHEMA : TX_SERIALIZATION_SCHEMA
|
|
372
377
|
|
|
373
378
|
if (!schema[firstKey]) {
|
|
374
|
-
throw new
|
|
379
|
+
throw new SchemaNotFoundError(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type}`)
|
|
375
380
|
}
|
|
376
381
|
if (!schema[firstKey][vsn]) {
|
|
377
|
-
throw new
|
|
382
|
+
throw new SchemaNotFoundError(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type} version ${vsn}`)
|
|
378
383
|
}
|
|
379
384
|
return schema[firstKey][vsn]
|
|
380
385
|
}
|
package/src/tx/builder/schema.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// # https://github.com/aeternity/protocol/blob/master/serializations.md#binary-serialization
|
|
9
9
|
|
|
10
10
|
import BigNumber from 'bignumber.js'
|
|
11
|
+
import { Name, NameId, NameFee, Deposit } from './field-types'
|
|
11
12
|
|
|
12
13
|
export const VSN = 1
|
|
13
14
|
export const VSN_2 = 2
|
|
@@ -20,9 +21,8 @@ export const ORACLE_TTL = { type: 'delta', value: 500 }
|
|
|
20
21
|
export const QUERY_TTL = { type: 'delta', value: 10 }
|
|
21
22
|
export const RESPONSE_TTL = { type: 'delta', value: 10 }
|
|
22
23
|
// # CONTRACT
|
|
23
|
-
export const DEPOSIT = 0
|
|
24
24
|
export const AMOUNT = 0
|
|
25
|
-
export const
|
|
25
|
+
export const GAS_MAX = 1600000 - 21000
|
|
26
26
|
export const MIN_GAS_PRICE = 1e9
|
|
27
27
|
export const MAX_AUTH_FUN_GAS = 50000
|
|
28
28
|
export const DRY_RUN_ACCOUNT = { pub: 'ak_11111111111111111111111111111111273Yts', amount: '100000000000000000000000000000000000' }
|
|
@@ -34,7 +34,6 @@ export const NAME_TTL = 180000
|
|
|
34
34
|
export const NAME_MAX_TTL = 36000
|
|
35
35
|
export const NAME_MAX_CLIENT_TTL = 84600
|
|
36
36
|
export const CLIENT_TTL = NAME_MAX_CLIENT_TTL
|
|
37
|
-
export const NAME_FEE = 0
|
|
38
37
|
// # see https://github.com/aeternity/aeternity/blob/72e440b8731422e335f879a31ecbbee7ac23a1cf/apps/aecore/src/aec_governance.erl#L67
|
|
39
38
|
export const NAME_FEE_MULTIPLIER = 1e14 // 100000000000000
|
|
40
39
|
export const NAME_FEE_BID_INCREMENT = 0.05 // # the increment is in percentage
|
|
@@ -227,7 +226,6 @@ export const TX_TYPE = {
|
|
|
227
226
|
nameserviceTree: 'nameserviceTree',
|
|
228
227
|
oraclesTree: 'oraclesTree',
|
|
229
228
|
accountsTree: 'accountsTree',
|
|
230
|
-
// GA ACCOUNTS
|
|
231
229
|
gaAttach: 'gaAttach',
|
|
232
230
|
gaMeta: 'gaMeta',
|
|
233
231
|
payingFor: 'payingFor',
|
|
@@ -327,7 +325,6 @@ export const OBJECT_ID_TX_TYPE = {
|
|
|
327
325
|
[OBJECT_TAG_NAMESERVICE_TREE]: TX_TYPE.nameserviceTree,
|
|
328
326
|
[OBJECT_TAG_ORACLES_TREE]: TX_TYPE.oraclesTree,
|
|
329
327
|
[OBJECT_TAG_ACCOUNTS_TREE]: TX_TYPE.accountsTree,
|
|
330
|
-
// GA Accounts
|
|
331
328
|
[OBJECT_TAG_GA_ATTACH]: TX_TYPE.gaAttach,
|
|
332
329
|
[OBJECT_TAG_GA_META]: TX_TYPE.gaMeta,
|
|
333
330
|
[OBJECT_TAG_PAYING_FOR]: TX_TYPE.payingFor,
|
|
@@ -421,17 +418,6 @@ export const PREFIX_ID_TAG = {
|
|
|
421
418
|
ch: ID_TAG.channel
|
|
422
419
|
}
|
|
423
420
|
export const ID_TAG_PREFIX = revertObject(PREFIX_ID_TAG)
|
|
424
|
-
const VALIDATION_ERROR = (msg) => msg
|
|
425
|
-
|
|
426
|
-
export const VALIDATION_MESSAGE = {
|
|
427
|
-
[FIELD_TYPES.int]: ({ value, isMinusValue }) => isMinusValue ? VALIDATION_ERROR(`${value} must be >= 0`) : VALIDATION_ERROR(`${value} is not of type Number or BigNumber`),
|
|
428
|
-
[FIELD_TYPES.amount]: ({ value, isMinusValue }) => isMinusValue ? VALIDATION_ERROR(`${value} must be >= 0`) : VALIDATION_ERROR(`${value} is not of type Number or BigNumber`),
|
|
429
|
-
[FIELD_TYPES.id]: ({ value, prefix }) => VALIDATION_ERROR(`'${value}' prefix doesn't match expected prefix '${prefix}' or ID_TAG for prefix not found`),
|
|
430
|
-
[FIELD_TYPES.binary]: ({ prefix, value }) => VALIDATION_ERROR(`'${value}' prefix doesn't match expected prefix '${prefix}'`),
|
|
431
|
-
[FIELD_TYPES.string]: ({ value }) => VALIDATION_ERROR('Not a string'),
|
|
432
|
-
[FIELD_TYPES.pointers]: ({ value }) => VALIDATION_ERROR('Value must be of type Array and contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\''),
|
|
433
|
-
[FIELD_TYPES.ctVersion]: ({ value }) => VALIDATION_ERROR('Value must be an object with "vmVersion" and "abiVersion" fields')
|
|
434
|
-
}
|
|
435
421
|
|
|
436
422
|
const BASE_TX = [
|
|
437
423
|
TX_FIELD('tag', FIELD_TYPES.int),
|
|
@@ -486,9 +472,9 @@ const NAME_CLAIM_TX_2 = [
|
|
|
486
472
|
...BASE_TX,
|
|
487
473
|
TX_FIELD('accountId', FIELD_TYPES.id, 'ak'),
|
|
488
474
|
TX_FIELD('nonce', FIELD_TYPES.int),
|
|
489
|
-
TX_FIELD('name',
|
|
475
|
+
TX_FIELD('name', Name),
|
|
490
476
|
TX_FIELD('nameSalt', FIELD_TYPES.int),
|
|
491
|
-
TX_FIELD('nameFee',
|
|
477
|
+
TX_FIELD('nameFee', NameFee),
|
|
492
478
|
TX_FIELD('fee', FIELD_TYPES.int),
|
|
493
479
|
TX_FIELD('ttl', FIELD_TYPES.int)
|
|
494
480
|
]
|
|
@@ -497,7 +483,7 @@ const NAME_UPDATE_TX = [
|
|
|
497
483
|
...BASE_TX,
|
|
498
484
|
TX_FIELD('accountId', FIELD_TYPES.id, 'ak'),
|
|
499
485
|
TX_FIELD('nonce', FIELD_TYPES.int),
|
|
500
|
-
TX_FIELD('nameId',
|
|
486
|
+
TX_FIELD('nameId', NameId),
|
|
501
487
|
TX_FIELD('nameTtl', FIELD_TYPES.int),
|
|
502
488
|
TX_FIELD('pointers', FIELD_TYPES.pointers),
|
|
503
489
|
TX_FIELD('clientTtl', FIELD_TYPES.int),
|
|
@@ -509,7 +495,7 @@ const NAME_TRANSFER_TX = [
|
|
|
509
495
|
...BASE_TX,
|
|
510
496
|
TX_FIELD('accountId', FIELD_TYPES.id, 'ak'),
|
|
511
497
|
TX_FIELD('nonce', FIELD_TYPES.int),
|
|
512
|
-
TX_FIELD('nameId',
|
|
498
|
+
TX_FIELD('nameId', NameId),
|
|
513
499
|
TX_FIELD('recipientId', FIELD_TYPES.id, ['ak', 'nm']),
|
|
514
500
|
TX_FIELD('fee', FIELD_TYPES.int),
|
|
515
501
|
TX_FIELD('ttl', FIELD_TYPES.int)
|
|
@@ -519,7 +505,7 @@ const NAME_REVOKE_TX = [
|
|
|
519
505
|
...BASE_TX,
|
|
520
506
|
TX_FIELD('accountId', FIELD_TYPES.id, 'ak'),
|
|
521
507
|
TX_FIELD('nonce', FIELD_TYPES.int),
|
|
522
|
-
TX_FIELD('nameId',
|
|
508
|
+
TX_FIELD('nameId', NameId),
|
|
523
509
|
TX_FIELD('fee', FIELD_TYPES.int),
|
|
524
510
|
TX_FIELD('ttl', FIELD_TYPES.int)
|
|
525
511
|
]
|
|
@@ -532,7 +518,7 @@ const CONTRACT_TX = [
|
|
|
532
518
|
TX_FIELD('log', FIELD_TYPES.binary, 'cb'),
|
|
533
519
|
TX_FIELD('active', FIELD_TYPES.bool),
|
|
534
520
|
TX_FIELD('referers', FIELD_TYPES.ids, 'ak'),
|
|
535
|
-
TX_FIELD('deposit',
|
|
521
|
+
TX_FIELD('deposit', Deposit)
|
|
536
522
|
]
|
|
537
523
|
|
|
538
524
|
const GA_ATTACH_TX = [
|
|
@@ -576,7 +562,7 @@ const CONTRACT_CREATE_TX = [
|
|
|
576
562
|
TX_FIELD('ctVersion', FIELD_TYPES.ctVersion),
|
|
577
563
|
TX_FIELD('fee', FIELD_TYPES.int),
|
|
578
564
|
TX_FIELD('ttl', FIELD_TYPES.int),
|
|
579
|
-
TX_FIELD('deposit',
|
|
565
|
+
TX_FIELD('deposit', Deposit),
|
|
580
566
|
TX_FIELD('amount', FIELD_TYPES.amount),
|
|
581
567
|
TX_FIELD('gas', FIELD_TYPES.int),
|
|
582
568
|
TX_FIELD('gasPrice', FIELD_TYPES.int),
|
|
@@ -752,8 +738,8 @@ const CHANNEL_FORCE_PROGRESS_TX = [
|
|
|
752
738
|
TX_FIELD('fromId', FIELD_TYPES.id, 'ak'),
|
|
753
739
|
TX_FIELD('payload', FIELD_TYPES.binary, 'tx'),
|
|
754
740
|
TX_FIELD('round', FIELD_TYPES.int),
|
|
755
|
-
TX_FIELD('update', FIELD_TYPES.binary),
|
|
756
|
-
TX_FIELD('stateHash', FIELD_TYPES.binary),
|
|
741
|
+
TX_FIELD('update', FIELD_TYPES.binary, 'cb'),
|
|
742
|
+
TX_FIELD('stateHash', FIELD_TYPES.binary, 'st'),
|
|
757
743
|
TX_FIELD('offChainTrees', FIELD_TYPES.stateTree),
|
|
758
744
|
TX_FIELD('ttl', FIELD_TYPES.int),
|
|
759
745
|
TX_FIELD('fee', FIELD_TYPES.int),
|