-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #147 from terra-money/proposal/register-fee-sharing
Proposal/register fee sharing
- Loading branch information
Showing
11 changed files
with
681 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
.../enterprise/src/pages/create-proposal/register-fee-share/RegisterFeeShareProposalForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ProposalForm } from '../shared/ProposalForm'; | ||
import * as z from 'zod'; | ||
import { useForm } from 'react-hook-form'; | ||
import { zodResolver } from '@hookform/resolvers/zod'; | ||
import { toRegisterFeeShareMsg } from './helpers/toRegisterFeeShareMsg'; | ||
import { VStack } from 'lib/ui/Stack'; | ||
import { TextInput } from 'lib/ui/inputs/TextInput'; | ||
import { zodAddressValidator } from 'chain/utils/validators'; | ||
import { useCurrentDao } from 'dao/components/CurrentDaoProvider'; | ||
|
||
interface RegisterFeeShareProposalFormSchema { | ||
contractAddress: string; | ||
withdrawerAddress: string; | ||
} | ||
|
||
export const RegisterFeeShareProposalForm = () => { | ||
const dao = useCurrentDao(); | ||
|
||
|
||
|
||
const formSchema: z.ZodType<RegisterFeeShareProposalFormSchema> = z.object({ | ||
contractAddress: zodAddressValidator, | ||
withdrawerAddress: zodAddressValidator | ||
}); | ||
|
||
const { | ||
formState: { isValid }, | ||
getValues, | ||
register, | ||
} = useForm<RegisterFeeShareProposalFormSchema>({ | ||
mode: 'all', | ||
resolver: zodResolver(formSchema), | ||
}); | ||
|
||
return ( | ||
<ProposalForm | ||
disabled={!isValid} | ||
getProposalActions={() => { | ||
const { contractAddress, withdrawerAddress } = getValues(); | ||
return [ | ||
{ | ||
execute_msgs: { | ||
action_type: 'register-fee-share', | ||
msgs: [ | ||
toRegisterFeeShareMsg({ | ||
contractAddress, | ||
deployerAddress: dao.address, | ||
withdrawerAddress, | ||
}), | ||
], | ||
}, | ||
}, | ||
]; | ||
}} | ||
> | ||
<VStack alignItems="start" gap={8}> | ||
<TextInput {...register('contractAddress')} label="Contract address" placeholder="Enter a DAO-owned address" /> | ||
<TextInput {...register('withdrawerAddress')} label="Withdrawer address" placeholder="Enter an address to whitelist for fee withdrawal" /> | ||
</VStack> | ||
</ProposalForm> | ||
); | ||
}; |
7 changes: 7 additions & 0 deletions
7
.../enterprise/src/pages/create-proposal/register-fee-share/RegisterFeeShareProposalPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { RegisterFeeShareProposalForm } from './RegisterFeeShareProposalForm'; | ||
|
||
export const RegisterFeeShareProposalPage = () => { | ||
return ( | ||
<RegisterFeeShareProposalForm /> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
...enterprise/src/pages/create-proposal/register-fee-share/helpers/toRegisterFeeShareMsg.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { StargateMsg } from 'chain/CosmWasm'; | ||
import { MsgRegisterFeeShare } from '@terra-money/feather.js'; | ||
|
||
|
||
interface RegisterFeeShareParams { | ||
contractAddress: string | ||
deployerAddress: string, | ||
withdrawerAddress: string; | ||
} | ||
|
||
export const toRegisterFeeShareMsg = ({ contractAddress, deployerAddress, withdrawerAddress }: RegisterFeeShareParams) => { | ||
|
||
const registerMsg = new MsgRegisterFeeShare(contractAddress, deployerAddress, withdrawerAddress); | ||
const packed = registerMsg.packAny(); | ||
|
||
|
||
const msg: StargateMsg = { | ||
stargate: { | ||
type_url: packed.typeUrl, | ||
value: Buffer.from(packed.value).toString("base64") | ||
} | ||
}; | ||
|
||
return JSON.stringify(msg); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.