@aeternity/aepp-sdk 9.0.1 → 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 -36
- 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.mjs +179 -0
- package/es/account/base.mjs.map +1 -0
- package/es/account/memory.mjs +99 -0
- package/es/account/memory.mjs.map +1 -0
- package/es/account/multiple.mjs +179 -0
- package/es/account/multiple.mjs.map +1 -0
- package/es/ae/aens.mjs +404 -0
- 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.mjs +207 -0
- package/es/ae/index.mjs.map +1 -0
- package/es/ae/oracle.mjs +339 -0
- 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} +29 -9
- package/es/chain/index.mjs.map +1 -0
- package/es/chain/node.mjs +442 -0
- package/es/chain/node.mjs.map +1 -0
- package/es/channel/handlers.mjs +1110 -0
- package/es/channel/handlers.mjs.map +1 -0
- package/es/channel/{index.js → index.mjs} +245 -472
- package/es/channel/index.mjs.map +1 -0
- package/es/channel/internal.mjs +283 -0
- 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.mjs +178 -0
- 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.mjs +188 -0
- package/es/node-pool/index.mjs.map +1 -0
- package/es/node.mjs +133 -0
- package/es/node.mjs.map +1 -0
- package/es/other.d.ts +1 -1
- package/es/tx/builder/field-types.mjs +74 -0
- package/es/tx/builder/field-types.mjs.map +1 -0
- package/es/tx/builder/helpers.mjs +363 -0
- package/es/tx/builder/helpers.mjs.map +1 -0
- package/es/tx/builder/index.mjs +606 -0
- package/es/tx/builder/index.mjs.map +1 -0
- package/es/tx/builder/schema.mjs +760 -0
- package/es/tx/builder/schema.mjs.map +1 -0
- package/es/tx/{index.js → index.mjs} +107 -15
- package/es/tx/index.mjs.map +1 -0
- package/es/tx/tx-object.mjs +283 -0
- package/es/tx/tx-object.mjs.map +1 -0
- package/es/tx/tx.mjs +938 -0
- package/es/tx/tx.mjs.map +1 -0
- package/es/tx/validator.mjs +247 -0
- 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} +27 -29
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.mjs +183 -0
- 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} +7 -3
- 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} +29 -23
- package/es/utils/aepp-wallet-communication/content-script-bridge.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs +92 -0
- package/es/utils/aepp-wallet-communication/helpers.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +375 -0
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs +275 -0
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.mjs.map +1 -0
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.mjs +541 -0
- 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.mjs +110 -0
- package/es/utils/aepp-wallet-communication/wallet-detector.mjs.map +1 -0
- package/es/utils/amount-formatter.mjs +139 -0
- package/es/utils/amount-formatter.mjs.map +1 -0
- package/es/utils/async-init.mjs +64 -0
- package/es/utils/async-init.mjs.map +1 -0
- package/es/utils/bignumber.mjs +21 -0
- package/es/utils/bignumber.mjs.map +1 -0
- package/es/utils/{bytes.js → bytes.mjs} +16 -12
- 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.mjs +239 -0
- 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.mjs +111 -0
- package/es/utils/hd-wallet.mjs.map +1 -0
- package/es/utils/json-big.mjs +45 -0
- package/es/utils/json-big.mjs.map +1 -0
- package/es/utils/keystore.mjs +240 -0
- package/es/utils/keystore.mjs.map +1 -0
- package/es/utils/mptree.mjs +161 -0
- package/es/utils/mptree.mjs.map +1 -0
- package/es/utils/other.mjs +43 -0
- package/es/utils/other.mjs.map +1 -0
- package/es/utils/semver-satisfies.mjs +16 -0
- package/es/utils/semver-satisfies.mjs.map +1 -0
- package/es/utils/{string.js → string.mjs} +5 -14
- package/es/utils/string.mjs.map +1 -0
- package/es/utils/swagger.mjs +164 -0
- package/es/utils/swagger.mjs.map +1 -0
- package/package.json +55 -62
- package/src/account/base.js +3 -1
- package/src/account/memory.js +13 -8
- package/src/account/multiple.js +31 -22
- package/src/ae/aens.js +75 -77
- package/src/ae/aepp.js +2 -2
- package/src/ae/contract.js +27 -291
- package/src/ae/index.js +9 -7
- package/src/ae/oracle.js +51 -28
- package/src/ae/universal.js +4 -2
- package/src/ae/wallet.js +2 -2
- package/src/chain/index.js +29 -6
- package/src/chain/node.js +95 -67
- package/src/channel/handlers.js +30 -21
- package/src/channel/index.js +44 -20
- package/src/channel/internal.js +30 -24
- package/src/contract/aci.js +376 -0
- package/src/contract/compiler.js +41 -91
- package/src/contract/ga/helpers.js +10 -13
- package/src/contract/ga/index.js +42 -33
- package/src/index.js +9 -10
- package/src/node-pool/index.js +29 -17
- package/src/node.js +33 -36
- package/src/tx/builder/field-types.js +61 -0
- package/src/tx/builder/helpers.js +126 -84
- package/src/tx/builder/index.js +83 -41
- package/src/tx/builder/schema.js +50 -40
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +35 -15
- package/src/tx/tx.js +232 -153
- package/src/tx/validator.js +34 -12
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +11 -5
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +35 -13
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +14 -7
- package/src/utils/aepp-wallet-communication/helpers.js +6 -14
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +107 -60
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +24 -11
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +98 -56
- package/src/utils/aepp-wallet-communication/schema.ts +80 -0
- package/src/utils/aepp-wallet-communication/wallet-detector.js +6 -2
- package/src/utils/amount-formatter.ts +4 -3
- package/src/utils/async-init.js +10 -6
- package/src/utils/bignumber.ts +3 -10
- package/src/utils/bytes.ts +3 -2
- package/src/utils/crypto-ts.ts +2 -2
- package/src/utils/crypto.js +10 -144
- package/src/utils/errors.ts +683 -0
- package/src/utils/hd-wallet.js +11 -26
- package/src/utils/keystore.js +57 -53
- package/src/utils/mptree.ts +12 -6
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +75 -45
- package/es/account/base.js +0 -259
- package/es/account/base.js.map +0 -1
- package/es/account/memory.js +0 -86
- package/es/account/memory.js.map +0 -1
- package/es/account/multiple.js +0 -267
- package/es/account/multiple.js.map +0 -1
- package/es/ae/aens.js +0 -829
- package/es/ae/aens.js.map +0 -1
- package/es/ae/aepp.js.map +0 -1
- package/es/ae/contract.js +0 -985
- package/es/ae/contract.js.map +0 -1
- package/es/ae/index.js +0 -442
- package/es/ae/index.js.map +0 -1
- package/es/ae/oracle.js +0 -690
- 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 +0 -1119
- package/es/chain/node.js.map +0 -1
- package/es/channel/handlers.js +0 -1601
- package/es/channel/handlers.js.map +0 -1
- package/es/channel/index.js.map +0 -1
- package/es/channel/internal.js +0 -438
- 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 -517
- package/es/contract/aci/index.js.map +0 -1
- package/es/contract/aci/transformation.js +0 -742
- package/es/contract/aci/transformation.js.map +0 -1
- package/es/contract/compiler.js +0 -316
- package/es/contract/compiler.js.map +0 -1
- package/es/contract/ga/helpers.js +0 -120
- package/es/contract/ga/helpers.js.map +0 -1
- package/es/contract/ga/index.js +0 -307
- package/es/contract/ga/index.js.map +0 -1
- package/es/contract/index.js +0 -158
- 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 +0 -204
- package/es/node-pool/index.js.map +0 -1
- package/es/node.js +0 -228
- package/es/node.js.map +0 -1
- package/es/tx/builder/helpers.js +0 -355
- package/es/tx/builder/helpers.js.map +0 -1
- package/es/tx/builder/index.js +0 -686
- package/es/tx/builder/index.js.map +0 -1
- package/es/tx/builder/schema.js +0 -695
- package/es/tx/builder/schema.js.map +0 -1
- package/es/tx/index.js.map +0 -1
- package/es/tx/tx-object.js +0 -297
- package/es/tx/tx-object.js.map +0 -1
- package/es/tx/tx.js +0 -1757
- package/es/tx/tx.js.map +0 -1
- package/es/tx/validator.js +0 -344
- 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 +0 -211
- 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 +0 -148
- package/es/utils/aepp-wallet-communication/helpers.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +0 -652
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +0 -285
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +0 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +0 -763
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +0 -1
- package/es/utils/aepp-wallet-communication/schema.js +0 -103
- package/es/utils/aepp-wallet-communication/schema.js.map +0 -1
- package/es/utils/aepp-wallet-communication/wallet-detector.js +0 -135
- package/es/utils/aepp-wallet-communication/wallet-detector.js.map +0 -1
- package/es/utils/amount-formatter.js +0 -152
- package/es/utils/amount-formatter.js.map +0 -1
- package/es/utils/async-init.js +0 -103
- package/es/utils/async-init.js.map +0 -1
- package/es/utils/bignumber.js +0 -36
- 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 +0 -358
- package/es/utils/crypto.js.map +0 -1
- package/es/utils/hd-wallet.js +0 -148
- package/es/utils/hd-wallet.js.map +0 -1
- package/es/utils/json-big.js +0 -78
- package/es/utils/json-big.js.map +0 -1
- package/es/utils/keystore.js +0 -393
- package/es/utils/keystore.js.map +0 -1
- package/es/utils/mptree.js +0 -198
- package/es/utils/mptree.js.map +0 -1
- package/es/utils/other.js +0 -93
- package/es/utils/other.js.map +0 -1
- package/es/utils/semver-satisfies.js +0 -35
- package/es/utils/semver-satisfies.js.map +0 -1
- package/es/utils/string.js.map +0 -1
- package/es/utils/swagger.js +0 -269
- package/es/utils/swagger.js.map +0 -1
- package/src/contract/aci/helpers.js +0 -140
- package/src/contract/aci/index.js +0 -191
- package/src/contract/aci/transformation.js +0 -464
- package/src/contract/index.js +0 -159
- package/src/utils/aepp-wallet-communication/schema.js +0 -110
package/src/tx/tx.js
CHANGED
|
@@ -22,34 +22,42 @@
|
|
|
22
22
|
* @example import { Transaction } from '@aeternity/aepp-sdk'
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import * as R from 'ramda'
|
|
26
|
-
|
|
27
25
|
import ChainNode from '../chain/node'
|
|
28
26
|
import Tx from './'
|
|
29
|
-
|
|
30
27
|
import { buildTx, calculateFee, unpackTx } from './builder'
|
|
31
28
|
import { ABI_VERSIONS, MIN_GAS_PRICE, PROTOCOL_VM_ABI, TX_TYPE, TX_TTL } from './builder/schema'
|
|
32
|
-
import { buildContractId } from './builder/helpers'
|
|
29
|
+
import { buildContractId, encode } from './builder/helpers'
|
|
33
30
|
import { TxObject } from './tx-object'
|
|
31
|
+
import {
|
|
32
|
+
ArgumentError,
|
|
33
|
+
UnsupportedABIversionError,
|
|
34
|
+
UnsupportedVMversionError,
|
|
35
|
+
UnsupportedProtocolError,
|
|
36
|
+
UnknownTxError
|
|
37
|
+
} from '../utils/errors'
|
|
34
38
|
|
|
35
39
|
async function spendTx ({ senderId, recipientId, amount, payload = '' }) {
|
|
36
40
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
37
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
41
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
42
|
+
TX_TYPE.spend, { senderId, ...arguments[0], payload }
|
|
43
|
+
)
|
|
38
44
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
39
45
|
const { tx } = this.nativeMode
|
|
40
46
|
? {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
tx: TxObject({
|
|
48
|
+
params: {
|
|
49
|
+
...arguments[0],
|
|
50
|
+
recipientId,
|
|
51
|
+
senderId,
|
|
52
|
+
nonce,
|
|
53
|
+
ttl,
|
|
54
|
+
payload
|
|
55
|
+
},
|
|
56
|
+
type: TX_TYPE.spend
|
|
57
|
+
}).encodedTx
|
|
58
|
+
}
|
|
59
|
+
: await this.api.postSpend({
|
|
60
|
+
...arguments[0],
|
|
53
61
|
amount: parseInt(amount),
|
|
54
62
|
recipientId,
|
|
55
63
|
senderId,
|
|
@@ -57,160 +65,197 @@ async function spendTx ({ senderId, recipientId, amount, payload = '' }) {
|
|
|
57
65
|
ttl,
|
|
58
66
|
fee: parseInt(fee),
|
|
59
67
|
payload
|
|
60
|
-
})
|
|
68
|
+
})
|
|
61
69
|
|
|
62
70
|
return tx
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
async function namePreclaimTx ({ accountId, commitmentId }) {
|
|
66
74
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
67
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
75
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
76
|
+
TX_TYPE.namePreClaim, { senderId: accountId, ...arguments[0] }
|
|
77
|
+
)
|
|
68
78
|
|
|
69
79
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
70
80
|
const { tx } = this.nativeMode
|
|
71
81
|
? {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
: await this.api.postNamePreclaim(
|
|
82
|
+
tx: TxObject({
|
|
83
|
+
params: { ...arguments[0], nonce, ttl, fee },
|
|
84
|
+
type: TX_TYPE.namePreClaim
|
|
85
|
+
}).encodedTx
|
|
86
|
+
}
|
|
87
|
+
: await this.api.postNamePreclaim({ ...arguments[0], nonce, ttl, fee: parseInt(fee) })
|
|
78
88
|
|
|
79
89
|
return tx
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
async function nameClaimTx ({ accountId, name, nameSalt, vsn = 2 }) {
|
|
83
93
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
84
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
94
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
95
|
+
TX_TYPE.nameClaim, { senderId: accountId, ...arguments[0], vsn }
|
|
96
|
+
)
|
|
85
97
|
|
|
86
98
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
87
99
|
const { tx } = this.nativeMode
|
|
88
100
|
? {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
: await this.api.postNameClaim(
|
|
101
|
+
tx: TxObject({
|
|
102
|
+
params: { ...arguments[0], nonce, ttl, fee, vsn },
|
|
103
|
+
type: TX_TYPE.nameClaim
|
|
104
|
+
}).encodedTx
|
|
105
|
+
}
|
|
106
|
+
: await this.api.postNameClaim({
|
|
107
|
+
...arguments[0], nonce, ttl, fee: parseInt(fee), name: encode(name, 'nm')
|
|
108
|
+
})
|
|
95
109
|
|
|
96
110
|
return tx
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
async function nameTransferTx ({ accountId, nameId, recipientId }) {
|
|
100
114
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
101
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
115
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
116
|
+
TX_TYPE.nameTransfer, { senderId: accountId, ...arguments[0] }
|
|
117
|
+
)
|
|
102
118
|
|
|
103
119
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
104
120
|
const { tx } = this.nativeMode
|
|
105
121
|
? {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
: await this.api.postNameTransfer(
|
|
122
|
+
tx: TxObject({
|
|
123
|
+
params: { ...arguments[0], recipientId, nonce, ttl, fee },
|
|
124
|
+
type: TX_TYPE.nameTransfer
|
|
125
|
+
}).encodedTx
|
|
126
|
+
}
|
|
127
|
+
: await this.api.postNameTransfer({
|
|
128
|
+
...arguments[0], recipientId, nonce, ttl, fee: parseInt(fee)
|
|
129
|
+
})
|
|
112
130
|
|
|
113
131
|
return tx
|
|
114
132
|
}
|
|
115
133
|
|
|
116
134
|
async function nameUpdateTx ({ accountId, nameId, nameTtl, pointers, clientTtl }) {
|
|
117
135
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
118
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
136
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
137
|
+
TX_TYPE.nameUpdate, { senderId: accountId, ...arguments[0] }
|
|
138
|
+
)
|
|
119
139
|
|
|
120
140
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
121
141
|
const { tx } = this.nativeMode
|
|
122
142
|
? {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
: await this.api.postNameUpdate(
|
|
143
|
+
tx: TxObject({
|
|
144
|
+
params: { ...arguments[0], nonce, ttl, fee },
|
|
145
|
+
type: TX_TYPE.nameUpdate
|
|
146
|
+
}).encodedTx
|
|
147
|
+
}
|
|
148
|
+
: await this.api.postNameUpdate({ ...arguments[0], nonce, ttl, fee: parseInt(fee) })
|
|
129
149
|
|
|
130
150
|
return tx
|
|
131
151
|
}
|
|
132
152
|
|
|
133
153
|
async function nameRevokeTx ({ accountId, nameId }) {
|
|
134
154
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
135
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
155
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
156
|
+
TX_TYPE.nameRevoke, { senderId: accountId, ...arguments[0] }
|
|
157
|
+
)
|
|
136
158
|
|
|
137
159
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
138
160
|
const { tx } = this.nativeMode
|
|
139
161
|
? {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
: await this.api.postNameRevoke(
|
|
162
|
+
tx: TxObject({
|
|
163
|
+
params: { ...arguments[0], nonce, ttl, fee },
|
|
164
|
+
type: TX_TYPE.nameRevoke
|
|
165
|
+
}).encodedTx
|
|
166
|
+
}
|
|
167
|
+
: await this.api.postNameRevoke({ ...arguments[0], nonce, ttl, fee: parseInt(fee) })
|
|
146
168
|
|
|
147
169
|
return tx
|
|
148
170
|
}
|
|
149
171
|
|
|
150
|
-
async function contractCreateTx ({
|
|
172
|
+
async function contractCreateTx ({
|
|
173
|
+
ownerId, code, vmVersion, abiVersion, amount, gas, gasPrice = MIN_GAS_PRICE, callData
|
|
174
|
+
}) {
|
|
151
175
|
// Get VM_ABI version
|
|
152
|
-
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate,
|
|
176
|
+
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0])
|
|
153
177
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
154
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
178
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
179
|
+
TX_TYPE.contractCreate, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice }
|
|
180
|
+
)
|
|
155
181
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
156
182
|
return this.nativeMode
|
|
157
183
|
? {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
: this.api.postContractCreate(
|
|
184
|
+
tx: TxObject({
|
|
185
|
+
params: { ...arguments[0], nonce, ttl, fee, ctVersion, gasPrice },
|
|
186
|
+
type: TX_TYPE.contractCreate
|
|
187
|
+
}).encodedTx,
|
|
188
|
+
contractId: buildContractId(ownerId, nonce)
|
|
189
|
+
}
|
|
190
|
+
: this.api.postContractCreate({
|
|
191
|
+
...arguments[0],
|
|
192
|
+
nonce,
|
|
193
|
+
ttl,
|
|
194
|
+
fee: parseInt(fee),
|
|
195
|
+
gas: parseInt(gas),
|
|
196
|
+
gasPrice,
|
|
197
|
+
vmVersion: ctVersion.vmVersion,
|
|
198
|
+
abiVersion: ctVersion.abiVersion
|
|
199
|
+
})
|
|
165
200
|
}
|
|
166
201
|
|
|
167
|
-
async function contractCallTx ({
|
|
168
|
-
|
|
202
|
+
async function contractCallTx ({
|
|
203
|
+
callerId, contractId, abiVersion, amount, gas, gasPrice = MIN_GAS_PRICE, callData
|
|
204
|
+
}) {
|
|
205
|
+
const ctVersion = this.getVmVersion(TX_TYPE.contractCall, arguments[0])
|
|
169
206
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
170
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
207
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
208
|
+
TX_TYPE.contractCall,
|
|
209
|
+
{ senderId: callerId, ...arguments[0], gasPrice, abiVersion: ctVersion.abiVersion }
|
|
210
|
+
)
|
|
171
211
|
|
|
172
212
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
173
213
|
const { tx } = this.nativeMode
|
|
174
214
|
? {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
: await this.api.postContractCall(
|
|
215
|
+
tx: TxObject({
|
|
216
|
+
params: { ...arguments[0], nonce, ttl, fee, abiVersion: ctVersion.abiVersion, gasPrice },
|
|
217
|
+
type: TX_TYPE.contractCall
|
|
218
|
+
}).encodedTx
|
|
219
|
+
}
|
|
220
|
+
: await this.api.postContractCall({
|
|
221
|
+
...arguments[0],
|
|
181
222
|
nonce,
|
|
182
223
|
ttl,
|
|
183
224
|
fee: parseInt(fee),
|
|
184
225
|
gas: parseInt(gas),
|
|
185
226
|
gasPrice,
|
|
186
227
|
abiVersion: ctVersion.abiVersion
|
|
187
|
-
})
|
|
228
|
+
})
|
|
188
229
|
|
|
189
230
|
return tx
|
|
190
231
|
}
|
|
191
232
|
|
|
192
|
-
async function oracleRegisterTx ({
|
|
193
|
-
|
|
233
|
+
async function oracleRegisterTx ({
|
|
234
|
+
accountId, queryFormat, responseFormat, queryFee, oracleTtl, abiVersion = ABI_VERSIONS.NO_ABI
|
|
235
|
+
}) {
|
|
236
|
+
// const { abiVersion: abi } = this.getVmVersion(TX_TYPE.oracleRegister, arguments[0])
|
|
194
237
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
195
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
238
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
239
|
+
TX_TYPE.oracleRegister, { senderId: accountId, ...arguments[0], abiVersion }
|
|
240
|
+
)
|
|
196
241
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
197
242
|
const { tx } = this.nativeMode
|
|
198
243
|
? {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
244
|
+
tx: TxObject({
|
|
245
|
+
params: {
|
|
246
|
+
accountId,
|
|
247
|
+
queryFee,
|
|
248
|
+
abiVersion,
|
|
249
|
+
fee,
|
|
250
|
+
oracleTtl,
|
|
251
|
+
nonce,
|
|
252
|
+
ttl,
|
|
253
|
+
queryFormat,
|
|
254
|
+
responseFormat
|
|
255
|
+
},
|
|
256
|
+
type: TX_TYPE.oracleRegister
|
|
257
|
+
}).encodedTx
|
|
258
|
+
}
|
|
214
259
|
: await this.api.postOracleRegister({
|
|
215
260
|
accountId,
|
|
216
261
|
queryFee,
|
|
@@ -228,16 +273,18 @@ async function oracleRegisterTx ({ accountId, queryFormat, responseFormat, query
|
|
|
228
273
|
|
|
229
274
|
async function oracleExtendTx ({ oracleId, callerId, oracleTtl }) {
|
|
230
275
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
231
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
276
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
277
|
+
TX_TYPE.oracleExtend, { senderId: callerId, ...arguments[0] }
|
|
278
|
+
)
|
|
232
279
|
|
|
233
280
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
234
281
|
const { tx } = this.nativeMode
|
|
235
282
|
? {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
283
|
+
tx: TxObject({
|
|
284
|
+
params: { oracleId, fee, oracleTtl, nonce, ttl },
|
|
285
|
+
type: TX_TYPE.oracleExtend
|
|
286
|
+
}).encodedTx
|
|
287
|
+
}
|
|
241
288
|
: await this.api.postOracleExtend({ oracleId, fee: parseInt(fee), oracleTtl, nonce, ttl })
|
|
242
289
|
|
|
243
290
|
return tx
|
|
@@ -245,16 +292,18 @@ async function oracleExtendTx ({ oracleId, callerId, oracleTtl }) {
|
|
|
245
292
|
|
|
246
293
|
async function oraclePostQueryTx ({ oracleId, responseTtl, query, queryTtl, queryFee, senderId }) {
|
|
247
294
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
248
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
295
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
296
|
+
TX_TYPE.oracleQuery, { senderId, ...arguments[0] }
|
|
297
|
+
)
|
|
249
298
|
|
|
250
299
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
251
300
|
const { tx } = this.nativeMode
|
|
252
301
|
? {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
302
|
+
tx: TxObject({
|
|
303
|
+
params: { oracleId, responseTtl, query, queryTtl, fee, queryFee, ttl, nonce, senderId },
|
|
304
|
+
type: TX_TYPE.oracleQuery
|
|
305
|
+
}).encodedTx
|
|
306
|
+
}
|
|
258
307
|
: await this.api.postOracleQuery({
|
|
259
308
|
oracleId,
|
|
260
309
|
responseTtl,
|
|
@@ -272,27 +321,34 @@ async function oraclePostQueryTx ({ oracleId, responseTtl, query, queryTtl, quer
|
|
|
272
321
|
|
|
273
322
|
async function oracleRespondTx ({ oracleId, callerId, responseTtl, queryId, response }) {
|
|
274
323
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
275
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
324
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
325
|
+
TX_TYPE.oracleResponse, { senderId: callerId, ...arguments[0] }
|
|
326
|
+
)
|
|
276
327
|
|
|
277
328
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
278
329
|
const { tx } = this.nativeMode
|
|
279
330
|
? {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
: await this.api.postOracleRespond({
|
|
331
|
+
tx: TxObject({
|
|
332
|
+
params: { oracleId, responseTtl, queryId, response, fee, ttl, nonce },
|
|
333
|
+
type: TX_TYPE.oracleResponse
|
|
334
|
+
}).encodedTx
|
|
335
|
+
}
|
|
336
|
+
: await this.api.postOracleRespond({
|
|
337
|
+
oracleId, responseTtl, queryId, response, fee: parseInt(fee), ttl, nonce
|
|
338
|
+
})
|
|
286
339
|
return tx
|
|
287
340
|
}
|
|
288
341
|
|
|
289
342
|
async function channelCloseSoloTx ({ channelId, fromId, payload, poi }) {
|
|
290
343
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
291
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
344
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
345
|
+
TX_TYPE.channelCloseSolo, { senderId: fromId, ...arguments[0], payload }
|
|
346
|
+
)
|
|
292
347
|
|
|
293
348
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
294
349
|
const { tx } = this.nativeMode
|
|
295
|
-
? buildTx(
|
|
350
|
+
? buildTx({
|
|
351
|
+
...arguments[0],
|
|
296
352
|
channelId,
|
|
297
353
|
fromId,
|
|
298
354
|
payload,
|
|
@@ -300,8 +356,9 @@ async function channelCloseSoloTx ({ channelId, fromId, payload, poi }) {
|
|
|
300
356
|
ttl,
|
|
301
357
|
fee,
|
|
302
358
|
nonce
|
|
303
|
-
}
|
|
304
|
-
: await this.api.postChannelCloseSolo(
|
|
359
|
+
}, TX_TYPE.channelCloseSolo)
|
|
360
|
+
: await this.api.postChannelCloseSolo({
|
|
361
|
+
...arguments[0],
|
|
305
362
|
channelId,
|
|
306
363
|
fromId,
|
|
307
364
|
payload,
|
|
@@ -309,18 +366,21 @@ async function channelCloseSoloTx ({ channelId, fromId, payload, poi }) {
|
|
|
309
366
|
ttl,
|
|
310
367
|
fee: parseInt(fee),
|
|
311
368
|
nonce
|
|
312
|
-
})
|
|
369
|
+
})
|
|
313
370
|
|
|
314
371
|
return tx
|
|
315
372
|
}
|
|
316
373
|
|
|
317
374
|
async function channelSlashTx ({ channelId, fromId, payload, poi }) {
|
|
318
375
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
319
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
376
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
377
|
+
TX_TYPE.channelSlash, { senderId: fromId, ...arguments[0], payload }
|
|
378
|
+
)
|
|
320
379
|
|
|
321
380
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
322
381
|
const { tx } = this.nativeMode
|
|
323
|
-
? buildTx(
|
|
382
|
+
? buildTx({
|
|
383
|
+
...arguments[0],
|
|
324
384
|
channelId,
|
|
325
385
|
fromId,
|
|
326
386
|
payload,
|
|
@@ -328,8 +388,9 @@ async function channelSlashTx ({ channelId, fromId, payload, poi }) {
|
|
|
328
388
|
ttl,
|
|
329
389
|
fee,
|
|
330
390
|
nonce
|
|
331
|
-
}
|
|
332
|
-
: await this.api.postChannelSlash(
|
|
391
|
+
}, TX_TYPE.channelSlash)
|
|
392
|
+
: await this.api.postChannelSlash({
|
|
393
|
+
...arguments[0],
|
|
333
394
|
channelId,
|
|
334
395
|
fromId,
|
|
335
396
|
payload,
|
|
@@ -337,18 +398,21 @@ async function channelSlashTx ({ channelId, fromId, payload, poi }) {
|
|
|
337
398
|
ttl,
|
|
338
399
|
fee: parseInt(fee),
|
|
339
400
|
nonce
|
|
340
|
-
})
|
|
401
|
+
})
|
|
341
402
|
|
|
342
403
|
return tx
|
|
343
404
|
}
|
|
344
405
|
|
|
345
406
|
async function channelSettleTx ({ channelId, fromId, initiatorAmountFinal, responderAmountFinal }) {
|
|
346
407
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
347
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
408
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
409
|
+
TX_TYPE.channelSettle, { senderId: fromId, ...arguments[0] }
|
|
410
|
+
)
|
|
348
411
|
|
|
349
412
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
350
413
|
const { tx } = this.nativeMode
|
|
351
|
-
? buildTx(
|
|
414
|
+
? buildTx({
|
|
415
|
+
...arguments[0],
|
|
352
416
|
channelId,
|
|
353
417
|
fromId,
|
|
354
418
|
initiatorAmountFinal,
|
|
@@ -356,8 +420,9 @@ async function channelSettleTx ({ channelId, fromId, initiatorAmountFinal, respo
|
|
|
356
420
|
ttl,
|
|
357
421
|
fee,
|
|
358
422
|
nonce
|
|
359
|
-
}
|
|
360
|
-
: await this.api.postChannelSettle(
|
|
423
|
+
}, TX_TYPE.channelSettle)
|
|
424
|
+
: await this.api.postChannelSettle({
|
|
425
|
+
...arguments[0],
|
|
361
426
|
channelId,
|
|
362
427
|
fromId,
|
|
363
428
|
initiatorAmountFinal: parseInt(initiatorAmountFinal),
|
|
@@ -365,46 +430,54 @@ async function channelSettleTx ({ channelId, fromId, initiatorAmountFinal, respo
|
|
|
365
430
|
ttl,
|
|
366
431
|
fee: parseInt(fee),
|
|
367
432
|
nonce
|
|
368
|
-
})
|
|
433
|
+
})
|
|
369
434
|
|
|
370
435
|
return tx
|
|
371
436
|
}
|
|
372
437
|
|
|
373
438
|
async function channelSnapshotSoloTx ({ channelId, fromId, payload }) {
|
|
374
439
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
375
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
440
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
441
|
+
TX_TYPE.channelSnapshotSolo, { senderId: fromId, ...arguments[0], payload }
|
|
442
|
+
)
|
|
376
443
|
|
|
377
444
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
378
445
|
const { tx } = this.nativeMode
|
|
379
|
-
? buildTx(
|
|
446
|
+
? buildTx({
|
|
447
|
+
...arguments[0],
|
|
380
448
|
channelId,
|
|
381
449
|
fromId,
|
|
382
450
|
payload,
|
|
383
451
|
ttl,
|
|
384
452
|
fee,
|
|
385
453
|
nonce
|
|
386
|
-
}
|
|
387
|
-
: await this.api.postChannelSnapshotSolo(
|
|
454
|
+
}, TX_TYPE.channelSnapshotSolo)
|
|
455
|
+
: await this.api.postChannelSnapshotSolo({
|
|
456
|
+
...arguments[0],
|
|
388
457
|
channelId,
|
|
389
458
|
fromId,
|
|
390
459
|
payload,
|
|
391
460
|
ttl,
|
|
392
461
|
fee: parseInt(fee),
|
|
393
462
|
nonce
|
|
394
|
-
})
|
|
463
|
+
})
|
|
395
464
|
|
|
396
465
|
return tx
|
|
397
466
|
}
|
|
398
467
|
|
|
399
|
-
async function gaAttachTx ({
|
|
468
|
+
async function gaAttachTx ({
|
|
469
|
+
ownerId, code, vmVersion, abiVersion, authFun, gas, gasPrice = MIN_GAS_PRICE, callData
|
|
470
|
+
}) {
|
|
400
471
|
// Get VM_ABI version
|
|
401
|
-
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate,
|
|
472
|
+
const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0])
|
|
402
473
|
// Calculate fee, get absolute ttl (ttl + height), get account nonce
|
|
403
|
-
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
474
|
+
const { fee, ttl, nonce } = await this.prepareTxParams(
|
|
475
|
+
TX_TYPE.gaAttach, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice }
|
|
476
|
+
)
|
|
404
477
|
// Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
|
|
405
478
|
return {
|
|
406
479
|
tx: TxObject({
|
|
407
|
-
params:
|
|
480
|
+
params: { ...arguments[0], nonce, ttl, fee, ctVersion, gasPrice },
|
|
408
481
|
type: TX_TYPE.gaAttach
|
|
409
482
|
}).encodedTx,
|
|
410
483
|
contractId: buildContractId(ownerId, nonce)
|
|
@@ -429,18 +502,20 @@ async function payingForTx ({ tx, payerId, ...args }) {
|
|
|
429
502
|
function getVmVersion (txType, { vmVersion, abiVersion } = {}) {
|
|
430
503
|
const { consensusProtocolVersion } = this.getNodeInfo()
|
|
431
504
|
const supportedProtocol = PROTOCOL_VM_ABI[consensusProtocolVersion]
|
|
432
|
-
if (!supportedProtocol) throw new
|
|
505
|
+
if (!supportedProtocol) throw new UnsupportedProtocolError('Not supported consensus protocol version')
|
|
433
506
|
const protocolForTX = supportedProtocol[txType]
|
|
434
|
-
if (!protocolForTX) throw new
|
|
507
|
+
if (!protocolForTX) throw new UnknownTxError('Not supported tx type')
|
|
435
508
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
509
|
+
abiVersion = abiVersion || protocolForTX.abiVersion[0]
|
|
510
|
+
vmVersion = vmVersion || protocolForTX.vmVersion[0]
|
|
511
|
+
if (!protocolForTX.vmVersion.includes(vmVersion)) {
|
|
512
|
+
throw new UnsupportedVMversionError(`VM VERSION ${vmVersion} do not support by this node. Supported: [${protocolForTX.vmVersion}]`)
|
|
513
|
+
}
|
|
514
|
+
if (!protocolForTX.abiVersion.includes(abiVersion)) {
|
|
515
|
+
throw new UnsupportedABIversionError(`ABI VERSION ${abiVersion} do not support by this node. Supported: [${protocolForTX.abiVersion}]`)
|
|
439
516
|
}
|
|
440
|
-
if (protocolForTX.vmVersion.length && !R.contains(ctVersion.vmVersion, protocolForTX.vmVersion)) throw new Error(`VM VERSION ${ctVersion.vmVersion} do not support by this node. Supported: [${protocolForTX.vmVersion}]`)
|
|
441
|
-
if (protocolForTX.abiVersion.length && !R.contains(ctVersion.abiVersion, protocolForTX.abiVersion)) throw new Error(`ABI VERSION ${ctVersion.abiVersion} do not support by this node. Supported: [${protocolForTX.abiVersion}]`)
|
|
442
517
|
|
|
443
|
-
return
|
|
518
|
+
return { vmVersion, abiVersion }
|
|
444
519
|
}
|
|
445
520
|
|
|
446
521
|
/**
|
|
@@ -452,7 +527,7 @@ function getVmVersion (txType, { vmVersion, abiVersion } = {}) {
|
|
|
452
527
|
*/
|
|
453
528
|
async function calculateTtl (ttl = TX_TTL, relative = true) {
|
|
454
529
|
if (ttl === 0) return 0
|
|
455
|
-
if (ttl < 0) throw new
|
|
530
|
+
if (ttl < 0) throw new ArgumentError('ttl', 'greater or equal to 0', ttl)
|
|
456
531
|
|
|
457
532
|
if (relative) {
|
|
458
533
|
const { height } = await this.api.getCurrentKeyBlock()
|
|
@@ -470,7 +545,8 @@ async function calculateTtl (ttl = TX_TTL, relative = true) {
|
|
|
470
545
|
*/
|
|
471
546
|
async function getAccountNonce (accountId, nonce) {
|
|
472
547
|
if (nonce) return nonce
|
|
473
|
-
const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId)
|
|
548
|
+
const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId)
|
|
549
|
+
.catch(() => ({ nonce: 0 }))
|
|
474
550
|
return accountNonce + 1
|
|
475
551
|
}
|
|
476
552
|
|
|
@@ -481,16 +557,19 @@ async function getAccountNonce (accountId, nonce) {
|
|
|
481
557
|
* @param {Object} params Object which contains all tx data
|
|
482
558
|
* @return {Object} { ttl, nonce, fee } Object with account nonce, absolute ttl and transaction fee
|
|
483
559
|
*/
|
|
484
|
-
async function prepareTxParams (
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
560
|
+
async function prepareTxParams (
|
|
561
|
+
txType,
|
|
562
|
+
{ senderId, nonce: n, ttl: t, fee: f, gas, absoluteTtl, vsn, strategy }
|
|
563
|
+
) {
|
|
564
|
+
n = n || (
|
|
565
|
+
await this.api.getAccountNextNonce(senderId, { strategy }).catch(e => ({ nextNonce: 1 }))
|
|
566
|
+
).nextNonce
|
|
492
567
|
const ttl = await calculateTtl.call(this, t, !absoluteTtl)
|
|
493
|
-
const fee = calculateFee(
|
|
568
|
+
const fee = calculateFee(
|
|
569
|
+
f,
|
|
570
|
+
txType,
|
|
571
|
+
{ showWarning: this.showWarning, gas, params: { ...arguments[1], nonce: n, ttl }, vsn }
|
|
572
|
+
)
|
|
494
573
|
return { fee, ttl, nonce: n }
|
|
495
574
|
}
|
|
496
575
|
|