Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğecko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Ğecko
Commits
981094ab
Commit
981094ab
authored
3 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
WIP: Work about derivation: Can't get seed from stored keypair
parent
90c0765c
No related branches found
No related tags found
No related merge requests found
Pipeline
#15015
failed
3 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/providers/substrate_sdk.dart
+58
-9
58 additions, 9 deletions
lib/providers/substrate_sdk.dart
lib/screens/substrate_sandbox.dart
+34
-26
34 additions, 26 deletions
lib/screens/substrate_sandbox.dart
with
92 additions
and
35 deletions
lib/providers/substrate_sdk.dart
+
58
−
9
View file @
981094ab
// ignore_for_file: avoid_print
import
'dart:convert'
;
import
"package:hex/hex.dart"
;
import
'dart:io'
;
import
'package:crypto/crypto.dart'
;
import
'package:fast_base58/fast_base58.dart'
;
...
...
@@ -9,7 +12,12 @@ import 'package:polkawallet_sdk/api/types/networkParams.dart';
import
'package:polkawallet_sdk/api/types/txInfoData.dart'
;
import
'package:polkawallet_sdk/polkawallet_sdk.dart'
;
import
'package:polkawallet_sdk/storage/keyring.dart'
;
import
'package:polkawallet_sdk/storage/localStorage.dart'
;
import
'package:polkawallet_sdk/utils/index.dart'
;
import
'package:polkawallet_sdk/utils/localStorage.dart'
;
import
'package:truncate/truncate.dart'
;
import
'package:get_storage/get_storage.dart'
;
import
'package:aes_ecb_pkcs5_flutter/aes_ecb_pkcs5_flutter.dart'
;
class
SubstrateSdk
with
ChangeNotifier
{
final
List
subNode
=
[
'127.0.0.1:9944'
,
'192.168.1.85:9944'
];
...
...
@@ -65,7 +73,8 @@ class SubstrateSdk with ChangeNotifier {
});
}
Future
<
bool
>
importAccount
({
bool
fromMnemonic
=
false
})
async
{
Future
<
bool
>
importAccount
(
{
bool
fromMnemonic
=
false
,
String
derivePath
=
''
})
async
{
final
KeyType
keytype
;
final
String
keyToImport
;
if
(
fromMnemonic
)
{
...
...
@@ -80,19 +89,19 @@ class SubstrateSdk with ChangeNotifier {
notifyListeners
();
final
clipboardData
=
await
Clipboard
.
getData
(
Clipboard
.
kTextPlain
);
if
(
clipboardData
?.
text
!=
null
)
jsonKeystore
.
text
=
clipboardData
!.
text
!
;
final
json
=
await
sdk
.
api
.
keyring
.
importAccount
(
keyring
,
keyType:
keytype
,
key:
keyToImport
,
name:
'testKey'
,
password:
keystorePassword
.
text
,
)
var
json
=
await
sdk
.
api
.
keyring
.
importAccount
(
keyring
,
keyType:
keytype
,
key:
keyToImport
,
name:
'testKey'
,
password:
keystorePassword
.
text
,
derivePath:
derivePath
)
.
catchError
((
e
)
{
importIsLoading
=
false
;
notifyListeners
();
});
if
(
json
==
null
)
return
false
;
print
(
json
);
try
{
final
acc
=
await
sdk
.
api
.
keyring
.
addAccount
(
keyring
,
...
...
@@ -178,6 +187,46 @@ class SubstrateSdk with ChangeNotifier {
print
(
err
.
toString
());
}
}
derive
(
BuildContext
context
,
String
address
,
double
amount
,
String
password
)
async
{
final
keypair
=
keyring
.
keyPairs
.
firstWhere
((
element
)
=
>
element
.
address
==
address
);
// KeyringStorage _storage = KeyringStorage();
// print(_storage.encryptedMnemonics.val);
// final keyPairs = [].val('keyPairs', getBox: _storage);
// final encryptedRawSeeds = {}.val('encryptedRawSeeds', getBox: _storage);
print
(
await
sdk
.
api
.
keyring
.
getDecryptedSeed
(
keyring
,
password
));
print
(
await
keyring
.
store
.
getDecryptedSeed
(
keypair
.
pubKey
,
password
));
print
(
await
keyring
.
store
.
checkSeedExist
(
KeyType
.
keystore
,
keypair
.
pubKey
!
));
print
(
await
keyring
.
store
.
checkSeedExist
(
KeyType
.
mnemonic
,
keypair
.
pubKey
!
));
_storage
()
=
>
GetStorage
(
sdk_storage_key
);
final
encryptedMnemonics
=
{}
.
val
(
'encryptedMnemonics'
,
getBox:
_storage
);
// await keyring.store.updateEncryptedSeed(keypair.pubKey, password, '012');
final
enc
=
encryptedMnemonics
.
val
[
keypair
.
pubKey
!
];
// final key = Encrypt.passwordToEncryptKey(password);
// const enc =
// '69E16A6F8CD15799FC036B3D71FC3C53EFCEDB6A2D4F2A743555809DC5B48D6FC25E96E5CFF8E7DF4FCE1AE9AFC61A0D85CDCAD945C5371F11DEBA1BF362B8124A4C8D264A05AC1D72F5A9566D0D3B35';
final
LocalStorage
_storageOld
=
LocalStorage
();
print
(
enc
);
print
(
await
_storageOld
.
getAccountList
());
print
(
await
_storageOld
.
getSeeds
(
'keystore'
));
// print(await FlutterAesEcbPkcs5.decryptString(enc, key));
// generatedMnemonic = keypair.encoded;
// importAccount();
}
}
void
snack
(
BuildContext
context
,
String
message
,
{
int
duration
=
2
})
{
...
...
This diff is collapsed.
Click to expand it.
lib/screens/substrate_sandbox.dart
+
34
−
26
View file @
981094ab
...
...
@@ -32,11 +32,9 @@ class SubstrateSandBox extends StatelessWidget {
children:
<
Widget
>[
Text
(
'js-api chargé ?:
${_sub.sdkReady}
'
),
InkWell
(
onTap:
!
_sub
.
nodeConnected
?
()
async
{
onTap:
()
async
{
await
_sub
.
connectNode
();
}
:
null
,
},
child:
Text
(
'Noeud connecté ?:
${_sub.nodeConnected}
(
${_sub.subNode}
)'
)),
if
(
_sub
.
nodeConnected
)
...
...
@@ -63,29 +61,39 @@ class SubstrateSandBox extends StatelessWidget {
builder:
(
BuildContext
context
,
AsyncSnapshot
<
List
<
AddressInfo
>>
_data
)
{
return
Column
(
children:
[
for
(
final
AddressInfo
e
in
_data
.
data
!
)
Row
(
children:
[
InkWell
(
onTap:
()
=
>
_sub
.
keyring
.
setCurrent
(
_sub
.
keyring
.
keyPairs
.
firstWhere
((
element
)
=
>
element
.
address
==
e
.
address
!
)),
child:
Text
(
getShortPubkey
(
e
.
address
!
),
style:
const
TextStyle
(
fontFamily:
'Monospace'
),
if
(
_data
.
data
!=
null
)
for
(
final
AddressInfo
e
in
_data
.
data
!
)
Row
(
children:
[
InkWell
(
onTap:
()
=
>
_sub
.
keyring
.
setCurrent
(
_sub
.
keyring
.
keyPairs
.
firstWhere
((
element
)
=
>
element
.
address
==
e
.
address
!
)),
child:
Text
(
getShortPubkey
(
e
.
address
!
),
style:
const
TextStyle
(
fontFamily:
'Monospace'
),
),
),
),
const
SizedBox
(
width:
20
),
InkWell
(
onTap:
()
async
=
>
await
_sub
.
pay
(
context
,
e
.
address
!
,
10
,
_sub
.
keystorePassword
.
text
),
child:
Text
(
"
${e.balance.toString()}
ğdev"
),
)
])
const
SizedBox
(
width:
20
),
InkWell
(
onTap:
()
async
=
>
await
_sub
.
pay
(
context
,
e
.
address
!
,
10
,
_sub
.
keystorePassword
.
text
),
child:
Text
(
"
${e.balance.toString()}
ğdev"
),
),
const
SizedBox
(
width:
20
),
InkWell
(
onTap:
()
async
=
>
await
_sub
.
derive
(
context
,
e
.
address
!
,
3
,
_sub
.
keystorePassword
.
text
),
child:
const
Text
(
"Dériver"
),
)
])
]);
}),
const
SizedBox
(
height:
20
),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment