Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • DanBaDo/ginkgo
  • flodef/ginkgo
  • zicmama/ginkgo
  • vjrj/ginkgo
  • pokapow/ginkgo
  • weblate/ginkgo
6 results
Show changes
Showing
with 3307 additions and 201 deletions
import 'dart:typed_data';
import 'package:durt/durt.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:pointycastle/export.dart';
import 'package:polkadart_keyring/polkadart_keyring.dart';
// From:
// https://polkadot.js.org/docs/util-crypto/examples/validate-address/
bool isValidV2Address(String address) {
try {
final Keyring keyring = Keyring();
keyring.encodeAddress(
isHex(address) ? hexToU8a(address) : keyring.decodeAddress(address));
return true;
} catch (error) {
return false;
}
}
Uint8List hexToU8a(String hexString) {
hexString = hexString.startsWith('0x') ? hexString.substring(2) : hexString;
if (hexString.length % 2 != 0) {
hexString = '0$hexString';
}
return Uint8List.fromList(List<int>.generate(hexString.length ~/ 2, (int i) {
return int.parse(hexString.substring(i * 2, i * 2 + 2), radix: 16);
}));
}
bool isHex(String value, [int bitLength = -1]) {
final RegExp hexRegEx = RegExp(r'^0x[a-fA-F0-9]+$');
return hexRegEx.hasMatch(value) &&
(bitLength == -1 || value.length == 2 + bitLength ~/ 4);
}
String addressFromV1Pubkey(String pubkey) {
final Keyring keyring = Keyring();
final List<int> pubkeyByte = Base58Decode(pubkey);
final String address = keyring.encodeAddress(pubkeyByte);
return address;
}
String v1pubkeyFromAddress(String address) {
final Keyring keyring = Keyring();
final Uint8List publicKeyBytes = keyring.decodeAddress(address);
final String publicKey = Base58Encode(publicKeyBytes);
return publicKey;
}
Keyring keyringFromV1Seed(Uint8List seed) {
final Keyring keyring = Keyring();
final KeyPair keypair = KeyPair.ed25519.fromSeed(seed);
keyring.add(keypair);
return keyring;
}
Keyring keyringFromSeed(Uint8List seed) {
final Keyring keyring = Keyring();
final KeyPair keypair = KeyPair.sr25519.fromSeed(seed);
keyring.add(keypair);
return keyring;
}
class AuthDataV1 {
AuthDataV1(this.password, this.salt);
String password;
String salt;
}
class AuthDataV2 {
AuthDataV2(this.mnemonic, this.meta);
String mnemonic;
String meta;
}
class AuthData {
AuthData({this.v1, this.v2});
AuthDataV1? v1;
AuthDataV2? v2;
}
Future<KeyPair> createPair(AuthData data, Keyring keyring) async {
if (data.v1 != null) {
final List<int> password = data.v1!.password.codeUnits;
final String salt = data.v1!.salt;
final Uint8List passwordU8a = Uint8List.fromList(password);
final Uint8List saltU8a = Uint8List.fromList(salt.codeUnits);
final Scrypt scrypt = Scrypt()
..init(ScryptParameters(4096, 16, 1, 32, saltU8a));
final Uint8List seedBytes = scrypt.process(passwordU8a);
final String seedHex = Base58Encode(seedBytes);
final KeyPair keyPair = await keyring.fromUri(seedHex,
password: data.v1!.password, keyPairType: KeyPairType.ed25519);
return keyPair;
} else if (data.v2 != null) {
final KeyPair keyPair = await keyring.fromUri(data.v2!.mnemonic,
password: data.v2!.meta, keyPairType: KeyPairType.sr25519);
return keyPair;
} else {
throw Exception('Data format not recognized');
}
}
// From durt
String mnemonicGenerate({String lang = 'english'}) {
final List<String> supportedLanguages = <String>[
'english',
'french',
'italian',
'spanish'
];
if (!supportedLanguages.contains(lang)) {
throw ArgumentError('Unsupported language');
}
final String mnemonic = generateMnemonic(lang: lang);
return mnemonic;
}
// From:
// https://polkadot.js.org/docs/keyring/start/create
Future<KeyPair> addPair() async {
final String mnemonic = mnemonicGenerate();
final Keyring keyring = Keyring();
// create & add the pair to the keyring with the type
// TODOAdd some additional metadata as in polkadot-js
final KeyPair pair =
await keyring.fromUri(mnemonic, keyPairType: KeyPairType.sr25519);
return pair;
}
/*
Future<Map<String, dynamic>> createAccount(
AuthData data, Keyring keyring) async {
final KeyPair pair = await createPair(data, keyring);
final String? publicKeyV1 = pair.keyPairType == KeyPairType.ed25519
? Base58Encode(pair.publicKey.bytes)
: null;
final String name = data.v2?.meta ??
(publicKeyV1 != null
? formatPubkey(publicKeyV1)
: formatAddress(pair.address));
Map<String, dynamic> accountMeta = {
'name': name,
'publicKeyV1': publicKeyV1,
'genesisHash':
...data.v2?.meta ?? {}
};
Account account = Account(pair.address, pair.publicKey, accountMeta);
pair.setMeta(account.meta);
return {'pair': pair, 'account': account};
}
String formatAddress(String value) {
if (value.isEmpty) {
return '';
}
if (value.length < 12) {
return '?';
}
return '${value.substring(0, 6)}\u2026${value.substring(value.length - 6)}';
}
String formatPubkey(String value) {
if (value.isEmpty) {
return '';
}
if (value.length < 12) {
return '?';
}
return '${value.substring(0, 4)}\u2026${value.substring(value.length - 4)}';
}
*/
// While polkadart doesn't support web
// https://github.com/leonardocustodio/polkadart/issues/297
String addressFromV1Pubkey(String pubKey) => '';
class NodeCheckResult {
NodeCheckResult({required this.latency, required this.currentBlock});
final Duration latency;
final int currentBlock;
}
import '../data/models/node.dart';
class PayResult {
PayResult({
required this.message,
this.node,
this.progressStream,
});
final Node? node;
final String message;
final Stream<String>? progressStream;
}
import 'package:flutter/foundation.dart';
import 'package:tuple/tuple.dart';
import '../data/models/contact.dart';
import '../data/models/node.dart';
import '../data/models/transaction_state.dart';
import 'api.dart';
import 'duniter_datapod_helper.dart';
import 'duniter_endpoint_helper.dart';
import 'duniter_indexer_helper.dart';
import 'pay_result.dart';
import 'transactions_v1_parser.dart';
import 'transactions_v2_parser.dart';
abstract class DuniterService {
Future<Contact> getProfile(String pubKey,
{bool onlyProfile = false, bool resize = true, bool complete = false});
Future<List<Contact>> getProfiles(List<String> pubKeys);
Future<List<Contact>> searchWot(String searchPatternRaw);
Future<List<Contact>> searchProfiles(
{required String searchTermLower,
required String searchTerm,
required String searchTermCapitalized});
Future<Tuple2<Map<String, dynamic>?, Node>> getHistoryAndBalance(
String pubKeyRaw,
{int? pageSize = 10,
int? from,
int? to,
String? cursor,
required bool isConnected});
Future<TransactionState> transactionsParser(
Map<String, dynamic> txData, TransactionState state, String myPubKeyRaw);
Future<PayResult> pay(
{required List<String> to, required double amount, String? comment});
Future<String?> getProfileUserName(String pubKey);
Future<bool> createOrUpdateProfile(String name);
Future<bool> deleteProfile();
}
class DuniterServiceV1 implements DuniterService {
@override
Future<Contact> getProfile(String pubKey,
{bool onlyProfile = false, bool resize = true, bool complete = false}) {
return getProfileV1(pubKey, onlyCPlusProfile: onlyProfile, resize: resize);
}
@override
Future<List<Contact>> searchWot(String searchPatternRaw) {
return searchWotV1(searchPatternRaw);
}
@override
Future<List<Contact>> searchProfiles(
{required String searchTermLower,
required String searchTerm,
required String searchTermCapitalized}) {
return searchProfilesV1(
searchTermLower: searchTermLower,
searchTerm: searchTerm,
searchTermCapitalized: searchTermCapitalized);
}
@override
Future<List<Contact>> getProfiles(List<String> pubKeys) {
throw UnimplementedError();
}
@override
Future<Tuple2<Map<String, dynamic>?, Node>> getHistoryAndBalance(
String pubKeyRaw,
{int? pageSize = 10,
int? from,
int? to,
String? cursor,
required bool isConnected}) {
return getHistoryAndBalanceV1(pubKeyRaw,
pageSize: pageSize,
from: from,
to: to,
cursor: cursor,
isConnected: isConnected);
}
@override
Future<TransactionState> transactionsParser(
Map<String, dynamic> txData, TransactionState state, String myPubKeyRaw) {
return transactionsV1Parser(txData, state, myPubKeyRaw);
}
@override
Future<PayResult> pay(
{required List<String> to, required double amount, String? comment}) {
return payV1(to: to, amount: amount, comment: comment);
}
@override
Future<bool> createOrUpdateProfile(String name) {
return createOrUpdateProfileV1(name);
}
@override
Future<bool> deleteProfile() {
return deleteProfileV1();
}
@override
Future<String?> getProfileUserName(String pubKey) {
return getProfileUserNameV1(pubKey);
}
}
class DuniterServiceV2 implements DuniterService {
@override
Future<Contact> getProfile(String pubKey,
{bool onlyProfile = false, bool resize = true, bool complete = false}) {
return getProfileV2(pubKey, onlyProfile: onlyProfile, complete: complete);
}
@override
Future<List<Contact>> getProfiles(List<String> pubKeys) {
return getProfilesV2(pubKeys: pubKeys);
}
@override
Future<List<Contact>> searchWot(String searchPattern) {
return searchWotV2('.*$searchPattern.*');
}
@override
Future<List<Contact>> searchProfiles(
{required String searchTermLower,
required String searchTerm,
required String searchTermCapitalized}) {
return searchProfilesV2(
searchTermLower: searchTermLower,
searchTerm: searchTerm,
searchTermCapitalized: searchTermCapitalized);
}
@override
Future<Tuple2<Map<String, dynamic>?, Node>> getHistoryAndBalance(
String pubKeyRaw,
{int? pageSize = 10,
int? from,
int? to,
String? cursor,
required bool isConnected}) {
return getHistoryAndBalanceV2(pubKeyRaw,
pageSize: pageSize,
from: from,
to: to,
cursor: cursor,
isConnected: isConnected);
}
@override
Future<TransactionState> transactionsParser(
Map<String, dynamic> txData, TransactionState state, String myPubKeyRaw) {
return transactionsV2Parser(txData, state, myPubKeyRaw);
}
@override
Future<PayResult> pay(
{required List<String> to, required double amount, String? comment}) {
return payV2(to: to, amount: amount, comment: comment);
}
@override
Future<bool> createOrUpdateProfile(String name) {
return createOrUpdateProfileV2(name);
}
@override
Future<bool> deleteProfile() {
return deleteProfileV2();
}
@override
Future<String?> getProfileUserName(String pubKey) async {
final Contact c = await getProfileV2(pubKey, onlyProfile: true);
return c.name;
}
}
class ServiceManager with ChangeNotifier {
ServiceManager({required bool initialIsV2})
: _currentService = initialIsV2 ? DuniterServiceV2() : DuniterServiceV1();
DuniterService _currentService;
final DuniterService _v1Service = DuniterServiceV1();
final DuniterService _v2Service = DuniterServiceV2();
DuniterService get current => _currentService;
void updateService(bool useV2) {
_currentService = useV2 ? _v2Service : _v1Service;
notifyListeners();
}
}
import 'dart:async';
import 'dart:typed_data';
import 'package:easy_localization/easy_localization.dart';
import 'package:polkadart/polkadart.dart';
import 'package:polkadart/scale_codec.dart';
import 'package:polkadart_keyring/polkadart_keyring.dart';
import '../data/models/node.dart';
import '../generated/gdev/gdev.dart';
import '../generated/gdev/types/gdev_runtime/runtime_call.dart';
import '../generated/gdev/types/primitive_types/h256.dart';
import '../ui/logger.dart';
import 'duniter_endpoint_helper.dart';
class SignAndSendResult {
SignAndSendResult({
this.node,
required this.progressStream,
});
final Node? node;
final Stream<String> progressStream;
}
Future<SignAndSendResult> signAndSend(Node node, Provider provider,
Gdev polkadot, KeyPair wallet, RuntimeCall call,
{required String Function(String statusType) messageTransformer,
Duration timeout = defPolkadotTimeout}) async {
final StreamController<String> progressController =
StreamController<String>();
try {
progressController.add(messageTransformer('building_transaction'));
final RuntimeVersion runtimeVersion =
await polkadot.rpc.state.getRuntimeVersion();
final int currentBlockNumber = (await polkadot.query.system.number()) - 1;
final H256 currentBlockHash =
await polkadot.query.system.blockHash(currentBlockNumber);
final int nonce =
await polkadot.rpc.system.accountNextIndex(wallet.address);
final H256 genesisHash = await polkadot.query.system.blockHash(0);
final Uint8List encodedCall = call.encode();
final Uint8List payload = SigningPayload(
method: encodedCall,
specVersion: runtimeVersion.specVersion,
transactionVersion: runtimeVersion.transactionVersion,
genesisHash: encodeHex(genesisHash),
blockHash: encodeHex(currentBlockHash),
blockNumber: currentBlockNumber,
eraPeriod: 64,
nonce: nonce,
tip: 0)
.encode(polkadot.registry);
final Uint8List signature = wallet.sign(payload);
final Uint8List extrinsic = ExtrinsicPayload(
signer: wallet.bytes(),
method: encodedCall,
signature: signature,
eraPeriod: 64,
blockNumber: currentBlockNumber,
nonce: nonce,
tip: 0)
.encode(polkadot.registry, SignatureType.ed25519);
final AuthorApi<Provider> author = AuthorApi<Provider>(provider);
progressController.add(messageTransformer('submitting_transaction'));
await author.submitAndWatchExtrinsic(
extrinsic,
(ExtrinsicStatus status) {
final String transformedMessage = messageTransformer(status.type);
progressController.add(transformedMessage);
if (<String>[
'finalized',
'dropped',
'invalid',
'usurped',
].contains(status.type)) {
progressController.close();
}
},
).timeout(timeout);
} catch (e, stacktrace) {
final String errorMessage = messageTransformer('error');
progressController.add(errorMessage);
loggerDev(errorMessage, error: e, stackTrace: stacktrace);
progressController.close();
}
return SignAndSendResult(
node: node,
progressStream: progressController.stream,
);
}
Future<String> signAndSendOld(Gdev polkadot, KeyPair wallet, RuntimeCall call,
Provider provider, Completer<String> result, Duration timeout) async {
final RuntimeVersion runtimeVersion =
await polkadot.rpc.state.getRuntimeVersion();
final int currentBlockNumber = (await polkadot.query.system.number()) - 1;
final H256 currentBlockHash =
await polkadot.query.system.blockHash(currentBlockNumber);
final int nonce = await polkadot.rpc.system.accountNextIndex(wallet.address);
final H256 genesisHash = await polkadot.query.system.blockHash(0);
final Uint8List encodedCall = call.encode();
final Uint8List payload = SigningPayload(
method: encodedCall,
specVersion: runtimeVersion.specVersion,
transactionVersion: runtimeVersion.transactionVersion,
genesisHash: encodeHex(genesisHash),
blockHash: encodeHex(currentBlockHash),
blockNumber: currentBlockNumber,
eraPeriod: 64,
nonce: nonce,
tip: 0)
.encode(polkadot.registry);
final Uint8List signature = wallet.sign(payload);
final Uint8List extrinsic = ExtrinsicPayload(
signer: wallet.bytes(),
method: encodedCall,
signature: signature,
eraPeriod: 64,
blockNumber: currentBlockNumber,
nonce: nonce,
tip: 0)
.encode(polkadot.registry, SignatureType.ed25519);
final AuthorApi<Provider> author = AuthorApi<Provider>(provider);
await author.submitAndWatchExtrinsic(extrinsic, (ExtrinsicStatus status) {
switch (status.type) {
case 'finalized':
result.complete('');
break;
case 'dropped':
result.complete(tr('op_dropped'));
break;
case 'invalid':
result.complete(tr('op_invalid'));
break;
case 'usurped':
result.complete(tr('op_usurped'));
break;
case 'future':
break;
case 'ready':
break;
case 'inBlock':
break;
case 'broadcast':
break;
default:
result.complete('Unexpected transaction status: ${status.type}.');
loggerDev('Unexpected transaction status: ${status.type}.');
break;
}
}).timeout(timeout);
return result.future;
}
......@@ -5,11 +5,12 @@ import '../data/models/transaction.dart';
import '../data/models/transaction_state.dart';
import '../data/models/transaction_type.dart';
import '../ui/contacts_cache.dart';
import '../ui/logger.dart';
import 'g1_helper.dart';
final RegExp exp = RegExp(r'\((.*?)\)');
Future<TransactionState> transactionParser(
Future<TransactionState> transactionsParser(
String txData, List<Transaction> pendingTransactions) async {
final Map<String, dynamic> parsedTxData =
json.decode(txData) as Map<String, dynamic>;
......@@ -43,8 +44,10 @@ Future<TransactionState> transactionParser(
logger('Timestamp: $timestamp');
logger('Fecha: $txDate');
} */
final Contact fromC = getContactCache(pubKey: address2!);
final Contact toC = getContactCache(pubKey: address1!);
final Contact fromC =
getContactCache(simpleContact: Contact(pubKey: address2!));
final Contact toC =
getContactCache(simpleContact: Contact(pubKey: address1!));
tx.insert(
0,
......@@ -63,15 +66,7 @@ Future<TransactionState> transactionParser(
lastChecked: DateTime.now());
}
Contact getContactCache({required String pubKey}) {
final Contact contact =
ContactsCache().getCachedContact(pubKey, false, true) ??
Contact(pubKey: pubKey);
assert(contact.hasAvatar == false);
return contact;
}
Future<TransactionState> transactionsGvaParser(Map<String, dynamic> txData,
Future<TransactionState> transactionsV1Parser(Map<String, dynamic> txData,
TransactionState state, String myPubKeyRaw) async {
final String myPubKey = extractPublicKey(myPubKeyRaw);
// Balance
......@@ -121,6 +116,7 @@ Future<TransactionState> transactionsGvaParser(Map<String, dynamic> txData,
txs.insert(0, tx);
}
loggerDev('Balance $amount');
return state.copyWith(
transactions: txs,
balance: amount,
......@@ -157,7 +153,8 @@ Future<Transaction> _txGvaParse(
// Extract the recipient from each output
final String outputS = output as String;
final String? recipient = exp.firstMatch(outputS)!.group(1);
final Contact recipientContact = getContactCache(pubKey: recipient!);
final Contact recipientContact =
getContactCache(simpleContact: Contact(pubKey: recipient!));
recipients.add(recipientContact);
final double outputAmount = double.parse(outputS.split(':')[0]);
......@@ -184,14 +181,15 @@ Future<Transaction> _txGvaParse(
final dynamic writtenTime = tx['writtenTime'];
final DateTime time = writtenTime == null
? DateTime.now()
: DateTime.fromMillisecondsSinceEpoch((writtenTime as int) * 1000);
: DateTime.fromMillisecondsSinceEpoch((writtenTime as int) * 1000,
isUtc: true);
if (isSent) {
amount = -amount;
}
// Comment
final String comment = tx['comment'] as String;
final Contact fromC = getContactCache(pubKey: from);
final Contact fromC = getContactCache(simpleContact: Contact(pubKey: from));
return Transaction(
type: type,
......
import 'dart:async';
import '../data/models/contact.dart';
import '../data/models/transaction.dart';
import '../data/models/transaction_state.dart';
import '../data/models/transaction_type.dart';
import '../ui/contacts_cache.dart';
import '../ui/logger.dart';
import 'g1_v2_helper.dart';
Future<TransactionState> transactionsV2Parser(
Map<String, dynamic> jsonData,
TransactionState currentState,
String pubKeyRaw,
) async {
final String accountAddress = addressFromV1PubkeyFaiSafe(pubKeyRaw);
if (jsonData == null || jsonData.isEmpty) {
return currentState.copyWith(
balance: 0.0,
transactions: <Transaction>[],
lastChecked: DateTime.now(),
);
}
final List<dynamic>? accounts = jsonData['account'] as List<dynamic>?;
if (accounts == null || accounts.isEmpty) {
return currentState.copyWith(
balance: 0.0,
transactions: <Transaction>[],
lastChecked: DateTime.now(),
);
}
final Map<String, dynamic>? account = accounts.firstWhere(
(dynamic acc) => (acc as Map<String, dynamic>)['id'] == accountAddress,
orElse: () => null,
) as Map<String, dynamic>?;
if (account == null) {
return currentState.copyWith(
balance: 0.0,
transactions: <Transaction>[],
lastChecked: DateTime.now(),
);
}
final double balance = (jsonData['balance'] as BigInt?)?.toDouble() ?? 0.0;
final List<Transaction> issuedTransactions = await _parseTransactions(
account['transfersIssued'] as List<dynamic>? ?? <dynamic>[],
TransactionType.sent,
accountAddress,
);
final List<Transaction> receivedTransactions = await _parseTransactions(
account['transfersReceived'] as List<dynamic>? ?? <dynamic>[],
TransactionType.received,
accountAddress,
);
final List<Transaction> allTransactions = <Transaction>[
...receivedTransactions,
...issuedTransactions
];
allTransactions
.sort((Transaction a, Transaction b) => b.time.compareTo(a.time));
return currentState.copyWith(
balance: balance,
transactions: allTransactions,
lastChecked: DateTime.now(),
);
}
Future<List<Transaction>> _parseTransactions(
List<dynamic> rawTransactions,
TransactionType type,
String accountAddress,
) async {
final List<Transaction> transactions = <Transaction>[];
for (final dynamic rawTx in rawTransactions) {
try {
final Map<String, dynamic> txData = rawTx as Map<String, dynamic>;
final String from =
(txData['from'] as Map<String, dynamic>)['id'] as String;
final String to = (txData['to'] as Map<String, dynamic>)['id'] as String;
final DateTime time = DateTime.parse(txData['timestamp'] as String);
double amount = (txData['amount'] as num).toDouble();
final Map<String, dynamic>? commentRaw =
txData['comment'] as Map<String, dynamic>?;
final String? comment =
commentRaw != null ? commentRaw['remark'] as String : null;
final Contact fromContact =
getContactCache(simpleContact: Contact.withAddress(address: from));
final Contact toContact =
getContactCache(simpleContact: Contact.withAddress(address: to));
if (type == TransactionType.sent) {
amount = -amount;
}
final Transaction transaction = Transaction(
type: type,
from: fromContact,
to: toContact,
amount: amount,
comment: comment ?? '',
time: time,
);
transactions.add(transaction);
} catch (e, st) {
loggerDev('Error parsing transaction $rawTx', error: e, stackTrace: st);
rethrow;
}
}
return transactions;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i37;
import 'package:polkadart/polkadart.dart' as _i1;
import 'pallets/account.dart' as _i33;
import 'pallets/atomic_swap.dart' as _i28;
import 'pallets/authority_discovery.dart' as _i19;
import 'pallets/authority_members.dart' as _i12;
import 'pallets/authorship.dart' as _i13;
import 'pallets/babe.dart' as _i4;
import 'pallets/balances.dart' as _i7;
import 'pallets/certification.dart' as _i26;
import 'pallets/distance.dart' as _i27;
import 'pallets/grandpa.dart' as _i17;
import 'pallets/historical.dart' as _i15;
import 'pallets/identity.dart' as _i24;
import 'pallets/im_online.dart' as _i18;
import 'pallets/membership.dart' as _i25;
import 'pallets/multisig.dart' as _i29;
import 'pallets/offences.dart' as _i14;
import 'pallets/oneshot_account.dart' as _i9;
import 'pallets/parameters.dart' as _i6;
import 'pallets/preimage.dart' as _i21;
import 'pallets/provide_randomness.dart' as _i30;
import 'pallets/proxy.dart' as _i31;
import 'pallets/quota.dart' as _i10;
import 'pallets/scheduler.dart' as _i3;
import 'pallets/session.dart' as _i16;
import 'pallets/smith_members.dart' as _i11;
import 'pallets/sudo.dart' as _i20;
import 'pallets/system.dart' as _i2;
import 'pallets/technical_committee.dart' as _i22;
import 'pallets/timestamp.dart' as _i5;
import 'pallets/transaction_payment.dart' as _i8;
import 'pallets/treasury.dart' as _i32;
import 'pallets/universal_dividend.dart' as _i23;
import 'pallets/upgrade_origin.dart' as _i34;
import 'pallets/utility.dart' as _i35;
import 'pallets/wot.dart' as _i36;
class Queries {
Queries(_i1.StateApi api)
: system = _i2.Queries(api),
scheduler = _i3.Queries(api),
babe = _i4.Queries(api),
timestamp = _i5.Queries(api),
parameters = _i6.Queries(api),
balances = _i7.Queries(api),
transactionPayment = _i8.Queries(api),
oneshotAccount = _i9.Queries(api),
quota = _i10.Queries(api),
smithMembers = _i11.Queries(api),
authorityMembers = _i12.Queries(api),
authorship = _i13.Queries(api),
offences = _i14.Queries(api),
historical = _i15.Queries(api),
session = _i16.Queries(api),
grandpa = _i17.Queries(api),
imOnline = _i18.Queries(api),
authorityDiscovery = _i19.Queries(api),
sudo = _i20.Queries(api),
preimage = _i21.Queries(api),
technicalCommittee = _i22.Queries(api),
universalDividend = _i23.Queries(api),
identity = _i24.Queries(api),
membership = _i25.Queries(api),
certification = _i26.Queries(api),
distance = _i27.Queries(api),
atomicSwap = _i28.Queries(api),
multisig = _i29.Queries(api),
provideRandomness = _i30.Queries(api),
proxy = _i31.Queries(api),
treasury = _i32.Queries(api);
final _i2.Queries system;
final _i3.Queries scheduler;
final _i4.Queries babe;
final _i5.Queries timestamp;
final _i6.Queries parameters;
final _i7.Queries balances;
final _i8.Queries transactionPayment;
final _i9.Queries oneshotAccount;
final _i10.Queries quota;
final _i11.Queries smithMembers;
final _i12.Queries authorityMembers;
final _i13.Queries authorship;
final _i14.Queries offences;
final _i15.Queries historical;
final _i16.Queries session;
final _i17.Queries grandpa;
final _i18.Queries imOnline;
final _i19.Queries authorityDiscovery;
final _i20.Queries sudo;
final _i21.Queries preimage;
final _i22.Queries technicalCommittee;
final _i23.Queries universalDividend;
final _i24.Queries identity;
final _i25.Queries membership;
final _i26.Queries certification;
final _i27.Queries distance;
final _i28.Queries atomicSwap;
final _i29.Queries multisig;
final _i30.Queries provideRandomness;
final _i31.Queries proxy;
final _i32.Queries treasury;
}
class Extrinsics {
Extrinsics();
final _i2.Txs system = _i2.Txs();
final _i33.Txs account = _i33.Txs();
final _i3.Txs scheduler = _i3.Txs();
final _i4.Txs babe = _i4.Txs();
final _i5.Txs timestamp = _i5.Txs();
final _i7.Txs balances = _i7.Txs();
final _i9.Txs oneshotAccount = _i9.Txs();
final _i11.Txs smithMembers = _i11.Txs();
final _i12.Txs authorityMembers = _i12.Txs();
final _i16.Txs session = _i16.Txs();
final _i17.Txs grandpa = _i17.Txs();
final _i18.Txs imOnline = _i18.Txs();
final _i20.Txs sudo = _i20.Txs();
final _i34.Txs upgradeOrigin = _i34.Txs();
final _i21.Txs preimage = _i21.Txs();
final _i22.Txs technicalCommittee = _i22.Txs();
final _i23.Txs universalDividend = _i23.Txs();
final _i24.Txs identity = _i24.Txs();
final _i26.Txs certification = _i26.Txs();
final _i27.Txs distance = _i27.Txs();
final _i28.Txs atomicSwap = _i28.Txs();
final _i29.Txs multisig = _i29.Txs();
final _i30.Txs provideRandomness = _i30.Txs();
final _i31.Txs proxy = _i31.Txs();
final _i35.Txs utility = _i35.Txs();
final _i32.Txs treasury = _i32.Txs();
}
class Constants {
Constants();
final _i2.Constants system = _i2.Constants();
final _i3.Constants scheduler = _i3.Constants();
final _i4.Constants babe = _i4.Constants();
final _i5.Constants timestamp = _i5.Constants();
final _i7.Constants balances = _i7.Constants();
final _i8.Constants transactionPayment = _i8.Constants();
final _i10.Constants quota = _i10.Constants();
final _i11.Constants smithMembers = _i11.Constants();
final _i12.Constants authorityMembers = _i12.Constants();
final _i17.Constants grandpa = _i17.Constants();
final _i18.Constants imOnline = _i18.Constants();
final _i22.Constants technicalCommittee = _i22.Constants();
final _i23.Constants universalDividend = _i23.Constants();
final _i36.Constants wot = _i36.Constants();
final _i24.Constants identity = _i24.Constants();
final _i25.Constants membership = _i25.Constants();
final _i26.Constants certification = _i26.Constants();
final _i27.Constants distance = _i27.Constants();
final _i28.Constants atomicSwap = _i28.Constants();
final _i29.Constants multisig = _i29.Constants();
final _i30.Constants provideRandomness = _i30.Constants();
final _i31.Constants proxy = _i31.Constants();
final _i35.Constants utility = _i35.Constants();
final _i32.Constants treasury = _i32.Constants();
}
class Rpc {
const Rpc({
required this.state,
required this.system,
});
final _i1.StateApi state;
final _i1.SystemApi system;
}
class Registry {
Registry();
final int extrinsicVersion = 4;
List getSignedExtensionTypes() {
return ['CheckMortality', 'CheckNonce', 'ChargeTransactionPayment'];
}
List getSignedExtensionExtra() {
return [
'CheckSpecVersion',
'CheckTxVersion',
'CheckGenesis',
'CheckMortality'
];
}
}
class Gdev {
Gdev._(
this._provider,
this.rpc,
) : query = Queries(rpc.state),
constant = Constants(),
tx = Extrinsics(),
registry = Registry();
factory Gdev(_i1.Provider provider) {
final rpc = Rpc(
state: _i1.StateApi(provider),
system: _i1.SystemApi(provider),
);
return Gdev._(
provider,
rpc,
);
}
factory Gdev.url(Uri url) {
final provider = _i1.Provider.fromUri(url);
return Gdev(provider);
}
final _i1.Provider _provider;
final Queries query;
final Constants constant;
final Rpc rpc;
final Extrinsics tx;
final Registry registry;
_i37.Future connect() async {
return await _provider.connect();
}
_i37.Future disconnect() async {
return await _provider.disconnect();
}
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import '../types/gdev_runtime/runtime_call.dart' as _i1;
import '../types/pallet_duniter_account/pallet/call.dart' as _i2;
class Txs {
const Txs();
/// Unlink the identity associated with the account.
_i1.RuntimeCall unlinkIdentity() {
final _call = _i2.Call.unlinkIdentity;
return _i1.RuntimeCall.values.account(_call);
}
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5;
import 'dart:typed_data' as _i6;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i4;
import '../types/gdev_runtime/runtime_call.dart' as _i7;
import '../types/pallet_atomic_swap/balance_swap_action.dart' as _i8;
import '../types/pallet_atomic_swap/pallet/call.dart' as _i9;
import '../types/pallet_atomic_swap/pending_swap.dart' as _i3;
import '../types/sp_core/crypto/account_id32.dart' as _i2;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageDoubleMap<_i2.AccountId32, List<int>, _i3.PendingSwap>
_pendingSwaps =
const _i1.StorageDoubleMap<_i2.AccountId32, List<int>, _i3.PendingSwap>(
prefix: 'AtomicSwap',
storage: 'PendingSwaps',
valueCodec: _i3.PendingSwap.codec,
hasher1: _i1.StorageHasher.twoxx64Concat(_i2.AccountId32Codec()),
hasher2: _i1.StorageHasher.blake2b128Concat(_i4.U8ArrayCodec(32)),
);
_i5.Future<_i3.PendingSwap?> pendingSwaps(
_i2.AccountId32 key1,
List<int> key2, {
_i1.BlockHash? at,
}) async {
final hashedKey = _pendingSwaps.hashedKeyFor(
key1,
key2,
);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _pendingSwaps.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Returns the storage key for `pendingSwaps`.
_i6.Uint8List pendingSwapsKey(
_i2.AccountId32 key1,
List<int> key2,
) {
final hashedKey = _pendingSwaps.hashedKeyFor(
key1,
key2,
);
return hashedKey;
}
/// Returns the storage map key prefix for `pendingSwaps`.
_i6.Uint8List pendingSwapsMapPrefix(_i2.AccountId32 key1) {
final hashedKey = _pendingSwaps.mapPrefix(key1);
return hashedKey;
}
}
class Txs {
const Txs();
/// Register a new atomic swap, declaring an intention to send funds from origin to target
/// on the current blockchain. The target can claim the fund using the revealed proof. If
/// the fund is not claimed after `duration` blocks, then the sender can cancel the swap.
///
/// The dispatch origin for this call must be _Signed_.
///
/// - `target`: Receiver of the atomic swap.
/// - `hashed_proof`: The blake2_256 hash of the secret proof.
/// - `balance`: Funds to be sent from origin.
/// - `duration`: Locked duration of the atomic swap. For safety reasons, it is recommended
/// that the revealer uses a shorter duration than the counterparty, to prevent the
/// situation where the revealer reveals the proof too late around the end block.
_i7.RuntimeCall createSwap({
required _i2.AccountId32 target,
required List<int> hashedProof,
required _i8.BalanceSwapAction action,
required int duration,
}) {
final _call = _i9.Call.values.createSwap(
target: target,
hashedProof: hashedProof,
action: action,
duration: duration,
);
return _i7.RuntimeCall.values.atomicSwap(_call);
}
/// Claim an atomic swap.
///
/// The dispatch origin for this call must be _Signed_.
///
/// - `proof`: Revealed proof of the claim.
/// - `action`: Action defined in the swap, it must match the entry in blockchain. Otherwise
/// the operation fails. This is used for weight calculation.
_i7.RuntimeCall claimSwap({
required List<int> proof,
required _i8.BalanceSwapAction action,
}) {
final _call = _i9.Call.values.claimSwap(
proof: proof,
action: action,
);
return _i7.RuntimeCall.values.atomicSwap(_call);
}
/// Cancel an atomic swap. Only possible after the originally set duration has passed.
///
/// The dispatch origin for this call must be _Signed_.
///
/// - `target`: Target of the original atomic swap.
/// - `hashed_proof`: Hashed proof of the original atomic swap.
_i7.RuntimeCall cancelSwap({
required _i2.AccountId32 target,
required List<int> hashedProof,
}) {
final _call = _i9.Call.values.cancelSwap(
target: target,
hashedProof: hashedProof,
);
return _i7.RuntimeCall.values.atomicSwap(_call);
}
}
class Constants {
Constants();
/// Limit of proof size.
///
/// Atomic swap is only atomic if once the proof is revealed, both parties can submit the
/// proofs on-chain. If A is the one that generates the proof, then it requires that either:
/// - A's blockchain has the same proof length limit as B's blockchain.
/// - Or A's blockchain has shorter proof length limit as B's blockchain.
///
/// If B sees A is on a blockchain with larger proof length limit, then it should kindly
/// refuse to accept the atomic swap request if A generates the proof, and asks that B
/// generates the proof instead.
final int proofLimit = 1024;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i4;
import 'dart:typed_data' as _i5;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i3;
import '../types/sp_authority_discovery/app/public.dart' as _i2;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<List<_i2.Public>> _keys =
const _i1.StorageValue<List<_i2.Public>>(
prefix: 'AuthorityDiscovery',
storage: 'Keys',
valueCodec: _i3.SequenceCodec<_i2.Public>(_i2.PublicCodec()),
);
final _i1.StorageValue<List<_i2.Public>> _nextKeys =
const _i1.StorageValue<List<_i2.Public>>(
prefix: 'AuthorityDiscovery',
storage: 'NextKeys',
valueCodec: _i3.SequenceCodec<_i2.Public>(_i2.PublicCodec()),
);
/// Keys of the current authority set.
_i4.Future<List<_i2.Public>> keys({_i1.BlockHash? at}) async {
final hashedKey = _keys.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _keys.decodeValue(bytes);
}
return []; /* Default */
}
/// Keys of the next authority set.
_i4.Future<List<_i2.Public>> nextKeys({_i1.BlockHash? at}) async {
final hashedKey = _nextKeys.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _nextKeys.decodeValue(bytes);
}
return []; /* Default */
}
/// Returns the storage key for `keys`.
_i5.Uint8List keysKey() {
final hashedKey = _keys.hashedKey();
return hashedKey;
}
/// Returns the storage key for `nextKeys`.
_i5.Uint8List nextKeysKey() {
final hashedKey = _nextKeys.hashedKey();
return hashedKey;
}
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i4;
import 'dart:typed_data' as _i5;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i2;
import '../types/gdev_runtime/opaque/session_keys.dart' as _i8;
import '../types/gdev_runtime/runtime_call.dart' as _i6;
import '../types/pallet_authority_members/pallet/call.dart' as _i7;
import '../types/pallet_authority_members/types/member_data.dart' as _i3;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<List<int>> _incomingAuthorities =
const _i1.StorageValue<List<int>>(
prefix: 'AuthorityMembers',
storage: 'IncomingAuthorities',
valueCodec: _i2.U32SequenceCodec.codec,
);
final _i1.StorageValue<List<int>> _onlineAuthorities =
const _i1.StorageValue<List<int>>(
prefix: 'AuthorityMembers',
storage: 'OnlineAuthorities',
valueCodec: _i2.U32SequenceCodec.codec,
);
final _i1.StorageValue<List<int>> _outgoingAuthorities =
const _i1.StorageValue<List<int>>(
prefix: 'AuthorityMembers',
storage: 'OutgoingAuthorities',
valueCodec: _i2.U32SequenceCodec.codec,
);
final _i1.StorageMap<int, _i3.MemberData> _members =
const _i1.StorageMap<int, _i3.MemberData>(
prefix: 'AuthorityMembers',
storage: 'Members',
valueCodec: _i3.MemberData.codec,
hasher: _i1.StorageHasher.twoxx64Concat(_i2.U32Codec.codec),
);
final _i1.StorageValue<List<int>> _blacklist =
const _i1.StorageValue<List<int>>(
prefix: 'AuthorityMembers',
storage: 'Blacklist',
valueCodec: _i2.U32SequenceCodec.codec,
);
/// The incoming authorities.
_i4.Future<List<int>> incomingAuthorities({_i1.BlockHash? at}) async {
final hashedKey = _incomingAuthorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _incomingAuthorities.decodeValue(bytes);
}
return List<int>.filled(
0,
0,
growable: true,
); /* Default */
}
/// The online authorities.
_i4.Future<List<int>> onlineAuthorities({_i1.BlockHash? at}) async {
final hashedKey = _onlineAuthorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _onlineAuthorities.decodeValue(bytes);
}
return List<int>.filled(
0,
0,
growable: true,
); /* Default */
}
/// The outgoing authorities.
_i4.Future<List<int>> outgoingAuthorities({_i1.BlockHash? at}) async {
final hashedKey = _outgoingAuthorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _outgoingAuthorities.decodeValue(bytes);
}
return List<int>.filled(
0,
0,
growable: true,
); /* Default */
}
/// The member data.
_i4.Future<_i3.MemberData?> members(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _members.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _members.decodeValue(bytes);
}
return null; /* Nullable */
}
/// The blacklisted authorities.
_i4.Future<List<int>> blacklist({_i1.BlockHash? at}) async {
final hashedKey = _blacklist.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _blacklist.decodeValue(bytes);
}
return List<int>.filled(
0,
0,
growable: true,
); /* Default */
}
/// Returns the storage key for `incomingAuthorities`.
_i5.Uint8List incomingAuthoritiesKey() {
final hashedKey = _incomingAuthorities.hashedKey();
return hashedKey;
}
/// Returns the storage key for `onlineAuthorities`.
_i5.Uint8List onlineAuthoritiesKey() {
final hashedKey = _onlineAuthorities.hashedKey();
return hashedKey;
}
/// Returns the storage key for `outgoingAuthorities`.
_i5.Uint8List outgoingAuthoritiesKey() {
final hashedKey = _outgoingAuthorities.hashedKey();
return hashedKey;
}
/// Returns the storage key for `members`.
_i5.Uint8List membersKey(int key1) {
final hashedKey = _members.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `blacklist`.
_i5.Uint8List blacklistKey() {
final hashedKey = _blacklist.hashedKey();
return hashedKey;
}
/// Returns the storage map key prefix for `members`.
_i5.Uint8List membersMapPrefix() {
final hashedKey = _members.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Request to leave the set of validators two sessions later.
_i6.RuntimeCall goOffline() {
final _call = _i7.Call.values.goOffline();
return _i6.RuntimeCall.values.authorityMembers(_call);
}
/// Request to join the set of validators two sessions later.
_i6.RuntimeCall goOnline() {
final _call = _i7.Call.values.goOnline();
return _i6.RuntimeCall.values.authorityMembers(_call);
}
/// Declare new session keys to replace current ones.
_i6.RuntimeCall setSessionKeys({required _i8.SessionKeys keys}) {
final _call = _i7.Call.values.setSessionKeys(keys: keys);
return _i6.RuntimeCall.values.authorityMembers(_call);
}
/// Remove a member from the set of validators.
_i6.RuntimeCall removeMember({required int memberId}) {
final _call = _i7.Call.values.removeMember(memberId: memberId);
return _i6.RuntimeCall.values.authorityMembers(_call);
}
/// Remove a member from the blacklist.
/// remove an identity from the blacklist
_i6.RuntimeCall removeMemberFromBlacklist({required int memberId}) {
final _call = _i7.Call.values.removeMemberFromBlacklist(memberId: memberId);
return _i6.RuntimeCall.values.authorityMembers(_call);
}
}
class Constants {
Constants();
/// Maximum number of authorities allowed.
final int maxAuthorities = 32;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'dart:typed_data' as _i4;
import 'package:polkadart/polkadart.dart' as _i1;
import '../types/sp_core/crypto/account_id32.dart' as _i2;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<_i2.AccountId32> _author =
const _i1.StorageValue<_i2.AccountId32>(
prefix: 'Authorship',
storage: 'Author',
valueCodec: _i2.AccountId32Codec(),
);
/// Author of current block.
_i3.Future<_i2.AccountId32?> author({_i1.BlockHash? at}) async {
final hashedKey = _author.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _author.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Returns the storage key for `author`.
_i4.Uint8List authorKey() {
final hashedKey = _author.hashedKey();
return hashedKey;
}
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i10;
import 'dart:typed_data' as _i11;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i2;
import '../types/gdev_runtime/runtime_call.dart' as _i12;
import '../types/pallet_babe/pallet/call.dart' as _i15;
import '../types/sp_consensus_babe/app/public.dart' as _i4;
import '../types/sp_consensus_babe/babe_epoch_configuration.dart' as _i9;
import '../types/sp_consensus_babe/digests/next_config_descriptor.dart' as _i6;
import '../types/sp_consensus_babe/digests/pre_digest.dart' as _i7;
import '../types/sp_consensus_slots/equivocation_proof.dart' as _i13;
import '../types/sp_consensus_slots/slot.dart' as _i5;
import '../types/sp_session/membership_proof.dart' as _i14;
import '../types/tuples.dart' as _i3;
import '../types/tuples_1.dart' as _i8;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<BigInt> _epochIndex = const _i1.StorageValue<BigInt>(
prefix: 'Babe',
storage: 'EpochIndex',
valueCodec: _i2.U64Codec.codec,
);
final _i1.StorageValue<List<_i3.Tuple2<_i4.Public, BigInt>>> _authorities =
const _i1.StorageValue<List<_i3.Tuple2<_i4.Public, BigInt>>>(
prefix: 'Babe',
storage: 'Authorities',
valueCodec: _i2.SequenceCodec<_i3.Tuple2<_i4.Public, BigInt>>(
_i3.Tuple2Codec<_i4.Public, BigInt>(
_i4.PublicCodec(),
_i2.U64Codec.codec,
)),
);
final _i1.StorageValue<_i5.Slot> _genesisSlot =
const _i1.StorageValue<_i5.Slot>(
prefix: 'Babe',
storage: 'GenesisSlot',
valueCodec: _i5.SlotCodec(),
);
final _i1.StorageValue<_i5.Slot> _currentSlot =
const _i1.StorageValue<_i5.Slot>(
prefix: 'Babe',
storage: 'CurrentSlot',
valueCodec: _i5.SlotCodec(),
);
final _i1.StorageValue<List<int>> _randomness =
const _i1.StorageValue<List<int>>(
prefix: 'Babe',
storage: 'Randomness',
valueCodec: _i2.U8ArrayCodec(32),
);
final _i1.StorageValue<_i6.NextConfigDescriptor> _pendingEpochConfigChange =
const _i1.StorageValue<_i6.NextConfigDescriptor>(
prefix: 'Babe',
storage: 'PendingEpochConfigChange',
valueCodec: _i6.NextConfigDescriptor.codec,
);
final _i1.StorageValue<List<int>> _nextRandomness =
const _i1.StorageValue<List<int>>(
prefix: 'Babe',
storage: 'NextRandomness',
valueCodec: _i2.U8ArrayCodec(32),
);
final _i1.StorageValue<List<_i3.Tuple2<_i4.Public, BigInt>>>
_nextAuthorities =
const _i1.StorageValue<List<_i3.Tuple2<_i4.Public, BigInt>>>(
prefix: 'Babe',
storage: 'NextAuthorities',
valueCodec: _i2.SequenceCodec<_i3.Tuple2<_i4.Public, BigInt>>(
_i3.Tuple2Codec<_i4.Public, BigInt>(
_i4.PublicCodec(),
_i2.U64Codec.codec,
)),
);
final _i1.StorageValue<int> _segmentIndex = const _i1.StorageValue<int>(
prefix: 'Babe',
storage: 'SegmentIndex',
valueCodec: _i2.U32Codec.codec,
);
final _i1.StorageMap<int, List<List<int>>> _underConstruction =
const _i1.StorageMap<int, List<List<int>>>(
prefix: 'Babe',
storage: 'UnderConstruction',
valueCodec: _i2.SequenceCodec<List<int>>(_i2.U8ArrayCodec(32)),
hasher: _i1.StorageHasher.twoxx64Concat(_i2.U32Codec.codec),
);
final _i1.StorageValue<_i7.PreDigest?> _initialized =
const _i1.StorageValue<_i7.PreDigest?>(
prefix: 'Babe',
storage: 'Initialized',
valueCodec: _i2.OptionCodec<_i7.PreDigest>(_i7.PreDigest.codec),
);
final _i1.StorageValue<List<int>?> _authorVrfRandomness =
const _i1.StorageValue<List<int>?>(
prefix: 'Babe',
storage: 'AuthorVrfRandomness',
valueCodec: _i2.OptionCodec<List<int>>(_i2.U8ArrayCodec(32)),
);
final _i1.StorageValue<_i8.Tuple2<int, int>> _epochStart =
const _i1.StorageValue<_i8.Tuple2<int, int>>(
prefix: 'Babe',
storage: 'EpochStart',
valueCodec: _i8.Tuple2Codec<int, int>(
_i2.U32Codec.codec,
_i2.U32Codec.codec,
),
);
final _i1.StorageValue<int> _lateness = const _i1.StorageValue<int>(
prefix: 'Babe',
storage: 'Lateness',
valueCodec: _i2.U32Codec.codec,
);
final _i1.StorageValue<_i9.BabeEpochConfiguration> _epochConfig =
const _i1.StorageValue<_i9.BabeEpochConfiguration>(
prefix: 'Babe',
storage: 'EpochConfig',
valueCodec: _i9.BabeEpochConfiguration.codec,
);
final _i1.StorageValue<_i9.BabeEpochConfiguration> _nextEpochConfig =
const _i1.StorageValue<_i9.BabeEpochConfiguration>(
prefix: 'Babe',
storage: 'NextEpochConfig',
valueCodec: _i9.BabeEpochConfiguration.codec,
);
final _i1.StorageValue<List<_i3.Tuple2<BigInt, int>>> _skippedEpochs =
const _i1.StorageValue<List<_i3.Tuple2<BigInt, int>>>(
prefix: 'Babe',
storage: 'SkippedEpochs',
valueCodec:
_i2.SequenceCodec<_i3.Tuple2<BigInt, int>>(_i3.Tuple2Codec<BigInt, int>(
_i2.U64Codec.codec,
_i2.U32Codec.codec,
)),
);
/// Current epoch index.
_i10.Future<BigInt> epochIndex({_i1.BlockHash? at}) async {
final hashedKey = _epochIndex.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _epochIndex.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// Current epoch authorities.
_i10.Future<List<_i3.Tuple2<_i4.Public, BigInt>>> authorities(
{_i1.BlockHash? at}) async {
final hashedKey = _authorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _authorities.decodeValue(bytes);
}
return []; /* Default */
}
/// The slot at which the first epoch actually started. This is 0
/// until the first block of the chain.
_i10.Future<_i5.Slot> genesisSlot({_i1.BlockHash? at}) async {
final hashedKey = _genesisSlot.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _genesisSlot.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// Current slot number.
_i10.Future<_i5.Slot> currentSlot({_i1.BlockHash? at}) async {
final hashedKey = _currentSlot.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _currentSlot.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// The epoch randomness for the *current* epoch.
///
/// # Security
///
/// This MUST NOT be used for gambling, as it can be influenced by a
/// malicious validator in the short term. It MAY be used in many
/// cryptographic protocols, however, so long as one remembers that this
/// (like everything else on-chain) it is public. For example, it can be
/// used where a number is needed that cannot have been chosen by an
/// adversary, for purposes such as public-coin zero-knowledge proofs.
_i10.Future<List<int>> randomness({_i1.BlockHash? at}) async {
final hashedKey = _randomness.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _randomness.decodeValue(bytes);
}
return List<int>.filled(
32,
0,
growable: false,
); /* Default */
}
/// Pending epoch configuration change that will be applied when the next epoch is enacted.
_i10.Future<_i6.NextConfigDescriptor?> pendingEpochConfigChange(
{_i1.BlockHash? at}) async {
final hashedKey = _pendingEpochConfigChange.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _pendingEpochConfigChange.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Next epoch randomness.
_i10.Future<List<int>> nextRandomness({_i1.BlockHash? at}) async {
final hashedKey = _nextRandomness.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _nextRandomness.decodeValue(bytes);
}
return List<int>.filled(
32,
0,
growable: false,
); /* Default */
}
/// Next epoch authorities.
_i10.Future<List<_i3.Tuple2<_i4.Public, BigInt>>> nextAuthorities(
{_i1.BlockHash? at}) async {
final hashedKey = _nextAuthorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _nextAuthorities.decodeValue(bytes);
}
return []; /* Default */
}
/// Randomness under construction.
///
/// We make a trade-off between storage accesses and list length.
/// We store the under-construction randomness in segments of up to
/// `UNDER_CONSTRUCTION_SEGMENT_LENGTH`.
///
/// Once a segment reaches this length, we begin the next one.
/// We reset all segments and return to `0` at the beginning of every
/// epoch.
_i10.Future<int> segmentIndex({_i1.BlockHash? at}) async {
final hashedKey = _segmentIndex.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _segmentIndex.decodeValue(bytes);
}
return 0; /* Default */
}
/// TWOX-NOTE: `SegmentIndex` is an increasing integer, so this is okay.
_i10.Future<List<List<int>>> underConstruction(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _underConstruction.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _underConstruction.decodeValue(bytes);
}
return []; /* Default */
}
/// Temporary value (cleared at block finalization) which is `Some`
/// if per-block initialization has already been called for current block.
_i10.Future<_i7.PreDigest?> initialized({_i1.BlockHash? at}) async {
final hashedKey = _initialized.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _initialized.decodeValue(bytes);
}
return null; /* Nullable */
}
/// This field should always be populated during block processing unless
/// secondary plain slots are enabled (which don't contain a VRF output).
///
/// It is set in `on_finalize`, before it will contain the value from the last block.
_i10.Future<List<int>?> authorVrfRandomness({_i1.BlockHash? at}) async {
final hashedKey = _authorVrfRandomness.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _authorVrfRandomness.decodeValue(bytes);
}
return null; /* Default */
}
/// The block numbers when the last and current epoch have started, respectively `N-1` and
/// `N`.
/// NOTE: We track this is in order to annotate the block number when a given pool of
/// entropy was fixed (i.e. it was known to chain observers). Since epochs are defined in
/// slots, which may be skipped, the block numbers may not line up with the slot numbers.
_i10.Future<_i8.Tuple2<int, int>> epochStart({_i1.BlockHash? at}) async {
final hashedKey = _epochStart.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _epochStart.decodeValue(bytes);
}
return _i8.Tuple2<int, int>(
0,
0,
); /* Default */
}
/// How late the current block is compared to its parent.
///
/// This entry is populated as part of block execution and is cleaned up
/// on block finalization. Querying this storage entry outside of block
/// execution context should always yield zero.
_i10.Future<int> lateness({_i1.BlockHash? at}) async {
final hashedKey = _lateness.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _lateness.decodeValue(bytes);
}
return 0; /* Default */
}
/// The configuration for the current epoch. Should never be `None` as it is initialized in
/// genesis.
_i10.Future<_i9.BabeEpochConfiguration?> epochConfig(
{_i1.BlockHash? at}) async {
final hashedKey = _epochConfig.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _epochConfig.decodeValue(bytes);
}
return null; /* Nullable */
}
/// The configuration for the next epoch, `None` if the config will not change
/// (you can fallback to `EpochConfig` instead in that case).
_i10.Future<_i9.BabeEpochConfiguration?> nextEpochConfig(
{_i1.BlockHash? at}) async {
final hashedKey = _nextEpochConfig.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _nextEpochConfig.decodeValue(bytes);
}
return null; /* Nullable */
}
/// A list of the last 100 skipped epochs and the corresponding session index
/// when the epoch was skipped.
///
/// This is only used for validating equivocation proofs. An equivocation proof
/// must contains a key-ownership proof for a given session, therefore we need a
/// way to tie together sessions and epoch indices, i.e. we need to validate that
/// a validator was the owner of a given key on a given session, and what the
/// active epoch index was during that session.
_i10.Future<List<_i3.Tuple2<BigInt, int>>> skippedEpochs(
{_i1.BlockHash? at}) async {
final hashedKey = _skippedEpochs.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _skippedEpochs.decodeValue(bytes);
}
return []; /* Default */
}
/// Returns the storage key for `epochIndex`.
_i11.Uint8List epochIndexKey() {
final hashedKey = _epochIndex.hashedKey();
return hashedKey;
}
/// Returns the storage key for `authorities`.
_i11.Uint8List authoritiesKey() {
final hashedKey = _authorities.hashedKey();
return hashedKey;
}
/// Returns the storage key for `genesisSlot`.
_i11.Uint8List genesisSlotKey() {
final hashedKey = _genesisSlot.hashedKey();
return hashedKey;
}
/// Returns the storage key for `currentSlot`.
_i11.Uint8List currentSlotKey() {
final hashedKey = _currentSlot.hashedKey();
return hashedKey;
}
/// Returns the storage key for `randomness`.
_i11.Uint8List randomnessKey() {
final hashedKey = _randomness.hashedKey();
return hashedKey;
}
/// Returns the storage key for `pendingEpochConfigChange`.
_i11.Uint8List pendingEpochConfigChangeKey() {
final hashedKey = _pendingEpochConfigChange.hashedKey();
return hashedKey;
}
/// Returns the storage key for `nextRandomness`.
_i11.Uint8List nextRandomnessKey() {
final hashedKey = _nextRandomness.hashedKey();
return hashedKey;
}
/// Returns the storage key for `nextAuthorities`.
_i11.Uint8List nextAuthoritiesKey() {
final hashedKey = _nextAuthorities.hashedKey();
return hashedKey;
}
/// Returns the storage key for `segmentIndex`.
_i11.Uint8List segmentIndexKey() {
final hashedKey = _segmentIndex.hashedKey();
return hashedKey;
}
/// Returns the storage key for `underConstruction`.
_i11.Uint8List underConstructionKey(int key1) {
final hashedKey = _underConstruction.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `initialized`.
_i11.Uint8List initializedKey() {
final hashedKey = _initialized.hashedKey();
return hashedKey;
}
/// Returns the storage key for `authorVrfRandomness`.
_i11.Uint8List authorVrfRandomnessKey() {
final hashedKey = _authorVrfRandomness.hashedKey();
return hashedKey;
}
/// Returns the storage key for `epochStart`.
_i11.Uint8List epochStartKey() {
final hashedKey = _epochStart.hashedKey();
return hashedKey;
}
/// Returns the storage key for `lateness`.
_i11.Uint8List latenessKey() {
final hashedKey = _lateness.hashedKey();
return hashedKey;
}
/// Returns the storage key for `epochConfig`.
_i11.Uint8List epochConfigKey() {
final hashedKey = _epochConfig.hashedKey();
return hashedKey;
}
/// Returns the storage key for `nextEpochConfig`.
_i11.Uint8List nextEpochConfigKey() {
final hashedKey = _nextEpochConfig.hashedKey();
return hashedKey;
}
/// Returns the storage key for `skippedEpochs`.
_i11.Uint8List skippedEpochsKey() {
final hashedKey = _skippedEpochs.hashedKey();
return hashedKey;
}
/// Returns the storage map key prefix for `underConstruction`.
_i11.Uint8List underConstructionMapPrefix() {
final hashedKey = _underConstruction.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Report authority equivocation/misbehavior. This method will verify
/// the equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence will
/// be reported.
_i12.RuntimeCall reportEquivocation({
required _i13.EquivocationProof equivocationProof,
required _i14.MembershipProof keyOwnerProof,
}) {
final _call = _i15.Call.values.reportEquivocation(
equivocationProof: equivocationProof,
keyOwnerProof: keyOwnerProof,
);
return _i12.RuntimeCall.values.babe(_call);
}
/// Report authority equivocation/misbehavior. This method will verify
/// the equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence will
/// be reported.
/// This extrinsic must be called unsigned and it is expected that only
/// block authors will call it (validated in `ValidateUnsigned`), as such
/// if the block author is defined it will be defined as the equivocation
/// reporter.
_i12.RuntimeCall reportEquivocationUnsigned({
required _i13.EquivocationProof equivocationProof,
required _i14.MembershipProof keyOwnerProof,
}) {
final _call = _i15.Call.values.reportEquivocationUnsigned(
equivocationProof: equivocationProof,
keyOwnerProof: keyOwnerProof,
);
return _i12.RuntimeCall.values.babe(_call);
}
/// Plan an epoch config change. The epoch config change is recorded and will be enacted on
/// the next call to `enact_epoch_change`. The config will be activated one epoch after.
/// Multiple calls to this method will replace any existing planned config change that had
/// not been enacted yet.
_i12.RuntimeCall planConfigChange(
{required _i6.NextConfigDescriptor config}) {
final _call = _i15.Call.values.planConfigChange(config: config);
return _i12.RuntimeCall.values.babe(_call);
}
}
class Constants {
Constants();
/// The amount of time, in slots, that each epoch should last.
/// NOTE: Currently it is not possible to change the epoch duration after
/// the chain has started. Attempting to do so will brick block production.
final BigInt epochDuration = BigInt.from(600);
/// The expected average block time at which BABE should be creating
/// blocks. Since BABE is probabilistic it is not trivial to figure out
/// what the expected average block time should be based on the slot
/// duration and the security parameter `c` (where `1 - c` represents
/// the probability of a slot being empty).
final BigInt expectedBlockTime = BigInt.from(6000);
/// Max number of authorities allowed
final int maxAuthorities = 32;
/// The maximum number of nominators for each validator.
final int maxNominators = 64;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i9;
import 'dart:typed_data' as _i10;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i2;
import '../types/frame_support/traits/tokens/misc/id_amount_1.dart' as _i7;
import '../types/frame_support/traits/tokens/misc/id_amount_2.dart' as _i8;
import '../types/gdev_runtime/runtime_call.dart' as _i11;
import '../types/pallet_balances/pallet/call.dart' as _i13;
import '../types/pallet_balances/types/account_data.dart' as _i4;
import '../types/pallet_balances/types/adjustment_direction.dart' as _i14;
import '../types/pallet_balances/types/balance_lock.dart' as _i5;
import '../types/pallet_balances/types/reserve_data.dart' as _i6;
import '../types/sp_core/crypto/account_id32.dart' as _i3;
import '../types/sp_runtime/multiaddress/multi_address.dart' as _i12;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<BigInt> _totalIssuance =
const _i1.StorageValue<BigInt>(
prefix: 'Balances',
storage: 'TotalIssuance',
valueCodec: _i2.U64Codec.codec,
);
final _i1.StorageValue<BigInt> _inactiveIssuance =
const _i1.StorageValue<BigInt>(
prefix: 'Balances',
storage: 'InactiveIssuance',
valueCodec: _i2.U64Codec.codec,
);
final _i1.StorageMap<_i3.AccountId32, _i4.AccountData> _account =
const _i1.StorageMap<_i3.AccountId32, _i4.AccountData>(
prefix: 'Balances',
storage: 'Account',
valueCodec: _i4.AccountData.codec,
hasher: _i1.StorageHasher.blake2b128Concat(_i3.AccountId32Codec()),
);
final _i1.StorageMap<_i3.AccountId32, List<_i5.BalanceLock>> _locks =
const _i1.StorageMap<_i3.AccountId32, List<_i5.BalanceLock>>(
prefix: 'Balances',
storage: 'Locks',
valueCodec: _i2.SequenceCodec<_i5.BalanceLock>(_i5.BalanceLock.codec),
hasher: _i1.StorageHasher.blake2b128Concat(_i3.AccountId32Codec()),
);
final _i1.StorageMap<_i3.AccountId32, List<_i6.ReserveData>> _reserves =
const _i1.StorageMap<_i3.AccountId32, List<_i6.ReserveData>>(
prefix: 'Balances',
storage: 'Reserves',
valueCodec: _i2.SequenceCodec<_i6.ReserveData>(_i6.ReserveData.codec),
hasher: _i1.StorageHasher.blake2b128Concat(_i3.AccountId32Codec()),
);
final _i1.StorageMap<_i3.AccountId32, List<_i7.IdAmount>> _holds =
const _i1.StorageMap<_i3.AccountId32, List<_i7.IdAmount>>(
prefix: 'Balances',
storage: 'Holds',
valueCodec: _i2.SequenceCodec<_i7.IdAmount>(_i7.IdAmount.codec),
hasher: _i1.StorageHasher.blake2b128Concat(_i3.AccountId32Codec()),
);
final _i1.StorageMap<_i3.AccountId32, List<_i8.IdAmount>> _freezes =
const _i1.StorageMap<_i3.AccountId32, List<_i8.IdAmount>>(
prefix: 'Balances',
storage: 'Freezes',
valueCodec: _i2.SequenceCodec<_i8.IdAmount>(_i8.IdAmount.codec),
hasher: _i1.StorageHasher.blake2b128Concat(_i3.AccountId32Codec()),
);
/// The total units issued in the system.
_i9.Future<BigInt> totalIssuance({_i1.BlockHash? at}) async {
final hashedKey = _totalIssuance.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _totalIssuance.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// The total units of outstanding deactivated balance in the system.
_i9.Future<BigInt> inactiveIssuance({_i1.BlockHash? at}) async {
final hashedKey = _inactiveIssuance.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _inactiveIssuance.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// The Balances pallet example of storing the balance of an account.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = StorageMapShim<Self::Account<Runtime>, frame_system::Provider<Runtime>, AccountId, Self::AccountData<Balance>>
/// }
/// ```
///
/// You can also store the balance of an account in the `System` pallet.
///
/// # Example
///
/// ```nocompile
/// impl pallet_balances::Config for Runtime {
/// type AccountStore = System
/// }
/// ```
///
/// But this comes with tradeoffs, storing account balances in the system pallet stores
/// `frame_system` data alongside the account data contrary to storing account balances in the
/// `Balances` pallet, which uses a `StorageMap` to store balances data only.
/// NOTE: This is only used in the case that this pallet is used to store balances.
_i9.Future<_i4.AccountData> account(
_i3.AccountId32 key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _account.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _account.decodeValue(bytes);
}
return _i4.AccountData(
free: BigInt.zero,
reserved: BigInt.zero,
frozen: BigInt.zero,
flags: BigInt.parse(
'170141183460469231731687303715884105728',
radix: 10,
),
); /* Default */
}
/// Any liquidity locks on some account balances.
/// NOTE: Should only be accessed when setting, changing and freeing a lock.
///
/// Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/`
_i9.Future<List<_i5.BalanceLock>> locks(
_i3.AccountId32 key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _locks.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _locks.decodeValue(bytes);
}
return []; /* Default */
}
/// Named reserves on some account balances.
///
/// Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/`
_i9.Future<List<_i6.ReserveData>> reserves(
_i3.AccountId32 key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _reserves.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _reserves.decodeValue(bytes);
}
return []; /* Default */
}
/// Holds on account balances.
_i9.Future<List<_i7.IdAmount>> holds(
_i3.AccountId32 key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _holds.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _holds.decodeValue(bytes);
}
return []; /* Default */
}
/// Freeze locks on account balances.
_i9.Future<List<_i8.IdAmount>> freezes(
_i3.AccountId32 key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _freezes.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _freezes.decodeValue(bytes);
}
return []; /* Default */
}
/// Returns the storage key for `totalIssuance`.
_i10.Uint8List totalIssuanceKey() {
final hashedKey = _totalIssuance.hashedKey();
return hashedKey;
}
/// Returns the storage key for `inactiveIssuance`.
_i10.Uint8List inactiveIssuanceKey() {
final hashedKey = _inactiveIssuance.hashedKey();
return hashedKey;
}
/// Returns the storage key for `account`.
_i10.Uint8List accountKey(_i3.AccountId32 key1) {
final hashedKey = _account.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `locks`.
_i10.Uint8List locksKey(_i3.AccountId32 key1) {
final hashedKey = _locks.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `reserves`.
_i10.Uint8List reservesKey(_i3.AccountId32 key1) {
final hashedKey = _reserves.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `holds`.
_i10.Uint8List holdsKey(_i3.AccountId32 key1) {
final hashedKey = _holds.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `freezes`.
_i10.Uint8List freezesKey(_i3.AccountId32 key1) {
final hashedKey = _freezes.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage map key prefix for `account`.
_i10.Uint8List accountMapPrefix() {
final hashedKey = _account.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `locks`.
_i10.Uint8List locksMapPrefix() {
final hashedKey = _locks.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `reserves`.
_i10.Uint8List reservesMapPrefix() {
final hashedKey = _reserves.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `holds`.
_i10.Uint8List holdsMapPrefix() {
final hashedKey = _holds.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `freezes`.
_i10.Uint8List freezesMapPrefix() {
final hashedKey = _freezes.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Transfer some liquid free balance to another account.
///
/// `transfer_allow_death` will set the `FreeBalance` of the sender and receiver.
/// If the sender's account is below the existential deposit as a result
/// of the transfer, the account will be reaped.
///
/// The dispatch origin for this call must be `Signed` by the transactor.
_i11.RuntimeCall transferAllowDeath({
required _i12.MultiAddress dest,
required BigInt value,
}) {
final _call = _i13.Call.values.transferAllowDeath(
dest: dest,
value: value,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Exactly as `transfer_allow_death`, except the origin must be root and the source account
/// may be specified.
_i11.RuntimeCall forceTransfer({
required _i12.MultiAddress source,
required _i12.MultiAddress dest,
required BigInt value,
}) {
final _call = _i13.Call.values.forceTransfer(
source: source,
dest: dest,
value: value,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Same as the [`transfer_allow_death`] call, but with a check that the transfer will not
/// kill the origin account.
///
/// 99% of the time you want [`transfer_allow_death`] instead.
///
/// [`transfer_allow_death`]: struct.Pallet.html#method.transfer
_i11.RuntimeCall transferKeepAlive({
required _i12.MultiAddress dest,
required BigInt value,
}) {
final _call = _i13.Call.values.transferKeepAlive(
dest: dest,
value: value,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Transfer the entire transferable balance from the caller account.
///
/// NOTE: This function only attempts to transfer _transferable_ balances. This means that
/// any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be
/// transferred by this function. To ensure that this function results in a killed account,
/// you might need to prepare the account by removing any reference counters, storage
/// deposits, etc...
///
/// The dispatch origin of this call must be Signed.
///
/// - `dest`: The recipient of the transfer.
/// - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
/// of the funds the account has, causing the sender account to be killed (false), or
/// transfer everything except at least the existential deposit, which will guarantee to
/// keep the sender account alive (true).
_i11.RuntimeCall transferAll({
required _i12.MultiAddress dest,
required bool keepAlive,
}) {
final _call = _i13.Call.values.transferAll(
dest: dest,
keepAlive: keepAlive,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Unreserve some balance from a user by force.
///
/// Can only be called by ROOT.
_i11.RuntimeCall forceUnreserve({
required _i12.MultiAddress who,
required BigInt amount,
}) {
final _call = _i13.Call.values.forceUnreserve(
who: who,
amount: amount,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Upgrade a specified account.
///
/// - `origin`: Must be `Signed`.
/// - `who`: The account to be upgraded.
///
/// This will waive the transaction fee if at least all but 10% of the accounts needed to
/// be upgraded. (We let some not have to be upgraded just in order to allow for the
/// possibility of churn).
/// Set the regular balance of a given account.
///
/// The dispatch origin for this call is `root`.
_i11.RuntimeCall forceSetBalance({
required _i12.MultiAddress who,
required BigInt newFree,
}) {
final _call = _i13.Call.values.forceSetBalance(
who: who,
newFree: newFree,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Adjust the total issuance in a saturating way.
///
/// Can only be called by root and always needs a positive `delta`.
///
/// # Example
_i11.RuntimeCall forceAdjustTotalIssuance({
required _i14.AdjustmentDirection direction,
required BigInt delta,
}) {
final _call = _i13.Call.values.forceAdjustTotalIssuance(
direction: direction,
delta: delta,
);
return _i11.RuntimeCall.values.balances(_call);
}
/// Burn the specified liquid free balance from the origin account.
///
/// If the origin's account ends up below the existential deposit as a result
/// of the burn and `keep_alive` is false, the account will be reaped.
///
/// Unlike sending funds to a _burn_ address, which merely makes the funds inaccessible,
/// this `burn` operation will reduce total issuance by the amount _burned_.
_i11.RuntimeCall burn({
required BigInt value,
required bool keepAlive,
}) {
final _call = _i13.Call.values.burn(
value: value,
keepAlive: keepAlive,
);
return _i11.RuntimeCall.values.balances(_call);
}
}
class Constants {
Constants();
/// The minimum amount required to keep an account open. MUST BE GREATER THAN ZERO!
///
/// If you *really* need it to be zero, you can enable the feature `insecure_zero_ed` for
/// this pallet. However, you do so at your own risk: this will open up a major DoS vector.
/// In case you have multiple sources of provider references, you may also get unexpected
/// behaviour if you set this to zero.
///
/// Bottom line: Do yourself a favour and make it at least one!
final BigInt existentialDeposit = BigInt.from(100);
/// The maximum number of locks that should exist on an account.
/// Not strictly enforced, but used for weight estimation.
///
/// Use of locks is deprecated in favour of freezes. See `https://github.com/paritytech/substrate/pull/12951/`
final int maxLocks = 50;
/// The maximum number of named reserves that can exist on an account.
///
/// Use of reserves is deprecated in favour of holds. See `https://github.com/paritytech/substrate/pull/12951/`
final int maxReserves = 5;
/// The maximum number of individual freeze locks that can exist on an account at any time.
final int maxFreezes = 0;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i5;
import 'dart:typed_data' as _i6;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i3;
import '../types/gdev_runtime/runtime_call.dart' as _i7;
import '../types/pallet_certification/pallet/call.dart' as _i8;
import '../types/pallet_certification/types/idty_cert_meta.dart' as _i2;
import '../types/tuples_1.dart' as _i4;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageMap<int, _i2.IdtyCertMeta> _storageIdtyCertMeta =
const _i1.StorageMap<int, _i2.IdtyCertMeta>(
prefix: 'Certification',
storage: 'StorageIdtyCertMeta',
valueCodec: _i2.IdtyCertMeta.codec,
hasher: _i1.StorageHasher.twoxx64Concat(_i3.U32Codec.codec),
);
final _i1.StorageMap<int, List<_i4.Tuple2<int, int>>> _certsByReceiver =
const _i1.StorageMap<int, List<_i4.Tuple2<int, int>>>(
prefix: 'Certification',
storage: 'CertsByReceiver',
valueCodec:
_i3.SequenceCodec<_i4.Tuple2<int, int>>(_i4.Tuple2Codec<int, int>(
_i3.U32Codec.codec,
_i3.U32Codec.codec,
)),
hasher: _i1.StorageHasher.twoxx64Concat(_i3.U32Codec.codec),
);
final _i1.StorageMap<int, List<_i4.Tuple2<int, int>>> _certsRemovableOn =
const _i1.StorageMap<int, List<_i4.Tuple2<int, int>>>(
prefix: 'Certification',
storage: 'CertsRemovableOn',
valueCodec:
_i3.SequenceCodec<_i4.Tuple2<int, int>>(_i4.Tuple2Codec<int, int>(
_i3.U32Codec.codec,
_i3.U32Codec.codec,
)),
hasher: _i1.StorageHasher.twoxx64Concat(_i3.U32Codec.codec),
);
/// The certification metadata for each issuer.
_i5.Future<_i2.IdtyCertMeta> storageIdtyCertMeta(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _storageIdtyCertMeta.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _storageIdtyCertMeta.decodeValue(bytes);
}
return _i2.IdtyCertMeta(
issuedCount: 0,
nextIssuableOn: 0,
receivedCount: 0,
); /* Default */
}
/// The certifications for each receiver.
_i5.Future<List<_i4.Tuple2<int, int>>> certsByReceiver(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _certsByReceiver.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _certsByReceiver.decodeValue(bytes);
}
return []; /* Default */
}
/// The certifications that should expire at a given block.
_i5.Future<List<_i4.Tuple2<int, int>>?> certsRemovableOn(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _certsRemovableOn.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _certsRemovableOn.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Returns the storage key for `storageIdtyCertMeta`.
_i6.Uint8List storageIdtyCertMetaKey(int key1) {
final hashedKey = _storageIdtyCertMeta.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `certsByReceiver`.
_i6.Uint8List certsByReceiverKey(int key1) {
final hashedKey = _certsByReceiver.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `certsRemovableOn`.
_i6.Uint8List certsRemovableOnKey(int key1) {
final hashedKey = _certsRemovableOn.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage map key prefix for `storageIdtyCertMeta`.
_i6.Uint8List storageIdtyCertMetaMapPrefix() {
final hashedKey = _storageIdtyCertMeta.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `certsByReceiver`.
_i6.Uint8List certsByReceiverMapPrefix() {
final hashedKey = _certsByReceiver.mapPrefix();
return hashedKey;
}
/// Returns the storage map key prefix for `certsRemovableOn`.
_i6.Uint8List certsRemovableOnMapPrefix() {
final hashedKey = _certsRemovableOn.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Add a new certification.
_i7.RuntimeCall addCert({required int receiver}) {
final _call = _i8.Call.values.addCert(receiver: receiver);
return _i7.RuntimeCall.values.certification(_call);
}
/// Renew an existing certification.
_i7.RuntimeCall renewCert({required int receiver}) {
final _call = _i8.Call.values.renewCert(receiver: receiver);
return _i7.RuntimeCall.values.certification(_call);
}
/// Remove one certification given the issuer and the receiver.
///
/// - `origin`: Must be `Root`.
_i7.RuntimeCall delCert({
required int issuer,
required int receiver,
}) {
final _call = _i8.Call.values.delCert(
issuer: issuer,
receiver: receiver,
);
return _i7.RuntimeCall.values.certification(_call);
}
/// Remove all certifications received by an identity.
///
/// - `origin`: Must be `Root`.
_i7.RuntimeCall removeAllCertsReceivedBy({required int idtyIndex}) {
final _call =
_i8.Call.values.removeAllCertsReceivedBy(idtyIndex: idtyIndex);
return _i7.RuntimeCall.values.certification(_call);
}
}
class Constants {
Constants();
/// The minimum duration (in blocks) between two certifications issued by the same issuer.
final int certPeriod = 14400;
/// The maximum number of active certifications that can be issued by a single issuer.
final int maxByIssuer = 100;
/// The minimum number of certifications received that an identity must have
/// to be allowed to issue a certification.
final int minReceivedCertToBeAbleToIssueCert = 3;
/// The duration (in blocks) for which a certification remains valid.
final int validityPeriod = 2102400;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i6;
import 'dart:typed_data' as _i7;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i5;
import '../types/gdev_runtime/runtime_call.dart' as _i8;
import '../types/pallet_distance/pallet/call.dart' as _i9;
import '../types/pallet_distance/types/evaluation_pool.dart' as _i2;
import '../types/primitive_types/h256.dart' as _i3;
import '../types/sp_arithmetic/per_things/perbill.dart' as _i11;
import '../types/sp_core/crypto/account_id32.dart' as _i4;
import '../types/sp_distance/computation_result.dart' as _i10;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<_i2.EvaluationPool> _evaluationPool0 =
const _i1.StorageValue<_i2.EvaluationPool>(
prefix: 'Distance',
storage: 'EvaluationPool0',
valueCodec: _i2.EvaluationPool.codec,
);
final _i1.StorageValue<_i2.EvaluationPool> _evaluationPool1 =
const _i1.StorageValue<_i2.EvaluationPool>(
prefix: 'Distance',
storage: 'EvaluationPool1',
valueCodec: _i2.EvaluationPool.codec,
);
final _i1.StorageValue<_i2.EvaluationPool> _evaluationPool2 =
const _i1.StorageValue<_i2.EvaluationPool>(
prefix: 'Distance',
storage: 'EvaluationPool2',
valueCodec: _i2.EvaluationPool.codec,
);
final _i1.StorageValue<_i3.H256> _evaluationBlock =
const _i1.StorageValue<_i3.H256>(
prefix: 'Distance',
storage: 'EvaluationBlock',
valueCodec: _i3.H256Codec(),
);
final _i1.StorageMap<int, _i4.AccountId32> _pendingEvaluationRequest =
const _i1.StorageMap<int, _i4.AccountId32>(
prefix: 'Distance',
storage: 'PendingEvaluationRequest',
valueCodec: _i4.AccountId32Codec(),
hasher: _i1.StorageHasher.twoxx64Concat(_i5.U32Codec.codec),
);
final _i1.StorageValue<bool> _didUpdate = const _i1.StorageValue<bool>(
prefix: 'Distance',
storage: 'DidUpdate',
valueCodec: _i5.BoolCodec.codec,
);
final _i1.StorageValue<int> _currentPeriodIndex = const _i1.StorageValue<int>(
prefix: 'Distance',
storage: 'CurrentPeriodIndex',
valueCodec: _i5.U32Codec.codec,
);
/// The first evaluation pool for distance evaluation queuing identities to evaluate for a given
/// evaluator account.
_i6.Future<_i2.EvaluationPool> evaluationPool0({_i1.BlockHash? at}) async {
final hashedKey = _evaluationPool0.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _evaluationPool0.decodeValue(bytes);
}
return _i2.EvaluationPool(
evaluations: [],
evaluators: [],
); /* Default */
}
/// The second evaluation pool for distance evaluation queuing identities to evaluate for a given
/// evaluator account.
_i6.Future<_i2.EvaluationPool> evaluationPool1({_i1.BlockHash? at}) async {
final hashedKey = _evaluationPool1.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _evaluationPool1.decodeValue(bytes);
}
return _i2.EvaluationPool(
evaluations: [],
evaluators: [],
); /* Default */
}
/// The third evaluation pool for distance evaluation queuing identities to evaluate for a given
/// evaluator account.
_i6.Future<_i2.EvaluationPool> evaluationPool2({_i1.BlockHash? at}) async {
final hashedKey = _evaluationPool2.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _evaluationPool2.decodeValue(bytes);
}
return _i2.EvaluationPool(
evaluations: [],
evaluators: [],
); /* Default */
}
/// The block at which the distance is evaluated.
_i6.Future<_i3.H256> evaluationBlock({_i1.BlockHash? at}) async {
final hashedKey = _evaluationBlock.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _evaluationBlock.decodeValue(bytes);
}
return List<int>.filled(
32,
0,
growable: false,
); /* Default */
}
/// The pending evaluation requesters.
_i6.Future<_i4.AccountId32?> pendingEvaluationRequest(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _pendingEvaluationRequest.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _pendingEvaluationRequest.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Store if the evaluation was updated in this block.
_i6.Future<bool> didUpdate({_i1.BlockHash? at}) async {
final hashedKey = _didUpdate.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _didUpdate.decodeValue(bytes);
}
return false; /* Default */
}
/// The current evaluation period index.
_i6.Future<int> currentPeriodIndex({_i1.BlockHash? at}) async {
final hashedKey = _currentPeriodIndex.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _currentPeriodIndex.decodeValue(bytes);
}
return 0; /* Default */
}
/// Returns the storage key for `evaluationPool0`.
_i7.Uint8List evaluationPool0Key() {
final hashedKey = _evaluationPool0.hashedKey();
return hashedKey;
}
/// Returns the storage key for `evaluationPool1`.
_i7.Uint8List evaluationPool1Key() {
final hashedKey = _evaluationPool1.hashedKey();
return hashedKey;
}
/// Returns the storage key for `evaluationPool2`.
_i7.Uint8List evaluationPool2Key() {
final hashedKey = _evaluationPool2.hashedKey();
return hashedKey;
}
/// Returns the storage key for `evaluationBlock`.
_i7.Uint8List evaluationBlockKey() {
final hashedKey = _evaluationBlock.hashedKey();
return hashedKey;
}
/// Returns the storage key for `pendingEvaluationRequest`.
_i7.Uint8List pendingEvaluationRequestKey(int key1) {
final hashedKey = _pendingEvaluationRequest.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `didUpdate`.
_i7.Uint8List didUpdateKey() {
final hashedKey = _didUpdate.hashedKey();
return hashedKey;
}
/// Returns the storage key for `currentPeriodIndex`.
_i7.Uint8List currentPeriodIndexKey() {
final hashedKey = _currentPeriodIndex.hashedKey();
return hashedKey;
}
/// Returns the storage map key prefix for `pendingEvaluationRequest`.
_i7.Uint8List pendingEvaluationRequestMapPrefix() {
final hashedKey = _pendingEvaluationRequest.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Request evaluation of the caller's identity distance.
///
/// This function allows the caller to request an evaluation of their distance.
/// A positive evaluation will lead to claiming or renewing membership, while a negative
/// evaluation will result in slashing for the caller.
_i8.RuntimeCall requestDistanceEvaluation() {
final _call = _i9.Call.values.requestDistanceEvaluation();
return _i8.RuntimeCall.values.distance(_call);
}
/// Request evaluation of a target identity's distance.
///
/// This function allows the caller to request an evaluation of a specific target identity's distance.
/// This action is only permitted for unvalidated identities.
_i8.RuntimeCall requestDistanceEvaluationFor({required int target}) {
final _call = _i9.Call.values.requestDistanceEvaluationFor(target: target);
return _i8.RuntimeCall.values.distance(_call);
}
/// Push an evaluation result to the pool.
///
/// This inherent function is called internally by validators to push an evaluation result
/// to the evaluation pool.
_i8.RuntimeCall updateEvaluation(
{required _i10.ComputationResult computationResult}) {
final _call =
_i9.Call.values.updateEvaluation(computationResult: computationResult);
return _i8.RuntimeCall.values.distance(_call);
}
/// Force push an evaluation result to the pool.
///
/// It is primarily used for testing purposes.
///
/// - `origin`: Must be `Root`.
_i8.RuntimeCall forceUpdateEvaluation({
required _i4.AccountId32 evaluator,
required _i10.ComputationResult computationResult,
}) {
final _call = _i9.Call.values.forceUpdateEvaluation(
evaluator: evaluator,
computationResult: computationResult,
);
return _i8.RuntimeCall.values.distance(_call);
}
/// Force set the distance evaluation status of an identity.
///
/// It is primarily used for testing purposes.
///
/// - `origin`: Must be `Root`.
_i8.RuntimeCall forceValidDistanceStatus({required int identity}) {
final _call = _i9.Call.values.forceValidDistanceStatus(identity: identity);
return _i8.RuntimeCall.values.distance(_call);
}
}
class Constants {
Constants();
/// The amount reserved during evaluation.
final BigInt evaluationPrice = BigInt.from(1000);
/// The evaluation period in blocks.
/// Since the evaluation uses 3 pools, the total evaluation time will be 3 * EvaluationPeriod.
final int evaluationPeriod = 100;
/// The maximum distance used to define a referee's accessibility.
/// This value is not used by the runtime but is needed by the client distance oracle.
final int maxRefereeDistance = 5;
/// The minimum ratio of accessible referees required.
final _i11.Perbill minAccessibleReferees = 800000000;
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i8;
import 'dart:typed_data' as _i9;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i4;
import '../types/gdev_runtime/runtime_call.dart' as _i10;
import '../types/pallet_grandpa/pallet/call.dart' as _i13;
import '../types/pallet_grandpa/stored_pending_change.dart' as _i3;
import '../types/pallet_grandpa/stored_state.dart' as _i2;
import '../types/sp_consensus_grandpa/app/public.dart' as _i7;
import '../types/sp_consensus_grandpa/equivocation_proof.dart' as _i11;
import '../types/sp_session/membership_proof.dart' as _i12;
import '../types/tuples.dart' as _i6;
import '../types/tuples_1.dart' as _i5;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageValue<_i2.StoredState> _state =
const _i1.StorageValue<_i2.StoredState>(
prefix: 'Grandpa',
storage: 'State',
valueCodec: _i2.StoredState.codec,
);
final _i1.StorageValue<_i3.StoredPendingChange> _pendingChange =
const _i1.StorageValue<_i3.StoredPendingChange>(
prefix: 'Grandpa',
storage: 'PendingChange',
valueCodec: _i3.StoredPendingChange.codec,
);
final _i1.StorageValue<int> _nextForced = const _i1.StorageValue<int>(
prefix: 'Grandpa',
storage: 'NextForced',
valueCodec: _i4.U32Codec.codec,
);
final _i1.StorageValue<_i5.Tuple2<int, int>> _stalled =
const _i1.StorageValue<_i5.Tuple2<int, int>>(
prefix: 'Grandpa',
storage: 'Stalled',
valueCodec: _i5.Tuple2Codec<int, int>(
_i4.U32Codec.codec,
_i4.U32Codec.codec,
),
);
final _i1.StorageValue<BigInt> _currentSetId = const _i1.StorageValue<BigInt>(
prefix: 'Grandpa',
storage: 'CurrentSetId',
valueCodec: _i4.U64Codec.codec,
);
final _i1.StorageMap<BigInt, int> _setIdSession =
const _i1.StorageMap<BigInt, int>(
prefix: 'Grandpa',
storage: 'SetIdSession',
valueCodec: _i4.U32Codec.codec,
hasher: _i1.StorageHasher.twoxx64Concat(_i4.U64Codec.codec),
);
final _i1.StorageValue<List<_i6.Tuple2<_i7.Public, BigInt>>> _authorities =
const _i1.StorageValue<List<_i6.Tuple2<_i7.Public, BigInt>>>(
prefix: 'Grandpa',
storage: 'Authorities',
valueCodec: _i4.SequenceCodec<_i6.Tuple2<_i7.Public, BigInt>>(
_i6.Tuple2Codec<_i7.Public, BigInt>(
_i7.PublicCodec(),
_i4.U64Codec.codec,
)),
);
/// State of the current authority set.
_i8.Future<_i2.StoredState> state({_i1.BlockHash? at}) async {
final hashedKey = _state.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _state.decodeValue(bytes);
}
return _i2.Live(); /* Default */
}
/// Pending change: (signaled at, scheduled change).
_i8.Future<_i3.StoredPendingChange?> pendingChange(
{_i1.BlockHash? at}) async {
final hashedKey = _pendingChange.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _pendingChange.decodeValue(bytes);
}
return null; /* Nullable */
}
/// next block number where we can force a change.
_i8.Future<int?> nextForced({_i1.BlockHash? at}) async {
final hashedKey = _nextForced.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _nextForced.decodeValue(bytes);
}
return null; /* Nullable */
}
/// `true` if we are currently stalled.
_i8.Future<_i5.Tuple2<int, int>?> stalled({_i1.BlockHash? at}) async {
final hashedKey = _stalled.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _stalled.decodeValue(bytes);
}
return null; /* Nullable */
}
/// The number of changes (both in terms of keys and underlying economic responsibilities)
/// in the "set" of Grandpa validators from genesis.
_i8.Future<BigInt> currentSetId({_i1.BlockHash? at}) async {
final hashedKey = _currentSetId.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _currentSetId.decodeValue(bytes);
}
return BigInt.zero; /* Default */
}
/// A mapping from grandpa set ID to the index of the *most recent* session for which its
/// members were responsible.
///
/// This is only used for validating equivocation proofs. An equivocation proof must
/// contains a key-ownership proof for a given session, therefore we need a way to tie
/// together sessions and GRANDPA set ids, i.e. we need to validate that a validator
/// was the owner of a given key on a given session, and what the active set ID was
/// during that session.
///
/// TWOX-NOTE: `SetId` is not under user control.
_i8.Future<int?> setIdSession(
BigInt key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _setIdSession.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _setIdSession.decodeValue(bytes);
}
return null; /* Nullable */
}
/// The current list of authorities.
_i8.Future<List<_i6.Tuple2<_i7.Public, BigInt>>> authorities(
{_i1.BlockHash? at}) async {
final hashedKey = _authorities.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _authorities.decodeValue(bytes);
}
return []; /* Default */
}
/// Returns the storage key for `state`.
_i9.Uint8List stateKey() {
final hashedKey = _state.hashedKey();
return hashedKey;
}
/// Returns the storage key for `pendingChange`.
_i9.Uint8List pendingChangeKey() {
final hashedKey = _pendingChange.hashedKey();
return hashedKey;
}
/// Returns the storage key for `nextForced`.
_i9.Uint8List nextForcedKey() {
final hashedKey = _nextForced.hashedKey();
return hashedKey;
}
/// Returns the storage key for `stalled`.
_i9.Uint8List stalledKey() {
final hashedKey = _stalled.hashedKey();
return hashedKey;
}
/// Returns the storage key for `currentSetId`.
_i9.Uint8List currentSetIdKey() {
final hashedKey = _currentSetId.hashedKey();
return hashedKey;
}
/// Returns the storage key for `setIdSession`.
_i9.Uint8List setIdSessionKey(BigInt key1) {
final hashedKey = _setIdSession.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `authorities`.
_i9.Uint8List authoritiesKey() {
final hashedKey = _authorities.hashedKey();
return hashedKey;
}
/// Returns the storage map key prefix for `setIdSession`.
_i9.Uint8List setIdSessionMapPrefix() {
final hashedKey = _setIdSession.mapPrefix();
return hashedKey;
}
}
class Txs {
const Txs();
/// Report voter equivocation/misbehavior. This method will verify the
/// equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence
/// will be reported.
_i10.RuntimeCall reportEquivocation({
required _i11.EquivocationProof equivocationProof,
required _i12.MembershipProof keyOwnerProof,
}) {
final _call = _i13.Call.values.reportEquivocation(
equivocationProof: equivocationProof,
keyOwnerProof: keyOwnerProof,
);
return _i10.RuntimeCall.values.grandpa(_call);
}
/// Report voter equivocation/misbehavior. This method will verify the
/// equivocation proof and validate the given key ownership proof
/// against the extracted offender. If both are valid, the offence
/// will be reported.
///
/// This extrinsic must be called unsigned and it is expected that only
/// block authors will call it (validated in `ValidateUnsigned`), as such
/// if the block author is defined it will be defined as the equivocation
/// reporter.
_i10.RuntimeCall reportEquivocationUnsigned({
required _i11.EquivocationProof equivocationProof,
required _i12.MembershipProof keyOwnerProof,
}) {
final _call = _i13.Call.values.reportEquivocationUnsigned(
equivocationProof: equivocationProof,
keyOwnerProof: keyOwnerProof,
);
return _i10.RuntimeCall.values.grandpa(_call);
}
/// Note that the current authority set of the GRANDPA finality gadget has stalled.
///
/// This will trigger a forced authority set change at the beginning of the next session, to
/// be enacted `delay` blocks after that. The `delay` should be high enough to safely assume
/// that the block signalling the forced change will not be re-orged e.g. 1000 blocks.
/// The block production rate (which may be slowed down because of finality lagging) should
/// be taken into account when choosing the `delay`. The GRANDPA voters based on the new
/// authority will start voting on top of `best_finalized_block_number` for new finalized
/// blocks. `best_finalized_block_number` should be the highest of the latest finalized
/// block of all validators of the new authority set.
///
/// Only callable by root.
_i10.RuntimeCall noteStalled({
required int delay,
required int bestFinalizedBlockNumber,
}) {
final _call = _i13.Call.values.noteStalled(
delay: delay,
bestFinalizedBlockNumber: bestFinalizedBlockNumber,
);
return _i10.RuntimeCall.values.grandpa(_call);
}
}
class Constants {
Constants();
/// Max Authorities in use
final int maxAuthorities = 32;
/// The maximum number of nominators for each validator.
final int maxNominators = 64;
/// The maximum number of entries to keep in the set id to session index mapping.
///
/// Since the `SetIdSession` map is only used for validating equivocations this
/// value should relate to the bonding duration of whatever staking system is
/// being used (if any). If equivocation handling is not enabled then this value
/// can be zero.
final BigInt maxSetIdSessionEntries = BigInt.from(1000);
}
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i6;
import 'dart:typed_data' as _i7;
import 'package:polkadart/polkadart.dart' as _i1;
import 'package:polkadart/scale_codec.dart' as _i4;
import '../types/primitive_types/h256.dart' as _i3;
import '../types/tuples.dart' as _i2;
import '../types/tuples_1.dart' as _i5;
class Queries {
const Queries(this.__api);
final _i1.StateApi __api;
final _i1.StorageMap<int, _i2.Tuple2<_i3.H256, int>> _historicalSessions =
const _i1.StorageMap<int, _i2.Tuple2<_i3.H256, int>>(
prefix: 'Historical',
storage: 'HistoricalSessions',
valueCodec: _i2.Tuple2Codec<_i3.H256, int>(
_i3.H256Codec(),
_i4.U32Codec.codec,
),
hasher: _i1.StorageHasher.twoxx64Concat(_i4.U32Codec.codec),
);
final _i1.StorageValue<_i5.Tuple2<int, int>> _storedRange =
const _i1.StorageValue<_i5.Tuple2<int, int>>(
prefix: 'Historical',
storage: 'StoredRange',
valueCodec: _i5.Tuple2Codec<int, int>(
_i4.U32Codec.codec,
_i4.U32Codec.codec,
),
);
/// Mapping from historical session indices to session-data root hash and validator count.
_i6.Future<_i2.Tuple2<_i3.H256, int>?> historicalSessions(
int key1, {
_i1.BlockHash? at,
}) async {
final hashedKey = _historicalSessions.hashedKeyFor(key1);
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _historicalSessions.decodeValue(bytes);
}
return null; /* Nullable */
}
/// The range of historical sessions we store. [first, last)
_i6.Future<_i5.Tuple2<int, int>?> storedRange({_i1.BlockHash? at}) async {
final hashedKey = _storedRange.hashedKey();
final bytes = await __api.getStorage(
hashedKey,
at: at,
);
if (bytes != null) {
return _storedRange.decodeValue(bytes);
}
return null; /* Nullable */
}
/// Returns the storage key for `historicalSessions`.
_i7.Uint8List historicalSessionsKey(int key1) {
final hashedKey = _historicalSessions.hashedKeyFor(key1);
return hashedKey;
}
/// Returns the storage key for `storedRange`.
_i7.Uint8List storedRangeKey() {
final hashedKey = _storedRange.hashedKey();
return hashedKey;
}
/// Returns the storage map key prefix for `historicalSessions`.
_i7.Uint8List historicalSessionsMapPrefix() {
final hashedKey = _historicalSessions.mapPrefix();
return hashedKey;
}
}