@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.
Files changed (159) hide show
  1. package/CHANGELOG.md +216 -337
  2. package/README.md +16 -9
  3. package/dist/aepp-sdk.browser-script.js +1 -1
  4. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  5. package/dist/aepp-sdk.browser-script.js.map +1 -1
  6. package/dist/aepp-sdk.browser.js +1 -1
  7. package/dist/aepp-sdk.browser.js.map +1 -1
  8. package/dist/aepp-sdk.js +1 -1
  9. package/dist/aepp-sdk.js.map +1 -1
  10. package/es/account/base.js +36 -120
  11. package/es/account/base.js.map +1 -1
  12. package/es/account/memory.js +17 -19
  13. package/es/account/memory.js.map +1 -1
  14. package/es/account/multiple.js +79 -156
  15. package/es/account/multiple.js.map +1 -1
  16. package/es/ae/aens.js +205 -626
  17. package/es/ae/aens.js.map +1 -1
  18. package/es/ae/contract.js +114 -918
  19. package/es/ae/contract.js.map +1 -1
  20. package/es/ae/index.js +90 -250
  21. package/es/ae/index.js.map +1 -1
  22. package/es/ae/oracle.js +136 -504
  23. package/es/ae/oracle.js.map +1 -1
  24. package/es/ae/universal.js.map +1 -1
  25. package/es/chain/index.js +12 -27
  26. package/es/chain/index.js.map +1 -1
  27. package/es/chain/node.js +289 -1020
  28. package/es/chain/node.js.map +1 -1
  29. package/es/channel/handlers.js +597 -1086
  30. package/es/channel/handlers.js.map +1 -1
  31. package/es/channel/index.js +238 -465
  32. package/es/channel/index.js.map +1 -1
  33. package/es/channel/internal.js +129 -301
  34. package/es/channel/internal.js.map +1 -1
  35. package/es/contract/aci/index.js +328 -495
  36. package/es/contract/aci/index.js.map +1 -1
  37. package/es/contract/aci/transformation.js +35 -711
  38. package/es/contract/aci/transformation.js.map +1 -1
  39. package/es/contract/compiler.js +131 -203
  40. package/es/contract/compiler.js.map +1 -1
  41. package/es/contract/ga/helpers.js +17 -122
  42. package/es/contract/ga/helpers.js.map +1 -1
  43. package/es/contract/ga/index.js +108 -249
  44. package/es/contract/ga/index.js.map +1 -1
  45. package/es/contract/index.js +7 -3
  46. package/es/contract/index.js.map +1 -1
  47. package/es/index.js +3 -3
  48. package/es/index.js.map +1 -1
  49. package/es/node-pool/index.js +57 -74
  50. package/es/node-pool/index.js.map +1 -1
  51. package/es/node.js +65 -161
  52. package/es/node.js.map +1 -1
  53. package/es/other.d.ts +1 -1
  54. package/es/tx/builder/helpers.js +62 -115
  55. package/es/tx/builder/helpers.js.map +1 -1
  56. package/es/tx/builder/index.js +218 -309
  57. package/es/tx/builder/index.js.map +1 -1
  58. package/es/tx/builder/schema.js +586 -573
  59. package/es/tx/builder/schema.js.map +1 -1
  60. package/es/tx/index.js +102 -13
  61. package/es/tx/index.js.map +1 -1
  62. package/es/tx/tx-object.js +114 -138
  63. package/es/tx/tx-object.js.map +1 -1
  64. package/es/tx/tx.js +810 -1586
  65. package/es/tx/tx.js.map +1 -1
  66. package/es/tx/validator.js +191 -426
  67. package/es/tx/validator.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +20 -23
  69. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +53 -80
  71. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  72. package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
  73. package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
  74. package/es/utils/aepp-wallet-communication/content-script-bridge.js +24 -19
  75. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  76. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  77. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  78. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +191 -514
  79. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  80. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +78 -93
  81. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  82. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +381 -613
  83. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  84. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  85. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  86. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  87. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  88. package/es/utils/amount-formatter.js +41 -61
  89. package/es/utils/amount-formatter.js.map +1 -1
  90. package/es/utils/async-init.js +28 -64
  91. package/es/utils/async-init.js.map +1 -1
  92. package/es/utils/bignumber.js +3 -11
  93. package/es/utils/bignumber.js.map +1 -1
  94. package/es/utils/bytes.js +5 -9
  95. package/es/utils/bytes.js.map +1 -1
  96. package/es/utils/crypto.js +41 -106
  97. package/es/utils/crypto.js.map +1 -1
  98. package/es/utils/hd-wallet.js +45 -81
  99. package/es/utils/hd-wallet.js.map +1 -1
  100. package/es/utils/json-big.js +16 -49
  101. package/es/utils/json-big.js.map +1 -1
  102. package/es/utils/keystore.js +81 -246
  103. package/es/utils/keystore.js.map +1 -1
  104. package/es/utils/mptree.js +88 -134
  105. package/es/utils/mptree.js.map +1 -1
  106. package/es/utils/other.js +10 -60
  107. package/es/utils/other.js.map +1 -1
  108. package/es/utils/semver-satisfies.js +9 -28
  109. package/es/utils/semver-satisfies.js.map +1 -1
  110. package/es/utils/string.js +4 -13
  111. package/es/utils/string.js.map +1 -1
  112. package/es/utils/swagger.js +87 -224
  113. package/es/utils/swagger.js.map +1 -1
  114. package/package.json +51 -44
  115. package/src/account/base.js +11 -10
  116. package/src/account/multiple.js +24 -18
  117. package/src/ae/aens.js +64 -61
  118. package/src/ae/contract.js +71 -248
  119. package/src/ae/index.js +34 -9
  120. package/src/ae/oracle.js +30 -22
  121. package/src/ae/universal.js +3 -1
  122. package/src/chain/index.js +10 -16
  123. package/src/chain/node.js +38 -38
  124. package/src/channel/handlers.js +10 -4
  125. package/src/channel/index.js +44 -20
  126. package/src/contract/aci/index.js +234 -112
  127. package/src/contract/aci/transformation.js +30 -422
  128. package/src/contract/compiler.js +50 -5
  129. package/src/contract/ga/helpers.js +6 -14
  130. package/src/contract/ga/index.js +28 -28
  131. package/src/contract/index.js +6 -2
  132. package/src/index.js +4 -4
  133. package/src/node-pool/index.js +24 -13
  134. package/src/node.js +29 -30
  135. package/src/tx/builder/helpers.js +31 -56
  136. package/src/tx/builder/index.js +67 -28
  137. package/src/tx/builder/schema.js +79 -121
  138. package/src/tx/index.js +101 -12
  139. package/src/tx/tx-object.js +25 -8
  140. package/src/tx/tx.js +229 -150
  141. package/src/tx/validator.js +134 -202
  142. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  143. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
  144. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  145. package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  146. package/src/utils/aepp-wallet-communication/helpers.js +4 -2
  147. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +33 -12
  148. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  149. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +59 -29
  150. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  151. package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
  152. package/src/utils/amount-formatter.ts +1 -1
  153. package/src/utils/bignumber.ts +2 -1
  154. package/src/utils/crypto.js +4 -68
  155. package/src/utils/keystore.js +10 -2
  156. package/src/utils/other.ts +1 -1
  157. package/src/utils/semver-satisfies.ts +1 -1
  158. package/src/utils/swagger.js +22 -10
  159. 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
