Skip to content

Commit

Permalink
Rename validate methods function (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeesunikim authored Jul 19, 2024
1 parent 0a30706 commit 88068b3
Show file tree
Hide file tree
Showing 39 changed files with 273 additions and 267 deletions.
2 changes: 1 addition & 1 deletion src/app/(sidebar)/account/fund/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function FundAccount() {
value={generatedPublicKey}
onChange={(e) => {
setGeneratedPublicKey(e.target.value);
const error = validate.publicKey(e.target.value);
const error = validate.getPublicKeyError(e.target.value);
setInlineErrorMessage(error || "");
}}
placeholder="Ex: GCEXAMPLE5HWNK4AYSTEQ4UWDKHTCKADVS2AHF3UI2ZMO3DPUSM6Q4UG"
Expand Down
4 changes: 2 additions & 2 deletions src/app/(sidebar)/account/muxed-create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default function CreateMuxedAccount() {
if (!e.target.value.startsWith("G")) {
error = "Base account address should start with G";
} else {
error = validate.publicKey(e.target.value) || "";
error = validate.getPublicKeyError(e.target.value) || "";
}

setBaseFieldErrorMessage(error);
Expand All @@ -120,7 +120,7 @@ export default function CreateMuxedAccount() {
setReset(true);
setMuxedId(e.target.value);

const error = validate.positiveInt(e.target.value);
const error = validate.getPositiveIntError(e.target.value);
setMuxedFieldError(error || "");
}}
error={muxedFieldError}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(sidebar)/account/muxed-parse/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function ParseMuxedAccount() {
if (!e.target.value.startsWith("M")) {
error = "Muxed account address should start with M";
} else {
error = validate.publicKey(e.target.value) || "";
error = validate.getPublicKeyError(e.target.value) || "";
}

setMuxedFieldError(error);
Expand Down
12 changes: 6 additions & 6 deletions src/app/(sidebar)/transaction/build/components/Params.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,27 @@ export const Params = () => {
const validateParam = (param: ParamsField, value: any) => {
switch (param) {
case "cond":
return validate.timeBounds(value?.time || value);
return validate.getTimeBoundsError(value?.time || value);
case "fee":
return validate.positiveInt(value);
return validate.getPositiveIntError(value);
case "memo":
if (!value || isEmptyObject(value)) {
return false;
}

// Memo in store is in transaction format { memoType: memoValue }
if (value.type) {
return validate.memo(value);
return validate.getMemoError(value);
} else {
// Changing it to { type, value } format if needed
const [type, val] = Object.entries(value)[0];
return validate.memo({ type, value: val as MemoValue });
return validate.getMemoError({ type, value: val as MemoValue });
}

case "seq_num":
return validate.positiveInt(value);
return validate.getPositiveIntError(value);
case "source_account":
return validate.publicKey(value);
return validate.getPublicKeyError(value);
default:
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/(sidebar)/transaction/fee-bump/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export default function FeeBumpTransaction() {
const validateParam = (param: ParamsField, value: any) => {
switch (param) {
case "source_account":
return validate.publicKey(value);
return validate.getPublicKeyError(value);
case "fee":
return validate.positiveInt(value);
return validate.getPositiveIntError(value);
case "xdr":
if (validate.xdr(value)?.result === "success") {
if (validate.getXdrError(value)?.result === "success") {
return false;
}
return validate.xdr(value)?.message;
return validate.getXdrError(value)?.message;
default:
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/(sidebar)/transaction/sign/components/Import.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Import = () => {
setTxXdr(value);

if (value.length > 0) {
const validatedXDR = validate.xdr(value);
const validatedXDR = validate.getXdrError(value);

if (validatedXDR?.result && validatedXDR.message) {
if (validatedXDR.result === "success") {
Expand Down
6 changes: 3 additions & 3 deletions src/app/(sidebar)/transaction/sign/components/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const Overview = () => {
const HAS_SECRET_KEYS = secretInputs.some((input) => input !== "");
const HAS_INVALID_SECRET_KEYS = secretInputs.some((input) => {
if (input.length) {
return validate.secretKey(input);
return validate.getSecretKeyError(input);
}
return false;
});
Expand Down Expand Up @@ -283,7 +283,7 @@ export const Overview = () => {
label="Add Signer"
value={secretInputs}
onChange={onUpdateSecretInputs}
validate={validate.secretKey}
validate={validate.getSecretKeyError}
placeholder="Secret key (starting with S) or hash preimage (in hex)"
autocomplete="off"
/>
Expand All @@ -306,7 +306,7 @@ export const Overview = () => {
onChange={(e) => {
updateBipPath(e.target.value);

const error = validate.bipPath(e.target.value);
const error = validate.getBipPathError(e.target.value);

if (error) {
setBipPathErrorMsg(error);
Expand Down
4 changes: 2 additions & 2 deletions src/components/FormElements/FiltersPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const FiltersPicker = ({ id, value, onChange }: FiltersPickerProps) => {
label="Contract IDs (up to 5)"
value={value?.contract_ids}
onChange={(val) => onUpdate(val, "contract_ids")}
validate={validate.contractId}
validate={validate.getContractIdError}
placeholder="Ex: CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
limit={5}
/>
Expand All @@ -87,7 +87,7 @@ export const FiltersPicker = ({ id, value, onChange }: FiltersPickerProps) => {
label="Topics (up to 5)"
value={value?.topics}
onChange={(val) => onUpdate(val, "topics")}
validate={validate.arrayOfStrings}
validate={validate.getArrayOfStringsError}
placeholder="Ex: ['AAAADwAAAAh0cmFuc2Zlcg==', '*', '*', '*']"
limit={5}
/>
Expand Down
Loading

0 comments on commit 88068b3

Please sign in to comment.