Skip to content

Commit 39a51dd

Browse files
committed
just to be safe
1 parent 324b0e0 commit 39a51dd

15 files changed

+848
-697
lines changed

.firebase/hosting.YnVpbGRcd2Vi.cache

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ assets/assets/img/down_red.svg,1746542305030,412733d5b4fe9db50f50491305f403e9f17
4949
assets/assets/img/down_gray.svg,1746542305030,c53b7d6f52f4727af1826ca8b4ea69e430428332847840b14593bba248e91464
5050
assets/assets/img/debate_tree_icon.png,1749918431533,01b587de0be2d676d8f7f4164a1f5bc36c51ecb810015b62f4e1d148242701ed
5151
assets/assets/img/daomic.png,1749918431533,5df2906f4140e0da26677d2dbdabd41484decd0b7c04308e30c521ebc4c6b7b6
52-
version.json,1750175752761,7a8150bbbb022ccc68f6918ae17c96dd48946ae20c63d291d51e8ebec37477a0
53-
index.html,1750175712474,47715042005db0a6b5bbb0e1337fba8a26c6e7a64791a096fed384a6f149b625
54-
flutter_service_worker.js,1750175757289,91dcaac7300565e4db5b2ecb03e3fd3b64ad17f3f2cd0ab5ffa4e5180b7535ea
55-
assets/FontManifest.json,1750175752984,40558917e686edef453bec6b1ce52fe20a28f93a6c047ada95a037e62112c6fd
56-
assets/AssetManifest.json,1750175752983,65b57b5a7562c148d26aab11e8fa194db9cb5676c25b4f74577bf64fd68c746b
57-
flutter_bootstrap.js,1750175712364,22b315b0c664629f842e7b12799bbb236dceb392216c58d7e3c201261d1e0734
58-
assets/AssetManifest.bin.json,1750175752983,a78fb0556ddc8c63a873a331c32884fd50005287f4d3f09358a6261ce2d2e1c2
59-
assets/AssetManifest.bin,1750175752983,ac9619a4b4098c84a5b572baad55b3b587b991f589b5aca0aecd943cb80b71e8
60-
assets/packages/cupertino_icons/assets/CupertinoIcons.ttf,1750175754695,d41473de1f7708a0702d7f19327693486512db442f6ab0cf7774e6d6576f9fcb
61-
assets/shaders/ink_sparkle.frag,1750175753129,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
62-
assets/fonts/MaterialIcons-Regular.otf,1750175754692,9a4157c815ba1b0b729c116546811bfd4c6f681d1162aa6d7491bf86fe5157f1
63-
assets/NOTICES,1750175752984,64130d8480daa3ee182e26edb9ff0fe7fd942731e610eb607dab1025da619a50
64-
main.dart.js,1750175747809,9ca1bb60b702e6822a97becde6807a5a1c6e1e41760ad49b0d336c1771d3299d
52+
version.json,1750235045934,7a8150bbbb022ccc68f6918ae17c96dd48946ae20c63d291d51e8ebec37477a0
53+
flutter_service_worker.js,1750235050259,39acffec2ab41b4069b8a7e3d964287280a8439d5b4b9bda70ec30a09ef5113a
54+
index.html,1750235006291,46f15e377ce0b89afb1457e713d3df3ac0fa0d8ec7f948dfb0b5a16521a7e089
55+
assets/FontManifest.json,1750235046201,40558917e686edef453bec6b1ce52fe20a28f93a6c047ada95a037e62112c6fd
56+
assets/AssetManifest.json,1750235046201,65b57b5a7562c148d26aab11e8fa194db9cb5676c25b4f74577bf64fd68c746b
57+
assets/AssetManifest.bin.json,1750235046201,a78fb0556ddc8c63a873a331c32884fd50005287f4d3f09358a6261ce2d2e1c2
58+
assets/AssetManifest.bin,1750235046201,ac9619a4b4098c84a5b572baad55b3b587b991f589b5aca0aecd943cb80b71e8
59+
assets/packages/cupertino_icons/assets/CupertinoIcons.ttf,1750235047877,d41473de1f7708a0702d7f19327693486512db442f6ab0cf7774e6d6576f9fcb
60+
flutter_bootstrap.js,1750235006209,3bb7a93d04fb079467f6c9c3e76bda1614315f63058d96ec318b3601d3bfeebb
61+
assets/shaders/ink_sparkle.frag,1750235046351,591c7517d5cb43eb91ea451e0d3f9f585cbf8298cf6c46a9144b77cb0775a406
62+
assets/fonts/MaterialIcons-Regular.otf,1750235047879,68501760f45b61955af1eabf7f25794e3a6e96d31a33f4b646a2c42bb106cea8
63+
assets/NOTICES,1750235046202,64130d8480daa3ee182e26edb9ff0fe7fd942731e610eb607dab1025da619a50
64+
main.dart.js,1750235041595,6bef41b4d682e4d406a6f11e8062ae0e6d57b6bb8c112f10d774e83d59e59940

