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
0687ae07
Commit
0687ae07
authored
2 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
get onchain consts; fix batch validate membership
parent
e8acb59f
No related branches found
No related tags found
1 merge request
!27
Import cs accounts
Pipeline
#16802
failed
2 years ago
Stage: format
Stage: build_and_test
Stage: package
Changes
3
Pipelines
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/providers/generate_wallets.dart
+2
-2
2 additions, 2 deletions
lib/providers/generate_wallets.dart
lib/providers/substrate_sdk.dart
+44
-26
44 additions, 26 deletions
lib/providers/substrate_sdk.dart
lib/screens/home.dart
+1
-0
1 addition, 0 deletions
lib/screens/home.dart
with
47 additions
and
28 deletions
lib/providers/generate_wallets.dart
+
2
−
2
View file @
0687ae07
...
@@ -390,7 +390,7 @@ class GenerateWalletsProvider with ChangeNotifier {
...
@@ -390,7 +390,7 @@ class GenerateWalletsProvider with ChangeNotifier {
for
(
var
derivationNbr
in
[
for
(
var
i
=
0
;
i
<
numberScan
;
i
+=
1
)
i
])
{
for
(
var
derivationNbr
in
[
for
(
var
i
=
0
;
i
<
numberScan
;
i
+=
1
)
i
])
{
final
addressData
=
await
sub
.
sdk
.
api
.
keyring
.
addressFromMnemonic
(
final
addressData
=
await
sub
.
sdk
.
api
.
keyring
.
addressFromMnemonic
(
sub
.
ss58
,
sub
.
currencyParameters
[
'
ss58
'
]
!
,
cryptoType:
CryptoType
.
sr25519
,
cryptoType:
CryptoType
.
sr25519
,
mnemonic:
generatedMnemonic
!
,
mnemonic:
generatedMnemonic
!
,
derivePath:
'//
$derivationNbr
'
);
derivePath:
'//
$derivationNbr
'
);
...
@@ -435,7 +435,7 @@ class GenerateWalletsProvider with ChangeNotifier {
...
@@ -435,7 +435,7 @@ class GenerateWalletsProvider with ChangeNotifier {
}
}
Future
<
bool
>
scanRootBalance
(
SubstrateSdk
sub
,
int
currentChestNumber
)
async
{
Future
<
bool
>
scanRootBalance
(
SubstrateSdk
sub
,
int
currentChestNumber
)
async
{
final
addressData
=
await
sub
.
sdk
.
api
.
keyring
.
addressFromMnemonic
(
sub
.
ss58
,
final
addressData
=
await
sub
.
sdk
.
api
.
keyring
.
addressFromMnemonic
(
sub
.
currencyParameters
[
'
ss58
'
]
!
,
cryptoType:
CryptoType
.
sr25519
,
mnemonic:
generatedMnemonic
!
);
cryptoType:
CryptoType
.
sr25519
,
mnemonic:
generatedMnemonic
!
);
final
balance
=
await
sub
.
getBalance
(
addressData
.
address
!
)
.
timeout
(
final
balance
=
await
sub
.
getBalance
(
addressData
.
address
!
)
.
timeout
(
...
...
This diff is collapsed.
Click to expand it.
lib/providers/substrate_sdk.dart
+
44
−
26
View file @
0687ae07
...
@@ -29,7 +29,8 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -29,7 +29,8 @@ class SubstrateSdk with ChangeNotifier {
bool
isLoadingEndpoint
=
false
;
bool
isLoadingEndpoint
=
false
;
String
debugConnection
=
''
;
String
debugConnection
=
''
;
String
transactionStatus
=
''
;
String
transactionStatus
=
''
;
int
ss58
=
42
;
final
int
initSs58
=
42
;
Map
<
String
,
int
>
currencyParameters
=
{};
/////////////////////////////////////
/////////////////////////////////////
////////// 1: API METHODS ///////////
////////// 1: API METHODS ///////////
...
@@ -66,6 +67,11 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -66,6 +67,11 @@ class SubstrateSdk with ChangeNotifier {
return
await
sdk
.
webView
!.
evalJavascript
(
'api.query.
$call
'
);
return
await
sdk
.
webView
!.
evalJavascript
(
'api.query.
$call
'
);
}
}
Future
getStorageConst
(
String
call
)
async
{
return
(
await
sdk
.
webView
!
.
evalJavascript
(
'api.consts.
$call
'
,
wrapPromise:
false
))[
0
];
}
TxSenderData
_setSender
()
{
TxSenderData
_setSender
()
{
return
TxSenderData
(
return
TxSenderData
(
keyring
.
current
.
address
,
keyring
.
current
.
address
,
...
@@ -108,12 +114,6 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -108,12 +114,6 @@ class SubstrateSdk with ChangeNotifier {
return
0
;
return
0
;
}
}
Future
<
Map
<
String
,
dynamic
>>
getParameters
()
async
{
final
currencyParameters
=
await
getStorage
(
'parameters.parametersStorage()'
)
??
{};
return
currencyParameters
;
}
Future
<
bool
>
hasAccountConsumers
(
String
address
)
async
{
Future
<
bool
>
hasAccountConsumers
(
String
address
)
async
{
final
accountInfo
=
await
getStorage
(
'system.account("
$address
")'
);
final
accountInfo
=
await
getStorage
(
'system.account("
$address
")'
);
final
consumers
=
accountInfo
[
'consumers'
];
final
consumers
=
accountInfo
[
'consumers'
];
...
@@ -136,6 +136,8 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -136,6 +136,8 @@ class SubstrateSdk with ChangeNotifier {
// }
// }
Future
<
Map
<
String
,
double
>>
getBalance
(
String
address
)
async
{
Future
<
Map
<
String
,
double
>>
getBalance
(
String
address
)
async
{
// log.d('currencyParameters: $currencyParameters');
if
(
!
nodeConnected
)
{
if
(
!
nodeConnected
)
{
return
{
return
{
'transferableBalance'
:
0
,
'transferableBalance'
:
0
,
...
@@ -202,17 +204,6 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -202,17 +204,6 @@ class SubstrateSdk with ChangeNotifier {
return
totalAmount
;
return
totalAmount
;
}
}
Future
<
int
>
getSs58Prefix
()
async
{
final
List
res
=
await
sdk
.
webView
!.
evalJavascript
(
'api.consts.system.ss58Prefix.words'
,
wrapPromise:
false
)
??
[
42
];
ss58
=
res
[
0
];
log
.
d
(
ss58
);
return
ss58
;
}
Future
<
bool
>
isMemberGet
(
String
address
)
async
{
Future
<
bool
>
isMemberGet
(
String
address
)
async
{
return
await
idtyStatus
(
address
)
==
'Validated'
;
return
await
idtyStatus
(
address
)
==
'Validated'
;
}
}
...
@@ -268,7 +259,32 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -268,7 +259,32 @@ class SubstrateSdk with ChangeNotifier {
}
}
}
}
Future
getCurencyName
()
async
{}
// Future addressToPubkey(String address) async {
// await sdk.api.account.decodeAddress([address]);
// }
// Future pubkeyToAddress(String pubkey) async {
// await sdk.api.account.encodeAddress([pubkey]);
// }
Future
initCurrencyParameters
()
async
{
currencyParameters
[
'ss58'
]
=
await
getStorageConst
(
'system.ss58Prefix.words'
);
currencyParameters
[
'minCertForMembership'
]
=
await
getStorageConst
(
'wot.minCertForMembership.words'
);
currencyParameters
[
'newAccountPrice'
]
=
await
getStorageConst
(
'account.newAccountPrice.words'
);
currencyParameters
[
'existentialDeposit'
]
=
await
getStorageConst
(
'balances.existentialDeposit.words'
);
currencyParameters
[
'certPeriod'
]
=
await
getStorageConst
(
'cert.certPeriod.words'
);
currencyParameters
[
'certMaxByIssuer'
]
=
await
getStorageConst
(
'cert.maxByIssuer.words'
);
currencyParameters
[
'certValidityPeriod'
]
=
await
getStorageConst
(
'cert.validityPeriod.words'
);
log
.
i
(
'currencyParameters:
$currencyParameters
'
);
}
/////////////////////////////////////
/////////////////////////////////////
////// 3: SUBSTRATE CONNECTION //////
////// 3: SUBSTRATE CONNECTION //////
...
@@ -276,8 +292,8 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -276,8 +292,8 @@ class SubstrateSdk with ChangeNotifier {
Future
<
void
>
initApi
()
async
{
Future
<
void
>
initApi
()
async
{
sdkLoading
=
true
;
sdkLoading
=
true
;
await
keyring
.
init
([
s
s58
]);
await
keyring
.
init
([
initS
s58
]);
keyring
.
setSS58
(
s
s58
);
keyring
.
setSS58
(
initS
s58
);
await
sdk
.
init
(
keyring
);
await
sdk
.
init
(
keyring
);
sdkReady
=
true
;
sdkReady
=
true
;
...
@@ -356,7 +372,7 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -356,7 +372,7 @@ class SubstrateSdk with ChangeNotifier {
final
n
=
NetworkParams
();
final
n
=
NetworkParams
();
n
.
name
=
currencyName
;
n
.
name
=
currencyName
;
n
.
endpoint
=
endpoint
;
n
.
endpoint
=
endpoint
;
n
.
ss58
=
s
s58
;
n
.
ss58
=
currencyParameters
[
'ss58'
]
??
initS
s58
;
node
.
add
(
n
);
node
.
add
(
n
);
}
}
return
node
;
return
node
;
...
@@ -366,7 +382,7 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -366,7 +382,7 @@ class SubstrateSdk with ChangeNotifier {
final
nodeParams
=
NetworkParams
();
final
nodeParams
=
NetworkParams
();
nodeParams
.
name
=
currencyName
;
nodeParams
.
name
=
currencyName
;
nodeParams
.
endpoint
=
configBox
.
get
(
'customEndpoint'
);
nodeParams
.
endpoint
=
configBox
.
get
(
'customEndpoint'
);
nodeParams
.
ss58
=
s
s58
;
nodeParams
.
ss58
=
currencyParameters
[
'ss58'
]
??
initS
s58
;
return
nodeParams
;
return
nodeParams
;
}
}
...
@@ -476,7 +492,8 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -476,7 +492,8 @@ class SubstrateSdk with ChangeNotifier {
}
}
Future
<
String
>
generateMnemonic
({
String
lang
=
appLang
})
async
{
Future
<
String
>
generateMnemonic
({
String
lang
=
appLang
})
async
{
final
gen
=
await
sdk
.
api
.
keyring
.
generateMnemonic
(
ss58
);
final
gen
=
await
sdk
.
api
.
keyring
.
generateMnemonic
(
currencyParameters
[
'ss58'
]
??
initSs58
);
generatedMnemonic
=
gen
.
mnemonic
!
;
generatedMnemonic
=
gen
.
mnemonic
!
;
return
gen
.
mnemonic
!
;
return
gen
.
mnemonic
!
;
...
@@ -654,7 +671,8 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -654,7 +671,8 @@ class SubstrateSdk with ChangeNotifier {
String
?
rawParams
;
String
?
rawParams
;
final
toCerts
=
await
getCerts
(
toAddress
);
final
toCerts
=
await
getCerts
(
toAddress
);
final
currencyParameters
=
await
getParameters
();
// log.d('debug: ${currencyParameters['minCertForMembership']}');
if
(
toIdtyStatus
==
'noid'
)
{
if
(
toIdtyStatus
==
'noid'
)
{
txInfo
=
TxInfoData
(
txInfo
=
TxInfoData
(
...
@@ -665,7 +683,7 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -665,7 +683,7 @@ class SubstrateSdk with ChangeNotifier {
txOptions
=
[
toAddress
];
txOptions
=
[
toAddress
];
}
else
if
(
toIdtyStatus
==
'Validated'
||
}
else
if
(
toIdtyStatus
==
'Validated'
||
toIdtyStatus
==
'ConfirmedByOwner'
)
{
toIdtyStatus
==
'ConfirmedByOwner'
)
{
if
(
toCerts
[
0
]
>
=
currencyParameters
[
'
wotM
inCertForMembership'
]
&&
if
(
toCerts
[
0
]
>
=
currencyParameters
[
'
m
inCertForMembership'
]
!
-
1
&&
toIdtyStatus
!=
'Validated'
)
{
toIdtyStatus
!=
'Validated'
)
{
log
.
i
(
'Batch cert and membership validation'
);
log
.
i
(
'Batch cert and membership validation'
);
txInfo
=
TxInfoData
(
txInfo
=
TxInfoData
(
...
...
This diff is collapsed.
Click to expand it.
lib/screens/home.dart
+
1
−
0
View file @
0687ae07
...
@@ -167,6 +167,7 @@ class HomeScreen extends StatelessWidget {
...
@@ -167,6 +167,7 @@ class HomeScreen extends StatelessWidget {
sub
.
reload
();
sub
.
reload
();
}
else
{
}
else
{
await
sub
.
connectNode
(
ctx
);
await
sub
.
connectNode
(
ctx
);
await
sub
.
initCurrencyParameters
();
}
}
});
});
}
}
...
...
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