edge-currency-accountbased 2.2.4 → 2.3.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 +4 -0
- package/android/src/main/assets/edge-currency-accountbased/234.chunk.js +35 -0
- package/android/src/main/assets/edge-currency-accountbased/248.chunk.js +35 -0
- package/android/src/main/assets/edge-currency-accountbased/336.chunk.js +9 -0
- package/android/src/main/assets/edge-currency-accountbased/612.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{945.chunk.js → 814.chunk.js} +8 -8
- package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -0
- package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +4 -4
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +10 -10
- package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +12 -12
- package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +5 -5
- package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
- 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 -5
- package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +4 -4
- 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/algorand/AlgorandEngine.js +46 -24
- package/lib/algorand/algorandInfo.js +8 -7
- package/lib/algorand/algorandTestnetInfo.js +8 -7
- package/lib/binance/BinanceEngine.js +19 -17
- package/lib/binance/binanceInfo.js +10 -7
- package/lib/common/types.js +10 -0
- package/lib/common/upgradeMemos.js +52 -0
- package/lib/common/utf8.js +32 -0
- package/lib/common/validateMemos.js +107 -0
- package/lib/eos/EosEngine.js +42 -41
- package/lib/eos/info/eosCommonInfo.js +10 -0
- package/lib/eos/info/eosInfo.js +15 -17
- package/lib/eos/info/telosInfo.js +15 -15
- package/lib/eos/info/waxInfo.js +15 -16
- package/lib/ethereum/EthereumEngine.js +13 -12
- package/lib/ethereum/EthereumNetwork.js +16 -14
- package/lib/ethereum/info/avalancheInfo.js +9 -7
- package/lib/ethereum/info/binancesmartchainInfo.js +9 -7
- package/lib/ethereum/info/celoInfo.js +9 -7
- package/lib/ethereum/info/ethDevInfo.js +9 -7
- package/lib/ethereum/info/ethereumCommonInfo.js +10 -0
- package/lib/ethereum/info/ethereumInfo.js +9 -7
- package/lib/ethereum/info/ethereumclassicInfo.js +9 -7
- package/lib/ethereum/info/ethereumpowInfo.js +9 -7
- package/lib/ethereum/info/fantomInfo.js +9 -7
- package/lib/ethereum/info/goerliInfo.js +9 -7
- package/lib/ethereum/info/kovanInfo.js +9 -7
- package/lib/ethereum/info/optimismInfo.js +9 -7
- package/lib/ethereum/info/polygonInfo.js +9 -7
- package/lib/ethereum/info/pulsechainInfo.js +9 -7
- package/lib/ethereum/info/rinkebyInfo.js +9 -7
- package/lib/ethereum/info/ropstenInfo.js +9 -7
- package/lib/ethereum/info/rskInfo.js +9 -7
- package/lib/ethereum/info/zksyncInfo.js +9 -7
- package/lib/filecoin/FilecoinEngine.js +21 -15
- package/lib/filecoin/filecoinInfo.js +5 -7
- package/lib/fio/FioEngine.js +25 -17
- package/lib/fio/fioInfo.js +8 -6
- package/lib/hedera/HederaEngine.js +22 -18
- package/lib/hedera/hederaInfo.js +11 -8
- package/lib/hedera/hederaTestnetInfo.js +6 -6
- package/lib/polkadot/PolkadotEngine.js +15 -9
- package/lib/polkadot/info/liberlandInfo.js +3 -2
- package/lib/polkadot/info/liberlandTestnetInfo.js +3 -2
- package/lib/polkadot/info/polkadotInfo.js +8 -5
- package/lib/ripple/RippleEngine.js +53 -75
- package/lib/ripple/rippleInfo.js +16 -8
- package/lib/solana/SolanaEngine.js +17 -12
- package/lib/solana/solanaInfo.js +9 -5
- package/lib/stellar/StellarEngine.js +31 -22
- package/lib/stellar/stellarInfo.js +16 -7
- package/lib/tezos/TezosEngine.js +17 -11
- package/lib/tezos/tezosInfo.js +8 -5
- package/lib/tron/TronEngine.js +85 -68
- package/lib/tron/tronInfo.js +8 -7
- package/lib/zcash/ZcashEngine.js +17 -19
- package/lib/zcash/piratechainInfo.js +8 -6
- package/lib/zcash/zcashInfo.js +7 -6
- package/package.json +2 -2
- package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
- package/android/src/main/assets/edge-currency-accountbased/223.chunk.js +0 -9
- package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/689.chunk.js +0 -8
- package/android/src/main/assets/edge-currency-accountbased/826.chunk.js +0 -35
|
@@ -27,6 +27,7 @@ var _biggystring = require('biggystring');
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
var _types = require('edge-core-js/types');
|
|
30
|
+
var _rfc4648 = require('rfc4648');
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
|
|
@@ -43,18 +44,14 @@ var _payment = require('xrpl/dist/npm/models/transactions/payment');
|
|
|
43
44
|
var _CurrencyEngine = require('../common/CurrencyEngine');
|
|
44
45
|
|
|
45
46
|
var _tokenHelpers = require('../common/tokenHelpers');
|
|
47
|
+
var _upgradeMemos = require('../common/upgradeMemos');
|
|
48
|
+
var _utf8 = require('../common/utf8');
|
|
46
49
|
|
|
47
50
|
|
|
48
51
|
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
var _utils = require('../common/utils');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var _pluginError = require('../pluginError');
|
|
58
55
|
var _rippleInfo = require('./rippleInfo');
|
|
59
56
|
|
|
60
57
|
|
|
@@ -166,19 +163,20 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
166
163
|
: this.allTokensMap[fromTokenId]
|
|
167
164
|
|
|
168
165
|
const out = {
|
|
169
|
-
txid: '',
|
|
170
|
-
date: Date.now() / 1000,
|
|
171
|
-
currencyCode,
|
|
172
166
|
blockHeight: 0, // blockHeight,
|
|
167
|
+
currencyCode,
|
|
168
|
+
date: Date.now() / 1000,
|
|
169
|
+
isSend: true,
|
|
170
|
+
memos: [],
|
|
173
171
|
metadata,
|
|
174
172
|
nativeAmount: `-${_biggystring.add.call(void 0, fromNativeAmount, networkFee)}`,
|
|
175
|
-
isSend: true,
|
|
176
173
|
networkFee,
|
|
177
|
-
ourReceiveAddresses: [],
|
|
178
|
-
signedTx: '',
|
|
179
174
|
otherParams: {
|
|
180
175
|
xrpTransaction
|
|
181
176
|
},
|
|
177
|
+
ourReceiveAddresses: [],
|
|
178
|
+
signedTx: '',
|
|
179
|
+
txid: '',
|
|
182
180
|
walletId: this.walletId
|
|
183
181
|
}
|
|
184
182
|
return out
|
|
@@ -337,16 +335,17 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
337
335
|
}
|
|
338
336
|
// Parent currency like XRP
|
|
339
337
|
this.addTransaction(currency, {
|
|
340
|
-
txid: hash.toLowerCase(),
|
|
341
|
-
date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
|
|
342
|
-
currencyCode: currency,
|
|
343
338
|
blockHeight: _nullishCoalesce(tx.ledger_index, () => ( -1)),
|
|
344
|
-
|
|
339
|
+
currencyCode: currency,
|
|
340
|
+
date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
|
|
345
341
|
isSend,
|
|
342
|
+
memos: [],
|
|
343
|
+
nativeAmount,
|
|
346
344
|
networkFee,
|
|
345
|
+
otherParams: {},
|
|
347
346
|
ourReceiveAddresses,
|
|
348
347
|
signedTx: '',
|
|
349
|
-
|
|
348
|
+
txid: hash.toLowerCase(),
|
|
350
349
|
walletId: this.walletId
|
|
351
350
|
})
|
|
352
351
|
} else {
|
|
@@ -372,16 +371,17 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
372
371
|
}
|
|
373
372
|
|
|
374
373
|
this.addTransaction(currencyCode, {
|
|
375
|
-
txid: hash.toLowerCase(),
|
|
376
|
-
date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
|
|
377
|
-
currencyCode,
|
|
378
374
|
blockHeight: _nullishCoalesce(tx.ledger_index, () => ( -1)),
|
|
379
|
-
|
|
375
|
+
currencyCode,
|
|
376
|
+
date: _xrpl.rippleTimeToUnixTime.call(void 0, date) / 1000, // Returned date is in "ripple time" which is unix time if it had started on Jan 1 2000
|
|
380
377
|
isSend,
|
|
378
|
+
memos: [],
|
|
379
|
+
nativeAmount,
|
|
381
380
|
networkFee: '0',
|
|
381
|
+
otherParams: {},
|
|
382
382
|
ourReceiveAddresses,
|
|
383
383
|
signedTx: '',
|
|
384
|
-
|
|
384
|
+
txid: hash.toLowerCase(),
|
|
385
385
|
walletId: this.walletId
|
|
386
386
|
})
|
|
387
387
|
}
|
|
@@ -583,6 +583,7 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
async getMaxSpendable(spendInfo) {
|
|
586
|
+
spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
|
|
586
587
|
const { currencyCode } = spendInfo
|
|
587
588
|
let spendableBalance = this.getBalance({
|
|
588
589
|
currencyCode
|
|
@@ -599,8 +600,11 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
599
600
|
}
|
|
600
601
|
|
|
601
602
|
async makeSpend(edgeSpendInfoIn) {
|
|
603
|
+
edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
|
|
602
604
|
const { edgeSpendInfo, currencyCode, nativeBalance } =
|
|
603
605
|
this.makeSpendCheck(edgeSpendInfoIn)
|
|
606
|
+
const { memos = [] } = edgeSpendInfo
|
|
607
|
+
|
|
604
608
|
const parentCurrencyCode = this.currencyInfo.currencyCode
|
|
605
609
|
|
|
606
610
|
// Activation Transaction:
|
|
@@ -628,19 +632,20 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
628
632
|
})
|
|
629
633
|
|
|
630
634
|
return {
|
|
631
|
-
txid: '',
|
|
632
|
-
date: Date.now() / 1000,
|
|
633
|
-
currencyCode: this.currencyInfo.currencyCode,
|
|
634
635
|
blockHeight: 0, // blockHeight,
|
|
636
|
+
currencyCode: this.currencyInfo.currencyCode,
|
|
637
|
+
date: Date.now() / 1000,
|
|
638
|
+
isSend: true,
|
|
639
|
+
memos,
|
|
635
640
|
metadata: edgeSpendInfo.metadata,
|
|
636
641
|
nativeAmount: `-${networkFee}`,
|
|
637
|
-
isSend: true,
|
|
638
642
|
networkFee,
|
|
639
|
-
ourReceiveAddresses: [],
|
|
640
|
-
signedTx: '',
|
|
641
643
|
otherParams: {
|
|
642
644
|
xrpTransaction
|
|
643
645
|
},
|
|
646
|
+
ourReceiveAddresses: [],
|
|
647
|
+
signedTx: '',
|
|
648
|
+
txid: '',
|
|
644
649
|
walletId: this.walletId
|
|
645
650
|
}
|
|
646
651
|
}
|
|
@@ -688,44 +693,6 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
688
693
|
}
|
|
689
694
|
}
|
|
690
695
|
|
|
691
|
-
const uniqueIdentifier =
|
|
692
|
-
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(edgeSpendInfo.spendTargets[0].memo, () => (
|
|
693
|
-
edgeSpendInfo.spendTargets[0].uniqueIdentifier)), () => (
|
|
694
|
-
_optionalChain([edgeSpendInfo, 'access', _18 => _18.spendTargets, 'access', _19 => _19[0], 'access', _20 => _20.otherParams, 'optionalAccess', _21 => _21.uniqueIdentifier]))), () => (
|
|
695
|
-
''))
|
|
696
|
-
|
|
697
|
-
if (uniqueIdentifier !== '') {
|
|
698
|
-
// Destination Tag Checks
|
|
699
|
-
const { memoMaxLength = Infinity, memoMaxValue } = this.currencyInfo
|
|
700
|
-
|
|
701
|
-
if (Number.isNaN(parseInt(uniqueIdentifier))) {
|
|
702
|
-
throw new (0, _pluginError.PluginError)(
|
|
703
|
-
'Please enter a valid Destination Tag',
|
|
704
|
-
_pluginError.pluginErrorName.XRP_ERROR,
|
|
705
|
-
_pluginError.pluginErrorCodes[0],
|
|
706
|
-
_pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_FORMAT
|
|
707
|
-
)
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
if (uniqueIdentifier.length > memoMaxLength) {
|
|
711
|
-
throw new (0, _pluginError.PluginError)(
|
|
712
|
-
`Destination Tag must be ${memoMaxLength} characters or less`,
|
|
713
|
-
_pluginError.pluginErrorName.XRP_ERROR,
|
|
714
|
-
_pluginError.pluginErrorCodes[0],
|
|
715
|
-
_pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_EXCEEDS_LENGTH
|
|
716
|
-
)
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
if (memoMaxValue != null && _biggystring.gt.call(void 0, uniqueIdentifier, memoMaxValue)) {
|
|
720
|
-
throw new (0, _pluginError.PluginError)(
|
|
721
|
-
'XRP Destination Tag is above its maximum limit',
|
|
722
|
-
_pluginError.pluginErrorName.XRP_ERROR,
|
|
723
|
-
_pluginError.pluginErrorCodes[0],
|
|
724
|
-
_pluginError.pluginErrorLabels.UNIQUE_IDENTIFIER_EXCEEDS_LIMIT
|
|
725
|
-
)
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
696
|
let payment
|
|
730
697
|
if (currencyCode === parentCurrencyCode) {
|
|
731
698
|
payment = {
|
|
@@ -765,8 +732,18 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
765
732
|
nativeAmount = `-${nativeAmount}`
|
|
766
733
|
}
|
|
767
734
|
|
|
768
|
-
|
|
769
|
-
|
|
735
|
+
for (const memo of memos) {
|
|
736
|
+
if (memo.type === 'number') {
|
|
737
|
+
payment.DestinationTag = parseInt(memos[0].value)
|
|
738
|
+
} else if (memo.type === 'text') {
|
|
739
|
+
if (payment.Memos == null) payment.Memos = []
|
|
740
|
+
payment.Memos.push({
|
|
741
|
+
Memo: {
|
|
742
|
+
MemoFormat: _rfc4648.base16.stringify(_utf8.utf8.parse('text/plain')),
|
|
743
|
+
MemoData: _rfc4648.base16.stringify(_utf8.utf8.parse(memo.value))
|
|
744
|
+
}
|
|
745
|
+
})
|
|
746
|
+
}
|
|
770
747
|
}
|
|
771
748
|
|
|
772
749
|
const otherParams = {
|
|
@@ -774,17 +751,18 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
774
751
|
}
|
|
775
752
|
|
|
776
753
|
const edgeTransaction = {
|
|
777
|
-
txid: '', // txid
|
|
778
|
-
date: 0, // date
|
|
779
|
-
currencyCode, // currencyCode
|
|
780
754
|
blockHeight: 0, // blockHeight
|
|
781
|
-
|
|
755
|
+
currencyCode, // currencyCode
|
|
756
|
+
date: 0, // date
|
|
782
757
|
isSend: true,
|
|
758
|
+
memos: [],
|
|
759
|
+
nativeAmount, // nativeAmount
|
|
783
760
|
networkFee,
|
|
784
|
-
|
|
761
|
+
otherParams,
|
|
785
762
|
ourReceiveAddresses: [], // ourReceiveAddresses
|
|
763
|
+
parentNetworkFee,
|
|
786
764
|
signedTx: '', // signedTx
|
|
787
|
-
|
|
765
|
+
txid: '', // txid
|
|
788
766
|
walletId: this.walletId
|
|
789
767
|
}
|
|
790
768
|
|
|
@@ -904,7 +882,7 @@ const SET_TRUST_LINE_FEE = '12'
|
|
|
904
882
|
)
|
|
905
883
|
if (paymentTokenId != null)
|
|
906
884
|
throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`)
|
|
907
|
-
if (_optionalChain([paymentWallet, 'optionalAccess',
|
|
885
|
+
if (_optionalChain([paymentWallet, 'optionalAccess', _18 => _18.id]) !== this.walletId)
|
|
908
886
|
throw new Error('Must pay with same wallet you are activating token with')
|
|
909
887
|
|
|
910
888
|
for (const activateTokenId of activateTokenIds) {
|
package/lib/ripple/rippleInfo.js
CHANGED
|
@@ -15,29 +15,37 @@ const networkInfo = {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const currencyInfo = {
|
|
18
|
-
// Basic currency information:
|
|
19
18
|
currencyCode: 'XRP',
|
|
20
19
|
displayName: 'XRP',
|
|
21
20
|
pluginId: 'ripple',
|
|
22
21
|
walletType: 'wallet:ripple',
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
memoMaxLength: 10,
|
|
27
|
-
memoMaxValue: '4294967295',
|
|
28
|
-
|
|
23
|
+
// Explorers:
|
|
29
24
|
addressExplorer: 'https://xrpscan.com/account/%s',
|
|
30
25
|
transactionExplorer: 'https://xrpscan.com/tx/%s',
|
|
31
26
|
|
|
32
27
|
denominations: [
|
|
33
|
-
// An array of Objects of the possible denominations for this currency
|
|
34
28
|
{
|
|
35
29
|
name: 'XRP',
|
|
36
30
|
multiplier: '1000000',
|
|
37
31
|
symbol: 'X'
|
|
38
32
|
}
|
|
39
33
|
],
|
|
40
|
-
|
|
34
|
+
|
|
35
|
+
memoOptions: [
|
|
36
|
+
// https://xrpl.org/payment.html#payment-fields
|
|
37
|
+
{ type: 'number', memoName: 'destination tag', maxValue: '4294967295' },
|
|
38
|
+
// https://xrpl.org/transaction-common-fields.html#memos-field
|
|
39
|
+
{ type: 'text', memoName: 'memo', maxLength: 990 }
|
|
40
|
+
],
|
|
41
|
+
multipleMemos: true,
|
|
42
|
+
|
|
43
|
+
// Deprecated:
|
|
44
|
+
defaultSettings: {},
|
|
45
|
+
memoMaxLength: 10,
|
|
46
|
+
memoMaxValue: '4294967295',
|
|
47
|
+
memoType: 'number',
|
|
48
|
+
metaTokens: []
|
|
41
49
|
}; exports.currencyInfo = currencyInfo
|
|
42
50
|
|
|
43
51
|
const builtinTokens = {
|
|
@@ -16,6 +16,8 @@ var _rfc4648 = require('rfc4648');
|
|
|
16
16
|
|
|
17
17
|
var _CurrencyEngine = require('../common/CurrencyEngine');
|
|
18
18
|
|
|
19
|
+
var _upgradeMemos = require('../common/upgradeMemos');
|
|
20
|
+
var _utf8 = require('../common/utf8');
|
|
19
21
|
|
|
20
22
|
|
|
21
23
|
|
|
@@ -176,15 +178,16 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
176
178
|
ourReceiveAddresses.push(this.base58PublicKey)
|
|
177
179
|
}
|
|
178
180
|
const edgeTransaction = {
|
|
179
|
-
txid: tx.transaction.signatures[0],
|
|
180
|
-
date: timestamp,
|
|
181
|
-
currencyCode: this.chainCode,
|
|
182
181
|
blockHeight: tx.slot,
|
|
183
|
-
|
|
182
|
+
currencyCode: this.chainCode,
|
|
183
|
+
date: timestamp,
|
|
184
184
|
isSend: amount.toString().startsWith('-'),
|
|
185
|
+
memos: [],
|
|
186
|
+
nativeAmount: amount.toString(),
|
|
185
187
|
networkFee: fee.toString(),
|
|
186
188
|
ourReceiveAddresses,
|
|
187
189
|
signedTx: '',
|
|
190
|
+
txid: tx.transaction.signatures[0],
|
|
188
191
|
walletId: this.walletId
|
|
189
192
|
}
|
|
190
193
|
this.addTransaction(this.chainCode, edgeTransaction)
|
|
@@ -314,7 +317,9 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
async makeSpend(edgeSpendInfoIn) {
|
|
320
|
+
edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
|
|
317
321
|
const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
|
|
322
|
+
const { memos = [] } = edgeSpendInfo
|
|
318
323
|
|
|
319
324
|
if (edgeSpendInfo.spendTargets.length !== 1) {
|
|
320
325
|
throw new Error('Error: only one output allowed')
|
|
@@ -348,8 +353,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
348
353
|
})
|
|
349
354
|
)
|
|
350
355
|
|
|
351
|
-
|
|
352
|
-
if (memo != null && memo !== '') {
|
|
356
|
+
if (_optionalChain([memos, 'access', _ => _[0], 'optionalAccess', _2 => _2.type]) === 'text') {
|
|
353
357
|
const memoOpts = new TransactionInstruction({
|
|
354
358
|
keys: [
|
|
355
359
|
{
|
|
@@ -359,7 +363,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
359
363
|
}
|
|
360
364
|
],
|
|
361
365
|
programId: new PublicKey(this.networkInfo.memoPublicKey),
|
|
362
|
-
data: Buffer.from(
|
|
366
|
+
data: Buffer.from(_utf8.utf8.parse(memos[0].value))
|
|
363
367
|
})
|
|
364
368
|
solTx.add(memoOpts)
|
|
365
369
|
}
|
|
@@ -374,16 +378,17 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
374
378
|
// Create the unsigned EdgeTransaction
|
|
375
379
|
|
|
376
380
|
const edgeTransaction = {
|
|
377
|
-
txid: '',
|
|
378
|
-
date: 0,
|
|
379
|
-
currencyCode,
|
|
380
381
|
blockHeight: 0,
|
|
381
|
-
|
|
382
|
+
currencyCode,
|
|
383
|
+
date: 0,
|
|
382
384
|
isSend: true,
|
|
385
|
+
memos,
|
|
386
|
+
nativeAmount: _biggystring.mul.call(void 0, totalTxAmount, '-1'),
|
|
383
387
|
networkFee: nativeNetworkFee,
|
|
388
|
+
otherParams,
|
|
384
389
|
ourReceiveAddresses: [],
|
|
385
390
|
signedTx: '',
|
|
386
|
-
|
|
391
|
+
txid: '',
|
|
387
392
|
walletId: this.walletId
|
|
388
393
|
}
|
|
389
394
|
|
package/lib/solana/solanaInfo.js
CHANGED
|
@@ -17,26 +17,30 @@ const networkInfo = {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const currencyInfo = {
|
|
20
|
-
// Basic currency information:
|
|
21
20
|
currencyCode: 'SOL',
|
|
22
21
|
displayName: 'Solana',
|
|
23
22
|
pluginId: 'solana',
|
|
24
23
|
walletType: 'wallet:solana',
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Explorers:
|
|
28
26
|
addressExplorer: 'https://explorer.solana.com/address/%s',
|
|
29
27
|
transactionExplorer: 'https://explorer.solana.com/tx/%s',
|
|
30
28
|
|
|
31
29
|
denominations: [
|
|
32
|
-
// An array of Objects of the possible denominations for this currency
|
|
33
30
|
{
|
|
34
31
|
name: 'SOL',
|
|
35
32
|
multiplier: '1000000000',
|
|
36
33
|
symbol: '◎'
|
|
37
34
|
}
|
|
38
35
|
],
|
|
39
|
-
|
|
36
|
+
|
|
37
|
+
// https://spl.solana.com/memo
|
|
38
|
+
memoOptions: [{ type: 'text', memoName: 'memo', maxLength: 32 }],
|
|
39
|
+
|
|
40
|
+
// Deprecated:
|
|
41
|
+
defaultSettings: {},
|
|
42
|
+
memoType: 'text',
|
|
43
|
+
metaTokens: []
|
|
40
44
|
}; exports.currencyInfo = currencyInfo
|
|
41
45
|
|
|
42
46
|
const solana = _innerPlugin.makeOuterPlugin({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _biggystring = require('biggystring');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -14,6 +14,7 @@ var _stellarsdk = require('stellar-sdk'); var _stellarsdk2 = _interopRequireDefa
|
|
|
14
14
|
|
|
15
15
|
var _CurrencyEngine = require('../common/CurrencyEngine');
|
|
16
16
|
|
|
17
|
+
var _upgradeMemos = require('../common/upgradeMemos');
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
@@ -249,20 +250,21 @@ const BASE_FEE = 100 // Stroops
|
|
|
249
250
|
nativeAmount = '-' + nativeAmount
|
|
250
251
|
}
|
|
251
252
|
const edgeTransaction = {
|
|
252
|
-
txid: tx.transaction_hash,
|
|
253
|
-
date,
|
|
254
|
-
currencyCode,
|
|
255
253
|
blockHeight: rawTx.ledger_attr > 0 ? rawTx.ledger_attr : 0, // API shows no ledger number ??
|
|
256
|
-
|
|
254
|
+
currencyCode,
|
|
255
|
+
date,
|
|
257
256
|
isSend: nativeAmount.startsWith('-'),
|
|
257
|
+
memos: [],
|
|
258
|
+
nativeAmount,
|
|
258
259
|
networkFee,
|
|
259
|
-
parentNetworkFee: '0',
|
|
260
|
-
ourReceiveAddresses,
|
|
261
|
-
signedTx: '',
|
|
262
260
|
otherParams: {
|
|
263
261
|
fromAddress,
|
|
264
262
|
toAddress
|
|
265
263
|
},
|
|
264
|
+
ourReceiveAddresses,
|
|
265
|
+
parentNetworkFee: '0',
|
|
266
|
+
signedTx: '',
|
|
267
|
+
txid: tx.transaction_hash,
|
|
266
268
|
walletId: this.walletId
|
|
267
269
|
}
|
|
268
270
|
|
|
@@ -469,8 +471,10 @@ const BASE_FEE = 100 // Stroops
|
|
|
469
471
|
}
|
|
470
472
|
|
|
471
473
|
async makeSpend(edgeSpendInfoIn) {
|
|
474
|
+
edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
|
|
472
475
|
const { edgeSpendInfo, currencyCode, nativeBalance, denom } =
|
|
473
476
|
this.makeSpendCheck(edgeSpendInfoIn)
|
|
477
|
+
const { memos = [] } = edgeSpendInfo
|
|
474
478
|
|
|
475
479
|
if (edgeSpendInfo.spendTargets.length !== 1) {
|
|
476
480
|
throw new Error('Error: only one output allowed')
|
|
@@ -507,11 +511,6 @@ const BASE_FEE = 100 // Stroops
|
|
|
507
511
|
this.walletLocalData.publicKey,
|
|
508
512
|
this.otherData.accountSequence
|
|
509
513
|
)
|
|
510
|
-
const spendTarget0 = edgeSpendInfo.spendTargets[0]
|
|
511
|
-
const memoId =
|
|
512
|
-
_nullishCoalesce(_nullishCoalesce(spendTarget0.memo, () => (
|
|
513
|
-
spendTarget0.uniqueIdentifier)), () => (
|
|
514
|
-
_optionalChain([spendTarget0, 'access', _5 => _5.otherParams, 'optionalAccess', _6 => _6.uniqueIdentifier])))
|
|
515
514
|
|
|
516
515
|
const feeSetting =
|
|
517
516
|
edgeSpendInfo.networkFeeOption !== undefined &&
|
|
@@ -539,9 +538,18 @@ const BASE_FEE = 100 // Stroops
|
|
|
539
538
|
})
|
|
540
539
|
)
|
|
541
540
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
541
|
+
for (const memo of memos) {
|
|
542
|
+
switch (memo.type) {
|
|
543
|
+
case 'hex':
|
|
544
|
+
txBuilder = txBuilder.addMemo(_stellarsdk2.default.Memo.hash(memo.value))
|
|
545
|
+
break
|
|
546
|
+
case 'number':
|
|
547
|
+
txBuilder = txBuilder.addMemo(_stellarsdk2.default.Memo.id(memo.value))
|
|
548
|
+
break
|
|
549
|
+
case 'text':
|
|
550
|
+
txBuilder = txBuilder.addMemo(_stellarsdk2.default.Memo.text(memo.value))
|
|
551
|
+
break
|
|
552
|
+
}
|
|
545
553
|
}
|
|
546
554
|
const transaction = txBuilder.build()
|
|
547
555
|
|
|
@@ -555,20 +563,21 @@ const BASE_FEE = 100 // Stroops
|
|
|
555
563
|
nativeAmount = `-${nativeAmount}`
|
|
556
564
|
const idInternal = this.pendingTransactionsIndex
|
|
557
565
|
const edgeTransaction = {
|
|
558
|
-
txid: '', // txid
|
|
559
|
-
date: 0, // date
|
|
560
|
-
currencyCode, // currencyCode
|
|
561
566
|
blockHeight: 0, // blockHeight
|
|
562
|
-
|
|
567
|
+
currencyCode, // currencyCode
|
|
568
|
+
date: 0, // date
|
|
563
569
|
isSend: nativeAmount.startsWith('-'),
|
|
570
|
+
memos,
|
|
571
|
+
nativeAmount, // nativeAmount
|
|
564
572
|
networkFee, // networkFee
|
|
565
|
-
ourReceiveAddresses: [], // ourReceiveAddresses
|
|
566
|
-
signedTx: '', // signedTx
|
|
567
573
|
otherParams: {
|
|
568
574
|
idInternal,
|
|
569
575
|
fromAddress: this.walletLocalData.publicKey,
|
|
570
576
|
toAddress: publicAddress
|
|
571
577
|
},
|
|
578
|
+
ourReceiveAddresses: [], // ourReceiveAddresses
|
|
579
|
+
signedTx: '', // signedTx
|
|
580
|
+
txid: '', // txid
|
|
572
581
|
walletId: this.walletId
|
|
573
582
|
}
|
|
574
583
|
this.pendingTransactionsMap[idInternal] = transaction
|
|
@@ -10,28 +10,37 @@ const networkInfo = {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const currencyInfo = {
|
|
13
|
-
// Basic currency information:
|
|
14
13
|
currencyCode: 'XLM',
|
|
15
14
|
displayName: 'Stellar',
|
|
16
15
|
pluginId: 'stellar',
|
|
17
16
|
walletType: 'wallet:stellar',
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
memoMaxLength: 19,
|
|
22
|
-
|
|
18
|
+
// Explorers:
|
|
23
19
|
addressExplorer: 'https://stellarchain.io/address/%s',
|
|
24
20
|
transactionExplorer: 'https://stellarchain.io/tx/%s',
|
|
25
21
|
|
|
26
22
|
denominations: [
|
|
27
|
-
// An array of Objects of the possible denominations for this currency
|
|
28
23
|
{
|
|
29
24
|
name: 'XLM',
|
|
30
25
|
multiplier: '10000000',
|
|
31
26
|
symbol: '*'
|
|
32
27
|
}
|
|
33
28
|
],
|
|
34
|
-
|
|
29
|
+
|
|
30
|
+
// https://developers.stellar.org/docs/encyclopedia/memos
|
|
31
|
+
memoOptions: [
|
|
32
|
+
{ type: 'text', maxLength: 28 },
|
|
33
|
+
{ type: 'number', maxValue: '18446744073709551615' },
|
|
34
|
+
{ type: 'hex', maxBytes: 32, minBytes: 32 }
|
|
35
|
+
// We also support a transaction ID for returned funds
|
|
36
|
+
],
|
|
37
|
+
multipleMemos: true,
|
|
38
|
+
|
|
39
|
+
// Deprecated:
|
|
40
|
+
defaultSettings: {},
|
|
41
|
+
memoMaxLength: 19,
|
|
42
|
+
memoType: 'text',
|
|
43
|
+
metaTokens: []
|
|
35
44
|
}; exports.currencyInfo = currencyInfo
|
|
36
45
|
|
|
37
46
|
const stellar = _innerPlugin.makeOuterPlugin({
|
package/lib/tezos/TezosEngine.js
CHANGED
|
@@ -14,6 +14,7 @@ var _eztzjs = require('eztz.js');
|
|
|
14
14
|
|
|
15
15
|
var _CurrencyEngine = require('../common/CurrencyEngine');
|
|
16
16
|
|
|
17
|
+
var _upgradeMemos = require('../common/upgradeMemos');
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
|
|
@@ -273,16 +274,17 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
273
274
|
nativeAmount = '-' + _biggystring.add.call(void 0, nativeAmount, networkFee)
|
|
274
275
|
}
|
|
275
276
|
const edgeTransaction = {
|
|
276
|
-
txid: tx.hash,
|
|
277
|
-
date,
|
|
278
|
-
currencyCode,
|
|
279
277
|
blockHeight,
|
|
280
|
-
|
|
278
|
+
currencyCode,
|
|
279
|
+
date,
|
|
281
280
|
isSend: nativeAmount.startsWith('-'),
|
|
281
|
+
memos: [],
|
|
282
|
+
nativeAmount,
|
|
282
283
|
networkFee,
|
|
284
|
+
otherParams: {},
|
|
283
285
|
ourReceiveAddresses,
|
|
284
286
|
signedTx: '',
|
|
285
|
-
|
|
287
|
+
txid: tx.hash,
|
|
286
288
|
walletId: this.walletId
|
|
287
289
|
}
|
|
288
290
|
if (!failedOperation) {
|
|
@@ -397,6 +399,7 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
397
399
|
}
|
|
398
400
|
|
|
399
401
|
async makeSpend(edgeSpendInfoIn) {
|
|
402
|
+
edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
|
|
400
403
|
return await makeSpendMutex(
|
|
401
404
|
async () => await this.makeSpendInner(edgeSpendInfoIn)
|
|
402
405
|
)
|
|
@@ -407,6 +410,8 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
407
410
|
) {
|
|
408
411
|
const { edgeSpendInfo, currencyCode, nativeBalance, denom } =
|
|
409
412
|
this.makeSpendCheck(edgeSpendInfoIn)
|
|
413
|
+
const { memos = [] } = edgeSpendInfo
|
|
414
|
+
|
|
410
415
|
if (edgeSpendInfo.spendTargets.length !== 1) {
|
|
411
416
|
throw new Error('Error: only one output allowed')
|
|
412
417
|
}
|
|
@@ -464,21 +469,22 @@ const PRIMARY_CURRENCY = _tezosInfo.currencyInfo.currencyCode
|
|
|
464
469
|
nativeAmount = '-' + nativeAmount
|
|
465
470
|
|
|
466
471
|
const edgeTransaction = {
|
|
467
|
-
txid: '',
|
|
468
|
-
date: 0,
|
|
469
|
-
currencyCode,
|
|
470
472
|
blockHeight: 0,
|
|
471
|
-
|
|
473
|
+
currencyCode,
|
|
474
|
+
date: 0,
|
|
472
475
|
isSend: nativeAmount.startsWith('-'),
|
|
476
|
+
memos,
|
|
477
|
+
nativeAmount,
|
|
473
478
|
networkFee,
|
|
474
|
-
ourReceiveAddresses: [],
|
|
475
|
-
signedTx: '',
|
|
476
479
|
otherParams: {
|
|
477
480
|
idInternal: 0,
|
|
478
481
|
fromAddress: this.walletLocalData.publicKey,
|
|
479
482
|
toAddress: publicAddress,
|
|
480
483
|
fullOp: ops
|
|
481
484
|
},
|
|
485
|
+
ourReceiveAddresses: [],
|
|
486
|
+
signedTx: '',
|
|
487
|
+
txid: '',
|
|
482
488
|
walletId: this.walletId
|
|
483
489
|
}
|
|
484
490
|
return edgeTransaction
|
package/lib/tezos/tezosInfo.js
CHANGED
|
@@ -36,26 +36,29 @@ const networkInfo = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const currencyInfo = {
|
|
39
|
-
// Basic currency information:
|
|
40
39
|
currencyCode: 'XTZ',
|
|
41
40
|
displayName: 'Tezos',
|
|
42
41
|
pluginId: 'tezos',
|
|
43
42
|
walletType: 'wallet:tezos',
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
// Explorers:
|
|
47
45
|
addressExplorer: 'https://tzstats.com/%s',
|
|
48
46
|
transactionExplorer: 'https://tzstats.com/%s',
|
|
49
47
|
|
|
50
48
|
denominations: [
|
|
51
|
-
// An array of Objects of the possible denominations for this currency
|
|
52
49
|
{
|
|
53
50
|
name: 'XTZ',
|
|
54
51
|
multiplier: '1000000',
|
|
55
52
|
symbol: 't'
|
|
56
53
|
}
|
|
57
54
|
],
|
|
58
|
-
|
|
55
|
+
|
|
56
|
+
// No memo support:
|
|
57
|
+
memoOptions: [],
|
|
58
|
+
|
|
59
|
+
// Deprecated:
|
|
60
|
+
defaultSettings: {},
|
|
61
|
+
metaTokens: []
|
|
59
62
|
}; exports.currencyInfo = currencyInfo
|
|
60
63
|
|
|
61
64
|
const tezos = _innerPlugin.makeOuterPlugin({
|