Skip to content

Commit

Permalink
fixed rebalancer config action initial funds detection
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Nov 5, 2024
1 parent 67cbe08 commit b8b2ae0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Close, InfoOutlined } from '@mui/icons-material'
import clsx from 'clsx'
import { ComponentType, useEffect, useState } from 'react'
import { useFieldArray, useFormContext } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -318,58 +319,62 @@ export const ConfigureRebalancerComponent: ActionComponent<
>
{t('button.addToken')}
</Button>
</>
)}

<div className="flex flex-row gap-2 items-center mt-4">
<FormCheckbox
fieldName={
(fieldNamePrefix +
'newValenceAccount.acknowledgedServiceFee') as 'newValenceAccount.acknowledgedServiceFee'
}
setValue={setValue}
size="sm"
value={acknowledgedServiceFee}
/>
<div
className={clsx(
'flex flex-row gap-2 items-center',
isCreating ? 'mt-4' : 'mt-2'
)}
>
<FormCheckbox
fieldName={
(fieldNamePrefix +
'newValenceAccount.acknowledgedServiceFee') as 'newValenceAccount.acknowledgedServiceFee'
}
readOnly={!isCreating}
setValue={setValue}
size="sm"
value={acknowledgedServiceFee}
/>

<p
className="body-text cursor-pointer"
onClick={() =>
setValue(
(fieldNamePrefix +
'newValenceAccount.acknowledgedServiceFee') as 'newValenceAccount.acknowledgedServiceFee',
!acknowledgedServiceFee
)
}
>
{t('info.acknowledgeServiceFee', {
fee: serviceFee.loading
? '...'
: serviceFee.errored
? '<error>'
: serviceFee.data
? t('format.token', {
amount: HugeDecimal.from(
serviceFee.data.balance
).toInternationalizedHumanReadableString({
decimals: serviceFee.data.token.decimals,
}),
symbol: serviceFee.data.token.symbol,
})
: '',
context:
serviceFee.loading ||
serviceFee.errored ||
serviceFee.data
? undefined
: 'none',
})}
</p>
</div>
<p
className="body-text cursor-pointer"
onClick={() =>
setValue(
(fieldNamePrefix +
'newValenceAccount.acknowledgedServiceFee') as 'newValenceAccount.acknowledgedServiceFee',
!acknowledgedServiceFee
)
}
>
{t('info.acknowledgeServiceFee', {
fee: serviceFee.loading
? '...'
: serviceFee.errored
? '<error>'
: serviceFee.data
? t('format.token', {
amount: HugeDecimal.from(
serviceFee.data.balance
).toInternationalizedHumanReadableString({
decimals: serviceFee.data.token.decimals,
}),
symbol: serviceFee.data.token.symbol,
})
: '',
context:
serviceFee.loading || serviceFee.errored || serviceFee.data
? undefined
: 'none',
})}
</p>
</div>

<InputErrorMessage
error={errors?.newValenceAccount?.acknowledgedServiceFee}
/>
</>
)}
<InputErrorMessage
error={errors?.newValenceAccount?.acknowledgedServiceFee}
/>
</div>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,7 @@ export class ConfigureRebalancerAction extends ActionBase<ConfigureRebalancerDat
: undefined

const newValenceAccountFunds = isCreating
? []
: await Promise.all(
? await Promise.all(
(
messages[0].decodedMessage.stargate.value as MsgInstantiateContract2
).funds.map(async ({ denom, amount }) => {
Expand All @@ -772,11 +771,13 @@ export class ConfigureRebalancerAction extends ActionBase<ConfigureRebalancerDat
}
})
)
: []

return {
newValenceAccount: {
creating: isCreating,
funds: newValenceAccountFunds,
acknowledgedServiceFee: true,
},
chainId,
trustee:
Expand Down

0 comments on commit b8b2ae0

Please sign in to comment.