forked from axiom-team/gecko
Ready to migrate identity, wait for signMessage methode in sdk
https://github.com/polkawallet-io/sdk/issues/31
This commit is contained in:
parent
1b896960ea
commit
237e581d0f
|
@ -184,5 +184,6 @@
|
||||||
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
||||||
"importOldAccount": "Import your old account",
|
"importOldAccount": "Import your old account",
|
||||||
"enterCesiumId": "Enter your Cesium ID",
|
"enterCesiumId": "Enter your Cesium ID",
|
||||||
"enterCesiumPassword": "Enter your Cesium password"
|
"enterCesiumPassword": "Enter your Cesium password",
|
||||||
|
"migrateAccount": "Migrate account"
|
||||||
}
|
}
|
|
@ -184,5 +184,6 @@
|
||||||
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
"youCannotMigrateIdentityToExistingIdentity": "You cannot migrate an identity\nto an account that already has an identity",
|
||||||
"importOldAccount": "Import your old account",
|
"importOldAccount": "Import your old account",
|
||||||
"enterCesiumId": "Enter your Cesium ID",
|
"enterCesiumId": "Enter your Cesium ID",
|
||||||
"enterCesiumPassword": "Enter your Cesium password"
|
"enterCesiumPassword": "Enter your Cesium password",
|
||||||
|
"migrateAccount": "Migrate account"
|
||||||
}
|
}
|
|
@ -185,5 +185,6 @@
|
||||||
"youCannotMigrateIdentityToExistingIdentity": "Vous ne pouvez pas migrer une identité\nvers un compte disposant déjà d'une identité",
|
"youCannotMigrateIdentityToExistingIdentity": "Vous ne pouvez pas migrer une identité\nvers un compte disposant déjà d'une identité",
|
||||||
"importOldAccount": "Importer son ancien compte",
|
"importOldAccount": "Importer son ancien compte",
|
||||||
"enterCesiumId": "Entrez votre identifiant Cesium",
|
"enterCesiumId": "Entrez votre identifiant Cesium",
|
||||||
"enterCesiumPassword": "Entrez votre mot de passe Cesium"
|
"enterCesiumPassword": "Entrez votre mot de passe Cesium",
|
||||||
|
"migrateAccount": "Migrer le compte"
|
||||||
}
|
}
|
|
@ -270,9 +270,19 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future addressToPubkey(String address) async {
|
Future<String> getGenesisHash() async {
|
||||||
// await sdk.api.account.decodeAddress([address]);
|
final String genesisHash = await sdk.webView!.evalJavascript(
|
||||||
// }
|
'api.genesisHash.toHex()',
|
||||||
|
wrapPromise: false,
|
||||||
|
) ??
|
||||||
|
'';
|
||||||
|
// log.d('genesisHash: $genesisHash');
|
||||||
|
return genesisHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future addressToPubkey(String address) async {
|
||||||
|
await sdk.api.account.decodeAddress([address]);
|
||||||
|
}
|
||||||
|
|
||||||
// Future pubkeyToAddress(String pubkey) async {
|
// Future pubkeyToAddress(String pubkey) async {
|
||||||
// await sdk.api.account.encodeAddress([pubkey]);
|
// await sdk.api.account.encodeAddress([pubkey]);
|
||||||
|
@ -784,6 +794,45 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return await executeCall(txInfo, txOptions, password);
|
return await executeCall(txInfo, txOptions, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> migrateIdentity(
|
||||||
|
{required String fromAddress,
|
||||||
|
required String destAddress,
|
||||||
|
required String password}) async {
|
||||||
|
transactionStatus = '';
|
||||||
|
final fromPubkey = await sdk.api.account.decodeAddress([fromAddress]);
|
||||||
|
final sender = TxSenderData(
|
||||||
|
fromAddress,
|
||||||
|
fromPubkey!.keys.first,
|
||||||
|
);
|
||||||
|
|
||||||
|
// final globalBalance = await getBalance(fromAddress);
|
||||||
|
TxInfoData txInfo;
|
||||||
|
List txOptions = [];
|
||||||
|
String? rawParams;
|
||||||
|
// final destKeyring = getKeypair(destAddress);
|
||||||
|
|
||||||
|
final genesisHash = await getGenesisHash();
|
||||||
|
final idtyIndex = await getIdentityIndexOf(destAddress);
|
||||||
|
// final oldPubkey = await addressToPubkey(fromAddress);
|
||||||
|
final messageToSign = 'icok$genesisHash$idtyIndex$fromAddress';
|
||||||
|
final newKeySig = messageToSign;
|
||||||
|
|
||||||
|
txInfo = TxInfoData(
|
||||||
|
'utility',
|
||||||
|
'batchAll',
|
||||||
|
sender,
|
||||||
|
);
|
||||||
|
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]]';
|
||||||
|
|
||||||
|
log.d(
|
||||||
|
'g1migration args: ${txInfo.module}, ${txInfo.call}, $txOptions, $rawParams');
|
||||||
|
return await executeCall(txInfo, txOptions, password, rawParams);
|
||||||
|
}
|
||||||
|
|
||||||
Future revokeIdentity(String address, String password) async {
|
Future revokeIdentity(String address, String password) async {
|
||||||
final idtyIndex = await getIdentityIndexOf(address);
|
final idtyIndex = await getIdentityIndexOf(address);
|
||||||
|
|
||||||
|
@ -837,7 +886,13 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
password: password,
|
password: password,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (balance != 0) {
|
log.d('g1migration idtyStatus: $idtyStatus');
|
||||||
|
if (idtyStatus != 'noid') {
|
||||||
|
await migrateIdentity(
|
||||||
|
fromAddress: keypair.address!,
|
||||||
|
destAddress: destAddress,
|
||||||
|
password: 'password');
|
||||||
|
} else if (balance != 0) {
|
||||||
await pay(
|
await pay(
|
||||||
fromAddress: keypair.address!,
|
fromAddress: keypair.address!,
|
||||||
destAddress: destAddress,
|
destAddress: destAddress,
|
||||||
|
|
|
@ -62,6 +62,8 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
final myIdtyStatus = status.data?[2];
|
final myIdtyStatus = status.data?[2];
|
||||||
final hasConsumer = status.data?[3] ?? false;
|
final hasConsumer = status.data?[3] ?? false;
|
||||||
|
|
||||||
|
// log.d('hasconsumer: $hasConsumer');
|
||||||
|
|
||||||
if (balance != 0 && !hasConsumer) {
|
if (balance != 0 && !hasConsumer) {
|
||||||
canValidate = true;
|
canValidate = true;
|
||||||
validationStatus = '';
|
validationStatus = '';
|
||||||
|
@ -216,7 +218,6 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
selectedWallet.address!,
|
selectedWallet.address!,
|
||||||
balance: balance,
|
balance: balance,
|
||||||
idtyStatus: idtyStatus);
|
idtyStatus: idtyStatus);
|
||||||
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) {
|
MaterialPageRoute(builder: (context) {
|
||||||
|
@ -227,7 +228,7 @@ class ImportG1v1 extends StatelessWidget {
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: Text(
|
child: Text(
|
||||||
'validate'.tr(),
|
'migrateAccount'.tr(),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 23 * ratio,
|
fontSize: 23 * ratio,
|
||||||
fontWeight: FontWeight.w600),
|
fontWeight: FontWeight.w600),
|
||||||
|
|
|
@ -88,6 +88,7 @@ class TransactionInProgress extends StatelessWidget {
|
||||||
if (result.contains('blockHash: ')) {
|
if (result.contains('blockHash: ')) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
resultText = 'extrinsicValidated'.tr(args: [actionName]);
|
resultText = 'extrinsicValidated'.tr(args: [actionName]);
|
||||||
|
log.i('Bloc of last transaction: ${sub.blocNumber} --- $result');
|
||||||
} else {
|
} else {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
resultText = "${"anErrorOccured".tr()}:\n";
|
resultText = "${"anErrorOccured".tr()}:\n";
|
||||||
|
|
|
@ -62,6 +62,8 @@ dependencies:
|
||||||
package_info_plus: ^1.4.2
|
package_info_plus: ^1.4.2
|
||||||
polkawallet_sdk: #^0.4.9
|
polkawallet_sdk: #^0.4.9
|
||||||
git:
|
git:
|
||||||
|
# url: https://github.com/polkawallet-io/sdk.git
|
||||||
|
# ref: develop
|
||||||
url: https://github.com/poka-IT/sdk.git
|
url: https://github.com/poka-IT/sdk.git
|
||||||
ref: gecko-old
|
ref: gecko-old
|
||||||
dots_indicator: ^2.1.0
|
dots_indicator: ^2.1.0
|
||||||
|
|
Loading…
Reference in New Issue