@rainlanguage/ui-components 0.0.1-alpha.97 → 0.0.1-alpha.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,12 +6,16 @@ export let rainlangText = void 0;
6
6
  export let codeMirrorTheme;
7
7
  export let codeMirrorDisabled = true;
8
8
  export let codeMirrorStyles = {};
9
- $: extendedOrder = order ? extendOrder(order) : void 0;
9
+ let result;
10
+ let extendedOrder;
11
+ $: result = order ? extendOrder(order) : void 0;
12
+ $: extendedOrder = result && !result.error ? result.value : void 0;
13
+ $: extendOrderError = result && result.error ? result.error : void 0;
10
14
  </script>
11
15
 
12
16
  {#if rainlangText || extendedOrder?.rainlang}
13
17
  <CodeMirror
14
- value={rainlangText || extendedOrder.rainlang}
18
+ value={rainlangText || extendedOrder?.rainlang}
15
19
  extensions={[RainlangLR]}
16
20
  theme={codeMirrorTheme}
17
21
  readonly={codeMirrorDisabled}
@@ -24,6 +28,10 @@ $: extendedOrder = order ? extendOrder(order) : void 0;
24
28
  ...codeMirrorStyles
25
29
  }}
26
30
  />
31
+ {:else if extendOrderError}
32
+ <div class="w-full tracking-tight text-red-600 dark:text-red-400" data-testid="rainlang-error">
33
+ {extendOrderError.readableMsg}
34
+ </div>
27
35
  {:else if !extendedOrder?.rainlang && !rainlangText}
28
36
  <div
29
37
  class="w-full tracking-tight text-gray-900 dark:text-white"
@@ -20,7 +20,8 @@ $: query = createQuery({
20
20
  BigInt(1e3),
21
21
  void 0
22
22
  );
23
- return prepareHistoricalOrderChartData(data, $colorTheme);
23
+ if (data.error) throw new Error(data.error.msg);
24
+ return prepareHistoricalOrderChartData(data.value, $colorTheme);
24
25
  },
25
26
  enabled: !!subgraphUrl
26
27
  });
@@ -1,9 +1,7 @@
1
1
  <script>import { timestampSecondsToUTCTimestamp } from "../../services/time";
2
2
  import { bigintToFloat } from "../../utils/number";
3
3
  import { createQuery } from "@tanstack/svelte-query";
4
- import {
5
- getVaultBalanceChanges
6
- } from "@rainlanguage/orderbook";
4
+ import { getVaultBalanceChanges } from "@rainlanguage/orderbook";
7
5
  import TanstackLightweightChartLine from "../charts/TanstackLightweightChartLine.svelte";
8
6
  import { QKEY_VAULT_CHANGES } from "../../queries/keys";
9
7
  export let vault;
@@ -12,11 +10,13 @@ export let subgraphUrl;
12
10
  export let lightweightChartsTheme;
