@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/src/tx/index.js
CHANGED
|
@@ -72,7 +72,15 @@ const Tx = stampit(required({
|
|
|
72
72
|
* @instance
|
|
73
73
|
* @abstract
|
|
74
74
|
* @category async
|
|
75
|
-
* @rtype ({
|
|
75
|
+
* @rtype ({
|
|
76
|
+
* sender?: String,
|
|
77
|
+
* recipientId: String,
|
|
78
|
+
* amount: Number,
|
|
79
|
+
* fee?: Number,
|
|
80
|
+
* ttl?: Number,
|
|
81
|
+
* nonce?: Number,
|
|
82
|
+
* payload?: String
|
|
83
|
+
* }) => tx: Promise[String]
|
|
76
84
|
* @param {Object} options - The object to extract properties from
|
|
77
85
|
* @return {String} `spend_tx` transaction
|
|
78
86
|
*/
|
|
@@ -83,7 +91,9 @@ const Tx = stampit(required({
|
|
|
83
91
|
* @instance
|
|
84
92
|
* @abstract
|
|
85
93
|
* @category async
|
|
86
|
-
* @rtype ({
|
|
94
|
+
* @rtype ({
|
|
95
|
+
* account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
96
|
+
* }) => tx: Promise[String]
|
|
87
97
|
* @param {Object} options - The object to extract properties from
|
|
88
98
|
* @return {String} `name_preclaim_tx` transaction
|
|
89
99
|
*/
|
|
@@ -94,7 +104,9 @@ const Tx = stampit(required({
|
|
|
94
104
|
* @instance
|
|
95
105
|
* @abstract
|
|
96
106
|
* @category async
|
|
97
|
-
* @rtype ({
|
|
107
|
+
* @rtype ({
|
|
108
|
+
* account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
109
|
+
* }) => tx: Promise[String]
|
|
98
110
|
* @param {Object} options - The object to extract properties from
|
|
99
111
|
* @return {String} `name_claim_tx` transaction
|
|
100
112
|
*/
|
|
@@ -105,7 +117,14 @@ const Tx = stampit(required({
|
|
|
105
117
|
* @instance
|
|
106
118
|
* @abstract
|
|
107
119
|
* @category async
|
|
108
|
-
* @rtype ({
|
|
120
|
+
* @rtype ({
|
|
121
|
+
* account?: String,
|
|
122
|
+
* nameId: String,
|
|
123
|
+
* recipientId: String,
|
|
124
|
+
* fee?: Number,
|
|
125
|
+
* ttl?: Number,
|
|
126
|
+
* nonce?: Number
|
|
127
|
+
* }) => tx: Promise[String]
|
|
109
128
|
* @param {Object} options - The object to extract properties from
|
|
110
129
|
* @return {String} `name_transfer_tx` transaction
|
|
111
130
|
*/
|
|
@@ -116,7 +135,16 @@ const Tx = stampit(required({
|
|
|
116
135
|
* @instance
|
|
117
136
|
* @abstract
|
|
118
137
|
* @category async
|
|
119
|
-
* @rtype ({
|
|
138
|
+
* @rtype ({
|
|
139
|
+
* account?: String,
|
|
140
|
+
* nameId: String,
|
|
141
|
+
* pointers: Object,
|
|
142
|
+
* nameTtl: Number,
|
|
143
|
+
* clientTtl: Number,
|
|
144
|
+
* fee?: Number,
|
|
145
|
+
* ttl?: Number,
|
|
146
|
+
* nonce?: Number
|
|
147
|
+
* }) => tx: Promise[String]
|
|
120
148
|
* @param {Object} options - The object to extract properties from
|
|
121
149
|
* @return {String} `name_update_tx` transaction
|
|
122
150
|
*/
|
|
@@ -127,7 +155,9 @@ const Tx = stampit(required({
|
|
|
127
155
|
* @instance
|
|
128
156
|
* @abstract
|
|
129
157
|
* @category async
|
|
130
|
-
* @rtype ({
|
|
158
|
+
* @rtype ({
|
|
159
|
+
* account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
160
|
+
* }) => tx: Promise[String]
|
|
131
161
|
* @param {Object} options - The object to extract properties from
|
|
132
162
|
* @return {String} `name_revoke_tx` transaction
|
|
133
163
|
*/
|
|
@@ -138,7 +168,19 @@ const Tx = stampit(required({
|
|
|
138
168
|
* @instance
|
|
139
169
|
* @abstract
|
|
140
170
|
* @category async
|
|
141
|
-
* @rtype ({
|
|
171
|
+
* @rtype ({
|
|
172
|
+
* owner: String,
|
|
173
|
+
* code: String,
|
|
174
|
+
* callData: String,
|
|
175
|
+
* vmVersion: Number,
|
|
176
|
+
* deposit: Number,
|
|
177
|
+
* amount: Number,
|
|
178
|
+
* gas: Number,
|
|
179
|
+
* gasPrice: Number,
|
|
180
|
+
* fee?: Number,
|
|
181
|
+
* ttl?: Number,
|
|
182
|
+
* nonce?: Number
|
|
183
|
+
* }) => tx: Promise[String]
|
|
142
184
|
* @param {Object} options - The object to extract properties from
|
|
143
185
|
* @return {String} `contract_create_tx` transaction
|
|
144
186
|
*/
|
|
@@ -149,7 +191,18 @@ const Tx = stampit(required({
|
|
|
149
191
|
* @instance
|
|
150
192
|
* @abstract
|
|
151
193
|
* @category async
|
|
152
|
-
* @rtype ({
|
|
194
|
+
* @rtype ({
|
|
195
|
+
* callerId: String,
|
|
196
|
+
* contract: String,
|
|
197
|
+
* callData: String,
|
|
198
|
+
* vmVersion: Number,
|
|
199
|
+
* amount: Number,
|
|
200
|
+
* gas: Number,
|
|
201
|
+
* gasPrice: Number,
|
|
202
|
+
* fee?: Number,
|
|
203
|
+
* ttl?: Number,
|
|
204
|
+
* nonce?: Number
|
|
205
|
+
* }) => tx: Promise[String]
|
|
153
206
|
* @param {Object} options - The object to extract properties from
|
|
154
207
|
* @return {String} `contract_call_tx` transaction
|
|
155
208
|
*/
|
|
@@ -160,7 +213,17 @@ const Tx = stampit(required({
|
|
|
160
213
|
* @instance
|
|
161
214
|
* @abstract
|
|
162
215
|
* @category async
|
|
163
|
-
* @rtype ({
|
|
216
|
+
* @rtype ({
|
|
217
|
+
* accountId: String,
|
|
218
|
+
* queryFormat: String,
|
|
219
|
+
* responseFormat: String,
|
|
220
|
+
* queryFee: String|Number,
|
|
221
|
+
* oracleTtl: Object,
|
|
222
|
+
* vmVersion: Number = ORACLE_VM_VERSION,
|
|
223
|
+
* fee?: Number,
|
|
224
|
+
* ttl?: Number,
|
|
225
|
+
* nonce?: Number
|
|
226
|
+
* }) => tx: Promise[String]
|
|
164
227
|
* @param {Object} options - The object to extract properties from
|
|
165
228
|
* @return {String} `oracle_register_tx` transaction
|
|
166
229
|
*/
|
|
@@ -171,7 +234,14 @@ const Tx = stampit(required({
|
|
|
171
234
|
* @instance
|
|
172
235
|
* @abstract
|
|
173
236
|
* @category async
|
|
174
|
-
* @rtype ({
|
|
237
|
+
* @rtype ({
|
|
238
|
+
* oracleId: String,
|
|
239
|
+
* callerId: String,
|
|
240
|
+
* oracleTtl: Object,
|
|
241
|
+
* fee?: Number,
|
|
242
|
+
* ttl: Number,
|
|
243
|
+
* nonce?: Number
|
|
244
|
+
* }) => tx: Promise[String]
|
|
175
245
|
* @param {Object} options - The object to extract properties from
|
|
176
246
|
* @return {String} `oracle_extend_tx` transaction
|
|
177
247
|
*/
|
|
@@ -182,7 +252,17 @@ const Tx = stampit(required({
|
|
|
182
252
|
* @instance
|
|
183
253
|
* @abstract
|
|
184
254
|
* @category async
|
|
185
|
-
* @rtype ({
|
|
255
|
+
* @rtype ({
|
|
256
|
+
* oracleId: String,
|
|
257
|
+
* responseTtl: Object,
|
|
258
|
+
* query: String,
|
|
259
|
+
* queryTtl: Object,
|
|
260
|
+
* queryFee: String|Number,
|
|
261
|
+
* senderId: String,
|
|
262
|
+
* fee?: Number,
|
|
263
|
+
* ttl: Number,
|
|
264
|
+
* nonce?: Number
|
|
265
|
+
* }) => tx: Promise[String]
|
|
186
266
|
* @param {Object} options - The object to extract properties from
|
|
187
267
|
* @return {String} `oracle_post_query_tx` transaction
|
|
188
268
|
*/
|
|
@@ -193,7 +273,16 @@ const Tx = stampit(required({
|
|
|
193
273
|
* @instance
|
|
194
274
|
* @abstract
|
|
195
275
|
* @category async
|
|
196
|
-
* @rtype ({
|
|
276
|
+
* @rtype ({
|
|
277
|
+
* oracleId: String,
|
|
278
|
+
* callerId: String,
|
|
279
|
+
* responseTtl: Object,
|
|
280
|
+
* queryId: String,
|
|
281
|
+
* response: String,
|
|
282
|
+
* fee?: Number,
|
|
283
|
+
* ttl?: Number,
|
|
284
|
+
* nonce?: Number
|
|
285
|
+
* }) => tx: Promise[String]
|
|
197
286
|
* @param {Object} options - The object to extract properties from
|
|
198
287
|
* @return {String} `oracle_respond_tx` transaction
|
|
199
288
|
*/
|
package/src/tx/tx-object.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* @example import TxObject from '@aeternity/aepp-sdk/es/tx/tx-object'
|
|
6
6
|
*/
|
|
7
7
|
import stampit from '@stamp/it'
|
|
8
|
-
import { assertedType } from '../utils/crypto'
|
|
9
8
|
import { buildTx, calculateFee, unpackTx } from './builder'
|
|
10
9
|
import { TX_TYPE } from './builder/schema'
|
|
11
10
|
import { encode } from './builder/helpers'
|
|
@@ -18,13 +17,17 @@ import { isHex } from '../utils/string'
|
|
|
18
17
|
* @param {Object} params Transaction params
|
|
19
18
|
* @param {Object} [options={}] Options
|
|
20
19
|
* @throws {Error} Arguments validation error's
|
|
21
|
-
* @return {{
|
|
20
|
+
* @return {{
|
|
21
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String
|
|
22
|
+
* }}
|
|
22
23
|
*/
|
|
23
24
|
const buildTransaction = (type, params, options = {}) => {
|
|
24
25
|
if (typeof params !== 'object') throw new Error('"params" should be an object')
|
|
25
26
|
if (typeof type !== 'string' || !Object.values(TX_TYPE).includes(type)) throw new Error(`Unknown transaction type ${type}`)
|
|
26
27
|
const fee = calculateFee(params.fee, type, { gas: params.gas, params, vsn: params.vsn })
|
|
27
|
-
const { rlpEncoded, binary, tx: encodedTx, txObject } = buildTx(
|
|
28
|
+
const { rlpEncoded, binary, tx: encodedTx, txObject } = buildTx(
|
|
29
|
+
{ ...params, fee }, type, { vsn: params.vsn, ...options }
|
|
30
|
+
)
|
|
28
31
|
return { rlpEncoded, binary, encodedTx, params: txObject, type }
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -33,12 +36,13 @@ const buildTransaction = (type, params, options = {}) => {
|
|
|
33
36
|
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
34
37
|
* @param {Buffer|String} tx RLP encoded binary or base64c(rlpBinary) string
|
|
35
38
|
* @throws {Error} Arguments validation error's
|
|
36
|
-
* @return {{
|
|
39
|
+
* @return {{
|
|
40
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
41
|
+
* }}
|
|
37
42
|
*/
|
|
38
43
|
const unpackTransaction = (tx) => {
|
|
39
44
|
if (!tx) throw new Error(`Invalid transaction: ${tx}`)
|
|
40
45
|
if (typeof tx === 'string') {
|
|
41
|
-
if (!assertedType(tx, 'tx', true)) throw new Error('Invalid transaction string. Tx should be `tx` prefixed base58c string')
|
|
42
46
|
const { txType: type, tx: params, rlpEncoded, binary } = unpackTx(tx)
|
|
43
47
|
return { encodedTx: tx, type, params, rlpEncoded, binary }
|
|
44
48
|
}
|
|
@@ -57,7 +61,9 @@ const unpackTransaction = (tx) => {
|
|
|
57
61
|
* @param {String} type Transaction type
|
|
58
62
|
* @param {Object} [options={}] Options
|
|
59
63
|
* @throws {Error} Arguments validation error's
|
|
60
|
-
* @return {{
|
|
64
|
+
* @return {{
|
|
65
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
66
|
+
* }}
|
|
61
67
|
*/
|
|
62
68
|
const initTransaction = ({ tx, params, type, options = {} } = {}) => {
|
|
63
69
|
if (params && type) return buildTransaction(type, params, options)
|
|
@@ -124,7 +130,12 @@ export const TxObject = stampit({
|
|
|
124
130
|
if (typeof props !== 'object') throw new Error('Props should be an object')
|
|
125
131
|
this.isSigned = false
|
|
126
132
|
this.signatures = []
|
|
127
|
-
Object.assign(
|
|
133
|
+
Object.assign(
|
|
134
|
+
this,
|
|
135
|
+
buildTransaction(
|
|
136
|
+
this.type, { ...this.params, ...props, fee: null }, { ...this.options, ...options }
|
|
137
|
+
)
|
|
138
|
+
)
|
|
128
139
|
return this
|
|
129
140
|
},
|
|
130
141
|
/**
|
|
@@ -145,7 +156,13 @@ export const TxObject = stampit({
|
|
|
145
156
|
addSignature (signature) {
|
|
146
157
|
signature = isHex(signature) ? Buffer.from(signature, 'hex') : signature
|
|
147
158
|
if (!Buffer.isBuffer(signature) && !(signature instanceof Uint8Array)) throw new Error('Invalid signature, signature must be of type Buffer or Uint8Array')
|
|
148
|
-
Object.assign(
|
|
159
|
+
Object.assign(
|
|
160
|
+
this,
|
|
161
|
+
buildTransaction(
|
|
162
|
+
TX_TYPE.signed,
|
|
163
|
+
{ encodedTx: this.rlpEncoded, signatures: [[...this.signatures, signature]] }
|
|
164
|
+
)
|
|
165
|
+
)
|
|
149
166
|
|
|
150
167
|
const { signatures, encodedTx: { txType, tx } } = this.params
|
|
151
168
|
this.signatures = signatures
|