From 28f5619caeb2e8307ca8c901eb9df948e2bb6eb0 Mon Sep 17 00:00:00 2001 From: Philipp Piwo Date: Tue, 10 Dec 2024 18:40:27 +0100 Subject: [PATCH] feat: allow to evaluate args --- src/components/Call.vue | 22 ++++++++++++++-------- src/components/CallStatic.vue | 26 ++++++++++++++++++-------- src/components/Deploy.vue | 22 ++++++++++++++-------- src/stores/contractStore.ts | 28 ++++++++++++++++++++++++---- 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/src/components/Call.vue b/src/components/Call.vue index c1a9479..3988980 100644 --- a/src/components/Call.vue +++ b/src/components/Call.vue @@ -96,14 +96,20 @@
- +
+ +
+ + +
+
diff --git a/src/components/CallStatic.vue b/src/components/CallStatic.vue index f78dcb0..12493f5 100644 --- a/src/components/CallStatic.vue +++ b/src/components/CallStatic.vue @@ -31,14 +31,24 @@
- +
+ +
+ + +
+
diff --git a/src/components/Deploy.vue b/src/components/Deploy.vue index 6fdcdc3..b550811 100644 --- a/src/components/Deploy.vue +++ b/src/components/Deploy.vue @@ -30,14 +30,20 @@
- +
+ +
+ + +
+
diff --git a/src/stores/contractStore.ts b/src/stores/contractStore.ts index 6e1301d..406f64a 100644 --- a/src/stores/contractStore.ts +++ b/src/stores/contractStore.ts @@ -24,6 +24,7 @@ export const useContractStore = defineStore("contract", () => { bytecode: string; aci: string; args: string; + eval: boolean; options: { amount: number; callData: string; @@ -35,19 +36,27 @@ export const useContractStore = defineStore("contract", () => { bytecode: "", aci: "", args: "", + eval: false, options: structuredClone(defaultCallOptions), }); const deployResult: Ref> = ref(new Result()); - const callStaticData: Ref<{ args: string; func: string; gas: number }> = ref({ + const callStaticData: Ref<{ + args: string; + func: string; + gas: number; + eval: boolean; + }> = ref({ func: "example", gas: 1000000, args: "", + eval: false, }); const callStaticResult: Ref> = ref(new Result()); const callData: Ref<{ args: string; + eval: boolean; func: string; options: { amount: number; @@ -59,6 +68,7 @@ export const useContractStore = defineStore("contract", () => { }> = ref({ func: "example", args: "", + eval: false, options: structuredClone(defaultCallOptions), }); const callResult: Ref> = ref(new Result()); @@ -137,7 +147,9 @@ export const useContractStore = defineStore("contract", () => { async function deployContract() { resetDeployAndCallData(false); deployResult.value.setInfo("Deploying Contract ..."); - const args = argsStringToArgs(deployData.value.args); + const args = deployData.value.eval + ? eval(deployData.value.args) + : argsStringToArgs(deployData.value.args); contractInstance = await Contract.initialize({ ...sdkStore.aeSdk.getContext(), @@ -166,7 +178,9 @@ export const useContractStore = defineStore("contract", () => { async function callContractStatic() { callStaticResult.value.setInfo("Dry-Running ..."); - const args = argsStringToArgs(callStaticData.value.args); + const args = callStaticData.value.eval + ? eval(callStaticData.value.args) + : argsStringToArgs(callStaticData.value.args); const options = { callStatic: true, gas: callStaticData.value.gas }; contractInstance @@ -189,7 +203,10 @@ export const useContractStore = defineStore("contract", () => { async function callContract() { callResult.value.setInfo("Calling Contract ..."); - const args = argsStringToArgs(callData.value.args); + + const args = callData.value.eval + ? eval(callData.value.args) + : argsStringToArgs(callData.value.args); const options = Object.fromEntries( Object.entries(callData.value.options).filter(([, v]) => v != null), ); @@ -233,6 +250,7 @@ export const useContractStore = defineStore("contract", () => { deployData.value = { aci: "", args: "", + eval: false, bytecode: "", options: structuredClone(defaultCallOptions), }; @@ -243,12 +261,14 @@ export const useContractStore = defineStore("contract", () => { func: "example", gas: 1000000, args: "", + eval: false, }; callStaticResult.value = new Result(); callData.value = { func: "example", args: "", + eval: false, options: structuredClone(defaultCallOptions), }; callResult.value = new Result();