@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/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import { required } from '@stamp/required';
|
|
|
40
40
|
* @example Tx()
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
const Tx = stampit(required({
|
|
44
44
|
methods: {
|
|
45
45
|
spendTx: required,
|
|
46
46
|
namePreclaimTx: required,
|
|
@@ -70,7 +70,15 @@ var Tx = stampit(required({
|
|
|
70
70
|
* @instance
|
|
71
71
|
* @abstract
|
|
72
72
|
* @category async
|
|
73
|
-
* @rtype ({
|
|
73
|
+
* @rtype ({
|
|
74
|
+
* sender?: String,
|
|
75
|
+
* recipientId: String,
|
|
76
|
+
* amount: Number,
|
|
77
|
+
* fee?: Number,
|
|
78
|
+
* ttl?: Number,
|
|
79
|
+
* nonce?: Number,
|
|
80
|
+
* payload?: String
|
|
81
|
+
* }) => tx: Promise[String]
|
|
74
82
|
* @param {Object} options - The object to extract properties from
|
|
75
83
|
* @return {String} `spend_tx` transaction
|
|
76
84
|
*/
|
|
@@ -81,7 +89,9 @@ var Tx = stampit(required({
|
|
|
81
89
|
* @instance
|
|
82
90
|
* @abstract
|
|
83
91
|
* @category async
|
|
84
|
-
* @rtype ({
|
|
92
|
+
* @rtype ({
|
|
93
|
+
* account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
94
|
+
* }) => tx: Promise[String]
|
|
85
95
|
* @param {Object} options - The object to extract properties from
|
|
86
96
|
* @return {String} `name_preclaim_tx` transaction
|
|
87
97
|
*/
|
|
@@ -92,7 +102,9 @@ var Tx = stampit(required({
|
|
|
92
102
|
* @instance
|
|
93
103
|
* @abstract
|
|
94
104
|
* @category async
|
|
95
|
-
* @rtype ({
|
|
105
|
+
* @rtype ({
|
|
106
|
+
* account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
107
|
+
* }) => tx: Promise[String]
|
|
96
108
|
* @param {Object} options - The object to extract properties from
|
|
97
109
|
* @return {String} `name_claim_tx` transaction
|
|
98
110
|
*/
|
|
@@ -103,7 +115,14 @@ var Tx = stampit(required({
|
|
|
103
115
|
* @instance
|
|
104
116
|
* @abstract
|
|
105
117
|
* @category async
|
|
106
|
-
* @rtype ({
|
|
118
|
+
* @rtype ({
|
|
119
|
+
* account?: String,
|
|
120
|
+
* nameId: String,
|
|
121
|
+
* recipientId: String,
|
|
122
|
+
* fee?: Number,
|
|
123
|
+
* ttl?: Number,
|
|
124
|
+
* nonce?: Number
|
|
125
|
+
* }) => tx: Promise[String]
|
|
107
126
|
* @param {Object} options - The object to extract properties from
|
|
108
127
|
* @return {String} `name_transfer_tx` transaction
|
|
109
128
|
*/
|
|
@@ -114,7 +133,16 @@ var Tx = stampit(required({
|
|
|
114
133
|
* @instance
|
|
115
134
|
* @abstract
|
|
116
135
|
* @category async
|
|
117
|
-
* @rtype ({
|
|
136
|
+
* @rtype ({
|
|
137
|
+
* account?: String,
|
|
138
|
+
* nameId: String,
|
|
139
|
+
* pointers: Object,
|
|
140
|
+
* nameTtl: Number,
|
|
141
|
+
* clientTtl: Number,
|
|
142
|
+
* fee?: Number,
|
|
143
|
+
* ttl?: Number,
|
|
144
|
+
* nonce?: Number
|
|
145
|
+
* }) => tx: Promise[String]
|
|
118
146
|
* @param {Object} options - The object to extract properties from
|
|
119
147
|
* @return {String} `name_update_tx` transaction
|
|
120
148
|
*/
|
|
@@ -125,7 +153,9 @@ var Tx = stampit(required({
|
|
|
125
153
|
* @instance
|
|
126
154
|
* @abstract
|
|
127
155
|
* @category async
|
|
128
|
-
* @rtype ({
|
|
156
|
+
* @rtype ({
|
|
157
|
+
* account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number
|
|
158
|
+
* }) => tx: Promise[String]
|
|
129
159
|
* @param {Object} options - The object to extract properties from
|
|
130
160
|
* @return {String} `name_revoke_tx` transaction
|
|
131
161
|
*/
|
|
@@ -136,7 +166,19 @@ var Tx = stampit(required({
|
|
|
136
166
|
* @instance
|
|
137
167
|
* @abstract
|
|
138
168
|
* @category async
|
|
139
|
-
* @rtype ({
|
|
169
|
+
* @rtype ({
|
|
170
|
+
* owner: String,
|
|
171
|
+
* code: String,
|
|
172
|
+
* callData: String,
|
|
173
|
+
* vmVersion: Number,
|
|
174
|
+
* deposit: Number,
|
|
175
|
+
* amount: Number,
|
|
176
|
+
* gas: Number,
|
|
177
|
+
* gasPrice: Number,
|
|
178
|
+
* fee?: Number,
|
|
179
|
+
* ttl?: Number,
|
|
180
|
+
* nonce?: Number
|
|
181
|
+
* }) => tx: Promise[String]
|
|
140
182
|
* @param {Object} options - The object to extract properties from
|
|
141
183
|
* @return {String} `contract_create_tx` transaction
|
|
142
184
|
*/
|
|
@@ -147,7 +189,18 @@ var Tx = stampit(required({
|
|
|
147
189
|
* @instance
|
|
148
190
|
* @abstract
|
|
149
191
|
* @category async
|
|
150
|
-
* @rtype ({
|
|
192
|
+
* @rtype ({
|
|
193
|
+
* callerId: String,
|
|
194
|
+
* contract: String,
|
|
195
|
+
* callData: String,
|
|
196
|
+
* vmVersion: Number,
|
|
197
|
+
* amount: Number,
|
|
198
|
+
* gas: Number,
|
|
199
|
+
* gasPrice: Number,
|
|
200
|
+
* fee?: Number,
|
|
201
|
+
* ttl?: Number,
|
|
202
|
+
* nonce?: Number
|
|
203
|
+
* }) => tx: Promise[String]
|
|
151
204
|
* @param {Object} options - The object to extract properties from
|
|
152
205
|
* @return {String} `contract_call_tx` transaction
|
|
153
206
|
*/
|
|
@@ -158,7 +211,17 @@ var Tx = stampit(required({
|
|
|
158
211
|
* @instance
|
|
159
212
|
* @abstract
|
|
160
213
|
* @category async
|
|
161
|
-
* @rtype ({
|
|
214
|
+
* @rtype ({
|
|
215
|
+
* accountId: String,
|
|
216
|
+
* queryFormat: String,
|
|
217
|
+
* responseFormat: String,
|
|
218
|
+
* queryFee: String|Number,
|
|
219
|
+
* oracleTtl: Object,
|
|
220
|
+
* vmVersion: Number = ORACLE_VM_VERSION,
|
|
221
|
+
* fee?: Number,
|
|
222
|
+
* ttl?: Number,
|
|
223
|
+
* nonce?: Number
|
|
224
|
+
* }) => tx: Promise[String]
|
|
162
225
|
* @param {Object} options - The object to extract properties from
|
|
163
226
|
* @return {String} `oracle_register_tx` transaction
|
|
164
227
|
*/
|
|
@@ -169,7 +232,14 @@ var Tx = stampit(required({
|
|
|
169
232
|
* @instance
|
|
170
233
|
* @abstract
|
|
171
234
|
* @category async
|
|
172
|
-
* @rtype ({
|
|
235
|
+
* @rtype ({
|
|
236
|
+
* oracleId: String,
|
|
237
|
+
* callerId: String,
|
|
238
|
+
* oracleTtl: Object,
|
|
239
|
+
* fee?: Number,
|
|
240
|
+
* ttl: Number,
|
|
241
|
+
* nonce?: Number
|
|
242
|
+
* }) => tx: Promise[String]
|
|
173
243
|
* @param {Object} options - The object to extract properties from
|
|
174
244
|
* @return {String} `oracle_extend_tx` transaction
|
|
175
245
|
*/
|
|
@@ -180,7 +250,17 @@ var Tx = stampit(required({
|
|
|
180
250
|
* @instance
|
|
181
251
|
* @abstract
|
|
182
252
|
* @category async
|
|
183
|
-
* @rtype ({
|
|
253
|
+
* @rtype ({
|
|
254
|
+
* oracleId: String,
|
|
255
|
+
* responseTtl: Object,
|
|
256
|
+
* query: String,
|
|
257
|
+
* queryTtl: Object,
|
|
258
|
+
* queryFee: String|Number,
|
|
259
|
+
* senderId: String,
|
|
260
|
+
* fee?: Number,
|
|
261
|
+
* ttl: Number,
|
|
262
|
+
* nonce?: Number
|
|
263
|
+
* }) => tx: Promise[String]
|
|
184
264
|
* @param {Object} options - The object to extract properties from
|
|
185
265
|
* @return {String} `oracle_post_query_tx` transaction
|
|
186
266
|
*/
|
|
@@ -191,7 +271,16 @@ var Tx = stampit(required({
|
|
|
191
271
|
* @instance
|
|
192
272
|
* @abstract
|
|
193
273
|
* @category async
|
|
194
|
-
* @rtype ({
|
|
274
|
+
* @rtype ({
|
|
275
|
+
* oracleId: String,
|
|
276
|
+
* callerId: String,
|
|
277
|
+
* responseTtl: Object,
|
|
278
|
+
* queryId: String,
|
|
279
|
+
* response: String,
|
|
280
|
+
* fee?: Number,
|
|
281
|
+
* ttl?: Number,
|
|
282
|
+
* nonce?: Number
|
|
283
|
+
* }) => tx: Promise[String]
|
|
195
284
|
* @param {Object} options - The object to extract properties from
|
|
196
285
|
* @return {String} `oracle_respond_tx` transaction
|
|
197
286
|
*/
|
package/es/tx/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/tx/index.js"],"names":["stampit","required","Tx","methods","spendTx","namePreclaimTx","nameClaimTx","nameTransferTx","nameUpdateTx","nameRevokeTx","contractCreateTx","contractCallTx","oracleRegisterTx","oracleExtendTx","oraclePostQueryTx","oracleRespondTx","getAccountNonce","channelCloseSoloTx","channelSlashTx","channelSettleTx","channelSnapshotSoloTx","gaAttachTx","getVmVersion","prepareTxParams"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,EAAE,GAAGF,OAAO,CAACC,QAAQ,CAAC;AAC1BE,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAEH,QADF;AAEPI,IAAAA,cAAc,EAAEJ,QAFT;AAGPK,IAAAA,WAAW,EAAEL,QAHN;AAIPM,IAAAA,cAAc,EAAEN,QAJT;AAKPO,IAAAA,YAAY,EAAEP,QALP;AAMPQ,IAAAA,YAAY,EAAER,QANP;AAOPS,IAAAA,gBAAgB,EAAET,QAPX;AAQPU,IAAAA,cAAc,EAAEV,QART;AASPW,IAAAA,gBAAgB,EAAEX,QATX;AAUPY,IAAAA,cAAc,EAAEZ,QAVT;AAWPa,IAAAA,iBAAiB,EAAEb,QAXZ;AAYPc,IAAAA,eAAe,EAAEd,QAZV;AAaPe,IAAAA,eAAe,EAAEf,QAbV;AAcPgB,IAAAA,kBAAkB,EAAEhB,QAdb;AAePiB,IAAAA,cAAc,EAAEjB,QAfT;AAgBPkB,IAAAA,eAAe,EAAElB,QAhBV;AAiBPmB,IAAAA,qBAAqB,EAAEnB,QAjBhB;AAkBPoB,IAAAA,UAAU,EAAEpB,QAlBL;AAmBPqB,IAAAA,YAAY,EAAErB,QAnBP;AAoBPsB,IAAAA,eAAe,EAAEtB;AApBV;AADiB,CAAD,CAAT,CAAlB;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAeC,EAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Tx module\n * @module @aeternity/aepp-sdk/es/tx\n * @export Tx\n * @example import { Tx } from '@aeternity/aepp-sdk'\n */\n\nimport stampit from '@stamp/it'\nimport { required } from '@stamp/required'\n\n/**\n * Basic Tx Stamp\n *\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n *\n * Tx is one of the three basic building blocks of an\n * {@link module:@aeternity/aepp-sdk/es/ae--Ae} client and provides methods to\n * create aeternity transactions.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Tx instance\n * @example Tx()\n */\nconst Tx = stampit(required({\n methods: {\n spendTx: required,\n namePreclaimTx: required,\n nameClaimTx: required,\n nameTransferTx: required,\n nameUpdateTx: required,\n nameRevokeTx: required,\n contractCreateTx: required,\n contractCallTx: required,\n oracleRegisterTx: required,\n oracleExtendTx: required,\n oraclePostQueryTx: required,\n oracleRespondTx: required,\n getAccountNonce: required,\n channelCloseSoloTx: required,\n channelSlashTx: required,\n channelSettleTx: required,\n channelSnapshotSoloTx: required,\n gaAttachTx: required,\n getVmVersion: required,\n prepareTxParams: required\n }\n}))\n\n/**\n * Create a `spend_tx` transaction\n * @function spendTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({sender?: String, recipientId: String, amount: Number, fee?: Number, ttl?: Number, nonce?: Number, payload?: String}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `spend_tx` transaction\n */\n\n/**\n * Create a `name_preclaim_tx` transaction\n * @function namePreclaimTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_preclaim_tx` transaction\n */\n\n/**\n * Create a `name_claim_tx` transaction\n * @function nameClaimTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_claim_tx` transaction\n */\n\n/**\n * Create a `name_transfer_tx` transaction\n * @function nameTransferTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({account?: String, nameId: String, recipientId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_transfer_tx` transaction\n */\n\n/**\n * Create a `name_update_tx` transaction\n * @function nameUpdateTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({account?: String, nameId: String, pointers: Object, nameTtl: Number, clientTtl: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_update_tx` transaction\n */\n\n/**\n * Create a `name_revoke_tx` transaction\n * @function nameRevokeTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_revoke_tx` transaction\n */\n\n/**\n * Create a `contract_create_tx` transaction\n * @function contractCreateTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({owner: String, code: String, callData: String, vmVersion: Number, deposit: Number, amount: Number, gas: Number, gasPrice: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `contract_create_tx` transaction\n */\n\n/**\n * Create a `contract_call_tx` transaction\n * @function contractCallTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({callerId: String, contract: String, callData: String, vmVersion: Number, amount: Number, gas: Number, gasPrice: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `contract_call_tx` transaction\n */\n\n/**\n * Create a `oracle_register_tx` transaction\n * @function oracleRegisterTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({ accountId: String, queryFormat: String, responseFormat: String, queryFee: String|Number, oracleTtl: Object, vmVersion: Number = ORACLE_VM_VERSION, fee?: Number, ttl?: Number, nonce?: Number }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_register_tx` transaction\n */\n\n/**\n * Create a `oracle_extend_tx` transaction\n * @function oracleExtendTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({ oracleId: String, callerId: String, oracleTtl: Object, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_extend_tx` transaction\n */\n\n/**\n * Create a `oracle_post_query_tx` transaction\n * @function oraclePostQuery\n * @instance\n * @abstract\n * @category async\n * @rtype ({ oracleId: String, responseTtl: Object, query: String, queryTtl: Object, queryFee: String|Number, senderId: String, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_post_query_tx` transaction\n */\n\n/**\n * Create a `oracle_respond_tx` transaction\n * @function oracleRespondTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({ oracleId: String, callerId: String, responseTtl: Object, queryId: String, response: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_respond_tx` transaction\n */\n\n/**\n * Get Account Nonce\n * @function getAccountNonce\n * @instance\n * @abstract\n * @category async\n * @rtype (address) => result: Number\n * @param {String} address - Account public key\n * @return {Number} Result\n */\n\nexport default Tx\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/tx/index.js"],"names":["stampit","required","Tx","methods","spendTx","namePreclaimTx","nameClaimTx","nameTransferTx","nameUpdateTx","nameRevokeTx","contractCreateTx","contractCallTx","oracleRegisterTx","oracleExtendTx","oraclePostQueryTx","oracleRespondTx","getAccountNonce","channelCloseSoloTx","channelSlashTx","channelSettleTx","channelSnapshotSoloTx","gaAttachTx","getVmVersion","prepareTxParams"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,OAAP,MAAoB,WAApB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,EAAE,GAAGF,OAAO,CAACC,QAAQ,CAAC;AAC1BE,EAAAA,OAAO,EAAE;AACPC,IAAAA,OAAO,EAAEH,QADF;AAEPI,IAAAA,cAAc,EAAEJ,QAFT;AAGPK,IAAAA,WAAW,EAAEL,QAHN;AAIPM,IAAAA,cAAc,EAAEN,QAJT;AAKPO,IAAAA,YAAY,EAAEP,QALP;AAMPQ,IAAAA,YAAY,EAAER,QANP;AAOPS,IAAAA,gBAAgB,EAAET,QAPX;AAQPU,IAAAA,cAAc,EAAEV,QART;AASPW,IAAAA,gBAAgB,EAAEX,QATX;AAUPY,IAAAA,cAAc,EAAEZ,QAVT;AAWPa,IAAAA,iBAAiB,EAAEb,QAXZ;AAYPc,IAAAA,eAAe,EAAEd,QAZV;AAaPe,IAAAA,eAAe,EAAEf,QAbV;AAcPgB,IAAAA,kBAAkB,EAAEhB,QAdb;AAePiB,IAAAA,cAAc,EAAEjB,QAfT;AAgBPkB,IAAAA,eAAe,EAAElB,QAhBV;AAiBPmB,IAAAA,qBAAqB,EAAEnB,QAjBhB;AAkBPoB,IAAAA,UAAU,EAAEpB,QAlBL;AAmBPqB,IAAAA,YAAY,EAAErB,QAnBP;AAoBPsB,IAAAA,eAAe,EAAEtB;AApBV;AADiB,CAAD,CAAT,CAAlB;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAeC,EAAf","sourcesContent":["/*\n * ISC License (ISC)\n * Copyright (c) 2018 aeternity developers\n *\n * Permission to use, copy, modify, and/or distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n * copyright notice and this permission notice appear in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\n * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\n * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\n * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n * PERFORMANCE OF THIS SOFTWARE.\n */\n\n/**\n * Tx module\n * @module @aeternity/aepp-sdk/es/tx\n * @export Tx\n * @example import { Tx } from '@aeternity/aepp-sdk'\n */\n\nimport stampit from '@stamp/it'\nimport { required } from '@stamp/required'\n\n/**\n * Basic Tx Stamp\n *\n * Attempting to create instances from the Stamp without overwriting all\n * abstract methods using composition will result in an exception.\n *\n * Tx is one of the three basic building blocks of an\n * {@link module:@aeternity/aepp-sdk/es/ae--Ae} client and provides methods to\n * create aeternity transactions.\n * @function\n * @alias module:@aeternity/aepp-sdk/es/tx\n * @rtype Stamp\n * @param {Object} [options={}] - Initializer object\n * @return {Object} Tx instance\n * @example Tx()\n */\nconst Tx = stampit(required({\n methods: {\n spendTx: required,\n namePreclaimTx: required,\n nameClaimTx: required,\n nameTransferTx: required,\n nameUpdateTx: required,\n nameRevokeTx: required,\n contractCreateTx: required,\n contractCallTx: required,\n oracleRegisterTx: required,\n oracleExtendTx: required,\n oraclePostQueryTx: required,\n oracleRespondTx: required,\n getAccountNonce: required,\n channelCloseSoloTx: required,\n channelSlashTx: required,\n channelSettleTx: required,\n channelSnapshotSoloTx: required,\n gaAttachTx: required,\n getVmVersion: required,\n prepareTxParams: required\n }\n}))\n\n/**\n * Create a `spend_tx` transaction\n * @function spendTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * sender?: String,\n * recipientId: String,\n * amount: Number,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number,\n * payload?: String\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `spend_tx` transaction\n */\n\n/**\n * Create a `name_preclaim_tx` transaction\n * @function namePreclaimTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_preclaim_tx` transaction\n */\n\n/**\n * Create a `name_claim_tx` transaction\n * @function nameClaimTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_claim_tx` transaction\n */\n\n/**\n * Create a `name_transfer_tx` transaction\n * @function nameTransferTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * account?: String,\n * nameId: String,\n * recipientId: String,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_transfer_tx` transaction\n */\n\n/**\n * Create a `name_update_tx` transaction\n * @function nameUpdateTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * account?: String,\n * nameId: String,\n * pointers: Object,\n * nameTtl: Number,\n * clientTtl: Number,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_update_tx` transaction\n */\n\n/**\n * Create a `name_revoke_tx` transaction\n * @function nameRevokeTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `name_revoke_tx` transaction\n */\n\n/**\n * Create a `contract_create_tx` transaction\n * @function contractCreateTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * owner: String,\n * code: String,\n * callData: String,\n * vmVersion: Number,\n * deposit: Number,\n * amount: Number,\n * gas: Number,\n * gasPrice: Number,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `contract_create_tx` transaction\n */\n\n/**\n * Create a `contract_call_tx` transaction\n * @function contractCallTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * callerId: String,\n * contract: String,\n * callData: String,\n * vmVersion: Number,\n * amount: Number,\n * gas: Number,\n * gasPrice: Number,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `contract_call_tx` transaction\n */\n\n/**\n * Create a `oracle_register_tx` transaction\n * @function oracleRegisterTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * accountId: String,\n * queryFormat: String,\n * responseFormat: String,\n * queryFee: String|Number,\n * oracleTtl: Object,\n * vmVersion: Number = ORACLE_VM_VERSION,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_register_tx` transaction\n */\n\n/**\n * Create a `oracle_extend_tx` transaction\n * @function oracleExtendTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * oracleId: String,\n * callerId: String,\n * oracleTtl: Object,\n * fee?: Number,\n * ttl: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_extend_tx` transaction\n */\n\n/**\n * Create a `oracle_post_query_tx` transaction\n * @function oraclePostQuery\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * oracleId: String,\n * responseTtl: Object,\n * query: String,\n * queryTtl: Object,\n * queryFee: String|Number,\n * senderId: String,\n * fee?: Number,\n * ttl: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_post_query_tx` transaction\n */\n\n/**\n * Create a `oracle_respond_tx` transaction\n * @function oracleRespondTx\n * @instance\n * @abstract\n * @category async\n * @rtype ({\n * oracleId: String,\n * callerId: String,\n * responseTtl: Object,\n * queryId: String,\n * response: String,\n * fee?: Number,\n * ttl?: Number,\n * nonce?: Number\n * }) => tx: Promise[String]\n * @param {Object} options - The object to extract properties from\n * @return {String} `oracle_respond_tx` transaction\n */\n\n/**\n * Get Account Nonce\n * @function getAccountNonce\n * @instance\n * @abstract\n * @category async\n * @rtype (address) => result: Number\n * @param {String} address - Account public key\n * @return {Number} Result\n */\n\nexport default Tx\n"],"file":"index.js"}
|
package/es/tx/tx-object.js
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
|
4
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
|
7
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
|
9
|
-
import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
|
|
10
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
11
|
-
import _typeof from "@babel/runtime-corejs3/helpers/typeof";
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
-
|
|
17
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
18
|
-
import _Object$values from "@babel/runtime-corejs3/core-js-stable/object/values";
|
|
19
|
-
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
20
|
-
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
21
|
-
|
|
22
1
|
/**
|
|
23
2
|
* TxObject module
|
|
24
3
|
* @module @aeternity/aepp-sdk/es/tx/tx-object
|
|
@@ -26,7 +5,6 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/insta
|
|
|
26
5
|
* @example import TxObject from '@aeternity/aepp-sdk/es/tx/tx-object'
|
|
27
6
|
*/
|
|
28
7
|
import stampit from '@stamp/it';
|
|
29
|
-
import { assertedType } from '../utils/crypto';
|
|
30
8
|
import { buildTx, calculateFee, unpackTx } from './builder';
|
|
31
9
|
import { TX_TYPE } from './builder/schema';
|
|
32
10
|
import { encode } from './builder/helpers';
|
|
@@ -38,37 +16,37 @@ import { isHex } from '../utils/string';
|
|
|
38
16
|
* @param {Object} params Transaction params
|
|
39
17
|
* @param {Object} [options={}] Options
|
|
40
18
|
* @throws {Error} Arguments validation error's
|
|
41
|
-
* @return {{
|
|
19
|
+
* @return {{
|
|
20
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String
|
|
21
|
+
* }}
|
|
42
22
|
*/
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (typeof type !== 'string' || !_includesInstanceProperty(_context = _Object$values(TX_TYPE)).call(_context, type)) throw new Error("Unknown transaction type ".concat(type));
|
|
50
|
-
var fee = calculateFee(params.fee, type, {
|
|
24
|
+
const buildTransaction = function (type, params) {
|
|
25
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
26
|
+
if (typeof params !== 'object') throw new Error('"params" should be an object');
|
|
27
|
+
if (typeof type !== 'string' || !Object.values(TX_TYPE).includes(type)) throw new Error(`Unknown transaction type ${type}`);
|
|
28
|
+
const fee = calculateFee(params.fee, type, {
|
|
51
29
|
gas: params.gas,
|
|
52
|
-
params
|
|
30
|
+
params,
|
|
53
31
|
vsn: params.vsn
|
|
54
32
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
33
|
+
const {
|
|
34
|
+
rlpEncoded,
|
|
35
|
+
binary,
|
|
36
|
+
tx: encodedTx,
|
|
37
|
+
txObject
|
|
38
|
+
} = buildTx({ ...params,
|
|
39
|
+
fee
|
|
40
|
+
}, type, {
|
|
41
|
+
vsn: params.vsn,
|
|
42
|
+
...options
|
|
43
|
+
});
|
|
66
44
|
return {
|
|
67
|
-
rlpEncoded
|
|
68
|
-
binary
|
|
69
|
-
encodedTx
|
|
45
|
+
rlpEncoded,
|
|
46
|
+
binary,
|
|
47
|
+
encodedTx,
|
|
70
48
|
params: txObject,
|
|
71
|
-
type
|
|
49
|
+
type
|
|
72
50
|
};
|
|
73
51
|
};
|
|
74
52
|
/**
|
|
@@ -76,44 +54,44 @@ var buildTransaction = function buildTransaction(type, params) {
|
|
|
76
54
|
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
77
55
|
* @param {Buffer|String} tx RLP encoded binary or base64c(rlpBinary) string
|
|
78
56
|
* @throws {Error} Arguments validation error's
|
|
79
|
-
* @return {{
|
|
57
|
+
* @return {{
|
|
58
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
59
|
+
* }}
|
|
80
60
|
*/
|
|
81
61
|
|
|
82
62
|
|
|
83
|
-
|
|
84
|
-
if (!tx) throw new Error(
|
|
63
|
+
const unpackTransaction = tx => {
|
|
64
|
+
if (!tx) throw new Error(`Invalid transaction: ${tx}`);
|
|
85
65
|
|
|
86
66
|
if (typeof tx === 'string') {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
binary = _unpackTx.binary;
|
|
94
|
-
|
|
67
|
+
const {
|
|
68
|
+
txType: type,
|
|
69
|
+
tx: params,
|
|
70
|
+
rlpEncoded,
|
|
71
|
+
binary
|
|
72
|
+
} = unpackTx(tx);
|
|
95
73
|
return {
|
|
96
74
|
encodedTx: tx,
|
|
97
|
-
type
|
|
98
|
-
params
|
|
99
|
-
rlpEncoded
|
|
100
|
-
binary
|
|
75
|
+
type,
|
|
76
|
+
params,
|
|
77
|
+
rlpEncoded,
|
|
78
|
+
binary
|
|
101
79
|
};
|
|
102
80
|
}
|
|
103
81
|
|
|
104
82
|
if (Buffer.isBuffer(tx)) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
83
|
+
const {
|
|
84
|
+
txType: type,
|
|
85
|
+
tx: params,
|
|
86
|
+
rlpEncoded,
|
|
87
|
+
binary
|
|
88
|
+
} = unpackTx(tx, true);
|
|
111
89
|
return {
|
|
112
90
|
encodedTx: encode(tx, 'tx'),
|
|
113
|
-
type
|
|
114
|
-
params
|
|
115
|
-
rlpEncoded
|
|
116
|
-
binary
|
|
91
|
+
type,
|
|
92
|
+
params,
|
|
93
|
+
rlpEncoded,
|
|
94
|
+
binary
|
|
117
95
|
};
|
|
118
96
|
}
|
|
119
97
|
};
|
|
@@ -126,18 +104,19 @@ var unpackTransaction = function unpackTransaction(tx) {
|
|
|
126
104
|
* @param {String} type Transaction type
|
|
127
105
|
* @param {Object} [options={}] Options
|
|
128
106
|
* @throws {Error} Arguments validation error's
|
|
129
|
-
* @return {{
|
|
107
|
+
* @return {{
|
|
108
|
+
* encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
|
|
109
|
+
* }}
|
|
130
110
|
*/
|
|
131
111
|
|
|
132
112
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
113
|
+
const initTransaction = function () {
|
|
114
|
+
let {
|
|
115
|
+
tx,
|
|
116
|
+
params,
|
|
117
|
+
type,
|
|
118
|
+
options = {}
|
|
119
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
141
120
|
if (params && type) return buildTransaction(type, params, options);
|
|
142
121
|
if (tx) return unpackTransaction(tx);
|
|
143
122
|
throw new Error('Invalid TxObject arguments. Please provide one of { tx: "tx_asdasd23..." } or { type: "spendTx", params: {...} }');
|
|
@@ -159,37 +138,38 @@ var initTransaction = function initTransaction() {
|
|
|
159
138
|
*/
|
|
160
139
|
|
|
161
140
|
|
|
162
|
-
export
|
|
163
|
-
init
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
141
|
+
export const TxObject = stampit({
|
|
142
|
+
init() {
|
|
143
|
+
let {
|
|
144
|
+
tx,
|
|
145
|
+
params,
|
|
146
|
+
type,
|
|
147
|
+
options = {}
|
|
148
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
171
149
|
this.options = options;
|
|
172
150
|
this.signatures = [];
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
options: options
|
|
151
|
+
Object.assign(this, initTransaction({
|
|
152
|
+
tx,
|
|
153
|
+
params,
|
|
154
|
+
type,
|
|
155
|
+
options
|
|
179
156
|
}));
|
|
180
157
|
|
|
181
158
|
if (this.type === TX_TYPE.signed) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
txType
|
|
186
|
-
|
|
159
|
+
const {
|
|
160
|
+
signatures,
|
|
161
|
+
encodedTx: {
|
|
162
|
+
txType,
|
|
163
|
+
tx
|
|
164
|
+
}
|
|
165
|
+
} = this.params;
|
|
187
166
|
this.signatures = signatures;
|
|
188
|
-
this.params =
|
|
167
|
+
this.params = tx;
|
|
189
168
|
this.type = txType;
|
|
190
169
|
this.isSigned = true;
|
|
191
170
|
}
|
|
192
171
|
},
|
|
172
|
+
|
|
193
173
|
statics: {
|
|
194
174
|
/**
|
|
195
175
|
* Create txObject from base64c RLP encoded transaction string with 'tx_' prefix
|
|
@@ -198,11 +178,9 @@ export var TxObject = stampit({
|
|
|
198
178
|
* @param {String} tx Transaction string (tx_23fsdgsdfg...)
|
|
199
179
|
* @return {TxObject}
|
|
200
180
|
*/
|
|
201
|
-
fromString:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
});
|
|
205
|
-
},
|
|
181
|
+
fromString: tx => TxObject({
|
|
182
|
+
tx
|
|
183
|
+
}),
|
|
206
184
|
|
|
207
185
|
/**
|
|
208
186
|
* Create txObject from transaction RLP binary
|
|
@@ -211,11 +189,9 @@ export var TxObject = stampit({
|
|
|
211
189
|
* @param {Buffer} tx Transaction RLP binary
|
|
212
190
|
* @return {TxObject}
|
|
213
191
|
*/
|
|
214
|
-
fromRlp:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
}
|
|
192
|
+
fromRlp: tx => TxObject({
|
|
193
|
+
tx
|
|
194
|
+
})
|
|
219
195
|
},
|
|
220
196
|
methods: {
|
|
221
197
|
/**
|
|
@@ -225,17 +201,18 @@ export var TxObject = stampit({
|
|
|
225
201
|
* @param options
|
|
226
202
|
* @return {TxObject}
|
|
227
203
|
*/
|
|
228
|
-
setProp
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if (
|
|
204
|
+
setProp() {
|
|
205
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
206
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
207
|
+
if (typeof props !== 'object') throw new Error('Props should be an object');
|
|
232
208
|
this.isSigned = false;
|
|
233
209
|
this.signatures = [];
|
|
234
|
-
|
|
235
|
-
|
|
210
|
+
Object.assign(this, buildTransaction(this.type, { ...this.params,
|
|
211
|
+
...props,
|
|
236
212
|
fee: null
|
|
237
|
-
}
|
|
238
|
-
|
|
213
|
+
}, { ...this.options,
|
|
214
|
+
...options
|
|
215
|
+
}));
|
|
239
216
|
return this;
|
|
240
217
|
},
|
|
241
218
|
|
|
@@ -244,7 +221,7 @@ export var TxObject = stampit({
|
|
|
244
221
|
* @alias module:@aeternity/aepp-sdk/es/tx/tx-object
|
|
245
222
|
* @return {Array} Array of signatures
|
|
246
223
|
*/
|
|
247
|
-
getSignatures
|
|
224
|
+
getSignatures() {
|
|
248
225
|
if (!this.isSigned) throw new Error('Signature not found, transaction is not signed');
|
|
249
226
|
return this.signatures;
|
|
250
227
|
},
|
|
@@ -255,22 +232,20 @@ export var TxObject = stampit({
|
|
|
255
232
|
* @param {Buffer|String} signature Signature to add ( Can be: Buffer | Uint8Array | HexString )
|
|
256
233
|
* @return {void}
|
|
257
234
|
*/
|
|
258
|
-
addSignature
|
|
259
|
-
var _context2;
|
|
260
|
-
|
|
235
|
+
addSignature(signature) {
|
|
261
236
|
signature = isHex(signature) ? Buffer.from(signature, 'hex') : signature;
|
|
262
237
|
if (!Buffer.isBuffer(signature) && !(signature instanceof Uint8Array)) throw new Error('Invalid signature, signature must be of type Buffer or Uint8Array');
|
|
263
|
-
|
|
264
|
-
_Object$assign(this, buildTransaction(TX_TYPE.signed, {
|
|
238
|
+
Object.assign(this, buildTransaction(TX_TYPE.signed, {
|
|
265
239
|
encodedTx: this.rlpEncoded,
|
|
266
|
-
signatures: [
|
|
240
|
+
signatures: [[...this.signatures, signature]]
|
|
267
241
|
}));
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
242
|
+
const {
|
|
243
|
+
signatures,
|
|
244
|
+
encodedTx: {
|
|
245
|
+
txType,
|
|
246
|
+
tx
|
|
247
|
+
}
|
|
248
|
+
} = this.params;
|
|
274
249
|
this.signatures = signatures;
|
|
275
250
|
this.params = tx;
|
|
276
251
|
this.type = txType;
|
|
@@ -283,17 +258,18 @@ export var TxObject = stampit({
|
|
|
283
258
|
* @param {Object} props
|
|
284
259
|
* @return {String} fee
|
|
285
260
|
*/
|
|
286
|
-
calculateMinFee
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
261
|
+
calculateMinFee() {
|
|
262
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
263
|
+
const params = { ...this.params,
|
|
264
|
+
...props
|
|
265
|
+
};
|
|
291
266
|
return calculateFee(0, this.type, {
|
|
292
267
|
gas: params.gas,
|
|
293
|
-
params
|
|
268
|
+
params,
|
|
294
269
|
vsn: params.vsn
|
|
295
270
|
});
|
|
296
271
|
}
|
|
272
|
+
|
|
297
273
|
}
|
|
298
274
|
});
|
|
299
275
|
export default TxObject;
|