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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
var _types = require('edge-core-js/types');
|
|
11
12
|
var _stellarsdk = require('stellar-sdk'); var _stellarsdk2 = _interopRequireDefault(_stellarsdk);
|
|
12
13
|
|
|
@@ -28,6 +29,9 @@ var _utils = require('../common/utils');
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
31
35
|
var _stellarTypes = require('./stellarTypes');
|
|
32
36
|
|
|
33
37
|
const TX_QUERY_PAGING_LIMIT = 2
|
|
@@ -44,7 +48,10 @@ const BASE_FEE = 100 // Stroops
|
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
|
|
47
|
-
class StellarEngine extends _engine.CurrencyEngine
|
|
51
|
+
class StellarEngine extends _engine.CurrencyEngine
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
{
|
|
48
55
|
|
|
49
56
|
|
|
50
57
|
|
|
@@ -453,7 +460,6 @@ const BASE_FEE = 100 // Stroops
|
|
|
453
460
|
await this.startEngine()
|
|
454
461
|
}
|
|
455
462
|
|
|
456
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
457
463
|
async makeSpend(edgeSpendInfoIn) {
|
|
458
464
|
const { edgeSpendInfo, currencyCode, nativeBalance, denom } =
|
|
459
465
|
this.makeSpendCheck(edgeSpendInfoIn)
|
|
@@ -587,7 +593,11 @@ const BASE_FEE = 100 // Stroops
|
|
|
587
593
|
return edgeTransaction
|
|
588
594
|
}
|
|
589
595
|
|
|
590
|
-
async signTx(
|
|
596
|
+
async signTx(
|
|
597
|
+
edgeTransaction,
|
|
598
|
+
privateKeys
|
|
599
|
+
) {
|
|
600
|
+
const stellarPrivateKeys = _stellarTypes.asStellarPrivateKeys.call(void 0, privateKeys)
|
|
591
601
|
const otherParams = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
592
602
|
|
|
593
603
|
const sendAmount = _biggystring.abs.call(void 0,
|
|
@@ -610,7 +620,7 @@ const BASE_FEE = 100 // Stroops
|
|
|
610
620
|
this.warn('Signing...')
|
|
611
621
|
// @ts-expect-error
|
|
612
622
|
const keypair = this.stellarApi.Keypair.fromSecret(
|
|
613
|
-
|
|
623
|
+
stellarPrivateKeys.stellarKey
|
|
614
624
|
)
|
|
615
625
|
// @ts-expect-error
|
|
616
626
|
await transaction.sign(keypair)
|
|
@@ -658,22 +668,13 @@ const BASE_FEE = 100 // Stroops
|
|
|
658
668
|
return edgeTransaction
|
|
659
669
|
}
|
|
660
670
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if (this.walletInfo.keys && this.walletInfo.keys.stellarKey) {
|
|
665
|
-
return this.walletInfo.keys.stellarKey
|
|
666
|
-
}
|
|
667
|
-
return ''
|
|
671
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
672
|
+
const stellarPrivateKeys = _stellarTypes.asStellarPrivateKeys.call(void 0, privateKeys)
|
|
673
|
+
return stellarPrivateKeys.stellarKey
|
|
668
674
|
}
|
|
669
675
|
|
|
670
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
671
676
|
getDisplayPublicSeed() {
|
|
672
|
-
|
|
673
|
-
if (this.walletInfo.keys && this.walletInfo.keys.publicKey) {
|
|
674
|
-
return this.walletInfo.keys.publicKey
|
|
675
|
-
}
|
|
676
|
-
return ''
|
|
677
|
+
return this.walletInfo.keys.publicKey
|
|
677
678
|
}
|
|
678
679
|
} exports.StellarEngine = StellarEngine;
|
|
679
680
|
|
|
@@ -683,11 +684,12 @@ const BASE_FEE = 100 // Stroops
|
|
|
683
684
|
walletInfo,
|
|
684
685
|
opts
|
|
685
686
|
) {
|
|
686
|
-
const
|
|
687
|
+
const safeWalletInfo = _stellarTypes.asSafeStellarWalletInfo.call(void 0, walletInfo)
|
|
688
|
+
const engine = new StellarEngine(env, tools, safeWalletInfo, opts)
|
|
687
689
|
|
|
688
690
|
engine.stellarApi = _stellarsdk2.default
|
|
689
691
|
|
|
690
|
-
await engine.loadEngine(tools,
|
|
692
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
691
693
|
|
|
692
694
|
return engine
|
|
693
695
|
} 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
|
|
|
@@ -83,3 +85,11 @@
|
|
|
83
85
|
// p99: asString
|
|
84
86
|
})
|
|
85
87
|
}); exports.asFeeStats = asFeeStats
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
const asSafeStellarWalletInfo = _types.asSafeCommonWalletInfo; exports.asSafeStellarWalletInfo = asSafeStellarWalletInfo
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const asStellarPrivateKeys = _cleaners.asObject.call(void 0, {
|
|
94
|
+
stellarKey: _cleaners.asString
|
|
95
|
+
}); exports.asStellarPrivateKeys = asStellarPrivateKeys
|
package/lib/tezos/tezosEngine.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
|
|
11
12
|
var _types = require('edge-core-js/types');
|
|
12
13
|
var _eztzjs = require('eztz.js');
|
|
13
14
|
|
|
@@ -32,6 +33,9 @@ var _tezosInfo = require('./tezosInfo');
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
35
39
|
var _tezosTypes = require('./tezosTypes');
|
|
36
40
|
|
|
37
41
|
const ADDRESS_POLL_MILLISECONDS = 15000
|
|
@@ -50,7 +54,11 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
50
54
|
|
|
51
55
|
|
|
52
56
|
|
|
53
|
-
class TezosEngine extends _engine.CurrencyEngine
|
|
57
|
+
class TezosEngine extends _engine.CurrencyEngine
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
|
|
54
62
|
|
|
55
63
|
|
|
56
64
|
|
|
@@ -62,6 +70,7 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
62
70
|
opts
|
|
63
71
|
) {
|
|
64
72
|
super(env, tools, walletInfo, opts)
|
|
73
|
+
this.walletInfo = _tezosTypes.asSafeTezosWalletInfo.call(void 0, walletInfo)
|
|
65
74
|
this.networkInfo = env.networkInfo
|
|
66
75
|
const fetchCors = _utils.getFetchCors.call(void 0, env)
|
|
67
76
|
this.fetchCors = fetchCors
|
|
@@ -474,11 +483,15 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
474
483
|
return edgeTransaction
|
|
475
484
|
}
|
|
476
485
|
|
|
477
|
-
async signTx(
|
|
486
|
+
async signTx(
|
|
487
|
+
edgeTransaction,
|
|
488
|
+
privateKeys
|
|
489
|
+
) {
|
|
490
|
+
const tezosPrivateKeys = _tezosTypes.asTezosPrivateKeys.call(void 0, privateKeys)
|
|
478
491
|
const otherParams = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
479
492
|
|
|
480
493
|
if (edgeTransaction.signedTx === '') {
|
|
481
|
-
const sk =
|
|
494
|
+
const sk = tezosPrivateKeys.privateKey
|
|
482
495
|
const signed = _eztzjs.eztz.crypto.sign(
|
|
483
496
|
otherParams.fullOp.opbytes,
|
|
484
497
|
sk,
|
|
@@ -506,22 +519,13 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
506
519
|
return edgeTransaction
|
|
507
520
|
}
|
|
508
521
|
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
if (this.walletInfo.keys && this.walletInfo.keys.mnemonic) {
|
|
513
|
-
return this.walletInfo.keys.mnemonic
|
|
514
|
-
}
|
|
515
|
-
return ''
|
|
522
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
523
|
+
const tezosPrivateKeys = _tezosTypes.asTezosPrivateKeys.call(void 0, privateKeys)
|
|
524
|
+
return tezosPrivateKeys.mnemonic
|
|
516
525
|
}
|
|
517
526
|
|
|
518
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
519
527
|
getDisplayPublicSeed() {
|
|
520
|
-
|
|
521
|
-
if (this.walletInfo.keys && this.walletInfo.keys.publicKey) {
|
|
522
|
-
return this.walletInfo.keys.publicKey
|
|
523
|
-
}
|
|
524
|
-
return ''
|
|
528
|
+
return this.walletInfo.keys.publicKey
|
|
525
529
|
}
|
|
526
530
|
} exports.TezosEngine = TezosEngine;
|
|
527
531
|
|
|
@@ -531,9 +535,10 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
531
535
|
walletInfo,
|
|
532
536
|
opts
|
|
533
537
|
) {
|
|
534
|
-
const
|
|
538
|
+
const safeWalletInfo = _tezosTypes.asSafeTezosWalletInfo.call(void 0, walletInfo)
|
|
539
|
+
const engine = new TezosEngine(env, tools, safeWalletInfo, opts)
|
|
535
540
|
|
|
536
|
-
await engine.loadEngine(tools,
|
|
541
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
537
542
|
|
|
538
543
|
return engine
|
|
539
544
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
package/lib/tezos/tezosTypes.js
CHANGED
|
@@ -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
|
|
|
@@ -123,3 +125,17 @@
|
|
|
123
125
|
|
|
124
126
|
|
|
125
127
|
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
const asSafeTezosWalletInfo = _types.asWalletInfo.call(void 0,
|
|
131
|
+
_cleaners.asObject.call(void 0, {
|
|
132
|
+
publicKey: _cleaners.asString,
|
|
133
|
+
publicKeyEd: _cleaners.asString
|
|
134
|
+
})
|
|
135
|
+
); exports.asSafeTezosWalletInfo = asSafeTezosWalletInfo
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
const asTezosPrivateKeys = _cleaners.asObject.call(void 0, {
|
|
139
|
+
mnemonic: _cleaners.asString,
|
|
140
|
+
privateKey: _cleaners.asString
|
|
141
|
+
}); exports.asTezosPrivateKeys = asTezosPrivateKeys
|
package/lib/tron/tronEngine.js
CHANGED
|
@@ -58,6 +58,8 @@ var _utils = require('../common/utils');
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
|
|
62
|
+
|
|
61
63
|
|
|
62
64
|
|
|
63
65
|
|
|
@@ -1278,11 +1280,14 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
|
|
|
1278
1280
|
return edgeTransaction
|
|
1279
1281
|
}
|
|
1280
1282
|
|
|
1281
|
-
async signTx(
|
|
1283
|
+
async signTx(
|
|
1284
|
+
edgeTransaction,
|
|
1285
|
+
privateKeys
|
|
1286
|
+
) {
|
|
1282
1287
|
const otherParams = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
1283
1288
|
|
|
1284
1289
|
const transaction = await this.txBuilder(otherParams)
|
|
1285
|
-
const { tronKey } = _tronTypes.
|
|
1290
|
+
const { tronKey } = _tronTypes.asTronPrivateKeys.call(void 0, privateKeys)
|
|
1286
1291
|
const signer = this.tronscan.getSigner(tronKey)
|
|
1287
1292
|
const { hex } = await signer.signTransaction(transaction.transaction)
|
|
1288
1293
|
|
|
@@ -1329,12 +1334,13 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
|
|
|
1329
1334
|
return edgeTransaction
|
|
1330
1335
|
}
|
|
1331
1336
|
|
|
1332
|
-
getDisplayPrivateSeed() {
|
|
1333
|
-
|
|
1337
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
1338
|
+
const tronPrivateKeys = _tronTypes.asTronPrivateKeys.call(void 0, privateKeys)
|
|
1339
|
+
return _nullishCoalesce(tronPrivateKeys.tronMnemonic, () => ( tronPrivateKeys.tronKey))
|
|
1334
1340
|
}
|
|
1335
1341
|
|
|
1336
1342
|
getDisplayPublicSeed() {
|
|
1337
|
-
return
|
|
1343
|
+
return this.walletInfo.keys.publicKey
|
|
1338
1344
|
}
|
|
1339
1345
|
} exports.TronEngine = TronEngine;
|
|
1340
1346
|
|
|
@@ -1344,10 +1350,11 @@ const NETWORKFEES_POLL_MILLISECONDS = 60 * 10 * 1000
|
|
|
1344
1350
|
walletInfo,
|
|
1345
1351
|
opts
|
|
1346
1352
|
) {
|
|
1347
|
-
const
|
|
1353
|
+
const safeWalletInfo = _tronTypes.asSafeTronWalletInfo.call(void 0, walletInfo)
|
|
1354
|
+
const engine = new TronEngine(env, tools, safeWalletInfo, opts)
|
|
1348
1355
|
|
|
1349
1356
|
// Do any async initialization necessary for the engine
|
|
1350
|
-
await engine.loadEngine(tools,
|
|
1357
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
1351
1358
|
|
|
1352
1359
|
return engine
|
|
1353
1360
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
package/lib/tron/tronPlugin.js
CHANGED
|
@@ -100,7 +100,7 @@ var _tronTypes = require('./tronTypes');
|
|
|
100
100
|
throw new Error('InvalidWalletType')
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const { tronKey } = _tronTypes.
|
|
103
|
+
const { tronKey } = _tronTypes.asTronPrivateKeys.call(void 0, walletInfo.keys)
|
|
104
104
|
const publicKey = _crypto.pkToAddress.call(void 0, tronKey)
|
|
105
105
|
return { publicKey }
|
|
106
106
|
}
|
package/lib/tron/tronTypes.js
CHANGED
|
@@ -13,17 +13,7 @@
|
|
|
13
13
|
var _cleaners = require('cleaners');
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const asTronKeys = _cleaners.asObject({
|
|
23
|
-
tronMnemonic: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
24
|
-
tronKey: _cleaners.asString,
|
|
25
|
-
derivationPath: _cleaners.asOptional.call(void 0, _cleaners.asString)
|
|
26
|
-
}); exports.asTronKeys = asTronKeys
|
|
16
|
+
var _types3 = require('../common/types');
|
|
27
17
|
|
|
28
18
|
const asTronInitOptions = _cleaners.asObject.call(void 0, {
|
|
29
19
|
smartPayPublicAddress: _cleaners.asOptional.call(void 0,
|
|
@@ -423,3 +413,17 @@ const asResource = _cleaners.asValue.call(void 0, 'BANDWIDTH', 'ENERGY')
|
|
|
423
413
|
txid: _cleaners.asString,
|
|
424
414
|
message: _cleaners.asString
|
|
425
415
|
}); exports.asBroadcastResponse = asBroadcastResponse
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
const asSafeTronWalletInfo = _types3.asSafeCommonWalletInfo; exports.asSafeTronWalletInfo = asSafeTronWalletInfo
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
const asTronPrivateKeys = _cleaners.asObject({
|
|
426
|
+
tronMnemonic: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
427
|
+
tronKey: _cleaners.asString,
|
|
428
|
+
derivationPath: _cleaners.asOptional.call(void 0, _cleaners.asString)
|
|
429
|
+
}); exports.asTronPrivateKeys = asTronPrivateKeys
|
package/lib/xrp/xrpEngine.js
CHANGED
|
@@ -24,6 +24,7 @@ var _biggystring = require('biggystring');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
|
|
27
28
|
var _types = require('edge-core-js/types');
|
|
28
29
|
var _xrpl = require('xrpl');
|
|
29
30
|
|
|
@@ -56,6 +57,10 @@ var _pluginError = require('../pluginError');
|
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
59
64
|
var _xrpTypes = require('./xrpTypes');
|
|
60
65
|
var _xrpUtils = require('./xrpUtils');
|
|
61
66
|
|
|
@@ -95,7 +100,10 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
95
100
|
|
|
96
101
|
|
|
97
102
|
|
|
98
|
-
class XrpEngine extends _engine.CurrencyEngine
|
|
103
|
+
class XrpEngine extends _engine.CurrencyEngine
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
{
|
|
99
107
|
|
|
100
108
|
|
|
101
109
|
|
|
@@ -495,6 +503,47 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
495
503
|
this.makeSpendCheck(edgeSpendInfoIn)
|
|
496
504
|
const parentCurrencyCode = this.currencyInfo.currencyCode
|
|
497
505
|
|
|
506
|
+
// Activation Transaction:
|
|
507
|
+
const activateTokenParams = _xrpTypes.asMaybeActivateTokenParams.call(void 0,
|
|
508
|
+
edgeSpendInfo.otherParams
|
|
509
|
+
)
|
|
510
|
+
if (_optionalChain([activateTokenParams, 'optionalAccess', _14 => _14.activateTokenId]) != null) {
|
|
511
|
+
const activateTokenId = activateTokenParams.activateTokenId
|
|
512
|
+
const edgeToken = this.allTokensMap[activateTokenId]
|
|
513
|
+
const { currency, issuer } = _xrpTypes.asXrpNetworkLocation.call(void 0,
|
|
514
|
+
edgeToken.networkLocation
|
|
515
|
+
)
|
|
516
|
+
const networkFee = SET_TRUST_LINE_FEE
|
|
517
|
+
const trustSetTx = await this.tools.rippleApi.autofill({
|
|
518
|
+
TransactionType: 'TrustSet',
|
|
519
|
+
Account: this.walletLocalData.publicKey,
|
|
520
|
+
Fee: networkFee,
|
|
521
|
+
Flags: tfSetNoRipple,
|
|
522
|
+
LimitAmount: {
|
|
523
|
+
currency,
|
|
524
|
+
issuer,
|
|
525
|
+
value: TRUST_LINE_APPROVAL_AMOUNT
|
|
526
|
+
}
|
|
527
|
+
// Sequence: 12
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
return {
|
|
531
|
+
txid: '',
|
|
532
|
+
date: Date.now() / 1000,
|
|
533
|
+
currencyCode: this.currencyInfo.currencyCode,
|
|
534
|
+
blockHeight: 0, // blockHeight,
|
|
535
|
+
metadata: edgeSpendInfo.metadata,
|
|
536
|
+
nativeAmount: `-${networkFee}`,
|
|
537
|
+
networkFee,
|
|
538
|
+
ourReceiveAddresses: [],
|
|
539
|
+
signedTx: '',
|
|
540
|
+
otherParams: {
|
|
541
|
+
trustSetTx
|
|
542
|
+
},
|
|
543
|
+
walletId: this.walletId
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
498
547
|
if (edgeSpendInfo.spendTargets.length !== 1) {
|
|
499
548
|
throw new Error('Error: only one output allowed')
|
|
500
549
|
}
|
|
@@ -541,7 +590,7 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
541
590
|
const uniqueIdentifier =
|
|
542
591
|
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(edgeSpendInfo.spendTargets[0].memo, () => (
|
|
543
592
|
edgeSpendInfo.spendTargets[0].uniqueIdentifier)), () => (
|
|
544
|
-
_optionalChain([edgeSpendInfo, 'access',
|
|
593
|
+
_optionalChain([edgeSpendInfo, 'access', _15 => _15.spendTargets, 'access', _16 => _16[0], 'access', _17 => _17.otherParams, 'optionalAccess', _18 => _18.uniqueIdentifier]))), () => (
|
|
545
594
|
''))
|
|
546
595
|
|
|
547
596
|
if (uniqueIdentifier !== '') {
|
|
@@ -640,9 +689,27 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
640
689
|
return edgeTransaction
|
|
641
690
|
}
|
|
642
691
|
|
|
643
|
-
async signTx(
|
|
692
|
+
async signTx(
|
|
693
|
+
edgeTransaction,
|
|
694
|
+
privateKeys
|
|
695
|
+
) {
|
|
696
|
+
const ripplePrivateKeys = _xrpTypes.asRipplePrivateKeys.call(void 0, privateKeys)
|
|
644
697
|
const otherParams = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
645
698
|
|
|
699
|
+
// Activation Transaction:
|
|
700
|
+
if (otherParams.trustSetTx != null) {
|
|
701
|
+
const trustSetTx = otherParams.trustSetTx
|
|
702
|
+
const privateKey = privateKeys.rippleKey
|
|
703
|
+
const wallet = _xrpl.Wallet.fromSeed(privateKey)
|
|
704
|
+
const { tx_blob: signedTransaction, hash: id } = wallet.sign(trustSetTx)
|
|
705
|
+
this.warn('Activation transaction signed...')
|
|
706
|
+
edgeTransaction.signedTx = signedTransaction
|
|
707
|
+
edgeTransaction.txid = id.toLowerCase()
|
|
708
|
+
edgeTransaction.date = Date.now() / 1000
|
|
709
|
+
this.warn(`signTx\n${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`)
|
|
710
|
+
return edgeTransaction
|
|
711
|
+
}
|
|
712
|
+
|
|
646
713
|
const completeTxJson = {
|
|
647
714
|
...otherParams.preparedTx,
|
|
648
715
|
Sequence: this.nonce,
|
|
@@ -666,7 +733,7 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
666
733
|
}
|
|
667
734
|
|
|
668
735
|
// Do signing
|
|
669
|
-
const privateKey =
|
|
736
|
+
const privateKey = ripplePrivateKeys.rippleKey
|
|
670
737
|
const wallet = _xrpl.Wallet.fromSeed(privateKey)
|
|
671
738
|
const { tx_blob: signedTransaction, hash: id } = wallet.sign(completeTxJson)
|
|
672
739
|
|
|
@@ -708,12 +775,13 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
708
775
|
return edgeTransaction
|
|
709
776
|
}
|
|
710
777
|
|
|
711
|
-
getDisplayPrivateSeed() {
|
|
712
|
-
|
|
778
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
779
|
+
const ripplePrivateKeys = _xrpTypes.asRipplePrivateKeys.call(void 0, privateKeys)
|
|
780
|
+
return ripplePrivateKeys.rippleKey
|
|
713
781
|
}
|
|
714
782
|
|
|
715
783
|
getDisplayPublicSeed() {
|
|
716
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
784
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _19 => _19.walletInfo, 'access', _20 => _20.keys, 'optionalAccess', _21 => _21.publicKey]), () => ( ''))
|
|
717
785
|
}
|
|
718
786
|
|
|
719
787
|
__init2() {this.engineGetActivationAssets = async (
|
|
@@ -741,7 +809,7 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
741
809
|
)
|
|
742
810
|
if (paymentTokenId != null)
|
|
743
811
|
throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`)
|
|
744
|
-
if (_optionalChain([paymentWallet, 'optionalAccess',
|
|
812
|
+
if (_optionalChain([paymentWallet, 'optionalAccess', _22 => _22.id]) !== this.walletId)
|
|
745
813
|
throw new Error('Must pay with same wallet you are activating token with')
|
|
746
814
|
|
|
747
815
|
for (const activateTokenId of activateTokenIds) {
|
|
@@ -765,56 +833,14 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
765
833
|
const { metadata } = options
|
|
766
834
|
const transactions = []
|
|
767
835
|
for (const activateTokenId of activateTokenIds) {
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
edgeToken.networkLocation
|
|
771
|
-
)
|
|
772
|
-
const networkFee = SET_TRUST_LINE_FEE
|
|
773
|
-
const payment = {
|
|
774
|
-
TransactionType: 'TrustSet',
|
|
775
|
-
Account: this.walletLocalData.publicKey,
|
|
776
|
-
Fee: networkFee,
|
|
777
|
-
Flags: tfSetNoRipple,
|
|
778
|
-
LimitAmount: {
|
|
779
|
-
currency,
|
|
780
|
-
issuer,
|
|
781
|
-
value: TRUST_LINE_APPROVAL_AMOUNT
|
|
782
|
-
}
|
|
783
|
-
// Sequence: 12
|
|
784
|
-
}
|
|
785
|
-
const sendTx = await this.tools.rippleApi.autofill(payment)
|
|
786
|
-
const rippleWallet = _xrpl.Wallet.fromSeed(this.walletInfo.keys.rippleKey)
|
|
787
|
-
const { tx_blob: signedTx, hash: txid } = rippleWallet.sign(sendTx)
|
|
788
|
-
const response = await this.tools.rippleApi.submit(signedTx)
|
|
789
|
-
const {
|
|
790
|
-
engine_result_code: resultCode,
|
|
791
|
-
engine_result_message: resultMessage
|
|
792
|
-
} = response.result
|
|
793
|
-
|
|
794
|
-
if (resultCode !== 0) {
|
|
795
|
-
this.warn(
|
|
796
|
-
`FAILURE activateWallet.approve() ${resultCode} ${resultMessage}`
|
|
797
|
-
)
|
|
798
|
-
throw new Error(resultMessage)
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
const otherParams = {
|
|
802
|
-
preparedTx: payment
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
const edgeTransaction = {
|
|
806
|
-
txid: txid.toLowerCase(),
|
|
807
|
-
date: Date.now() / 1000,
|
|
808
|
-
currencyCode: this.currencyInfo.currencyCode,
|
|
809
|
-
blockHeight: 0, // blockHeight,
|
|
836
|
+
const activationTx = await paymentWallet.makeSpend({
|
|
837
|
+
spendTargets: [],
|
|
810
838
|
metadata,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
walletId: this.walletId
|
|
817
|
-
}
|
|
839
|
+
otherParams: { activateTokenId }
|
|
840
|
+
})
|
|
841
|
+
const signedTx = await paymentWallet.signTx(activationTx)
|
|
842
|
+
const edgeTransaction = await paymentWallet.broadcastTx(signedTx)
|
|
843
|
+
|
|
818
844
|
this.warn(
|
|
819
845
|
`SUCCESS activateWallet.approve()\n${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`
|
|
820
846
|
)
|
|
@@ -835,9 +861,10 @@ const SUPPORTED_TRANSACTION_TYPES = {
|
|
|
835
861
|
walletInfo,
|
|
836
862
|
opts
|
|
837
863
|
) {
|
|
838
|
-
const
|
|
864
|
+
const safeWalletInfo = _xrpTypes.asSafeRippleWalletInfo.call(void 0, walletInfo)
|
|
865
|
+
const engine = new XrpEngine(env, tools, safeWalletInfo, opts)
|
|
839
866
|
|
|
840
|
-
await engine.loadEngine(tools,
|
|
867
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
841
868
|
|
|
842
869
|
return engine
|
|
843
870
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
package/lib/xrp/xrpTypes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _cleaners = require('cleaners');
|
|
2
2
|
|
|
3
|
+
var _types = require('../common/types');
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
@@ -14,6 +15,13 @@
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
|
|
18
|
+
|
|
19
|
+
const asMaybeActivateTokenParams = _cleaners.asMaybe.call(void 0,
|
|
20
|
+
_cleaners.asObject.call(void 0, {
|
|
21
|
+
activateTokenId: _cleaners.asString
|
|
22
|
+
})
|
|
23
|
+
); exports.asMaybeActivateTokenParams = asMaybeActivateTokenParams
|
|
24
|
+
|
|
17
25
|
const asXrpWalletOtherData = _cleaners.asObject.call(void 0, {
|
|
18
26
|
recommendedFee: _cleaners.asMaybe.call(void 0, _cleaners.asString, '0') // Floating point value in full XRP value
|
|
19
27
|
}); exports.asXrpWalletOtherData = asXrpWalletOtherData
|
|
@@ -32,3 +40,11 @@
|
|
|
32
40
|
currency: _cleaners.asString,
|
|
33
41
|
issuer: _cleaners.asString
|
|
34
42
|
}); exports.asXrpNetworkLocation = asXrpNetworkLocation
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const asSafeRippleWalletInfo = _types.asSafeCommonWalletInfo; exports.asSafeRippleWalletInfo = asSafeRippleWalletInfo
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const asRipplePrivateKeys = _cleaners.asObject.call(void 0, {
|
|
49
|
+
rippleKey: _cleaners.asString
|
|
50
|
+
}); exports.asRipplePrivateKeys = asRipplePrivateKeys
|