@aeternity/aepp-sdk 9.0.1 → 10.0.0-beta.1

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 (137) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.LICENSE.txt +0 -9
  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 +30 -122
  9. package/es/account/base.js.map +1 -1
  10. package/es/account/memory.js +17 -19
  11. package/es/account/memory.js.map +1 -1
  12. package/es/account/multiple.js +73 -164
  13. package/es/account/multiple.js.map +1 -1
  14. package/es/ae/aens.js +164 -599
  15. package/es/ae/aens.js.map +1 -1
  16. package/es/ae/contract.js +82 -759
  17. package/es/ae/contract.js.map +1 -1
  18. package/es/ae/index.js +78 -315
  19. package/es/ae/index.js.map +1 -1
  20. package/es/ae/oracle.js +130 -498
  21. package/es/ae/oracle.js.map +1 -1
  22. package/es/chain/index.js +1 -1
  23. package/es/chain/index.js.map +1 -1
  24. package/es/chain/node.js +288 -1008
  25. package/es/chain/node.js.map +1 -1
  26. package/es/channel/handlers.js +597 -1086
  27. package/es/channel/handlers.js.map +1 -1
  28. package/es/channel/index.js +203 -451
  29. package/es/channel/index.js.map +1 -1
  30. package/es/channel/internal.js +129 -301
  31. package/es/channel/internal.js.map +1 -1
  32. package/es/contract/aci/index.js +319 -480
  33. package/es/contract/aci/index.js.map +1 -1
  34. package/es/contract/aci/transformation.js +35 -711
  35. package/es/contract/aci/transformation.js.map +1 -1
  36. package/es/contract/compiler.js +129 -203
  37. package/es/contract/compiler.js.map +1 -1
  38. package/es/contract/ga/helpers.js +16 -114
  39. package/es/contract/ga/helpers.js.map +1 -1
  40. package/es/contract/ga/index.js +101 -242
  41. package/es/contract/ga/index.js.map +1 -1
  42. package/es/contract/index.js +1 -1
  43. package/es/contract/index.js.map +1 -1
  44. package/es/index.js +1 -2
  45. package/es/index.js.map +1 -1
  46. package/es/node-pool/index.js +54 -73
  47. package/es/node-pool/index.js.map +1 -1
  48. package/es/node.js +56 -157
  49. package/es/node.js.map +1 -1
  50. package/es/other.d.ts +1 -1
  51. package/es/tx/builder/helpers.js +38 -75
  52. package/es/tx/builder/helpers.js.map +1 -1
  53. package/es/tx/builder/index.js +196 -294
  54. package/es/tx/builder/index.js.map +1 -1
  55. package/es/tx/builder/schema.js +577 -459
  56. package/es/tx/builder/schema.js.map +1 -1
  57. package/es/tx/index.js +1 -1
  58. package/es/tx/index.js.map +1 -1
  59. package/es/tx/tx-object.js +105 -132
  60. package/es/tx/tx-object.js.map +1 -1
  61. package/es/tx/tx.js +808 -1628
  62. package/es/tx/tx.js.map +1 -1
  63. package/es/tx/validator.js +132 -268
  64. package/es/tx/validator.js.map +1 -1
  65. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js +17 -21
  66. package/es/utils/aepp-wallet-communication/connection/browser-runtime.js.map +1 -1
  67. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js +38 -74
  68. package/es/utils/aepp-wallet-communication/connection/browser-window-message.js.map +1 -1
  69. package/es/utils/aepp-wallet-communication/content-script-bridge.js +14 -15
  70. package/es/utils/aepp-wallet-communication/content-script-bridge.js.map +1 -1
  71. package/es/utils/aepp-wallet-communication/helpers.js +60 -105
  72. package/es/utils/aepp-wallet-communication/helpers.js.map +1 -1
  73. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js +179 -510
  74. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.js.map +1 -1
  75. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js +70 -89
  76. package/es/utils/aepp-wallet-communication/rpc/rpc-client.js.map +1 -1
  77. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js +353 -600
  78. package/es/utils/aepp-wallet-communication/rpc/wallet-rpc.js.map +1 -1
  79. package/es/utils/aepp-wallet-communication/schema.js +43 -39
  80. package/es/utils/aepp-wallet-communication/schema.js.map +1 -1
  81. package/es/utils/aepp-wallet-communication/wallet-detector.js +32 -58
  82. package/es/utils/aepp-wallet-communication/wallet-detector.js.map +1 -1
  83. package/es/utils/amount-formatter.js +41 -61
  84. package/es/utils/amount-formatter.js.map +1 -1
  85. package/es/utils/async-init.js +28 -64
  86. package/es/utils/async-init.js.map +1 -1
  87. package/es/utils/bignumber.js +3 -11
  88. package/es/utils/bignumber.js.map +1 -1
  89. package/es/utils/bytes.js +5 -9
  90. package/es/utils/bytes.js.map +1 -1
  91. package/es/utils/crypto.js +47 -62
  92. package/es/utils/crypto.js.map +1 -1
  93. package/es/utils/hd-wallet.js +45 -81
  94. package/es/utils/hd-wallet.js.map +1 -1
  95. package/es/utils/json-big.js +16 -49
  96. package/es/utils/json-big.js.map +1 -1
  97. package/es/utils/keystore.js +81 -246
  98. package/es/utils/keystore.js.map +1 -1
  99. package/es/utils/mptree.js +88 -134
  100. package/es/utils/mptree.js.map +1 -1
  101. package/es/utils/other.js +10 -60
  102. package/es/utils/other.js.map +1 -1
  103. package/es/utils/semver-satisfies.js +9 -28
  104. package/es/utils/semver-satisfies.js.map +1 -1
  105. package/es/utils/string.js +4 -13
  106. package/es/utils/string.js.map +1 -1
  107. package/es/utils/swagger.js +85 -224
  108. package/es/utils/swagger.js.map +1 -1
  109. package/package.json +44 -40
  110. package/src/account/multiple.js +18 -19
  111. package/src/ae/aens.js +25 -21
  112. package/src/ae/contract.js +32 -163
  113. package/src/ae/index.js +3 -3
  114. package/src/ae/oracle.js +18 -14
  115. package/src/chain/node.js +2 -4
  116. package/src/channel/handlers.js +0 -1
  117. package/src/channel/index.js +4 -5
  118. package/src/contract/aci/index.js +221 -102
  119. package/src/contract/aci/transformation.js +30 -422
  120. package/src/contract/compiler.js +45 -4
  121. package/src/contract/ga/helpers.js +1 -8
  122. package/src/contract/ga/index.js +13 -11
  123. package/src/index.js +0 -2
  124. package/src/node-pool/index.js +21 -12
  125. package/src/node.js +22 -26
  126. package/src/tx/builder/index.js +2 -1
  127. package/src/tx/builder/schema.js +2 -1
  128. package/src/tx/tx.js +147 -143
  129. package/src/tx/validator.js +9 -7
  130. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -3
  131. package/src/utils/aepp-wallet-communication/rpc/wallet-rpc.js +3 -3
  132. package/src/utils/aepp-wallet-communication/schema.js +1 -3
  133. package/src/utils/bignumber.ts +2 -1
  134. package/src/utils/other.ts +1 -1
  135. package/src/utils/semver-satisfies.ts +1 -1
  136. package/src/utils/swagger.js +14 -7
  137. package/src/contract/aci/helpers.js +0 -140
