mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-21 22:58:49 +00:00
eth + eth token send fix
This commit is contained in:
parent
e90baa39e8
commit
fb937ebddf
1 changed files with 13 additions and 12 deletions
|
@ -33,7 +33,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
|
||||||
EthereumWallet(CryptoCurrencyNetwork network) : super(Ethereum(network));
|
EthereumWallet(CryptoCurrencyNetwork network) : super(Ethereum(network));
|
||||||
|
|
||||||
Timer? timer;
|
Timer? timer;
|
||||||
late web3.EthPrivateKey _credentials;
|
web3.EthPrivateKey? _credentials;
|
||||||
|
|
||||||
Future<void> updateTokenContracts(List<String> contractAddresses) async {
|
Future<void> updateTokenContracts(List<String> contractAddresses) async {
|
||||||
await info.updateContractAddresses(
|
await info.updateContractAddresses(
|
||||||
|
@ -78,11 +78,10 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
|
||||||
|
|
||||||
// ==================== Private ==============================================
|
// ==================== Private ==============================================
|
||||||
|
|
||||||
Future<void> _initCredentials(
|
Future<void> _initCredentials() async {
|
||||||
String mnemonic,
|
final mnemonic = await getMnemonic();
|
||||||
String mnemonicPassphrase,
|
final mnemonicPassphrase = await getMnemonicPassphrase();
|
||||||
) async {
|
final privateKey = getPrivateKey(mnemonic, mnemonicPassphrase);
|
||||||
String privateKey = getPrivateKey(mnemonic, mnemonicPassphrase);
|
|
||||||
_credentials = web3.EthPrivateKey.fromHex(privateKey);
|
_credentials = web3.EthPrivateKey.fromHex(privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,14 +110,13 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
|
||||||
Future<void> checkSaveInitialReceivingAddress() async {
|
Future<void> checkSaveInitialReceivingAddress() async {
|
||||||
final address = await getCurrentReceivingAddress();
|
final address = await getCurrentReceivingAddress();
|
||||||
if (address == null) {
|
if (address == null) {
|
||||||
await _initCredentials(
|
if (_credentials == null) {
|
||||||
await getMnemonic(),
|
await _initCredentials();
|
||||||
await getMnemonicPassphrase(),
|
}
|
||||||
);
|
|
||||||
|
|
||||||
final address = Address(
|
final address = Address(
|
||||||
walletId: walletId,
|
walletId: walletId,
|
||||||
value: _credentials.address.hexEip55,
|
value: _credentials!.address.hexEip55,
|
||||||
publicKey: [],
|
publicKey: [],
|
||||||
// maybe store address bytes here? seems a waste of space though
|
// maybe store address bytes here? seems a waste of space though
|
||||||
derivationIndex: 0,
|
derivationIndex: 0,
|
||||||
|
@ -450,9 +448,12 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface {
|
||||||
@override
|
@override
|
||||||
Future<TxData> confirmSend({required TxData txData}) async {
|
Future<TxData> confirmSend({required TxData txData}) async {
|
||||||
final client = getEthClient();
|
final client = getEthClient();
|
||||||
|
if (_credentials == null) {
|
||||||
|
await _initCredentials();
|
||||||
|
}
|
||||||
|
|
||||||
final txid = await client.sendTransaction(
|
final txid = await client.sendTransaction(
|
||||||
_credentials,
|
_credentials!,
|
||||||
txData.web3dartTransaction!,
|
txData.web3dartTransaction!,
|
||||||
chainId: txData.chainId!.toInt(),
|
chainId: txData.chainId!.toInt(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue