-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added dashboard screen with transaction screen and fixed font sizes
- Loading branch information
Showing
17 changed files
with
1,744 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# **ProtoBuf Definitions** | ||
|
||
### ● **BlockChain Service Definition** | ||
|
||
``` | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE | | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
| Blockchain | GetBlock | GetBlockRequest | GetBlockResponse | | ||
| Blockchain | GetBlockHash | GetBlockHashRequest | GetBlockHashResponse | | ||
| Blockchain | GetBlockHeight | GetBlockHeightRequest | GetBlockHeightResponse | | ||
| Blockchain | GetBlockchainInfo | GetBlockchainInfoRequest | GetBlockchainInfoResponse | | ||
| Blockchain | GetConsensusInfo | GetConsensusInfoRequest | GetConsensusInfoResponse | | ||
| Blockchain | GetAccount | GetAccountRequest | GetAccountResponse | | ||
| Blockchain | GetValidator | GetValidatorRequest | GetValidatorResponse | | ||
| Blockchain | GetValidatorByNumber | GetValidatorByNumberRequest | GetValidatorResponse | | ||
| Blockchain | GetValidatorAddresses | GetValidatorAddressesRequest | GetValidatorAddressesResponse | | ||
| Blockchain | GetPublicKey | GetPublicKeyRequest | GetPublicKeyResponse | | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
``` | ||
|
||
### ● **Transaction Service Definition** | ||
|
||
``` | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE | | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
| Transaction | GetTransaction | GetTransactionRequest | GetTransactionResponse | | ||
| Transaction | CalculateFee | CalculateFeeRequest | CalculateFeeResponse | | ||
| Transaction | BroadcastTransaction | BroadcastTransactionRequest | BroadcastTransactionResponse | | ||
| Transaction | GetRawTransferTransaction | GetRawTransferTransactionRequest | GetRawTransactionResponse | | ||
| Transaction | GetRawBondTransaction | GetRawBondTransactionRequest | GetRawTransactionResponse | | ||
| Transaction | GetRawUnbondTransaction | GetRawUnbondTransactionRequest | GetRawTransactionResponse | | ||
| Transaction | GetRawWithdrawTransaction | GetRawWithdrawTransactionRequest | GetRawTransactionResponse | | ||
+-------------+---------------------------+----------------------------------+-------------------------------+ | ||
``` | ||
|
||
### ● **Wallet Service Definition** | ||
|
||
``` | ||
+-------------+---------------------------+----------------------------------+------------------------------+ | ||
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE | | ||
+-------------+---------------------------+----------------------------------+------------------------------+ | ||
| Wallet | GetTotalBalance | GetTotalBalanceRequest | GetTotalBalanceResponse | | ||
| Wallet | GetAddressHistory | GetAddressHistoryRequest | GetAddressHistoryResponse | | ||
| Wallet | GetNewAddress | GetNewAddressRequest | GetNewAddressResponse | | ||
| Wallet | GetValidatorAddress | GetValidatorAddressRequest | GetValidatorAddressResponse | | ||
| Wallet | SignRawTransaction | SignRawTransactionRequest | SignRawTransactionResponse | | ||
| Wallet | CreateWallet | CreateWalletRequest | CreateWalletResponse | | ||
| Wallet | UnloadWallet | UnloadWalletRequest | UnloadWalletResponse | | ||
| Wallet | LoadWallet | LoadWalletRequest | LoadWalletResponse | | ||
| Wallet | RestoreWallet | RestoreWalletRequest | RestoreWalletResponse | | ||
+-------------+---------------------------+----------------------------------+------------------------------+ | ||
``` | ||
|
||
### ● **Network Service Definition** | ||
|
||
``` | ||
+---------+----------------+-----------------------+------------------------+ | ||
| SERVICE | RPC | REQUEST TYPE | RESPONSE TYPE | | ||
+---------+----------------+-----------------------+------------------------+ | ||
| Network | GetNetworkInfo | GetNetworkInfoRequest | GetNetworkInfoResponse | | ||
| Network | GetNodeInfo | GetNodeInfoRequest | GetNodeInfoResponse | | ||
+---------+----------------+-----------------------+------------------------+ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:pactus/grpc_gen/blockchain.pbgrpc.dart'; | ||
import 'package:pactus/provider/rpc_api/grpc_provider.dart'; | ||
|
||
final blockchainClientProvider = Provider<BlockchainClient>((ref) { | ||
final channel = ref.watch(grpcChannelProvider); | ||
return BlockchainClient(channel); | ||
}); | ||
|
||
// Provider for BlockchainInfoNotifier | ||
final blockchainInfoProvider = StateNotifierProvider<BlockchainInfoNotifier, | ||
AsyncValue<GetBlockchainInfoResponse>>((ref) { | ||
final client = ref.watch(blockchainClientProvider); | ||
return BlockchainInfoNotifier(client); | ||
}); | ||
|
||
class BlockchainInfoNotifier | ||
extends StateNotifier<AsyncValue<GetBlockchainInfoResponse>> { | ||
BlockchainInfoNotifier(this.client) : super(const AsyncValue.loading()); | ||
final BlockchainClient client; | ||
|
||
Future<void> fetchBlockchainInfo() async { | ||
debugPrint('Fetching blockchain info'); | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = GetBlockchainInfoRequest(); | ||
final response = await client.getBlockchainInfo(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:grpc/grpc.dart'; | ||
|
||
// Provider for ClientChannel | ||
final grpcChannelProvider = Provider<ClientChannel>((ref) { | ||
return ClientChannel( | ||
'127.0.0.1', // Change to the actual server IP if necessary. | ||
// '172.27.172.3', // Change to the actual server IP if necessary. | ||
port: 50051, | ||
options: const ChannelOptions( | ||
credentials: | ||
ChannelCredentials.insecure()), // Use secure for production. | ||
); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import 'package:fluent_ui/fluent_ui.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:pactus/provider/rpc_api/grpc_provider.dart'; | ||
import 'package:protobuf/protobuf.dart'; | ||
|
||
import '../../grpc_gen/network.pbgrpc.dart'; | ||
|
||
// Provider for the gRPC service client | ||
final networkClientProvider = Provider<NetworkClient>((ref) { | ||
final channel = ref.watch(grpcChannelProvider); | ||
return NetworkClient(channel); | ||
}); | ||
|
||
// Provider for NetworkInfoNotifier | ||
final networkInfoProvider = | ||
StateNotifierProvider<NetworkInfoNotifier, AsyncValue<GeneratedMessage>>( | ||
(ref) { | ||
final client = ref.watch(networkClientProvider); | ||
return NetworkInfoNotifier(client); | ||
}); | ||
|
||
class NetworkInfoNotifier extends StateNotifier<AsyncValue<GeneratedMessage>> { | ||
NetworkInfoNotifier(this.client) : super(const AsyncValue.loading()); | ||
final NetworkClient client; | ||
|
||
Future<void> fetchNetworkInfo() async { | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = GetNetworkInfoRequest(); | ||
final response = await client.getNetworkInfo(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
} | ||
|
||
final nodeInfoProvider = | ||
StateNotifierProvider<NodeInfoNotifier, AsyncValue<GeneratedMessage>>((ref) { | ||
final client = ref.watch(networkClientProvider); | ||
return NodeInfoNotifier(client); | ||
}); | ||
|
||
class NodeInfoNotifier extends StateNotifier<AsyncValue<GeneratedMessage>> { | ||
NodeInfoNotifier(this.client) : super(const AsyncValue.loading()); | ||
final NetworkClient client; | ||
|
||
Future<void> fetchData() async { | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = GetNodeInfoRequest(); | ||
final response = await client.getNodeInfo(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:pactus/grpc_gen/transaction.pbgrpc.dart'; | ||
import 'package:pactus/provider/rpc_api/grpc_provider.dart'; | ||
import 'package:protobuf/protobuf.dart'; | ||
|
||
final transactionClientProvider = Provider<TransactionClient>((ref) { | ||
final channel = ref.watch(grpcChannelProvider); | ||
return TransactionClient(channel); | ||
}); | ||
|
||
|
||
// Provider for transactionInfoNotifier | ||
final transactionInfoProvider = StateNotifierProvider<TransactionInfoNotifier, | ||
AsyncValue<GeneratedMessage>>((ref) { | ||
final client = ref.watch(transactionClientProvider); | ||
return TransactionInfoNotifier(client); | ||
}); | ||
|
||
class TransactionInfoNotifier | ||
extends StateNotifier<AsyncValue<GeneratedMessage>> { | ||
TransactionInfoNotifier(this.client) : super(const AsyncValue.loading()); | ||
final TransactionClient client; | ||
|
||
Future<void> fetchtransactionInfo() async { | ||
debugPrint('Fetching transaction info'); | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = GetTransactionRequest(); | ||
final response = await client.getTransaction(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
|
||
Future<void> fetchtransaction() async { | ||
debugPrint('Fetching transaction info'); | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = GetRawBondTransactionRequest(); | ||
final response = await client.getRawBondTransaction(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:pactus/grpc_gen/wallet.pbgrpc.dart'; | ||
import 'package:pactus/provider/rpc_api/grpc_provider.dart'; | ||
|
||
final walletClientProvider = Provider<WalletClient>((ref) { | ||
final channel = ref.watch(grpcChannelProvider); | ||
return WalletClient(channel); | ||
}); | ||
|
||
|
||
// Provider for WalletInfoNotifier | ||
final walletInfoProvider = StateNotifierProvider<WalletInfoNotifier, | ||
AsyncValue<LoadWalletResponse>>((ref) { | ||
final client = ref.watch(walletClientProvider); | ||
return WalletInfoNotifier(client); | ||
}); | ||
|
||
class WalletInfoNotifier | ||
extends StateNotifier<AsyncValue<LoadWalletResponse>> { | ||
WalletInfoNotifier(this.client) : super(const AsyncValue.loading()); | ||
final WalletClient client; | ||
|
||
Future<void> fetchwalletInfo() async { | ||
debugPrint('Fetching wallet info'); | ||
try { | ||
state = const AsyncValue.loading(); | ||
final request = LoadWalletRequest(); | ||
final response = await client.loadWallet(request); | ||
state = AsyncValue.data(response); | ||
} on Exception catch (e, st) { | ||
debugPrint(e.toString()); | ||
state = AsyncValue.error(e, st); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.