-
Notifications
You must be signed in to change notification settings - Fork 199
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
Conversation
This reverts commit 367c863.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
Future<bool> requestZanoNode() async { | ||
// TODO: fix it | ||
return true; | ||
} |
There was a problem hiding this comment.
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
lib/core/address_validator.dart
Outdated
@@ -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}'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
lib/core/address_validator.dart
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to the correct regex
@@ -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; |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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)."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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(); |
There was a problem hiding this comment.
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?
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
Co-authored-by: Omar Hatem <[email protected]>
lib/src/screens/dashboard/edit_token_page.dart - using AddressValidator().call
use build_zano_all script to build