Skip to content

Commit

Permalink
update to chain
Browse files Browse the repository at this point in the history
  • Loading branch information
bai-3 authored and bai-3 committed Oct 29, 2024
1 parent b22f72b commit 6c7d4e5
Show file tree
Hide file tree
Showing 34 changed files with 1,671 additions and 546 deletions.
4 changes: 2 additions & 2 deletions hacks/init_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:polkadart/scale_codec.dart';
const DAO_ROOT_SEED = "gloom album notable jewel divorce never trouble lesson month neck sign harbor";

void main() async {
final wetee = WeTEE.url('http://127.0.0.1:9944');
final wetee = WeTEE.url('wss://xiaobai.asyou.me:30001');
final chainAccount = await getSeedPhrase(seedStr: DAO_ROOT_SEED, name: '', password: '');
await WeTEE.addKeyring(account: chainAccount, password: "");

Expand All @@ -27,7 +27,7 @@ void main() async {
print(chainAccount.meta["ss58Address"]);

// 创建DAO
var runcall = wetee.tx.weTEEOrg.createDao(
var runcall = wetee.tx.weTEEMatrix.createNode(
name: convertStringToUint8List("ProgrammingDAO"),
bg: convertStringToUint8List(''),
logo: convertStringToUint8List(''),
Expand Down
239 changes: 0 additions & 239 deletions integration_test/dao_test.dart

This file was deleted.

39 changes: 8 additions & 31 deletions lib/application/chain/wetee/wetee.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class WeTEE {
registry = Registry();

factory WeTEE.url(String url) {
final provider = Provider.fromUri(Uri.parse(url));
// 大部分时间使用http请求,提交交易使用ws
var httpUrl = url.replaceAll("ws", "http");
final provider = Provider.fromUri(Uri.parse(httpUrl));
final rpc = Rpc(
state: StateApi(provider),
system: SystemApi(provider),
Expand Down Expand Up @@ -63,7 +65,6 @@ class WeTEE {
}
final KeyPair keyPair = keyPairs[address]!;


final signature = keyPair.sign(Uint8List.fromList(list));
// final hexSignature = hex.encode(signature);

Expand Down Expand Up @@ -142,10 +143,10 @@ class WeTEE {
}

static Future<bool> addKeyring({required ChainAccountData account, required String password}) async {
late KeyPair keyPair ;
if (account.encoding.type=="uri"){
late KeyPair keyPair;
if (account.encoding.type == "uri") {
keyPair = await KeyPair.sr25519.fromUri(account.encoded, password);
}else if (account.encoding.type=="mnemonic") {
} else if (account.encoding.type == "mnemonic") {
keyPair = await KeyPair.sr25519.fromMnemonic(account.encoded, password);
}

Expand All @@ -158,13 +159,8 @@ class WeTEE {
}

Future<int> getBlockNumber() async {
final completer = Completer<int>();
final sub = await subscribeFinalizedHeads((s) {
completer.complete(s.blockNumber!);
}, provider);
final header = await completer.future;
sub.cancel();
return header;
final block = await provider.send('chain_getBlock', []);
return int.parse(block.result['block']['header']['number']);
}

Future<List<StorageData>> queryMapList({
Expand Down Expand Up @@ -200,25 +196,6 @@ class WeTEE {
}
return ks;
}

Future<StreamSubscription<BlockHeader>> subscribeFinalizedHeads(
void Function(BlockHeader) onData, Provider provider) async {
final subscription = await provider.subscribe(
'chain_subscribeFinalizedHeads',
[],
onCancel: (subscription) async {
await provider.send('chain_unsubscribeFinalizedHeads', [subscription]);
},
);

return subscription.stream.map((response) {
var header = BlockHeader.fromJson(response.result);
header.blockNumber = hexToInt(header.number);
return header;
}).listen(onData);

// return subscription.stream.map((event) => event.result).listen(onData);
}
}

class ChainStruct<T> {
Expand Down
2 changes: 1 addition & 1 deletion lib/application/chain/wetee/wetee_gen/pallets/system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ class Constants {
specName: 'WeTEE-dev',
implName: 'WeTEE-dev-runtime',
authoringVersion: 1,
specVersion: 155,
specVersion: 156,
implVersion: 1,
apis: [
_i9.Tuple2<List<int>, int>(
Expand Down
Loading

0 comments on commit 6c7d4e5

Please sign in to comment.