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
6af9199a
Commit
6af9199a
authored
2 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
add methode to import Cs account
parent
8a30ba70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!27
Import cs accounts
Pipeline
#16776
waiting for manual action
Stage: format
Stage: build_and_test
Stage: package
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/providers/substrate_sdk.dart
+49
-1
49 additions, 1 deletion
lib/providers/substrate_sdk.dart
lib/screens/home.dart
+2
-0
2 additions, 0 deletions
lib/screens/home.dart
pubspec.lock
+2
-2
2 additions, 2 deletions
pubspec.lock
pubspec.yaml
+2
-0
2 additions, 0 deletions
pubspec.yaml
with
55 additions
and
3 deletions
lib/providers/substrate_sdk.dart
+
49
−
1
View file @
6af9199a
import
'dart:typed_data'
;
import
'package:easy_localization/easy_localization.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gecko/globals.dart'
;
...
...
@@ -13,7 +14,8 @@ import 'package:polkawallet_sdk/storage/keyring.dart';
import
'package:polkawallet_sdk/storage/types/keyPairData.dart'
;
import
'package:provider/provider.dart'
;
import
'package:truncate/truncate.dart'
;
// import 'package:web_socket_channel/io.dart';
import
'package:pointycastle/pointycastle.dart'
as
pc
;
import
"package:hex/hex.dart"
;
class
SubstrateSdk
with
ChangeNotifier
{
final
WalletSDK
sdk
=
WalletSDK
();
...
...
@@ -368,6 +370,52 @@ class SubstrateSdk with ChangeNotifier {
return
nodeParams
;
}
Future
csToV2
(
String
salt
,
String
password
)
async
{
final
scrypt
=
pc
.
KeyDerivator
(
'scrypt'
);
scrypt
.
init
(
pc
.
ScryptParameters
(
4096
,
16
,
1
,
32
,
Uint8List
.
fromList
(
salt
.
codeUnits
),
),
);
final
rawSeed
=
scrypt
.
process
(
Uint8List
.
fromList
(
password
.
codeUnits
));
final
rawSeedHex
=
'0x
${HEX.encode(rawSeed)}
'
;
// final newAddress1 = await sdk.api.keyring.addressFromRawSeed(ss58,
// cryptoType: CryptoType.ed25519, rawSeed: '0x$rawSeedString');
// log.d('csconvert address: ${newAddress1.address}');
final
json
=
await
sdk
.
api
.
keyring
.
importAccount
(
keyring
,
keyType:
KeyType
.
rawSeed
,
key:
rawSeedHex
,
name:
'test'
,
password:
'password'
,
derivePath:
''
,
cryptoType:
CryptoType
.
ed25519
)
.
catchError
((
e
)
{
importIsLoading
=
false
;
notifyListeners
();
});
final
keypair
=
await
sdk
.
api
.
keyring
.
addAccount
(
keyring
,
keyType:
KeyType
.
rawSeed
,
acc:
json
!
,
password:
password
,
);
await
sdk
.
api
.
keyring
.
deleteAccount
(
keyring
,
keypair
);
// final keypair2 = KeyPairData.fromJson(json as Map<String, dynamic>);
log
.
d
(
keypair
.
address
);
}
Future
<
String
>
importAccount
(
{
String
mnemonic
=
''
,
String
derivePath
=
''
,
...
...
This diff is collapsed.
Click to expand it.
lib/screens/home.dart
+
2
−
0
View file @
6af9199a
...
...
@@ -39,6 +39,8 @@ class HomeScreen extends StatelessWidget {
final
bool
isWalletsExists
=
myWalletProvider
.
checkIfWalletExist
();
// sub.csToV2('test', 'test');
isTall
=
false
;
ratio
=
1
;
if
(
MediaQuery
.
of
(
context
)
.
size
.
height
>
=
930
)
{
...
...
This diff is collapsed.
Click to expand it.
pubspec.lock
+
2
−
2
View file @
6af9199a
...
...
@@ -557,7 +557,7 @@ packages:
source: hosted
version: "2.1.0"
hex:
dependency:
transitive
dependency:
"direct main"
description:
name: hex
url: "https://pub.dartlang.org"
...
...
@@ -1052,7 +1052,7 @@ packages:
source: hosted
version: "2.1.2"
pointycastle:
dependency:
transitive
dependency:
"direct main"
description:
name: pointycastle
url: "https://pub.dartlang.org"
...
...
This diff is collapsed.
Click to expand it.
pubspec.yaml
+
2
−
0
View file @
6af9199a
...
...
@@ -71,6 +71,8 @@ dependencies:
easy_localization
:
^3.0.1
flutter_markdown
:
^0.6.10+2
dropdown_button2
:
^1.6.3
pointycastle
:
^3.6.1
hex
:
^0.2.0
dev_dependencies
:
# flutter_launcher_icons: ^0.9.2
...
...
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