Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support of cip129 for drep ids #3271

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ export const messages = defineMessages({
drepInputLabel: {
id: 'voting.governance.drepInputLabel',
defaultMessage:
'!!!Please type or paste a valid DRep ID (CIP-105) here. Look up {drepDirectoryLink}',
'!!!Please type or paste a valid DRep ID here. Look up {drepDirectoryLink}',
description: 'Label for DRep input on the governance page',
},
drepInputLabelPreprod: {
id: 'voting.governance.drepInputLabelPreprod',
defaultMessage: '!!!Please type or paste a valid DRep ID (CIP-105) here.',
defaultMessage: '!!!Please type or paste a valid DRep ID here.',
description: 'Label for DRep input on the governance page for preprod',
},
drepInputLabelLinkText: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,6 @@ type StateConfirmation = Omit<FormData, 'fee'> & {

type State = Form | FormWithError | StateFormComplete | StateConfirmation;

// TODO discuss if we need to restrict the length
const isDrepIdValid = (drepId: string) => {
const isDRepId = (value: string): value is Cardano.DRepID =>
Cardano.DRepID.isValid(value);
return isDRepId(drepId) && Cardano.DRepID.toCip105DRepID(drepId) === drepId;
};

const mapOfTxErrorCodeToIntl: Record<
InitializeVPDelegationTxError,
typeof messages[keyof typeof messages]
Expand Down Expand Up @@ -110,7 +103,7 @@ function VotingPowerDelegation({
}: Props) {
const [state, setState] = useState<State>(initialState);

const drepInputIsValid = isDrepIdValid(state.drepInputState.value);
const drepInputIsValid = Cardano.DRepID.isValid(state.drepInputState.value);

const formIsValid =
!!state.selectedWallet &&
Expand Down
4 changes: 2 additions & 2 deletions source/renderer/app/i18n/locales/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4407,12 +4407,12 @@
{
"descriptors": [
{
"defaultMessage": "!!!Please type or paste a valid DRep ID (CIP-105) here. Look up {drepDirectoryLink}",
"defaultMessage": "!!!Please type or paste a valid DRep ID here. Look up {drepDirectoryLink}",
"description": "Label for DRep input on the governance page",
"id": "voting.governance.drepInputLabel"
},
{
"defaultMessage": "!!!Please type or paste a valid DRep ID (CIP-105) here.",
"defaultMessage": "!!!Please type or paste a valid DRep ID here.",
"description": "Label for DRep input on the governance page for preprod",
"id": "voting.governance.drepInputLabelPreprod"
},
Expand Down
4 changes: 2 additions & 2 deletions source/renderer/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,11 @@
"voting.governance.confirmationDialog.vote": "Vote",
"voting.governance.delegateToDRep": "Delegate to DRep (default)",
"voting.governance.drepInputError": "Invalid DRep ID",
"voting.governance.drepInputLabel": "Please type or paste a valid DRep ID (CIP-105) here. Look up {drepDirectoryLink}",
"voting.governance.drepInputLabel": "Please type or paste a valid DRep ID here. Look up {drepDirectoryLink}",
"voting.governance.drepInputLabelLinkText": "DRep directory",
"voting.governance.drepInputLabelLinkUrl": "https://gov.tools/drep_directory",
"voting.governance.drepInputLabelLinkUrlPreview": "https://preview.gov.tools/drep_directory",
"voting.governance.drepInputLabelPreprod": "Please type or paste a valid DRep ID (CIP-105) here.",
"voting.governance.drepInputLabelPreprod": "Please type or paste a valid DRep ID here.",
"voting.governance.drepInputPlaceholder": "Paste DRep ID here …",
"voting.governance.heading": "CARDANO VOTING POWER DELEGATION",
"voting.governance.initializeTxError.generic": "Something went wrong during transaction initialization. Please try again in a few minutes. ",
Expand Down
4 changes: 2 additions & 2 deletions source/renderer/app/i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,11 @@
"voting.governance.confirmationDialog.vote": "投票",
"voting.governance.delegateToDRep": "DRepに委任(初期設定)",
"voting.governance.drepInputError": "無効なDRep IDです",
"voting.governance.drepInputLabel": "有効なDRep ID (CIP-105)を入力するか貼り付けます。{drepDirectoryLink}で検索する",
"voting.governance.drepInputLabel": "有効なDRep ID を入力するか貼り付けます。{drepDirectoryLink}で検索する",
"voting.governance.drepInputLabelLinkText": "DRepディレクトリ",
"voting.governance.drepInputLabelLinkUrl": "https://gov.tools/drep_directory",
"voting.governance.drepInputLabelLinkUrlPreview": "https://preview.gov.tools/drep_directory",
"voting.governance.drepInputLabelPreprod": "有効なDRep ID (CIP-105)を入力するか貼り付けます。",
"voting.governance.drepInputLabelPreprod": "有効なDRep ID を入力するか貼り付けます。",
"voting.governance.drepInputPlaceholder": "DRep IDを追加してください",
"voting.governance.heading": "Cardano投票権の委任",
"voting.governance.initializeTxError.generic": "トランザクションの初期化中に問題が発生しました。しばらくしてからもう一度お試しください。",
Expand Down
4 changes: 2 additions & 2 deletions translations/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4407,12 +4407,12 @@
{
"descriptors": [
{
"defaultMessage": "!!!Please type or paste a valid DRep ID (CIP-105) here. Look up {drepDirectoryLink}",
"defaultMessage": "!!!Please type or paste a valid DRep ID here. Look up {drepDirectoryLink}",
"description": "Label for DRep input on the governance page",
"id": "voting.governance.drepInputLabel"
},
{
"defaultMessage": "!!!Please type or paste a valid DRep ID (CIP-105) here.",
"defaultMessage": "!!!Please type or paste a valid DRep ID here.",
"description": "Label for DRep input on the governance page for preprod",
"id": "voting.governance.drepInputLabelPreprod"
},
Expand Down
Loading