edge-currency-accountbased 0.22.21 → 0.23.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 (57) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/android/src/main/assets/edge-currency-accountbased/{645.chunk.js → 216.chunk.js} +6 -6
  3. package/android/src/main/assets/edge-currency-accountbased/244.chunk.js +1 -1
  4. package/android/src/main/assets/edge-currency-accountbased/387.chunk.js +9 -0
  5. package/android/src/main/assets/edge-currency-accountbased/491.chunk.js +1 -1
  6. package/android/src/main/assets/edge-currency-accountbased/549.chunk.js +1 -1
  7. package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -9
  8. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +3 -3
  9. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -2
  10. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +11 -11
  11. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +9 -9
  12. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  13. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  14. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  15. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -4
  16. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
  17. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +6 -6
  18. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
  19. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  20. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  21. package/lib/binance/bnbEngine.js +28 -16
  22. package/lib/binance/bnbTypes.js +11 -0
  23. package/lib/common/engine.js +47 -3
  24. package/lib/common/types.js +20 -0
  25. package/lib/declare-modules.d.js +0 -22
  26. package/lib/eos/eosEngine.js +32 -21
  27. package/lib/eos/eosTypes.js +16 -0
  28. package/lib/eos/info/eosInfo.js +3 -1
  29. package/lib/ethereum/ethEngine.js +90 -140
  30. package/lib/ethereum/ethTypes.js +64 -0
  31. package/lib/fio/fioConst.js +26 -55
  32. package/lib/fio/fioEngine.js +830 -609
  33. package/lib/fio/fioError.js +15 -22
  34. package/lib/fio/fioInfo.js +13 -23
  35. package/lib/fio/fioPlugin.js +85 -94
  36. package/lib/fio/fioTypes.js +180 -1
  37. package/lib/hedera/hederaEngine.js +24 -12
  38. package/lib/hedera/hederaTypes.js +37 -0
  39. package/lib/polkadot/polkadotEngine.js +30 -10
  40. package/lib/polkadot/polkadotTypes.js +37 -0
  41. package/lib/solana/solanaEngine.js +25 -27
  42. package/lib/solana/solanaTypes.js +37 -0
  43. package/lib/stellar/stellarEngine.js +21 -19
  44. package/lib/stellar/stellarTypes.js +10 -0
  45. package/lib/tezos/tezosEngine.js +23 -18
  46. package/lib/tezos/tezosTypes.js +16 -0
  47. package/lib/tron/tronEngine.js +14 -7
  48. package/lib/tron/tronPlugin.js +1 -1
  49. package/lib/tron/tronTypes.js +15 -11
  50. package/lib/xrp/xrpEngine.js +86 -59
  51. package/lib/xrp/xrpTypes.js +16 -0
  52. package/lib/zcash/zecEngine.js +33 -27
  53. package/lib/zcash/zecInfo.js +4 -1
  54. package/lib/zcash/zecPlugin.js +20 -6
  55. package/lib/zcash/zecTypes.js +57 -1
  56. package/package.json +3 -3
  57. package/android/src/main/assets/edge-currency-accountbased/206.chunk.js +0 -8
@@ -17,6 +17,8 @@
17
17
 
18
18
 
19
19
 
20
+
21
+
20
22
 
21
23
 
22
24
  var _types = require('edge-core-js/types');
@@ -36,6 +38,7 @@ var _tokenHelpers = require('./tokenHelpers');
36
38
 
37
39
 
38
40
 
41
+
39
42
  var _types3 = require('./types');
40
43
 
41
44
 
@@ -51,7 +54,12 @@ const DROPPED_TX_TIME_GAP = 3600 * 24 // 1 Day
51
54
 
52
55
  class CurrencyEngine
53
56
 
54
- {
57
+
58
+
59
+
60
+
61
+
62
+ {
55
63
 
56
64
 
57
65
 
@@ -263,8 +271,7 @@ const DROPPED_TX_TIME_GAP = 3600 * 24 // 1 Day
263
271
  const { currencyCode } = this.currencyInfo
264
272
 
265
273
  if (this.walletInfo.keys.publicKey == null) {
266
- const pubKeys = await this.tools.derivePublicKey(this.walletInfo)
267
- this.walletInfo.keys.publicKey = pubKeys.publicKey
274
+ this.walletInfo.keys.publicKey = walletInfo.keys.publicKey
268
275
  }
269
276
 
270
277
  const disklet = this.walletLocalDisklet
@@ -1064,4 +1071,41 @@ const DROPPED_TX_TIME_GAP = 3600 * 24 // 1 Day
1064
1071
  )
1065
1072
  }
