Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBEN committed Nov 10, 2023
1 parent a17f5fb commit 4ef17b4
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions front-end-tools/src/components/InitComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export default function InitComponent(props: ConnectionProps) {
const checkboxElement = form.getValues('useModuleReferenceFromStep1');

form.setValue('moduleReference', undefined);
setModuleReferenceLengthError(undefined);

if (
checkboxElement &&
Expand Down
1 change: 1 addition & 0 deletions front-end-tools/src/components/ReadComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export default function ReadComponenet(props: ConnectionProps) {
})
.catch((err: Error) => {
setContractInstanceInfo(contractInfo);
form.setValue('smartContractName', contractInfo.contractName);
setError((err as Error).message);
});
})
Expand Down
2 changes: 2 additions & 0 deletions front-end-tools/src/components/UpdateComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export default function UpdateComponenet(props: ConnectionProps) {
})
.catch((err: Error) => {
setContractInstanceInfo(contractInfo);
form.setValue('smartContractName', contractInfo.contractName);
setError((err as Error).message);
});
})
Expand Down Expand Up @@ -419,6 +420,7 @@ export default function UpdateComponenet(props: ConnectionProps) {
setParsingError(undefined);
form.setValue('inputParameterType', undefined);
form.setValue('inputParameter', undefined);
setUploadedModuleSchemaBase64(undefined);
setEntryPointTemplate(undefined);
setSchemaError(undefined);
}}
Expand Down
2 changes: 1 addition & 1 deletion front-end-tools/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ export const INPUT_PARAMETER_TYPES_OPTIONS = [
export const CONTRACT_SUB_INDEX = 0n;

// Regular expression of a valid module reference which has to be a hex string `[0-9A-Fa-f]` of length 64.
export const REG_MODULE_REF = /[0-9A-Fa-f]{64}/g;
export const REG_MODULE_REF = /^[0-9A-Fa-f]{64}$/;
8 changes: 5 additions & 3 deletions front-end-tools/src/reading_from_blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ export async function read(
});

if (!res || res.tag === 'failure') {
const rejectReason = JSON.stringify(
((res as InvokeContractFailedResult)?.reason as RejectedReceive)?.rejectReason
);

throw new Error(
`RPC call 'invokeContract' on method '${contractName}.${entryPoint}' of contract '${contractIndex}' failed.
Reject reason: ${JSON.stringify(
((res as InvokeContractFailedResult)?.reason as RejectedReceive)?.rejectReason
)}`
${rejectReason !== undefined ? `Reject reason: ${rejectReason}` : ''}`
);
}
if (!res.returnValue) {
Expand Down
2 changes: 1 addition & 1 deletion front-end-tools/src/writing_to_blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function initialize(
amount: bigint
) {
if (moduleReferenceAlreadyDeployed === false) {
throw new Error(`Module reference does not exist on chain. First, deploy your module in step 1.`);
throw new Error(`Module reference does not exist on chain. First, deploy your module in step 1 and change/refresh the module reference field in step 2 to remove this error.`);
}

if (moduleReference === undefined) {
Expand Down

0 comments on commit 4ef17b4

Please sign in to comment.