Skip to content

Commit

Permalink
updated vote delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebyt committed Jan 12, 2024
1 parent 5e2800a commit f447b91
Showing 1 changed file with 24 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React, {useState} from 'react'
import ApiCardWithModal from './apiCardWithModal'
import {ModalWindowContent} from '../ui-constants'
import InputWithLabel from '../inputWithLabel'
import {
getCertOfNewVoteDelegation,
Expand All @@ -11,8 +9,9 @@ import {
getDRepNoConfidence,
getVoteDelegCert,
} from '../../utils/cslTools'
import GovToolsPanel from './govToolsPanel'

const VoteDelationCard = ({api, wasm, onWaiting, onError, getters, setters}) => {
const VoteDelegationPanel = ({api, wasm, onWaiting, onError, getters, setters}) => {
const [currentTarget, setTarget] = useState('')
const [currentStake, setStake] = useState('')
const {currentDRepIdBech32, currentRegPubStakeKey, currentUnregPubStakeKey, getCertBuilder} = getters
Expand All @@ -28,7 +27,9 @@ const VoteDelationCard = ({api, wasm, onWaiting, onError, getters, setters}) =>
return getCslCredentialFromBech32(wasm, input)
} catch (err2) {
onWaiting(false)
console.error(`Error in parsing credential, not Hex or Bech32: ${JSON.stringify(err1)}, ${JSON.stringify(err2)}`)
console.error(
`Error in parsing credential, not Hex or Bech32: ${JSON.stringify(err1)}, ${JSON.stringify(err2)}`,
)
onError()
return null
}
Expand Down Expand Up @@ -83,31 +84,29 @@ const VoteDelationCard = ({api, wasm, onWaiting, onError, getters, setters}) =>
}
}

const apiProps = {
buttonLabel: 'voteDelegation',
const panelProps = {
certLabel: 'voteDelegation',
clickFunction: buildVoteDelegationCert,
}

return (
<ApiCardWithModal {...apiProps}>
<div className={ModalWindowContent.contentPadding}>
<InputWithLabel
inputName="Target of vote delegation | abstain | no confidence"
inputValue={currentDRepIdBech32}
onChangeFunction={(event) => {
setTarget(event.target.value)
}}
/>
<InputWithLabel
inputName="Stake credential"
inputValue={currentRegPubStakeKey.length > 0 ? currentRegPubStakeKey: currentUnregPubStakeKey}
onChangeFunction={(event) => {
setStake(event.target.value)
}}
/>
</div>
</ApiCardWithModal>
<GovToolsPanel {...panelProps}>
<InputWithLabel
inputName="Target of vote delegation | abstain | no confidence"
inputValue={currentDRepIdBech32}
onChangeFunction={(event) => {
setTarget(event.target.value)
}}
/>
<InputWithLabel
inputName="Stake credential"
inputValue={currentRegPubStakeKey.length > 0 ? currentRegPubStakeKey : currentUnregPubStakeKey}
onChangeFunction={(event) => {
setStake(event.target.value)
}}
/>
</GovToolsPanel>
)
}

export default VoteDelationCard
export default VoteDelegationPanel

0 comments on commit f447b91

Please sign in to comment.