1066
1073
  }
1074
+
1075
+ //
1076
+ // Virtual functions to be override by extension:
1077
+ //
1078
+
1079
+ getDisplayPrivateSeed(privateKeys) {
1080
+ throw new Error('not implemented')
1081
+ }
1082
+
1083
+ getDisplayPublicSeed() {
1084
+ throw new Error('not implemented')
1085
+ }
1086
+
1087
+ async resyncBlockchain() {
1088
+ throw new Error('not implemented')
1089
+ }
1090
+
1091
+ async makeSpend(
1092
+ edgeSpendInfoIn,
1093
+ opts
1094
+ ) {
1095
+ throw new Error('not implemented')
1096
+ }
1097
+
1098
+ async signTx(
1099
+ edgeTransaction,
1100
+ privateKeys
1101
+ ) {
1102
+ throw new Error('not implemented')
1103
+ }
1104
+
1105
+ async broadcastTx(
1106
+ edgeTransaction,
1107
+ opts
1108
+ ) {
1109
+ throw new Error('not implemented')
1110
+ }
1067
1111
  } exports.CurrencyEngine = CurrencyEngine;
@@ -8,6 +8,7 @@
8
8
 
9
9
 
10
10
 
11
+
11
12
  var _cleaners = require('cleaners');
12
13
 
13
14
 
@@ -54,3 +55,22 @@ var _cleaners = require('cleaners');
54
55
  }); exports.asWalletLocalData = asWalletLocalData
55
56
 
56
57
 
58
+
59
+
60
+
61
+
62
+
63
+
64
+ const asWalletInfo = (
65
+ asKeys
66
+ ) =>
67
+ _cleaners.asObject.call(void 0, {
68
+ id: _cleaners.asString,
69
+ type: _cleaners.asString,
70
+ keys: asKeys
71
+ }); exports.asWalletInfo = asWalletInfo
72
+
73
+
74
+ const asSafeCommonWalletInfo = exports.asWalletInfo.call(void 0,
75
+ _cleaners.asObject.call(void 0, { publicKey: _cleaners.asString })
76
+ ); exports.asSafeCommonWalletInfo = asSafeCommonWalletInfo
@@ -21,6 +21,8 @@ var _cleaners = require('cleaners');
21
21
 
22
22
 
23
23
 
24
+
25
+
24
26
  var _types = require('edge-core-js/types');
25
27
  var _urlparse = require('url-parse'); var _urlparse2 = _interopRequireDefault(_urlparse);
26
28
 
@@ -58,6 +60,10 @@ var _eosSchema = require('./eosSchema');
58
60
 
59
61
 
60
62
 
63
+
64
+
65
+
66
+
61
67
  var _eosTypes = require('./eosTypes');
62
68
 
63
69
  const ADDRESS_POLL_MILLISECONDS = 10000
