@aeternity/aepp-sdk 10.0.0-beta.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 (113) hide show
  1. package/CHANGELOG.md +1603 -0
  2. package/dist/aepp-sdk.browser-script.js +1 -1
  3. package/dist/aepp-sdk.browser-script.js.map +1 -1
  4. package/dist/aepp-sdk.browser.js +1 -1
  5. package/dist/aepp-sdk.browser.js.map +1 -1
  6. package/dist/aepp-sdk.js +1 -1
  7. package/dist/aepp-sdk.js.map +1 -1
  8. package/es/account/base.js +3 -1
  9. package/es/account/base.js.map +1 -1
  10. package/es/account/multiple.js +4 -2
  11. package/es/account/multiple.js.map +1 -1
  12. package/es/ae/aens.js +52 -38
  13. package/es/ae/aens.js.map +1 -1
  14. package/es/ae/contract.js +9 -5
  15. package/es/ae/contract.js.map +1 -1
  16. package/es/ae/index.js +4 -3
  17. package/es/ae/index.js.map +1 -1
  18. package/es/ae/oracle.js +4 -4
  19. package/es/ae/oracle.js.map +1 -1
  20. package/es/ae/universal.js.map +1 -1
  21. package/es/chain/index.js +8 -4
  22. package/es/chain/index.js.map +1 -1
  23. package/es/chain/node.js +15 -20
  24. package/es/chain/node.js.map +1 -1
  25. package/es/channel/handlers.js.map +1 -1
  26. package/es/channel/index.js +35 -14
  27. package/es/channel/index.js.map +1 -1
  28. package/es/contract/aci/index.js +12 -7
  29. package/es/contract/aci/index.js.map +1 -1
  30. package/es/contract/compiler.js +3 -1
  31. package/es/contract/compiler.js.map +1 -1
  32. package/es/contract/ga/helpers.js +6 -6
  33. package/es/contract/ga/helpers.js.map +1 -1
  34. package/es/contract/ga/index.js +6 -2
  35. package/es/contract/ga/index.js.map +1 -1
  36. package/es/contract/index.js +6 -2
  37. package/es/contract/index.js.map +1 -1
  38. package/es/index.js +1 -0
  39. package/es/index.js.map +1 -1
  40. package/es/node-pool/index.js +4 -2
  41. package/es/node-pool/index.js.map +1 -1
  42. package/es/node.js +9 -4
  43. package/es/node.js.map +1 -1
  44. package/es/tx/builder/helpers.js +20 -33
  45. package/es/tx/builder/helpers.js.map +1 -1
  46. package/es/tx/builder/index.js +13 -6
  47. package/es/tx/builder/index.js.map +1 -1
  48. package/es/tx/builder/schema.js +5 -4
  49. package/es/tx/builder/schema.js.map +1 -1
  50. package/es/tx/index.js +101 -12
  51. package/es/tx/index.js.map +1 -1
  52. package/es/tx/tx-object.js +9 -3
  53. package/es/tx/tx-object.js.map +1 -1
  54. package/es/tx/tx.js.map +1 -1
  55. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  56. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  57. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +15 -6
  58. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  59. package/es/utils/aepp-wallet-communication/connection/index.js +2 -1
  60. package/es/utils/aepp-wallet-communication/connection/index.js.map +1 -1
  61. package/es/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  62. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  63. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  64. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +13 -5
  65. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  66. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  67. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  68. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +57 -40
  69. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  70. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  71. package/es/utils/crypto.js +1 -40
  72. package/es/utils/crypto.js.map +1 -1
  73. package/es/utils/keystore.js.map +1 -1
  74. package/es/utils/swagger.js +3 -1
  75. package/es/utils/swagger.js.map +1 -1
  76. package/package.json +11 -13
  77. package/src/account/base.js +3 -1
  78. package/src/account/multiple.js +4 -2
  79. package/src/ae/aens.js +41 -42
  80. package/src/ae/contract.js +9 -5
  81. package/src/ae/index.js +4 -3
  82. package/src/ae/oracle.js +9 -5
  83. package/src/ae/universal.js +3 -1
  84. package/src/chain/index.js +8 -4
  85. package/src/chain/node.js +17 -14
  86. package/src/channel/handlers.js +10 -3
  87. package/src/channel/index.js +40 -15
  88. package/src/contract/aci/index.js +15 -8
  89. package/src/contract/compiler.js +6 -2
  90. package/src/contract/ga/helpers.js +5 -3
  91. package/src/contract/ga/index.js +6 -2
  92. package/src/contract/index.js +6 -2
  93. package/src/index.js +2 -0
  94. package/src/node-pool/index.js +4 -2
  95. package/src/node.js +7 -4
  96. package/src/tx/builder/helpers.js +20 -33
  97. package/src/tx/builder/index.js +49 -13
  98. package/src/tx/builder/schema.js +37 -14
  99. package/src/tx/index.js +101 -12
  100. package/src/tx/tx-object.js +25 -6
  101. package/src/tx/tx.js +94 -28
  102. package/src/utils/aepp-wallet-communication/connection/browser-runtime.js +3 -2
  103. package/src/utils/aepp-wallet-communication/connection/browser-window-message.js +25 -7
  104. package/src/utils/aepp-wallet-communication/connection/index.js +2 -1
  105. package/src/utils/aepp-wallet-communication/content-script-bridge.js +10 -4
  106. package/src/utils/aepp-wallet-communication/helpers.js +4 -2
  107. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +32 -9
  108. package/src/utils/aepp-wallet-communication/rpc/rpc-client.js +9 -5
  109. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +53 -22
  110. package/src/utils/aepp-wallet-communication/wallet-detector.js +4 -1
  111. package/src/utils/crypto.js +1 -52
  112. package/src/utils/keystore.js +10 -2
  113. package/src/utils/swagger.js +1 -1
