Match inputs and message types for execute

This commit is contained in:
Serkan Reis 2023-10-07 12:30:54 +03:00
parent b398650794
commit 51acae6a78
2 changed files with 55 additions and 11 deletions

View File

@ -203,7 +203,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
txSigner,
contractAddress,
{
set_collection_royalty_default: { collection, recipient, share },
set_collection_royalty_default: { collection, recipient, share: share / 100 },
},
'auto',
)
@ -220,7 +220,12 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
txSigner,
contractAddress,
{
update_collection_royalty_default: { collection, recipient, share_delta: shareDelta, decrement },
update_collection_royalty_default: {
collection,
recipient,
share_delta: shareDelta ? shareDelta / 100 : undefined,
decrement,
},
},
'auto',
)
@ -237,7 +242,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
txSigner,
contractAddress,
{
set_collection_royalty_protocol: { collection, protocol, recipient, share },
set_collection_royalty_protocol: { collection, protocol, recipient, share: share / 100 },
},
'auto',
)
@ -259,7 +264,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
collection,
protocol,
recipient,
share_delta: shareDelta,
share_delta: shareDelta ? shareDelta / 100 : undefined,
decrement,
},
},
@ -328,7 +333,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
sender: txSigner,
contract: contractAddress,
msg: {
set_collection_royalty_default: { collection, recipient, share },
set_collection_royalty_default: { collection, recipient, share: share / 100 },
},
funds: [],
}
@ -344,7 +349,12 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
sender: txSigner,
contract: contractAddress,
msg: {
update_collection_royalty_default: { collection, recipient, share_delta: shareDelta, decrement },
update_collection_royalty_default: {
collection,
recipient,
share_delta: shareDelta ? shareDelta / 100 : undefined,
decrement,
},
},
funds: [],
}
@ -355,7 +365,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
sender: txSigner,
contract: contractAddress,
msg: {
set_collection_royalty_protocol: { collection, protocol, recipient, share },
set_collection_royalty_protocol: { collection, protocol, recipient, share: share / 100 },
},
funds: [],
}
@ -376,7 +386,7 @@ export const RoyaltyRegistry = (client: SigningCosmWasmClient, txSigner: string)
collection,
protocol,
recipient,
share_delta: shareDelta,
share_delta: shareDelta ? shareDelta / 100 : undefined,
decrement,
},
},

View File

@ -1,10 +1,11 @@
import clsx from 'clsx'
import { Button } from 'components/Button'
import { Conditional } from 'components/Conditional'
import { ContractPageHeader } from 'components/ContractPageHeader'
import { ExecuteCombobox } from 'components/contracts/royaltyRegistry/ExecuteCombobox'
import { useExecuteComboboxState } from 'components/contracts/royaltyRegistry/ExecuteCombobox.hooks'
import { FormControl } from 'components/FormControl'
import { AddressInput } from 'components/forms/FormInput'
import { AddressInput, NumberInput } from 'components/forms/FormInput'
import { useInputState, useNumberInputState } from 'components/forms/FormInput.hooks'
import { JsonPreview } from 'components/JsonPreview'
import { LinkTabs } from 'components/LinkTabs'
@ -69,14 +70,16 @@ const RoyaltyRegistryExecutePage: NextPage = () => {
id: 'share',
name: 'share',
title: 'Share',
subtitle: 'Share',
subtitle: 'Share percentage',
placeholder: '4%',
})
const shareDeltaState = useNumberInputState({
id: 'share-delta',
name: 'share-delta',
title: 'Share Delta',
subtitle: 'Share delta',
subtitle: 'The change of share percentage',
placeholder: '1%',
})
const [decrement, setDecrement] = useState(false)
@ -152,10 +155,41 @@ const RoyaltyRegistryExecutePage: NextPage = () => {
<div className="space-y-8">
<AddressInput {...contractState} />
<ExecuteCombobox {...comboboxState} />
<AddressInput {...collectionAddressState} />
<Conditional
test={isEitherType(type, ['set_collection_royalty_protocol', 'update_collection_royalty_protocol'])}
>
<AddressInput {...protocolAddressState} />
</Conditional>
<Conditional test={showRecipientAddress}>
<AddressInput {...recipientAddressState} />
</Conditional>
<Conditional test={isEitherType(type, ['set_collection_royalty_protocol', 'set_collection_royalty_default'])}>
<NumberInput {...shareState} />
</Conditional>
<Conditional
test={isEitherType(type, ['update_collection_royalty_default', 'update_collection_royalty_protocol'])}
>
<NumberInput {...shareDeltaState} />
<div className="flex flex-row space-y-2 w-1/4">
<div className={clsx('flex flex-col space-y-2 w-full form-control')}>
<label className="justify-start cursor-pointer label">
<div className="flex flex-col">
<span className="mr-4 font-bold">Increment</span>
</div>
<input
checked={decrement}
className={`toggle ${decrement ? `bg-stargaze` : `bg-gray-600`}`}
onClick={() => setDecrement(!decrement)}
type="checkbox"
/>
</label>
</div>
<span className="mx-4 font-bold">Decrement</span>
</div>
</Conditional>
</div>
<div className="space-y-8">
<div className="relative">
<Button className="absolute top-0 right-0" isLoading={isLoading} rightIcon={<FaArrowRight />} type="submit">