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
package/lib/fio/fioTypes.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _cleaners = require('cleaners');
|
|
11
|
+
|
|
12
|
+
var _types = require('../common/types');
|
|
13
|
+
var _fioConst = require('./fioConst');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const fioOtherMethodNames = [
|
|
2
17
|
'getConnectedPublicAddress',
|
|
3
18
|
'isFioAddressValid',
|
|
4
19
|
'validateAccount',
|
|
@@ -12,4 +27,168 @@
|
|
|
12
27
|
|
|
13
28
|
|
|
14
29
|
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
15
51
|
; exports.fioOtherMethodNames = fioOtherMethodNames
|
|
52
|
+
|
|
53
|
+
const asFioAction = _cleaners.asObject.call(void 0, {
|
|
54
|
+
name: _cleaners.asString,
|
|
55
|
+
params: _cleaners.asObject.call(void 0, _cleaners.asUnknown)
|
|
56
|
+
}); exports.asFioAction = asFioAction
|
|
57
|
+
|
|
58
|
+
const asFioTxParams = _cleaners.asObject.call(void 0, {
|
|
59
|
+
action: _cleaners.asString,
|
|
60
|
+
account: _cleaners.asString,
|
|
61
|
+
data: _cleaners.asObject.call(void 0, _cleaners.asUnknown)
|
|
62
|
+
}); exports.asFioTxParams = asFioTxParams
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const asFioSignedTx = _cleaners.asObject.call(void 0, {
|
|
67
|
+
compression: _cleaners.asNumber,
|
|
68
|
+
packed_context_free_data: _cleaners.asString,
|
|
69
|
+
packed_trx: _cleaners.asString,
|
|
70
|
+
signatures: _cleaners.asArray.call(void 0, _cleaners.asString)
|
|
71
|
+
}); exports.asFioSignedTx = asFioSignedTx
|
|
72
|
+
|
|
73
|
+
const asFioFee = _cleaners.asObject.call(void 0, { fee: _cleaners.asNumber }); exports.asFioFee = asFioFee
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
const asFioAddressParam = _cleaners.asObject.call(void 0, {
|
|
82
|
+
fioAddress: _cleaners.asString
|
|
83
|
+
}); exports.asFioAddressParam = asFioAddressParam
|
|
84
|
+
|
|
85
|
+
const asFioDomainParam = _cleaners.asObject.call(void 0, {
|
|
86
|
+
fioDomain: _cleaners.asString
|
|
87
|
+
}); exports.asFioDomainParam = asFioDomainParam
|
|
88
|
+
|
|
89
|
+
const asFioTransferDomainParams = _cleaners.asObject.call(void 0, {
|
|
90
|
+
fioDomain: _cleaners.asString
|
|
91
|
+
}); exports.asFioTransferDomainParams = asFioTransferDomainParams
|
|
92
|
+
|
|
93
|
+
const asFioConnectAddressesParams = _cleaners.asObject.call(void 0, {
|
|
94
|
+
fioAddress: _cleaners.asString,
|
|
95
|
+
publicAddresses: _cleaners.asArray.call(void 0,
|
|
96
|
+
_cleaners.asObject.call(void 0, {
|
|
97
|
+
token_code: _cleaners.asString,
|
|
98
|
+
chain_code: _cleaners.asString,
|
|
99
|
+
public_address: _cleaners.asString
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
}); exports.asFioConnectAddressesParams = asFioConnectAddressesParams
|
|
103
|
+
|
|
104
|
+
const asFioAddBundledTransactions = _cleaners.asObject.call(void 0, {
|
|
105
|
+
fioAddress: _cleaners.asString,
|
|
106
|
+
bundleSets: _cleaners.asNumber
|
|
107
|
+
}); exports.asFioAddBundledTransactions = asFioAddBundledTransactions
|
|
108
|
+
|
|
109
|
+
const asSetFioDomainVisibility = _cleaners.asObject.call(void 0, {
|
|
110
|
+
fioDomain: _cleaners.asString,
|
|
111
|
+
isPublic: _cleaners.asBoolean
|
|
112
|
+
}); exports.asSetFioDomainVisibility = asSetFioDomainVisibility
|
|
113
|
+
|
|
114
|
+
const asRejectFundsRequest = _cleaners.asObject.call(void 0, {
|
|
115
|
+
payerFioAddress: _cleaners.asString,
|
|
116
|
+
fioRequestId: _cleaners.asNumber
|
|
117
|
+
}); exports.asRejectFundsRequest = asRejectFundsRequest
|
|
118
|
+
|
|
119
|
+
const asCancelFundsRequest = _cleaners.asObject.call(void 0, {
|
|
120
|
+
fioAddress: _cleaners.asString,
|
|
121
|
+
fioRequestId: _cleaners.asNumber
|
|
122
|
+
}); exports.asCancelFundsRequest = asCancelFundsRequest
|
|
123
|
+
|
|
124
|
+
const asFioRecordObtData = _cleaners.asObject.call(void 0, {
|
|
125
|
+
payerFioAddress: _cleaners.asString,
|
|
126
|
+
payeeFioAddress: _cleaners.asString,
|
|
127
|
+
payerPublicAddress: _cleaners.asString,
|
|
128
|
+
payeePublicAddress: _cleaners.asString,
|
|
129
|
+
amount: _cleaners.asString,
|
|
130
|
+
tokenCode: _cleaners.asString,
|
|
131
|
+
chainCode: _cleaners.asString,
|
|
132
|
+
obtId: _cleaners.asString,
|
|
133
|
+
memo: _cleaners.asString,
|
|
134
|
+
status: _cleaners.asOptional.call(void 0,
|
|
135
|
+
_cleaners.asValue.call(void 0, 'cancelled', 'rejected', 'requested', 'sent_to_blockchain')
|
|
136
|
+
),
|
|
137
|
+
fioRequestId: _cleaners.asOptional.call(void 0, _cleaners.asNumber)
|
|
138
|
+
}); exports.asFioRecordObtData = asFioRecordObtData
|
|
139
|
+
|
|
140
|
+
const asFioRequestFundsParams = _cleaners.asObject.call(void 0, {
|
|
141
|
+
payerFioAddress: _cleaners.asString,
|
|
142
|
+
payerFioPublicKey: _cleaners.asString,
|
|
143
|
+
payeeFioAddress: _cleaners.asString,
|
|
144
|
+
payeeTokenPublicAddress: _cleaners.asString,
|
|
145
|
+
amount: _cleaners.asString,
|
|
146
|
+
chainCode: _cleaners.asString,
|
|
147
|
+
tokenCode: _cleaners.asString,
|
|
148
|
+
memo: _cleaners.asString
|
|
149
|
+
}); exports.asFioRequestFundsParams = asFioRequestFundsParams
|
|
150
|
+
|
|
151
|
+
const asFioBroadcastResult = _cleaners.asObject.call(void 0, {
|
|
152
|
+
block_num: _cleaners.asNumber,
|
|
153
|
+
block_time: _cleaners.asString,
|
|
154
|
+
transaction_id: _cleaners.asString
|
|
155
|
+
}).withRest; exports.asFioBroadcastResult = asFioBroadcastResult
|
|
156
|
+
|
|
157
|
+
const asFioEmptyResponse = _cleaners.asObject.call(void 0, {
|
|
158
|
+
message: _cleaners.asString
|
|
159
|
+
}); exports.asFioEmptyResponse = asFioEmptyResponse
|
|
160
|
+
|
|
161
|
+
const asGetFioRequestsResponse = _cleaners.asObject.call(void 0, {
|
|
162
|
+
requests: _cleaners.asArray.call(void 0, _fioConst.asEncryptedFioRequest),
|
|
163
|
+
more: _cleaners.asNumber
|
|
164
|
+
}); exports.asGetFioRequestsResponse = asGetFioRequestsResponse
|
|
165
|
+
|
|
166
|
+
const asObtData = _cleaners.asObject.call(void 0, {
|
|
167
|
+
payer_fio_address: _cleaners.asString,
|
|
168
|
+
payee_fio_address: _cleaners.asString,
|
|
169
|
+
payer_fio_public_key: _cleaners.asString,
|
|
170
|
+
payee_fio_public_key: _cleaners.asString,
|
|
171
|
+
content: _cleaners.asString,
|
|
172
|
+
fio_request_id: _cleaners.asNumber,
|
|
173
|
+
status: _cleaners.asString,
|
|
174
|
+
time_stamp: _cleaners.asString
|
|
175
|
+
}); exports.asObtData = asObtData
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
const asGetObtDataResponse = _cleaners.asObject.call(void 0, {
|
|
180
|
+
obt_data_records: _cleaners.asArray.call(void 0, exports.asObtData),
|
|
181
|
+
more: _cleaners.asNumber
|
|
182
|
+
}); exports.asGetObtDataResponse = asGetObtDataResponse
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
const asSafeFioWalletInfo = _types.asWalletInfo.call(void 0,
|
|
186
|
+
_cleaners.asObject.call(void 0, {
|
|
187
|
+
publicKey: _cleaners.asString
|
|
188
|
+
})
|
|
189
|
+
); exports.asSafeFioWalletInfo = asSafeFioWalletInfo
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
const asFioPrivateKeys = _cleaners.asObject.call(void 0, {
|
|
193
|
+
fioKey: _cleaners.asString
|
|
194
|
+
}); exports.asFioPrivateKeys = asFioPrivateKeys
|
|
@@ -11,6 +11,7 @@ var _biggystring = require('biggystring');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
var _types = require('edge-core-js/types');
|
|
15
16
|
var _rfc4648 = require('rfc4648');
|
|
16
17
|
|
|
@@ -27,11 +28,17 @@ var _utils = require('../common/utils');
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
30
34
|
var _hederaTypes = require('./hederaTypes');
|
|
31
35
|
|
|
32
36
|
const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
33
37
|
|
|
34
|
-
class HederaEngine extends _engine.CurrencyEngine
|
|
38
|
+
class HederaEngine extends _engine.CurrencyEngine
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
{
|
|
35
42
|
|
|
36
43
|
|
|
37
44
|
|
|
@@ -191,7 +198,7 @@ const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
|
191
198
|
)
|
|
192
199
|
const { accounts } = _hederaTypes.asGetHederaAccount.call(void 0, await response.json())
|
|
193
200
|
for (const account of accounts) {
|
|
194
|
-
if (this.walletInfo.keys.publicKey.
|
|
201
|
+
if (this.walletInfo.keys.publicKey.includes(account.key.key)) {
|
|
195
202
|
accountId = account.account
|
|
196
203
|
}
|
|
197
204
|
}
|
|
@@ -485,7 +492,13 @@ const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
|
485
492
|
return edgeTransaction
|
|
486
493
|
}
|
|
487
494
|
|
|
488
|
-
async signTx(
|
|
495
|
+
async signTx(
|
|
496
|
+
edgeTransaction,
|
|
497
|
+
privateKeys
|
|
498
|
+
) {
|
|
499
|
+
const hederaPrivateKeys = _hederaTypes.asHederaPrivateKeys.call(void 0, this.currencyInfo.pluginId)(
|
|
500
|
+
privateKeys
|
|
501
|
+
)
|
|
489
502
|
if (
|
|
490
503
|
edgeTransaction.otherParams == null ||
|
|
491
504
|
edgeTransaction.otherParams.transferTx == null
|
|
@@ -493,7 +506,7 @@ const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
|
493
506
|
throw new Error('missing otherParam transferTx')
|
|
494
507
|
}
|
|
495
508
|
|
|
496
|
-
const privateKey =
|
|
509
|
+
const privateKey = hederaPrivateKeys.privateKey
|
|
497
510
|
|
|
498
511
|
if (privateKey == null) {
|
|
499
512
|
throw new Error('missing privateKey in walletInfo')
|
|
@@ -546,13 +559,11 @@ const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
|
546
559
|
return Math.floor(Date.now() / 1000)
|
|
547
560
|
}
|
|
548
561
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
_nullishCoalesce(_nullishCoalesce(this.walletInfo.keys[`${this.currencyInfo.pluginId}Mnemonic`], () => (
|
|
553
|
-
this.walletInfo.keys[`${this.currencyInfo.pluginId}Key`])), () => (
|
|
554
|
-
''))
|
|
562
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
563
|
+
const hederaPrivateKeys = _hederaTypes.asHederaPrivateKeys.call(void 0, this.currencyInfo.pluginId)(
|
|
564
|
+
privateKeys
|
|
555
565
|
)
|
|
566
|
+
return _nullishCoalesce(hederaPrivateKeys.mnemonic, () => ( hederaPrivateKeys.privateKey))
|
|
556
567
|
}
|
|
557
568
|
|
|
558
569
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
@@ -575,9 +586,10 @@ const GENESIS = '1535068800' // '2018-08-24T00:00:00.000Z'
|
|
|
575
586
|
opts
|
|
576
587
|
) {
|
|
577
588
|
const { io } = env
|
|
578
|
-
const
|
|
589
|
+
const safeWalletInfo = _hederaTypes.asSafeHederaWalletInfo.call(void 0, walletInfo)
|
|
590
|
+
const engine = new HederaEngine(env, tools, safeWalletInfo, opts, io)
|
|
579
591
|
|
|
580
|
-
await engine.loadEngine(tools,
|
|
592
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
581
593
|
|
|
582
594
|
return engine
|
|
583
595
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
|
|
9
11
|
var _cleaners = require('cleaners');
|
|
10
12
|
|
|
13
|
+
var _types = require('../common/types');
|
|
14
|
+
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
|
|
@@ -84,3 +88,36 @@ var _cleaners = require('cleaners');
|
|
|
84
88
|
status: _cleaners.asString,
|
|
85
89
|
account_id: _cleaners.asOptional.call(void 0, _cleaners.asString)
|
|
86
90
|
}); exports.asCheckAccountCreationStatus = asCheckAccountCreationStatus
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const asSafeHederaWalletInfo = _types.asSafeCommonWalletInfo; exports.asSafeHederaWalletInfo = asSafeHederaWalletInfo
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
const asHederaPrivateKeys = (
|
|
100
|
+
pluginId
|
|
101
|
+
) =>
|
|
102
|
+
_cleaners.asCodec.call(void 0,
|
|
103
|
+
(value) => {
|
|
104
|
+
const from = _cleaners.asObject.call(void 0, {
|
|
105
|
+
[`${pluginId}Mnemonic`]: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
106
|
+
[`${pluginId}Key`]: _cleaners.asString
|
|
107
|
+
})(value)
|
|
108
|
+
const to = {
|
|
109
|
+
mnemonic: from[`${pluginId}Mnemonic`],
|
|
110
|
+
privateKey: from[`${pluginId}Key`]
|
|
111
|
+
}
|
|
112
|
+
return _cleaners.asObject.call(void 0, {
|
|
113
|
+
mnemonic: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
114
|
+
privateKey: _cleaners.asString
|
|
115
|
+
})(to)
|
|
116
|
+
},
|
|
117
|
+
hbarPrivateKey => {
|
|
118
|
+
return {
|
|
119
|
+
[`${pluginId}Mnemonic`]: hbarPrivateKey.mnemonic,
|
|
120
|
+
[`${pluginId}Key`]: hbarPrivateKey.privateKey
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
); exports.asHederaPrivateKeys = asHederaPrivateKeys
|
|
@@ -12,6 +12,7 @@ var _biggystring = require('biggystring');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _types = require('edge-core-js/types');
|
|
15
|
+
var _rfc4648 = require('rfc4648');
|
|
15
16
|
|
|
16
17
|
var _engine = require('../common/engine');
|
|
17
18
|
|
|
@@ -32,6 +33,9 @@ var _utils = require('../common/utils');
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
35
39
|
var _polkadotTypes = require('./polkadotTypes');
|
|
36
40
|
|
|
37
41
|
const ACCOUNT_POLL_MILLISECONDS = 5000
|
|
@@ -40,7 +44,10 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
40
44
|
|
|
41
45
|
const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
42
46
|
|
|
43
|
-
class PolkadotEngine extends _engine.CurrencyEngine
|
|
47
|
+
class PolkadotEngine extends _engine.CurrencyEngine
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
{
|
|
44
51
|
|
|
45
52
|
|
|
46
53
|
|
|
@@ -98,7 +105,7 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
98
105
|
|
|
99
106
|
async queryBalance() {
|
|
100
107
|
const response = await this.api.query.system.account(
|
|
101
|
-
this.walletInfo.keys.publicKey
|
|
108
|
+
this.walletInfo.keys.publicKey
|
|
102
109
|
)
|
|
103
110
|
this.nonce = response.nonce.toNumber()
|
|
104
111
|
this.updateBalance(
|
|
@@ -379,7 +386,13 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
379
386
|
return edgeTransaction
|
|
380
387
|
}
|
|
381
388
|
|
|
382
|
-
async signTx(
|
|
389
|
+
async signTx(
|
|
390
|
+
edgeTransaction,
|
|
391
|
+
privateKeys
|
|
392
|
+
) {
|
|
393
|
+
const polkadotPrivateKeys = _polkadotTypes.asPolkapolkadotPrivateKeys.call(void 0,
|
|
394
|
+
this.currencyInfo.pluginId
|
|
395
|
+
)(privateKeys)
|
|
383
396
|
const { publicAddress } = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
384
397
|
if (publicAddress == null)
|
|
385
398
|
throw new Error('Missing publicAddress from makeSpend')
|
|
@@ -417,9 +430,12 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
417
430
|
|
|
418
431
|
if (this.keypair == null) {
|
|
419
432
|
this.keypair = new (0, _api.Keyring)({ ss58Format: 0 })
|
|
420
|
-
|
|
421
|
-
this.
|
|
422
|
-
|
|
433
|
+
if (polkadotPrivateKeys.mnemonic != null) {
|
|
434
|
+
this.keypair.addFromUri(polkadotPrivateKeys.mnemonic)
|
|
435
|
+
} else {
|
|
436
|
+
const uint8Array = _rfc4648.base16.parse(polkadotPrivateKeys.privateKey)
|
|
437
|
+
this.keypair.addFromSeed(uint8Array)
|
|
438
|
+
}
|
|
423
439
|
}
|
|
424
440
|
|
|
425
441
|
const signedPayload = extrinsicPayload.sign(
|
|
@@ -455,8 +471,11 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
455
471
|
return edgeTransaction
|
|
456
472
|
}
|
|
457
473
|
|
|
458
|
-
getDisplayPrivateSeed() {
|
|
459
|
-
|
|
474
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
475
|
+
const polkadotPrivateKeys = _polkadotTypes.asPolkapolkadotPrivateKeys.call(void 0,
|
|
476
|
+
this.currencyInfo.pluginId
|
|
477
|
+
)(privateKeys)
|
|
478
|
+
return _nullishCoalesce(polkadotPrivateKeys.mnemonic, () => ( polkadotPrivateKeys.privateKey))
|
|
460
479
|
}
|
|
461
480
|
|
|
462
481
|
getDisplayPublicSeed() {
|
|
@@ -470,10 +489,11 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
470
489
|
walletInfo,
|
|
471
490
|
opts
|
|
472
491
|
) {
|
|
473
|
-
const
|
|
492
|
+
const safeWalletInfo = _polkadotTypes.asSafePolkadotWalletInfo.call(void 0, walletInfo)
|
|
493
|
+
const engine = new PolkadotEngine(env, tools, safeWalletInfo, opts)
|
|
474
494
|
|
|
475
495
|
// Do any async initialization necessary for the engine
|
|
476
|
-
await engine.loadEngine(tools,
|
|
496
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
477
497
|
|
|
478
498
|
return engine
|
|
479
499
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
|
|
11
|
+
|
|
10
12
|
var _cleaners = require('cleaners');
|
|
11
13
|
|
|
14
|
+
var _types = require('../common/types');
|
|
15
|
+
|
|
12
16
|
|
|
13
17
|
|
|
14
18
|
|
|
@@ -53,3 +57,36 @@ var _cleaners = require('cleaners');
|
|
|
53
57
|
count: _cleaners.asNumber,
|
|
54
58
|
transfers: _cleaners.asMaybe.call(void 0, _cleaners.asArray.call(void 0, exports.asTransfer), [])
|
|
55
59
|
}); exports.asTransactions = asTransactions
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const asSafePolkadotWalletInfo = _types.asSafeCommonWalletInfo; exports.asSafePolkadotWalletInfo = asSafePolkadotWalletInfo
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const asPolkapolkadotPrivateKeys = (
|
|
69
|
+
pluginId
|
|
70
|
+
) =>
|
|
71
|
+
_cleaners.asCodec.call(void 0,
|
|
72
|
+
(value) => {
|
|
73
|
+
const from = _cleaners.asObject.call(void 0, {
|
|
74
|
+
[`${pluginId}Mnemonic`]: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
75
|
+
[`${pluginId}Key`]: _cleaners.asString
|
|
76
|
+
})(value)
|
|
77
|
+
const to = {
|
|
78
|
+
mnemonic: from[`${pluginId}Mnemonic`],
|
|
79
|
+
privateKey: from[`${pluginId}Key`]
|
|
80
|
+
}
|
|
81
|
+
return _cleaners.asObject.call(void 0, {
|
|
82
|
+
mnemonic: _cleaners.asOptional.call(void 0, _cleaners.asString),
|
|
83
|
+
privateKey: _cleaners.asString
|
|
84
|
+
})(to)
|
|
85
|
+
},
|
|
86
|
+
privateKeys => {
|
|
87
|
+
return {
|
|
88
|
+
[`${pluginId}Mnemonic`]: privateKeys.mnemonic,
|
|
89
|
+
[`${pluginId}Key`]: privateKeys.privateKey
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
); exports.asPolkapolkadotPrivateKeys = asPolkapolkadotPrivateKeys
|
|
@@ -12,6 +12,7 @@ var _cleaners = require('cleaners');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _types = require('edge-core-js/types');
|
|
15
|
+
var _rfc4648 = require('rfc4648');
|
|
15
16
|
|
|
16
17
|
var _engine = require('../common/engine');
|
|
17
18
|
|
|
@@ -31,6 +32,9 @@ var _utils = require('../common/utils');
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
34
38
|
var _solanaTypes = require('./solanaTypes');
|
|
35
39
|
|
|
36
40
|
const {
|
|
@@ -45,7 +49,10 @@ const ACCOUNT_POLL_MILLISECONDS = 5000
|
|
|
45
49
|
const BLOCKCHAIN_POLL_MILLISECONDS = 20000
|
|
46
50
|
const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
47
51
|
|
|
48
|
-
class SolanaEngine extends _engine.CurrencyEngine
|
|
52
|
+
class SolanaEngine extends _engine.CurrencyEngine
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
{
|
|
49
56
|
|
|
50
57
|
|
|
51
58
|
|
|
@@ -382,18 +389,19 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
382
389
|
return edgeTransaction
|
|
383
390
|
}
|
|
384
391
|
|
|
385
|
-
async signTx(
|
|
392
|
+
async signTx(
|
|
393
|
+
edgeTransaction,
|
|
394
|
+
privateKeys
|
|
395
|
+
) {
|
|
396
|
+
const solanaPrivateKeys = _solanaTypes.asSolanaPrivateKeys.call(void 0, this.currencyInfo.pluginId)(
|
|
397
|
+
privateKeys
|
|
398
|
+
)
|
|
386
399
|
const { unsignedSerializedSolTx } = _utils.getOtherParams.call(void 0, edgeTransaction)
|
|
387
400
|
if (unsignedSerializedSolTx == null)
|
|
388
401
|
throw new Error('Missing unsignedSerializedSolTx')
|
|
389
402
|
|
|
390
403
|
const keypair = Keypair.fromSecretKey(
|
|
391
|
-
Uint8Array.from(
|
|
392
|
-
Buffer.from(
|
|
393
|
-
this.walletInfo.keys[`${this.currencyInfo.pluginId}Key`],
|
|
394
|
-
'hex'
|
|
395
|
-
)
|
|
396
|
-
)
|
|
404
|
+
Uint8Array.from(_rfc4648.base16.parse(solanaPrivateKeys.privateKey))
|
|
397
405
|
)
|
|
398
406
|
|
|
399
407
|
const solTx = Transaction.from(unsignedSerializedSolTx)
|
|
@@ -426,26 +434,15 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
426
434
|
return edgeTransaction
|
|
427
435
|
}
|
|
428
436
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
435
|
-
this.walletInfo.keys[`${this.currencyInfo.pluginId}Mnemonic`]
|
|
436
|
-
) {
|
|
437
|
-
return this.walletInfo.keys[`${this.currencyInfo.pluginId}Mnemonic`]
|
|
438
|
-
}
|
|
439
|
-
return ''
|
|
437
|
+
getDisplayPrivateSeed(privateKeys) {
|
|
438
|
+
const solanaPrivateKeys = _solanaTypes.asSolanaPrivateKeys.call(void 0, this.currencyInfo.pluginId)(
|
|
439
|
+
privateKeys
|
|
440
|
+
)
|
|
441
|
+
return solanaPrivateKeys.mnemonic
|
|
440
442
|
}
|
|
441
443
|
|
|
442
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
443
444
|
getDisplayPublicSeed() {
|
|
444
|
-
|
|
445
|
-
if (this.walletInfo.keys && this.walletInfo.keys.publicKey) {
|
|
446
|
-
return this.walletInfo.keys.publicKey
|
|
447
|
-
}
|
|
448
|
-
return ''
|
|
445
|
+
return this.walletInfo.keys.publicKey
|
|
449
446
|
}
|
|
450
447
|
} exports.SolanaEngine = SolanaEngine;
|
|
451
448
|
|
|
@@ -455,10 +452,11 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
|
|
|
455
452
|
walletInfo,
|
|
456
453
|
opts
|
|
457
454
|
) {
|
|
458
|
-
const
|
|
455
|
+
const safeWalletInfo = _solanaTypes.asSafeSolanaWalletInfo.call(void 0, walletInfo)
|
|
456
|
+
const engine = new SolanaEngine(env, tools, safeWalletInfo, opts)
|
|
459
457
|
|
|
460
458
|
// Do any async initialization necessary for the engine
|
|
461
|
-
await engine.loadEngine(tools,
|
|
459
|
+
await engine.loadEngine(tools, safeWalletInfo, opts)
|
|
462
460
|
|
|
463
461
|
return engine
|
|
464
462
|
} exports.makeCurrencyEngine = makeCurrencyEngine;
|
|
@@ -6,8 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
|
|
9
11
|
var _cleaners = require('cleaners');
|
|
10
12
|
|
|
13
|
+
var _types = require('../common/types');
|
|
14
|
+
|
|
11
15
|
|
|
12
16
|
|
|
13
17
|
|
|
@@ -62,3 +66,36 @@ var _cleaners = require('cleaners');
|
|
|
62
66
|
})
|
|
63
67
|
})
|
|
64
68
|
}); exports.asRecentBlockHash = asRecentBlockHash
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
const asSafeSolanaWalletInfo = _types.asSafeCommonWalletInfo; exports.asSafeSolanaWalletInfo = asSafeSolanaWalletInfo
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
const asSolanaPrivateKeys = (
|
|
78
|
+
pluginId
|
|
79
|
+
) =>
|
|
80
|
+
_cleaners.asCodec.call(void 0,
|
|
81
|
+
(value) => {
|
|
82
|
+
const from = _cleaners.asObject.call(void 0, {
|
|
83
|
+
[`${pluginId}Mnemonic`]: _cleaners.asString,
|
|
84
|
+
[`${pluginId}Key`]: _cleaners.asString
|
|
85
|
+
})(value)
|
|
86
|
+
const to = {
|
|
87
|
+
mnemonic: from[`${pluginId}Mnemonic`],
|
|
88
|
+
privateKey: from[`${pluginId}Key`]
|
|
89
|
+
}
|
|
90
|
+
return _cleaners.asObject.call(void 0, {
|
|
91
|
+
mnemonic: _cleaners.asString,
|
|
92
|
+
privateKey: _cleaners.asString
|
|
93
|
+
})(to)
|
|
94
|
+
},
|
|
95
|
+
hbarPrivateKey => {
|
|
96
|
+
return {
|
|
97
|
+
[`${pluginId}Mnemonic`]: hbarPrivateKey.mnemonic,
|
|
98
|
+
[`${pluginId}Key`]: hbarPrivateKey.privateKey
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
); exports.asSolanaPrivateKeys = asSolanaPrivateKeys
|