Skip to content

Commit

Permalink
Merge branch 'main' into 2025-01-10-yaml-handlebar-support
Browse files Browse the repository at this point in the history
  • Loading branch information
findolor authored Jan 10, 2025
2 parents 7c98450 + b86f340 commit 2584149
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 37 deletions.
62 changes: 30 additions & 32 deletions packages/orderbook/test/js_api/vault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions packages/ui-components/src/__tests__/ButtonVaultLink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { formatUnits } from 'viem';
export let tokenVault: Vault;
export let subgraphName: string;
</script>

<!-- svelte-ignore a11y-no-static-element-interactions -->
Expand All @@ -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}`)}
>
<div class="flex flex-col space-y-2">
<div class="flex items-center justify-between">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,6 +66,8 @@
onDestroy(() => {
clearInterval(interval);
});
$: subgraphName = $page.url.pathname.split('/')[2]?.split('-')[0];
</script>

<TanstackPageContentDetail query={orderDetailQuery} emptyMessage="Order not found">
Expand Down Expand Up @@ -118,7 +121,7 @@
</div>
<div class="space-y-2">
{#each data.inputs || [] as t}
<ButtonVaultLink tokenVault={t} />
<ButtonVaultLink tokenVault={t} {subgraphName} />
{/each}
</div>
</svelte:fragment>
Expand All @@ -132,7 +135,7 @@
</div>
<div class="space-y-2">
{#each data.outputs || [] as t}
<ButtonVaultLink tokenVault={t} />
<ButtonVaultLink tokenVault={t} {subgraphName} />
{/each}
</div>
</svelte:fragment>
Expand Down

0 comments on commit 2584149

Please sign in to comment.