Various bug fixes (#435)
* fix: fixed the TxMessages issue * fix: don’t show RewardsCenter if not connected * fix: change deleteAccount message * undo: rewert delete account fix
This commit is contained in:
parent
0e62045031
commit
f7917c1660
@ -51,7 +51,7 @@ export default function DesktopHeader() {
|
||||
) : (
|
||||
<div className='flex gap-4'>
|
||||
{address && <AccountMenu />}
|
||||
<RewardsCenter />
|
||||
{address && <RewardsCenter />}
|
||||
<Wallet />
|
||||
<Settings />
|
||||
</div>
|
||||
|
@ -122,12 +122,12 @@ export default function WalletConnectedButton() {
|
||||
setShow={setShowDetails}
|
||||
>
|
||||
<div className='flex w-[440px] flex-wrap p-6'>
|
||||
<div className='flex-0 mb-4 flex w-full flex-nowrap items-start'>
|
||||
<div className='flex w-auto flex-1'>
|
||||
<div className='flex items-start w-full mb-4 flex-0 flex-nowrap'>
|
||||
<div className='flex flex-1 w-auto'>
|
||||
<div className='mr-2 flex h-[31px] items-end pb-0.5 text-base-caps'>
|
||||
{baseAsset.denom}
|
||||
{baseAsset.symbol}
|
||||
</div>
|
||||
<div className='flex-0 flex flex-wrap justify-end'>
|
||||
<div className='flex flex-wrap justify-end flex-0'>
|
||||
<FormattedNumber
|
||||
animate
|
||||
className='flex items-end text-2xl '
|
||||
@ -139,8 +139,8 @@ export default function WalletConnectedButton() {
|
||||
<Button color='secondary' onClick={onDisconnectWallet} text='Disconnect' />
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex w-full flex-wrap'>
|
||||
<Text uppercase className='/80 mb-1 break-all'>
|
||||
<div className='flex flex-wrap w-full'>
|
||||
<Text uppercase className='mb-1 break-all /80'>
|
||||
{'Your Address'}
|
||||
</Text>
|
||||
|
||||
@ -154,7 +154,7 @@ export default function WalletConnectedButton() {
|
||||
<Button
|
||||
leftIcon={isCopied ? <Check /> : <Copy />}
|
||||
variant='transparent'
|
||||
className='mr-10 flex w-auto py-2'
|
||||
className='flex w-auto py-2 mr-10'
|
||||
color='quaternary'
|
||||
onClick={setCopied}
|
||||
text={isCopied ? 'Copied' : 'Copy Address'}
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
ExecuteMsg as CreditManagerExecuteMsg,
|
||||
} from 'types/generated/mars-credit-manager/MarsCreditManager.types'
|
||||
import { getAssetByDenom, getAssetBySymbol } from 'utils/assets'
|
||||
import { getSingleValueFromBroadcastResult } from 'utils/broadcast'
|
||||
import { generateErrorMessage, getSingleValueFromBroadcastResult } from 'utils/broadcast'
|
||||
import checkAutoLendEnabled from 'utils/checkAutoLendEnabled'
|
||||
import { defaultFee } from 'utils/constants'
|
||||
import { formatAmountWithSymbol } from 'utils/formatters'
|
||||
@ -51,12 +51,11 @@ export default function createBroadcastSlice(
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const error = response.error ? response.error : response.result?.rawLogs
|
||||
set({
|
||||
toast: {
|
||||
message: errorMessage ?? `Transaction failed: ${error}`,
|
||||
message: generateErrorMessage(response, errorMessage),
|
||||
isError: true,
|
||||
hash: response.result.hash,
|
||||
hash: response.result?.hash,
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -134,7 +133,7 @@ export default function createBroadcastSlice(
|
||||
messages: [generateExecutionMessage(get().address, ENV.ADDRESS_CREDIT_MANAGER, msg, [])],
|
||||
})
|
||||
|
||||
if (response.result) {
|
||||
if (response.result && !response.error) {
|
||||
set({ createAccountModal: false })
|
||||
const id = getSingleValueFromBroadcastResult(response.result, 'wasm', 'token_id')
|
||||
set({
|
||||
@ -146,11 +145,8 @@ export default function createBroadcastSlice(
|
||||
set({
|
||||
createAccountModal: false,
|
||||
toast: {
|
||||
message:
|
||||
response.error && response.error !== 'Transaction failed'
|
||||
? `Transaction failed: ${response.error}`
|
||||
: 'Transaction rejected by user',
|
||||
hash: response.result?.hash ?? undefined,
|
||||
message: generateErrorMessage(response),
|
||||
hash: response?.result?.hash,
|
||||
isError: true,
|
||||
},
|
||||
})
|
||||
|
2
src/types/interfaces/store/broadcast.d.ts
vendored
2
src/types/interfaces/store/broadcast.d.ts
vendored
@ -2,7 +2,7 @@ const BNCoin = import('types/classes/BNCoin').BNCoin
|
||||
const ActionCoin = import('types/generated').ActionCoin
|
||||
|
||||
interface BroadcastResult {
|
||||
result?: import('@delphi-labs/shuttle-react').TxBroadcastResult
|
||||
result?: import('@delphi-labs/shuttle-react').BroadcastResult
|
||||
error?: string
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
import { BroadcastResult } from '@delphi-labs/shuttle-react'
|
||||
|
||||
export function getSingleValueFromBroadcastResult(
|
||||
response: BroadcastResult,
|
||||
response: BroadcastResult['result'],
|
||||
messageType: string,
|
||||
messageKey: string,
|
||||
): string | null {
|
||||
@ -14,3 +12,10 @@ export function getSingleValueFromBroadcastResult(
|
||||
if (!value) return null
|
||||
return value
|
||||
}
|
||||
|
||||
export function generateErrorMessage(result: BroadcastResult, errorMessage?: string) {
|
||||
const error = result.error ? result.error : result.result?.rawLogs
|
||||
if (errorMessage) return errorMessage
|
||||
if (error === 'Transaction failed') return 'Transaction rejected by user'
|
||||
return `Transaction failed: ${error}`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user