package/src/ae/aens.js CHANGED
@@ -26,7 +26,6 @@
26
26
  * @example import { Aens } from '@aeternity/aepp-sdk'
27
27
  */
28
28
 
29
- import * as R from 'ramda'
30
29
  import { salt } from '../utils/crypto'
31
30
  import {
32
31
  commitmentHash,
@@ -63,12 +62,13 @@ import { CLIENT_TTL, NAME_FEE, NAME_TTL } from '../tx/builder/schema'
63
62
  */
64
63
  async function revoke (name, options = {}) {
65
64
  ensureNameValid(name)
66
- const opt = R.merge(this.Ae.defaults, options)
65
+ const opt = { ...this.Ae.defaults, ...options }
67
66
 
68
- const nameRevokeTx = await this.nameRevokeTx(R.merge(opt, {
67
+ const nameRevokeTx = await this.nameRevokeTx({
68
+ ...opt,
69
69
  nameId: produceNameId(name),
70
70
  accountId: await this.address(opt)
71
- }))
71
+ })
72
72
 
73
73
  return this.send(nameRevokeTx, opt)
74
74
  }
@@ -103,18 +103,19 @@ async function revoke (name, options = {}) {
103
103
  */
104
104
  async function update (name, pointers = [], options = { extendPointers: false }) {
105
105
  ensureNameValid(name)
106
- const opt = R.merge(this.Ae.defaults, options)
106
+ const opt = { ...this.Ae.defaults, ...options }
107
107
  if (!validatePointers(pointers)) throw new Error('Invalid pointers array')
108
108
 
109
109
  pointers = [
110
110
  ...options.extendPointers ? (await this.getName(name)).pointers : [],
111
- ...pointers.map(p => R.fromPairs([['id', p], ['key', classify(p)]]))
111
+ ...pointers.map(p => Object.fromEntries([['id', p], ['key', classify(p)]]))
112
112
  ].reduce((acc, el) => [...acc.filter(p => p.key !== el.key), el], [])
113
- const nameUpdateTx = await this.nameUpdateTx(R.merge(opt, {
113
+ const nameUpdateTx = await this.nameUpdateTx({
114
+ ...opt,
114
115
  nameId: produceNameId(name),
115
116
  accountId: await this.address(opt),
116
117
  pointers
117
- }))
118
+ })
118
119
 
119
120
  return this.send(nameUpdateTx, opt)
120
121
  }
@@ -145,13 +146,14 @@ async function update (name, pointers = [], options = { extendPointers: false })
145
146
  */
146
147
  async function transfer (name, account, options = {}) {
147
148
  ensureNameValid(name)
148
- const opt = R.merge(this.Ae.defaults, options)
149
+ const opt = { ...this.Ae.defaults, ...options }
149
150
 
150
- const nameTransferTx = await this.nameTransferTx(R.merge(opt, {
151
+ const nameTransferTx = await this.nameTransferTx({
152
+ ...opt,
151
153
  nameId: produceNameId(name),
152
154
  accountId: await this.address(opt),
153
155
  recipientId: account
154
- }))
156
+ })
155
157
 
156
158
  return this.send(nameTransferTx, opt)
157
159
  }
@@ -186,22 +188,22 @@ async function query (name, opt = {}) {
186
188
  pointers: o.pointers || [],
187
189
  update: async (pointers = [], options = {}) => {
188
190
  return {
189
- ...(await this.aensUpdate(name, pointers, R.merge(opt, options))),
191
+ ...(await this.aensUpdate(name, pointers, { ...opt, ...options })),
190
192
  ...(await this.aensQuery(name))
191
193
  }
192
194
  },
193
195
  transfer: async (account, options = {}) => {
194
196
  return {
195
- ...(await this.aensTransfer(name, account, R.merge(opt, options))),
197
+ ...(await this.aensTransfer(name, account, { ...opt, ...options })),
196
198
  ...(await this.aensQuery(name))
197
199
  }
198
200
  },
199
- revoke: async (options = {}) => this.aensRevoke(name, R.merge(opt, options)),
201
+ revoke: async (options = {}) => this.aensRevoke(name, { ...opt, ...options }),
200
202
  extendTtl: async (nameTtl = NAME_TTL, options = {}) => {
201
203
  if (!nameTtl || typeof nameTtl !== 'number' || nameTtl > NAME_TTL) throw new Error('Ttl must be an number and less then 180000 blocks')
202
204
 
203
205
  return {
204
- ...(await this.aensUpdate(name, o.pointers.map(p => p.id), { ...R.merge(opt, options), nameTtl })),
206
+ ...(await this.aensUpdate(name, o.pointers.map(p => p.id), { ...opt, ...options, nameTtl })),
205
207
  ...(await this.aensQuery(name))
206
208
  }
207
209
  }
@@ -233,18 +235,19 @@ async function query (name, opt = {}) {
233
235
  */
234
236
  async function claim (name, salt, options) {
235
237
  ensureNameValid(name)
236
- const opt = R.merge(this.Ae.defaults, options)
238
+ const opt = { ...this.Ae.defaults, ...options }
237
239
 
238
240
  const minNameFee = getMinimumNameFee(name)
239
241
  if (opt.nameFee !== this.Ae.defaults.nameFee && minNameFee.gt(opt.nameFee)) {
240
242
  throw new Error(`the provided fee ${opt.nameFee} is not enough to execute the claim, required: ${minNameFee}`)
241
243
  }
242
244
  opt.nameFee = opt.nameFee !== this.Ae.defaults.nameFee ? opt.nameFee : minNameFee
243
- const claimTx = await this.nameClaimTx(R.merge(opt, {
245
+ const claimTx = await this.nameClaimTx({
246
+ ...opt,
244
247
  accountId: await this.address(opt),
245
248
  nameSalt: salt,
246
249
  name: encode(name, 'nm')
247
- }))
250
+ })
248
251
 
249
252
  const result = await this.send(claimTx, opt)
250
253
  if (!isAuctionName(name)) {
@@ -282,15 +285,16 @@ async function claim (name, salt, options) {
282
285
  */
283
286
  async function preclaim (name, options = {}) {
284
287
  ensureNameValid(name)
285
- const opt = R.merge(this.Ae.defaults, options)
288
+ const opt = { ...this.Ae.defaults, ...options }
286
289
  const _salt = salt()
287
290
  const height = await this.height()
288
291
  const commitmentId = commitmentHash(name, _salt)
289
292
 
290
- const preclaimTx = await this.namePreclaimTx(R.merge(opt, {
293
+ const preclaimTx = await this.namePreclaimTx({
294
+ ...opt,
291
295
  accountId: await this.address(opt),
292
296
  commitmentId
293
- }))
297
+ })
294
298
 
295
299
  const result = await this.send(preclaimTx, opt)
296
300
 
@@ -27,87 +27,23 @@
27
27
  */
28
28
 
29
29
  import Ae from './'
30
- import * as R from 'ramda'
31
30
  import ContractCompilerAPI from '../contract/compiler'
32
31
  import ContractBase from '../contract'
33
32
  import getContractInstance from '../contract/aci'
34
33
  import NodePool from '../node-pool'
35
- import { AMOUNT, DEPOSIT, DRY_RUN_ACCOUNT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema'
34
+ import { AMOUNT, DEPOSIT, GAS, MIN_GAS_PRICE } from '../tx/builder/schema'
36
35
  import { decode, produceNameId } from '../tx/builder/helpers'
37
- import TxObject from '../tx/tx-object'
38
-
39
- async function _sendAndProcess (tx, source, name, options) {
40
- const txData = await this.send(tx, options)
41
- const result = { hash: txData.hash, tx: TxObject({ tx: txData.rawTx }), txData, rawTx: txData.rawTx }
42
- if (options.waitMined === false) return result
43
- const txInfo = await this.getTxInfo(txData.hash)
44
- await this._handleCallError(source, name, txInfo)
45
- return { ...result, result: txInfo }
46
- }
47
-
48
- /**
49
- * Handle contract call error
50
- * @function
51
- * @private
52
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
53
- * @category async
54
- * @param {String} source contract source code
55
- * @param {String} name name of called method
56
- * @param {Object} result call result object
57
- * @throws Error Decoded error
58
- * @return {Promise<void>}
59
- */
60
- async function _handleCallError (source, name, result) {
61
- if (result.returnType === 'ok') return
62
- const error = await this.contractDecodeCallResultAPI(source, name, result.returnValue, result.returnType)
63
- const message = error[{ revert: 'abort' }[result.returnType] || result.returnType][0]
64
- throw new Error(`Invocation failed${message ? `: "${message}"` : ''}`)
65
- }
66
-
67
- /**
68
- * Encode call data for contract call
69
- * @function
70
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
71
- * @category async
72
- * @param {String} source Contract source code
73
- * @param {String} name Name of function to call
74
- * @param {Array} args Argument's for call
75
- * @param {Object} [options={}] Options
76
- * @param {Object} [options.filesystem={}] Contract external namespaces map
77
- * @return {Promise<String>}
78
- */
79
- async function contractEncodeCall (source, name, args, options) {
80
- return this.contractEncodeCallDataAPI(source, name, args, options)
81
- }
82
-
83
- /**
84
- * Decode contract call result data
85
- * @function
86
- * @alias module:@aeternity/aepp-sdk/es/ae/contract
87
- * @category async
88
- * @param {String} source - source code
89
- * @param {String } fn - function name
90
- * @param {String} callValue - result call data
91
- * @param {String} callResult - result status
92
- * @param {Object} [options={}] Options
93
- * @param {Object} [options.filesystem={}] Contract external namespaces map
94
- * @return {Promise<String>} Result object
95
- * @example
96
- * const decodedData = await client.contractDecodeData(SourceCode ,'functionName', 'cb_asdasdasd...', 'ok|revert')lt
97
- */
98
- async function contractDecodeData (source, fn, callValue, callResult, options) {
99
- return this.contractDecodeCallResultAPI(source, fn, callValue, callResult, options)
100
- }
101
36
 
102
37
  /**
103
38
  * Static contract call(using dry-run)
104
39
  * @function
105
40
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
106
41
  * @category async
42
+ * @deprecated
107
43
  * @param {String} source Contract source code
108
- * @param {String} address Contract address
44
+ * @param {String} contractAddress Contract address
109
45
  * @param {String} name Name of function to call
110
- * @param {Array|String} args Argument's or callData for call/deploy transaction
46
+ * @param {Array} args Arguments array for call/deploy transaction
111
47
  * @param {Object} [options]
112
48
  * @param {Number|String} [options.top] Block height or hash on which you want to call contract
113
49
  * @param {String} [options.bytecode] Block hash on which you want to call contract
@@ -120,39 +56,9 @@ async function contractDecodeData (source, fn, callValue, callResult, options) {
120
56
  * decode: (type) => Decode call result
121
57
  * }
122
58
  */
123
- async function contractCallStatic (source, address, name, args = [], options = {}) {
124
- const callerId = await this.address(options).catch(() => DRY_RUN_ACCOUNT.pub)
125
- if (typeof options.top === 'number') {
126
- options.top = (await this.getKeyBlock(options.top)).hash
127
- }
128
- const txOpt = {
129
- ...this.Ae.defaults,
130
- ...options,
131
- callData: Array.isArray(args) ? await this.contractEncodeCall(source, name, args, options) : args,
132
- nonce: options.top && (await this.getAccount(callerId, { hash: options.top })).nonce + 1
133
- }
134
- const tx = name === 'init'
135
- ? (await this.contractCreateTx({
136
- ...txOpt,
137
- code: options.bytecode,
138
- ownerId: callerId
139
- })).tx
140
- : await this.contractCallTx({
141
- ...txOpt,
142
- callerId,
143
- contractId: await this.resolveName(address, 'ct', { resolveByNode: true })
144
- })
145
-
146
- const { callObj, ...dryRunOther } = await this.txDryRun(tx, callerId, options)
147
-
148
- await this._handleCallError(source, name, callObj)
149
- const { returnType, returnValue } = callObj
150
- return {
151
- ...dryRunOther,
152
- tx: TxObject({ tx }),
153
- result: callObj,
154
- decode: () => this.contractDecodeData(source, name, returnValue, returnType, options)
155
- }
59
+ async function contractCallStatic (source, contractAddress, name, args = [], options) {
60
+ const contract = await this.getContractInstance({ ...options, source, contractAddress })
61
+ return contract.call(name, args, { ...options, callStatic: true })
156
62
  }
157
63
 
158
64
  /**
@@ -160,12 +66,14 @@ async function contractCallStatic (source, address, name, args = [], options = {
160
66
  * @function
161
67
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
162
68
  * @category async
69
+ * @deprecated
163
70
  * @param {String} source Contract source code
164
- * @param {String} address Contract address or AENS name
71
+ * @param {String} contractAddress Contract address or AENS name
165
72
  * @param {String} name Name of function to call
166
- * @param {Array|String} argsOrCallData Argument's array or callData for call function
167
- * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
168
- * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
73
+ * @param {Array} args Arguments array for call/deploy transaction
74
+ * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
75
+ * @param {Object} [options.filesystem] Contract external namespaces map
76
+ * @return {Promise<Object>} Result object
169
77
  * @example
170
78
  * const callResult = await client.contractCall(source, address, fnName, args = [], options)
171
79
  * {
@@ -174,23 +82,9 @@ async function contractCallStatic (source, address, name, args = [], options = {
174
82
  * decode: (type) => Decode call result
175
83
  * }
176
84
  */
177
- async function contractCall (source, address, name, argsOrCallData = [], options = {}) {
178
- const opt = R.merge(this.Ae.defaults, options)
179
-
180
- const tx = await this.contractCallTx(R.merge(opt, {
181
- callerId: await this.address(opt),
182
- contractId: await this.resolveName(address, 'ct', { resolveByNode: true }),
183
- callData: Array.isArray(argsOrCallData) ? await this.contractEncodeCall(source, name, argsOrCallData, opt) : argsOrCallData
184
- }))
185
-
186
- const { hash, rawTx, result, txData } = await this._sendAndProcess(tx, source, name, opt)
187
- return {
188
- hash,
189
- rawTx,
190
- result,
191
- txData,
192
- decode: () => result ? this.contractDecodeData(source, name, result.returnValue, result.returnType, opt) : {}
193
- }
85
+ async function contractCall (source, contractAddress, name, args, options) {
86
+ const contract = await this.getContractInstance({ ...options, source, contractAddress })
87
+ return contract.call(name, args, options)
194
88
  }
195
89
 
196
90
  /**
@@ -198,10 +92,11 @@ async function contractCall (source, address, name, argsOrCallData = [], options
198
92
  * @function
199
93
  * @alias module:@aeternity/aepp-sdk/es/ae/contract
200
94
  * @category async
95
+ * @deprecated
201
96
  * @param {String} code Compiled contract
202
97
  * @param {String} source Contract source code
203
- * @param {Array|String} initState Arguments of contract constructor(init) function. Can be array of arguments or callData string
204
- * @param {Object} [options={}] Transaction options (fee, ttl, gas, amount, deposit)
98
+ * @param {Array} params Arguments of contract constructor(init) function. Can be array of arguments or callData string
99
+ * @param {Object} [options] Transaction options (fee, ttl, gas, amount, deposit)
205
100
  * @param {Object} [options.filesystem={}] Contract external namespaces map* @return {Promise<Object>} Result object
206
101
  * @return {Promise<Object>} Result object
207
102
  * @example
@@ -216,31 +111,10 @@ async function contractCall (source, address, name, argsOrCallData = [], options
216
111
  * callStatic: (fnName, args = [], options) => Static all contract function
217
112
  * }
218
113
  */
219
- async function contractDeploy (code, source, initState = [], options = {}) {
220
- const opt = { ...this.Ae.defaults, ...options, deposit: DEPOSIT }
221
- const callData = Array.isArray(initState) ? await this.contractEncodeCall(source, 'init', initState, opt) : initState
222
- const ownerId = await this.address(opt)
223
-
224
- const { tx, contractId } = await this.contractCreateTx(R.merge(opt, {
225
- callData,
226
- code,
227
- ownerId
228
- }))
229
-
230
- const { hash, rawTx, result, txData } = await this._sendAndProcess(tx, source, 'init', opt)
231
- return Object.freeze({
232
- result,
233
- owner: ownerId,
234
- transaction: hash,
235
- rawTx,
236
- txData,
237
- address: contractId,
238
- call: (name, args, options) =>
239
- this.contractCall(source, contractId, name, args, { ...opt, ...options }),
240
- callStatic: (name, args, options) =>
241
- this.contractCallStatic(source, contractId, name, args, { ...opt, ...options }),
242
- createdAt: new Date()
243
- })
114
+ async function contractDeploy (code, source, params, options) {
115
+ const contract = await this.getContractInstance({ ...options, source })
116
+ contract.bytecode = code
117
+ return contract.deploy(params, options)
244
118
  }
245
119
 
246
120
  /**
@@ -264,7 +138,7 @@ async function contractCompile (source, options = {}) {
264
138
  const opt = { ...this.Ae.defaults, ...options }
265
139
  const bytecode = await this.compileContractAPI(source, options)
266
140
  return Object.freeze({
267
- encodeCall: (name, args) => this.contractEncodeCall(source, name, args, opt),
141
+ encodeCall: (name, args) => this.contractEncodeCallDataAPI(source, name, args, opt),
268
142
  deploy: (init, options) => this.contractDeploy(bytecode, source, init, { ...opt, ...options }),
269
143
  deployStatic: (init, options) => this.contractCallStatic(source, null, 'init', init, {
270
144
  ...opt,
@@ -286,16 +160,15 @@ async function contractCompile (source, options = {}) {
286
160
  * @return {Promise<String>} Signature in hex representation
287
161
  */
288
162
  async function delegateSignatureCommon (ids = [], opt = {}) {
289
- return this.sign(
290
- Buffer.concat(
291
- [
292
- Buffer.from(this.getNetworkId(opt)),
293
- ...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []),
294
- ...ids.map(e => decode(e))
295
- ]
296
- ),
163
+ const signature = await this.sign(
164
+ Buffer.concat([
165
+ Buffer.from(this.getNetworkId(opt)),
166
+ ...(Object.prototype.hasOwnProperty.call(opt, 'onAccount') ? [decode(await this.address(opt))] : []),
167
+ ...ids.map(e => decode(e))
168
+ ]),
297
169
  opt
298
- ).then(s => Buffer.from(s).toString('hex'))
170
+ )
171
+ return Buffer.from(signature).toString('hex')
299
172
  }
300
173
 
301
174
  /**
@@ -384,10 +257,6 @@ export const ContractAPI = Ae.compose(ContractBase, {
384
257
  contractCallStatic,
385
258
  contractDeploy,
386
259
  contractCall,
387
- contractEncodeCall,
388
- contractDecodeData,
389
- _handleCallError,
390
- _sendAndProcess,
391
260
  // Delegation for contract
392
261
  delegateSignatureCommon,
393
262
  // AENS
package/src/ae/index.js CHANGED
@@ -27,7 +27,6 @@ import Tx from '../tx'
27
27
  import Chain from '../chain'
28
28
  import AccountBase from '../account/base'
29
29
  import TxBuilder from '../tx/builder'
30
- import * as R from 'ramda'
31
30
  import BigNumber from 'bignumber.js'
32
31
  import { AE_AMOUNT_FORMATS } from '../utils/amount-formatter'
33
32
 
@@ -42,9 +41,10 @@ import { AE_AMOUNT_FORMATS } from '../utils/amount-formatter'
42
41
  * @return {Object} Transaction
43
42
  */
44
43
  async function send (tx, options = {}) {
45
- const opt = R.merge(this.Ae.defaults, options)
44
+ const opt = { ...this.Ae.defaults, ...options }
46
45
  const { contractId, authFun } = options.innerTx
47
- ? { contractId: false } : await this.getAccount(await this.address(opt))
46
+ ? { contractId: false }
47
+ : await this.getAccount(await this.address(opt))
48
48
  const signed = contractId
49
49
  ? await this.signUsingGA(tx, { ...opt, authFun })
50
50
  : await this.signTransaction(tx, opt)
package/src/ae/oracle.js CHANGED
@@ -27,7 +27,6 @@
27
27
  */
28
28
 
29
29
  import Ae from './'
30
- import * as R from 'ramda'
31
30
  import { decodeBase64Check } from '../utils/crypto'
32
31
  import { pause } from '../utils/other'
33
32
  import { oracleQueryId, decode } from '../tx/builder/helpers'
@@ -123,7 +122,7 @@ export async function pollForQueryResponse (oracleId, queryId, { attempts = 20,
123
122
  const { response } = await this.api.getOracleQueryByPubkeyAndQueryId(oracleId, queryId)
124
123
  const responseBuffer = decode(response, 'or')
125
124
  if (responseBuffer.length) {
126
- return { response, decode: () => responseBuffer } // TODO: Return just responseBuffer
125
+ return String(responseBuffer)
127
126
  }
128
127
  }
129
128
  throw new Error(`Giving up after ${(attempts - 1) * interval}ms`)
@@ -146,14 +145,15 @@ export async function pollForQueryResponse (oracleId, queryId, { attempts = 20,
146
145
  * @return {Promise<Object>} Oracle object
147
146
  */
148
147
  async function registerOracle (queryFormat, responseFormat, options = {}) {
149
- const opt = R.merge(this.Ae.defaults, options) // Preset VmVersion for oracle
148
+ const opt = { ...this.Ae.defaults, ...options } // Preset VmVersion for oracle
150
149
  const accountId = await this.address(opt)
151
150
 
152
- const oracleRegisterTx = await this.oracleRegisterTx(R.merge(opt, {
151
+ const oracleRegisterTx = await this.oracleRegisterTx({
152
+ ...opt,
153
153
  accountId,
154
154
  queryFormat,
155
155
  responseFormat
156
- }))
156
+ })
157
157
  return {
158
158
  ...await this.send(oracleRegisterTx, opt),
159
159
  ...await this.getOracleObject(`ok_${accountId.slice(3)}`)
@@ -177,14 +177,16 @@ async function registerOracle (queryFormat, responseFormat, options = {}) {
177
177
  * @return {Promise<Object>} Query object
178
178
  */
179
179
  async function postQueryToOracle (oracleId, query, options = {}) {
180
- const opt = R.merge(this.Ae.defaults, options)
180
+ const queryFee = options.queryFee || (await this.api.getOracleByPubkey(oracleId)).queryFee
181
+ const opt = { ...this.Ae.defaults, queryFee, ...options }
181
182
  const senderId = await this.address(opt)
182
183
 
183
- const oracleRegisterTx = await this.oraclePostQueryTx(R.merge(opt, {
184
+ const oracleRegisterTx = await this.oraclePostQueryTx({
185
+ ...opt,
184
186
  oracleId,
185
187
  senderId,
186
188
  query
187
- }))
189
+ })
188
190
  const queryId = oracleQueryId(senderId, unpackTx(oracleRegisterTx).tx.nonce, oracleId)
189
191
  return {
190
192
  ...await this.send(oracleRegisterTx, opt),
@@ -206,14 +208,15 @@ async function postQueryToOracle (oracleId, query, options = {}) {
206
208
  * @return {Promise<Object>} Oracle object
207
209
  */
208
210
  async function extendOracleTtl (oracleId, oracleTtl, options = {}) {
209
- const opt = R.merge(this.Ae.defaults, options)
211
+ const opt = { ...this.Ae.defaults, ...options }
210
212
  const callerId = await this.address(opt)
211
213
 
212
- const oracleExtendTx = await this.oracleExtendTx(R.merge(opt, {
214
+ const oracleExtendTx = await this.oracleExtendTx({
215
+ ...opt,
213
216
  oracleId,
214
217
  callerId,
215
218
  oracleTtl
216
- }))
219
+ })
217
220
  return {
218
221
  ...await this.send(oracleExtendTx, opt),
219
222
  ...await this.getOracleObject(oracleId)
@@ -236,15 +239,16 @@ async function extendOracleTtl (oracleId, oracleTtl, options = {}) {
236
239
  * @return {Promise<Object>} Oracle object
237
240
  */
238
241
  async function respondToQuery (oracleId, queryId, response, options = {}) {
239
- const opt = R.merge(this.Ae.defaults, options)
242
+ const opt = { ...this.Ae.defaults, ...options }
240
243
  const callerId = await this.address(opt)
241
244
 
242
- const oracleRespondTx = await this.oracleRespondTx(R.merge(opt, {
245
+ const oracleRespondTx = await this.oracleRespondTx({
246
+ ...opt,
243
247
  oracleId,
244
248
  queryId,
245
249
  callerId,
246
250
  response
247
- }))
251
+ })
248
252
  return {
249
253
  ...await this.send(oracleRespondTx, opt),
250
254
  ...await this.getOracleObject(oracleId)
package/src/chain/node.js CHANGED
@@ -14,8 +14,6 @@
14
14
  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  * PERFORMANCE OF THIS SOFTWARE.
16
16
  */
17
- import * as R from 'ramda'
18
-
19
17
  import Chain from './'
20
18
  import { AE_AMOUNT_FORMATS, formatAmount } from '../utils/amount-formatter'
21
19
  import verifyTransaction from '../tx/validator'
@@ -34,7 +32,7 @@ import { DRY_RUN_ACCOUNT, NAME_ID_KEY } from '../tx/builder/schema'
34
32
  */
35
33
 
36
34
  async function sendTransaction (tx, options = {}) {
37
- const { waitMined, verify } = R.merge(this.Ae.defaults, options)
35
+ const { waitMined, verify } = { ...this.Ae.defaults, ...options }
38
36
  if (verify) {
39
37
  const validation = await verifyTransaction(tx, this.selectedNode.instance)
40
38
  if (validation.length) {
@@ -140,7 +138,7 @@ async function topBlock () {
140
138
  return this.api.getTopHeader()
141
139
  }
142
140
 
143
- async function poll (th, { blocks = 10, interval = 5000, allowUnsynced = false } = {}) {
141
+ async function poll (th, { blocks = 10, interval = 500, allowUnsynced = false } = {}) {
144
142
  const max = await this.height() + blocks
145
143
  do {
146
144
  const tx = await this.tx(th).catch(_ => null)
@@ -603,7 +603,6 @@ export async function awaitingCallContractForceProgressUpdate (channel, message,
603
603
  }
604
604
 
605
605
  export function awaitingForceProgressCompletion (channel, message, state) {
606
- console.log('From force progress await completion ->', message)
607
606
  if (message.method === 'channels.on_chain_tx') {
608
607
  if (state.onOnChainTx) {
609
608
  state.onOnChainTx(message.params.data)
@@ -39,7 +39,6 @@ import {
39
39
  disconnect as channelDisconnect,
40
40
  fsmId as channelFsmId
41
41
  } from './internal'
42
- import * as R from 'ramda'
43
42
 
44
43
  function snakeToPascalObjKeys (obj) {
45
44
  return Object.entries(obj).reduce((result, [key, val]) => ({
@@ -238,10 +237,10 @@ async function poi ({ accounts, contracts }) {
238
237
  * )
239
238
  */
240
239
  async function balances (accounts) {
241
- return R.reduce((acc, item) => ({
242
- ...acc,
243
- [item.account]: item.balance
244
- }), {}, await call(this, 'channels.get.balances', { accounts }))
240
+ return Object.fromEntries(
241
+ (await call(this, 'channels.get.balances', { accounts }))
242
+ .map(item => [item.account, item.balance])
243
+ )
245
244
  }
246
245
 
247
246
  /**