From bbf46bd97342c8f338646b90e89e702a73a5260b Mon Sep 17 00:00:00 2001 From: Wan <495709+wa0x6e@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:40:15 +0800 Subject: [PATCH] feat: add space params to strategy playground (#4941) --- src/helpers/interfaces.ts | 1 + src/views/PlaygroundView.vue | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/helpers/interfaces.ts b/src/helpers/interfaces.ts index fc39df550075..a59c8ac3cb32 100644 --- a/src/helpers/interfaces.ts +++ b/src/helpers/interfaces.ts @@ -18,6 +18,7 @@ interface StrategyExample { network: string; addresses: string[]; snapshot: number; + space?: string; } interface StrategySchema { diff --git a/src/views/PlaygroundView.vue b/src/views/PlaygroundView.vue index d117daa3d17b..2e4a14dc5ada 100644 --- a/src/views/PlaygroundView.vue +++ b/src/views/PlaygroundView.vue @@ -34,11 +34,13 @@ const scores = ref(null); const searchInput = ref(''); const form = ref<{ params: Record; + space: string; network: string; snapshot: string; addresses: string[]; }>({ params: {}, + space: '', network: '1', snapshot: '', addresses: [] @@ -67,7 +69,7 @@ const scoresWithZeroBalanceAddresses = computed(() => { const strategyExample = computed(() => { if (queryParams.query) { try { - const { params, network, snapshot, addresses } = decodeJson( + const { params, network, snapshot, addresses, space } = decodeJson( queryParams.query ); return { @@ -75,6 +77,7 @@ const strategyExample = computed(() => { addresses: addresses || extendedStrategy.value?.examples?.[0].addresses, network, snapshot, + space, strategy: { params } }; } catch (e) { @@ -97,7 +100,7 @@ async function loadScores() { params: form.value.params }; scores.value = await getScores( - '', + form.value.space, [strategyParams], form.value.network, form.value.addresses, @@ -155,6 +158,7 @@ watch( () => { form.value.params = strategyExample.value?.strategy.params ?? defaultParams; form.value.network = strategyExample.value?.network ?? '1'; + form.value.space = strategyExample.value?.space ?? ''; form.value.addresses = strategyExample.value?.addresses ?? []; }, { immediate: true } @@ -221,6 +225,11 @@ function handleNetworkSelect(value) { :title="$t('snapshot')" @update:model-value="handleURLUpdate" /> +