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

fix: Misleading Withdraw Amount wording in Offers #11239

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions components/trade/TradeOwnerButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ const onClick = () => emit('click', props.trade)

const details = {
[TradeType.SWAP]: {
cancel: 'transaction.withdrawSwap',
cancel: 'transaction.cancelSwap',
accept: 'transaction.acceptSwap',
withdraw: 'swap.withdrawSwap',
},
[TradeType.OFFER]: {
cancel: 'transaction.withdrawOffer',
cancel: 'transaction.cancelOffer',
accept: 'transaction.acceptOffer',
withdraw: 'offer.withdrawOffer',
},
}

const buttonConfig = computed<ButtonConfig | null>(() => {
if (props.trade.status === 'EXPIRED') {
return isCreatorOfTrade.value
? {
label: $i18n.t('offer.withdrawAmount'),
label: $i18n.t(details[props.trade.type].withdraw),
onClick,
}
: null
Expand Down
12 changes: 6 additions & 6 deletions components/trade/overviewModal/TradeOverviewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ const TradeTypeOverviewModeDetails: Record<TradeType, Record<OverviewMode, Overv
},
owner: {
title: $i18n.t('swap.yourSwap'),
signingTitle: $i18n.t('transaction.withdrawSwap'),
notificationTitle: $i18n.t('swap.swapWithdrawl'),
signingTitle: $i18n.t('transaction.cancelSwap'),
notificationTitle: $i18n.t('swap.swapCancellation'),
},
},
[TradeType.OFFER]: {
Expand All @@ -116,8 +116,8 @@ const TradeTypeOverviewModeDetails: Record<TradeType, Record<OverviewMode, Overv
},
owner: {
title: $i18n.t('offer.yourOffer'),
signingTitle: $i18n.t('transaction.withdrawOffer'),
notificationTitle: $i18n.t('offer.offerWithdrawl'),
signingTitle: $i18n.t('transaction.cancelOffer'),
notificationTitle: $i18n.t('offer.offerCancellation'),
},
},
}
Expand All @@ -137,7 +137,7 @@ const TradeTypeTx: Record<TradeType, Record<OverviewMode, (params: ExecTxParams)
[TradeType.SWAP]: {
owner: ({ offered }) => {
transaction({
interaction: ShoppingActions.WITHDRAW_SWAP,
interaction: ShoppingActions.CANCEL_SWAP,
urlPrefix: urlPrefix.value,
offeredId: offered.sn,
offeredCollectionId: offered.collection.id,
Expand All @@ -159,7 +159,7 @@ const TradeTypeTx: Record<TradeType, Record<OverviewMode, (params: ExecTxParams)
[TradeType.OFFER]: {
owner: ({ offered }) => {
transaction({
interaction: ShoppingActions.WITHDRAW_OFFER,
interaction: ShoppingActions.CANCEL_OFFER,
urlPrefix: urlPrefix.value,
offeredId: offered.sn,
})
Expand Down
18 changes: 18 additions & 0 deletions composables/transaction/transactionOfferCancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ApiPromise } from '@polkadot/api'
import type { ActionCancelOffer } from './types'
import { getOfferCollectionId } from './transactionOffer'

async function execCancelOfferAssetHub(item: ActionCancelOffer, api: ApiPromise, executeTransaction) {
executeTransaction({
cb: api.tx.nfts.cancelSwap,
arg: [getOfferCollectionId(item.urlPrefix), Number(item.offeredId)],
successMessage: item.successMessage,
errorMessage: item.errorMessage,
})
}

export async function execCancelOffer(item: ActionCancelOffer, api, executeTransaction) {
if (isAssetHub(item.urlPrefix)) {
await execCancelOfferAssetHub(item, api, executeTransaction)
}
}
18 changes: 0 additions & 18 deletions composables/transaction/transactionOfferWithdraw.ts

This file was deleted.

17 changes: 17 additions & 0 deletions composables/transaction/transactionSwapCancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { ApiPromise } from '@polkadot/api'
import type { ActionCancelSwap } from './types'

async function execCancelSwapAssetHub(item: ActionCancelSwap, api: ApiPromise, executeTransaction) {
executeTransaction({
cb: api.tx.nfts.cancelSwap,
arg: [Number(item.offeredCollectionId), Number(item.offeredId)],
successMessage: item.successMessage,
errorMessage: item.errorMessage,
})
}

export async function execCancelSwap(item: ActionCancelSwap, api: ApiPromise, executeTransaction) {
if (isAssetHub(item.urlPrefix)) {
await execCancelSwapAssetHub(item, api, executeTransaction)
}
}
17 changes: 0 additions & 17 deletions composables/transaction/transactionSwapWithdraw.ts

This file was deleted.

12 changes: 6 additions & 6 deletions composables/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ export type ActionSwap = {
errorMessage?: string
}

export type ActionWithdrawOffer = {
interaction: typeof ShoppingActions.WITHDRAW_OFFER
export type ActionCancelOffer = {
interaction: typeof ShoppingActions.CANCEL_OFFER
urlPrefix: Prefix
offeredId: string
successMessage?: string
Expand All @@ -228,8 +228,8 @@ export type ActionAcceptOffer = {
errorMessage?: string
}

export type ActionWithdrawSwap = {
interaction: typeof ShoppingActions.WITHDRAW_SWAP
export type ActionCancelSwap = {
interaction: typeof ShoppingActions.CANCEL_SWAP
urlPrefix: Prefix
offeredId: string
offeredCollectionId: string
Expand Down Expand Up @@ -338,9 +338,9 @@ export type Actions =
| ActionSend
| ActionOffer
| ActionConsume
| ActionWithdrawSwap
| ActionCancelSwap
| ActionAcceptSwap
| ActionWithdrawOffer
| ActionCancelOffer
| ActionAcceptOffer
| ActionMintToken
| ActionMintCollection
Expand Down
8 changes: 4 additions & 4 deletions composables/transaction/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import type {
ActionSwap,
ActionSend,
ActionUpdateCollection,
ActionWithdrawOffer,
ActionCancelOffer,
ActionSetNftMetadata,
ActionWithdrawSwap,
ActionCancelSwap,
ActionAcceptSwap,
Actions,
} from '../transaction/types'
Expand Down Expand Up @@ -53,9 +53,9 @@ export function isActionValid(action: Actions): boolean {
[Interaction.CONSUME]: (action: ActionConsume) => hasContent(action.nftIds),
[ShoppingActions.MAKE_OFFER]: (action: ActionOffer) =>
hasContent(action.token),
[ShoppingActions.WITHDRAW_OFFER]: (action: ActionWithdrawOffer) =>
[ShoppingActions.CANCEL_OFFER]: (action: ActionCancelOffer) =>
Boolean(action.offeredId),
[ShoppingActions.WITHDRAW_SWAP]: (action: ActionWithdrawSwap) =>
[ShoppingActions.CANCEL_SWAP]: (action: ActionCancelSwap) =>
Boolean(action.offeredId) && Boolean(action.offeredCollectionId),
[ShoppingActions.ACCEPT_SWAP]: (action: ActionAcceptSwap) =>
Boolean(action.receiveItem) && Boolean(action.receiveCollection) && Boolean(action.sendItem) && Boolean(action.sendCollection),
Expand Down
16 changes: 8 additions & 8 deletions composables/useTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
execBurnCollection,
execBurn,
} from './transaction/transactionBurn'
import { execWithdrawSwap } from './transaction/transactionSwapWithdraw'
import { execCancelSwap } from './transaction/transactionSwapCancel'
import { execAcceptSwap } from './transaction/transactionSwapAccept'
import { execWithdrawOfferTx } from './transaction/transactionOfferWithdraw'
import { execCancelOffer } from './transaction/transactionOfferCancel'
import { execAcceptOfferTx } from './transaction/transactionOfferAccept'
import { execMakingOfferTx } from './transaction/transactionOffer'
import { execCreateSwap } from './transaction/transactionCreateSwap'
Expand All @@ -33,13 +33,13 @@ import type {
ActionSend,
ActionUpdateCollection,
ActionSetNftMetadata,
ActionWithdrawOffer,
ActionCancelOffer,
Actions,
ExecuteEvmTransactionParams,
ExecuteSubstrateTransactionParams,
ExecuteTransactionParams,
ObjectMessage,
ActionWithdrawSwap,
ActionCancelSwap,
ActionAcceptSwap,
} from './transaction/types'
import { Collections, NFTs } from './transaction/types'
Expand Down Expand Up @@ -231,12 +231,12 @@ export const executeAction = ({
execSendTx(item as ActionSend, api, executeTransaction),
[ShoppingActions.CONSUME]: () =>
execBurn(item as ActionConsume, api, executeTransaction),
[ShoppingActions.WITHDRAW_SWAP]: () =>
execWithdrawSwap(item as ActionWithdrawSwap, api!, executeTransaction),
[ShoppingActions.CANCEL_SWAP]: () =>
execCancelSwap(item as ActionCancelSwap, api!, executeTransaction),
[ShoppingActions.ACCEPT_SWAP]: () =>
execAcceptSwap(item as ActionAcceptSwap, api!, executeTransaction),
[ShoppingActions.WITHDRAW_OFFER]: () =>
execWithdrawOfferTx(item as ActionWithdrawOffer, api, executeTransaction),
[ShoppingActions.CANCEL_OFFER]: () =>
execCancelOffer(item as ActionCancelOffer, api, executeTransaction),
[ShoppingActions.ACCEPT_OFFER]: () =>
execAcceptOfferTx(item as ActionAcceptOffer, api, executeTransaction),
[ShoppingActions.MAKE_OFFER]: () =>
Expand Down
10 changes: 6 additions & 4 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1515,11 +1515,12 @@
"manageOffers": "Manage Offers",
"newOffer": "New Offer",
"offerAccept": "Accepting Offer",
"offerCancellation": "Offer Cancellation",
"offerCreation": "Offer Creation",
"offerFees": "Offer Fee",
"offerWithdrawl": "Offer Cancelation",
"typeOffer": "Type An Offer",
"withdrawAmount": "Withdraw Amount",
"withdrawOffer": "Withdraw Offer",
"yourOffer": "Your Offer",
"yourOfferAmount": "Your Offer Amount"
},
Expand Down Expand Up @@ -1841,7 +1842,8 @@
"selectOfferSubtitle": "Select your NFTs you want to offer in this swap.",
"submit": "Submit Swap Offer",
"swap": "Swap",
"swapWithdrawl": "Swap Cancelation",
"swapCancellation": "Swap Cancellation",
"withdrawSwap": "Withdraw Swap",
"youOffer": "You offer",
"youWillReceive": "You will receive",
"yourAddress": "Your Address",
Expand Down Expand Up @@ -1983,6 +1985,8 @@
"addressIncorrect": "Address Incorrect",
"burnNft": "Burn NFT | Burn NFTs",
"buy": { "error": "Failed to buy this item" },
"cancelOffer": "Cancel Offer",
"cancelSwap": "Cancel Swap",
"consume": { "error": "Failed to burn item", "success": "Item burned" },
"inputAddressFirst": "Input address first",
"item": { "error": "Failed to send item", "success": "Item sent" },
Expand All @@ -2005,8 +2009,6 @@
"error": "Item unlisting failed",
"success": "Item successfully unlisted"
},
"withdrawOffer": "Cancel Offer",
"withdrawSwap": "Cancel Swap",
"wrongAddressCannotRecoveredWarning": "Items sent to the wrong address cannot be recovered."
},
"transactionLoader": {
Expand Down
4 changes: 2 additions & 2 deletions utils/shoppingActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { Interaction } from '@kodadot1/minimark/v1'
enum OfferActions {
MAKE_OFFER = 'MAKE_OFFER',
SET_ROYALTY = 'SET_ROYALTY',
WITHDRAW_OFFER = 'WITHDRAW_OFFER',
CANCEL_OFFER = 'CANCEL_OFFER',
ACCEPT_OFFER = 'ACCEPT_OFFER',
CREATE_SWAP = 'CREATE_SWAP',
}

enum SwapActions {
WITHDRAW_SWAP = 'WITHDRAW_SWAP',
ACCEPT_SWAP = 'ACCEPT_SWAP',
CANCEL_SWAP = 'CANCEL_SWAP',
}

export type ShoppingActions = Interaction | OfferActions | SwapActions
Expand Down
Loading