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
d71261d0
Commit
d71261d0
authored
2 years ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
WIP: unclaimed UD are almost calculated
parent
29754e23
No related branches found
No related tags found
1 merge request
!26
Features gdev2
Pipeline
#16697
waiting for manual action
Stage: format
Stage: build_and_test
Stage: package
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/providers/substrate_sdk.dart
+36
-24
36 additions, 24 deletions
lib/providers/substrate_sdk.dart
with
36 additions
and
24 deletions
lib/providers/substrate_sdk.dart
+
36
−
24
View file @
d71261d0
...
@@ -265,37 +265,49 @@ class SubstrateSdk with ChangeNotifier {
...
@@ -265,37 +265,49 @@ class SubstrateSdk with ChangeNotifier {
}
else
{
}
else
{
balance
=
-
1
;
balance
=
-
1
;
}
}
await
getUnclaimedUd
(
address
);
return
balance
;
return
balance
;
}
}
Future
<
double
>
getUnclaimedUd
(
String
address
)
async
{
Future
<
double
>
getUnclaimedUd
(
String
address
)
async
{
// TODO: Implement unclaimedUd evaluation
final
balanceGlobal
=
await
sdk
.
webView
!
// Pour ce faire, il vous faut requêter cinq éléments de storage :
.
evalJavascript
(
'api.query.system.account("
$address
")'
);
// system.account(address)
// identity.identityIndexOf(address)
// identity.identities(idtyIndex)
// universalDividend.currentUdIndex()
// universalDividend.pastReevals()
// const api = await ApiPromise.create(...);
// const { data: balance } = await api.query.system.account(address);
// const idtyIndex = await api.query.identity.identityIndexOf(address);
// const { data: idtyData } = await api.query.identity.identies(idtyIndex);
// const currentUdIndex = await api.query.universalDividend.currentUdIndex();
// const pastReevals = await api.query.universalDividend.pastReevals();
// let newUdsAmount = computeClaimUds(currentUdIndex, idtyData.firstEligibleUd, pastReevals);
// let transferableBalance = balance.free + newUdsAmount;
// let potentialBalance = balance.reserved + transferableBalance;
double
balance
=
0.0
;
final
idtyIndex
=
await
sdk
.
webView
!
.
evalJavascript
(
'api.query.identity.identityIndexOf("
$address
")'
);
final
idtyData
=
await
sdk
.
webView
!
.
evalJavascript
(
'api.query.identity.identities(
$idtyIndex
)'
);
final
brutBalance
=
await
sdk
.
api
.
account
.
queryBalance
(
address
);
final
int
currentUdIndex
=
int
.
parse
(
await
sdk
.
webView
!
// log.d(brutBalance?.toJson());
.
evalJavascript
(
'api.query.universalDividend.currentUdIndex()'
));
balance
=
int
.
parse
(
brutBalance
!.
freeBalance
)
/
100
;
return
balance
;
final
List
pastReevals
=
await
sdk
.
webView
!
.
evalJavascript
(
'api.query.universalDividend.pastReevals()'
);
log
.
d
(
'DEBUGG
${getShortPubkey(address)}
:
$balanceGlobal
|---|
$idtyIndex
|---|
$idtyData
|---|
$currentUdIndex
|---|
$pastReevals
'
);
final
int
newUdsAmount
=
_computeClaimUds
(
currentUdIndex
,
idtyData
?
[
'data'
]
?
[
'firstEligibleUd'
]
??
0
,
pastReevals
);
final
double
transferableBalance
=
(
balanceGlobal
[
'data'
][
'free'
]
+
newUdsAmount
)
/
100
;
final
double
potentialBalance
=
(
balanceGlobal
[
'data'
][
'reserved'
]
+
transferableBalance
)
/
100
;
log
.
i
(
'transferableBalance:
$transferableBalance
--- potentialBalance:
$potentialBalance
'
);
return
transferableBalance
;
}
int
_computeClaimUds
(
int
currentUdIndex
,
int
firstEligibleUd
,
List
pastReevals
)
{
// TODO: Implement _computeClaimUds
log
.
d
(
'DEBUGGG:
$currentUdIndex
-
$firstEligibleUd
-
$pastReevals
'
);
return
0
;
}
}
Future
<
double
>
subscribeBalance
(
String
address
,
{
bool
isUd
=
false
})
async
{
Future
<
double
>
subscribeBalance
(
String
address
,
{
bool
isUd
=
false
})
async
{
...
...
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