package/src/tx/index.js CHANGED
@@ -72,7 +72,15 @@ const Tx = stampit(required({
72
72
  * @instance
73
73
  * @abstract
74
74
  * @category async
75
- * @rtype ({sender?: String, recipientId: String, amount: Number, fee?: Number, ttl?: Number, nonce?: Number, payload?: String}) => tx: Promise[String]
75
+ * @rtype ({
76
+ * sender?: String,
77
+ * recipientId: String,
78
+ * amount: Number,
79
+ * fee?: Number,
80
+ * ttl?: Number,
81
+ * nonce?: Number,
82
+ * payload?: String
83
+ * }) => tx: Promise[String]
76
84
  * @param {Object} options - The object to extract properties from
77
85
  * @return {String} `spend_tx` transaction
78
86
  */
@@ -83,7 +91,9 @@ const Tx = stampit(required({
83
91
  * @instance
84
92
  * @abstract
85
93
  * @category async
86
- * @rtype ({account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
94
+ * @rtype ({
95
+ * account?: String, commitment: String, fee?: Number, ttl?: Number, nonce?: Number
96
+ * }) => tx: Promise[String]
87
97
  * @param {Object} options - The object to extract properties from
88
98
  * @return {String} `name_preclaim_tx` transaction
89
99
  */
@@ -94,7 +104,9 @@ const Tx = stampit(required({
94
104
  * @instance
95
105
  * @abstract
96
106
  * @category async
97
- * @rtype ({account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
107
+ * @rtype ({
108
+ * account?: String, name: String, nameSalt: String, fee?: Number, ttl?: Number, nonce?: Number
109
+ * }) => tx: Promise[String]
98
110
  * @param {Object} options - The object to extract properties from
99
111
  * @return {String} `name_claim_tx` transaction
100
112
  */
@@ -105,7 +117,14 @@ const Tx = stampit(required({
105
117
  * @instance
106
118
  * @abstract
107
119
  * @category async
108
- * @rtype ({account?: String, nameId: String, recipientId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
120
+ * @rtype ({
121
+ * account?: String,
122
+ * nameId: String,
123
+ * recipientId: String,
124
+ * fee?: Number,
125
+ * ttl?: Number,
126
+ * nonce?: Number
127
+ * }) => tx: Promise[String]
109
128
  * @param {Object} options - The object to extract properties from
110
129
  * @return {String} `name_transfer_tx` transaction
111
130
  */
@@ -116,7 +135,16 @@ const Tx = stampit(required({
116
135
  * @instance
117
136
  * @abstract
118
137
  * @category async
119
- * @rtype ({account?: String, nameId: String, pointers: Object, nameTtl: Number, clientTtl: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
138
+ * @rtype ({
139
+ * account?: String,
140
+ * nameId: String,
141
+ * pointers: Object,
142
+ * nameTtl: Number,
143
+ * clientTtl: Number,
144
+ * fee?: Number,
145
+ * ttl?: Number,
146
+ * nonce?: Number
147
+ * }) => tx: Promise[String]
120
148
  * @param {Object} options - The object to extract properties from
121
149
  * @return {String} `name_update_tx` transaction
122
150
  */
@@ -127,7 +155,9 @@ const Tx = stampit(required({
127
155
  * @instance
128
156
  * @abstract
129
157
  * @category async
130
- * @rtype ({account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
158
+ * @rtype ({
159
+ * account?: String, nameId: String, fee?: Number, ttl?: Number, nonce?: Number
160
+ * }) => tx: Promise[String]
131
161
  * @param {Object} options - The object to extract properties from
132
162
  * @return {String} `name_revoke_tx` transaction
133
163
  */
@@ -138,7 +168,19 @@ const Tx = stampit(required({
138
168
  * @instance
139
169
  * @abstract
140
170
  * @category async
141
- * @rtype ({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]
171
+ * @rtype ({
172
+ * owner: String,
173
+ * code: String,
174
+ * callData: String,
175
+ * vmVersion: Number,
176
+ * deposit: Number,
177
+ * amount: Number,
178
+ * gas: Number,
179
+ * gasPrice: Number,
180
+ * fee?: Number,
181
+ * ttl?: Number,
182
+ * nonce?: Number
183
+ * }) => tx: Promise[String]
142
184
  * @param {Object} options - The object to extract properties from
143
185
  * @return {String} `contract_create_tx` transaction
144
186
  */
@@ -149,7 +191,18 @@ const Tx = stampit(required({
149
191
  * @instance
150
192
  * @abstract
151
193
  * @category async
152
- * @rtype ({callerId: String, contract: String, callData: String, vmVersion: Number, amount: Number, gas: Number, gasPrice: Number, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
194
+ * @rtype ({
195
+ * callerId: String,
196
+ * contract: String,
197
+ * callData: String,
198
+ * vmVersion: Number,
199
+ * amount: Number,
200
+ * gas: Number,
201
+ * gasPrice: Number,
202
+ * fee?: Number,
203
+ * ttl?: Number,
204
+ * nonce?: Number
205
+ * }) => tx: Promise[String]
153
206
  * @param {Object} options - The object to extract properties from
154
207
  * @return {String} `contract_call_tx` transaction
155
208
  */
@@ -160,7 +213,17 @@ const Tx = stampit(required({
160
213
  * @instance
161
214
  * @abstract
162
215
  * @category async
163
- * @rtype ({ 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]
216
+ * @rtype ({
217
+ * accountId: String,
218
+ * queryFormat: String,
219
+ * responseFormat: String,
220
+ * queryFee: String|Number,
221
+ * oracleTtl: Object,
222
+ * vmVersion: Number = ORACLE_VM_VERSION,
223
+ * fee?: Number,
224
+ * ttl?: Number,
225
+ * nonce?: Number
226
+ * }) => tx: Promise[String]
164
227
  * @param {Object} options - The object to extract properties from
165
228
  * @return {String} `oracle_register_tx` transaction
166
229
  */
@@ -171,7 +234,14 @@ const Tx = stampit(required({
171
234
  * @instance
172
235
  * @abstract
173
236
  * @category async
174
- * @rtype ({ oracleId: String, callerId: String, oracleTtl: Object, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]
237
+ * @rtype ({
238
+ * oracleId: String,
239
+ * callerId: String,
240
+ * oracleTtl: Object,
241
+ * fee?: Number,
242
+ * ttl: Number,
243
+ * nonce?: Number
244
+ * }) => tx: Promise[String]
175
245
  * @param {Object} options - The object to extract properties from
176
246
  * @return {String} `oracle_extend_tx` transaction
177
247
  */
@@ -182,7 +252,17 @@ const Tx = stampit(required({
182
252
  * @instance
183
253
  * @abstract
184
254
  * @category async
185
- * @rtype ({ oracleId: String, responseTtl: Object, query: String, queryTtl: Object, queryFee: String|Number, senderId: String, fee?: Number, ttl: Number, nonce?: Number}) => tx: Promise[String]
255
+ * @rtype ({
256
+ * oracleId: String,
257
+ * responseTtl: Object,
258
+ * query: String,
259
+ * queryTtl: Object,
260
+ * queryFee: String|Number,
261
+ * senderId: String,
262
+ * fee?: Number,
263
+ * ttl: Number,
264
+ * nonce?: Number
265
+ * }) => tx: Promise[String]
186
266
  * @param {Object} options - The object to extract properties from
187
267
  * @return {String} `oracle_post_query_tx` transaction
188
268
  */
@@ -193,7 +273,16 @@ const Tx = stampit(required({
193
273
  * @instance
194
274
  * @abstract
195
275
  * @category async
196
- * @rtype ({ oracleId: String, callerId: String, responseTtl: Object, queryId: String, response: String, fee?: Number, ttl?: Number, nonce?: Number}) => tx: Promise[String]
276
+ * @rtype ({
277
+ * oracleId: String,
278
+ * callerId: String,
279
+ * responseTtl: Object,
280
+ * queryId: String,
281
+ * response: String,
282
+ * fee?: Number,
283
+ * ttl?: Number,
284
+ * nonce?: Number
285
+ * }) => tx: Promise[String]
197
286
  * @param {Object} options - The object to extract properties from
198
287
  * @return {String} `oracle_respond_tx` transaction
199
288
  */
@@ -17,13 +17,17 @@ import { isHex } from '../utils/string'
17
17
  * @param {Object} params Transaction params
18
18
  * @param {Object} [options={}] Options
19
19
  * @throws {Error} Arguments validation error's
20
- * @return {{ encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String }}
20
+ * @return {{
21
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, params: Object, type: String
22
+ * }}
21
23
  */
22
24
  const buildTransaction = (type, params, options = {}) => {
23
25
  if (typeof params !== 'object') throw new Error('"params" should be an object')
24
26
  if (typeof type !== 'string' || !Object.values(TX_TYPE).includes(type)) throw new Error(`Unknown transaction type ${type}`)
25
27
  const fee = calculateFee(params.fee, type, { gas: params.gas, params, vsn: params.vsn })
26
- const { rlpEncoded, binary, tx: encodedTx, txObject } = buildTx({ ...params, fee }, type, { vsn: params.vsn, ...options })
28
+ const { rlpEncoded, binary, tx: encodedTx, txObject } = buildTx(
29
+ { ...params, fee }, type, { vsn: params.vsn, ...options }
30
+ )
27
31
  return { rlpEncoded, binary, encodedTx, params: txObject, type }
28
32
  }
29
33
 
@@ -32,7 +36,9 @@ const buildTransaction = (type, params, options = {}) => {
32
36
  * @alias module:@aeternity/aepp-sdk/es/tx/tx-object
33
37
  * @param {Buffer|String} tx RLP encoded binary or base64c(rlpBinary) string
34
38
  * @throws {Error} Arguments validation error's
35
- * @return {{ encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object }}
39
+ * @return {{
40
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
41
+ * }}
36
42
  */
37
43
  const unpackTransaction = (tx) => {
38
44
  if (!tx) throw new Error(`Invalid transaction: ${tx}`)
@@ -55,7 +61,9 @@ const unpackTransaction = (tx) => {
55
61
  * @param {String} type Transaction type
56
62
  * @param {Object} [options={}] Options
57
63
  * @throws {Error} Arguments validation error's
58
- * @return {{encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object}}
64
+ * @return {{
65
+ * encodedTx: String, binary: Array<Buffer>, rlpEncoded: Buffer, type: String, params: Object
66
+ * }}
59
67
  */
60
68
  const initTransaction = ({ tx, params, type, options = {} } = {}) => {
61
69
  if (params && type) return buildTransaction(type, params, options)
@@ -122,7 +130,12 @@ export const TxObject = stampit({
122
130
  if (typeof props !== 'object') throw new Error('Props should be an object')
123
131
  this.isSigned = false
124
132
  this.signatures = []
125
- Object.assign(this, buildTransaction(this.type, { ...this.params, ...props, fee: null }, { ...this.options, ...options }))
133
+ Object.assign(
134
+ this,
135
+ buildTransaction(
136
+ this.type, { ...this.params, ...props, fee: null }, { ...this.options, ...options }
137
+ )
138
+ )
126
139
  return this
127
140
  },
128
141
  /**
@@ -143,7 +156,13 @@ export const TxObject = stampit({
143
156
  addSignature (signature) {
144
157
  signature = isHex(signature) ? Buffer.from(signature, 'hex') : signature
145
158
  if (!Buffer.isBuffer(signature) && !(signature instanceof Uint8Array)) throw new Error('Invalid signature, signature must be of type Buffer or Uint8Array')
146
- Object.assign(this, buildTransaction(TX_TYPE.signed, { encodedTx: this.rlpEncoded, signatures: [[...this.signatures, signature]] }))
159
+ Object.assign(
160
+ this,
161
+ buildTransaction(
162
+ TX_TYPE.signed,
163
+ { encodedTx: this.rlpEncoded, signatures: [[...this.signatures, signature]] }
164
+ )
165
+ )
147
166
 
148
167
  const { signatures, encodedTx: { txType, tx } } = this.params
149
168
  this.signatures = signatures
package/src/tx/tx.js CHANGED
@@ -31,7 +31,9 @@ import { TxObject } from './tx-object'
31
31
 
32
32
  async function spendTx ({ senderId, recipientId, amount, payload = '' }) {
33
33
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
34
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.spend, { senderId, ...arguments[0], payload })
34
+ const { fee, ttl, nonce } = await this.prepareTxParams(
35
+ TX_TYPE.spend, { senderId, ...arguments[0], payload }
36
+ )
35
37
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
36
38
  const { tx } = this.nativeMode
37
39
  ? {
@@ -63,7 +65,9 @@ async function spendTx ({ senderId, recipientId, amount, payload = '' }) {
63
65
 
64
66
  async function namePreclaimTx ({ accountId, commitmentId }) {
65
67
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
66
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.namePreClaim, { senderId: accountId, ...arguments[0] })
68
+ const { fee, ttl, nonce } = await this.prepareTxParams(
69
+ TX_TYPE.namePreClaim, { senderId: accountId, ...arguments[0] }
70
+ )
67
71
 
68
72
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
69
73
  const { tx } = this.nativeMode
@@ -80,7 +84,9 @@ async function namePreclaimTx ({ accountId, commitmentId }) {
80
84
 
81
85
  async function nameClaimTx ({ accountId, name, nameSalt, vsn = 2 }) {
82
86
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
83
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.nameClaim, { senderId: accountId, ...arguments[0], vsn })
87
+ const { fee, ttl, nonce } = await this.prepareTxParams(
88
+ TX_TYPE.nameClaim, { senderId: accountId, ...arguments[0], vsn }
89
+ )
84
90
 
85
91
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
86
92
  const { tx } = this.nativeMode
@@ -97,7 +103,9 @@ async function nameClaimTx ({ accountId, name, nameSalt, vsn = 2 }) {
97
103
 
98
104
  async function nameTransferTx ({ accountId, nameId, recipientId }) {
99
105
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
100
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.nameTransfer, { senderId: accountId, ...arguments[0] })
106
+ const { fee, ttl, nonce } = await this.prepareTxParams(
107
+ TX_TYPE.nameTransfer, { senderId: accountId, ...arguments[0] }
108
+ )
101
109
 
102
110
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
103
111
  const { tx } = this.nativeMode
@@ -107,14 +115,18 @@ async function nameTransferTx ({ accountId, nameId, recipientId }) {
107
115
  type: TX_TYPE.nameTransfer
108
116
  }).encodedTx
109
117
  }
110
- : await this.api.postNameTransfer({ ...arguments[0], recipientId, nonce, ttl, fee: parseInt(fee) })
118
+ : await this.api.postNameTransfer({
119
+ ...arguments[0], recipientId, nonce, ttl, fee: parseInt(fee)
120
+ })
111
121
 
112
122
  return tx
113
123
  }
114
124
 
115
125
  async function nameUpdateTx ({ accountId, nameId, nameTtl, pointers, clientTtl }) {
116
126
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
117
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.nameUpdate, { senderId: accountId, ...arguments[0] })
127
+ const { fee, ttl, nonce } = await this.prepareTxParams(
128
+ TX_TYPE.nameUpdate, { senderId: accountId, ...arguments[0] }
129
+ )
118
130
 
119
131
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
120
132
  const { tx } = this.nativeMode
@@ -131,7 +143,9 @@ async function nameUpdateTx ({ accountId, nameId, nameTtl, pointers, clientTtl }
131
143
 
132
144
  async function nameRevokeTx ({ accountId, nameId }) {
133
145
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
134
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.nameRevoke, { senderId: accountId, ...arguments[0] })
146
+ const { fee, ttl, nonce } = await this.prepareTxParams(
147
+ TX_TYPE.nameRevoke, { senderId: accountId, ...arguments[0] }
148
+ )
135
149
 
136
150
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
137
151
  const { tx } = this.nativeMode
@@ -146,11 +160,15 @@ async function nameRevokeTx ({ accountId, nameId }) {
146
160
  return tx
147
161
  }
148
162
 
149
- async function contractCreateTx ({ ownerId, code, vmVersion, abiVersion, deposit, amount, gas, gasPrice = MIN_GAS_PRICE, callData }) {
163
+ async function contractCreateTx ({
164
+ ownerId, code, vmVersion, abiVersion, deposit, amount, gas, gasPrice = MIN_GAS_PRICE, callData
165
+ }) {
150
166
  // Get VM_ABI version
151
167
  const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0])
152
168
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
153
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.contractCreate, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice })
169
+ const { fee, ttl, nonce } = await this.prepareTxParams(
170
+ TX_TYPE.contractCreate, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice }
171
+ )
154
172
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
155
173
  return this.nativeMode
156
174
  ? {
@@ -160,13 +178,27 @@ async function contractCreateTx ({ ownerId, code, vmVersion, abiVersion, deposit
160
178
  }).encodedTx,
161
179
  contractId: buildContractId(ownerId, nonce)
162
180
  }
163
- : this.api.postContractCreate({ ...arguments[0], nonce, ttl, fee: parseInt(fee), gas: parseInt(gas), gasPrice, vmVersion: ctVersion.vmVersion, abiVersion: ctVersion.abiVersion })
181
+ : this.api.postContractCreate({
182
+ ...arguments[0],
183
+ nonce,
184
+ ttl,
185
+ fee: parseInt(fee),
186
+ gas: parseInt(gas),
187
+ gasPrice,
188
+ vmVersion: ctVersion.vmVersion,
189
+ abiVersion: ctVersion.abiVersion
190
+ })
164
191
  }
165
192
 
166
- async function contractCallTx ({ callerId, contractId, abiVersion, amount, gas, gasPrice = MIN_GAS_PRICE, callData }) {
193
+ async function contractCallTx ({
194
+ callerId, contractId, abiVersion, amount, gas, gasPrice = MIN_GAS_PRICE, callData
195
+ }) {
167
196
  const ctVersion = this.getVmVersion(TX_TYPE.contractCall, arguments[0])
168
197
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
169
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.contractCall, { senderId: callerId, ...arguments[0], gasPrice, abiVersion: ctVersion.abiVersion })
198
+ const { fee, ttl, nonce } = await this.prepareTxParams(
199
+ TX_TYPE.contractCall,
200
+ { senderId: callerId, ...arguments[0], gasPrice, abiVersion: ctVersion.abiVersion }
201
+ )
170
202
 
171
203
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
172
204
  const { tx } = this.nativeMode
@@ -189,10 +221,14 @@ async function contractCallTx ({ callerId, contractId, abiVersion, amount, gas,
189
221
  return tx
190
222
  }
191
223
 
192
- async function oracleRegisterTx ({ accountId, queryFormat, responseFormat, queryFee, oracleTtl, abiVersion = ABI_VERSIONS.NO_ABI }) {
224
+ async function oracleRegisterTx ({
225
+ accountId, queryFormat, responseFormat, queryFee, oracleTtl, abiVersion = ABI_VERSIONS.NO_ABI
226
+ }) {
193
227
  // const { abiVersion: abi } = this.getVmVersion(TX_TYPE.oracleRegister, arguments[0])
194
228
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
195
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.oracleRegister, { senderId: accountId, ...arguments[0], abiVersion })
229
+ const { fee, ttl, nonce } = await this.prepareTxParams(
230
+ TX_TYPE.oracleRegister, { senderId: accountId, ...arguments[0], abiVersion }
231
+ )
196
232
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
197
233
  const { tx } = this.nativeMode
198
234
  ? {
@@ -228,7 +264,9 @@ async function oracleRegisterTx ({ accountId, queryFormat, responseFormat, query
228
264
 
229
265
  async function oracleExtendTx ({ oracleId, callerId, oracleTtl }) {
230
266
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
231
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.oracleExtend, { senderId: callerId, ...arguments[0] })
267
+ const { fee, ttl, nonce } = await this.prepareTxParams(
268
+ TX_TYPE.oracleExtend, { senderId: callerId, ...arguments[0] }
269
+ )
232
270
 
233
271
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
234
272
  const { tx } = this.nativeMode
@@ -245,7 +283,9 @@ async function oracleExtendTx ({ oracleId, callerId, oracleTtl }) {
245
283
 
246
284
  async function oraclePostQueryTx ({ oracleId, responseTtl, query, queryTtl, queryFee, senderId }) {
247
285
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
248
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.oracleQuery, { senderId, ...arguments[0] })
286
+ const { fee, ttl, nonce } = await this.prepareTxParams(
287
+ TX_TYPE.oracleQuery, { senderId, ...arguments[0] }
288
+ )
249
289
 
250
290
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
251
291
  const { tx } = this.nativeMode
@@ -272,7 +312,9 @@ async function oraclePostQueryTx ({ oracleId, responseTtl, query, queryTtl, quer
272
312
 
273
313
  async function oracleRespondTx ({ oracleId, callerId, responseTtl, queryId, response }) {
274
314
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
275
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.oracleResponse, { senderId: callerId, ...arguments[0] })
315
+ const { fee, ttl, nonce } = await this.prepareTxParams(
316
+ TX_TYPE.oracleResponse, { senderId: callerId, ...arguments[0] }
317
+ )
276
318
 
277
319
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
278
320
  const { tx } = this.nativeMode
@@ -282,13 +324,17 @@ async function oracleRespondTx ({ oracleId, callerId, responseTtl, queryId, resp
282
324
  type: TX_TYPE.oracleResponse
283
325
  }).encodedTx
284
326
  }
285
- : await this.api.postOracleRespond({ oracleId, responseTtl, queryId, response, fee: parseInt(fee), ttl, nonce })
327
+ : await this.api.postOracleRespond({
328
+ oracleId, responseTtl, queryId, response, fee: parseInt(fee), ttl, nonce
329
+ })
286
330
  return tx
287
331
  }
288
332
 
289
333
  async function channelCloseSoloTx ({ channelId, fromId, payload, poi }) {
290
334
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
291
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.channelCloseSolo, { senderId: fromId, ...arguments[0], payload })
335
+ const { fee, ttl, nonce } = await this.prepareTxParams(
336
+ TX_TYPE.channelCloseSolo, { senderId: fromId, ...arguments[0], payload }
337
+ )
292
338
 
293
339
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
294
340
  const { tx } = this.nativeMode
@@ -318,7 +364,9 @@ async function channelCloseSoloTx ({ channelId, fromId, payload, poi }) {
318
364
 
319
365
  async function channelSlashTx ({ channelId, fromId, payload, poi }) {
320
366
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
321
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.channelSlash, { senderId: fromId, ...arguments[0], payload })
367
+ const { fee, ttl, nonce } = await this.prepareTxParams(
368
+ TX_TYPE.channelSlash, { senderId: fromId, ...arguments[0], payload }
369
+ )
322
370
 
323
371
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
324
372
  const { tx } = this.nativeMode
@@ -348,7 +396,9 @@ async function channelSlashTx ({ channelId, fromId, payload, poi }) {
348
396
 
349
397
  async function channelSettleTx ({ channelId, fromId, initiatorAmountFinal, responderAmountFinal }) {
350
398
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
351
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.channelSettle, { senderId: fromId, ...arguments[0] })
399
+ const { fee, ttl, nonce } = await this.prepareTxParams(
400
+ TX_TYPE.channelSettle, { senderId: fromId, ...arguments[0] }
401
+ )
352
402
 
353
403
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
354
404
  const { tx } = this.nativeMode
@@ -378,7 +428,9 @@ async function channelSettleTx ({ channelId, fromId, initiatorAmountFinal, respo
378
428
 
379
429
  async function channelSnapshotSoloTx ({ channelId, fromId, payload }) {
380
430
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
381
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.channelSnapshotSolo, { senderId: fromId, ...arguments[0], payload })
431
+ const { fee, ttl, nonce } = await this.prepareTxParams(
432
+ TX_TYPE.channelSnapshotSolo, { senderId: fromId, ...arguments[0], payload }
433
+ )
382
434
 
383
435
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
384
436
  const { tx } = this.nativeMode
@@ -404,11 +456,15 @@ async function channelSnapshotSoloTx ({ channelId, fromId, payload }) {
404
456
  return tx
405
457
  }
406
458
 
407
- async function gaAttachTx ({ ownerId, code, vmVersion, abiVersion, authFun, gas, gasPrice = MIN_GAS_PRICE, callData }) {
459
+ async function gaAttachTx ({
460
+ ownerId, code, vmVersion, abiVersion, authFun, gas, gasPrice = MIN_GAS_PRICE, callData
461
+ }) {
408
462
  // Get VM_ABI version
409
463
  const ctVersion = this.getVmVersion(TX_TYPE.contractCreate, arguments[0])
410
464
  // Calculate fee, get absolute ttl (ttl + height), get account nonce
411
- const { fee, ttl, nonce } = await this.prepareTxParams(TX_TYPE.gaAttach, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice })
465
+ const { fee, ttl, nonce } = await this.prepareTxParams(
466
+ TX_TYPE.gaAttach, { senderId: ownerId, ...arguments[0], ctVersion, gasPrice }
467
+ )
412
468
  // Build transaction using sdk (if nativeMode) or build on `AETERNITY NODE` side
413
469
  return {
414
470
  tx: TxObject({
@@ -480,7 +536,8 @@ async function calculateTtl (ttl = TX_TTL, relative = true) {
480
536
  */
481
537
  async function getAccountNonce (accountId, nonce) {
482
538
  if (nonce) return nonce
483
- const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId).catch(() => ({ nonce: 0 }))
539
+ const { nonce: accountNonce } = await this.api.getAccountByPubkey(accountId)
540
+ .catch(() => ({ nonce: 0 }))
484
541
  return accountNonce + 1
485
542
  }
486
543
 
@@ -491,10 +548,19 @@ async function getAccountNonce (accountId, nonce) {
491
548
  * @param {Object} params Object which contains all tx data
492
549
  * @return {Object} { ttl, nonce, fee } Object with account nonce, absolute ttl and transaction fee
493
550
  */
494
- async function prepareTxParams (txType, { senderId, nonce: n, ttl: t, fee: f, gas, absoluteTtl, vsn, strategy }) {
495
- n = n || (await this.api.getAccountNextNonce(senderId, { strategy }).catch(e => ({ nextNonce: 1 }))).nextNonce
551
+ async function prepareTxParams (
552
+ txType,
553
+ { senderId, nonce: n, ttl: t, fee: f, gas, absoluteTtl, vsn, strategy }
554
+ ) {
555
+ n = n || (
556
+ await this.api.getAccountNextNonce(senderId, { strategy }).catch(e => ({ nextNonce: 1 }))
557
+ ).nextNonce
496
558
  const ttl = await calculateTtl.call(this, t, !absoluteTtl)
497
- const fee = calculateFee(f, txType, { showWarning: this.showWarning, gas, params: { ...arguments[1], nonce: n, ttl }, vsn })
559
+ const fee = calculateFee(
560
+ f,
561
+ txType,
562
+ { showWarning: this.showWarning, gas, params: { ...arguments[1], nonce: n, ttl }, vsn }
563
+ )
498
564
  return { fee, ttl, nonce: n }
499
565
  }
500
566
 
@@ -18,10 +18,11 @@
18
18
  /**
19
19
  * Browser runtime connector module
20
20
  *
21
- * This is the complement to {@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection}.
21
+ * This is the complement to
22
+ * {@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection}.
22
23
  * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-runtime
23
24
  * @export BrowserRuntimeConnection
24
- * @example import BrowserRuntimeConnection from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-runtime'
25
+ * @example import { BrowserRuntimeConnection } from '@aeternity/aepp-sdk'
25
26
  */
26
27
  import stampit from '@stamp/it'
27
28
 
@@ -18,10 +18,13 @@
18
18
  /**
19
19
  * Browser window Post Message connector module
20
20
  *
21
- * This is the complement to {@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection}.
21
+ * This is the complement to
22
+ * {@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection}.
22
23
  * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-window-message
23
24
  * @export BrowserWindowMessageConnection
24
- * @example import BrowserWindowMessageConnection from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-window-message'
25
+ * @example
26
+ * import BrowserWindowMessageConnection
27
+ * from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-window-message'
25
28
  */
26
29
  import stampit from '@stamp/it'
27
30
  import WalletConnection from '.'
@@ -102,27 +105,42 @@ const getTarget = () => {
102
105
  const isContentScript = isExtensionContext && isWeb
103
106
  if (isContentScript) return window
104
107
  // When we is the main page we need to decide the target by our self
105
- // Probably can be implemented some algo for checking DOM for Iframes and somehow decide which Iframe to talk
108
+ // Probably can be implemented some algo for checking DOM for Iframes and somehow decide which
109
+ // Iframe to talk
106
110
  return isInIframe() ? window.parent : undefined
107
111
  }
108
112
 
109
113
  /**
110
114
  * BrowserWindowMessageConnection
111
115
  * @function
112
- * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-window-message
116
+ * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication\
117
+ * /connection/browser-window-message
113
118
  * @rtype Stamp
114
119
  * @param {Object} [params={}] - Initializer object
115
120
  * @param {Object} [params.target=window.parent] - Target window for message
116
121
  * @param {Object} [params.self=window] - Host window for message
117
122
  * @param {Object} [params.origin] - Origin of receiver
118
- * @param {Object} [params.sendDirection] - Optional field for wrapping messages in additional structure({ type: 'to_aepp' || 'to_waellet', data }).Used for handling messages netween content script and page
119
- * @param {Object} [params.receiveDirection='to_aepp'] - Optional(default: 'to_aepp') field for unwrapping messages from additional structure({ type: 'to_aepp' || 'to_waellet', data }).Used for handling messages netween content script and page
123
+ * @param {String} [params.sendDirection] Wrapping messages into additional struct
124
+ * ({ type: 'to_aepp' || 'to_waellet', data })
125
+ * Used for handling messages between content script and page
126
+ * @param {String} [params.receiveDirection='to_aepp'] Unwrapping messages from additional struct
127
+ * ({ type: 'to_aepp' || 'to_waellet', data })
128
+ * Used for handling messages between content script and page
120
129
  * @param {Object} [params.connectionInfo={}] - Connection info object
121
130
  * @param {Boolean} [params.debug=false] - Debug flag
122
131
  * @return {Object}
123
132
  */
124
133
  export default stampit({
125
- init ({ connectionInfo = {}, target = getTarget(), self = window, origin, sendDirection, receiveDirection = MESSAGE_DIRECTION.to_aepp, debug = false, forceOrigin = false } = {}) {
134
+ init ({
135
+ connectionInfo = {},
136
+ target = getTarget(),
137
+ self = window,
138
+ origin,
139
+ sendDirection,
140
+ receiveDirection = MESSAGE_DIRECTION.to_aepp,
141
+ debug = false,
142
+ forceOrigin = false
143
+ } = {}) {
126
144
  if (sendDirection && !Object.keys(MESSAGE_DIRECTION).includes(sendDirection)) throw new Error(`sendDirection must be one of [${Object.keys(MESSAGE_DIRECTION)}]`)
127
145
  if (!Object.keys(MESSAGE_DIRECTION).includes(receiveDirection)) throw new Error(`receiveDirection must be one of [${Object.keys(MESSAGE_DIRECTION)}]`)
128
146
  this.connectionInfo = { id: uuid(), ...connectionInfo }
@@ -19,7 +19,8 @@
19
19
  * Wallet Connection base module
20
20
  * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection
21
21
  * @export WalletConnection
22
- * @example import WalletConnection from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection'
22
+ * @example
23
+ * import WalletConnection from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection'
23
24
  */
24
25
 
25
26
  import { required } from '@stamp/required'
@@ -20,7 +20,9 @@
20
20
  *
21
21
  * @module @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/content-script-bridge
22
22
  * @export ContentScriptBridge
23
- * @example import ContentScriptBridge from '@aeternity/aepp-sdk/es/utils/wallet-communication/content-script-bridge
23
+ * @example
24
+ * import ContentScriptBridge
25
+ * from '@aeternity/aepp-sdk/es/utils/wallet-communication/content-script-bridge
24
26
  */
25
27
  import stampit from '@stamp/it'
26
28
 
@@ -56,14 +58,18 @@ function stop () {
56
58
 
57
59
  /**
58
60
  * ContentScriptBridge stamp
59
- * Provide functionality to easly redirect messages from page to extension and from extension to page through content script
61
+ * Provide functionality to easly redirect messages from page to extension and from extension to
62
+ * page through content script
60
63
  * Using Runtime(Extension) and WindowPostMessage(Web-Page) connections
61
64
  * @function
62
65
  * @alias module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/content-script-bridge
63
66
  * @rtype Stamp
64
67
  * @param {Object} params - Initializer object
65
- * @param {Object} params.pageConnection - Page connection object(@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-window-message)
66
- * @param {Object} params.extConnection - Extension connection object(module: @aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-runtime)
68
+ * @param {Object} params.pageConnection - Page connection object
69
+ * (@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/\
70
+ * browser-window-message)
71
+ * @param {Object} params.extConnection - Extension connection object
72
+ * (@link module:@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/connection/browser-runtime)
67
73
  * @return {Object}
68
74
  */
69
75
  export default stampit({