From 8d7317ae29c10c7b87ab07368471823a160f5142 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 7 Jan 2025 12:06:28 +0100 Subject: [PATCH 1/2] get button name for vault link --- .../ui-components/src/__tests__/ButtonVaultLink.test.ts | 5 +++-- .../src/lib/components/ButtonVaultLink.svelte | 3 ++- .../src/lib/components/detail/OrderDetail.svelte | 7 +++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts b/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts index 518ef8abf..db251ca94 100644 --- a/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts +++ b/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts @@ -24,13 +24,14 @@ describe('ButtonVaultLink', () => { it('should navigate to vault details page when clicked', async () => { render(ButtonVaultLink, { props: { - tokenVault: mockVault + tokenVault: mockVault, + subgraphName: 'test' } }); const vaultLink = screen.getByTestId('vault-link'); expect(vaultLink).toBeTruthy(); await userEvent.click(vaultLink); - expect(navigation.goto).toHaveBeenCalledWith(`/vaults/${mockVault.id}`); + expect(navigation.goto).toHaveBeenCalledWith(`/vaults/test-${mockVault.id}`); }); }); diff --git a/packages/ui-components/src/lib/components/ButtonVaultLink.svelte b/packages/ui-components/src/lib/components/ButtonVaultLink.svelte index f174b2b03..ba43689fd 100644 --- a/packages/ui-components/src/lib/components/ButtonVaultLink.svelte +++ b/packages/ui-components/src/lib/components/ButtonVaultLink.svelte @@ -6,6 +6,7 @@ import { formatUnits } from 'viem'; export let tokenVault: Vault; + export let subgraphName: string; @@ -14,7 +15,7 @@ class="cursor-pointer rounded-lg" id="token-info" data-testid="vault-link" - on:click={() => goto(`/vaults/${tokenVault.id}`)} + on:click={() => goto(`/vaults/${subgraphName}-${tokenVault.id}`)} >
diff --git a/packages/ui-components/src/lib/components/detail/OrderDetail.svelte b/packages/ui-components/src/lib/components/detail/OrderDetail.svelte index 078347c9b..1cb312dca 100644 --- a/packages/ui-components/src/lib/components/detail/OrderDetail.svelte +++ b/packages/ui-components/src/lib/components/detail/OrderDetail.svelte @@ -18,6 +18,7 @@ import { onDestroy } from 'svelte'; import type { Readable } from 'svelte/store'; import OrderApy from '../tables/OrderAPY.svelte'; + import { page } from '$app/stores'; export let walletAddressMatchesOrBlank: Readable<(address: string) => boolean> | undefined = undefined; @@ -65,6 +66,8 @@ onDestroy(() => { clearInterval(interval); }); + + $: subgraphName = $page.url.pathname.split('/')[2]?.split('-')[0]; @@ -118,7 +121,7 @@
{#each data.inputs || [] as t} - + {/each}
@@ -132,7 +135,7 @@
{#each data.outputs || [] as t} - + {/each}
From 06a84b34b73c459f75c0d454268efba7074ff58f Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Tue, 7 Jan 2025 12:12:41 +0100 Subject: [PATCH 2/2] format vault test --- packages/orderbook/test/js_api/vault.test.ts | 62 ++++++++++---------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/orderbook/test/js_api/vault.test.ts b/packages/orderbook/test/js_api/vault.test.ts index ee8fe9509..e057e7d83 100644 --- a/packages/orderbook/test/js_api/vault.test.ts +++ b/packages/orderbook/test/js_api/vault.test.ts @@ -94,32 +94,32 @@ describe('Rain Orderbook JS API Package Bindgen Vault Tests', async function () it('should fetch vault balance changes', async () => { const mockVaultBalanceChanges = [ { - "__typename": "Deposit", - "amount": "5000000000000000000", - "newVaultBalance": "5000000000000000000", - "oldVaultBalance": "0", - "vault": { - "id": "0x166aeed725f0f3ef9fe62f2a9054035756d55e5560b17afa1ae439e9cd362902", - "vaultId": "1", - "token": { - "id": "0x1d80c49bbbcd1c0911346656b529df9e5c2f783d", - "address": "0x1d80c49bbbcd1c0911346656b529df9e5c2f783d", - "name": "Wrapped Flare", - "symbol": "WFLR", - "decimals": "18" - } - }, - "timestamp": "1734054063", - "transaction": { - "id": "0x85857b5c6d0b277f9e971b6b45cab98720f90b8f24d65df020776d675b71fc22", - "from": "0x7177b9d00bb5dbcaaf069cc63190902763783b09", - "blockNumber": "34407047", - "timestamp": "1734054063" - }, - "orderbook": { - "id": "0xcee8cd002f151a536394e564b84076c41bbbcd4d" - } - } + __typename: 'Deposit', + amount: '5000000000000000000', + newVaultBalance: '5000000000000000000', + oldVaultBalance: '0', + vault: { + id: '0x166aeed725f0f3ef9fe62f2a9054035756d55e5560b17afa1ae439e9cd362902', + vaultId: '1', + token: { + id: '0x1d80c49bbbcd1c0911346656b529df9e5c2f783d', + address: '0x1d80c49bbbcd1c0911346656b529df9e5c2f783d', + name: 'Wrapped Flare', + symbol: 'WFLR', + decimals: '18' + } + }, + timestamp: '1734054063', + transaction: { + id: '0x85857b5c6d0b277f9e971b6b45cab98720f90b8f24d65df020776d675b71fc22', + from: '0x7177b9d00bb5dbcaaf069cc63190902763783b09', + blockNumber: '34407047', + timestamp: '1734054063' + }, + orderbook: { + id: '0xcee8cd002f151a536394e564b84076c41bbbcd4d' + } + } ]; await mockServer @@ -128,16 +128,14 @@ describe('Rain Orderbook JS API Package Bindgen Vault Tests', async function () .thenReply(200, JSON.stringify({ data: { vaultBalanceChanges: mockVaultBalanceChanges } })); try { - const result: Deposit[] = await getVaultBalanceChanges( - mockServer.url + '/sg3', - vault1.id, - { page: 1, pageSize: 1 } - ); + const result: Deposit[] = await getVaultBalanceChanges(mockServer.url + '/sg3', vault1.id, { + page: 1, + pageSize: 1 + }); assert.equal(result[0].__typename, 'Deposit'); assert.equal(result[0].amount, '5000000000000000000'); assert.equal(result[0].newVaultBalance, '5000000000000000000'); assert.equal(result[0].oldVaultBalance, '0'); - } catch (e) { console.log(e); assert.fail('expected to resolve, but failed');