Skip to content

Commit

Permalink
feat: Separate crypto transfer and smart contract UI in transaction p…
Browse files Browse the repository at this point in the history
…age #3156
  • Loading branch information
bibash28 committed Dec 10, 2024
1 parent f736aa0 commit 212a449
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 31 deletions.
8 changes: 8 additions & 0 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2410,3 +2410,11 @@ Map<String, dynamic> getCredentialDataFromJson({

return credential;
}

bool isContract(String reciever) {
// check if it smart contract or not
// smart contarct address start with KT1
if (reciever.startsWith('tz')) return false;
if (reciever.startsWith('KT1')) return true;
return false;
}
5 changes: 2 additions & 3 deletions lib/dashboard/connection/operation/view/operation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ class _OperationViewState extends State<OperationView> {
sender = tezosOperationDetails!.first.source!;
reciever = tezosOperationDetails.first.destination!;
}
// check if it smart contract or not
// smart contarct address start with KT1
if (!reciever.startsWith('tz')) isSmartContract = true;

if (isContract(reciever)) isSmartContract = true;
} else if (transaction != null) {
symbol = state.cryptoAccountData?.blockchainType.symbol;
sender = transaction.from!.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ class TransactionItem extends StatelessWidget {
value: operationModel.parameter?.value?.value ??
operationModel.amount.toString(),
);

var button = l10n.send;

final isSmartContract = isContract(operationModel.target.address);

if (isSmartContract) {
button = l10n.operation;
} else {
final isSender = operationModel.isSender(
walletAddress:
context.read<WalletCubit>().state.currentAccount!.walletAddress,
);

if (isSender) {
button = l10n.send;
} else {
button = l10n.receive;
}
}

return InkWell(
onTap: onTap,
child: Column(
Expand All @@ -42,24 +62,33 @@ class TransactionItem extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
operationModel.formatedDateTime,
style: Theme.of(context).textTheme.bodyMedium,
Flexible(
flex: 8,
child: MyText(
operationModel.formatedDateTime,
style: Theme.of(context).textTheme.bodyMedium,
),
),
const Spacer(),
Text(
l10n.seeTransaction,
style: Theme.of(context).textTheme.bodyMedium,
),
const SizedBox(
width: Sizes.spaceSmall,
Flexible(
flex: 4,
child: MyText(
l10n.seeTransaction,
style: Theme.of(context).textTheme.bodyMedium,
),
),
Text(
tokenUsdPrice != null
? (tokenUsdPrice! * amount).decimalNumber(2).formatNumber +
r'$'
: r'$--.--',
style: Theme.of(context).textTheme.bodyMedium,
const Spacer(),
Flexible(
flex: 1,
child: MyText(
tokenUsdPrice != null
? (tokenUsdPrice! * amount)
.decimalNumber(2)
.formatNumber +
r'$'
: r'$--.--',
style: Theme.of(context).textTheme.bodyMedium,
),
),
],
),
Expand All @@ -86,15 +115,7 @@ class TransactionItem extends StatelessWidget {
width: Sizes.space2XSmall,
),
Text(
operationModel.isSender(
walletAddress: context
.read<WalletCubit>()
.state
.currentAccount!
.walletAddress,
)
? l10n.send
: l10n.receive,
button,
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(
Expand Down
3 changes: 2 additions & 1 deletion lib/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1170,5 +1170,6 @@
"domain": {}
}
},
"reject": "Reject"
"reject": "Reject",
"operation": "Operation"
}
9 changes: 6 additions & 3 deletions lib/l10n/untranslated.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@
"keyBindingHeader",
"keyBindingPayload",
"ebsiV4DecentralizedId",
"reject"
"reject",
"operation"
],

"es": [
"payload",
"keyBindingHeader",
"keyBindingPayload",
"ebsiV4DecentralizedId",
"reject"
"reject",
"operation"
],

"fr": [
"reject"
"reject",
"operation"
]
}

0 comments on commit 212a449

Please sign in to comment.