@rainlanguage/ui-components 0.0.1-alpha.150 → 0.0.1-alpha.151

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.
@@ -1,10 +1,6 @@
1
- import type { AccountCfg, NewConfig } from '@rainlanguage/orderbook';
2
1
  import { type Config } from '@wagmi/core';
3
2
  declare const initialPageState: {
4
3
  data: {
5
- stores: {
6
- settings: {};
7
- };
8
4
  dotrain: string;
9
5
  deployment: {
10
6
  key: string;
@@ -20,14 +16,6 @@ declare const initialPageState: {
20
16
  id: null;
21
17
  };
22
18
  };
23
- export declare const mockSettingsStore: {
24
- subscribe: (this: void, run: import("svelte/store").Subscriber<NewConfig>, invalidate?: import("svelte/store").Invalidator<NewConfig> | undefined) => import("svelte/store").Unsubscriber;
25
- set: (this: void, value: NewConfig) => void;
26
- mockSetSubscribeValue: (value: NewConfig) => void;
27
- };
28
- export declare const mockAccountsStore: {
29
- subscribe: (this: void, run: import("svelte/store").Subscriber<Record<string, AccountCfg>>, invalidate?: import("svelte/store").Invalidator<Record<string, AccountCfg>> | undefined) => import("svelte/store").Unsubscriber;
30
- };
31
19
  export declare const mockActiveAccountsItemsStore: {
32
20
  subscribe: (this: void, run: import("svelte/store").Subscriber<Record<string, string>>, invalidate?: import("svelte/store").Invalidator<Record<string, string>> | undefined) => import("svelte/store").Unsubscriber;
33
21
  set: (this: void, value: Record<string, string>) => void;
@@ -98,9 +86,6 @@ export declare const mockSelectedChainIdsStore: {
98
86
  export declare const mockPageStore: {
99
87
  subscribe: (this: void, run: import("svelte/store").Subscriber<{
100
88
  data: {
101
- stores: {
102
- settings: {};
103
- };
104
89
  dotrain: string;
105
90
  deployment: {
106
91
  key: string;
@@ -117,9 +102,6 @@ export declare const mockPageStore: {
117
102
  };
118
103
  }>, invalidate?: import("svelte/store").Invalidator<{
119
104
  data: {
120
- stores: {
121
- settings: {};
122
- };
123
105
  dotrain: string;
124
106
  deployment: {
125
107
  key: string;
@@ -137,9 +119,6 @@ export declare const mockPageStore: {
137
119
  }> | undefined) => import("svelte/store").Unsubscriber;
138
120
  set: (this: void, value: {
139
121
  data: {
140
- stores: {
141
- settings: {};
142
- };
143
122
  dotrain: string;
144
123
  deployment: {
145
124
  key: string;
@@ -1,6 +1,4 @@
1
- import { parseYaml } from '@rainlanguage/orderbook';
2
1
  import { writable } from 'svelte/store';
3
- import settingsYamlContent from '../__fixtures__/settings.yaml?raw';
4
2
  import {} from '@wagmi/core';
5
3
  import { mockWeb3Config } from './mockWeb3Config';
6
4
  if (import.meta.vitest) {
@@ -11,15 +9,8 @@ if (import.meta.vitest) {
11
9
  };
12
10
  });
13
11
  }
14
- // Parse the YAML settings
15
- const parseResult = parseYaml([settingsYamlContent]);
16
- if (parseResult.error) {
17
- throw new Error(`Failed to parse settings YAML: ${parseResult.error.readableMsg}`);
18
- }
19
- const settingsFixture = parseResult.value;
20
12
  const initialPageState = {
21
13
  data: {
22
- stores: { settings: {} },
23
14
  dotrain: 'some dotrain content',
24
15
  deployment: { key: 'deploy-key' },
25
16
  orderDetail: {}
@@ -34,8 +25,6 @@ const initialPageState = {
34
25
  }
35
26
  };
36
27
  const mockPageWritable = writable(initialPageState);
37
- const mockSettingsWritable = writable(settingsFixture);
38
- const mockAccountsWritable = writable({});
39
28
  const mockActiveAccountsItemsWritable = writable({});
40
29
  const mockShowInactiveOrdersWritable = writable(true);
41
30
  const mockOrderHashWritable = writable('');
@@ -49,14 +38,6 @@ const mockConnectedWritable = writable(true);
49
38
  const mockWagmiConfigWritable = writable(mockWeb3Config);
50
39
  const mockShowMyItemsOnlyWritable = writable(false);
51
40
  const mockSelectedChainIdsWritable = writable([]);
52
- export const mockSettingsStore = {
53
- subscribe: mockSettingsWritable.subscribe,
54
- set: mockSettingsWritable.set,
55
- mockSetSubscribeValue: (value) => mockSettingsWritable.set(value)
56
- };
57
- export const mockAccountsStore = {
58
- subscribe: mockAccountsWritable.subscribe
59
- };
60
41
  export const mockActiveAccountsItemsStore = {
61
42
  subscribe: mockActiveAccountsItemsWritable.subscribe,
62
43
  set: mockActiveAccountsItemsWritable.set,
@@ -1,4 +1,5 @@
1
- <script generics="T">import DropdownActiveNetworks from "./dropdown/DropdownActiveNetworks.svelte";
1
+ <script generics="T">import { useRaindexClient } from "../hooks/useRaindexClient";
2
+ import DropdownActiveNetworks from "./dropdown/DropdownActiveNetworks.svelte";
2
3
  import { page } from "$app/stores";
3
4
  import { isEmpty } from "lodash";
4
5
  import { Alert } from "flowbite-svelte";
@@ -10,8 +11,6 @@ import InputOrderHash from "./input/InputOrderHash.svelte";
10
11
  import CheckboxZeroBalanceVault from "./CheckboxZeroBalanceVault.svelte";
11
12
  import CheckboxMyItemsOnly from "./CheckboxMyItemsOnly.svelte";
12
13
  import { useAccount } from "../providers/wallet/useAccount";
13
- export let settings;
14
- export let accounts;
15
14
  export let hideZeroBalanceVaults;
16
15
  export let activeAccountsItems;
17
16
  export let showMyItemsOnly;
@@ -24,18 +23,21 @@ export let tokensQuery;
24
23
  $: isVaultsPage = $page.url.pathname === "/vaults";
25
24
  $: isOrdersPage = $page.url.pathname === "/orders";
26
25
  const { account } = useAccount();
26
+ const raindexClient = useRaindexClient();
27
+ $: networks = raindexClient.getAllNetworks();
28
+ $: accounts = raindexClient.getAllAccounts();
27
29
  </script>
28
30
 
29
31
  <div
30
32
  class="grid w-full items-center gap-4 md:flex md:justify-end lg:min-w-[600px]"
31
33
  style="grid-template-columns: repeat(2, minmax(0, 1fr));"
32
34
  >
33
- {#if isEmpty($settings.orderbook.networks)}
35
+ {#if networks.error || isEmpty(networks.value)}
34
36
  <Alert color="gray" data-testid="no-networks-alert" class="w-full">
35
37
  No networks added to <a class="underline" href="/settings">settings</a>
36
38
  </Alert>
37
39
  {:else}
38
- {#if $accounts && !Object.values($accounts).length}
40
+ {#if !accounts.error && accounts.value.size === 0}
39
41
  <div class="mt-4 w-full lg:w-auto" data-testid="my-items-only">
40
42
  <CheckboxMyItemsOnly context={isVaultsPage ? 'vaults' : 'orders'} {showMyItemsOnly} />
41
43
  {#if !$account}
@@ -55,10 +57,10 @@ const { account } = useAccount();
55
57
  <CheckboxActiveOrders {showInactiveOrders} />
56
58
  </div>
57
59
  {/if}
58
- {#if $accounts && Object.values($accounts).length > 0}
59
- <DropdownOrderListAccounts {accounts} {activeAccountsItems} />
60
+ {#if !accounts.error && accounts.value.size > 0}
61
+ <DropdownOrderListAccounts {activeAccountsItems} />
60
62
  {/if}
61
63
  <DropdownTokensFilter {tokensQuery} {activeTokens} {selectedTokens} label="Tokens" />
62
- <DropdownActiveNetworks settings={$settings} {selectedChainIds} />
64
+ <DropdownActiveNetworks {selectedChainIds} />
63
65
  {/if}
64
66
  </div>
@@ -5,8 +5,6 @@ import type { Address, RaindexVaultToken } from '@rainlanguage/orderbook';
5
5
  import type { AppStoresInterface } from '../types/appStores';
6
6
  declare class __sveltets_Render<T> {
7
7
  props(): {
8
- settings: AppStoresInterface["settings"];
9
- accounts: AppStoresInterface["accounts"];
10
8
  hideZeroBalanceVaults: AppStoresInterface["hideZeroBalanceVaults"];
11
9
  activeAccountsItems: AppStoresInterface["activeAccountsItems"];
12
10
  showMyItemsOnly: AppStoresInterface["showMyItemsOnly"];
@@ -37,7 +37,7 @@ export let lightweightChartsTheme;
37
37
  export let orderbookAddress;
38
38
  export let orderHash;
39
39
  export let chainId;
40
- export let rpcUrls = void 0;
40
+ export let rpcs = void 0;
41
41
  export let onRemove;
42
42
  export let onDeposit;
43
43
  export let onWithdraw;
@@ -194,7 +194,7 @@ const handleRefresh = async () => {
194
194
  </div>
195
195
  </TabItem>
196
196
  <TabItem open title="Trades">
197
- <OrderTradesListTable order={data} {handleDebugTradeModal} {rpcUrls} />
197
+ <OrderTradesListTable order={data} {handleDebugTradeModal} {rpcs} />
198
198
  </TabItem>
199
199
  <TabItem title="Volume">
200
200
  <OrderVaultsVolTable order={data} />
@@ -11,7 +11,7 @@ declare const __propDef: {
11
11
  orderbookAddress: Address;
12
12
  orderHash: Hex;
13
13
  chainId: number;
14
- rpcUrls?: string[] | undefined;
14
+ rpcs?: string[] | undefined;
15
15
  /** Callback function when remove action is triggered for an order
16
16
  * @param order The order to remove
17
17
  */ onRemove: (raindexClient: RaindexClient, order: RaindexOrder) => void;
@@ -1,48 +1,40 @@
1
1
  <script>import DropdownCheckbox from "./DropdownCheckbox.svelte";
2
2
  import { getNetworkName } from "../../utils/getNetworkName";
3
- export let settings;
3
+ import { useRaindexClient } from "../../hooks/useRaindexClient";
4
+ const raindexClient = useRaindexClient();
4
5
  export let selectedChainIds;
5
- $: dropdownOptions = Object.keys(settings.orderbook.networks ?? {}).reduce((acc, key) => {
6
- const networkCfg = (settings.orderbook.networks ?? {})[key];
7
- const networkName = getNetworkName(Number(networkCfg.chainId)) ?? key;
8
- const existingKey = Object.keys(acc).find((existingKey2) => {
9
- const existingNetworkCfg = (settings.orderbook.networks ?? {})[existingKey2];
10
- return existingNetworkCfg.chainId === networkCfg.chainId;
11
- });
12
- if (!existingKey) {
13
- return {
14
- ...acc,
15
- [key]: networkName
16
- };
6
+ let dropdownOptions = {};
7
+ $: {
8
+ const uniqueChainIds = raindexClient.getUniqueChainIds();
9
+ if (uniqueChainIds.error) {
10
+ dropdownOptions = {};
11
+ } else {
12
+ dropdownOptions = Object.fromEntries(
13
+ uniqueChainIds.value.map((chainId) => [
14
+ String(chainId),
15
+ getNetworkName(chainId) ?? `Chain ${chainId}`
16
+ ])
17
+ );
17
18
  }
18
- return acc;
19
- }, {});
19
+ }
20
20
  function handleStatusChange(event) {
21
- let items = Object.keys(event.detail);
22
- const chainIds = Array.from(
23
- new Set(
24
- Object.values(items).map((key) => {
25
- const networkCfg = (settings.orderbook.networks ?? {})[key];
26
- return networkCfg.chainId;
27
- })
28
- )
29
- );
21
+ const chainIds = Object.keys(event.detail).map(Number);
30
22
  selectedChainIds.set(chainIds);
31
23
  }
32
- $: value = $selectedChainIds.reduce(
33
- (acc, chainId) => {
34
- const networkKey = Object.keys(settings.orderbook.networks ?? {}).find((key) => {
35
- const networkCfg = (settings.orderbook.networks ?? {})[key];
36
- return networkCfg.chainId === chainId;
37
- });
38
- if (networkKey) {
39
- const networkName = getNetworkName(chainId) ?? networkKey;
40
- acc[networkKey] = networkName;
41
- }
42
- return acc;
43
- },
44
- {}
45
- );
24
+ let value = {};
25
+ $: {
26
+ const networks = raindexClient.getAllNetworks();
27
+ if (networks.error) {
28
+ value = {};
29
+ } else {
30
+ value = Object.fromEntries(
31
+ $selectedChainIds.map((chainId) => [
32
+ String(chainId),
33
+ getNetworkName(chainId) ?? `Chain ${chainId}`
34
+ ])
35
+ );
36
+ }
37
+ }
46
38
  </script>
47
39
 
48
40
  <div data-testid="subgraphs-dropdown">
@@ -1,9 +1,7 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type { NewConfig } from '@rainlanguage/orderbook';
3
2
  import type { AppStoresInterface } from '../../types/appStores';
4
3
  declare const __propDef: {
5
4
  props: {
6
- settings: NewConfig;
7
5
  selectedChainIds: AppStoresInterface["selectedChainIds"];
8
6
  };
9
7
  events: {
@@ -1,8 +1,10 @@
1
1
  <script>import DropdownCheckbox from "./DropdownCheckbox.svelte";
2
2
  import { getAccountsAsOptions } from "../../utils/configHelpers";
3
- export let accounts;
3
+ import { useRaindexClient } from "../../hooks/useRaindexClient";
4
4
  export let activeAccountsItems;
5
- $: options = getAccountsAsOptions($accounts);
5
+ const raindexClient = useRaindexClient();
6
+ $: accounts = raindexClient.getAllAccounts();
7
+ $: options = getAccountsAsOptions(accounts.value);
6
8
  </script>
7
9
 
8
10
  <div data-testid="accounts-dropdown">
@@ -2,7 +2,6 @@ import { SvelteComponent } from "svelte";
2
2
  import type { AppStoresInterface } from '../../types/appStores';
3
3
  declare const __propDef: {
4
4
  props: {
5
- accounts: AppStoresInterface["accounts"];
6
5
  activeAccountsItems: AppStoresInterface["activeAccountsItems"];
7
6
  };
8
7
  events: {
@@ -8,7 +8,7 @@ import Hash, { HashType } from "../Hash.svelte";
8
8
  import { BugOutline } from "flowbite-svelte-icons";
9
9
  import TableTimeFilters from "../charts/TableTimeFilters.svelte";
10
10
  export let order;
11
- export let rpcUrls = void 0;
11
+ export let rpcs = void 0;
12
12
  export let handleDebugTradeModal = void 0;
13
13
  let startTimestamp;
14
14
  let endTimestamp;
@@ -98,13 +98,13 @@ $: orderTradesQuery = createInfiniteQuery({
98
98
  )})
99
99
  </span>
100
100
  </TableBodyCell>
101
- {#if rpcUrls && handleDebugTradeModal}
101
+ {#if rpcs && handleDebugTradeModal}
102
102
  <TableBodyCell tdClass="py-2">
103
103
  <button
104
104
  data-testid="debug-trade-button"
105
105
  class="text-gray-500 hover:text-gray-700"
106
106
  on:click={() => {
107
- if (rpcUrls) handleDebugTradeModal(item.transaction.id, rpcUrls);
107
+ if (rpcs) handleDebugTradeModal(item.transaction.id, rpcs);
108
108
  }}
109
109
  >
110
110
  <BugOutline size="xs" />
@@ -3,8 +3,8 @@ import type { RaindexOrder } from '@rainlanguage/orderbook';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  order: RaindexOrder;
6
- rpcUrls?: string[] | undefined;
7
- handleDebugTradeModal?: ((hash: string, rpcUrls: string[]) => void) | undefined;
6
+ rpcs?: string[] | undefined;
7
+ handleDebugTradeModal?: ((hash: string, rpcs: string[]) => void) | undefined;
8
8
  };
9
9
  events: {
10
10
  [evt: string]: CustomEvent<any>;
@@ -19,10 +19,10 @@ import {
19
19
  } from "flowbite-svelte";
20
20
  import { useAccount } from "../../providers/wallet/useAccount";
21
21
  import { useRaindexClient } from "../../hooks/useRaindexClient";
22
+ import { getAllContexts } from "svelte";
23
+ const context = getAllContexts();
22
24
  export let handleOrderRemoveModal = void 0;
23
- export let settings;
24
25
  export let selectedChainIds;
25
- export let accounts;
26
26
  export let activeAccountsItems;
27
27
  export let showInactiveOrders;
28
28
  export let orderHash;
@@ -48,7 +48,6 @@ $: query = createInfiniteQuery({
48
48
  queryKey: [
49
49
  QKEY_ORDERS,
50
50
  $selectedChainIds,
51
- $settings,
52
51
  owners,
53
52
  $showInactiveOrders,
54
53
  $orderHash,
@@ -80,8 +79,6 @@ const AppTable = TanstackAppTable;
80
79
 
81
80
  <ListViewOrderbookFilters
82
81
  {selectedChainIds}
83
- {settings}
84
- {accounts}
85
82
  {activeAccountsItems}
86
83
  {showMyItemsOnly}
87
84
  {showInactiveOrders}
@@ -178,7 +175,7 @@ const AppTable = TanstackAppTable;
178
175
  <DropdownItem
179
176
  on:click={(e) => {
180
177
  e.stopPropagation();
181
- handleOrderRemoveModal(item, $query.refetch);
178
+ handleOrderRemoveModal(item, $query.refetch, context);
182
179
  }}>Remove</DropdownItem
183
180
  >
184
181
  </Dropdown>
@@ -3,9 +3,7 @@ import type { AppStoresInterface } from '../../types/appStores';
3
3
  declare class __sveltets_Render<T> {
4
4
  props(): {
5
5
  handleOrderRemoveModal?: any;
6
- settings: AppStoresInterface["settings"];
7
6
  selectedChainIds: AppStoresInterface["selectedChainIds"];
8
- accounts: AppStoresInterface["accounts"];
9
7
  activeAccountsItems: AppStoresInterface["activeAccountsItems"] | undefined;
10
8
  showInactiveOrders: AppStoresInterface["showInactiveOrders"];
11
9
  orderHash: AppStoresInterface["orderHash"];
@@ -13,10 +13,10 @@ import { RaindexVault } from "@rainlanguage/orderbook";
13
13
  import { QKEY_TOKENS, QKEY_VAULTS } from "../../queries/keys";
14
14
  import { useAccount } from "../../providers/wallet/useAccount";
15
15
  import { getNetworkName } from "../../utils/getNetworkName";
16
- export let accounts;
16
+ import { getAllContexts } from "svelte";
17
+ const context = getAllContexts();
17
18
  export let activeAccountsItems;
18
19
  export let orderHash;
19
- export let settings;
20
20
  export let showInactiveOrders;
21
21
  export let hideZeroBalanceVaults;
22
22
  export let activeTokens;
@@ -40,14 +40,7 @@ $: selectedTokens = $activeTokens?.filter(
40
40
  (address) => !$tokensQuery.data || $tokensQuery.data.some((t) => t.address === address)
41
41
  ) ?? [];
42
42
  $: query = createInfiniteQuery({
43
- queryKey: [
44
- QKEY_VAULTS,
45
- $hideZeroBalanceVaults,
46
- $selectedChainIds,
47
- $settings,
48
- owners,
49
- selectedTokens
50
- ],
43
+ queryKey: [QKEY_VAULTS, $hideZeroBalanceVaults, $selectedChainIds, owners, selectedTokens],
51
44
  queryFn: async ({ pageParam }) => {
52
45
  const result = await raindexClient.getVaults(
53
46
  $selectedChainIds,
@@ -74,8 +67,6 @@ const AppTable = TanstackAppTable;
74
67
  {#if $query}
75
68
  <ListViewOrderbookFilters
76
69
  {selectedChainIds}
77
- {settings}
78
- {accounts}
79
70
  {activeAccountsItems}
80
71
  {showMyItemsOnly}
81
72
  {showInactiveOrders}
@@ -186,7 +177,7 @@ const AppTable = TanstackAppTable;
186
177
  data-testid="deposit-button"
187
178
  on:click={(e) => {
188
179
  e.stopPropagation();
189
- handleDepositModal(item, $query.refetch);
180
+ handleDepositModal(item, $query.refetch, context);
190
181
  }}
191
182
  >Deposit
192
183
  </DropdownItem>
@@ -194,7 +185,7 @@ const AppTable = TanstackAppTable;
194
185
  data-testid="withdraw-button"
195
186
  on:click={(e) => {
196
187
  e.stopPropagation();
197
- handleWithdrawModal(item, $query.refetch);
188
+ handleWithdrawModal(item, $query.refetch, context);
198
189
  }}
199
190
  >Withdraw
200
191
  </DropdownItem>
@@ -1,19 +1,18 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import { RaindexVault } from '@rainlanguage/orderbook';
3
3
  import type { AppStoresInterface } from '../../types/appStores.ts';
4
+ import { getAllContexts } from 'svelte';
4
5
  declare class __sveltets_Render<T> {
5
6
  props(): {
6
- accounts: AppStoresInterface["accounts"];
7
7
  activeAccountsItems: AppStoresInterface["activeAccountsItems"];
8
8
  orderHash: AppStoresInterface["orderHash"];
9
- settings: AppStoresInterface["settings"];
10
9
  showInactiveOrders: AppStoresInterface["showInactiveOrders"];
11
10
  hideZeroBalanceVaults: AppStoresInterface["hideZeroBalanceVaults"];
12
11
  activeTokens: AppStoresInterface["activeTokens"];
13
12
  selectedChainIds: AppStoresInterface["selectedChainIds"];
14
13
  showMyItemsOnly: AppStoresInterface["showMyItemsOnly"];
15
- handleDepositModal?: ((vault: RaindexVault, refetch: () => void) => void) | undefined;
16
- handleWithdrawModal?: ((vault: RaindexVault, refetch: () => void) => void) | undefined;
14
+ handleDepositModal?: ((vault: RaindexVault, refetch: () => void, context: ReturnType<typeof getAllContexts>) => void) | undefined;
15
+ handleWithdrawModal?: ((vault: RaindexVault, refetch: () => void, context: ReturnType<typeof getAllContexts>) => void) | undefined;
17
16
  };
18
17
  events(): {} & {
19
18
  [evt: string]: CustomEvent<any>;
package/dist/index.d.ts CHANGED
@@ -93,6 +93,7 @@ export { default as RegistryProvider } from './providers/registry/RegistryProvid
93
93
  export { default as ToastProvider } from './providers/toasts/ToastProvider.svelte';
94
94
  export { default as TransactionProvider } from './providers/transactions/TransactionProvider.svelte';
95
95
  export { useGui } from './hooks/useGui';
96
+ export { useRaindexClient, RAINDEX_CLIENT_CONTEXT_KEY } from './hooks/useRaindexClient';
96
97
  export { useAccount } from './providers/wallet/useAccount';
97
98
  export { useRegistry } from './providers/registry/useRegistry';
98
99
  export { useToasts } from './providers/toasts/useToasts';
@@ -101,5 +102,3 @@ export { RegistryManager } from './providers/registry/RegistryManager';
101
102
  export { TransactionStore } from './models/Transaction';
102
103
  export { TransactionManager } from './providers/transactions/TransactionManager';
103
104
  export { mockPageStore } from './__mocks__/stores';
104
- export { mockConfig } from './__mocks__/settings';
105
- export { mockSettingsStore } from './__mocks__/settings';
package/dist/index.js CHANGED
@@ -95,6 +95,7 @@ export { default as ToastProvider } from './providers/toasts/ToastProvider.svelt
95
95
  export { default as TransactionProvider } from './providers/transactions/TransactionProvider.svelte';
96
96
  // Hooks
97
97
  export { useGui } from './hooks/useGui';
98
+ export { useRaindexClient, RAINDEX_CLIENT_CONTEXT_KEY } from './hooks/useRaindexClient';
98
99
  export { useAccount } from './providers/wallet/useAccount';
99
100
  export { useRegistry } from './providers/registry/useRegistry';
100
101
  export { useToasts } from './providers/toasts/useToasts';
@@ -105,5 +106,3 @@ export { TransactionStore } from './models/Transaction';
105
106
  export { TransactionManager } from './providers/transactions/TransactionManager';
106
107
  // Mocks
107
108
  export { mockPageStore } from './__mocks__/stores';
108
- export { mockConfig } from './__mocks__/settings';
109
- export { mockSettingsStore } from './__mocks__/settings';
@@ -1,7 +1,6 @@
1
1
  import type { Readable, Writable } from 'svelte/store';
2
- import type { AccountCfg, Address, Hex, NewConfig } from '@rainlanguage/orderbook';
2
+ import type { AccountCfg, Address, Hex } from '@rainlanguage/orderbook';
3
3
  export interface AppStoresInterface {
4
- settings: Writable<NewConfig>;
5
4
  selectedChainIds: Writable<number[]>;
6
5
  accounts: Readable<Record<string, AccountCfg>>;
7
6
  activeAccountsItems: Writable<Record<string, Address>> | undefined;
@@ -1,4 +1,4 @@
1
1
  import type { AccountCfg } from '@rainlanguage/orderbook';
2
- export declare function getAccountsAsOptions(accounts: Record<string, AccountCfg>): {
2
+ export declare function getAccountsAsOptions(accounts?: Map<string, AccountCfg>): {
3
3
  [k: string]: string;
4
4
  };
@@ -1,14 +1,16 @@
1
1
  export function getAccountsAsOptions(accounts) {
2
- return Object.fromEntries(Object.entries(accounts).map(([key, value]) => [key, value.address]));
2
+ if (!accounts)
3
+ return {};
4
+ return Object.fromEntries(Array.from(accounts.entries()).map(([key, value]) => [key, value.address]));
3
5
  }
4
6
  if (import.meta.vitest) {
5
7
  const { expect, it, describe } = import.meta.vitest;
6
8
  describe('getAccountsAsOptions', () => {
7
9
  it('should return the correct accounts as options', () => {
8
- const accounts = {
9
- account1: { address: '0x1234567890abcdef', key: 'account1' },
10
- account2: { address: '0xabcdef1234567890', key: 'account2' }
11
- };
10
+ const accounts = new Map([
11
+ ['account1', { address: '0x1234567890abcdef', key: 'account1' }],
12
+ ['account2', { address: '0xabcdef1234567890', key: 'account2' }]
13
+ ]);
12
14
  const result = getAccountsAsOptions(accounts);
13
15
  expect(result).toEqual({
14
16
  account1: '0x1234567890abcdef',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainlanguage/ui-components",
3
- "version": "0.0.1-alpha.150",
3
+ "version": "0.0.1-alpha.151",
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.150",
56
+ "@rainlanguage/orderbook": "0.0.1-alpha.151",
57
57
  "@reown/appkit": "1.6.4",
58
58
  "@reown/appkit-adapter-wagmi": "1.6.4",
59
59
  "@sentry/sveltekit": "7.120.0",
@@ -1,7 +0,0 @@
1
- import type { NewConfig } from '@rainlanguage/orderbook';
2
- export declare const mockConfig: NewConfig;
3
- export declare const mockSettingsStore: {
4
- subscribe: (this: void, run: import("svelte/store").Subscriber<NewConfig>, invalidate?: import("svelte/store").Invalidator<NewConfig> | undefined) => import("svelte/store").Unsubscriber;
5
- set: (this: void, value: NewConfig) => void;
6
- mockSetSubscribeValue: (value: NewConfig) => void;
7
- };
@@ -1,72 +0,0 @@
1
- import { writable } from 'svelte/store';
2
- export const mockConfig = {
3
- orderbook: {
4
- networks: {
5
- mainnet: {
6
- key: 'mainnet',
7
- rpcs: ['https://mainnet.infura.io/v3/YOUR-PROJECT-ID'],
8
- chainId: 1,
9
- label: 'Ethereum Mainnet',
10
- currency: 'ETH'
11
- }
12
- },
13
- subgraphs: {
14
- mainnet: {
15
- key: 'mainnet',
16
- url: 'https://api.thegraph.com/subgraphs/name/mainnet'
17
- },
18
- flare: {
19
- key: 'flare',
20
- url: 'https://api.thegraph.com/subgraphs/name/flare'
21
- },
22
- testnet: {
23
- key: 'testnet',
24
- url: 'https://api.thegraph.com/subgraphs/name/testnet'
25
- }
26
- },
27
- orderbooks: {
28
- orderbook1: {
29
- key: 'orderbook1',
30
- address: '0xOrderbookAddress1',
31
- network: {
32
- key: 'mainnet',
33
- rpc: 'https://mainnet.infura.io/v3/YOUR-PROJECT-ID',
34
- chainId: 1,
35
- label: 'Ethereum Mainnet',
36
- currency: 'ETH'
37
- },
38
- subgraph: {
39
- key: 'uniswap',
40
- url: 'https://api.thegraph.com/subgraphs/name/uniswap'
41
- },
42
- label: 'Orderbook 1'
43
- }
44
- },
45
- deployers: {
46
- deployer1: {
47
- key: 'deployer1',
48
- address: '0xDeployerAddress1',
49
- network: {
50
- key: 'mainnet',
51
- rpc: 'https://mainnet.infura.io/v3/YOUR-PROJECT-ID',
52
- chainId: 1,
53
- label: 'Ethereum Mainnet',
54
- currency: 'ETH'
55
- }
56
- }
57
- },
58
- metaboards: {
59
- metaboard1: 'https://example.com/metaboard1'
60
- },
61
- accounts: {
62
- name_one: 'address_one',
63
- name_two: 'address_two'
64
- }
65
- }
66
- };
67
- const mockSettingsStoreWritable = writable(mockConfig);
68
- export const mockSettingsStore = {
69
- subscribe: mockSettingsStoreWritable.subscribe,
70
- set: mockSettingsStoreWritable.set,
71
- mockSetSubscribeValue: (value) => mockSettingsStoreWritable.set(value)
72
- };