Skip to content

Commit

Permalink
refactor(transactions): add labels for a tip/retip transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Aug 12, 2022
1 parent ebcceba commit 04c59f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/popup/router/components/TransactionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
transaction: { type: Object, required: true },
},
computed: {
...mapGetters(['account', 'getAmountFiat']),
...mapGetters(['account', 'getAmountFiat', 'activeNetwork']),
labels() {
if (this.txType && this.txType?.startsWith('name')) {
return ['AENS', this.$t('transaction.type')[this.txType]];
Expand All @@ -95,7 +95,13 @@ export default {
? this.$t('transaction.dexType.pool')
: this.$t('transaction.dexType.swap')];
}
if (this.txType === (SCHEMA.TX_TYPE.contractCall)
if ((this.transaction.tx.contractId
&& (this.activeNetwork.tipContractV1 === this.transaction.tx.contractId
|| this.activeNetwork.tipContractV2 === this.transaction.tx.contractId)
&& (this.transaction.tx.function === 'tip' || this.transaction.tx.function === 'retip')) || this.transaction.claim) {
return [this.$t('pages.token-details.tip'), this.transaction.claim ? this.$t('transaction.spendType.in') : this.$t('transaction.spendType.out')];
}
if (this.txType === SCHEMA.TX_TYPE.contractCall
&& this.availableTokens[this.transaction.tx.contractId]
&& (this.transaction.tx.function === 'transfer' || this.transaction.incomplete)) {
return [this.$t('transaction.type.spendTx'), this.transaction.tx.callerId === this.account.address
Expand Down
1 change: 1 addition & 0 deletions src/popup/router/pages/Retip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default {
contractId: this.tippingContract.deployInfo.address,
type: SCHEMA.TX_TYPE.contractCall,
function: 'retip',
selectedTokenId: this.selectedToken?.contractId,
},
});
this.openCallbackOrGoHome(true);
Expand Down
1 change: 1 addition & 0 deletions src/popup/router/pages/TipsSend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export default {
contractId: this.tippingContract.deployInfo.address,
type: SCHEMA.TX_TYPE.contractCall,
function: 'tip',
selectedTokenId: this.selectedToken?.contractId,
},
});
this.openCallbackOrGoHome(true);
Expand Down
5 changes: 4 additions & 1 deletion src/popup/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,11 @@ export const getBalanceLocalStorage = () => (
export const categorizeContractCallTxObject = (transaction) => {
if (transaction.incomplete
|| ((transaction.tx.function === 'tip' || transaction.tx.function === 'retip') && transaction.pending)) {
if (!transaction.tx?.selectedTokenId && transaction.pending) return null;
return {
amount: transaction.amount, token: transaction.tx.contractId, to: transaction.tx.callerId,
amount: transaction.amount,
token: transaction.pending ? transaction.tx?.selectedTokenId : transaction.tx.contractId,
to: transaction.tx.callerId,
};
}
if (transaction.tx.type !== 'ContractCallTx') return null;
Expand Down

0 comments on commit 04c59f1

Please sign in to comment.