Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Zano (Android and iOS) #1661

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

Conversation

LeoBlackCat
Copy link

use build_zano_all script to build

LeoBlackCat and others added 29 commits March 10, 2024 13:08
Copy link
Contributor

@OmarHatem28 OmarHatem28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly it looks good, just some minor issues most of them are just some debug code left/missing, and please update to the latest main, so cuz there will be some conflicts with some new added code

In the meantime, I will build this locally and give it to our testers to try

@@ -223,7 +224,8 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
static const usdcTrc20 = CryptoCurrency(title: 'USDC', tag: 'TRX', fullName: 'USDC Coin', raw: 92, name: 'usdctrc20', iconPath: 'assets/images/usdc_icon.png', decimals: 6);
static const tbtc = CryptoCurrency(title: 'tBTC', fullName: 'Testnet Bitcoin', raw: 93, name: 'tbtc', iconPath: 'assets/images/tbtc.png', decimals: 8);
static const wow = CryptoCurrency(title: 'WOW', fullName: 'Wownero', raw: 94, name: 'wow', iconPath: 'assets/images/wownero_icon.png', decimals: 11);

static const zano = CryptoCurrency(title: 'ZANO', tag: 'ZANO', fullName: 'Zano', raw: 94, name: 'zano', iconPath: 'assets/images/zano_icon.png', decimals: 12);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the raw value should increased as it acts like an id for the object, so we can't have 2 similar ids

Comment on lines +172 to +175
Future<bool> requestZanoNode() async {
// TODO: fix it
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a normal get request should suffice here I believe

@@ -301,6 +307,8 @@ class AddressValidator extends TextValidator {
return '([^0-9a-zA-Z]|^)[1-9A-HJ-NP-Za-km-z]{43,44}([^0-9a-zA-Z]|\$)';
case CryptoCurrency.trx:
return '(T|t)[1-9A-HJ-NP-Za-km-z]{33}';
case CryptoCurrency.zano:
return '[0-9a-zA-Z]{1,100}';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the expected scheme of a Zano address so we can improve the regex here, cuz like this it will fetch the first 100 characters of any text

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might look like this:

([1-9A-HJ-NP-Za-km-z]{90,200})|(@[\w\d-.]+)

this includes regular zano addresses like this:
ZxBvJDuQjMG9R2j4WnYUhBYNrwZPwuyXrC7FHdVmWqaESgowDvgfWtiXeNGu8Px9B24pkmjsA39fzSSiEQG1ekB225ZnrMTBp
or alias like this:
@ravaga

@@ -123,6 +126,8 @@ class AddressValidator extends TextValidator {
return 'D([1-9a-km-zA-HJ-NP-Z]){33}';
case CryptoCurrency.btcln:
return '^(lnbc|LNBC)([0-9]{1,}[a-zA-Z0-9]+)';
case CryptoCurrency.zano:
return skipZanoAddressValidation ? '[0-9a-zA-Z]' : r'$.^'; // always false, we use additional validation then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -229,11 +230,12 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
final token = await widget.homeSettingsViewModel.getToken(_contractAddressController.text);

if (token != null) {
if (_tokenNameController.text.isEmpty) _tokenNameController.text = token.name;
if (_tokenSymbolController.text.isEmpty) _tokenSymbolController.text = token.title;
final isZano = widget.homeSettingsViewModel.walletType == WalletType.zano;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't see a need for this to be honest

@override
Future<void> connectToNode({required Node node}) async {
syncStatus = ConnectingSyncStatus();
await setupNode();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

} else {
if (fee > unlockedBalanceZano) {
throw ZanoTransactionCreationException(
"You don't have enough coins (required: ${ZanoFormatter.bigIntAmountToString(fee)} ZANO, unlocked ${ZanoFormatter.bigIntAmountToString(unlockedBalanceZano)} ZANO).");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"You don't have enough coins (required: ${ZanoFormatter.bigIntAmountToString(fee)} ZANO, unlocked ${ZanoFormatter.bigIntAmountToString(unlockedBalanceZano)} ZANO).");
"You don't have enough ZANO to pay the fees (required: ${ZanoFormatter.bigIntAmountToString(fee)} ZANO, unlocked ${ZanoFormatter.bigIntAmountToString(unlockedBalanceZano)} ZANO).");

@override
Future<void> save() async {
try {
await store();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see that this is in the wallet API, but can you please explain to me whether it just saves the current state of the wallet files or what exactly?

Comment on lines +371 to +373
if (balance.keys.any((element) => element is ZanoAsset && element.assetId == b.assetInfo.assetId)) {
balance[balance.keys.firstWhere((element) => element is ZanoAsset && element.assetId == b.assetInfo.assetId)] =
ZanoBalance(total: b.total, unlocked: b.unlocked, decimalPoint: asset.decimalPoint);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this if is not needed, you are going to add the asset to the balance anyway, why check if it's already there or not?

}

@override
Future<void>? updateBalance() => null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be implemented, so I'd say extract the update balance code from start sync and have it in this function instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants