Select Git revision
runtime-calls.md
-
* remove unused deps * fix #241 * remove sp_std dependency https://github.com/paritytech/polkadot-sdk/issues/2101# This is the commit message #2: * update metadata * clean Cargo.toml * run benchmarks * update node * update crates
* remove unused deps * fix #241 * remove sp_std dependency https://github.com/paritytech/polkadot-sdk/issues/2101# This is the commit message #2: * update metadata * clean Cargo.toml * run benchmarks * update node * update crates
substrate_sdk.dart 23.16 KiB
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/providers/home.dart';
import 'package:gecko/providers/my_wallets.dart';
import 'package:polkawallet_sdk/api/apiKeyring.dart';
import 'package:polkawallet_sdk/api/types/networkParams.dart';
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
import 'package:polkawallet_sdk/storage/keyring.dart';
import 'package:polkawallet_sdk/storage/types/keyPairData.dart';
import 'package:provider/provider.dart';
import 'package:truncate/truncate.dart';
// import 'package:web_socket_channel/io.dart';
class SubstrateSdk with ChangeNotifier {
final WalletSDK sdk = WalletSDK();
final Keyring keyring = Keyring();
String generatedMnemonic = '';
bool sdkReady = false;
bool sdkLoading = false;
bool nodeConnected = false;
bool importIsLoading = false;
int blocNumber = 0;
bool isLoadingEndpoint = false;
String debugConnection = '';
String transactionStatus = '';
int ss58 = 42;
TextEditingController jsonKeystore = TextEditingController();
TextEditingController keystorePassword = TextEditingController();
/////////////////////////////////////
////////// 1: API METHODS ///////////
/////////////////////////////////////
Future<String> executeCall(TxInfoData txInfo, txOptions, String password,
[String? rawParams]) async {
try {
final hash = await sdk.api.tx
.signAndSend(txInfo, txOptions, password, rawParam: rawParams)
.timeout(
const Duration(seconds: 12),
onTimeout: () => {},
);
log.d(hash);
if (hash.isEmpty) {
transactionStatus = 'timeout';
notifyListeners();
return 'timeout';
} else {
transactionStatus = hash.toString();
notifyListeners();
return hash.toString();
}
} catch (e) {
transactionStatus = e.toString();
notifyListeners();
return e.toString();
}
}
Future getStorage(String call) async {
return await sdk.webView!.evalJavascript('api.query.$call');
}