- var Tx = stampit(required({
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 ({sender?: String, recipientId: String, amount: Number, fee?: Number, ttl?: Number, nonce?: Number, payload?: String}) => tx: Promise[String]
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 ({account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({account?: String, nameId: String, recipientId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({account?: String, nameId: String, pointers: Object, nameTtl: Number, clientTtl: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({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]
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 ({callerId: String, contract: String, callData: String, vmVersion: Number, amount: Number, gas: Number, gasPrice: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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 ({ 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]
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 ({ oracleId: String, callerId: String, oracleTtl: Object, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]
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 ({ oracleId: String, responseTtl: Object, query: String, queryTtl: Object, queryFee: String|Number, senderId: String, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]
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 ({ oracleId: String, callerId: String, responseTtl: Object, queryId: String, response: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
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
  */
@@ -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"}
@@ -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 {{ encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String }}
19
+ * @return {{
20
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String
21
+ * }}
42
22
  */
43
23
 
44
- var buildTransaction = function buildTransaction(type, params) {
45
- var _context;
46
-
47
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
48
- if (_typeof(params) !== 'object') throw new Error('"params" should be an object');
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: params,
30
+ params,
53
31
  vsn: params.vsn
54
32
  });
55
-
56
- var _buildTx = buildTx(_objectSpread(_objectSpread({}, params), {}, {
57
- fee: fee
58
- }), type, _objectSpread({
59
- vsn: params.vsn
60
- }, options)),
61
- rlpEncoded = _buildTx.rlpEncoded,
62
- binary = _buildTx.binary,
63
- encodedTx = _buildTx.tx,
64
- txObject = _buildTx.txObject;
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: rlpEncoded,
68
- binary: binary,
69
- encodedTx: encodedTx,
45
+ rlpEncoded,
46
+ binary,
47
+ encodedTx,
70
48
  params: txObject,
71
- type: 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 {{ encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object }}
57
+ * @return {{
58
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
59
+ * }}
80
60
  */
81
61
 
82
62
 
83
- var unpackTransaction = function unpackTransaction(tx) {
84
- if (!tx) throw new Error("Invalid transaction: ".concat(tx));
63
+ const unpackTransaction = tx => {
64
+ if (!tx) throw new Error(`Invalid transaction: ${tx}`);
85
65
 
86
66
  if (typeof tx === 'string') {
87
- if (!assertedType(tx, 'tx', true)) throw new Error('Invalid transaction string. Tx should be `tx` prefixed base58c string');
88
-
89
- var _unpackTx = unpackTx(tx),
90
- type = _unpackTx.txType,
91
- params = _unpackTx.tx,
92
- rlpEncoded = _unpackTx.rlpEncoded,
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: type,
98
- params: params,
99
- rlpEncoded: rlpEncoded,
100
- binary: binary
75
+ type,
76
+ params,
77
+ rlpEncoded,
78
+ binary
101
79
  };
102
80
  }
103
81
 
104
82
  if (Buffer.isBuffer(tx)) {
105
- var _unpackTx2 = unpackTx(tx, true),
106
- _type = _unpackTx2.txType,
107
- _params = _unpackTx2.tx,
108
- _rlpEncoded = _unpackTx2.rlpEncoded,
109
- _binary = _unpackTx2.binary;
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: _type,
114
- params: _params,
115
- rlpEncoded: _rlpEncoded,
116
- binary: _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 {{encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object}}
107
+ * @return {{
108
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
109
+ * }}
130
110
  */
131
111
 
132
112
 
133
- var initTransaction = function initTransaction() {
134
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
135
- tx = _ref.tx,
136
- params = _ref.params,
137
- type = _ref.type,
138
- _ref$options = _ref.options,
139
- options = _ref$options === void 0 ? {} : _ref$options;
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 var TxObject = stampit({
163
- init: function init() {
164
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
165
- tx = _ref2.tx,
166
- params = _ref2.params,
167
- type = _ref2.type,
168
- _ref2$options = _ref2.options,
169
- options = _ref2$options === void 0 ? {} : _ref2$options;
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
- _Object$assign(this, initTransaction({
175
- tx: tx,
176
- params: params,
177
- type: type,
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
- var _this$params = this.params,
183
- signatures = _this$params.signatures,
184
- _this$params$encodedT = _this$params.encodedTx,
185
- txType = _this$params$encodedT.txType,
186
- _tx = _this$params$encodedT.tx;
159
+ const {
160
+ signatures,
161
+ encodedTx: {
162
+ txType,
163
+ tx
164
+ }
165
+ } = this.params;
187
166
  this.signatures = signatures;
188
- this.params = _tx;
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: function fromString(tx) {
202
- return TxObject({
203
- tx: tx
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: function fromRlp(tx) {
215
- return TxObject({
216
- tx: tx
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: function setProp() {
229
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
230
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
231
- if (_typeof(props) !== 'object') throw new Error('Props should be an object');
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
- _Object$assign(this, buildTransaction(this.type, _objectSpread(_objectSpread(_objectSpread({}, this.params), props), {}, {
210
+ Object.assign(this, buildTransaction(this.type, { ...this.params,
211
+ ...props,
236
212
  fee: null
237
- }), _objectSpread(_objectSpread({}, this.options), options)));
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: function 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: function addSignature(signature) {
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: [_concatInstanceProperty(_context2 = []).call(_context2, _toConsumableArray(this.signatures), [signature])]
240
+ signatures: [[...this.signatures, signature]]
267
241
  }));
268
-
269
- var _this$params2 = this.params,
270
- signatures = _this$params2.signatures,
271
- _this$params2$encoded = _this$params2.encodedTx,
272
- txType = _this$params2$encoded.txType,
273
- tx = _this$params2$encoded.tx;
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: function calculateMinFee() {
287
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
288
-
289
- var params = _objectSpread(_objectSpread({}, this.params), props);
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: params,
268
+ params,
294
269
  vsn: params.vsn
295
270
  });
296
271
  }
272
+
297
273
  }
298
274
  });
299
275
  export default TxObject;