@aeternity/aepp-sdk 8.2.1 → 10.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/CHANGELOG.md +216 -337
- package/README.md +16 -9
- 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 +36 -120
- 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 +79 -156
- package/es/account/multiple.js.map +1 -1
- package/es/ae/aens.js +205 -626
- package/es/ae/aens.js.map +1 -1
- package/es/ae/contract.js +114 -918
- package/es/ae/contract.js.map +1 -1
- package/es/ae/index.js +90 -250
- package/es/ae/index.js.map +1 -1
- package/es/ae/oracle.js +136 -504
- package/es/ae/oracle.js.map +1 -1
- package/es/ae/universal.js.map +1 -1
- package/es/chain/index.js +12 -27
- package/es/chain/index.js.map +1 -1
- package/es/chain/node.js +289 -1020
- 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 +238 -465
- 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 +328 -495
- 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 +131 -203
- package/es/contract/compiler.js.map +1 -1
- package/es/contract/ga/helpers.js +17 -122
- package/es/contract/ga/helpers.js.map +1 -1
- package/es/contract/ga/index.js +108 -249
- package/es/contract/ga/index.js.map +1 -1
- package/es/contract/index.js +7 -3
- package/es/contract/index.js.map +1 -1
- package/es/index.js +3 -3
- package/es/index.js.map +1 -1
- package/es/node-pool/index.js +57 -74
- package/es/node-pool/index.js.map +1 -1
- package/es/node.js +65 -161
- package/es/node.js.map +1 -1
- package/es/other.d.ts +1 -1
- package/es/tx/builder/helpers.js +62 -115
- package/es/tx/builder/helpers.js.map +1 -1
- package/es/tx/builder/index.js +218 -309
- package/es/tx/builder/index.js.map +1 -1
- package/es/tx/builder/schema.js +586 -573
- package/es/tx/builder/schema.js.map +1 -1
- package/es/tx/index.js +102 -13
- package/es/tx/index.js.map +1 -1
- package/es/tx/tx-object.js +114 -138
- package/es/tx/tx-object.js.map +1 -1
- package/es/tx/tx.js +810 -1586
- package/es/tx/tx.js.map +1 -1
- package/es/tx/validator.js +191 -426
- package/es/tx/validator.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
- package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
- package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
- package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
- package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
- 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 +191 -514
- package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
- package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
- package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
- 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 +41 -106
- 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 +87 -224
- package/es/utils/swagger.js.map +1 -1
- package/package.json +51 -44
- package/src/account/base.js +11 -10
- package/src/account/multiple.js +24 -18
- package/src/ae/aens.js +64 -61
- package/src/ae/contract.js +71 -248
- package/src/ae/index.js +34 -9
- package/src/ae/oracle.js +30 -22
- package/src/ae/universal.js +3 -1
- package/src/chain/index.js +10 -16
- package/src/chain/node.js +38 -38
- package/src/channel/handlers.js +10 -4
- package/src/channel/index.js +44 -20
- package/src/contract/aci/index.js +234 -112
- package/src/contract/aci/transformation.js +30 -422
- package/src/contract/compiler.js +50 -5
- package/src/contract/ga/helpers.js +6 -14
- package/src/contract/ga/index.js +28 -28
- package/src/contract/index.js +6 -2
- package/src/index.js +4 -4
- package/src/node-pool/index.js +24 -13
- package/src/node.js +29 -30
- package/src/tx/builder/helpers.js +31 -56
- package/src/tx/builder/index.js +67 -28
- package/src/tx/builder/schema.js +79 -121
- package/src/tx/index.js +101 -12
- package/src/tx/tx-object.js +25 -8
- package/src/tx/tx.js +229 -150
- package/src/tx/validator.js +134 -202
- package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
- package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
- package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
- package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
- package/src/utils/aepp-wallet-communication/helpers.js +4 -2
- package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
- package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
- package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
- package/src/utils/aepp-wallet-communication/schema.js +1 -3
- package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
- package/src/utils/amount-formatter.ts +1 -1
- package/src/utils/bignumber.ts +2 -1
- package/src/utils/crypto.js +4 -68
- package/src/utils/keystore.js +10 -2
- package/src/utils/other.ts +1 -1
- package/src/utils/semver-satisfies.ts +1 -1
- package/src/utils/swagger.js +22 -10
- package/src/contract/aci/helpers.js +0 -140
package/es/tx/builder/index.js
CHANGED
|
@@ -1,36 +1,9 @@
|
|
|
1
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
2
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
3
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
4
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
5
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
6
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
7
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
8
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
9
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
10
|
-
import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
|
|
11
|
-
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context10; _forEachInstanceProperty(_context10 = ownKeys(Object(source), true)).call(_context10, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context11; _forEachInstanceProperty(_context11 = ownKeys(Object(source))).call(_context11, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
15
|
-
|
|
16
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
17
|
-
import _reduceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/reduce";
|
|
18
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
19
|
-
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
20
|
-
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
21
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
22
|
-
import _Object$entries from "@babel/runtime-corejs3/core-js-stable/object/entries";
|
|
23
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
24
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
25
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
26
|
-
import _JSON$stringify from "@babel/runtime-corejs3/core-js-stable/json/stringify";
|
|
27
|
-
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
28
1
|
import BigNumber from 'bignumber.js';
|
|
29
2
|
import { decode as rlpDecode, encode as rlpEncode } from 'rlp';
|
|
30
3
|
import { AE_AMOUNT_FORMATS, formatAmount } from '../../utils/amount-formatter';
|
|
31
|
-
import {
|
|
4
|
+
import { hash } from '../../utils/crypto';
|
|
32
5
|
import { DEFAULT_FEE, FIELD_TYPES, OBJECT_ID_TX_TYPE, PREFIX_ID_TAG, TX_DESERIALIZATION_SCHEMA, TX_FEE_BASE_GAS, TX_FEE_OTHER_GAS, TX_SERIALIZATION_SCHEMA, TX_TYPE, VALIDATION_MESSAGE, VSN } from './schema';
|
|
33
|
-
import { readInt, readId, readPointers, writeId, writeInt, buildPointers, encode, decode
|
|
6
|
+
import { readInt, readId, readPointers, writeId, writeInt, buildPointers, encode, decode } from './helpers';
|
|
34
7
|
import { toBytes } from '../../utils/bytes';
|
|
35
8
|
import MPTree from '../../utils/mptree';
|
|
36
9
|
/**
|
|
@@ -40,7 +13,7 @@ import MPTree from '../../utils/mptree';
|
|
|
40
13
|
* @example import { TxBuilder } from '@aeternity/aepp-sdk'
|
|
41
14
|
*/
|
|
42
15
|
|
|
43
|
-
|
|
16
|
+
const ORACLE_TTL_TYPES = {
|
|
44
17
|
delta: 'delta',
|
|
45
18
|
block: 'block'
|
|
46
19
|
}; // SERIALIZE AND DESERIALIZE PART
|
|
@@ -51,10 +24,7 @@ function deserializeField(value, type, prefix) {
|
|
|
51
24
|
switch (type) {
|
|
52
25
|
case FIELD_TYPES.ctVersion:
|
|
53
26
|
{
|
|
54
|
-
|
|
55
|
-
vm = _value[0],
|
|
56
|
-
abi = _value[2];
|
|
57
|
-
|
|
27
|
+
const [vm,, abi] = value;
|
|
58
28
|
return {
|
|
59
29
|
vmVersion: readInt(Buffer.from([vm])),
|
|
60
30
|
abiVersion: readInt(Buffer.from([abi]))
|
|
@@ -64,14 +34,14 @@ function deserializeField(value, type, prefix) {
|
|
|
64
34
|
case FIELD_TYPES.amount:
|
|
65
35
|
return readInt(value);
|
|
66
36
|
|
|
67
|
-
case FIELD_TYPES
|
|
37
|
+
case FIELD_TYPES.int:
|
|
68
38
|
return readInt(value);
|
|
69
39
|
|
|
70
40
|
case FIELD_TYPES.id:
|
|
71
41
|
return readId(value);
|
|
72
42
|
|
|
73
43
|
case FIELD_TYPES.ids:
|
|
74
|
-
return
|
|
44
|
+
return value.map(readId);
|
|
75
45
|
|
|
76
46
|
case FIELD_TYPES.bool:
|
|
77
47
|
return value[0] === 1;
|
|
@@ -95,9 +65,7 @@ function deserializeField(value, type, prefix) {
|
|
|
95
65
|
return unpackTx(value, true);
|
|
96
66
|
|
|
97
67
|
case FIELD_TYPES.rlpBinaries:
|
|
98
|
-
return
|
|
99
|
-
return unpackTx(v, true);
|
|
100
|
-
});
|
|
68
|
+
return value.map(v => unpackTx(v, true));
|
|
101
69
|
|
|
102
70
|
case FIELD_TYPES.rawBinary:
|
|
103
71
|
return value;
|
|
@@ -106,18 +74,14 @@ function deserializeField(value, type, prefix) {
|
|
|
106
74
|
return value.toString('hex');
|
|
107
75
|
|
|
108
76
|
case FIELD_TYPES.offChainUpdates:
|
|
109
|
-
return
|
|
110
|
-
return unpackTx(v, true);
|
|
111
|
-
});
|
|
77
|
+
return value.map(v => unpackTx(v, true));
|
|
112
78
|
|
|
113
79
|
case FIELD_TYPES.callStack:
|
|
114
80
|
// TODO: fix this
|
|
115
81
|
return [readInt(value)];
|
|
116
82
|
|
|
117
83
|
case FIELD_TYPES.mptrees:
|
|
118
|
-
return
|
|
119
|
-
return new MPTree(t);
|
|
120
|
-
});
|
|
84
|
+
return value.map(t => new MPTree(t));
|
|
121
85
|
|
|
122
86
|
case FIELD_TYPES.callReturnType:
|
|
123
87
|
switch (readInt(value)) {
|
|
@@ -135,18 +99,15 @@ function deserializeField(value, type, prefix) {
|
|
|
135
99
|
}
|
|
136
100
|
|
|
137
101
|
case FIELD_TYPES.sophiaCodeTypeInfo:
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
argType: argType,
|
|
148
|
-
outType: outType
|
|
149
|
-
}));
|
|
102
|
+
return value.reduce((acc, _ref) => {
|
|
103
|
+
let [funHash, fnName, argType, outType] = _ref;
|
|
104
|
+
return { ...acc,
|
|
105
|
+
[fnName.toString()]: {
|
|
106
|
+
funHash,
|
|
107
|
+
argType,
|
|
108
|
+
outType
|
|
109
|
+
}
|
|
110
|
+
};
|
|
150
111
|
}, {});
|
|
151
112
|
|
|
152
113
|
default:
|
|
@@ -155,18 +116,16 @@ function deserializeField(value, type, prefix) {
|
|
|
155
116
|
}
|
|
156
117
|
|
|
157
118
|
function serializeField(value, type, prefix) {
|
|
158
|
-
var _context;
|
|
159
|
-
|
|
160
119
|
switch (type) {
|
|
161
120
|
case FIELD_TYPES.amount:
|
|
162
|
-
case FIELD_TYPES
|
|
121
|
+
case FIELD_TYPES.int:
|
|
163
122
|
return writeInt(value);
|
|
164
123
|
|
|
165
124
|
case FIELD_TYPES.id:
|
|
166
125
|
return writeId(value);
|
|
167
126
|
|
|
168
127
|
case FIELD_TYPES.ids:
|
|
169
|
-
return
|
|
128
|
+
return value.map(writeId);
|
|
170
129
|
|
|
171
130
|
case FIELD_TYPES.bool:
|
|
172
131
|
return Buffer.from([value ? 1 : 0]);
|
|
@@ -181,7 +140,7 @@ function serializeField(value, type, prefix) {
|
|
|
181
140
|
return Buffer.from(value, 'hex');
|
|
182
141
|
|
|
183
142
|
case FIELD_TYPES.signatures:
|
|
184
|
-
return
|
|
143
|
+
return value.map(Buffer.from);
|
|
185
144
|
|
|
186
145
|
case FIELD_TYPES.payload:
|
|
187
146
|
return typeof value === 'string' && value.split('_')[0] === 'ba' ? decode(value, 'ba') : toBytes(value);
|
|
@@ -192,13 +151,14 @@ function serializeField(value, type, prefix) {
|
|
|
192
151
|
case FIELD_TYPES.pointers:
|
|
193
152
|
return buildPointers(value);
|
|
194
153
|
|
|
154
|
+
case FIELD_TYPES.rlpBinary:
|
|
155
|
+
return value.rlpEncoded ?? value;
|
|
156
|
+
|
|
195
157
|
case FIELD_TYPES.mptrees:
|
|
196
|
-
return
|
|
197
|
-
return t.serialize();
|
|
198
|
-
});
|
|
158
|
+
return value.map(t => t.serialize());
|
|
199
159
|
|
|
200
160
|
case FIELD_TYPES.ctVersion:
|
|
201
|
-
return Buffer.from(
|
|
161
|
+
return Buffer.from([...toBytes(value.vmVersion), 0, ...toBytes(value.abiVersion)]);
|
|
202
162
|
|
|
203
163
|
case FIELD_TYPES.callReturnType:
|
|
204
164
|
switch (value) {
|
|
@@ -221,58 +181,51 @@ function serializeField(value, type, prefix) {
|
|
|
221
181
|
}
|
|
222
182
|
|
|
223
183
|
function validateField(value, key, type, prefix) {
|
|
224
|
-
|
|
225
|
-
|
|
184
|
+
const assert = (valid, params) => valid ? {} : {
|
|
185
|
+
[key]: VALIDATION_MESSAGE[type](params)
|
|
226
186
|
}; // All fields are required
|
|
227
187
|
|
|
228
188
|
|
|
229
|
-
if (value === undefined || value === null) return
|
|
189
|
+
if (value === undefined || value === null) return {
|
|
190
|
+
[key]: 'Field is required'
|
|
191
|
+
}; // Validate type of value
|
|
230
192
|
|
|
231
193
|
switch (type) {
|
|
232
194
|
case FIELD_TYPES.amount:
|
|
233
|
-
case FIELD_TYPES
|
|
195
|
+
case FIELD_TYPES.int:
|
|
234
196
|
{
|
|
235
|
-
|
|
197
|
+
const isMinusValue = (!isNaN(value) || BigNumber.isBigNumber(value)) && BigNumber(value).lt(0);
|
|
236
198
|
return assert((!isNaN(value) || BigNumber.isBigNumber(value)) && BigNumber(value).gte(0), {
|
|
237
|
-
value
|
|
238
|
-
isMinusValue
|
|
199
|
+
value,
|
|
200
|
+
isMinusValue
|
|
239
201
|
});
|
|
240
202
|
}
|
|
241
203
|
|
|
242
204
|
case FIELD_TYPES.id:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
|
|
205
|
+
{
|
|
206
|
+
const prefixes = Array.isArray(prefix) ? prefix : [prefix];
|
|
207
|
+
const p = prefixes.find(p => p === value.split('_')[0]);
|
|
248
208
|
return assert(p && PREFIX_ID_TAG[value.split('_')[0]], {
|
|
249
|
-
value
|
|
250
|
-
prefix
|
|
209
|
+
value,
|
|
210
|
+
prefix
|
|
251
211
|
});
|
|
252
212
|
}
|
|
253
213
|
|
|
254
|
-
return assert(assertedType(value, prefix) && PREFIX_ID_TAG[value.split('_')[0]] && value.split('_')[0] === prefix, {
|
|
255
|
-
value: value,
|
|
256
|
-
prefix: prefix
|
|
257
|
-
});
|
|
258
|
-
|
|
259
214
|
case FIELD_TYPES.binary:
|
|
260
215
|
return assert(value.split('_')[0] === prefix, {
|
|
261
|
-
prefix
|
|
262
|
-
value
|
|
216
|
+
prefix,
|
|
217
|
+
value
|
|
263
218
|
});
|
|
264
219
|
|
|
265
220
|
case FIELD_TYPES.string:
|
|
266
221
|
return assert(true);
|
|
267
222
|
|
|
268
223
|
case FIELD_TYPES.ctVersion:
|
|
269
|
-
return assert(
|
|
224
|
+
return assert(typeof value === 'object' && Object.prototype.hasOwnProperty.call(value, 'abiVersion') && Object.prototype.hasOwnProperty.call(value, 'vmVersion'));
|
|
270
225
|
|
|
271
226
|
case FIELD_TYPES.pointers:
|
|
272
|
-
return assert(
|
|
273
|
-
|
|
274
|
-
}), {
|
|
275
|
-
value: value
|
|
227
|
+
return assert(Array.isArray(value) && !value.find(e => e !== Object(e)), {
|
|
228
|
+
value
|
|
276
229
|
});
|
|
277
230
|
|
|
278
231
|
default:
|
|
@@ -281,45 +234,31 @@ function validateField(value, key, type, prefix) {
|
|
|
281
234
|
}
|
|
282
235
|
|
|
283
236
|
function transformParams(params, schema) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
params = _reduceInstanceProperty(_context2 = _filterInstanceProperty(schema).call(schema, function (_ref6) {
|
|
290
|
-
var _ref7 = _slicedToArray(_ref6, 2),
|
|
291
|
-
_ = _ref7[0],
|
|
292
|
-
t = _ref7[1];
|
|
293
|
-
|
|
237
|
+
let {
|
|
238
|
+
denomination
|
|
239
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
240
|
+
params = schema.filter(_ref2 => {
|
|
241
|
+
let [_, t] = _ref2;
|
|
294
242
|
return t === FIELD_TYPES.amount;
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
243
|
+
}).reduce((acc, _ref3) => {
|
|
244
|
+
let [key] = _ref3;
|
|
245
|
+
return { ...params,
|
|
246
|
+
[key]: formatAmount(params[key], {
|
|
247
|
+
denomination
|
|
248
|
+
})
|
|
249
|
+
};
|
|
302
250
|
}, params);
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
var _ref11 = _slicedToArray(_ref10, 1),
|
|
306
|
-
k = _ref11[0];
|
|
307
|
-
|
|
251
|
+
const schemaKeys = schema.map(_ref4 => {
|
|
252
|
+
let [k] = _ref4;
|
|
308
253
|
return k;
|
|
309
254
|
});
|
|
255
|
+
return Object.entries(params).reduce((acc, _ref5) => {
|
|
256
|
+
let [key, value] = _ref5;
|
|
257
|
+
if (schemaKeys.includes(key)) acc[key] = value;
|
|
310
258
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
var _ref13 = _slicedToArray(_ref12, 2),
|
|
315
|
-
key = _ref13[0],
|
|
316
|
-
value = _ref13[1];
|
|
317
|
-
|
|
318
|
-
if (_includesInstanceProperty(schemaKeys).call(schemaKeys, key)) acc[key] = value;
|
|
319
|
-
|
|
320
|
-
if (_includesInstanceProperty(_context4 = ['oracleTtl', 'queryTtl', 'responseTtl']).call(_context4, key)) {
|
|
321
|
-
acc["".concat(key, "Type")] = value.type === ORACLE_TTL_TYPES.delta ? 0 : 1;
|
|
322
|
-
acc["".concat(key, "Value")] = value.value;
|
|
259
|
+
if (['oracleTtl', 'queryTtl', 'responseTtl'].includes(key)) {
|
|
260
|
+
acc[`${key}Type`] = value.type === ORACLE_TTL_TYPES.delta ? 0 : 1;
|
|
261
|
+
acc[`${key}Value`] = value.value;
|
|
323
262
|
}
|
|
324
263
|
|
|
325
264
|
return acc;
|
|
@@ -328,12 +267,15 @@ function transformParams(params, schema) {
|
|
|
328
267
|
|
|
329
268
|
|
|
330
269
|
function getOracleRelativeTtl(params, txType) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
270
|
+
const ttlKey = {
|
|
271
|
+
[TX_TYPE.oracleRegister]: 'oracleTtl',
|
|
272
|
+
[TX_TYPE.oracleExtend]: 'oracleTtl',
|
|
273
|
+
[TX_TYPE.oracleQuery]: 'queryTtl',
|
|
274
|
+
[TX_TYPE.oracleResponse]: 'responseTtl'
|
|
275
|
+
}[txType];
|
|
276
|
+
|
|
277
|
+
if (params[ttlKey] || params[`${ttlKey}Value`]) {
|
|
278
|
+
return params[`${ttlKey}Value`] || params[ttlKey].value;
|
|
337
279
|
}
|
|
338
280
|
|
|
339
281
|
return 1;
|
|
@@ -352,32 +294,33 @@ function getOracleRelativeTtl(params, txType) {
|
|
|
352
294
|
*/
|
|
353
295
|
|
|
354
296
|
|
|
355
|
-
export function calculateMinFee(txType,
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
297
|
+
export function calculateMinFee(txType, _ref6) {
|
|
298
|
+
let {
|
|
299
|
+
gas = 0,
|
|
300
|
+
params,
|
|
301
|
+
vsn
|
|
302
|
+
} = _ref6;
|
|
303
|
+
const multiplier = BigNumber(1e9); // 10^9 GAS_PRICE
|
|
361
304
|
|
|
362
305
|
if (!params) return BigNumber(DEFAULT_FEE).times(multiplier).toString(10);
|
|
363
|
-
|
|
364
|
-
params:
|
|
306
|
+
let actualFee = buildFee(txType, {
|
|
307
|
+
params: { ...params,
|
|
365
308
|
fee: 0
|
|
366
|
-
}
|
|
367
|
-
multiplier
|
|
368
|
-
gas
|
|
369
|
-
vsn
|
|
309
|
+
},
|
|
310
|
+
multiplier,
|
|
311
|
+
gas,
|
|
312
|
+
vsn
|
|
370
313
|
});
|
|
371
|
-
|
|
314
|
+
let expected = BigNumber(0);
|
|
372
315
|
|
|
373
316
|
while (!actualFee.eq(expected)) {
|
|
374
317
|
actualFee = buildFee(txType, {
|
|
375
|
-
params:
|
|
318
|
+
params: { ...params,
|
|
376
319
|
fee: actualFee
|
|
377
|
-
}
|
|
378
|
-
multiplier
|
|
379
|
-
gas
|
|
380
|
-
vsn
|
|
320
|
+
},
|
|
321
|
+
multiplier,
|
|
322
|
+
gas,
|
|
323
|
+
vsn
|
|
381
324
|
});
|
|
382
325
|
expected = actualFee;
|
|
383
326
|
}
|
|
@@ -394,22 +337,23 @@ export function calculateMinFee(txType, _ref14) {
|
|
|
394
337
|
* @return {BigNumber}
|
|
395
338
|
*/
|
|
396
339
|
|
|
397
|
-
function buildFee(txType,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
relativeTtl: getOracleRelativeTtl(params, txType)
|
|
340
|
+
function buildFee(txType, _ref7) {
|
|
341
|
+
let {
|
|
342
|
+
params,
|
|
343
|
+
gas = 0,
|
|
344
|
+
multiplier,
|
|
345
|
+
vsn
|
|
346
|
+
} = _ref7;
|
|
347
|
+
const {
|
|
348
|
+
rlpEncoded: txWithOutFee
|
|
349
|
+
} = buildTx({ ...params
|
|
350
|
+
}, txType, {
|
|
351
|
+
vsn
|
|
352
|
+
});
|
|
353
|
+
const txSize = txWithOutFee.length;
|
|
354
|
+
return TX_FEE_BASE_GAS(txType).plus(TX_FEE_OTHER_GAS(txType, txSize, {
|
|
355
|
+
relativeTtl: getOracleRelativeTtl(params, txType),
|
|
356
|
+
innerTxSize: [TX_TYPE.gaMeta, TX_TYPE.payingFor].includes(txType) ? params.tx.tx.encodedTx.rlpEncoded.length : 0
|
|
413
357
|
})).times(multiplier);
|
|
414
358
|
}
|
|
415
359
|
/**
|
|
@@ -428,22 +372,19 @@ function buildFee(txType, _ref15) {
|
|
|
428
372
|
|
|
429
373
|
|
|
430
374
|
export function calculateFee() {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
vsn = _ref16.vsn;
|
|
441
|
-
|
|
442
|
-
if (!params && showWarning) console.warn("Can't build transaction fee, we will use DEFAULT_FEE(".concat(DEFAULT_FEE, ")"));
|
|
375
|
+
let fee = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
376
|
+
let txType = arguments.length > 1 ? arguments[1] : undefined;
|
|
377
|
+
let {
|
|
378
|
+
gas = 0,
|
|
379
|
+
params,
|
|
380
|
+
showWarning = true,
|
|
381
|
+
vsn
|
|
382
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
383
|
+
if (!params && showWarning) console.warn(`Can't build transaction fee, we will use DEFAULT_FEE(${DEFAULT_FEE})`);
|
|
443
384
|
return fee || calculateMinFee(txType, {
|
|
444
|
-
params
|
|
445
|
-
gas
|
|
446
|
-
vsn
|
|
385
|
+
params,
|
|
386
|
+
gas,
|
|
387
|
+
vsn
|
|
447
388
|
});
|
|
448
389
|
}
|
|
449
390
|
/**
|
|
@@ -456,23 +397,16 @@ export function calculateFee() {
|
|
|
456
397
|
* @return {Object} Object with validation errors
|
|
457
398
|
*/
|
|
458
399
|
|
|
459
|
-
export function validateParams(params, schema,
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
return
|
|
469
|
-
})).call(_context5, function (acc, _ref20) {
|
|
470
|
-
var _ref21 = _slicedToArray(_ref20, 3),
|
|
471
|
-
key = _ref21[0],
|
|
472
|
-
type = _ref21[1],
|
|
473
|
-
prefix = _ref21[2];
|
|
474
|
-
|
|
475
|
-
return _Object$assign(acc, validateField(params[key], key, type, prefix));
|
|
400
|
+
export function validateParams(params, schema, _ref8) {
|
|
401
|
+
let {
|
|
402
|
+
excludeKeys = []
|
|
403
|
+
} = _ref8;
|
|
404
|
+
return schema.filter(_ref9 => {
|
|
405
|
+
let [key] = _ref9;
|
|
406
|
+
return !excludeKeys.includes(key) && key !== 'payload';
|
|
407
|
+
}).reduce((acc, _ref10) => {
|
|
408
|
+
let [key, type, prefix] = _ref10;
|
|
409
|
+
return Object.assign(acc, validateField(params[key], key, type, prefix));
|
|
476
410
|
}, {});
|
|
477
411
|
}
|
|
478
412
|
/**
|
|
@@ -482,45 +416,36 @@ export function validateParams(params, schema, _ref17) {
|
|
|
482
416
|
* @param {Object} params Object with tx params
|
|
483
417
|
* @param {Array} schema Transaction schema
|
|
484
418
|
* @param {Object} [options={}] options
|
|
485
|
-
* @param {
|
|
486
|
-
* @param {String} [options.denomination='aettos']
|
|
419
|
+
* @param {String[]} [options.excludeKeys=[]] Array of keys to exclude for validation and build
|
|
420
|
+
* @param {String} [options.denomination='aettos'] Denomination of amounts
|
|
487
421
|
* @throws {Error} Validation error
|
|
488
422
|
* @return {Array} Array with binary fields of transaction
|
|
489
423
|
*/
|
|
490
424
|
|
|
491
425
|
export function buildRawTx(params, schema) {
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
var _ref24 = _slicedToArray(_ref23, 1),
|
|
500
|
-
key = _ref24[0];
|
|
501
|
-
|
|
502
|
-
return !_includesInstanceProperty(excludeKeys).call(excludeKeys, key);
|
|
426
|
+
let {
|
|
427
|
+
excludeKeys = [],
|
|
428
|
+
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
429
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
430
|
+
const filteredSchema = schema.filter(_ref11 => {
|
|
431
|
+
let [key] = _ref11;
|
|
432
|
+
return !excludeKeys.includes(key);
|
|
503
433
|
}); // Transform `amount` type fields to `aettos`
|
|
504
434
|
|
|
505
|
-
|
|
506
435
|
params = transformParams(params, filteredSchema, {
|
|
507
|
-
denomination
|
|
436
|
+
denomination
|
|
508
437
|
}); // Validation
|
|
509
438
|
|
|
510
|
-
|
|
511
|
-
excludeKeys
|
|
439
|
+
const valid = validateParams(params, schema, {
|
|
440
|
+
excludeKeys
|
|
512
441
|
});
|
|
513
442
|
|
|
514
|
-
if (
|
|
515
|
-
throw new Error('Transaction build error. ' +
|
|
443
|
+
if (Object.keys(valid).length) {
|
|
444
|
+
throw new Error('Transaction build error. ' + JSON.stringify(valid));
|
|
516
445
|
}
|
|
517
446
|
|
|
518
|
-
return
|
|
519
|
-
|
|
520
|
-
key = _ref26[0],
|
|
521
|
-
fieldType = _ref26[1],
|
|
522
|
-
prefix = _ref26[2];
|
|
523
|
-
|
|
447
|
+
return filteredSchema.map(_ref12 => {
|
|
448
|
+
let [key, fieldType, prefix] = _ref12;
|
|
524
449
|
return serializeField(params[key], fieldType, prefix);
|
|
525
450
|
});
|
|
526
451
|
}
|
|
@@ -534,13 +459,11 @@ export function buildRawTx(params, schema) {
|
|
|
534
459
|
*/
|
|
535
460
|
|
|
536
461
|
export function unpackRawTx(binary, schema) {
|
|
537
|
-
return
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return _Object$assign(acc, _defineProperty({}, key, deserializeField(binary[index], fieldType, prefix)));
|
|
462
|
+
return schema.reduce((acc, _ref13, index) => {
|
|
463
|
+
let [key, fieldType, prefix] = _ref13;
|
|
464
|
+
return Object.assign(acc, {
|
|
465
|
+
[key]: deserializeField(binary[index], fieldType, prefix)
|
|
466
|
+
});
|
|
544
467
|
}, {});
|
|
545
468
|
}
|
|
546
469
|
/**
|
|
@@ -551,24 +474,22 @@ export function unpackRawTx(binary, schema) {
|
|
|
551
474
|
* @return {Object} Schema
|
|
552
475
|
*/
|
|
553
476
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
477
|
+
const getSchema = _ref14 => {
|
|
478
|
+
let {
|
|
479
|
+
vsn,
|
|
480
|
+
objId,
|
|
481
|
+
type
|
|
482
|
+
} = _ref14;
|
|
483
|
+
const isDeserialize = !!objId;
|
|
484
|
+
const firstKey = isDeserialize ? objId : type;
|
|
485
|
+
const schema = isDeserialize ? TX_DESERIALIZATION_SCHEMA : TX_SERIALIZATION_SCHEMA;
|
|
561
486
|
|
|
562
487
|
if (!schema[firstKey]) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
throw new Error(_concatInstanceProperty(_context6 = "Transaction ".concat(isDeserialize ? 'deserialization' : 'serialization', " not implemented for ")).call(_context6, isDeserialize ? 'tag ' + objId : type));
|
|
488
|
+
throw new Error(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type}`);
|
|
566
489
|
}
|
|
567
490
|
|
|
568
491
|
if (!schema[firstKey][vsn]) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
throw new Error(_concatInstanceProperty(_context7 = _concatInstanceProperty(_context8 = "Transaction ".concat(isDeserialize ? 'deserialization' : 'serialization', " not implemented for ")).call(_context8, isDeserialize ? 'tag ' + objId : type, " version ")).call(_context7, vsn));
|
|
492
|
+
throw new Error(`Transaction ${isDeserialize ? 'deserialization' : 'serialization'} not implemented for ${isDeserialize ? 'tag ' + objId : type} version ${vsn}`);
|
|
572
493
|
}
|
|
573
494
|
|
|
574
495
|
return schema[firstKey][vsn];
|
|
@@ -580,50 +501,40 @@ var getSchema = function getSchema(_ref29) {
|
|
|
580
501
|
* @param {Object} params Object with tx params
|
|
581
502
|
* @param {String} type Transaction type
|
|
582
503
|
* @param {Object} [options={}] options
|
|
583
|
-
* @param {
|
|
504
|
+
* @param {String[]} [options.excludeKeys] Array of keys to exclude for validation and build
|
|
584
505
|
* @param {String} [options.prefix] Prefix of transaction
|
|
585
506
|
* @throws {Error} Validation error
|
|
586
|
-
* @
|
|
507
|
+
* @returns {Object} object
|
|
508
|
+
* @returns {String} object.tx Base64Check transaction hash with 'tx_' prefix
|
|
509
|
+
* @returns {Buffer} object.rlpEncoded rlp encoded transaction
|
|
510
|
+
* @returns {Array<Buffer>} object.binary binary transaction
|
|
587
511
|
*/
|
|
588
512
|
|
|
589
513
|
|
|
590
514
|
export function buildTx(params, type) {
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
var _getSchema = getSchema({
|
|
604
|
-
type: type,
|
|
605
|
-
vsn: vsn
|
|
606
|
-
}),
|
|
607
|
-
_getSchema2 = _slicedToArray(_getSchema, 2),
|
|
608
|
-
schema = _getSchema2[0],
|
|
609
|
-
tag = _getSchema2[1];
|
|
610
|
-
|
|
611
|
-
var binary = _filterInstanceProperty(_context9 = buildRawTx(_objectSpread(_objectSpread({}, params), {}, {
|
|
515
|
+
let {
|
|
516
|
+
excludeKeys = [],
|
|
517
|
+
prefix = 'tx',
|
|
518
|
+
vsn = VSN,
|
|
519
|
+
denomination = AE_AMOUNT_FORMATS.AETTOS
|
|
520
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
521
|
+
const [schema, tag] = getSchema({
|
|
522
|
+
type,
|
|
523
|
+
vsn
|
|
524
|
+
});
|
|
525
|
+
const binary = buildRawTx({ ...params,
|
|
612
526
|
VSN: vsn,
|
|
613
|
-
tag
|
|
614
|
-
}
|
|
615
|
-
excludeKeys
|
|
527
|
+
tag
|
|
528
|
+
}, schema, {
|
|
529
|
+
excludeKeys,
|
|
616
530
|
denomination: params.denomination || denomination
|
|
617
|
-
})
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
var rlpEncoded = rlpEncode(binary);
|
|
622
|
-
var tx = encode(rlpEncoded, prefix);
|
|
531
|
+
}).filter(e => e !== undefined);
|
|
532
|
+
const rlpEncoded = rlpEncode(binary);
|
|
533
|
+
const tx = encode(rlpEncoded, prefix);
|
|
623
534
|
return {
|
|
624
|
-
tx
|
|
625
|
-
rlpEncoded
|
|
626
|
-
binary
|
|
535
|
+
tx,
|
|
536
|
+
rlpEncoded,
|
|
537
|
+
binary,
|
|
627
538
|
txObject: unpackRawTx(binary, schema)
|
|
628
539
|
};
|
|
629
540
|
}
|
|
@@ -631,32 +542,32 @@ export function buildTx(params, type) {
|
|
|
631
542
|
* Unpack transaction hash
|
|
632
543
|
* @function
|
|
633
544
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
634
|
-
* @param {String|Buffer} encodedTx String or RLP encoded transaction array
|
|
545
|
+
* @param {String|Buffer} encodedTx String or RLP encoded transaction array
|
|
546
|
+
* (if fromRlpBinary flag is true)
|
|
635
547
|
* @param {Boolean} fromRlpBinary Unpack from RLP encoded transaction (default: false)
|
|
636
548
|
* @param {String} prefix - Prefix of data
|
|
637
|
-
* @
|
|
549
|
+
* @returns {Object} object
|
|
550
|
+
* @returns {Object} object.tx Object with transaction param's
|
|
551
|
+
* @returns {Buffer} object.rlpEncoded rlp encoded transaction
|
|
552
|
+
* @returns {Array<Buffer>} object.binary binary transaction
|
|
638
553
|
*/
|
|
639
554
|
|
|
640
555
|
export function unpackTx(encodedTx) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}),
|
|
652
|
-
_getSchema4 = _slicedToArray(_getSchema3, 1),
|
|
653
|
-
schema = _getSchema4[0];
|
|
654
|
-
|
|
556
|
+
let fromRlpBinary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
557
|
+
let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'tx';
|
|
558
|
+
const rlpEncoded = fromRlpBinary ? encodedTx : decode(encodedTx, prefix);
|
|
559
|
+
const binary = rlpDecode(rlpEncoded);
|
|
560
|
+
const objId = readInt(binary[0]);
|
|
561
|
+
const vsn = readInt(binary[1]);
|
|
562
|
+
const [schema] = getSchema({
|
|
563
|
+
objId,
|
|
564
|
+
vsn
|
|
565
|
+
});
|
|
655
566
|
return {
|
|
656
567
|
txType: OBJECT_ID_TX_TYPE[objId],
|
|
657
568
|
tx: unpackRawTx(binary, schema),
|
|
658
|
-
rlpEncoded
|
|
659
|
-
binary
|
|
569
|
+
rlpEncoded,
|
|
570
|
+
binary
|
|
660
571
|
};
|
|
661
572
|
}
|
|
662
573
|
/**
|
|
@@ -664,23 +575,21 @@ export function unpackTx(encodedTx) {
|
|
|
664
575
|
* @function
|
|
665
576
|
* @alias module:@aeternity/aepp-sdk/es/tx/builder
|
|
666
577
|
* @param {String | Buffer} rawTx base64 or rlp encoded transaction
|
|
667
|
-
* @param {Object} options
|
|
668
|
-
* @param {Boolean} options.raw
|
|
669
578
|
* @return {String} Transaction hash
|
|
670
579
|
*/
|
|
671
580
|
|
|
672
|
-
export function buildTxHash(rawTx
|
|
673
|
-
|
|
674
|
-
return
|
|
581
|
+
export function buildTxHash(rawTx) {
|
|
582
|
+
const data = typeof rawTx === 'string' && rawTx.startsWith('tx_') ? decode(rawTx, 'tx') : rawTx;
|
|
583
|
+
return encode(hash(data), 'th');
|
|
675
584
|
}
|
|
676
585
|
export default {
|
|
677
|
-
calculateMinFee
|
|
678
|
-
calculateFee
|
|
679
|
-
unpackTx
|
|
680
|
-
unpackRawTx
|
|
681
|
-
buildTx
|
|
682
|
-
buildRawTx
|
|
683
|
-
validateParams
|
|
684
|
-
buildTxHash
|
|
586
|
+
calculateMinFee,
|
|
587
|
+
calculateFee,
|
|
588
|
+
unpackTx,
|
|
589
|
+
unpackRawTx,
|
|
590
|
+
buildTx,
|
|
591
|
+
buildRawTx,
|
|
592
|
+
validateParams,
|
|
593
|
+
buildTxHash
|
|
685
594
|
};
|
|
686
595
|
//# sourceMappingURL=index.js.map
|