From 4ef17b4e45eb4c986f95aa097f26df27c9e582f6 Mon Sep 17 00:00:00 2001 From: Doris Benda Date: Fri, 10 Nov 2023 09:58:19 +0200 Subject: [PATCH] Small fixes --- front-end-tools/src/components/InitComponent.tsx | 1 + front-end-tools/src/components/ReadComponent.tsx | 1 + front-end-tools/src/components/UpdateComponent.tsx | 2 ++ front-end-tools/src/constants.ts | 2 +- front-end-tools/src/reading_from_blockchain.ts | 8 +++++--- front-end-tools/src/writing_to_blockchain.ts | 2 +- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/front-end-tools/src/components/InitComponent.tsx b/front-end-tools/src/components/InitComponent.tsx index 223dabf3..da0c7a44 100644 --- a/front-end-tools/src/components/InitComponent.tsx +++ b/front-end-tools/src/components/InitComponent.tsx @@ -278,6 +278,7 @@ export default function InitComponent(props: ConnectionProps) { const checkboxElement = form.getValues('useModuleReferenceFromStep1'); form.setValue('moduleReference', undefined); + setModuleReferenceLengthError(undefined); if ( checkboxElement && diff --git a/front-end-tools/src/components/ReadComponent.tsx b/front-end-tools/src/components/ReadComponent.tsx index b7eea1e7..d43fb2fe 100644 --- a/front-end-tools/src/components/ReadComponent.tsx +++ b/front-end-tools/src/components/ReadComponent.tsx @@ -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); }); }) diff --git a/front-end-tools/src/components/UpdateComponent.tsx b/front-end-tools/src/components/UpdateComponent.tsx index c21ff26d..15ddee32 100644 --- a/front-end-tools/src/components/UpdateComponent.tsx +++ b/front-end-tools/src/components/UpdateComponent.tsx @@ -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); }); }) @@ -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); }} diff --git a/front-end-tools/src/constants.ts b/front-end-tools/src/constants.ts index b9aeb4a6..7504616a 100644 --- a/front-end-tools/src/constants.ts +++ b/front-end-tools/src/constants.ts @@ -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}$/; diff --git a/front-end-tools/src/reading_from_blockchain.ts b/front-end-tools/src/reading_from_blockchain.ts index 9f212d25..bde89fa8 100644 --- a/front-end-tools/src/reading_from_blockchain.ts +++ b/front-end-tools/src/reading_from_blockchain.ts @@ -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) { diff --git a/front-end-tools/src/writing_to_blockchain.ts b/front-end-tools/src/writing_to_blockchain.ts index e6f25b01..7af43493 100644 --- a/front-end-tools/src/writing_to_blockchain.ts +++ b/front-end-tools/src/writing_to_blockchain.ts @@ -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) {