Skip to content

Commit

Permalink
it's mobile friendly but the chat doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
EightRice committed May 26, 2024
1 parent 157a212 commit 7c2a900
Show file tree
Hide file tree
Showing 11 changed files with 1,306 additions and 198 deletions.
88 changes: 41 additions & 47 deletions lib/entities/contractFunctions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,56 +17,50 @@ const String etherlink_testnet = 'https://node.ghostnet.etherlink.com';
class ContractFunctions{

getProjectsCounter() async {
var httpClient = Client();
var ethClient = Web3Client(Human().chain.rpcNode, httpClient);

final contractSursa = DeployedContract(
ContractAbi.fromJson(economyAbi, 'Economy'),
EthereumAddress.fromHex(sourceAddress),
);

var getRepToken = contractSursa.function('getNumberOfProjects');
Uint8List encodedData = getRepToken.encodeCall([]);

try {
// Log the RPC request
print('RPC Request:');
print(jsonEncode({
'jsonrpc': '2.0',
'method': 'eth_call',
'params': [
{
'to': sourceAddress,
'data': '0x' + bytesToHex(encodedData),
},
'latest',
],
'id': 1,
}));

var counter = await ethClient.call(
contract: contractSursa,
function: getRepToken,
params: [],
var httpClient = Client();
var ethClient = Web3Client(Human().chain.rpcNode, httpClient);
final contractSursa = DeployedContract(
ContractAbi.fromJson(economyAbi, 'Economy'),
EthereumAddress.fromHex(sourceAddress),
);

// Log the RPC response
print('RPC Response:');
print(counter.toString());
int rezultat = int.parse(counter[0].toString()) as int;
numberOfProjects = rezultat;
print('$rezultat ${rezultat.runtimeType}');
return rezultat;
} catch (e) {
print('Error: $e');
// Log the full response body
print('Response Body:');
print(httpClient.toString());
rethrow;
}
var getRepToken = contractSursa.function('getNumberOfProjects');
Uint8List encodedData = getRepToken.encodeCall([]);
try {
// Log the RPC request
print('RPC Request:');
print(jsonEncode({
'jsonrpc': '2.0',
'method': 'eth_call',
'params': [
{
'to': sourceAddress,
'data': '0x' + bytesToHex(encodedData),
},
'latest',
],
'id': 1,
}));
var counter = await ethClient.call(
contract: contractSursa,
function: getRepToken,
params: [],
);
// Log the RPC response
print('RPC Response:');
print(counter.toString());
int rezultat = int.parse(counter[0].toString()) as int;
numberOfProjects = rezultat;
print('$rezultat ${rezultat.runtimeType}');
return rezultat;
} catch (e) {
print('Error: $e');
// Log the full response body
print('Response Body:');
print(httpClient.toString());
rethrow;
}
}


getUserRep() async {
print("getting rep");
var httpClient = Client();
Expand Down
1 change: 0 additions & 1 deletion lib/entities/human.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class Human extends ChangeNotifier{
}
}


signIn()async{
try {
var accounts = await promiseToFuture(
Expand Down
9 changes: 2 additions & 7 deletions lib/entities/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import 'human.dart';
String workingHash ="0x71436760615bde646197979c0be8a86c1c6179cd17ae7492355e76ff79949bbc";

class User{

User({this.about,this.link, this.name, required this.lastActive, required this.address,required this.nativeEarned,
required this.usdtEarned,required this.usdtSpent,required this.nativeSpent,required this.projectsContracted,
required this.projectsArbitrated,required this.projectsBacked,
required this.projectsArbitrated,required this.projectsBacked,
required this.projectsAuthored});
List<TTransaction>actions=[];
String address;
Expand All @@ -35,7 +34,6 @@ class User{
UserCard getCard() {
return UserCard(user: this);
}

Map<String, dynamic> toJson() => {
'nativeEarned': nativeEarned,
'link':link,
Expand All @@ -52,7 +50,6 @@ class User{
};
factory User.fromNew(String address){


User u= User(lastActive: DateTime.now(), address: address,
nativeEarned: "0",
usdtEarned: "0",
Expand Down Expand Up @@ -134,15 +131,13 @@ class TTransaction{

class UserDetails extends StatefulWidget {
User human;
UserDetails({required this.human,super.key});
UserDetails({required this.human,super.key, });

@override
State<UserDetails> createState() => _UserDetailsState();
}

class _UserDetailsState extends State<UserDetails> {


Widget involvement(String address, String type){
Project p= projects.firstWhere(
(element) => element.contractAddress==address,
Expand Down
10 changes: 5 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ class MyApp extends StatelessWidget {
if (settings.name == '/') {
builder = (_) =>
// BaseScaffold(body: Profile(), title: "title", selectedItem: 0);
// ProjectDetails(project: projects[0]);
// ProjectDetails(project: projects[1]);
// Prelaunch();
// Poll();

// Poll();
// Scaffold(body: SetParty(project: projects[0]));
// BaseScaffold(selectedItem: 0, body: const Users(), title: "Users");
// BaseScaffold(selectedItem: 0, body: Profile(), title: "Users");
// BaseScaffold(selectedItem: 0, body: Users(), title: "Users");
Human().beta ? BaseScaffold(
selectedItem: 0, body: Landing(), title: "Trustless Business") : Prelaunch();
// BaseScaffold(selectedItem: 1,body: Projects( main: true, capacity: ""), title: "Projects");
Expand Down Expand Up @@ -262,7 +262,7 @@ class MyApp extends StatelessWidget {
), );
}
else if (settings.name == '/users') {
builder = (_) => BaseScaffold(selectedItem: 3, body: const Users(), title: "Users");
builder = (_) => BaseScaffold(selectedItem: 3, body: Users(), title: "Users");
} else if (settings.name == '/') {
builder = (_) => BaseScaffold(selectedItem: 0, body: Landing(), title: "Trustless Business");
} else if (settings.name == '/projects') {
Expand Down
Loading

0 comments on commit 7c2a900

Please sign in to comment.