lib/entities/contractFunctions.dart

Lines changed: 91 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ import 'human.dart';
1616
import 'org.dart';
1717

1818
delegate(String toWhom, Org org) async {
19+
final human = Human(); // Get the singleton instance
20+
if (human.web3user == null) {
21+
print("Error in delegate: web3user is null. Wallet not connected or on wrong chain?");
22+
return "not ok: Wallet not ready";
23+
}
24+
// Ensure we are using the latest provider state by creating contract with current web3user
1925
var sourceContract =
20-
Contract(org.govTokenAddress!, tokenAbiString, Human().web3user);
21-
print("facuram contractu");
26+
Contract(org.govTokenAddress!, tokenAbiString, human.web3user);
27+
print("delegate: Contract object created with current web3user for chain: ${human.chain.name}");
2228
try {
23-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
24-
print("signed ok");
29+
// Connect with the signer from the current web3user
30+
final signer = human.web3user!.getSigner();
31+
sourceContract = sourceContract.connect(signer);
32+
print("delegate: Contract connected with signer for chain: ${human.chain.name}");
2533
final transaction =
2634
await promiseToFuture(callMethod(sourceContract, "delegate", [toWhom]));
2735
print("facuram tranzactia");
@@ -443,24 +451,26 @@ Future<List<String>> createDAOwithWrappedToken(Org org, DaoConfig daoConfig) asy
443451
return ["ERROR: Wrapped token symbol not provided"];
444452
}
445453

446-
final String contractAddressToUse = Human().chain.wrapperContract_w ?? "0xf4B3022b0fb4e8A73082ba9081722d6a276195c2";
447-
print("Using wrapper contract address for wrapped token DAO: $contractAddressToUse");
454+
final human = Human(); // Get the singleton instance
455+
final String contractAddressToUse = human.chain.wrapperContract_w ?? "0xf4B3022b0fb4e8A73082ba9081722d6a276195c2";
456+
print("Using wrapper contract address for wrapped token DAO: $contractAddressToUse for chain: ${human.chain.name}");
448457

449-
if (Human().web3user == null) {
450-
print("Error: Web3 provider (Human().web3user) is null.");
458+
if (human.web3user == null) {
459+
print("Error in createDAOwithWrappedToken: web3user is null.");
451460
return ["ERROR: Web3 provider not initialized"];
452461
}
453462

454463
var sourceContract = Contract(
455-
contractAddressToUse,
464+
contractAddressToUse,
456465
wrapperAbiStringGlobal,
457-
Human().web3user
466+
human.web3user // Use human.web3user
458467
);
459-
print("Contract object created with address: $contractAddressToUse");
468+
print("createDAOwithWrappedToken: Contract object created with address: $contractAddressToUse for chain: ${human.chain.name}");
460469

461470
try {
462-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
463-
print("Contract connected with signer.");
471+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
472+
sourceContract = sourceContract.connect(signer);
473+
print("createDAOwithWrappedToken: Contract connected with signer for chain: ${human.chain.name}");
464474

465475
String executionDelayString = (org.executionDelay ?? 0).toString();
466476
String votingDelayString = (org.votingDelay ?? 0).toString();
@@ -495,7 +505,7 @@ Future<List<String>> createDAOwithWrappedToken(Org org, DaoConfig daoConfig) asy
495505
print("Transaction hash: $hash");
496506

497507
final result = await promiseToFuture(
498-
callMethod(Human().web3user!, 'waitForTransaction', [hash, 1]));
508+
callMethod(human.web3user!, 'waitForTransaction', [hash, 1])); // Use human.web3user
499509

500510
final decodedResult = json.decode(stringify(result));
501511
print("Transaction receipt status: ${decodedResult["status"]}");
@@ -591,14 +601,22 @@ createDAO(Org org) async {
591601
org.proposalThreshold.toString(),
592602
org.quorum.toString(),
593603
]);
594-
print("wrapper contract address ${Human().chain.wrapperContract}");
595-
print("web3 is of type ${Human().web3user}");
604+
final human = Human(); // Get the singleton instance
605+
print("wrapper contract address ${human.chain.wrapperContract} for chain: ${human.chain.name}");
606+
print("web3 is of type ${human.web3user}");
607+
608+
if (human.web3user == null) {
609+
print("Error in createDAO: web3user is null.");
610+
return ["ERROR: Web3 provider not initialized"]; // Or appropriate error list
611+
}
612+
596613
var sourceContract = Contract(
597-
Human().chain.wrapperContract, wrapperAbiStringGlobal, Human().web3user);
598-
print("facuram contractu");
614+
human.chain.wrapperContract, wrapperAbiStringGlobal, human.web3user); // Use human.web3user
615+
print("createDAO: Contract object created for chain: ${human.chain.name}");
599616
try {
600-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
601-
print("signed oki");
617+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
618+
sourceContract = sourceContract.connect(signer);
619+
print("createDAO: Contract connected with signer for chain: ${human.chain.name}");
602620

603621
if (org.debatesOnly ?? false) {
604622
org.registry = {"debatesOnly": "True"};
@@ -628,7 +646,7 @@ createDAO(Org org) async {
628646
final hash = json.decode(stringify(transaction))["hash"];
629647

630648
final result = await promiseToFuture(
631-
callMethod(Human().web3user!, 'waitForTransaction', [hash]));
649+
callMethod(human.web3user!, 'waitForTransaction', [hash])); // Use human.web3user
632650
if (json.decode(stringify(result))["status"] == 0) {
633651
print("nu merge eroare de greseala");
634652
return "not ok";
@@ -675,13 +693,21 @@ propose(Proposal p) async {
675693
print(p.description);
676694
String concatenated =
677695
"${p.name}0|||0${p.type}0|||0${p.description}0|||0${p.externalResource}";
678-
print("web3user: ${Human().web3user}");
679-
var sourceContract = Contract(p.org.address!, daoAbiString, Human().web3user);
680-
print("facuram contractu");
696+
final human = Human(); // Get the singleton instance
697+
print("propose: web3user is type ${human.web3user} for chain: ${human.chain.name}");
698+
699+
if (human.web3user == null) {
700+
print("Error in propose: web3user is null.");
701+
return "not ok: Wallet not ready";
702+
}
703+
704+
var sourceContract = Contract(p.org.address!, daoAbiString, human.web3user); // Use human.web3user
705+
print("propose: Contract object created for chain: ${human.chain.name}");
681706
String calldata0;
682707
try {
683-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
684-
print("signed ok");
708+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
709+
sourceContract = sourceContract.connect(signer);
710+
print("propose: Contract connected with signer for chain: ${human.chain.name}");
685711
print("concatenated: $concatenated");
686712
print("targets ${p.targets}");
687713
print("values ${p.values}");
@@ -691,7 +717,7 @@ propose(Proposal p) async {
691717
print("facuram tranzactia");
692718
final hash = json.decode(stringify(transaction))["hash"];
693719
final result = await promiseToFuture(
694-
callMethod(Human().web3user!, 'waitForTransaction', [hash]));
720+
callMethod(human.web3user!, 'waitForTransaction', [hash])); // Use human.web3user
695721
if (json.decode(stringify(result))["status"] == 0) {
696722
print("nu merge eroare de greseala");
697723
return "not ok";
@@ -728,11 +754,19 @@ queueProposal(Proposal p) async {
728754
Uint8List keccakHash = keccak256(encodedInput);
729755
String hashHex = "0x${bytesToHex(keccakHash)}";
730756
print("Keccak-256 hash: $hashHex");
731-
var sourceContract = Contract(p.org.address!, daoAbiString, Human().web3user);
732-
print("facuram contractu");
757+
final human = Human(); // Get the singleton instance
758+
759+
if (human.web3user == null) {
760+
print("Error in queueProposal: web3user is null.");
761+
return "not ok: Wallet not ready";
762+
}
763+
764+
var sourceContract = Contract(p.org.address!, daoAbiString, human.web3user); // Use human.web3user
765+
print("queueProposal: Contract object created for chain: ${human.chain.name}");
733766
try {
734-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
735-
print("signed ok");
767+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
768+
sourceContract = sourceContract.connect(signer);
769+
print("queueProposal: Contract connected with signer for chain: ${human.chain.name}");
736770
List<String> calldatas = [];
737771
for (String c in p.callDatas) {
738772
calldatas.add("0x$c");
@@ -747,7 +781,7 @@ queueProposal(Proposal p) async {
747781

748782
final hash = json.decode(stringify(transaction))["hash"];
749783
final result = await promiseToFuture(
750-
callMethod(Human().web3user!, 'waitForTransaction', [hash]));
784+
callMethod(human.web3user!, 'waitForTransaction', [hash])); // Use human.web3user
751785
if (json.decode(stringify(result))["status"] == 0) {
752786
print("nu merge eroare de greseala");
753787
return "not ok";
@@ -775,11 +809,19 @@ execute(Proposal p) async {
775809
Uint8List keccakHash = keccak256(encodedInput);
776810
String hashHex = "0x${bytesToHex(keccakHash)}";
777811
print("Keccak-256 hash: $hashHex");
778-
var sourceContract = Contract(p.org.address!, daoAbiString, Human().web3user);
779-
print("facuram contractu");
812+
final human = Human(); // Get the singleton instance
813+
814+
if (human.web3user == null) {
815+
print("Error in execute: web3user is null.");
816+
return "not ok: Wallet not ready";
817+
}
818+
819+
var sourceContract = Contract(p.org.address!, daoAbiString, human.web3user); // Use human.web3user
820+
print("execute: Contract object created for chain: ${human.chain.name}");
780821
try {
781-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
782-
print("signed okkkkk");
822+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
823+
sourceContract = sourceContract.connect(signer);
824+
print("execute: Contract connected with signer for chain: ${human.chain.name}");
783825
List<String> calldatas = [];
784826
for (String c in p.callDatas) {
785827
calldatas.add("0x$c");
@@ -793,7 +835,7 @@ execute(Proposal p) async {
793835
print("facuram tranzactia");
794836
final hash = json.decode(stringify(transaction))["hash"];
795837
final result = await promiseToFuture(
796-
callMethod(Human().web3user!, 'waitForTransaction', [hash]));
838+
callMethod(human.web3user!, 'waitForTransaction', [hash])); // Use human.web3user
797839
if (json.decode(stringify(result))["status"] == 0) {
798840
print("nu merge eroare de greseala");
799841
return "not ok";
@@ -813,17 +855,23 @@ execute(Proposal p) async {
813855
}
814856

815857
vote(Vote v, Org org) async {
816-
var sourceContract = Contract(org.address!, daoAbiString, Human().web3user);
817-
print("facuram contractu");
858+
final human = Human(); // Get the singleton instance
859+
if (human.web3user == null) {
860+
print("Error in vote: web3user is null.");
861+
return "not ok: Wallet not ready";
862+
}
863+
var sourceContract = Contract(org.address!, daoAbiString, human.web3user); // Use human.web3user
864+
print("vote: Contract object created for chain: ${human.chain.name}");
818865
try {
819-
print("before signing");
820-
sourceContract = sourceContract.connect(Human().web3user!.getSigner());
866+
print("vote: before signing for chain: ${human.chain.name}");
867+
final signer = human.web3user!.getSigner(); // Get signer from current web3user
868+
sourceContract = sourceContract.connect(signer);
821869
final transaction = await promiseToFuture(callMethod(
822870
sourceContract, "castVote", [v.proposalID, v.option.toString()]));
823-
print("facuram tranzactia");
871+
print("vote: transaction submitted for chain: ${human.chain.name}");
824872
final hash = json.decode(stringify(transaction))["hash"];
825873
final result = await promiseToFuture(
826-
callMethod(Human().web3user!, 'waitForTransaction', [hash]));
874+
callMethod(human.web3user!, 'waitForTransaction', [hash])); // Use human.web3user
827875
if (json.decode(stringify(result))["status"] == 0) {
828876
print("nu merge eroare de greseala");
829877
return "not ok";

0 commit comments

Comments
 (0)