@@ -192,6 +198,7 @@ const bogusAccounts = {
192
198
  opts
193
199
  ) {
194
200
  await super.loadEngine(plugin, walletInfo, opts)
201
+
195
202
  if (typeof this.walletInfo.keys.ownerPublicKey !== 'string') {
196
203
  if (walletInfo.keys.ownerPublicKey != null) {
197
204
  this.walletInfo.keys.ownerPublicKey = walletInfo.keys.ownerPublicKey
@@ -795,7 +802,7 @@ const bogusAccounts = {
795
802
  }
796
803
  }
797
804
 
798
- async getResources() {
805
+ async getResources(privateKeys) {
799
806
  if (this.getResourcesMutex) return
800
807
  const { cpu, net } = this.accountResources
801
808
  if (cpu > 500 && net > 500) {
@@ -870,9 +877,9 @@ const bogusAccounts = {
870
877
  },
871
878
  walletId: this.walletId
872
879
  }
873
- const signedTx = await this.signTx(edgeTransaction)
880
+ const signedTx = await this.signTx(edgeTransaction, privateKeys)
874
881
  this.getResourcesMutex = true
875
- await this.broadcastTx(signedTx)
882
+ await this.broadcastTx(signedTx, { privateKeys })
876
883
  this.log.warn('getResources purchase SUCCESS')
877
884
  } catch (e) {
878
885
  this.log.warn('getResources purchase FAILURE\n', e)
@@ -1044,7 +1051,11 @@ const bogusAccounts = {
1044
1051
  return edgeTransaction
1045
1052
  }
1046
1053
 
1047
- async signTx(edgeTransaction) {
1054
+ async signTx(
1055
+ edgeTransaction,
1056
+ privateKeys
1057
+ ) {
1058
+ const eosPrivateKeys = _eosTypes.asEosPrivateKeys.call(void 0, privateKeys)
1048
1059
  const otherParams = _utils.getOtherParams(edgeTransaction)
1049
1060
 
1050
1061
  const abi =
@@ -1059,7 +1070,7 @@ const bogusAccounts = {
1059
1070
  abi
1060
1071
  )
1061
1072
  const txDigest = transaction.signingDigest(this.networkInfo.chainId)
1062
- const privateKey = _eosio.PrivateKey.from(this.walletInfo.keys.eosKey)
1073
+ const privateKey = _eosio.PrivateKey.from(eosPrivateKeys.eosKey)
1063
1074
  const signature = privateKey.signDigest(txDigest)
1064
1075
  const signedTransaction = _eosio.SignedTransaction.from({
1065
1076
  ...transaction,
@@ -1075,9 +1086,11 @@ const bogusAccounts = {
1075
1086
  }
1076
1087
 
1077
1088
  async broadcastTx(
1078
- edgeTransaction
1089
+ edgeTransaction,
1090
+ opts
1079
1091
  ) {
1080
- await this.getResources()
1092
+ const eosPrivateKeys = _eosTypes.asEosPrivateKeys.call(void 0, _optionalChain([opts, 'optionalAccess', _5 => _5.privateKeys]))
1093
+ await this.getResources(eosPrivateKeys)
1081
1094
 
1082
1095
  const otherParams = _utils.getOtherParams(edgeTransaction)
1083
1096
  const { signatures } = otherParams
@@ -1108,13 +1121,13 @@ const bogusAccounts = {
1108
1121
  } catch (e2) {
1109
1122
  throw e
1110
1123
  }
1111
- if (_optionalChain([err, 'access', _5 => _5.error, 'optionalAccess', _6 => _6.name]) === 'tx_net_usage_exceeded') {
1124
+ if (_optionalChain([err, 'access', _6 => _6.error, 'optionalAccess', _7 => _7.name]) === 'tx_net_usage_exceeded') {
1112
1125
  err = new Error('Insufficient NET available to send EOS transaction')
1113
1126
  err.name = 'ErrorEosInsufficientNet'
1114
- } else if (_optionalChain([err, 'access', _7 => _7.error, 'optionalAccess', _8 => _8.name]) === 'tx_cpu_usage_exceeded') {
1127
+ } else if (_optionalChain([err, 'access', _8 => _8.error, 'optionalAccess', _9 => _9.name]) === 'tx_cpu_usage_exceeded') {
1115
1128
  err = new Error('Insufficient CPU available to send EOS transaction')
1116
1129
  err.name = 'ErrorEosInsufficientCpu'
1117
- } else if (_optionalChain([err, 'access', _9 => _9.error, 'optionalAccess', _10 => _10.name]) === 'ram_usage_exceeded') {
1130
+ } else if (_optionalChain([err, 'access', _10 => _10.error, 'optionalAccess', _11 => _11.name]) === 'ram_usage_exceeded') {
1118
1131
  err = new Error('Insufficient RAM available to send EOS transaction')
1119
1132
  err.name = 'ErrorEosInsufficientRam'
1120
1133
  }
@@ -1122,28 +1135,25 @@ const bogusAccounts = {
1122
1135
  }
1123
1136
  }
1124
1137
 
1125
- getDisplayPrivateSeed() {
1138
+ getDisplayPrivateSeed(privateKeys) {
1139
+ const eosPrivateKeys = _eosTypes.asEosPrivateKeys.call(void 0, privateKeys)
1126
1140
  let out = ''
1127
1141
  // usage of eosOwnerKey must be protected by conditional
1128
1142
  // checking for its existence
1129
- if (_optionalChain([this, 'access', _11 => _11.walletInfo, 'access', _12 => _12.keys, 'optionalAccess', _13 => _13.eosOwnerKey]) != null) {
1130
- out += 'owner key\n' + String(this.walletInfo.keys.eosOwnerKey) + '\n\n'
1131
- }
1132
- if (_optionalChain([this, 'access', _14 => _14.walletInfo, 'access', _15 => _15.keys, 'optionalAccess', _16 => _16.eosKey]) != null) {
1133
- out += 'active key\n' + String(this.walletInfo.keys.eosKey) + '\n\n'
1134
- }
1143
+ out += 'owner key\n' + String(eosPrivateKeys.eosOwnerKey) + '\n\n'
1144
+ out += 'active key\n' + String(eosPrivateKeys.eosKey) + '\n\n'
1135
1145
  return out
1136
1146
  }
1137
1147
 
1138
1148
  getDisplayPublicSeed() {
1139
1149
  let out = ''
1140
- if (_optionalChain([this, 'access', _17 => _17.walletInfo, 'access', _18 => _18.keys, 'optionalAccess', _19 => _19.ownerPublicKey]) != null) {
1150
+ if (_optionalChain([this, 'access', _12 => _12.walletInfo, 'access', _13 => _13.keys, 'optionalAccess', _14 => _14.ownerPublicKey]) != null) {
1141
1151
  out +=
1142
1152
  'owner publicKey\n' +
1143
1153
  String(this.walletInfo.keys.ownerPublicKey) +
1144
1154
  '\n\n'
1145
1155
  }
1146
- if (_optionalChain([this, 'access', _20 => _20.walletInfo, 'access', _21 => _21.keys, 'optionalAccess', _22 => _22.publicKey]) != null) {
1156
+ if (_optionalChain([this, 'access', _15 => _15.walletInfo, 'access', _16 => _16.keys, 'optionalAccess', _17 => _17.publicKey]) != null) {
1147
1157
  out +=
1148
1158
  'active publicKey\n' + String(this.walletInfo.keys.publicKey) + '\n\n'
1149
1159
  }
@@ -1157,8 +1167,9 @@ const bogusAccounts = {
1157
1167
  walletInfo,
1158
1168
  opts
1159
1169
  ) {
1160
- const engine = new EosEngine(env, tools, walletInfo, opts)
1161
- await engine.loadEngine(tools, walletInfo, opts)
1170
+ const safeWalletInfo = _eosTypes.asSafeEosWalletInfo.call(void 0, walletInfo)
1171
+ const engine = new EosEngine(env, tools, safeWalletInfo, opts)
1172
+ await engine.loadEngine(tools, safeWalletInfo, opts)
1162
1173
 
1163
1174
  return engine
1164
1175
  } exports.makeCurrencyEngine = makeCurrencyEngine;
@@ -1,5 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _cleaners = require('cleaners');
2
2
 
3
+ var _types = require('../common/types');
4
+
3
5
 
4
6
 
5
7
 
@@ -80,3 +82,17 @@
80
82
 
81
83
 
82
84
 
85
+
86
+
87
+ const asSafeEosWalletInfo = _types.asWalletInfo.call(void 0,
88
+ _cleaners.asObject.call(void 0, {
89
+ publicKey: _cleaners.asString,
90
+ ownerPublicKey: _cleaners.asOptional.call(void 0, _cleaners.asString)
91
+ })
92
+ ); exports.asSafeEosWalletInfo = asSafeEosWalletInfo
93
+
94
+
95
+ const asEosPrivateKeys = _cleaners.asObject.call(void 0, {
96
+ eosOwnerKey: _cleaners.asString,
97
+ eosKey: _cleaners.asString
98
+ }); exports.asEosPrivateKeys = asEosPrivateKeys
@@ -51,7 +51,9 @@ const denominations = [
51
51
  transactionExplorer: 'https://bloks.io/transaction/%s',
52
52
 
53
53
  denominations,
54
- metaTokens: [] // Deprecated
54
+ metaTokens: [], // Deprecated
55
+
56
+ unsafeBroadcastTx: true
55
57
  }; exports.eosCurrencyInfo = eosCurrencyInfo
56
58
 
57
59
  const eos = _innerPlugin.makeOuterPlugin({