File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -30,10 +30,11 @@ class Signer {
3030 }
3131 }
3232
33- void fromHexSeed (String hexSeed, KPType type) {
33+ KeyPair ? fromHexSeed (String hexSeed, KPType type) {
3434 try {
3535 final seed = HEX .decode (hexSeed.replaceAll ('0x' , '' ));
3636 keypair = fromSeed (Uint8List .fromList (seed), type);
37+ return keypair;
3738 } catch (e) {
3839 throw Exception ("Failed to create keyPair from hex seed. Error: $e " );
3940 }
Original file line number Diff line number Diff line change @@ -174,12 +174,22 @@ class Client extends QueryClient {
174174 _checkInputs ();
175175 final Signer .Signer signer = Signer .Signer ();
176176 if (keypairType == "sr25519" ) {
177- keypair = await signer.fromMnemonic (
178- mnemonicOrSecretSeed, Signer .KPType .sr25519);
177+ if (validateMnemonic (mnemonicOrSecretSeed)) {
178+ keypair = await signer.fromMnemonic (
179+ mnemonicOrSecretSeed, Signer .KPType .sr25519);
180+ } else {
181+ keypair = await signer.fromHexSeed (
182+ mnemonicOrSecretSeed, Signer .KPType .sr25519);
183+ }
179184 address = keypair! .address;
180185 } else {
181- keypair = await signer.fromMnemonic (
182- mnemonicOrSecretSeed, Signer .KPType .ed25519);
186+ if (validateMnemonic (mnemonicOrSecretSeed)) {
187+ keypair = await signer.fromMnemonic (
188+ mnemonicOrSecretSeed, Signer .KPType .ed25519);
189+ } else {
190+ keypair = await signer.fromHexSeed (
191+ mnemonicOrSecretSeed, Signer .KPType .ed25519);
192+ }
183193 address = keypair! .address;
184194 }
185195 }
You can’t perform that action at this time.
0 commit comments