From 6ca6fa59ed3975333b80854f85199f1af262f3e0 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Thu, 19 Dec 2024 10:31:33 +0100 Subject: [PATCH 1/9] add optional field --- crates/subgraph/src/types/common.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/subgraph/src/types/common.rs b/crates/subgraph/src/types/common.rs index b585a4fe2..5f4887983 100644 --- a/crates/subgraph/src/types/common.rs +++ b/crates/subgraph/src/types/common.rs @@ -348,7 +348,7 @@ pub struct Erc20 { pub address: Bytes, pub name: Option, pub symbol: Option, - #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt"))] + #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt | undefined"))] pub decimals: Option, } From 0983c4e866f9884fe2b4baace603d02ae4778c1e Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Thu, 19 Dec 2024 14:05:38 +0100 Subject: [PATCH 2/9] fix types --- crates/subgraph/src/types/common.rs | 5 +++++ packages/ui-components/src/__tests__/ButtonVaultLink.test.ts | 2 +- .../ui-components/src/__tests__/OrderTradesListTable.test.ts | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/subgraph/src/types/common.rs b/crates/subgraph/src/types/common.rs index 5f4887983..5fa295091 100644 --- a/crates/subgraph/src/types/common.rs +++ b/crates/subgraph/src/types/common.rs @@ -203,6 +203,7 @@ pub struct VaultBalanceChangeVault { #[typeshare] #[serde(rename_all = "camelCase")] pub struct VaultBalanceChangeUnwrapped { + #[serde(rename(serialize = "__typename"))] pub __typename: String, pub amount: BigInt, pub new_vault_balance: BigInt, @@ -233,6 +234,7 @@ pub enum VaultBalanceChange { #[serde(rename_all = "camelCase")] pub struct Deposit { pub id: Bytes, + #[serde(rename(serialize = "__typename"))] pub __typename: String, #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt"))] pub amount: BigInt, @@ -253,6 +255,7 @@ pub struct Deposit { #[serde(rename_all = "camelCase")] pub struct Withdrawal { pub id: Bytes, + #[serde(rename(serialize = "__typename"))] pub __typename: String, #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt"))] pub amount: BigInt, @@ -273,6 +276,7 @@ pub struct Withdrawal { #[serde(rename_all = "camelCase")] pub struct TradeVaultBalanceChange { pub id: Bytes, + #[serde(rename(serialize = "__typename"))] pub __typename: String, #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt"))] pub amount: BigInt, @@ -293,6 +297,7 @@ pub struct TradeVaultBalanceChange { #[serde(rename_all = "camelCase")] pub struct ClearBounty { pub id: Bytes, + #[serde(rename(serialize = "__typename"))] pub __typename: String, #[cfg_attr(target_family = "wasm", tsify(type = "SgBigInt"))] pub amount: BigInt, diff --git a/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts b/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts index 3078e7668..3e2f21ff4 100644 --- a/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts +++ b/packages/ui-components/src/__tests__/ButtonVaultLink.test.ts @@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/svelte'; import ButtonVaultLink from '../lib/components/ButtonVaultLink.svelte'; import * as navigation from '$app/navigation'; import { userEvent } from '@testing-library/user-event'; -import type { Vault } from '../lib/typeshare/subgraphTypes'; +import type { Vault } from '@rainlanguage/orderbook/js_api'; // Mock the $app/navigation module vi.mock('$app/navigation', () => ({ diff --git a/packages/ui-components/src/__tests__/OrderTradesListTable.test.ts b/packages/ui-components/src/__tests__/OrderTradesListTable.test.ts index d7d74f33c..fb724daf8 100644 --- a/packages/ui-components/src/__tests__/OrderTradesListTable.test.ts +++ b/packages/ui-components/src/__tests__/OrderTradesListTable.test.ts @@ -2,7 +2,7 @@ import { render, screen, waitFor } from '@testing-library/svelte'; import { test, vi, type Mock } from 'vitest'; import { expect } from '../lib/test/matchers'; import { mockIPC } from '@tauri-apps/api/mocks'; -import type { Trade } from '../lib/typeshare/subgraphTypes'; +import type { Trade } from '@rainlanguage/orderbook/js_api'; import { formatUnits } from 'viem'; import OrderTradesListTable from '../lib/components/tables/OrderTradesListTable.svelte'; import { QueryClient } from '@tanstack/svelte-query'; From 97dce1b993ad380538c7d3fb07900fd6e1acc1b7 Mon Sep 17 00:00:00 2001 From: Jamie Harding Date: Thu, 19 Dec 2024 14:12:39 +0100 Subject: [PATCH 3/9] remove types --- .../ui-components/src/__tests__/OrderVaultsVolTable.test.ts | 2 +- packages/ui-components/src/lib/__fixtures__/orderDetail.ts | 2 +- .../ui-components/src/lib/components/ButtonVaultLink.svelte | 2 +- .../src/lib/components/tables/OrderTradesListTable.svelte | 2 +- .../src/lib/components/tables/OrderVaultsVolTable.svelte | 2 +- .../src/lib/components/tables/VaultsListTable.svelte | 2 +- packages/ui-components/src/lib/index.ts | 1 - .../ui-components/src/lib/services/historicalOrderCharts.ts | 2 +- packages/ui-components/src/lib/utils/vault.ts | 2 +- 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/ui-components/src/__tests__/OrderVaultsVolTable.test.ts b/packages/ui-components/src/__tests__/OrderVaultsVolTable.test.ts index 3ce9a0df9..66310f2dd 100644 --- a/packages/ui-components/src/__tests__/OrderVaultsVolTable.test.ts +++ b/packages/ui-components/src/__tests__/OrderVaultsVolTable.test.ts @@ -1,7 +1,7 @@ import { render, screen, waitFor } from '@testing-library/svelte'; import { test, vi } from 'vitest'; import { expect } from '$lib/test/matchers'; -import type { VaultVolume } from '$lib/typeshare/subgraphTypes'; +import type { VaultVolume } from '@rainlanguage/orderbook/js_api'; import { formatUnits } from 'viem'; import OrderVaultsVolTable from '../lib/components/tables/OrderVaultsVolTable.svelte'; import { QueryClient } from '@tanstack/svelte-query'; diff --git a/packages/ui-components/src/lib/__fixtures__/orderDetail.ts b/packages/ui-components/src/lib/__fixtures__/orderDetail.ts index e432861dd..83d3909f1 100644 --- a/packages/ui-components/src/lib/__fixtures__/orderDetail.ts +++ b/packages/ui-components/src/lib/__fixtures__/orderDetail.ts @@ -1,4 +1,4 @@ -import type { OrderDetailExtended } from '../typeshare/subgraphTypes'; +import type { OrderDetailExtended } from '@rainlanguage/orderbook/js_api'; export const mockOrderDetailsExtended: OrderDetailExtended = { order: { diff --git a/packages/ui-components/src/lib/components/ButtonVaultLink.svelte b/packages/ui-components/src/lib/components/ButtonVaultLink.svelte index 81293ed34..f174b2b03 100644 --- a/packages/ui-components/src/lib/components/ButtonVaultLink.svelte +++ b/packages/ui-components/src/lib/components/ButtonVaultLink.svelte @@ -1,6 +1,6 @@