13
11
  $: query = createQuery({
14
12
  queryKey: [id, QKEY_VAULT_CHANGES + id, QKEY_VAULT_CHANGES],
15
- queryFn: () => {
16
- return getVaultBalanceChanges(subgraphUrl || "", vault.id, {
13
+ queryFn: async () => {
14
+ const result = await getVaultBalanceChanges(subgraphUrl || "", vault.id, {
17
15
  page: 1,
18
16
  pageSize: 1e3
19
17
  });
18
+ if (result.error) throw new Error(result.error.msg);
19
+ return result.value;
20
20
  },
21
21
  enabled: !!subgraphUrl
22
22
  });
@@ -44,8 +44,10 @@ const queryClient = useQueryClient();
44
44
  const { matchesAccount } = useAccount();
45
45
  $: orderDetailQuery = createQuery({
46
46
  queryKey: [orderHash, QKEY_ORDER + orderHash],
47
- queryFn: () => {
48
- return getOrderByHash(subgraphUrl, orderHash);
47
+ queryFn: async () => {
48
+ const result = await getOrderByHash(subgraphUrl, orderHash);
49
+ if (result.error) throw new Error(result.error.msg);
50
+ return result.value;
49
51
  },
50
52
  enabled: !!subgraphUrl
51
53
  });
@@ -29,8 +29,10 @@ const queryClient = useQueryClient();
29
29
  const { matchesAccount } = useAccount();
30
30
  $: vaultDetailQuery = createQuery({
31
31
  queryKey: [id, QKEY_VAULT + id],
32
- queryFn: () => {
33
- return getVault(subgraphUrl || "", id);
32
+ queryFn: async () => {
33
+ const result = await getVault(subgraphUrl || "", id);
34
+ if (result.error) throw new Error(result.error.msg);
35
+ return result.value;
34
36
  },
35
37
  enabled: !!subgraphUrl
36
38
  });
@@ -14,14 +14,9 @@ $: queryEndTime = endTimestamp ? BigInt(endTimestamp) : void 0;
14
14
  $: orderPerformance = createInfiniteQuery({
15
15
  queryKey: [id, QKEY_ORDER_APY + id],
16
16
  queryFn: async () => {
17
- return [
18
- await getOrderPerformance(
19
- subgraphUrl || "",
20
- id,
21
- queryStartTime,
22
- queryEndTime
23
- )
24
- ];
17
+ const result = await getOrderPerformance(subgraphUrl || "", id, queryStartTime, queryEndTime);
18
+ if (result.error) throw new Error(result.error.msg);
19
+ return [result.value];
25
20
  },
26
21
  initialPageParam: 0,
27
22
  getNextPageParam: () => void 0,
@@ -20,7 +20,7 @@ $: orderTradesQuery = createInfiniteQuery({
20
20
  queryKey: [id, QKEY_ORDER_TRADES_LIST + id],
21
21
  queryFn: async ({ pageParam }) => {
22
22
  tradesCount = void 0;
23
- const [count, trades] = await Promise.all([
23
+ const [countResult, tradesResult] = await Promise.all([
24
24
  getOrderTradesCount(
25
25
  subgraphUrl || "",
26
26
  id,
@@ -35,6 +35,10 @@ $: orderTradesQuery = createInfiniteQuery({
35
35
  endTimestamp ? BigInt(endTimestamp) : void 0
36
36
  )
37
37
  ]);
38
+ if (countResult.error) throw new Error(countResult.error.msg);
39
+ if (tradesResult.error) throw new Error(tradesResult.error.msg);
40
+ const count = countResult.value;
41
+ const trades = tradesResult.value;
38
42
  if (typeof count === "number") {
39
43
  tradesCount = count;
40
44
  }
@@ -15,7 +15,16 @@ $: queryStartTime = startTimestamp ? BigInt(startTimestamp) : void 0;
15
15
  $: queryEndTime = endTimestamp ? BigInt(endTimestamp) : void 0;
16
16
  $: vaultsVol = createInfiniteQuery({
17
17
  queryKey: [id, QKEY_VAULTS_VOL_LIST + id],
18
- queryFn: () => getOrderVaultsVolume(subgraphUrl || "", id, queryStartTime, queryEndTime),
18
+ queryFn: async () => {
19
+ const result = await getOrderVaultsVolume(
20
+ subgraphUrl || "",
21
+ id,
22
+ queryStartTime,
23
+ queryEndTime
24
+ );
25
+ if (result.error) throw new Error(result.error.msg);
26
+ return result.value;
27
+ },
19
28
  initialPageParam: 0,
20
29
  getNextPageParam: () => void 0,
21
30
  enabled: !!subgraphUrl
@@ -48,8 +48,8 @@ $: query = createInfiniteQuery({
48
48
  $showInactiveOrders,
49
49
  $orderHash
50
50
  ],
51
- queryFn: ({ pageParam }) => {
52
- return getOrders(
51
+ queryFn: async ({ pageParam }) => {
52
+ const result = await getOrders(
53
53
  multiSubgraphArgs,
54
54
  {
55
55
  owners,
@@ -58,6 +58,8 @@ $: query = createInfiniteQuery({
58
58
  },
59
59
  { page: pageParam + 1, pageSize: DEFAULT_PAGE_SIZE }
60
60
  );
61
+ if (result.error) throw new Error(result.error.msg);
62
+ return result.value;
61
63
  },
62
64
  initialPageParam: 0,
63
65
  getNextPageParam(lastPage, _allPages, lastPageParam) {
@@ -13,11 +13,13 @@ export let id;
13
13
  export let subgraphUrl;
14
14
  $: balanceChangesQuery = createInfiniteQuery({
15
15
  queryKey: [id, QKEY_VAULT_CHANGES + id],
16
- queryFn: ({ pageParam }) => {
17
- return getVaultBalanceChanges(subgraphUrl || "", id, {
16
+ queryFn: async ({ pageParam }) => {
17
+ const result = await getVaultBalanceChanges(subgraphUrl || "", id, {
18
18
  page: pageParam + 1,
19
19
  pageSize: DEFAULT_PAGE_SIZE
20
20
  });
21
+ if (result.error) throw new Error(result.error.msg);
22
+ return result.value;
21
23
  },
22
24
  initialPageParam: 0,
23
25
  getNextPageParam(lastPage, _allPages, lastPageParam) {
@@ -49,8 +49,8 @@ $: query = createInfiniteQuery({
49
49
  $settings,
50
50
  owners
51
51
  ],
52
- queryFn: ({ pageParam }) => {
53
- return getVaults(
52
+ queryFn: async ({ pageParam }) => {
53
+ const result = await getVaults(
54
54
  multiSubgraphArgs,
55
55
  {
56
56
  owners,
@@ -58,6 +58,8 @@ $: query = createInfiniteQuery({
58
58
  },
59
59
  { page: pageParam + 1, pageSize: DEFAULT_PAGE_SIZE }
60
60
  );
61
+ if (result.error) throw new Error(result.error.msg);
62
+ return result.value;
61
63
  },
62
64
  initialPageParam: 0,
63
65
  getNextPageParam(lastPage, _allPages, lastPageParam) {
@@ -2,7 +2,7 @@
2
2
  * @module awaitTransactionIndexing
3
3
  * @description Utilities for waiting for transactions to be indexed by a subgraph
4
4
  */
5
- import type { SgAddOrderWithOrder, SgRemoveOrderWithOrder, SgTransaction } from '@rainlanguage/orderbook';
5
+ import type { SgAddOrderWithOrder, SgRemoveOrderWithOrder, SgTransaction, WasmEncodedResult } from '@rainlanguage/orderbook';
6
6
  /**
7
7
  * Error message when subgraph indexing times out
8
8
  */
@@ -80,7 +80,7 @@ export declare const awaitSubgraphIndexing: <T>(options: {
80
80
  * @param subgraphUrl URL of the subgraph
81
81
  * @param txHash Transaction hash to query
82
82
  */
83
- fetchData: (subgraphUrl: string, txHash: string) => Promise<T | null | undefined>;
83
+ fetchData: (subgraphUrl: string, txHash: string) => Promise<WasmEncodedResult<T | null | undefined>>;
84
84
  /**
85
85
  * Function to determine if the fetched data indicates success
86
86
  * @param data The data returned from the subgraph
@@ -119,7 +119,7 @@ export interface TransactionConfig<T> {
119
119
  /**
120
120
  * Function to fetch data from the subgraph
121
121
  */
122
- fetchData: (subgraphUrl: string, txHash: string) => Promise<T>;
122
+ fetchData: (subgraphUrl: string, txHash: string) => Promise<WasmEncodedResult<T>>;
123
123
  /**
124
124
  * Function to determine if the fetched data indicates success
125
125
  */
@@ -23,12 +23,14 @@ export const awaitSubgraphIndexing = async (options) => {
23
23
  attempts++;
24
24
  try {
25
25
  const data = await fetchData(subgraphUrl, txHash);
26
- if (data && isSuccess(data)) {
26
+ if (data.value && isSuccess(data.value)) {
27
27
  clearInterval(checkInterval);
28
28
  let orderHash;
29
29
  // Extract orderHash from order data if it exists in the expected format
30
- if (Array.isArray(data) && data.length > 0 && data[0]?.order?.orderHash) {
31
- orderHash = data[0].order.orderHash;
30
+ if (Array.isArray(data.value) &&
31
+ data.value.length > 0 &&
32
+ data.value[0]?.order?.orderHash) {
33
+ orderHash = data.value[0].order.orderHash;
32
34
  }
33
35
  resolve({
34
36
  value: {
@@ -36,7 +38,7 @@ export const awaitSubgraphIndexing = async (options) => {
36
38
  successMessage,
37
39
  orderHash,
38
40
  network,
39
- data
41
+ data: data.value
40
42
  }
41
43
  });
42
44
  return;
@@ -1,6 +1,6 @@
1
1
  import type { Hex } from 'viem';
2
2
  import type { Config } from '@wagmi/core';
3
- import type { ApprovalCalldata, DepositCalldataResult, RemoveOrderCalldata, SgVault, WithdrawCalldataResult } from '@rainlanguage/orderbook';
3
+ import type { ApprovalCalldata, RemoveOrderCalldata, SgVault, VaultCalldataResult } from '@rainlanguage/orderbook';
4
4
  import type { DeploymentArgs } from '../types/transaction';
5
5
  export declare const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
6
6
  export declare const ONE: bigint;
@@ -39,8 +39,8 @@ export type DeploymentTransactionArgs = DeploymentArgsWithoutAccount & {
39
39
  };
40
40
  export type DepositOrWithdrawTransactionArgs = {
41
41
  config: Config;
42
- approvalCalldata?: ApprovalCalldata;
43
- transactionCalldata: DepositCalldataResult | WithdrawCalldataResult;
42
+ approvalCalldata?: VaultCalldataResult;
43
+ transactionCalldata: VaultCalldataResult;
44
44
  action: 'deposit' | 'withdraw';
45
45
  chainId: number;
46
46
  vault: SgVault;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainlanguage/ui-components",
3
- "version": "0.0.1-alpha.97",
3
+ "version": "0.0.1-alpha.99",
4
4
  "description": "A component library for building Svelte applications to be used with Raindex.",
5
5
  "license": "LicenseRef-DCL-1.0",
6
6
  "author": "Rain Open Source Software Ltd",
@@ -53,7 +53,7 @@
53
53
  "@fontsource/dm-sans": "5.1.0",
54
54
  "@imask/svelte": "7.6.1",
55
55
  "@observablehq/plot": "0.6.16",
56
- "@rainlanguage/orderbook": "0.0.1-alpha.97",
56
+ "@rainlanguage/orderbook": "0.0.1-alpha.99",
57
57
  "@reown/appkit": "1.6.4",
58
58
  "@reown/appkit-adapter-wagmi": "1.6.4",
59
59
  "@sentry/sveltekit": "7.120.0",