Skip to content

Commit

Permalink
v5.1.0
Browse files Browse the repository at this point in the history
Add features to solana network SPLToken, Create Account, TokenProgram, etc.
  • Loading branch information
mrtnetwork committed Apr 23, 2024
1 parent 15e9615 commit f8b90aa
Show file tree
Hide file tree
Showing 112 changed files with 2,720 additions and 946 deletions.
4 changes: 3 additions & 1 deletion mrt_wallet/lib/app/constant/page_path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PagePathConst {
static const String tronMultiSigAddress = "/tron/setup_multisig_address";
// solana transfer
static const String solanaTransfer = "/solana/transfer";
static const String solanaTransaction = "/solana/transaction";

/// cardano
static const String cardanoTransaction = "/cardano/transaction";
Expand Down Expand Up @@ -58,9 +59,10 @@ class PagePathConst {
static const String importEVMNetwork = "/networks/import";
static const String editEvmNetwork = "/networks/edit";
static const String updateElectrumProviders = "/networks/bitcoin/providers";

static const String editSolanaNetwork = "/networks/solana/providers";
static String providerDetails(AppNetworkImpl network) {
if (network is APPEVMNetwork) return editEvmNetwork;
if (network is APPSolanaNetwork) return editSolanaNetwork;
return updateElectrumProviders;
}

Expand Down
26 changes: 25 additions & 1 deletion mrt_wallet/lib/app/extention/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ extension QuickContextAccsess on BuildContext {
return null;
}

Future<T?> offTo<T>(String path, {dynamic argruments}) async {
if (mounted) {
final push =
Navigator.popAndPushNamed<T, T>(this, path, arguments: argruments);
return push;
}
return null;
}

void showAlert(String message) {
if (mounted) {
final sc = Repository.messengerKey(this);
Expand Down Expand Up @@ -88,7 +97,22 @@ extension QuickContextAccsess on BuildContext {
return DialogView(
title: label,
content: content?.call(context) ?? const [],
child: widget(context),
widget: widget(context),
);
},
);
}

Future<T?> openDialogPage<T>(WidgetContext child, String label,
{List<Widget> Function(BuildContext)? content}) async {
return await showAdaptiveDialog(
context: this,
useRootNavigator: true,
builder: (context) {
return DialogView(
title: label,
content: content?.call(context) ?? const [],
child: child(context),
);
},
);
Expand Down
71 changes: 67 additions & 4 deletions mrt_wallet/lib/app/localization/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1312,9 +1312,9 @@ class Localization {
"The header of the current block chain tip.",
"network_update_node_provider": "Update node provider",
"network_security_title":
"Ensuring wallet security: tips for adding Electrum servers",
"Ensuring wallet security: tips for adding node providers",
"network_security_desc":
"Ensuring the security of your wallet is paramount. When adding a new Electrum server, it's crucial to verify the RPC endpoint's accuracy to prevent potential security compromises. Before integration, double-check the RPC URL for correctness. Take an additional layer of caution by cross-referencing the current server header with a trusted block explorer or other reliable sources. These measures enhance security, providing confidence that the Electrum server added to your wallet is secure and free from any malicious intent.",
"Ensuring the security of your wallet is paramount. When adding a new provider, it's crucial to verify the RPC endpoint's accuracy to prevent potential security compromises. Before integration, double-check the RPC URL for correctness. Take an additional layer of caution by cross-referencing the current server header with a trusted block explorer or other reliable sources. These measures enhance security, providing confidence that the provider added to your wallet is secure and free from any malicious intent.",
"network_add_to_providers": "Add to providers.",
"network_update_network_providers": "Update network providers.",
"network": "Network",
Expand Down Expand Up @@ -1366,7 +1366,8 @@ class Localization {
"When using RBF, make sure your UTXOs have been confirmed; otherwise, you may encounter a non-final error",
"inaccessible_key_algorithm":
"Key algorithm inaccessible in multisig account.",
"recipient_info": "Recipient info",
"destination_info": "Destination info",
"destination_info_desc": "The information about destination account",
"executable": "Executable",
"import_spl_tokens": "Import SPL Tokens",
"unable_to_locate_token":
Expand Down Expand Up @@ -1424,7 +1425,69 @@ class Localization {
"enther_valid_un_label":
"Please enter a valid unsigned number for the label.",
"label_already_exists": "The label you entered already exists.",
"no_account_chosen": "No account has been chosen."
"no_account_chosen": "No account has been chosen.",
"associated_token_program": "Associated Token Program",
"create_associated_token_account": "Create Associated Token Account",
"mint": "Mint",
"token_program": "Token Program",
"owner_address": "Owner address",
"mint_address": "Mint address",
"mint_address_desc": "The mint account address",
"program_address": "Program address",
"program_address_desc": "The address of token program",
"associated_token_address": "Associated token address",
"new_account_address": "New Account address",
"solana_new_account_desc":
"Please provide the address for the account you wish to create, the account should be imported to your wallet before creation",
"owner_of_account": "The owner of account",
"account_size": "Account size",
"lamports": "Lamports",
"create_account": "Create Account",
"solana_create_account_desc":
"A created account is initialized to be owned by a built-in program called the System program.",
"setup_account_size": "Setup account size",
"solana_create_account_lamports_desc":
"Amount of lamports to transfer to the created account",
"required_signer_account_missing":
"Required signer account is missing",
"solana_account_size_desc":
"the amount of memory allocated to store data associated with the account on the blockchain",
"mint_authority": "Mint authority",
"decimals": "Decimals",
"solana_mint_decimal_desc":
"Number of base 10 digits to the right of the decimal place",
"mint_authority_desc": "The authority of mint tokens.",
"freeze_authority": "Freeze authority",
"freeze_authority_desc": "The freeze authority of the mint.",
"program_id": "Program ID",
"solana_program_id_desc": "The unique identifier of the application",
"mint_address_to_initialize": "The mint address to initialize.",
"setup_token_decimal": "Setup token decimals",
"initialize_mint": "Initialize mint",
"initiailize_mint_desc":
"Initializing a mint in Solana creates a new token type.",
"transfer_symbol": "Transfer ___1__",
"mint_to": "Mint to",
"mint_address_mint_desc": "The mint address",
"mint_to_desc": "Mints new tokens to an account.",
"authority": "Authority",
"mint_to_authority_desc": "The mint's minting authority.",
"mint_to_destination_desc": "The account to mint tokens to.",
"unknown_token": "Unknown token",
"mint_to_amount_desc": "The amount of new tokens to mint.",
"use_owner_account_instead_pda_desc":
"The account to mint tokens to. Utilize owner account. application automatically locates current PDA account.",
"name": "Name",
"update_token": "Update token",
"update_token_information": "Update token information",
"update_token_desc": "Update the name and symbol of the token",
"token_symbol_validator":
"The token symbol must be at least 2 characters long",
"token_name_validator":
"The token name must be at least 3 characters long",
"create_new_provider": "Create New Provider",
"gnesis_hash_desc":
"The genesis hash is the unique identifier for the initial block in a blockchain network, often used for network bootstrapping and verifying network state"
}
};
}
3 changes: 3 additions & 0 deletions mrt_wallet/lib/app/utility/blockchin_utils/solana/solana.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:blockchain_utils/blockchain_utils.dart';
import 'package:mrt_wallet/models/wallet_models/currency_balance/currency_balance.dart';

class SolanaConstants {
Expand All @@ -6,4 +7,6 @@ class SolanaConstants {
static final NoneDecimalBalance systemProgramRent =
NoneDecimalBalance(BigInt.from(890880), decimal, imutable: true);
static const int decimal = 9;
static final BigRational maximumAccountSizeBytes = BigRational.from(10240);
static final BigRational maxSPLTokenDecimalPlaces = BigRational.from(18);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ class SelectProviderIcon extends StatelessWidget {
return LiveWidget(() {
final ApiProviderTracker<ApiProviderService>? provider =
wallet.chain.provider()?.serviceProvider;
final bool supportCustomNode =
wallet.network is! AppXRPNetwork && wallet.network is! APPTVMNetwork;

return IconButton(
tooltip: provider.message().tr,
onPressed: () {
context.openSliverDialog(
(ctx) => _SelectProviderView(
network: wallet.network,
selectedProvider: provider,
supportCustomNode: supportCustomNode,
), content: (context) {
return supportCustomNode
return wallet.network.supportCustomNode
? [
WidgetConstant.width8,
IconButton(
Expand Down Expand Up @@ -74,18 +72,16 @@ class ProviderTrackerStatusView extends StatelessWidget {

class _SelectProviderView extends StatelessWidget {
const _SelectProviderView(
{required this.selectedProvider,
required this.network,
this.supportCustomNode = false});
{required this.selectedProvider, required this.network});
final ApiProviderTracker<ApiProviderService>? selectedProvider;
final AppNetworkImpl network;
final bool supportCustomNode;
bool get isTVM => network is APPTVMNetwork;
@override
Widget build(BuildContext context) {
Set<ApiProviderService> providers = {
...DefaultNodeProviders.getDefaultServices(network),
...network.coinParam.providers.where((element) => element.protocol.platforms.contains(PlatformInterface.appPlatform)),
...network.coinParam.providers.where((element) =>
element.protocol.platforms.contains(PlatformInterface.appPlatform)),
};

return SingleChildScrollView(
Expand Down Expand Up @@ -153,7 +149,7 @@ class _SelectProviderView extends StatelessWidget {
},
itemCount: providers.length,
),
] else if (supportCustomNode)
] else if (network.supportCustomNode)
Row(
children: [
Expanded(
Expand Down Expand Up @@ -290,8 +286,11 @@ class _ProviderLogsViewState extends State<_ProviderLogsView> with SafeState {
Text("url".tr, style: context.textTheme.titleSmall),
ContainerWithBorder(
backgroundColor: context.colors.secondary,
onRemoveIcon:
CopyTextIcon(dataToCopy: request.uri!),
onRemove: () {},
onRemoveIcon: CopyTextIcon(
dataToCopy: request.uri!,
color: context.colors.onSecondary,
),
onTapWhenOnRemove: false,
child: Text(
request.uri!,
Expand All @@ -307,8 +306,10 @@ class _ProviderLogsViewState extends State<_ProviderLogsView> with SafeState {
ContainerWithBorder(
backgroundColor: context.colors.secondary,
onRemove: () {},
onRemoveIcon:
CopyTextIcon(dataToCopy: request.params!),
onRemoveIcon: CopyTextIcon(
dataToCopy: request.params!,
color: context.colors.onSecondary,
),
onTapWhenOnRemove: false,
child: Text(
request.params!,
Expand Down Expand Up @@ -336,8 +337,10 @@ class _ProviderLogsViewState extends State<_ProviderLogsView> with SafeState {
ContainerWithBorder(
backgroundColor: context.colors.secondary,
onRemove: () {},
onRemoveIcon:
CopyTextIcon(dataToCopy: request.response!),
onRemoveIcon: CopyTextIcon(
dataToCopy: request.response!,
color: context.colors.onSecondary,
),
onTapWhenOnRemove: false,
child: Text(
request.response!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ class SetupNetworkAmount extends StatefulWidget {

class _SetupNetworkAmountState extends State<SetupNetworkAmount>
with SafeState {
late final BigInt? maxValue = widget.max == null
? null
: widget.max!.isNegative
? BigInt.zero
: widget.max;
final GlobalKey<FormState> form =
GlobalKey<FormState>(debugLabel: "SetupNetworkAmount");
final GlobalKey<AppTextFieldState> textFieldKey = GlobalKey();
late final String? maxString =
PriceUtils.tryEncodePrice(widget.max, widget.token.decimal!);
PriceUtils.tryEncodePrice(maxValue, widget.token.decimal!);
late final String? minString =
PriceUtils.tryEncodePrice(widget.min, widget.token.decimal!);
late final bool enableMin = (widget.min ?? BigInt.zero) > BigInt.zero;
Expand All @@ -50,7 +55,7 @@ class _SetupNetworkAmountState extends State<SetupNetworkAmount>
}
return "decimal_int_validator".tr;
}
if (widget.max != null && toBigit > widget.max!) {
if (maxValue != null && toBigit > maxValue!) {
return "price_less_than".tr.replaceOne(
PriceUtils.priceWithCoinName(maxString!, widget.token.symbolView));
} else if (widget.min != null && toBigit < widget.min!) {
Expand All @@ -65,10 +70,10 @@ class _SetupNetworkAmountState extends State<SetupNetworkAmount>
bool isMin = false;
void onChanged(String v) {
price = v;
if (widget.max == null && !enableMin) return;
if (maxValue == null && !enableMin) return;
final toBigit =
PriceUtils.tryDecodePrice<BigInt?>(price, widget.token.decimal!);
final equal = toBigit == widget.max;
final equal = toBigit == maxValue;
if (equal != isMax) {
setState(() {
isMax = equal;
Expand All @@ -85,7 +90,7 @@ class _SetupNetworkAmountState extends State<SetupNetworkAmount>
}

void onTapMax() {
final p = PriceUtils.tryEncodePrice(widget.max, widget.token.decimal!);
final p = PriceUtils.tryEncodePrice(maxValue, widget.token.decimal!);
if (p != null) {
textFieldKey.currentState?.updateText(p);
}
Expand Down Expand Up @@ -171,7 +176,7 @@ class _SetupNetworkAmountState extends State<SetupNetworkAmount>
],
),
),
if (widget.max != null || enableMin) ...[
if (maxValue != null || enableMin) ...[
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Expand All @@ -189,9 +194,9 @@ class _SetupNetworkAmountState extends State<SetupNetworkAmount>
borderRadius: WidgetConstant.border8)),
child: Text("min".tr),
),
if (widget.max != null) WidgetConstant.width8,
if (maxValue != null) WidgetConstant.width8,
],
if (widget.max != null)
if (maxValue != null)
FilledButton(
onPressed: onTapMax,
style: TextButton.styleFrom(
Expand Down
Loading

0 comments on commit f8b90aa

Please sign in to comment.