diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 94696c2..6f43a5c 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -598,7 +598,7 @@ class SubstrateSdk with ChangeNotifier { return await sdk.api.keyring.checkMnemonicValid(mnemonic); } - Future csToV2Address(String salt, String password) async { + Future csToV2Address(String salt, String password) async { final scrypt = pc.KeyDerivator('scrypt'); scrypt.init( @@ -621,6 +621,7 @@ class SubstrateSdk with ChangeNotifier { g1V1NewAddress = newAddress.address!; notifyListeners(); + return g1V1NewAddress; } Future getBalanceAndIdtyStatus(String address, String myAddress) async { @@ -801,7 +802,8 @@ class SubstrateSdk with ChangeNotifier { {required String fromAddress, required String destAddress, required String formPassword, - required String destPassword}) async { + required String destPassword, + bool withBalance = false}) async { transactionStatus = ''; final fromPubkey = await sdk.api.account.decodeAddress([fromAddress]); final sender = TxSenderData( @@ -840,19 +842,28 @@ messageToSign: $messageToSign messageToSignHex: $messageToSignHex newKeySig: $newKeySig"""); - txInfo = TxInfoData( - 'identity', - 'changeOwnerKey', - sender, - ); + if (withBalance) { + txInfo = TxInfoData( + 'utility', + 'batchAll', + sender, + ); - txOptions = [destAddress, newKeySig]; + const tx1 = 'api.tx.universalDividend.claimUds()'; + final tx2 = + 'api.tx.identity.changeOwnerKey("$destAddress", "$newKeySig")'; + const tx3 = 'api.tx.balances.transferAll(false)'; - // const tx1 = 'api.tx.universalDividend.claimUds()'; - // final tx2 = 'api.tx.identity.changeOwnerKey("$destAddress", "$newKeySig")'; - // const tx3 = 'api.tx.balances.transferAll(false)'; + rawParams = '[[$tx1, $tx2, $tx3]]'; + } else { + txInfo = TxInfoData( + 'identity', + 'changeOwnerKey', + sender, + ); - // rawParams = '[[$tx1, $tx2, $tx3]]'; + txOptions = [destAddress, newKeySig]; + } return await _executeCall(txInfo, txOptions, formPassword, rawParams); } @@ -918,7 +929,8 @@ newKeySig: $newKeySig"""); fromAddress: keypair.address!, destAddress: destAddress, formPassword: 'password', - destPassword: destPassword); + destPassword: destPassword, + withBalance: true); } else if (balance != 0) { await pay( fromAddress: keypair.address!, diff --git a/pubspec.lock b/pubspec.lock index 949cbc3..d404e72 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1062,8 +1062,8 @@ packages: dependency: "direct main" description: path: "." - ref: gecko-old - resolved-ref: "87096351fb187614b6386343615db39a2f2b5b9b" + ref: gecko-unwrapbytes + resolved-ref: b019cc2a6e77b6989f94b1bef8259298410cd82a url: "https://github.com/poka-IT/sdk.git" source: git version: "0.4.8" diff --git a/pubspec.yaml b/pubspec.yaml index a04320a..58d1deb 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -65,7 +65,8 @@ dependencies: # url: https://github.com/polkawallet-io/sdk.git # ref: develop url: https://github.com/poka-IT/sdk.git - ref: gecko-old + # ref: gecko-old + ref: gecko-unwrapbytes dots_indicator: ^2.1.0 web_socket_channel: ^2.2.0 connectivity_plus: ^2.3.3