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.
- package/CHANGELOG.md +7 -0
- package/android/src/main/assets/edge-currency-accountbased/{645.chunk.js → 216.chunk.js} +6 -6
- package/android/src/main/assets/edge-currency-accountbased/244.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/387.chunk.js +9 -0
- package/android/src/main/assets/edge-currency-accountbased/491.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/549.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -9
- package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +11 -11
- package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +9 -9
- package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -4
- package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +6 -6
- package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
- package/lib/binance/bnbEngine.js +28 -16
- package/lib/binance/bnbTypes.js +11 -0
- package/lib/common/engine.js +47 -3
- package/lib/common/types.js +20 -0
- package/lib/declare-modules.d.js +0 -22
- package/lib/eos/eosEngine.js +32 -21
- package/lib/eos/eosTypes.js +16 -0
- package/lib/eos/info/eosInfo.js +3 -1
- package/lib/ethereum/ethEngine.js +90 -140
- package/lib/ethereum/ethTypes.js +64 -0
- package/lib/fio/fioConst.js +26 -55
- package/lib/fio/fioEngine.js +830 -609
- package/lib/fio/fioError.js +15 -22
- package/lib/fio/fioInfo.js +13 -23
- package/lib/fio/fioPlugin.js +85 -94
- package/lib/fio/fioTypes.js +180 -1
- package/lib/hedera/hederaEngine.js +24 -12
- package/lib/hedera/hederaTypes.js +37 -0
- package/lib/polkadot/polkadotEngine.js +30 -10
- package/lib/polkadot/polkadotTypes.js +37 -0
- package/lib/solana/solanaEngine.js +25 -27
- package/lib/solana/solanaTypes.js +37 -0
- package/lib/stellar/stellarEngine.js +21 -19
- package/lib/stellar/stellarTypes.js +10 -0
- package/lib/tezos/tezosEngine.js +23 -18
- package/lib/tezos/tezosTypes.js +16 -0
- package/lib/tron/tronEngine.js +14 -7
- package/lib/tron/tronPlugin.js +1 -1
- package/lib/tron/tronTypes.js +15 -11
- package/lib/xrp/xrpEngine.js +86 -59
- package/lib/xrp/xrpTypes.js +16 -0
- package/lib/zcash/zecEngine.js +33 -27
- package/lib/zcash/zecInfo.js +4 -1
- package/lib/zcash/zecPlugin.js +20 -6
- package/lib/zcash/zecTypes.js +57 -1
- package/package.json +3 -3
- package/android/src/main/assets/edge-currency-accountbased/206.chunk.js +0 -8
|
@@ -14,6 +14,8 @@ var _cleaners = require('cleaners');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
|
|
18
|
+
|
|
17
19
|
var _types = require('edge-core-js/types');
|
|
18
20
|
// eslint-disable-next-line camelcase
|
|
19
21
|
var _ethsigutil = require('eth-sig-util');
|
|
@@ -66,6 +68,11 @@ var _ethSchema = require('./ethSchema');
|
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
69
76
|
|
|
70
77
|
|
|
71
78
|
|
|
@@ -80,10 +87,10 @@ var _ethMiningFees = require('./fees/ethMiningFees');
|
|
|
80
87
|
|
|
81
88
|
var _feeProviders = require('./fees/feeProviders');
|
|
82
89
|
|
|
83
|
-
class EthereumEngine
|
|
84
|
-
|
|
90
|
+
class EthereumEngine extends _engine.CurrencyEngine
|
|
91
|
+
|
|
85
92
|
|
|
86
|
-
{
|
|
93
|
+
{
|
|
87
94
|
|
|
88
95
|
|
|
89
96
|
|
|
@@ -104,14 +111,6 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
104
111
|
currencyInfo
|
|
105
112
|
) {
|
|
106
113
|
super(env, tools, walletInfo, opts);EthereumEngine.prototype.__init.call(this);
|
|
107
|
-
const { pluginId } = this.currencyInfo
|
|
108
|
-
if (typeof this.walletInfo.keys[`${pluginId}Key`] !== 'string') {
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-optional-chain
|
|
110
|
-
if (walletInfo.keys.keys && walletInfo.keys.keys[`${pluginId}Key`]) {
|
|
111
|
-
this.walletInfo.keys[`${pluginId}Key`] =
|
|
112
|
-
walletInfo.keys.keys[`${pluginId}Key`]
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
114
|
this.initOptions = initOptions
|
|
116
115
|
this.networkInfo = env.networkInfo
|
|
117
116
|
this.ethNetwork = new (0, _ethNetwork.EthereumNetwork)(this)
|
|
@@ -140,9 +139,9 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
140
139
|
]
|
|
141
140
|
|
|
142
141
|
this.utils = {
|
|
143
|
-
signMessage: (message) => {
|
|
142
|
+
signMessage: (message, privateKeys) => {
|
|
144
143
|
if (!_utils.isHex.call(void 0, message)) throw new Error('ErrorInvalidMessage')
|
|
145
|
-
const privKey = Buffer.from(
|
|
144
|
+
const privKey = Buffer.from(privateKeys.privateKey, 'hex')
|
|
146
145
|
const messageBuffer = _utils.hexToBuf.call(void 0, message)
|
|
147
146
|
const messageHash = _ethereumjsutil2.default.hashPersonalMessage(messageBuffer)
|
|
148
147
|
const { v, r, s } = _ethereumjsutil2.default.ecsign(messageHash, privKey)
|
|
@@ -150,12 +149,14 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
150
149
|
return _ethereumjsutil2.default.toRpcSig(v, r, s)
|
|
151
150
|
},
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
signTypedData: (
|
|
153
|
+
typedData,
|
|
154
|
+
privateKeys
|
|
155
|
+
) => {
|
|
155
156
|
// Adapted from https://github.com/ethereum/EIPs/blob/master/assets/eip-712/Example.js
|
|
156
157
|
const clean = _ethSchema.asEIP712TypedData.call(void 0, typedData)
|
|
157
158
|
|
|
158
|
-
const privKey = Buffer.from(
|
|
159
|
+
const privKey = Buffer.from(privateKeys.privateKey, 'hex')
|
|
159
160
|
const { types } = clean
|
|
160
161
|
|
|
161
162
|
// Recursively finds all the dependencies of a type
|
|
@@ -264,7 +265,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
264
265
|
)
|
|
265
266
|
},
|
|
266
267
|
|
|
267
|
-
txRpcParamsToSpendInfo: (params
|
|
268
|
+
txRpcParamsToSpendInfo: (params) => {
|
|
268
269
|
const spendTarget = { otherParams: params }
|
|
269
270
|
if (params.to != null) {
|
|
270
271
|
spendTarget.publicAddress = params.to
|
|
@@ -276,7 +277,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
276
277
|
}
|
|
277
278
|
|
|
278
279
|
const spendInfo = {
|
|
279
|
-
currencyCode,
|
|
280
|
+
currencyCode: this.currencyInfo.currencyCode,
|
|
280
281
|
spendTargets: [spendTarget],
|
|
281
282
|
networkFeeOption: 'custom',
|
|
282
283
|
customNetworkFee: {
|
|
@@ -295,48 +296,10 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
this.otherMethods = {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return this.utils.signTypedData(JSON.parse(params[1]))
|
|
303
|
-
} catch (e) {
|
|
304
|
-
// It's possible that the dApp makes the wrong call.
|
|
305
|
-
// Try to sign using the latest signTypedData_v4 method.
|
|
306
|
-
return this.otherMethods.eth_signTypedData_v4(params)
|
|
307
|
-
}
|
|
308
|
-
},
|
|
309
|
-
eth_signTypedData_v4: params =>
|
|
310
|
-
_ethsigutil.signTypedData_v4.call(void 0, Buffer.from(this.getDisplayPrivateSeed(), 'hex'), {
|
|
311
|
-
data: JSON.parse(params[1])
|
|
312
|
-
}),
|
|
313
|
-
eth_sendTransaction: async (params, cc) => {
|
|
314
|
-
// @ts-expect-error
|
|
315
|
-
const spendInfo = this.utils.txRpcParamsToSpendInfo(params[0], cc)
|
|
316
|
-
const tx = await this.makeSpend(spendInfo)
|
|
317
|
-
const signedTx = await this.signTx(tx)
|
|
318
|
-
return await this.broadcastTx(signedTx)
|
|
319
|
-
},
|
|
320
|
-
eth_signTransaction: async (params, cc) => {
|
|
321
|
-
// @ts-expect-error
|
|
322
|
-
const spendInfo = this.utils.txRpcParamsToSpendInfo(params[0], cc)
|
|
323
|
-
const tx = await this.makeSpend(spendInfo)
|
|
324
|
-
return await this.signTx(tx)
|
|
325
|
-
},
|
|
326
|
-
eth_sendRawTransaction: async params => {
|
|
327
|
-
const tx = {
|
|
328
|
-
currencyCode: '',
|
|
329
|
-
nativeAmount: '',
|
|
330
|
-
networkFee: '',
|
|
331
|
-
blockHeight: 0,
|
|
332
|
-
date: Date.now(),
|
|
333
|
-
txid: '',
|
|
334
|
-
signedTx: params[0],
|
|
335
|
-
ourReceiveAddresses: [],
|
|
336
|
-
walletId: this.walletId
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return await this.broadcastTx(tx)
|
|
299
|
+
txRpcParamsToSpendInfo: async (
|
|
300
|
+
params
|
|
301
|
+
) => {
|
|
302
|
+
return this.utils.txRpcParamsToSpendInfo(params)
|
|
340
303
|
},
|
|
341
304
|
|
|
342
305
|
// Wallet Connect utils
|
|
@@ -449,63 +412,28 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
449
412
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
450
413
|
delete this.tools.walletConnectors[uri]
|
|
451
414
|
},
|
|
452
|
-
|
|
415
|
+
wcApproveRequest: async (
|
|
453
416
|
uri,
|
|
454
|
-
|
|
455
|
-
|
|
417
|
+
payload,
|
|
418
|
+
result
|
|
456
419
|
) => {
|
|
457
|
-
|
|
458
|
-
id: payload.id,
|
|
420
|
+
this.tools.walletConnectors[uri].connector.approveRequest({
|
|
421
|
+
id: parseInt(payload.id.toString()),
|
|
459
422
|
jsonrpc: '2.0',
|
|
460
|
-
|
|
423
|
+
result: result
|
|
461
424
|
})
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
case 'eth_sign':
|
|
473
|
-
case 'eth_signTypedData':
|
|
474
|
-
case 'eth_signTypedData_v4':
|
|
475
|
-
this.tools.walletConnectors[uri].connector.approveRequest(
|
|
476
|
-
requestBody({ result: result })
|
|
477
|
-
)
|
|
478
|
-
break
|
|
479
|
-
case 'eth_signTransaction':
|
|
480
|
-
this.tools.walletConnectors[uri].connector.approveRequest(
|
|
481
|
-
requestBody({ result: result.signedTx })
|
|
482
|
-
)
|
|
483
|
-
break
|
|
484
|
-
case 'eth_sendTransaction':
|
|
485
|
-
case 'eth_sendRawTransaction':
|
|
486
|
-
this.tools.walletConnectors[uri].connector.approveRequest(
|
|
487
|
-
requestBody({ result: result.txid })
|
|
488
|
-
)
|
|
489
|
-
}
|
|
490
|
-
} catch (e) {
|
|
491
|
-
this.tools.walletConnectors[uri].connector.rejectRequest(
|
|
492
|
-
requestBody({
|
|
493
|
-
error: {
|
|
494
|
-
message: 'rejected'
|
|
495
|
-
}
|
|
496
|
-
})
|
|
497
|
-
)
|
|
498
|
-
throw e
|
|
425
|
+
},
|
|
426
|
+
wcRejectRequest: async (
|
|
427
|
+
uri,
|
|
428
|
+
payload
|
|
429
|
+
) => {
|
|
430
|
+
this.tools.walletConnectors[uri].connector.rejectRequest({
|
|
431
|
+
id: parseInt(payload.id.toString()),
|
|
432
|
+
jsonrpc: '2.0',
|
|
433
|
+
error: {
|
|
434
|
+
message: 'rejected'
|
|
499
435
|
}
|
|
500
|
-
}
|
|
501
|
-
this.tools.walletConnectors[uri].connector.rejectRequest(
|
|
502
|
-
requestBody({
|
|
503
|
-
error: {
|
|
504
|
-
message: 'rejected'
|
|
505
|
-
}
|
|
506
|
-
})
|
|
507
|
-
)
|
|
508
|
-
}
|
|
436
|
+
})
|
|
509
437
|
},
|
|
510
438
|
wcGetConnections: () =>
|
|
511
439
|
Object.keys(this.tools.walletConnectors)
|
|
@@ -819,7 +747,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
819
747
|
throw new TypeError(`Invalid ${this.currencyInfo.pluginId} address`)
|
|
820
748
|
}
|
|
821
749
|
|
|
822
|
-
let data = _nullishCoalesce(spendTarget.memo, () => ( _optionalChain([spendTarget, 'access',
|
|
750
|
+
let data = _nullishCoalesce(spendTarget.memo, () => ( _optionalChain([spendTarget, 'access', _2 => _2.otherParams, 'optionalAccess', _3 => _3.data])))
|
|
823
751
|
if (data != null && data.length > 0 && !_utils.isHex.call(void 0, data)) {
|
|
824
752
|
throw new Error(`Memo/data field must be of type 'hex'`)
|
|
825
753
|
}
|
|
@@ -1087,7 +1015,42 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1087
1015
|
return edgeTransaction
|
|
1088
1016
|
}
|
|
1089
1017
|
|
|
1090
|
-
async
|
|
1018
|
+
async signMessage(
|
|
1019
|
+
message,
|
|
1020
|
+
privateKeys,
|
|
1021
|
+
opts
|
|
1022
|
+
) {
|
|
1023
|
+
const ethereumPrivateKeys = _ethTypes.asEthereumPrivateKeys.call(void 0,
|
|
1024
|
+
this.currencyInfo.pluginId
|
|
1025
|
+
)(privateKeys)
|
|
1026
|
+
const otherParams = _ethTypes.asEthereumSignMessageParams.call(void 0, opts.otherParams)
|
|
1027
|
+
|
|
1028
|
+
if (otherParams.typedData) {
|
|
1029
|
+
const typedData = JSON.parse(message)
|
|
1030
|
+
try {
|
|
1031
|
+
return this.utils.signTypedData(typedData, ethereumPrivateKeys)
|
|
1032
|
+
} catch (_) {
|
|
1033
|
+
// It's possible that the dApp makes the wrong call.
|
|
1034
|
+
// Try to sign using the latest signTypedData_v4 method.
|
|
1035
|
+
return _ethsigutil.signTypedData_v4.call(void 0,
|
|
1036
|
+
Buffer.from(ethereumPrivateKeys.privateKey, 'hex'),
|
|
1037
|
+
{
|
|
1038
|
+
data: typedData
|
|
1039
|
+
}
|
|
1040
|
+
)
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
return this.utils.signMessage(message, ethereumPrivateKeys)
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
async signTx(
|
|
1048
|
+
edgeTransaction,
|
|
1049
|
+
privateKeys
|
|
1050
|
+
) {
|
|
1051
|
+
const ethereumPrivateKeys = _ethTypes.asEthereumPrivateKeys.call(void 0,
|
|
1052
|
+
this.currencyInfo.pluginId
|
|
1053
|
+
)(privateKeys)
|
|
1091
1054
|
const otherParams = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
1092
1055
|
|
|
1093
1056
|
// Do signing
|
|
@@ -1184,10 +1147,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1184
1147
|
data
|
|
1185
1148
|
}
|
|
1186
1149
|
|
|
1187
|
-
const privKey = Buffer.from(
|
|
1188
|
-
this.walletInfo.keys[`${this.currencyInfo.pluginId}Key`],
|
|
1189
|
-
'hex'
|
|
1190
|
-
)
|
|
1150
|
+
const privKey = Buffer.from(ethereumPrivateKeys.privateKey, 'hex')
|
|
1191
1151
|
|
|
1192
1152
|
// Log the private key address
|
|
1193
1153
|
const wallet = _ethereumjswallet2.default.fromPrivateKey(privKey)
|
|
@@ -1234,7 +1194,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1234
1194
|
)
|
|
1235
1195
|
if (replacedTxIndex === -1) {
|
|
1236
1196
|
if (
|
|
1237
|
-
_optionalChain([txOtherParams, 'optionalAccess',
|
|
1197
|
+
_optionalChain([txOtherParams, 'optionalAccess', _4 => _4.replacedTxid]) != null &&
|
|
1238
1198
|
txOtherParams.replacedTxid !== ''
|
|
1239
1199
|
) {
|
|
1240
1200
|
// If the tx parameter is not found, then perhaps it is a
|
|
@@ -1332,26 +1292,15 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1332
1292
|
}
|
|
1333
1293
|
}
|
|
1334
1294
|
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
1341
|
-
this.walletInfo.keys[`${this.currencyInfo.pluginId}Key`]
|
|
1342
|
-
) {
|
|
1343
|
-
return this.walletInfo.keys[`${this.currencyInfo.pluginId}Key`]
|
|
1344
|
-
}
|
|
1345
|
-
return ''
|
|
1295
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
1296
|
+
const ethereumPrivateKeys = _ethTypes.asEthereumPrivateKeys.call(void 0,
|
|
1297
|
+
this.currencyInfo.pluginId
|
|
1298
|
+
)(privateKeys)
|
|
1299
|
+
return ethereumPrivateKeys.privateKey
|
|
1346
1300
|
}
|
|
1347
1301
|
|
|
1348
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1349
1302
|
getDisplayPublicSeed() {
|
|
1350
|
-
|
|
1351
|
-
if (this.walletInfo.keys && this.walletInfo.keys.publicKey) {
|
|
1352
|
-
return this.walletInfo.keys.publicKey
|
|
1353
|
-
}
|
|
1354
|
-
return ''
|
|
1303
|
+
return this.walletInfo.keys.publicKey
|
|
1355
1304
|
}
|
|
1356
1305
|
|
|
1357
1306
|
// Overload saveTx to mutate replaced transactions by RBF
|
|
@@ -1362,7 +1311,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1362
1311
|
)
|
|
1363
1312
|
|
|
1364
1313
|
// We must check if this transaction replaces another transaction
|
|
1365
|
-
if (_optionalChain([txOtherParams, 'optionalAccess',
|
|
1314
|
+
if (_optionalChain([txOtherParams, 'optionalAccess', _5 => _5.replacedTxid]) != null) {
|
|
1366
1315
|
const { currencyCode } = edgeTransaction
|
|
1367
1316
|
const txid = _utils.normalizeAddress.call(void 0, txOtherParams.replacedTxid)
|
|
1368
1317
|
const index = this.findTransaction(currencyCode, txid)
|
|
@@ -1389,7 +1338,7 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1389
1338
|
// Update the unconfirmed nonce if the transaction being saved is not confirmed
|
|
1390
1339
|
if (edgeTransaction.blockHeight === 0) {
|
|
1391
1340
|
const nonceUsed =
|
|
1392
|
-
_optionalChain([edgeTransaction, 'access',
|
|
1341
|
+
_optionalChain([edgeTransaction, 'access', _6 => _6.otherParams, 'optionalAccess', _7 => _7.nonceUsed])
|
|
1393
1342
|
if (nonceUsed != null) {
|
|
1394
1343
|
this.otherData.unconfirmedNextNonce = _biggystring.add.call(void 0, nonceUsed, '1')
|
|
1395
1344
|
}
|
|
@@ -1419,17 +1368,18 @@ var _feeProviders = require('./fees/feeProviders');
|
|
|
1419
1368
|
) {
|
|
1420
1369
|
const { currencyInfo, initOptions } = env
|
|
1421
1370
|
|
|
1371
|
+
const safeWalletInfo = _ethTypes.asSafeEthWalletInfo.call(void 0, walletInfo)
|
|
1422
1372
|
const engine = new EthereumEngine(
|
|
1423
1373
|
env,
|
|
1424
1374
|
tools,
|
|
1425
|
-
|
|
1375
|
+
safeWalletInfo,
|
|
1426
1376
|
initOptions,
|
|
1427
1377
|
opts,
|
|
1428
1378
|
currencyInfo
|
|
1429
1379
|
)
|
|
1430
1380
|
|
|
1431
1381
|
// Do any async initialization necessary for the engine
|
|
1432
|
-
await engine.loadEngine(tools,
|
|
1382
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
1433
1383
|
|
|
1434
1384
|
return engine
|
|
1435
1385
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
package/lib/ethereum/ethTypes.js
CHANGED
|
@@ -10,9 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
13
16
|
var _cleaners = require('cleaners');
|
|
14
17
|
|
|
15
18
|
|
|
19
|
+
var _types3 = require('../common/types');
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
|
|
18
23
|
|
|
@@ -472,6 +477,9 @@ const asWcDappDetails = _cleaners.asObject.call(void 0, {
|
|
|
472
477
|
params: _cleaners.asArray.call(void 0, asWcDappDetails)
|
|
473
478
|
}); exports.asWcSessionRequestParams = asWcSessionRequestParams
|
|
474
479
|
|
|
480
|
+
//
|
|
481
|
+
// Other Params and Other Methods:
|
|
482
|
+
//
|
|
475
483
|
|
|
476
484
|
|
|
477
485
|
|
|
@@ -487,12 +495,68 @@ const asWcDappDetails = _cleaners.asObject.call(void 0, {
|
|
|
487
495
|
|
|
488
496
|
|
|
489
497
|
|
|
498
|
+
const asEthereumSignMessageParams = _cleaners.asOptional.call(void 0,
|
|
499
|
+
_cleaners.asObject.call(void 0, {
|
|
500
|
+
typedData: _cleaners.asOptional.call(void 0, _cleaners.asBoolean, false)
|
|
501
|
+
}),
|
|
502
|
+
{ typedData: false }
|
|
503
|
+
); exports.asEthereumSignMessageParams = asEthereumSignMessageParams
|
|
504
|
+
|
|
505
|
+
//
|
|
506
|
+
// Wallet Info and Keys:
|
|
507
|
+
//
|
|
508
|
+
|
|
490
509
|
|
|
510
|
+
const asSafeEthWalletInfo = _types3.asSafeCommonWalletInfo; exports.asSafeEthWalletInfo = asSafeEthWalletInfo
|
|
491
511
|
|
|
492
512
|
|
|
493
513
|
|
|
494
514
|
|
|
495
515
|
|
|
516
|
+
const asEthereumPrivateKeys = (
|
|
517
|
+
pluginId
|
|
518
|
+
) => {
|
|
519
|
+
// Type hacks:
|
|
520
|
+
|
|
496
521
|
|
|
497
522
|
|
|
498
523
|
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
const _pluginId = pluginId
|
|
528
|
+
// Derived cleaners from the generic parameter:
|
|
529
|
+
const asFromKeys = _cleaners.asObject.call(void 0, {
|
|
530
|
+
[`${_pluginId}Mnemonic`]: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
531
|
+
[`${_pluginId}Key`]: _cleaners.asString
|
|
532
|
+
})
|
|
533
|
+
const asFromJackedKeys = _cleaners.asObject.call(void 0, { keys: asFromKeys })
|
|
534
|
+
|
|
535
|
+
return _cleaners.asCodec.call(void 0,
|
|
536
|
+
(value) => {
|
|
537
|
+
// Handle potentially jacked-up keys:
|
|
538
|
+
const fromJacked = _cleaners.asMaybe.call(void 0, asFromJackedKeys)(value)
|
|
539
|
+
if (fromJacked != null) {
|
|
540
|
+
const to = {
|
|
541
|
+
mnemonic: fromJacked.keys[`${_pluginId}Mnemonic`],
|
|
542
|
+
privateKey: fromJacked.keys[`${_pluginId}Key`]
|
|
543
|
+
}
|
|
544
|
+
return to
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// Handle normal keys:
|
|
548
|
+
const from = asFromKeys(value)
|
|
549
|
+
const to = {
|
|
550
|
+
mnemonic: from[`${_pluginId}Mnemonic`],
|
|
551
|
+
privateKey: from[`${_pluginId}Key`]
|
|
552
|
+
}
|
|
553
|
+
return to
|
|
554
|
+
},
|
|
555
|
+
ethPrivateKey => {
|
|
556
|
+
return {
|
|
557
|
+
[`${_pluginId}Mnemonic`]: ethPrivateKey.mnemonic,
|
|
558
|
+
[`${_pluginId}Key`]: ethPrivateKey.privateKey
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
}; exports.asEthereumPrivateKeys = asEthereumPrivateKeys
|
package/lib/fio/fioConst.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
var _cleaners = require('cleaners');
|
|
11
12
|
|
|
12
13
|
var _types = require('../common/types');
|
|
@@ -25,8 +26,10 @@ var _types = require('../common/types');
|
|
|
25
26
|
transferTokens: 'transferTokens',
|
|
26
27
|
addPublicAddress: 'addPublicAddress',
|
|
27
28
|
addPublicAddresses: 'addPublicAddresses',
|
|
28
|
-
|
|
29
|
+
removePublicAddresses: 'removePublicAddresses',
|
|
30
|
+
setFioDomainPublic: 'setFioDomainVisibility',
|
|
29
31
|
rejectFundsRequest: 'rejectFundsRequest',
|
|
32
|
+
cancelFundsRequest: 'cancelFundsRequest',
|
|
30
33
|
requestFunds: 'requestFunds',
|
|
31
34
|
recordObtData: 'recordObtData',
|
|
32
35
|
registerFioAddress: 'registerFioAddress',
|
|
@@ -43,14 +46,18 @@ var _types = require('../common/types');
|
|
|
43
46
|
const BROADCAST_ACTIONS = {
|
|
44
47
|
[exports.ACTIONS.recordObtData]: true,
|
|
45
48
|
[exports.ACTIONS.requestFunds]: true,
|
|
49
|
+
[exports.ACTIONS.rejectFundsRequest]: true,
|
|
50
|
+
[exports.ACTIONS.cancelFundsRequest]: true,
|
|
46
51
|
[exports.ACTIONS.registerFioAddress]: true,
|
|
47
52
|
[exports.ACTIONS.registerFioDomain]: true,
|
|
48
53
|
[exports.ACTIONS.renewFioDomain]: true,
|
|
49
54
|
[exports.ACTIONS.transferTokens]: true,
|
|
50
55
|
[exports.ACTIONS.addPublicAddresses]: true,
|
|
56
|
+
[exports.ACTIONS.removePublicAddresses]: true,
|
|
51
57
|
[exports.ACTIONS.transferFioAddress]: true,
|
|
52
58
|
[exports.ACTIONS.transferFioDomain]: true,
|
|
53
59
|
[exports.ACTIONS.addBundledTransactions]: true,
|
|
60
|
+
[exports.ACTIONS.setFioDomainPublic]: true,
|
|
54
61
|
[exports.ACTIONS.stakeFioTokens]: true,
|
|
55
62
|
[exports.ACTIONS.unStakeFioTokens]: true
|
|
56
63
|
}; exports.BROADCAST_ACTIONS = BROADCAST_ACTIONS
|
|
@@ -61,8 +68,10 @@ var _types = require('../common/types');
|
|
|
61
68
|
[exports.ACTIONS.registerFioDomain]: 'registerFioDomain',
|
|
62
69
|
[exports.ACTIONS.renewFioDomain]: 'renewFioDomain',
|
|
63
70
|
[exports.ACTIONS.addPublicAddresses]: 'addPubAddress',
|
|
71
|
+
[exports.ACTIONS.removePublicAddresses]: 'removePubAddress',
|
|
64
72
|
[exports.ACTIONS.setFioDomainPublic]: 'setFioDomainPublic',
|
|
65
73
|
[exports.ACTIONS.rejectFundsRequest]: 'rejectFundsRequest',
|
|
74
|
+
[exports.ACTIONS.cancelFundsRequest]: 'cancelFundsRequest',
|
|
66
75
|
[exports.ACTIONS.recordObtData]: 'recordObtData',
|
|
67
76
|
[exports.ACTIONS.transferTokens]: 'transferTokens',
|
|
68
77
|
[exports.ACTIONS.pushTransaction]: 'pushTransaction',
|
|
@@ -71,25 +80,7 @@ var _types = require('../common/types');
|
|
|
71
80
|
[exports.ACTIONS.stakeFioTokens]: 'pushTransaction',
|
|
72
81
|
[exports.ACTIONS.unStakeFioTokens]: 'pushTransaction',
|
|
73
82
|
addBundledTransactions: 'addBundledTransactions'
|
|
74
|
-
}; exports.ACTIONS_TO_END_POINT_KEYS = ACTIONS_TO_END_POINT_KEYS
|
|
75
|
-
|
|
76
|
-
const ACTIONS_TO_FEE_END_POINT_KEYS = {
|
|
77
|
-
[exports.ACTIONS.requestFunds]: 'newFundsRequest',
|
|
78
|
-
[exports.ACTIONS.registerFioAddress]: 'registerFioAddress',
|
|
79
|
-
[exports.ACTIONS.registerFioDomain]: 'registerFioDomain',
|
|
80
|
-
[exports.ACTIONS.renewFioDomain]: 'renewFioDomain',
|
|
81
|
-
[exports.ACTIONS.addPublicAddresses]: 'addPubAddress',
|
|
82
|
-
[exports.ACTIONS.setFioDomainPublic]: 'setFioDomainPublic',
|
|
83
|
-
[exports.ACTIONS.rejectFundsRequest]: 'rejectFundsRequest',
|
|
84
|
-
[exports.ACTIONS.recordObtData]: 'recordObtData',
|
|
85
|
-
[exports.ACTIONS.transferTokens]: 'transferTokens',
|
|
86
|
-
[exports.ACTIONS.pushTransaction]: 'pushTransaction',
|
|
87
|
-
[exports.ACTIONS.transferFioAddress]: 'transferFioAddress',
|
|
88
|
-
[exports.ACTIONS.transferFioDomain]: 'transferFioDomain',
|
|
89
|
-
[exports.ACTIONS.addBundledTransactions]: 'addBundledTransactions',
|
|
90
|
-
[exports.ACTIONS.stakeFioTokens]: 'stakeFioTokens',
|
|
91
|
-
[exports.ACTIONS.unStakeFioTokens]: 'unStakeFioTokens'
|
|
92
|
-
}; exports.ACTIONS_TO_FEE_END_POINT_KEYS = ACTIONS_TO_FEE_END_POINT_KEYS
|
|
83
|
+
} ; exports.ACTIONS_TO_END_POINT_KEYS = ACTIONS_TO_END_POINT_KEYS
|
|
93
84
|
|
|
94
85
|
const ACTIONS_TO_TX_ACTION_NAME = {
|
|
95
86
|
[exports.ACTIONS.transferTokens]: 'trnsfiopubky',
|
|
@@ -98,40 +89,6 @@ var _types = require('../common/types');
|
|
|
98
89
|
transfer: 'transfer'
|
|
99
90
|
}; exports.ACTIONS_TO_TX_ACTION_NAME = ACTIONS_TO_TX_ACTION_NAME
|
|
100
91
|
|
|
101
|
-
const FIO_REQUESTS_TYPES = {
|
|
102
|
-
PENDING: 'PENDING',
|
|
103
|
-
SENT: 'SENT'
|
|
104
|
-
}; exports.FIO_REQUESTS_TYPES = FIO_REQUESTS_TYPES
|
|
105
|
-
|
|
106
|
-
const FEE_ACTION_MAP = {
|
|
107
|
-
[exports.ACTIONS.addPublicAddress]: {
|
|
108
|
-
action: 'getFeeForAddPublicAddress',
|
|
109
|
-
propName: 'fioAddress'
|
|
110
|
-
},
|
|
111
|
-
[exports.ACTIONS.addPublicAddresses]: {
|
|
112
|
-
action: 'getFeeForAddPublicAddress',
|
|
113
|
-
propName: 'fioAddress'
|
|
114
|
-
},
|
|
115
|
-
[exports.ACTIONS.rejectFundsRequest]: {
|
|
116
|
-
action: 'getFeeForRejectFundsRequest',
|
|
117
|
-
propName: 'payerFioAddress'
|
|
118
|
-
},
|
|
119
|
-
[exports.ACTIONS.requestFunds]: {
|
|
120
|
-
action: 'getFeeForNewFundsRequest',
|
|
121
|
-
propName: 'payeeFioAddress'
|
|
122
|
-
},
|
|
123
|
-
[exports.ACTIONS.recordObtData]: {
|
|
124
|
-
action: 'getFeeForRecordObtData',
|
|
125
|
-
propName: 'payerFioAddress'
|
|
126
|
-
},
|
|
127
|
-
[exports.ACTIONS.stakeFioTokens]: {
|
|
128
|
-
propName: 'fioAddress'
|
|
129
|
-
},
|
|
130
|
-
[exports.ACTIONS.unStakeFioTokens]: {
|
|
131
|
-
propName: 'fioAddress'
|
|
132
|
-
}
|
|
133
|
-
}; exports.FEE_ACTION_MAP = FEE_ACTION_MAP
|
|
134
|
-
|
|
135
92
|
const DEFAULT_BUNDLED_TXS_AMOUNT = 100; exports.DEFAULT_BUNDLED_TXS_AMOUNT = DEFAULT_BUNDLED_TXS_AMOUNT
|
|
136
93
|
const DEFAULT_APR = 450; exports.DEFAULT_APR = DEFAULT_APR
|
|
137
94
|
const STAKING_REWARD_MEMO = 'Paying Staking Rewards'; exports.STAKING_REWARD_MEMO = STAKING_REWARD_MEMO
|
|
@@ -153,6 +110,21 @@ var _types = require('../common/types');
|
|
|
153
110
|
|
|
154
111
|
|
|
155
112
|
|
|
113
|
+
const asEncryptedFioRequest = _cleaners.asObject.call(void 0, {
|
|
114
|
+
fio_request_id: _cleaners.asNumber,
|
|
115
|
+
payer_fio_address: _cleaners.asString,
|
|
116
|
+
payee_fio_address: _cleaners.asString,
|
|
117
|
+
payer_fio_public_key: _cleaners.asString,
|
|
118
|
+
payee_fio_public_key: _cleaners.asString,
|
|
119
|
+
content: _cleaners.asString,
|
|
120
|
+
time_stamp: _cleaners.asString,
|
|
121
|
+
status: _cleaners.asOptional.call(void 0,
|
|
122
|
+
_cleaners.asValue.call(void 0, 'cancelled', 'rejected', 'requested', 'sent_to_blockchain')
|
|
123
|
+
)
|
|
124
|
+
}); exports.asEncryptedFioRequest = asEncryptedFioRequest
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
156
128
|
const asFioAddress = _cleaners.asObject.call(void 0, {
|
|
157
129
|
name: _cleaners.asString,
|
|
158
130
|
bundledTxs: _cleaners.asOptional.call(void 0, _cleaners.asNumber)
|
|
@@ -213,7 +185,6 @@ var _types = require('../common/types');
|
|
|
213
185
|
PENDING: []
|
|
214
186
|
}
|
|
215
187
|
),
|
|
216
|
-
fioRequestsToApprove: _cleaners.asMaybe.call(void 0, _cleaners.asObject.call(void 0, _types.asAny), {}),
|
|
217
188
|
srps: _cleaners.asMaybe.call(void 0, _cleaners.asNumber, 0),
|
|
218
189
|
stakingRoe: _cleaners.asMaybe.call(void 0, _cleaners.asString, ''),
|
|
219
190
|
stakingStatus: _cleaners.asMaybe.call(void 0, exports.asEdgeStakingStatus, {
|