batch call is working for claimUd
This commit is contained in:
parent
99c559d38c
commit
2d1b3731bb
|
@ -37,15 +37,11 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
////////// 1: API METHODS ///////////
|
////////// 1: API METHODS ///////////
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
Future<String> executeCall(
|
Future<String> executeCall(TxInfoData txInfo, txOptions, String password,
|
||||||
TxInfoData txInfo, txOptions, String password) async {
|
[String? rawParams]) async {
|
||||||
try {
|
try {
|
||||||
final hash = await sdk.api.tx
|
final hash = await sdk.api.tx
|
||||||
.signAndSend(
|
.signAndSend(txInfo, txOptions, password, rawParam: rawParams)
|
||||||
txInfo,
|
|
||||||
txOptions,
|
|
||||||
password,
|
|
||||||
)
|
|
||||||
.timeout(
|
.timeout(
|
||||||
const Duration(seconds: 12),
|
const Duration(seconds: 12),
|
||||||
onTimeout: () => {},
|
onTimeout: () => {},
|
||||||
|
@ -72,16 +68,6 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return await sdk.webView!.evalJavascript('api.query.$call');
|
return await sdk.webView!.evalJavascript('api.query.$call');
|
||||||
}
|
}
|
||||||
|
|
||||||
List batchCall(TxSenderData sender, List calls) {
|
|
||||||
TxInfoData txInfo = TxInfoData(
|
|
||||||
'utility',
|
|
||||||
'batchAll',
|
|
||||||
sender,
|
|
||||||
);
|
|
||||||
|
|
||||||
return [txInfo, calls];
|
|
||||||
}
|
|
||||||
|
|
||||||
TxSenderData _setSender() {
|
TxSenderData _setSender() {
|
||||||
return TxSenderData(
|
return TxSenderData(
|
||||||
keyring.current.address,
|
keyring.current.address,
|
||||||
|
@ -625,17 +611,8 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
|
|
||||||
final globalBalance = await getBalance(fromAddress);
|
final globalBalance = await getBalance(fromAddress);
|
||||||
TxInfoData txInfo;
|
TxInfoData txInfo;
|
||||||
List txOptions;
|
List txOptions = [];
|
||||||
|
String? rawParams;
|
||||||
log.d(globalBalance);
|
|
||||||
|
|
||||||
// if (globalBalance['unclaimedUds'] != 0) {
|
|
||||||
// claimUDs(password);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// txInfo = TxInfoData(
|
|
||||||
// 'balances', amount == -1 ? 'transferAll' : 'transferKeepAlive', sender);
|
|
||||||
// txOptions = [destAddress, amount == -1 ? false : amountUnit];
|
|
||||||
|
|
||||||
if (globalBalance['unclaimedUds'] == 0) {
|
if (globalBalance['unclaimedUds'] == 0) {
|
||||||
txInfo = TxInfoData('balances',
|
txInfo = TxInfoData('balances',
|
||||||
|
@ -647,28 +624,16 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
'batchAll',
|
'batchAll',
|
||||||
sender,
|
sender,
|
||||||
);
|
);
|
||||||
|
const tx1 = 'api.tx.universalDividend.claimUds()';
|
||||||
|
final tx2 = amount == -1
|
||||||
|
? 'api.tx.balances.transferAll(false)'
|
||||||
|
: 'api.tx.balances.transferKeepAlive("$destAddress", $amountUnit)';
|
||||||
|
|
||||||
txOptions = [
|
rawParams = '[[$tx1, $tx2]]';
|
||||||
['api.tx.universalDividend.claimUds()']
|
|
||||||
];
|
|
||||||
// 'balances.transferKeepAlive($destAddress, $amountUnit)'
|
|
||||||
// amount == -1
|
|
||||||
// ? 'balances.transferAll(false)'
|
|
||||||
// : 'balances.transferKeepAlive([$destAddress, $amountUnit])'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d('yooooo: ${txInfo.module}, ${txInfo.call}, $txOptions');
|
// log.d('yooooo: ${txInfo.module}, ${txInfo.call}, $txOptions, $rawParams');
|
||||||
// Map tata = await sdk.webView!
|
return await executeCall(txInfo, txOptions, password, rawParams);
|
||||||
// .evalJavascript('api.tx.universalDividend.claimUds()',
|
|
||||||
// wrapPromise: false)
|
|
||||||
// .timeout(
|
|
||||||
// const Duration(seconds: 12),
|
|
||||||
// onTimeout: () => {},
|
|
||||||
// );
|
|
||||||
|
|
||||||
// return tata.toString();
|
|
||||||
|
|
||||||
return await executeCall(txInfo, txOptions, password);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> certify(
|
Future<String> certify(
|
||||||
|
@ -690,6 +655,7 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
final sender = _setSender();
|
final sender = _setSender();
|
||||||
TxInfoData txInfo;
|
TxInfoData txInfo;
|
||||||
List txOptions = [];
|
List txOptions = [];
|
||||||
|
String? rawParams;
|
||||||
|
|
||||||
final toCerts = await getCerts(toAddress);
|
final toCerts = await getCerts(toAddress);
|
||||||
final currencyParameters = await getParameters();
|
final currencyParameters = await getParameters();
|
||||||
|
@ -706,12 +672,15 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
|
if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
|
||||||
toIdtyStatus != 'Validated') {
|
toIdtyStatus != 'Validated') {
|
||||||
log.i('Batch cert and membership validation');
|
log.i('Batch cert and membership validation');
|
||||||
List batch = batchCall(sender, [
|
txInfo = TxInfoData(
|
||||||
'cert.addCert($fromIndex, $toIndex)',
|
'utility',
|
||||||
'identity.validateIdentity($toIndex)'
|
'batchAll',
|
||||||
]);
|
sender,
|
||||||
txInfo = batch[0];
|
);
|
||||||
txOptions = batch[1];
|
final tx1 = 'cert.addCert($fromIndex, $toIndex)';
|
||||||
|
final tx2 = 'identity.validateIdentity($toIndex)';
|
||||||
|
|
||||||
|
rawParams = '[[$tx1, $tx2]]';
|
||||||
} else {
|
} else {
|
||||||
txInfo = TxInfoData(
|
txInfo = TxInfoData(
|
||||||
'cert',
|
'cert',
|
||||||
|
@ -727,23 +696,23 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.d('Cert action: ${txInfo.call!}');
|
log.d('Cert action: ${txInfo.call!}');
|
||||||
return await executeCall(txInfo, txOptions, password);
|
return await executeCall(txInfo, txOptions, password, rawParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future claimUDs(String password) async {
|
// Future claimUDs(String password) async {
|
||||||
final sender = TxSenderData(
|
// final sender = TxSenderData(
|
||||||
keyring.current.address,
|
// keyring.current.address,
|
||||||
keyring.current.pubKey,
|
// keyring.current.pubKey,
|
||||||
);
|
// );
|
||||||
|
|
||||||
final txInfo = TxInfoData(
|
// final txInfo = TxInfoData(
|
||||||
'universalDividend',
|
// 'universalDividend',
|
||||||
'claimUds',
|
// 'claimUds',
|
||||||
sender,
|
// sender,
|
||||||
);
|
// );
|
||||||
|
|
||||||
return await executeCall(txInfo, [], password);
|
// return await executeCall(txInfo, [], password);
|
||||||
}
|
// }
|
||||||
|
|
||||||
Future<String> confirmIdentity(
|
Future<String> confirmIdentity(
|
||||||
String fromAddress, String name, String password) async {
|
String fromAddress, String name, String password) async {
|
||||||
|
|
|
@ -129,8 +129,8 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
|
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
|
||||||
if (snapshot.data == null) return const SizedBox();
|
if (snapshot.data == null) return const SizedBox();
|
||||||
String duration = '';
|
String duration = '';
|
||||||
log.d(snapshot.data!['certDelay']);
|
log.d('certDelay ${snapshot.data!['certDelay']}');
|
||||||
log.d(snapshot.data!['certRenewable']);
|
log.d('certRenewable ${snapshot.data!['certRenewable']}');
|
||||||
|
|
||||||
if (snapshot.data!['certDelay'] != null ||
|
if (snapshot.data!['certDelay'] != null ||
|
||||||
snapshot.data!['certRenewable'] != null) {
|
snapshot.data!['certRenewable'] != null) {
|
||||||
|
@ -518,7 +518,8 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
future:
|
future:
|
||||||
sub.getBalance(defaultWallet.address!),
|
sub.getBalance(defaultWallet.address!),
|
||||||
builder: (BuildContext context,
|
builder: (BuildContext context,
|
||||||
AsyncSnapshot<Map<String, double>> globalBalance) {
|
AsyncSnapshot<Map<String, double>>
|
||||||
|
globalBalance) {
|
||||||
if (globalBalance.connectionState !=
|
if (globalBalance.connectionState !=
|
||||||
ConnectionState.done ||
|
ConnectionState.done ||
|
||||||
globalBalance.hasError) {
|
globalBalance.hasError) {
|
||||||
|
@ -542,7 +543,8 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
balanceCache[defaultWallet.address!] =
|
balanceCache[defaultWallet.address!] =
|
||||||
globalBalance.data!['transferableBalance']!;
|
globalBalance
|
||||||
|
.data!['transferableBalance']!;
|
||||||
return Text(
|
return Text(
|
||||||
"${balanceCache[defaultWallet.address!]} $currencyName",
|
"${balanceCache[defaultWallet.address!]} $currencyName",
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
|
Loading…
Reference in New Issue