From 6c7d4e5e9ba6064721f672584c463818cb419ba9 Mon Sep 17 00:00:00 2001 From: bai-3 Date: Tue, 29 Oct 2024 20:04:18 +0800 Subject: [PATCH] update to chain --- hacks/init_dao.dart | 4 +- integration_test/dao_test.dart | 239 -------- lib/application/chain/wetee/wetee.dart | 39 +- .../chain/wetee/wetee_gen/pallets/system.dart | 2 +- .../wetee_gen/pallets/we_t_e_e_matrix.dart | 160 ++++++ .../types/wetee_matrix/node_info.dart | 276 +++++++++ .../types/wetee_matrix/pallet/call.dart | 535 ++++++++++++++++++ .../types/wetee_matrix/pallet/error.dart | 135 +++++ .../types/wetee_matrix/pallet/event.dart | 192 +++++++ .../wetee_gen/types/wetee_matrix/status.dart | 57 ++ .../types/wetee_runtime/runtime_call.dart | 56 ++ .../types/wetee_runtime/runtime_event.dart | 55 ++ .../chain/wetee/wetee_gen/wetee_gen.dart | 30 +- .../service/apis/account_org_api.dart | 43 +- lib/application/store/chain_ctx.dart | 96 +--- lib/domain/models/account.dart | 44 +- lib/domain/models/account.g.dart | 39 +- lib/infra/components/app_card.dart | 10 +- lib/infra/components/dao/dao_is_joined.dart | 8 +- .../components/dao/payments_detail_list.dart | 38 +- lib/infra/components/gov_pop.dart | 22 +- lib/infra/components/me_pop.dart | 2 +- lib/infra/components/window.dart | 2 +- lib/infra/pages/chain/import_sr25519_key.dart | 2 +- lib/infra/pages/chain/sr25519_key.dart | 2 +- lib/infra/pages/integrate/integrate.dart | 12 +- lib/infra/pages/main_mobile.dart | 12 +- lib/infra/pages/main_pc.dart | 54 +- lib/infra/pages/org/create_org.dart | 10 +- lib/infra/pages/org/org_menu.dart | 4 +- lib/infra/pages/org/org_view.dart | 2 +- lib/infra/pages/preloader.dart | 8 +- lib/infra/pages/select_org.dart | 23 +- lib/infra/pages/setting/theme.dart | 4 +- 34 files changed, 1671 insertions(+), 546 deletions(-) delete mode 100644 integration_test/dao_test.dart create mode 100644 lib/application/chain/wetee/wetee_gen/pallets/we_t_e_e_matrix.dart create mode 100644 lib/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart create mode 100644 lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/call.dart create mode 100644 lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/error.dart create mode 100644 lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/event.dart create mode 100644 lib/application/chain/wetee/wetee_gen/types/wetee_matrix/status.dart diff --git a/hacks/init_dao.dart b/hacks/init_dao.dart index 5cc8c19c..20fd59cc 100644 --- a/hacks/init_dao.dart +++ b/hacks/init_dao.dart @@ -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: ""); @@ -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(''), diff --git a/integration_test/dao_test.dart b/integration_test/dao_test.dart deleted file mode 100644 index 8205b58e..00000000 --- a/integration_test/dao_test.dart +++ /dev/null @@ -1,239 +0,0 @@ -import 'package:dtim/router.dart'; - -import 'package:dtim/application/store/chain_ctx.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; - -import 'package:dtim/main.dart' as app; - -import 'base.dart'; -import 'extensions/wait_for.dart'; - -void main() { - // 初始化 - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - testWidgets('signup', (WidgetTester tester) async { - runInTest = true; - // 构建应用 - await app.main(); - await tester.pumpAndSettle(); - await Future.delayed(const Duration(seconds: 2)); - - try { - var acount = find.byKey(const Key('auto_test_del')); - await tester.tap(acount); - await tester.pumpAndSettle(); - await tester.tap(find.maybeUppercaseText('NEXT')); - await tester.pumpAndSettle(); - // ignore: empty_catches - } catch (exception) {} - - await tester.pumpAndSettle(); - - // 触发注册按钮点击 - await tester.waitFor(find.byKey(const Key('selectAccountType')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('selectAccountType'))); - await tester.pumpAndSettle(); - - // 触发注册sr25519key - await tester.waitFor(find.byKey(const Key('sr25519key')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('sr25519key'))); - await tester.pumpAndSettle(); - - // 触发下一页 - await tester.waitFor(find.byKey(const Key('goNext')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('goNext'))); - await tester.pumpAndSettle(); - - // 触发注册按钮点击 - await tester.waitFor(find.byKey(const Key('nick')), timeout: const Duration(seconds: 50)); - var nick = find.byKey(const Key('nick')); - await tester.tap(nick); - await tester.enterText(nick, "auto_test"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('passwd')), timeout: const Duration(seconds: 50)); - var passwd = find.byKey(const Key('passwd')); - await tester.tap(passwd); - await tester.enterText(passwd, "test123456"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('passwd2')), timeout: const Duration(seconds: 50)); - var passwd2 = find.byKey(const Key('passwd2')); - await tester.tap(passwd2); - await tester.enterText(passwd2, "test123456"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('keyDone')), timeout: const Duration(seconds: 50)); - var keyDone = find.byKey(const Key('keyDone')); - await tester.tap(keyDone); - await tester.pumpAndSettle(); - - await Future.delayed(const Duration(seconds: 5)); - }); - - testWidgets('joinDao', (WidgetTester tester) async { - await login(tester); - // 查看DAO - await tester.waitFor(find.byKey(const Key('DAO')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('DAO'))); - - await tester.waitFor(find.byKey(const Key('daoView')), timeout: const Duration(seconds: 50)); - - // await rustApi.daoInitFromPair(client: workCtx.chainClient, address: workCtx.user.address); - await weteeCtx.getData(); - await Future.delayed(const Duration(seconds: 6)); - - await tester.waitFor(find.byKey(const Key('joinDao')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('joinDao'))); - - await tester.waitFor(find.byKey(const Key('joinDaoSubmit')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('joinDaoSubmit'))); - - for (var i = 0; i < 200; i++) { - await Future.delayed(const Duration(seconds: 1)); - await tester.pumpAndSettle(); - var texts = find.byKey(const Key('myShare')); - var myShare = texts.evaluate().single.widget as Text; - if (myShare.data != 'SHARE: 0') { - break; - } - } - }); - - testWidgets('createProject', (WidgetTester tester) async { - await login(tester); - // 查看DAO - await tester.waitFor(find.byKey(const Key('DAO')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('DAO'))); - - await tester.waitFor(find.byKey(const Key('daoView')), timeout: const Duration(seconds: 50)); - - await tester.waitFor(find.byKey(const Key('createGuildProject')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('createGuildProject'))); - - // 打开创建页面 - await tester.waitFor(find.byKey(const Key('createSpace')), timeout: const Duration(seconds: 50)); - - await tester.waitFor(find.byKey(const Key('spaceName')), timeout: const Duration(seconds: 50)); - var name = find.byKey(const Key('spaceName')); - await tester.tap(name); - await tester.enterText(name, "test project"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('spaceDescription')), timeout: const Duration(seconds: 50)); - var desc = find.byKey(const Key('spaceDescription')); - await tester.tap(desc); - await tester.enterText(desc, "test project desc"); - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const Key('selectProject'))); - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const Key('createSpace'))); - await tester.pumpAndSettle(); - }); - - testWidgets('createProject', (WidgetTester tester) async { - await login(tester); - // 查看DAO - await tester.waitFor(find.byKey(const Key('DAO')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('DAO'))); - - await tester.waitFor(find.byKey(const Key('daoView')), timeout: const Duration(seconds: 50)); - - await tester.waitFor(find.byKey(const Key('createGuildProject')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('createGuildProject'))); - - // 打开创建页面 - await tester.waitFor(find.byKey(const Key('createSpace')), timeout: const Duration(seconds: 50)); - - await tester.waitFor(find.byKey(const Key('spaceName')), timeout: const Duration(seconds: 50)); - var name = find.byKey(const Key('spaceName')); - await tester.tap(name); - await tester.enterText(name, "test project"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('spaceDescription')), timeout: const Duration(seconds: 50)); - var desc = find.byKey(const Key('spaceDescription')); - await tester.tap(desc); - await tester.enterText(desc, "test project desc"); - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const Key('selectProject'))); - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const Key('createSpace'))); - await tester.pumpAndSettle(); - }); - - testWidgets('start Regerendum', (WidgetTester tester) async { - await login(tester); - // 查看DAO - await tester.waitFor(find.byKey(const Key('DAO')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('DAO'))); - await tester.waitFor(find.byKey(const Key('daoView')), timeout: const Duration(seconds: 50)); - - // 点击进入公投页面 - await tester.tap(find.byKey(const Key('Referendums'))); - await tester.waitFor(find.byKey(const Key('ReferendumView')), timeout: const Duration(seconds: 50)); - - if (weteeCtx.pending.isNotEmpty) { - var pending = weteeCtx.pending[0]; - await tester.tap(find.byKey(Key('referendumStart${pending.id}'))); - await Future.delayed(const Duration(seconds: 10)); - await tester.pumpAndSettle(); - } - - // var going = workCtx.going.lastWhere((v) => v.status == 0); - // await tester.waitFor(find.byKey(Key('referendumExecute${going.id}')), timeout: const Duration(seconds: 50)); - // await tester.tap(find.byKey(Key('referendumExecute${going.id}'))); - }); - - testWidgets('join Project', (WidgetTester tester) async { - await login(tester); - - // 查看DAO - await tester.waitFor(find.byKey(const Key('DAO')), timeout: const Duration(seconds: 50)); - await tester.tap(find.byKey(const Key('DAO'))); - await tester.waitFor(find.byKey(const Key('daoView')), timeout: const Duration(seconds: 50)); - - await Future.delayed(const Duration(seconds: 3)); - await tester.pumpAndSettle(); - - // 点击进入公投页面 - await tester.tap(find.byKey(const Key('Projects 1'))); - await tester.waitFor(find.byKey(const Key('projectView')), timeout: const Duration(seconds: 50)); - - // 添加用户到项目 - // var rootAddress = await rustApi.addSeed(seed: DAO_ROOT_SEED); - // await rustApi.daoProjectJoinRequestWithRoot( - // from: rootAddress, - // client: workCtx.chainClient, - // daoId: workCtx.org.daoId, - // projectId: 1, - // user: workCtx.user.address, - // ); - await Future.delayed(const Duration(seconds: 5)); - - await tester.tap(find.byKey(const Key('createTaskBtn'))); - await tester.waitFor(find.byKey(const Key('createTaskView')), timeout: const Duration(seconds: 50)); - - await tester.waitFor(find.byKey(const Key('taskTitle')), timeout: const Duration(seconds: 50)); - var name = find.byKey(const Key('taskTitle')); - await tester.tap(name); - await tester.enterText(name, "test task"); - await tester.pumpAndSettle(); - - await tester.waitFor(find.byKey(const Key('taskDesc')), timeout: const Duration(seconds: 50)); - var desc = find.byKey(const Key('taskDesc')); - await tester.tap(desc); - await tester.enterText(desc, "test desc"); - await tester.pumpAndSettle(); - - await tester.tap(find.byKey(const Key('createTask'))); - await tester.pumpAndSettle(); - }); -} diff --git a/lib/application/chain/wetee/wetee.dart b/lib/application/chain/wetee/wetee.dart index 21dfa38c..d00fe627 100644 --- a/lib/application/chain/wetee/wetee.dart +++ b/lib/application/chain/wetee/wetee.dart @@ -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), @@ -63,7 +65,6 @@ class WeTEE { } final KeyPair keyPair = keyPairs[address]!; - final signature = keyPair.sign(Uint8List.fromList(list)); // final hexSignature = hex.encode(signature); @@ -142,10 +143,10 @@ class WeTEE { } static Future 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); } @@ -158,13 +159,8 @@ class WeTEE { } Future getBlockNumber() async { - final completer = Completer(); - 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> queryMapList({ @@ -200,25 +196,6 @@ class WeTEE { } return ks; } - - Future> 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 { diff --git a/lib/application/chain/wetee/wetee_gen/pallets/system.dart b/lib/application/chain/wetee/wetee_gen/pallets/system.dart index 43abba52..fc5dc71f 100644 --- a/lib/application/chain/wetee/wetee_gen/pallets/system.dart +++ b/lib/application/chain/wetee/wetee_gen/pallets/system.dart @@ -803,7 +803,7 @@ class Constants { specName: 'WeTEE-dev', implName: 'WeTEE-dev-runtime', authoringVersion: 1, - specVersion: 155, + specVersion: 156, implVersion: 1, apis: [ _i9.Tuple2, int>( diff --git a/lib/application/chain/wetee/wetee_gen/pallets/we_t_e_e_matrix.dart b/lib/application/chain/wetee/wetee_gen/pallets/we_t_e_e_matrix.dart new file mode 100644 index 00000000..18da33e3 --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/pallets/we_t_e_e_matrix.dart @@ -0,0 +1,160 @@ +// 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/frame_support/pallet_id.dart' as _i9; +import '../types/wetee_matrix/node_info.dart' as _i2; +import '../types/wetee_matrix/pallet/call.dart' as _i7; +import '../types/wetee_matrix/status.dart' as _i8; +import '../types/wetee_runtime/runtime_call.dart' as _i6; + +class Queries { + const Queries(this.__api); + + final _i1.StateApi __api; + + final _i1.StorageMap _matrix = + const _i1.StorageMap( + prefix: 'WeTEEMatrix', + storage: 'Matrix', + valueCodec: _i2.NodeInfo.codec, + hasher: _i1.StorageHasher.identity(_i3.U128Codec.codec), + ); + + final _i1.StorageValue _nextId = const _i1.StorageValue( + prefix: 'WeTEEMatrix', + storage: 'NextId', + valueCodec: _i3.U128Codec.codec, + ); + + /// All Nodes that have been created. + /// 所有节点 + _i4.Future<_i2.NodeInfo?> matrix( + BigInt key1, { + _i1.BlockHash? at, + }) async { + final hashedKey = _matrix.hashedKeyFor(key1); + final bytes = await __api.getStorage( + hashedKey, + at: at, + ); + if (bytes != null) { + return _matrix.decodeValue(bytes); + } + return null; /* Nullable */ + } + + /// The id of the next node to be created. + /// 获取下一个节点id + _i4.Future nextId({_i1.BlockHash? at}) async { + final hashedKey = _nextId.hashedKey(); + final bytes = await __api.getStorage( + hashedKey, + at: at, + ); + if (bytes != null) { + return _nextId.decodeValue(bytes); + } + return BigInt.one; /* Default */ + } + + /// Returns the storage key for `matrix`. + _i5.Uint8List matrixKey(BigInt key1) { + final hashedKey = _matrix.hashedKeyFor(key1); + return hashedKey; + } + + /// Returns the storage key for `nextId`. + _i5.Uint8List nextIdKey() { + final hashedKey = _nextId.hashedKey(); + return hashedKey; + } + + /// Returns the storage map key prefix for `matrix`. + _i5.Uint8List matrixMapPrefix() { + final hashedKey = _matrix.mapPrefix(); + return hashedKey; + } +} + +class Txs { + const Txs(); + + /// Create a N o de + /// 从一个通证池,创建一个节点 + _i6.RuntimeCall createNode({ + required List name, + required List desc, + required List purpose, + required List metaData, + required List imApi, + required List bg, + required List logo, + required List img, + required List homeUrl, + }) { + final _call = _i7.Call.values.createNode( + name: name, + desc: desc, + purpose: purpose, + metaData: metaData, + imApi: imApi, + bg: bg, + logo: logo, + img: img, + homeUrl: homeUrl, + ); + return _i6.RuntimeCall.values.weTEEMatrix(_call); + } + + /// update node info + /// 更新节点信息 + _i6.RuntimeCall updateNode({ + required BigInt nodeId, + List? name, + List? desc, + List? purpose, + List? metaData, + List? imApi, + List? bg, + List? logo, + List? img, + List? homeUrl, + _i8.Status? status, + }) { + final _call = _i7.Call.values.updateNode( + nodeId: nodeId, + name: name, + desc: desc, + purpose: purpose, + metaData: metaData, + imApi: imApi, + bg: bg, + logo: logo, + img: img, + homeUrl: homeUrl, + status: status, + ); + return _i6.RuntimeCall.values.weTEEMatrix(_call); + } +} + +class Constants { + Constants(); + + /// pallet id + /// 模块id + final _i9.PalletId palletId = const [ + 119, + 101, + 109, + 97, + 116, + 114, + 105, + 120, + ]; +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart new file mode 100644 index 00000000..ab90a8a5 --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart @@ -0,0 +1,276 @@ +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:typed_data' as _i4; + +import 'package:polkadart/scale_codec.dart' as _i1; +import 'package:quiver/collection.dart' as _i5; + +import '../sp_core/crypto/account_id32.dart' as _i2; +import 'status.dart' as _i3; + +class NodeInfo { + const NodeInfo({ + required this.id, + required this.creator, + required this.startBlock, + required this.accountId, + required this.name, + required this.desc, + required this.purpose, + required this.metaData, + required this.imApi, + required this.bg, + required this.logo, + required this.img, + required this.homeUrl, + required this.status, + }); + + factory NodeInfo.decode(_i1.Input input) { + return codec.decode(input); + } + + /// u128 + final BigInt id; + + /// AccountId + final _i2.AccountId32 creator; + + /// BlockNumber + final BigInt startBlock; + + /// AccountId + final _i2.AccountId32 accountId; + + /// Vec + final List name; + + /// Vec + final List desc; + + /// Vec + final List purpose; + + /// Vec + final List metaData; + + /// Vec + final List imApi; + + /// Vec + final List bg; + + /// Vec + final List logo; + + /// Vec + final List img; + + /// Vec + final List homeUrl; + + /// Status + final _i3.Status status; + + static const $NodeInfoCodec codec = $NodeInfoCodec(); + + _i4.Uint8List encode() { + return codec.encode(this); + } + + Map toJson() => { + 'id': id, + 'creator': creator.toList(), + 'startBlock': startBlock, + 'accountId': accountId.toList(), + 'name': name, + 'desc': desc, + 'purpose': purpose, + 'metaData': metaData, + 'imApi': imApi, + 'bg': bg, + 'logo': logo, + 'img': img, + 'homeUrl': homeUrl, + 'status': status.toJson(), + }; + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is NodeInfo && + other.id == id && + _i5.listsEqual( + other.creator, + creator, + ) && + other.startBlock == startBlock && + _i5.listsEqual( + other.accountId, + accountId, + ) && + _i5.listsEqual( + other.name, + name, + ) && + _i5.listsEqual( + other.desc, + desc, + ) && + _i5.listsEqual( + other.purpose, + purpose, + ) && + _i5.listsEqual( + other.metaData, + metaData, + ) && + _i5.listsEqual( + other.imApi, + imApi, + ) && + _i5.listsEqual( + other.bg, + bg, + ) && + _i5.listsEqual( + other.logo, + logo, + ) && + _i5.listsEqual( + other.img, + img, + ) && + _i5.listsEqual( + other.homeUrl, + homeUrl, + ) && + other.status == status; + + @override + int get hashCode => Object.hash( + id, + creator, + startBlock, + accountId, + name, + desc, + purpose, + metaData, + imApi, + bg, + logo, + img, + homeUrl, + status, + ); +} + +class $NodeInfoCodec with _i1.Codec { + const $NodeInfoCodec(); + + @override + void encodeTo( + NodeInfo obj, + _i1.Output output, + ) { + _i1.U128Codec.codec.encodeTo( + obj.id, + output, + ); + const _i1.U8ArrayCodec(32).encodeTo( + obj.creator, + output, + ); + _i1.U64Codec.codec.encodeTo( + obj.startBlock, + output, + ); + const _i1.U8ArrayCodec(32).encodeTo( + obj.accountId, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.name, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.desc, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.purpose, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.metaData, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.imApi, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.bg, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.logo, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.img, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + obj.homeUrl, + output, + ); + _i3.Status.codec.encodeTo( + obj.status, + output, + ); + } + + @override + NodeInfo decode(_i1.Input input) { + return NodeInfo( + id: _i1.U128Codec.codec.decode(input), + creator: const _i1.U8ArrayCodec(32).decode(input), + startBlock: _i1.U64Codec.codec.decode(input), + accountId: const _i1.U8ArrayCodec(32).decode(input), + name: _i1.U8SequenceCodec.codec.decode(input), + desc: _i1.U8SequenceCodec.codec.decode(input), + purpose: _i1.U8SequenceCodec.codec.decode(input), + metaData: _i1.U8SequenceCodec.codec.decode(input), + imApi: _i1.U8SequenceCodec.codec.decode(input), + bg: _i1.U8SequenceCodec.codec.decode(input), + logo: _i1.U8SequenceCodec.codec.decode(input), + img: _i1.U8SequenceCodec.codec.decode(input), + homeUrl: _i1.U8SequenceCodec.codec.decode(input), + status: _i3.Status.codec.decode(input), + ); + } + + @override + int sizeHint(NodeInfo obj) { + int size = 0; + size = size + _i1.U128Codec.codec.sizeHint(obj.id); + size = size + const _i2.AccountId32Codec().sizeHint(obj.creator); + size = size + _i1.U64Codec.codec.sizeHint(obj.startBlock); + size = size + const _i2.AccountId32Codec().sizeHint(obj.accountId); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.name); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.desc); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.purpose); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.metaData); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.imApi); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.bg); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.logo); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.img); + size = size + _i1.U8SequenceCodec.codec.sizeHint(obj.homeUrl); + size = size + _i3.Status.codec.sizeHint(obj.status); + return size; + } +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/call.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/call.dart new file mode 100644 index 00000000..d9f1fb20 --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/call.dart @@ -0,0 +1,535 @@ +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:typed_data' as _i2; + +import 'package:polkadart/scale_codec.dart' as _i1; +import 'package:quiver/collection.dart' as _i4; + +import '../status.dart' as _i3; + +/// Contains a variant per dispatchable extrinsic that this pallet has. +abstract class Call { + const Call(); + + factory Call.decode(_i1.Input input) { + return codec.decode(input); + } + + static const $CallCodec codec = $CallCodec(); + + static const $Call values = $Call(); + + _i2.Uint8List encode() { + final output = _i1.ByteOutput(codec.sizeHint(this)); + codec.encodeTo(this, output); + return output.toBytes(); + } + + int sizeHint() { + return codec.sizeHint(this); + } + + Map> toJson(); +} + +class $Call { + const $Call(); + + CreateNode createNode({ + required List name, + required List desc, + required List purpose, + required List metaData, + required List imApi, + required List bg, + required List logo, + required List img, + required List homeUrl, + }) { + return CreateNode( + name: name, + desc: desc, + purpose: purpose, + metaData: metaData, + imApi: imApi, + bg: bg, + logo: logo, + img: img, + homeUrl: homeUrl, + ); + } + + UpdateNode updateNode({ + required BigInt nodeId, + List? name, + List? desc, + List? purpose, + List? metaData, + List? imApi, + List? bg, + List? logo, + List? img, + List? homeUrl, + _i3.Status? status, + }) { + return UpdateNode( + nodeId: nodeId, + name: name, + desc: desc, + purpose: purpose, + metaData: metaData, + imApi: imApi, + bg: bg, + logo: logo, + img: img, + homeUrl: homeUrl, + status: status, + ); + } +} + +class $CallCodec with _i1.Codec { + const $CallCodec(); + + @override + Call decode(_i1.Input input) { + final index = _i1.U8Codec.codec.decode(input); + switch (index) { + case 1: + return CreateNode._decode(input); + case 2: + return UpdateNode._decode(input); + default: + throw Exception('Call: Invalid variant index: "$index"'); + } + } + + @override + void encodeTo( + Call value, + _i1.Output output, + ) { + switch (value.runtimeType) { + case CreateNode: + (value as CreateNode).encodeTo(output); + break; + case UpdateNode: + (value as UpdateNode).encodeTo(output); + break; + default: + throw Exception( + 'Call: Unsupported "$value" of type "${value.runtimeType}"'); + } + } + + @override + int sizeHint(Call value) { + switch (value.runtimeType) { + case CreateNode: + return (value as CreateNode)._sizeHint(); + case UpdateNode: + return (value as UpdateNode)._sizeHint(); + default: + throw Exception( + 'Call: Unsupported "$value" of type "${value.runtimeType}"'); + } + } +} + +/// Create a N o de +/// 从一个通证池,创建一个节点 +class CreateNode extends Call { + const CreateNode({ + required this.name, + required this.desc, + required this.purpose, + required this.metaData, + required this.imApi, + required this.bg, + required this.logo, + required this.img, + required this.homeUrl, + }); + + factory CreateNode._decode(_i1.Input input) { + return CreateNode( + name: _i1.U8SequenceCodec.codec.decode(input), + desc: _i1.U8SequenceCodec.codec.decode(input), + purpose: _i1.U8SequenceCodec.codec.decode(input), + metaData: _i1.U8SequenceCodec.codec.decode(input), + imApi: _i1.U8SequenceCodec.codec.decode(input), + bg: _i1.U8SequenceCodec.codec.decode(input), + logo: _i1.U8SequenceCodec.codec.decode(input), + img: _i1.U8SequenceCodec.codec.decode(input), + homeUrl: _i1.U8SequenceCodec.codec.decode(input), + ); + } + + /// Vec + final List name; + + /// Vec + final List desc; + + /// Vec + final List purpose; + + /// Vec + final List metaData; + + /// Vec + final List imApi; + + /// Vec + final List bg; + + /// Vec + final List logo; + + /// Vec + final List img; + + /// Vec + final List homeUrl; + + @override + Map>> toJson() => { + 'create_node': { + 'name': name, + 'desc': desc, + 'purpose': purpose, + 'metaData': metaData, + 'imApi': imApi, + 'bg': bg, + 'logo': logo, + 'img': img, + 'homeUrl': homeUrl, + } + }; + + int _sizeHint() { + int size = 1; + size = size + _i1.U8SequenceCodec.codec.sizeHint(name); + size = size + _i1.U8SequenceCodec.codec.sizeHint(desc); + size = size + _i1.U8SequenceCodec.codec.sizeHint(purpose); + size = size + _i1.U8SequenceCodec.codec.sizeHint(metaData); + size = size + _i1.U8SequenceCodec.codec.sizeHint(imApi); + size = size + _i1.U8SequenceCodec.codec.sizeHint(bg); + size = size + _i1.U8SequenceCodec.codec.sizeHint(logo); + size = size + _i1.U8SequenceCodec.codec.sizeHint(img); + size = size + _i1.U8SequenceCodec.codec.sizeHint(homeUrl); + return size; + } + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 1, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + name, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + desc, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + purpose, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + metaData, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + imApi, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + bg, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + logo, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + img, + output, + ); + _i1.U8SequenceCodec.codec.encodeTo( + homeUrl, + output, + ); + } + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is CreateNode && + _i4.listsEqual( + other.name, + name, + ) && + _i4.listsEqual( + other.desc, + desc, + ) && + _i4.listsEqual( + other.purpose, + purpose, + ) && + _i4.listsEqual( + other.metaData, + metaData, + ) && + _i4.listsEqual( + other.imApi, + imApi, + ) && + _i4.listsEqual( + other.bg, + bg, + ) && + _i4.listsEqual( + other.logo, + logo, + ) && + _i4.listsEqual( + other.img, + img, + ) && + _i4.listsEqual( + other.homeUrl, + homeUrl, + ); + + @override + int get hashCode => Object.hash( + name, + desc, + purpose, + metaData, + imApi, + bg, + logo, + img, + homeUrl, + ); +} + +/// update node info +/// 更新节点信息 +class UpdateNode extends Call { + const UpdateNode({ + required this.nodeId, + this.name, + this.desc, + this.purpose, + this.metaData, + this.imApi, + this.bg, + this.logo, + this.img, + this.homeUrl, + this.status, + }); + + factory UpdateNode._decode(_i1.Input input) { + return UpdateNode( + nodeId: _i1.U128Codec.codec.decode(input), + name: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + desc: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + purpose: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + metaData: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + imApi: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + bg: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + logo: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + img: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + homeUrl: const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .decode(input), + status: const _i1.OptionCodec<_i3.Status>(_i3.Status.codec).decode(input), + ); + } + + /// u128 + final BigInt nodeId; + + /// Option> + final List? name; + + /// Option> + final List? desc; + + /// Option> + final List? purpose; + + /// Option> + final List? metaData; + + /// Option> + final List? imApi; + + /// Option> + final List? bg; + + /// Option> + final List? logo; + + /// Option> + final List? img; + + /// Option> + final List? homeUrl; + + /// Option + final _i3.Status? status; + + @override + Map> toJson() => { + 'update_node': { + 'nodeId': nodeId, + 'name': name, + 'desc': desc, + 'purpose': purpose, + 'metaData': metaData, + 'imApi': imApi, + 'bg': bg, + 'logo': logo, + 'img': img, + 'homeUrl': homeUrl, + 'status': status?.toJson(), + } + }; + + int _sizeHint() { + int size = 1; + size = size + _i1.U128Codec.codec.sizeHint(nodeId); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(name); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(desc); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(purpose); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(metaData); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(imApi); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(bg); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(logo); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(img); + size = size + + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec) + .sizeHint(homeUrl); + size = size + + const _i1.OptionCodec<_i3.Status>(_i3.Status.codec).sizeHint(status); + return size; + } + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 2, + output, + ); + _i1.U128Codec.codec.encodeTo( + nodeId, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + name, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + desc, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + purpose, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + metaData, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + imApi, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + bg, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + logo, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + img, + output, + ); + const _i1.OptionCodec>(_i1.U8SequenceCodec.codec).encodeTo( + homeUrl, + output, + ); + const _i1.OptionCodec<_i3.Status>(_i3.Status.codec).encodeTo( + status, + output, + ); + } + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is UpdateNode && + other.nodeId == nodeId && + other.name == name && + other.desc == desc && + other.purpose == purpose && + other.metaData == metaData && + other.imApi == imApi && + other.bg == bg && + other.logo == logo && + other.img == img && + other.homeUrl == homeUrl && + other.status == status; + + @override + int get hashCode => Object.hash( + nodeId, + name, + desc, + purpose, + metaData, + imApi, + bg, + logo, + img, + homeUrl, + status, + ); +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/error.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/error.dart new file mode 100644 index 00000000..9888a44c --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/error.dart @@ -0,0 +1,135 @@ +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:typed_data' as _i2; + +import 'package:polkadart/scale_codec.dart' as _i1; + +/// The `Error` enum of this pallet. +enum Error { + /// Do not have permission to create. + /// 没有创建的权限 + haveNoCreatePermission('HaveNoCreatePermission', 0), + + /// Node already exists + /// 节点已存在 + nodeExists('NodeExists', 1), + + /// Node does not exist. + /// 节点不存在 + nodeNotExists('NodeNotExists', 2), + + /// guild create error + /// 公会创建失败 + guildCreateError('GuildCreateError', 3), + + /// guild does not exist. + /// 公会不存在 + guildNotExists('GuildNotExists', 4), + + /// Node unsupported call + /// 无效的调用 + inVailCall('InVailCall', 5), + + /// Node unsupported pallet + /// 无效的Pallet + inVailPallet('InVailPallet', 6), + + /// Wrong origin. + /// 错误的节点 + badOrigin('BadOrigin', 7), + + /// Not the id of this node. + /// 节点 id 不正确 + nodeIdNotMatch('NodeIdNotMatch', 8), + + /// The description of the Node is too long. + /// 名字太长 + nameTooLong('NameTooLong', 9), + + /// The description of the Node is too long. + /// 节点介绍太长 + descTooLong('DescTooLong', 10), + + /// The description of the Node is too long. + /// 节点目标太长 + purposeTooLong('PurposeTooLong', 11), + + /// The description of the Node is too long. + /// 节点目标太长 + metaDataTooLong('MetaDataTooLong', 12), + + /// Numerical calculation overflow error. + /// 溢出错误 + overflow('Overflow', 13); + + const Error( + this.variantName, + this.codecIndex, + ); + + factory Error.decode(_i1.Input input) { + return codec.decode(input); + } + + final String variantName; + + final int codecIndex; + + static const $ErrorCodec codec = $ErrorCodec(); + + String toJson() => variantName; + _i2.Uint8List encode() { + return codec.encode(this); + } +} + +class $ErrorCodec with _i1.Codec { + const $ErrorCodec(); + + @override + Error decode(_i1.Input input) { + final index = _i1.U8Codec.codec.decode(input); + switch (index) { + case 0: + return Error.haveNoCreatePermission; + case 1: + return Error.nodeExists; + case 2: + return Error.nodeNotExists; + case 3: + return Error.guildCreateError; + case 4: + return Error.guildNotExists; + case 5: + return Error.inVailCall; + case 6: + return Error.inVailPallet; + case 7: + return Error.badOrigin; + case 8: + return Error.nodeIdNotMatch; + case 9: + return Error.nameTooLong; + case 10: + return Error.descTooLong; + case 11: + return Error.purposeTooLong; + case 12: + return Error.metaDataTooLong; + case 13: + return Error.overflow; + default: + throw Exception('Error: Invalid variant index: "$index"'); + } + } + + @override + void encodeTo( + Error value, + _i1.Output output, + ) { + _i1.U8Codec.codec.encodeTo( + value.codecIndex, + output, + ); + } +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/event.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/event.dart new file mode 100644 index 00000000..0f71f0c2 --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/pallet/event.dart @@ -0,0 +1,192 @@ +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:typed_data' as _i2; + +import 'package:polkadart/scale_codec.dart' as _i1; +import 'package:quiver/collection.dart' as _i4; + +import '../../sp_core/crypto/account_id32.dart' as _i3; + +/// success event +/// 成功事件 +abstract class Event { + const Event(); + + factory Event.decode(_i1.Input input) { + return codec.decode(input); + } + + static const $EventCodec codec = $EventCodec(); + + static const $Event values = $Event(); + + _i2.Uint8List encode() { + final output = _i1.ByteOutput(codec.sizeHint(this)); + codec.encodeTo(this, output); + return output.toBytes(); + } + + int sizeHint() { + return codec.sizeHint(this); + } + + Map toJson(); +} + +class $Event { + const $Event(); + + CreatedNode createdNode( + _i3.AccountId32 value0, + BigInt value1, + ) { + return CreatedNode( + value0, + value1, + ); + } + + Success success() { + return Success(); + } +} + +class $EventCodec with _i1.Codec { + const $EventCodec(); + + @override + Event decode(_i1.Input input) { + final index = _i1.U8Codec.codec.decode(input); + switch (index) { + case 0: + return CreatedNode._decode(input); + case 1: + return const Success(); + default: + throw Exception('Event: Invalid variant index: "$index"'); + } + } + + @override + void encodeTo( + Event value, + _i1.Output output, + ) { + switch (value.runtimeType) { + case CreatedNode: + (value as CreatedNode).encodeTo(output); + break; + case Success: + (value as Success).encodeTo(output); + break; + default: + throw Exception( + 'Event: Unsupported "$value" of type "${value.runtimeType}"'); + } + } + + @override + int sizeHint(Event value) { + switch (value.runtimeType) { + case CreatedNode: + return (value as CreatedNode)._sizeHint(); + case Success: + return 1; + default: + throw Exception( + 'Event: Unsupported "$value" of type "${value.runtimeType}"'); + } + } +} + +/// Node create event +/// Node创建成功事件 +class CreatedNode extends Event { + const CreatedNode( + this.value0, + this.value1, + ); + + factory CreatedNode._decode(_i1.Input input) { + return CreatedNode( + const _i1.U8ArrayCodec(32).decode(input), + _i1.U128Codec.codec.decode(input), + ); + } + + /// T::AccountId + final _i3.AccountId32 value0; + + /// u128 + final BigInt value1; + + @override + Map> toJson() => { + 'CreatedNode': [ + value0.toList(), + value1, + ] + }; + + int _sizeHint() { + int size = 1; + size = size + const _i3.AccountId32Codec().sizeHint(value0); + size = size + _i1.U128Codec.codec.sizeHint(value1); + return size; + } + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 0, + output, + ); + const _i1.U8ArrayCodec(32).encodeTo( + value0, + output, + ); + _i1.U128Codec.codec.encodeTo( + value1, + output, + ); + } + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is CreatedNode && + _i4.listsEqual( + other.value0, + value0, + ) && + other.value1 == value1; + + @override + int get hashCode => Object.hash( + value0, + value1, + ); +} + +/// nomal success +/// 成功的事件 +class Success extends Event { + const Success(); + + @override + Map toJson() => {'Success': null}; + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 1, + output, + ); + } + + @override + bool operator ==(Object other) => other is Success; + + @override + int get hashCode => runtimeType.hashCode; +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/status.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/status.dart new file mode 100644 index 00000000..634c8782 --- /dev/null +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_matrix/status.dart @@ -0,0 +1,57 @@ +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:typed_data' as _i2; + +import 'package:polkadart/scale_codec.dart' as _i1; + +enum Status { + active('Active', 0), + inActive('InActive', 1); + + const Status( + this.variantName, + this.codecIndex, + ); + + factory Status.decode(_i1.Input input) { + return codec.decode(input); + } + + final String variantName; + + final int codecIndex; + + static const $StatusCodec codec = $StatusCodec(); + + String toJson() => variantName; + _i2.Uint8List encode() { + return codec.encode(this); + } +} + +class $StatusCodec with _i1.Codec { + const $StatusCodec(); + + @override + Status decode(_i1.Input input) { + final index = _i1.U8Codec.codec.decode(input); + switch (index) { + case 0: + return Status.active; + case 1: + return Status.inActive; + default: + throw Exception('Status: Invalid variant index: "$index"'); + } + } + + @override + void encodeTo( + Status value, + _i1.Output output, + ) { + _i1.U8Codec.codec.encodeTo( + value.codecIndex, + output, + ); + } +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_call.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_call.dart index f38972a9..d5219ff0 100644 --- a/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_call.dart +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_call.dart @@ -17,6 +17,7 @@ import '../wetee_dsecret/pallet/call.dart' as _i23; import '../wetee_gov/pallet/call.dart' as _i16; import '../wetee_gpu/pallet/call.dart' as _i20; import '../wetee_guild/pallet/call.dart' as _i14; +import '../wetee_matrix/pallet/call.dart' as _i25; import '../wetee_message_queue/pallet/call.dart' as _i9; import '../wetee_org/pallet/call.dart' as _i11; import '../wetee_project/pallet/call.dart' as _i15; @@ -140,6 +141,10 @@ class $RuntimeCall { WeTEEBridge weTEEBridge(_i24.Call value0) { return WeTEEBridge(value0); } + + WeTEEMatrix weTEEMatrix(_i25.Call value0) { + return WeTEEMatrix(value0); + } } class $RuntimeCallCodec with _i1.Codec { @@ -193,6 +198,8 @@ class $RuntimeCallCodec with _i1.Codec { return WeTEEDsecret._decode(input); case 24: return WeTEEBridge._decode(input); + case 25: + return WeTEEMatrix._decode(input); default: throw Exception('RuntimeCall: Invalid variant index: "$index"'); } @@ -270,6 +277,9 @@ class $RuntimeCallCodec with _i1.Codec { case WeTEEBridge: (value as WeTEEBridge).encodeTo(output); break; + case WeTEEMatrix: + (value as WeTEEMatrix).encodeTo(output); + break; default: throw Exception( 'RuntimeCall: Unsupported "$value" of type "${value.runtimeType}"'); @@ -323,6 +333,8 @@ class $RuntimeCallCodec with _i1.Codec { return (value as WeTEEDsecret)._sizeHint(); case WeTEEBridge: return (value as WeTEEBridge)._sizeHint(); + case WeTEEMatrix: + return (value as WeTEEMatrix)._sizeHint(); default: throw Exception( 'RuntimeCall: Unsupported "$value" of type "${value.runtimeType}"'); @@ -1296,3 +1308,47 @@ class WeTEEBridge extends RuntimeCall { @override int get hashCode => value0.hashCode; } + +class WeTEEMatrix extends RuntimeCall { + const WeTEEMatrix(this.value0); + + factory WeTEEMatrix._decode(_i1.Input input) { + return WeTEEMatrix(_i25.Call.codec.decode(input)); + } + + /// self::sp_api_hidden_includes_construct_runtime::hidden_include::dispatch + ///::CallableCallFor + final _i25.Call value0; + + @override + Map>> toJson() => + {'WeTEEMatrix': value0.toJson()}; + + int _sizeHint() { + int size = 1; + size = size + _i25.Call.codec.sizeHint(value0); + return size; + } + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 25, + output, + ); + _i25.Call.codec.encodeTo( + value0, + output, + ); + } + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is WeTEEMatrix && other.value0 == value0; + + @override + int get hashCode => value0.hashCode; +} diff --git a/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_event.dart b/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_event.dart index 1e715176..3f441d35 100644 --- a/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_event.dart +++ b/lib/application/chain/wetee/wetee_gen/types/wetee_runtime/runtime_event.dart @@ -17,6 +17,7 @@ import '../wetee_dsecret/pallet/event.dart' as _i23; import '../wetee_gov/pallet/event.dart' as _i16; import '../wetee_gpu/pallet/event.dart' as _i20; import '../wetee_guild/pallet/event.dart' as _i14; +import '../wetee_matrix/pallet/event.dart' as _i25; import '../wetee_message_queue/pallet/event.dart' as _i9; import '../wetee_org/pallet/event.dart' as _i11; import '../wetee_project/pallet/event.dart' as _i15; @@ -140,6 +141,10 @@ class $RuntimeEvent { WeTEEBridge weTEEBridge(_i24.Event value0) { return WeTEEBridge(value0); } + + WeTEEMatrix weTEEMatrix(_i25.Event value0) { + return WeTEEMatrix(value0); + } } class $RuntimeEventCodec with _i1.Codec { @@ -193,6 +198,8 @@ class $RuntimeEventCodec with _i1.Codec { return WeTEEDsecret._decode(input); case 24: return WeTEEBridge._decode(input); + case 25: + return WeTEEMatrix._decode(input); default: throw Exception('RuntimeEvent: Invalid variant index: "$index"'); } @@ -270,6 +277,9 @@ class $RuntimeEventCodec with _i1.Codec { case WeTEEBridge: (value as WeTEEBridge).encodeTo(output); break; + case WeTEEMatrix: + (value as WeTEEMatrix).encodeTo(output); + break; default: throw Exception( 'RuntimeEvent: Unsupported "$value" of type "${value.runtimeType}"'); @@ -323,6 +333,8 @@ class $RuntimeEventCodec with _i1.Codec { return (value as WeTEEDsecret)._sizeHint(); case WeTEEBridge: return (value as WeTEEBridge)._sizeHint(); + case WeTEEMatrix: + return (value as WeTEEMatrix)._sizeHint(); default: throw Exception( 'RuntimeEvent: Unsupported "$value" of type "${value.runtimeType}"'); @@ -1268,3 +1280,46 @@ class WeTEEBridge extends RuntimeEvent { @override int get hashCode => value0.hashCode; } + +class WeTEEMatrix extends RuntimeEvent { + const WeTEEMatrix(this.value0); + + factory WeTEEMatrix._decode(_i1.Input input) { + return WeTEEMatrix(_i25.Event.codec.decode(input)); + } + + /// wetee_matrix::Event + final _i25.Event value0; + + @override + Map> toJson() => + {'WeTEEMatrix': value0.toJson()}; + + int _sizeHint() { + int size = 1; + size = size + _i25.Event.codec.sizeHint(value0); + return size; + } + + void encodeTo(_i1.Output output) { + _i1.U8Codec.codec.encodeTo( + 25, + output, + ); + _i25.Event.codec.encodeTo( + value0, + output, + ); + } + + @override + bool operator ==(Object other) => + identical( + this, + other, + ) || + other is WeTEEMatrix && other.value0 == value0; + + @override + int get hashCode => value0.hashCode; +} diff --git a/lib/application/chain/wetee/wetee_gen/wetee_gen.dart b/lib/application/chain/wetee/wetee_gen/wetee_gen.dart index 1a225554..29b42b0e 100644 --- a/lib/application/chain/wetee/wetee_gen/wetee_gen.dart +++ b/lib/application/chain/wetee/wetee_gen/wetee_gen.dart @@ -1,5 +1,5 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'dart:async' as _i27; +import 'dart:async' as _i28; import 'package:polkadart/polkadart.dart' as _i1; @@ -13,20 +13,21 @@ import 'pallets/system.dart' as _i2; import 'pallets/timestamp.dart' as _i3; import 'pallets/tokens.dart' as _i9; import 'pallets/transaction_payment.dart' as _i7; -import 'pallets/utility.dart' as _i24; +import 'pallets/utility.dart' as _i25; import 'pallets/we_t_e_e_app.dart' as _i17; import 'pallets/we_t_e_e_asset.dart' as _i13; import 'pallets/we_t_e_e_bridge.dart' as _i23; import 'pallets/we_t_e_e_dsecret.dart' as _i22; import 'pallets/we_t_e_e_gov.dart' as _i16; import 'pallets/we_t_e_e_gpu.dart' as _i19; -import 'pallets/we_t_e_e_guild.dart' as _i25; +import 'pallets/we_t_e_e_guild.dart' as _i26; +import 'pallets/we_t_e_e_matrix.dart' as _i24; import 'pallets/we_t_e_e_message_queue.dart' as _i11; import 'pallets/we_t_e_e_org.dart' as _i12; import 'pallets/we_t_e_e_project.dart' as _i15; import 'pallets/we_t_e_e_sudo.dart' as _i14; import 'pallets/we_t_e_e_task.dart' as _i18; -import 'pallets/we_t_e_e_treasury.dart' as _i26; +import 'pallets/we_t_e_e_treasury.dart' as _i27; import 'pallets/we_t_e_e_worker.dart' as _i20; class Queries { @@ -52,7 +53,8 @@ class Queries { weTEEWorker = _i20.Queries(api), contracts = _i21.Queries(api), weTEEDsecret = _i22.Queries(api), - weTEEBridge = _i23.Queries(api); + weTEEBridge = _i23.Queries(api), + weTEEMatrix = _i24.Queries(api); final _i2.Queries system; @@ -97,6 +99,8 @@ class Queries { final _i22.Queries weTEEDsecret; final _i23.Queries weTEEBridge; + + final _i24.Queries weTEEMatrix; } class Extrinsics { @@ -116,7 +120,7 @@ class Extrinsics { final _i11.Txs weTEEMessageQueue = _i11.Txs(); - final _i24.Txs utility = _i24.Txs(); + final _i25.Txs utility = _i25.Txs(); final _i12.Txs weTEEOrg = _i12.Txs(); @@ -124,13 +128,13 @@ class Extrinsics { final _i14.Txs weTEESudo = _i14.Txs(); - final _i25.Txs weTEEGuild = _i25.Txs(); + final _i26.Txs weTEEGuild = _i26.Txs(); final _i15.Txs weTEEProject = _i15.Txs(); final _i16.Txs weTEEGov = _i16.Txs(); - final _i26.Txs weTEETreasury = _i26.Txs(); + final _i27.Txs weTEETreasury = _i27.Txs(); final _i17.Txs weTEEApp = _i17.Txs(); @@ -145,6 +149,8 @@ class Extrinsics { final _i22.Txs weTEEDsecret = _i22.Txs(); final _i23.Txs weTEEBridge = _i23.Txs(); + + final _i24.Txs weTEEMatrix = _i24.Txs(); } class Constants { @@ -166,11 +172,13 @@ class Constants { final _i11.Constants weTEEMessageQueue = _i11.Constants(); - final _i24.Constants utility = _i24.Constants(); + final _i25.Constants utility = _i25.Constants(); final _i12.Constants weTEEOrg = _i12.Constants(); final _i21.Constants contracts = _i21.Constants(); + + final _i24.Constants weTEEMatrix = _i24.Constants(); } class Rpc { @@ -240,11 +248,11 @@ class WeteeGen { final Registry registry; - _i27.Future connect() async { + _i28.Future connect() async { return await _provider.connect(); } - _i27.Future disconnect() async { + _i28.Future disconnect() async { return await _provider.disconnect(); } } diff --git a/lib/application/service/apis/account_org_api.dart b/lib/application/service/apis/account_org_api.dart index 4d22d1d9..8e8d3841 100644 --- a/lib/application/service/apis/account_org_api.dart +++ b/lib/application/service/apis/account_org_api.dart @@ -46,7 +46,6 @@ class AccountOrgApi { saveApp(String userId, String orgHash, List apps) async { var org = storeBox.get(userId + orgHash); if (org != null) { - org.apps = apps; await storeBox.put(userId + orgHash, org); } } @@ -62,16 +61,16 @@ class AccountOrgApi { } else if (org.logo != null && org.logo != "") { img = org.logo!; } - at.orgName = org.name; - at.orgDesc = org.desc; - at.orgAvater = org.logo; - at.orgImg = img; - at.orgColor = org.bg; + at.nodeName = org.name; + at.nodeDesc = org.desc; + at.nodeAvater = org.logo; + at.nodeImg = img; + at.nodeColor = org.bg; at.domain = org.imApi; at.status = 1; at.withAddr = address; at.account = account!; - at.daoId = org.daoId; + at.nodeId = org.daoId; await storeBox.put(address + org.hash, at); } @@ -94,13 +93,13 @@ class AccountOrgApi { for (var j = 0; j < storeOrgs.length; j++) { var storeIndex = -1; for (var i = 0; i < fs.length; i++) { - if (storeOrgs[j].orgHash == fs[i]) { + if (storeOrgs[j].nodeHash == fs[i]) { storeIndex = i; } } // 删除 if (storeIndex == -1) { - await storeBox.delete(address + storeOrgs[j].orgHash); + await storeBox.delete(address + storeOrgs[j].nodeHash); } } @@ -108,7 +107,7 @@ class AccountOrgApi { for (var i = 0; i < fs.length; i++) { var storeIndex = -1; for (var j = 0; j < storeOrgs.length; j++) { - if (storeOrgs[j].orgHash == fs[i]) { + if (storeOrgs[j].nodeHash == fs[i]) { storeIndex = j; } } @@ -118,31 +117,31 @@ class AccountOrgApi { // 新增 if (org != null) { final at = AccountOrg(org.hash); - at.orgName = org.name; - at.orgDesc = org.desc; - at.orgAvater = org.logo; - at.orgImg = org.img; - at.orgColor = org.bg; + at.nodeName = org.name; + at.nodeDesc = org.desc; + at.nodeAvater = org.logo; + at.nodeImg = org.img; + at.nodeColor = org.bg; at.domain = org.imApi; at.status = 1; at.withAddr = address; at.account = account!; - at.daoId = org.daoId; + at.nodeId = org.daoId; await storeBox.put(address + org.hash, at); } } else { // 更新 if (org != null) { - storeOrgs[storeIndex].orgName = org.name; - storeOrgs[storeIndex].orgDesc = org.desc; - storeOrgs[storeIndex].orgAvater = org.logo; - storeOrgs[storeIndex].orgImg = org.img; - storeOrgs[storeIndex].orgColor = org.bg; + storeOrgs[storeIndex].nodeName = org.name; + storeOrgs[storeIndex].nodeDesc = org.desc; + storeOrgs[storeIndex].nodeAvater = org.logo; + storeOrgs[storeIndex].nodeImg = org.img; + storeOrgs[storeIndex].nodeColor = org.bg; storeOrgs[storeIndex].domain = org.imApi; storeOrgs[storeIndex].status = 1; storeOrgs[storeIndex].withAddr = address; storeOrgs[storeIndex].account = account!; - storeOrgs[storeIndex].daoId = org.daoId; + storeOrgs[storeIndex].nodeId = org.daoId; await storeBox.put(address + org.hash, storeOrgs[storeIndex]); } } diff --git a/lib/application/store/chain_ctx.dart b/lib/application/store/chain_ctx.dart index 1831e92f..1c5f2cad 100644 --- a/lib/application/store/chain_ctx.dart +++ b/lib/application/store/chain_ctx.dart @@ -4,9 +4,8 @@ import 'dart:convert'; import 'package:convert/convert.dart'; import 'package:adaptive_dialog/adaptive_dialog.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/orml_tokens/account_data.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_gov/period.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_gov/vote_info.dart'; +import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart'; +import 'package:dtim/router.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; @@ -14,27 +13,17 @@ import 'package:flutter/material.dart'; import 'package:dtim/application/chain/wetee/wetee.dart'; import 'package:dtim/infra/components/components.dart'; import 'package:dtim/domain/models/models.dart'; -import 'package:dtim/router.dart'; import 'package:dtim/domain/utils/functions.dart'; import 'package:dtim/domain/utils/platform_infos.dart'; import 'package:polkadart/polkadart.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_org/guild_info.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_org/org_info.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_project/project_info.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_gov/pre_prop.dart'; -import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_gov/prop.dart'; // final chainUrl = PlatformInfos.isDesktop ? "ws://chain.gc.wetee.app:80" : "wss://chain.gc.wetee.app"; -const chainUrl = "https://xiaobai.asyou.me:30001"; +const chainUrl = "wss://xiaobai.asyou.me:30001"; -class WeTEECTX with ChangeNotifier { +class GlobalCTX with ChangeNotifier { late Account user; late AccountOrg org; - late OrgInfo dao; - late AccountData daoAmount; - late int userPoint; - late AccountData nativeAmount; - late AccountData share; + late NodeInfo node; WeTEE? chainClient; Provider? provider; @@ -43,14 +32,7 @@ class WeTEECTX with ChangeNotifier { int totalIssuance = 0; int daoRefreshChannel = 0; bool reConnecting = false; - List guilds = []; - List projects = []; - List members = []; String ss58Address = ""; - List votes = []; - List pending = []; - List going = []; - List periods = []; List callbacks = []; setOrg(AccountOrg porg, Account puser) { @@ -60,7 +42,7 @@ class WeTEECTX with ChangeNotifier { connectChain(Function? callback) async { if (chainClient != null) { - if (org.daoId == "") { + if (org.nodeId == "") { callback?.call(); return; } @@ -110,39 +92,12 @@ class WeTEECTX with ChangeNotifier { // 区块链代码 blockNumber = await chainClient!.getBlockNumber(); - if (org.daoId == "") return; - final daoId = BigInt.tryParse(org.daoId)!; - final publicKey = hex.decode(user.address); + if (org.nodeId == "") return; + final nodeId = BigInt.tryParse(org.nodeId)!; + // final publicKey = hex.decode(user.address); // DAO信息 - dao = (await chainClient!.query.weTEEOrg.daos(daoId))!; - daoAmount = await chainClient!.query.tokens.accounts(dao.daoAccountId, BigInt.from(0)); - totalIssuance = (await chainClient!.query.tokens.totalIssuance(daoId)).toInt(); - - // 工会&项目 - guilds = await chainClient!.query.weTEEOrg.guilds(daoId); - projects = await chainClient!.query.weTEEProject.daoProjects(daoId); - - // 用户荣誉点 share 链上金额 - userPoint = await chainClient!.query.weTEEOrg.memberPoint(daoId, publicKey); - share = await chainClient!.query.tokens.accounts(publicKey, daoId); - nativeAmount = await chainClient!.query.tokens.accounts(publicKey, BigInt.from(0)); - ss58Address = user.ss58Address; - - // DAO 成员 - members = (await chainClient!.query.weTEEOrg.members(daoId)).map((e) =>"0x${hex.encode(e)}").toList(); - votes = await chainClient!.query.weTEEGov.votesOf(publicKey); - - periods = await chainClient!.query.weTEEGov.periods(daoId); - - if (notify) notifyListeners(); - } - - getVoteData({notify = true}) async { - if (org.daoId == 0) return; - pending = await chainClient!.query.weTEEGov.preProps(BigInt.tryParse(org.daoId)!); - going = []; - // await chainClient!.query.weTEEGov.props(BigInt.from(org.daoId), key2); + node = (await chainClient!.query.weTEEMatrix.matrix(nodeId))!; if (notify) notifyListeners(); } @@ -154,42 +109,15 @@ class WeTEECTX with ChangeNotifier { if (daoRefreshChannel > 0) { daoRefreshChannel--; await getData(); - await getVoteData(); } else { if (user.address != '') { - if (org.daoId == 0) return; - nativeAmount = await chainClient!.query.tokens.accounts(hex.decode(user.address), BigInt.from(0)); - share = await chainClient!.query.tokens.accounts(hex.decode(user.address), BigInt.tryParse(org.daoId)!); + if (org.nodeId == "0") return; } } notifyListeners(); } } - Future checkAfterTx() async { - if (!members.contains(user.address)) { - BotToast.showText(text: 'You are not a member of this Org workgroup', duration: const Duration(seconds: 2)); - return false; - } - if (nativeAmount.free < BigInt.from(100)) { - BotToast.showText( - text: "The user's balance is not enough to pay the handling fee", - duration: const Duration(seconds: 2), - ); - return false; - } - return await inputPassword(); - } - - Future daoRefresh() async { - daoRefreshChannel = 3; - BotToast.showText( - text: 'Successfully, data will take effect in subsequent blocks ', duration: const Duration(seconds: 2)); - await getData(); - await getVoteData(); - notifyListeners(); - } - Future inputPassword() async { return await inputPasswordg(user); } @@ -197,7 +125,7 @@ class WeTEECTX with ChangeNotifier { WeTEE get client => chainClient!; } -final weteeCtx = WeTEECTX(); +final chainCtx = GlobalCTX(); Future inputPasswordg(Account user) async { if (!PlatformInfos.isWeb) { diff --git a/lib/domain/models/account.dart b/lib/domain/models/account.dart index 939329b3..d7818233 100644 --- a/lib/domain/models/account.dart +++ b/lib/domain/models/account.dart @@ -1,8 +1,6 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:hive/hive.dart'; -import 'org.dart'; - part 'account.g.dart'; @HiveType(typeId: 1) @@ -31,54 +29,54 @@ class Account extends HiveObject { late String chainData; @HiveField(5) - late List orgs; + late List nodes; // 区块链地址 @HiveField(7) late String ss58Address; - Account({required this.address, required this.chainData, required this.ss58Address, required this.orgs}); + Account({required this.address, required this.chainData, required this.ss58Address, required this.nodes}); } @HiveType(typeId: 2) class AccountOrg { - // 组织hash + // 节点hash @HiveField(2) - String orgHash = ""; + String nodeHash = ""; - // 组织名 + // 节点名 @HiveField(3) - String? orgName; + String? nodeName; - // 组织名 + // 节点名 @HiveField(14) - String? orgDesc; + String? nodeDesc; - // 组织主颜色 + // 节点主颜色 @HiveField(4) - String? orgColor; + String? nodeColor; - // 组织头像 + // 节点头像 @HiveField(5) - String? orgAvater; + String? nodeAvater; - // 组织图片 + // 节点图片 @HiveField(6) - String? orgImg; + String? nodeImg; - // 组织授权网址 + // 节点授权网址 @HiveField(7) String? domain; - // 组织Id + // 节点Id @HiveField(9) - String daoId = ""; + String nodeId = ""; // 区块链连接点 @HiveField(13) String? theme; - // 组织状态 1=>激活 2=>暂停 3=>删除 + // 节点状态 1=>激活 2=>暂停 3=>删除 @HiveField(10) int status = 1; @@ -89,11 +87,7 @@ class AccountOrg { @HiveField(12) late Account account; - // 应用列表 - @HiveField(15) - List? apps = []; - - AccountOrg(this.orgHash); + AccountOrg(this.nodeHash); } @JsonSerializable() diff --git a/lib/domain/models/account.g.dart b/lib/domain/models/account.g.dart index 6e6450d6..9131ef30 100644 --- a/lib/domain/models/account.g.dart +++ b/lib/domain/models/account.g.dart @@ -20,7 +20,7 @@ class AccountAdapter extends TypeAdapter { address: fields[3] as String, chainData: fields[4] as String, ss58Address: fields[7] as String, - orgs: (fields[5] as List).cast(), + nodes: (fields[5] as List).cast(), ) ..id = fields[0] as int ..name = fields[1] as String? @@ -45,7 +45,7 @@ class AccountAdapter extends TypeAdapter { ..writeByte(4) ..write(obj.chainData) ..writeByte(5) - ..write(obj.orgs) + ..write(obj.nodes) ..writeByte(7) ..write(obj.ss58Address); } @@ -74,40 +74,39 @@ class AccountOrgAdapter extends TypeAdapter { return AccountOrg( fields[2] as String, ) - ..orgName = fields[3] as String? - ..orgDesc = fields[14] as String? - ..orgColor = fields[4] as String? - ..orgAvater = fields[5] as String? - ..orgImg = fields[6] as String? + ..nodeName = fields[3] as String? + ..nodeDesc = fields[14] as String? + ..nodeColor = fields[4] as String? + ..nodeAvater = fields[5] as String? + ..nodeImg = fields[6] as String? ..domain = fields[7] as String? - ..daoId = fields[9] as String + ..nodeId = fields[9] as String ..theme = fields[13] as String? ..status = fields[10] as int ..withAddr = fields[11] as String - ..account = fields[12] as Account - ..apps = (fields[15] as List?)?.cast(); + ..account = fields[12] as Account; } @override void write(BinaryWriter writer, AccountOrg obj) { writer - ..writeByte(13) + ..writeByte(12) ..writeByte(2) - ..write(obj.orgHash) + ..write(obj.nodeHash) ..writeByte(3) - ..write(obj.orgName) + ..write(obj.nodeName) ..writeByte(14) - ..write(obj.orgDesc) + ..write(obj.nodeDesc) ..writeByte(4) - ..write(obj.orgColor) + ..write(obj.nodeColor) ..writeByte(5) - ..write(obj.orgAvater) + ..write(obj.nodeAvater) ..writeByte(6) - ..write(obj.orgImg) + ..write(obj.nodeImg) ..writeByte(7) ..write(obj.domain) ..writeByte(9) - ..write(obj.daoId) + ..write(obj.nodeId) ..writeByte(13) ..write(obj.theme) ..writeByte(10) @@ -115,9 +114,7 @@ class AccountOrgAdapter extends TypeAdapter { ..writeByte(11) ..write(obj.withAddr) ..writeByte(12) - ..write(obj.account) - ..writeByte(15) - ..write(obj.apps); + ..write(obj.account); } @override diff --git a/lib/infra/components/app_card.dart b/lib/infra/components/app_card.dart index 5b3fae16..aef71f82 100644 --- a/lib/infra/components/app_card.dart +++ b/lib/infra/components/app_card.dart @@ -121,7 +121,7 @@ class AppCard extends StatelessWidget { // context: globalCtx(), // future: () async { // await rustApi.createAsset( - // client: weteeCtx.chainClient, + // client: chainCtx.chainClient, // from: im.me!.address, // daoId: im.currentState!.org.daoId, // name: input[0], @@ -130,7 +130,7 @@ class AppCard extends StatelessWidget { // symbol: input[1], // ); // await rustApi.orgIntegrateApp( - // client: weteeCtx.chainClient, + // client: chainCtx.chainClient, // from: im.me!.address, // orgId: im.currentState!.org.daoId, // appId: id, @@ -164,11 +164,11 @@ class AppCard extends StatelessWidget { await waitFutureLoading( context: globalCtx(), future: () async { - final call = weteeCtx.client.tx.weTEEOrg.orgIntegrateApp( - daoId: BigInt.tryParse(weteeCtx.org.daoId)!, + final call = chainCtx.client.tx.weTEEOrg.orgIntegrateApp( + daoId: BigInt.tryParse(chainCtx.org.nodeId)!, appId: id, ); - await weteeCtx.client.signAndSubmit(call, weteeCtx.user.address, gov: gov); + await chainCtx.client.signAndSubmit(call, chainCtx.user.address, gov: gov); BotToast.showText(text: gov.runType == 2 ? "应用集成成功" : "应用集成提案将显示在治理中,请到治理插件中开启投票"); }, ); diff --git a/lib/infra/components/dao/dao_is_joined.dart b/lib/infra/components/dao/dao_is_joined.dart index 6d8c06b6..b204b7f3 100644 --- a/lib/infra/components/dao/dao_is_joined.dart +++ b/lib/infra/components/dao/dao_is_joined.dart @@ -63,13 +63,7 @@ class DaoIsJoined extends StatelessWidget { ElevatedButton( key: const Key('joinDao'), onPressed: () { - if (weteeCtx.nativeAmount.free < BigInt.from(100)) { - BotToast.showText( - text: "The user's balance is not enough to pay the handling fee", - duration: const Duration(seconds: 2)); - return; - } - showModelOrPage(context, "/join_dao"); + }, style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith((states) => constTheme.buttonBg), diff --git a/lib/infra/components/dao/payments_detail_list.dart b/lib/infra/components/dao/payments_detail_list.dart index 56d8fb94..c61f60a8 100644 --- a/lib/infra/components/dao/payments_detail_list.dart +++ b/lib/infra/components/dao/payments_detail_list.dart @@ -76,35 +76,35 @@ class PaymentsDetailList extends StatelessWidget { ), ), SizedBox(height: 20.w), - Consumer(builder: (_, dao, child) { + Consumer(builder: (_, dao, child) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ PrimaryText( - text: dao.votes.isNotEmpty ? 'My ongoing vote' : 'No ongoing vote', + text: 'My ongoing vote', size: 18, fontWeight: FontWeight.w800, ), ], ); }), - Consumer(builder: (_, dao, child) { - return Column( - children: List.generate( - dao.votes.length, - (index) => PaymentListTile( - icon: Icons.how_to_vote_rounded, - amount: "Share ${dao.votes[index].pledge}", - label: "Referendum #${dao.votes[index].propIndex}", - action: Icon( - dao.votes[index].opinion == 1 ? Icons.check_circle_outline_rounded : Icons.cancel_outlined, - color: dao.votes[index].opinion == 1 ? constTheme.buttonBg : constTheme.errorTextColor, - size: 25.w, - ), - ), - ), - ); - }), + // Consumer(builder: (_, dao, child) { + // return Column( + // children: List.generate( + // dao.votes.length, + // (index) => PaymentListTile( + // icon: Icons.how_to_vote_rounded, + // amount: "Share ${dao.votes[index].pledge}", + // label: "Referendum #${dao.votes[index].propIndex}", + // action: Icon( + // dao.votes[index].opinion == 1 ? Icons.check_circle_outline_rounded : Icons.cancel_outlined, + // color: dao.votes[index].opinion == 1 ? constTheme.buttonBg : constTheme.errorTextColor, + // size: 25.w, + // ), + // ), + // ), + // ); + // }), // SizedBox(height: 15.w), // Column( // crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/infra/components/gov_pop.dart b/lib/infra/components/gov_pop.dart index 854c55ea..ea3cb8b9 100644 --- a/lib/infra/components/gov_pop.dart +++ b/lib/infra/components/gov_pop.dart @@ -39,8 +39,8 @@ class _GovPopState extends State { getData() async { // periods = await XXXXdaoGovPeriods( - // client: weteeCtx.chainClient, - // orgId: weteeCtx.org.daoId, + // client: chainCtx.chainClient, + // orgId: chainCtx.org.daoId, // ); // print(periods); setState(() {}); @@ -51,15 +51,15 @@ class _GovPopState extends State { return; } _formKey.currentState!.save(); - widget.closeModel!.call( - WithGovPs( - runType: _data.type, - amount: 0, - member: widget.member, - periodIndex: _data.periodIndex, - daoId: weteeCtx.dao.id, - ), - ); + // widget.closeModel!.call( + // WithGovPs( + // runType: _data.type, + // amount: 0, + // member: widget.member, + // periodIndex: _data.periodIndex, + // daoId: chainCtx.dao.id, + // ), + // ); } @override diff --git a/lib/infra/components/me_pop.dart b/lib/infra/components/me_pop.dart index 246dfbcd..d13bdcd2 100644 --- a/lib/infra/components/me_pop.dart +++ b/lib/infra/components/me_pop.dart @@ -204,7 +204,7 @@ class _MePopState extends State { onTap: () async { final im = context.read(); menuController.hideMenu(); - weteeCtx.disconnectChain(); + chainCtx.disconnectChain(); await im.logout(); }, child: Container( diff --git a/lib/infra/components/window.dart b/lib/infra/components/window.dart index 7d3f527d..3173d93a 100644 --- a/lib/infra/components/window.dart +++ b/lib/infra/components/window.dart @@ -68,7 +68,7 @@ class _AeroFrameState extends State with WindowListener { (_isMaximized || _isFullScreen) ? 0 : 16, ), child: Container( - margin: const EdgeInsets.all(8), + margin: const EdgeInsets.all(6), child: ClipRRect( clipBehavior: Clip.hardEdge, borderRadius: BorderRadius.circular( diff --git a/lib/infra/pages/chain/import_sr25519_key.dart b/lib/infra/pages/chain/import_sr25519_key.dart index ea2ae820..25dd6dc1 100644 --- a/lib/infra/pages/chain/import_sr25519_key.dart +++ b/lib/infra/pages/chain/import_sr25519_key.dart @@ -308,7 +308,7 @@ class _ImportSr25519KeyPageState extends State with Window address: chainData.address, ss58Address: chainData.meta["ss58Address"]!, chainData: json.encode(chainData.toJson()), - orgs: [], + nodes: [], ); initUser.name = chainData.meta["name"]; initUser.domain = ""; diff --git a/lib/infra/pages/chain/sr25519_key.dart b/lib/infra/pages/chain/sr25519_key.dart index 8b0e2618..e358f9a1 100644 --- a/lib/infra/pages/chain/sr25519_key.dart +++ b/lib/infra/pages/chain/sr25519_key.dart @@ -346,7 +346,7 @@ class _Sr25519KeyPageState extends State with WindowListener { address: chainData.address, chainData: json.encode(chainData.toJson()), ss58Address: chainData.meta["ss58Address"]!, - orgs: [], + nodes: [], ); initUser.name = chainData.meta["name"]; initUser.domain = ""; diff --git a/lib/infra/pages/integrate/integrate.dart b/lib/infra/pages/integrate/integrate.dart index ce6c1c0b..a6041452 100644 --- a/lib/infra/pages/integrate/integrate.dart +++ b/lib/infra/pages/integrate/integrate.dart @@ -35,17 +35,17 @@ class _IntegratePageState extends State { void initState() { super.initState(); im = context.read(); - weteeCtx.setOrg(im.currentState!.org, im.me!); - weteeCtx.connectChain(() { - getData(); - }); + chainCtx.setOrg(im.currentState!.org, im.me!); + // chainCtx.connectChain(() { + // getData(); + // }); } getData() async { - // apps = await rustApi.appHubs(client: weteeCtx.chainClient); + // apps = await rustApi.appHubs(client: chainCtx.chainClient); // TODO apps = []; - oapps = trans(await weteeCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(weteeCtx.org.daoId)!)); + oapps = trans(await chainCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(chainCtx.org.nodeId)!)); loding = false; setState(() {}); } diff --git a/lib/infra/pages/main_mobile.dart b/lib/infra/pages/main_mobile.dart index 8ec9553c..21027ec4 100644 --- a/lib/infra/pages/main_mobile.dart +++ b/lib/infra/pages/main_mobile.dart @@ -64,9 +64,9 @@ class _MobilePageState extends State { } if (im.currentState != null) { var u = await im.currentState!.client.getAvatarUrl(im.currentState!.client.userID ?? ""); - AccountOrg? org = accountOrgApi.getOrg(im.me!.address, im.currentState!.org.orgHash); + AccountOrg? org = accountOrgApi.getOrg(im.me!.address, im.currentState!.org.nodeHash); if (org != null) { - apps = org.apps ?? []; + // apps = org.apps ?? []; } if (mounted) { setState(() { @@ -74,10 +74,10 @@ class _MobilePageState extends State { }); } - weteeCtx.setOrg(im.currentState!.org, im.me!); - weteeCtx.connectChain(() async { - apps = trans(await weteeCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(im.currentState!.org.daoId)!)); - await accountOrgApi.saveApp(im.me!.address, im.currentState!.org.orgHash, apps); + chainCtx.setOrg(im.currentState!.org, im.me!); + chainCtx.connectChain(() async { + apps = trans(await chainCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(im.currentState!.org.nodeId)!)); + await accountOrgApi.saveApp(im.me!.address, im.currentState!.org.nodeHash, apps); if (mounted) { setState(() {}); } diff --git a/lib/infra/pages/main_pc.dart b/lib/infra/pages/main_pc.dart index 67089a66..c33a5099 100644 --- a/lib/infra/pages/main_pc.dart +++ b/lib/infra/pages/main_pc.dart @@ -68,9 +68,9 @@ class _PCPageState extends State { } if (im.currentState != null) { var u = await im.currentState!.client.getAvatarUrl(im.currentState!.client.userID ?? ""); - AccountOrg? org = accountOrgApi.getOrg(im.me!.address, im.currentState!.org.orgHash); + AccountOrg? org = accountOrgApi.getOrg(im.me!.address, im.currentState!.org.nodeHash); if (org != null) { - apps = org.apps ?? []; + // apps = org.apps ?? []; } if (mounted) { setState(() { @@ -78,14 +78,14 @@ class _PCPageState extends State { }); } - weteeCtx.setOrg(im.currentState!.org, im.me!); - // weteeCtx.connectChain(() async { - // apps = trans(await weteeCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(im.currentState!.org.daoId)!)); - // await accountOrgApi.saveApp(im.me!.address, im.currentState!.org.orgHash, apps); - // if (mounted) { - // setState(() {}); - // } - // }); + chainCtx.setOrg(im.currentState!.org, im.me!); + chainCtx.connectChain(() async { + apps = trans(await chainCtx.client.query.weTEEOrg.orgApps(BigInt.tryParse(im.currentState!.org.nodeId)!)); + await accountOrgApi.saveApp(im.me!.address, im.currentState!.org.nodeHash, apps); + if (mounted) { + setState(() {}); + } + }); } } @@ -241,7 +241,7 @@ class _PCPageState extends State { for (var i = 0; i < aorgs!.length; i++) GestureDetector( onTap: () async { - if (im.currentState!.org.daoId == aorgs![i].daoId) { + if (im.currentState!.org.nodeId == aorgs![i].nodeId) { return; } if (im.sign == "") { @@ -266,36 +266,36 @@ class _PCPageState extends State { await getData(); }, child: Container( - width: im.currentState!.org.daoId == aorgs![i].daoId ? 40.w : 42.w, - height: im.currentState!.org.daoId == aorgs![i].daoId ? 40.w : 42.w, - padding: im.currentState!.org.daoId == aorgs![i].daoId ? EdgeInsets.all(2.w) : null, + width: im.currentState!.org.nodeId == aorgs![i].nodeId ? 40.w : 42.w, + height: im.currentState!.org.nodeId == aorgs![i].nodeId ? 40.w : 42.w, + padding: im.currentState!.org.nodeId == aorgs![i].nodeId ? EdgeInsets.all(2.w) : null, margin: EdgeInsets.fromLTRB(0, 10.w, 0, 0), decoration: BoxDecoration( color: constTheme.sidebarHeaderTextColor.withOpacity(0.1), borderRadius: BorderRadius.circular(8.w), border: Border.all( - color: im.currentState!.org.daoId == aorgs![i].daoId + color: im.currentState!.org.nodeId == aorgs![i].nodeId ? constTheme.sidebarTextActiveBorder.withOpacity(0.7) : constTheme.sidebarBg, width: 2.w, ), ), child: Container( - width: im.currentState!.org.daoId == aorgs![i].daoId ? 36.w : 42.w, - height: im.currentState!.org.daoId == aorgs![i].daoId ? 36.w : 42.w, + width: im.currentState!.org.nodeId == aorgs![i].nodeId ? 36.w : 42.w, + height: im.currentState!.org.nodeId == aorgs![i].nodeId ? 36.w : 42.w, decoration: BoxDecoration( - color: aorgs![i].orgColor != null - ? hexToColor(aorgs![i].orgColor!) + color: aorgs![i].nodeColor != null + ? hexToColor(aorgs![i].nodeColor!) : constTheme.sidebarText.withOpacity(0.02), borderRadius: BorderRadius.circular(4.w), ), - child: aorgs![i].orgAvater == null + child: aorgs![i].nodeAvater == null ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - if (aorgs![i].orgAvater == null) + if (aorgs![i].nodeAvater == null) Text( - aorgs![i].orgName ?? "", + aorgs![i].nodeName ?? "", textAlign: TextAlign.center, style: TextStyle( color: constTheme.sidebarHeaderTextColor.withOpacity(0.8), @@ -309,15 +309,15 @@ class _PCPageState extends State { borderRadius: BorderRadius.circular(6.w), child: Image.network( fit: BoxFit.cover, - aorgs![i].orgAvater!, - width: im.currentState!.org.daoId == aorgs![i].daoId ? 36.w : 42.w, - height: im.currentState!.org.daoId == aorgs![i].daoId ? 36.w : 42.w, + aorgs![i].nodeAvater!, + width: im.currentState!.org.nodeId == aorgs![i].nodeId ? 36.w : 42.w, + height: im.currentState!.org.nodeId == aorgs![i].nodeId ? 36.w : 42.w, loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent? loadingProgress) { if (loadingProgress == null) return child; return Center( child: Text( - aorgs![i].orgName != null ? aorgs![i].orgName![0] : "-", + aorgs![i].nodeName != null ? aorgs![i].nodeName![0] : "-", style: TextStyle(fontSize: 16.w, color: constTheme.sidebarText), ), ); @@ -326,7 +326,7 @@ class _PCPageState extends State { (BuildContext context, Object exception, StackTrace? stackTrace) { return Center( child: Text( - aorgs![i].orgName != null ? aorgs![i].orgName![0] : "-", + aorgs![i].nodeName != null ? aorgs![i].nodeName![0] : "-", style: TextStyle(fontSize: 16.w, color: constTheme.sidebarText), ), ); diff --git a/lib/infra/pages/org/create_org.dart b/lib/infra/pages/org/create_org.dart index f20e5dad..db436d95 100644 --- a/lib/infra/pages/org/create_org.dart +++ b/lib/infra/pages/org/create_org.dart @@ -433,9 +433,9 @@ class _CreateOrgPageState extends State with WindowListener { _formKey.currentState!.save(); final im = context.read(); - weteeCtx.setOrg(im.currentState!.org, im.me!); - weteeCtx.connectChain(() async { - printInfo("weteeCtx.connectChain2"); + chainCtx.setOrg(im.currentState!.org, im.me!); + chainCtx.connectChain(() async { + printInfo("chainCtx.connectChain2"); if (!await inputPasswordg(im.me!)) { return; } @@ -444,7 +444,7 @@ class _CreateOrgPageState extends State with WindowListener { future: () async { printSuccess(_imController.text.replaceAll(RegExp(r"\s*"), "")); try { - final call = weteeCtx.client.tx.weTEEOrg.createDao( + final call = chainCtx.client.tx.weTEEOrg.createDao( name: strToChain(_data.name), purpose: strToChain(_data.purpose), metaData: strToChain("{}"), @@ -457,7 +457,7 @@ class _CreateOrgPageState extends State with WindowListener { ); // 提交 - await weteeCtx.client.signAndSubmit(call, weteeCtx.user.address); + await chainCtx.client.signAndSubmit(call, chainCtx.user.address); } catch (e) { return "The user's balance is not enough to pay the handling fee"; } diff --git a/lib/infra/pages/org/org_menu.dart b/lib/infra/pages/org/org_menu.dart index 17e5360c..f0730654 100644 --- a/lib/infra/pages/org/org_menu.dart +++ b/lib/infra/pages/org/org_menu.dart @@ -26,7 +26,7 @@ List> menuItems = [ ItemModel('离开组织', onTap: (id, im) async { final accountOrgApi = await AccountOrgApi.create(); final orgs = await accountOrgApi.listByAccount(im.me!.address); - orgs.removeWhere((o) => o.orgHash == im.currentState!.org.orgHash); + orgs.removeWhere((o) => o.nodeHash == im.currentState!.org.nodeHash); if (OkCancelResult.ok == await showOkCancelAlertDialog( useRootNavigator: false, @@ -40,7 +40,7 @@ List> menuItems = [ title: "处理中...", context: globalCtx(), future: () async { - await accountOrgApi.deleteOrg(im.me!.address, im.currentState!.org.orgHash); + await accountOrgApi.deleteOrg(im.me!.address, im.currentState!.org.nodeHash); await im.logout(); }, ); diff --git a/lib/infra/pages/org/org_view.dart b/lib/infra/pages/org/org_view.dart index 0762badf..ed1da595 100644 --- a/lib/infra/pages/org/org_view.dart +++ b/lib/infra/pages/org/org_view.dart @@ -89,7 +89,7 @@ class _OrgViewPageState extends State { children: [ Expanded( child: Text( - imc.currentState!.org.orgName ?? "", + imc.currentState!.org.nodeName ?? "", softWrap: true, overflow: TextOverflow.ellipsis, style: TextStyle( diff --git a/lib/infra/pages/preloader.dart b/lib/infra/pages/preloader.dart index 4a4618a5..0fab8166 100644 --- a/lib/infra/pages/preloader.dart +++ b/lib/infra/pages/preloader.dart @@ -47,10 +47,10 @@ class _PreloaderPageState extends State with WindowListener { im = context.read(); getList(() { - weteeCtx.setOrg(AccountOrg(""), Account(address: "", chainData: "{}", orgs: [], ss58Address: '')); - weteeCtx.connectChain(() async { - setState(() => _loading = false); - }); + // chainCtx.setOrg(AccountOrg(""), Account(address: "", chainData: "{}", orgs: [], ss58Address: '')); + // chainCtx.connectChain(() async { + // setState(() => _loading = false); + // }); if (accounts.isNotEmpty && !runInTest) { autoLogin(); return; diff --git a/lib/infra/pages/select_org.dart b/lib/infra/pages/select_org.dart index 6177add3..10ccc4f1 100644 --- a/lib/infra/pages/select_org.dart +++ b/lib/infra/pages/select_org.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:adaptive_dialog/adaptive_dialog.dart'; +import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_matrix/node_info.dart'; import 'package:dtim/application/store/chain_ctx.dart'; import 'package:dtim/application/chain/wetee/wetee_gen/types/wetee_org/org_info.dart'; import 'package:dtim/domain/utils/functions.dart'; @@ -35,7 +36,7 @@ class _SelectOrgPageState extends State { List accounts = []; List userOrgs = []; List orgs = []; - WeTEECTX? wctx; + GlobalCTX? wctx; late AppCubit im; late AccountOrgApi accountOrgApi; @@ -63,14 +64,14 @@ class _SelectOrgPageState extends State { final vuser = await AccountApi.create(); accounts = await vuser.getUsers(); - final orgList = userOrgs.map((o) => o.orgHash).toList(); + final orgList = userOrgs.map((o) => o.nodeHash).toList(); selected = orgList; setState(() {}); - weteeCtx.setOrg(AccountOrg(""), im.me!); - weteeCtx.connectChain(() async { - final v = (await weteeCtx.client.queryMapList(module: 'WeteeOrg', storage: 'Daos')).map((b) { - return OrgInfo.decode(ByteInput(b)); + chainCtx.setOrg(AccountOrg(""), im.me!); + chainCtx.connectChain(() async { + final v = (await chainCtx.client.queryMapList(module: 'WeTEEMatrix', storage: 'Matrix')).map((b) { + return NodeInfo.decode(ByteInput(b)); }).toList(); print(v); orgs = v @@ -225,7 +226,7 @@ class _SelectOrgPageState extends State { okLabel: L10n.of(globalCtx())!.next, cancelLabel: L10n.of(globalCtx())!.cancel, )) { - await accountOrgApi.deleteOrg(im.me!.address, userOrgs[i].orgHash); + await accountOrgApi.deleteOrg(im.me!.address, userOrgs[i].nodeHash); await getData(); } }, @@ -245,10 +246,10 @@ class _SelectOrgPageState extends State { height: 130.w, decoration: BoxDecoration( color: - userOrgs[i].orgColor != null ? hexToColor(userOrgs[i].orgColor!) : Colors.transparent, + userOrgs[i].nodeColor != null ? hexToColor(userOrgs[i].nodeColor!) : Colors.transparent, ), child: Image.network( - userOrgs[i].orgImg ?? "", + userOrgs[i].nodeImg ?? "", width: 206.w, fit: BoxFit.cover, height: 130.w, @@ -262,7 +263,7 @@ class _SelectOrgPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "# ${userOrgs[i].orgName ?? "-"}", + "# ${userOrgs[i].nodeName ?? "-"}", style: TextStyle( color: constTheme.centerChannelColor, fontSize: 16.w, @@ -271,7 +272,7 @@ class _SelectOrgPageState extends State { overflow: TextOverflow.ellipsis, ), Text( - userOrgs[i].orgDesc ?? "", + userOrgs[i].nodeDesc ?? "", style: TextStyle( color: constTheme.centerChannelColor, fontSize: 12.w, diff --git a/lib/infra/pages/setting/theme.dart b/lib/infra/pages/setting/theme.dart index c8ad24b0..804acb65 100644 --- a/lib/infra/pages/setting/theme.dart +++ b/lib/infra/pages/setting/theme.dart @@ -70,7 +70,7 @@ class _ThemePageState extends State { description: const Text('选中后可看到效果,部分内容可能不会变化,重启后可消除'), onToggle: (String v) async { final accountOrgApi = await AccountOrgApi.create(); - await accountOrgApi.saveOrgTheme(im.me!.address + im.currentState!.org.orgHash, v); + await accountOrgApi.saveOrgTheme(im.me!.address + im.currentState!.org.nodeHash, v); // 设置全局设置,方便加载 final t = await setTheme(v); AdaptiveTheme.of(globalCtx()).setTheme( @@ -88,7 +88,7 @@ class _ThemePageState extends State { description: const Text('选中后可看到效果,部分内容可能不会变化,重启后可消除'), onToggle: (String v) async { final accountOrgApi = await AccountOrgApi.create(); - await accountOrgApi.saveOrgTheme(im.me!.address + im.currentState!.org.orgHash, v); + await accountOrgApi.saveOrgTheme(im.me!.address + im.currentState!.org.nodeHash, v); // 设置全局设置,方便加载 final t = await setTheme(v); AdaptiveTheme.of(globalCtx()).setTheme(