@rainlanguage/ui-components 0.0.1-alpha.237 → 0.0.1-alpha.239
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.
- package/README.md +14 -6
- package/dist/__fixtures__/settings.yaml +18 -20
- package/dist/__mocks__/MockCodeMirrorEditor.svelte +17 -0
- package/dist/__mocks__/MockCodeMirrorEditor.svelte.d.ts +21 -0
- package/dist/__mocks__/MockComponent.js +1 -1
- package/dist/__mocks__/MockComponent.svelte +7 -3
- package/dist/__mocks__/MockComponent.svelte.d.ts +1 -0
- package/dist/__mocks__/mockWeb3Config.d.ts +1 -1
- package/dist/__mocks__/mockWeb3Config.js +10 -7
- package/dist/__mocks__/queries.js +9 -9
- package/dist/__mocks__/stores.d.ts +4 -4
- package/dist/__mocks__/stores.js +40 -40
- package/dist/app.css +3 -3
- package/dist/components/ButtonDarkMode.svelte +7 -1
- package/dist/components/ButtonScrub.svelte +22 -0
- package/dist/components/ButtonScrub.svelte.d.ts +25 -0
- package/dist/components/ButtonVaultLink.svelte +3 -2
- package/dist/components/ButtonVaultLink.svelte.d.ts +2 -2
- package/dist/components/CodeMirrorRainlang.svelte +19 -2
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +2 -1
- package/dist/components/Hash.svelte +3 -2
- package/dist/components/{ListViewOrderbookFilters.svelte → ListViewRaindexFilters.svelte} +7 -7
- package/dist/components/{ListViewOrderbookFilters.svelte.d.ts → ListViewRaindexFilters.svelte.d.ts} +7 -7
- package/dist/components/LocalDbStatusBadge.svelte.d.ts +1 -1
- package/dist/components/LocalDbStatusCard.svelte +7 -4
- package/dist/components/LocalDbStatusCard.svelte.d.ts +2 -2
- package/dist/components/LocalDbStatusModal.svelte +16 -14
- package/dist/components/LocalDbStatusModal.svelte.d.ts +2 -2
- package/dist/components/OrderOrVaultHash.svelte +2 -2
- package/dist/components/OrderOrVaultHash.svelte.d.ts +2 -2
- package/dist/components/Sensitive.svelte +16 -0
- package/dist/components/Sensitive.svelte.d.ts +28 -0
- package/dist/components/TanstackAppTable.svelte +146 -87
- package/dist/components/TanstackAppTable.svelte.d.ts +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte +1 -1
- package/dist/components/VaultBalanceChangeTypeFilter.svelte.d.ts +1 -1
- package/dist/components/VaultCard.svelte +1 -1
- package/dist/components/VaultCard.svelte.d.ts +1 -1
- package/dist/components/charts/OrderTradesChart.svelte +116 -97
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +2 -2
- package/dist/components/charts/transformAndSortData.d.ts +1 -1
- package/dist/components/charts/transformAndSortData.js +19 -19
- package/dist/components/deployment/DeploymentSteps.svelte +5 -2
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +1 -1
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +1 -1
- package/dist/components/deployment/DepositInput.svelte +1 -1
- package/dist/components/deployment/DepositInput.svelte.d.ts +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte +1 -1
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +1 -1
- package/dist/components/deployment/OrderPage.svelte.d.ts +1 -1
- package/dist/components/deployment/SelectToken.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenIOInput.svelte +1 -1
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +1 -1
- package/dist/components/deployment/TokenSelectionModal.svelte.d.ts +1 -1
- package/dist/components/detail/OrderDetail.svelte +12 -6
- package/dist/components/detail/OrderDetail.svelte.d.ts +2 -2
- package/dist/components/detail/TanstackOrderQuote.svelte +22 -0
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +1 -1
- package/dist/components/detail/VaultDetail.svelte +12 -10
- package/dist/components/detail/VaultDetail.svelte.d.ts +2 -2
- package/dist/components/dropdown/{DropdownOrderbooksFilter.svelte → DropdownRaindexesFilter.svelte} +54 -54
- package/dist/components/dropdown/DropdownRaindexesFilter.svelte.d.ts +25 -0
- package/dist/components/dropdown/DropdownTokensFilter.svelte.d.ts +1 -1
- package/dist/components/icon/Refresh.svelte +2 -1
- package/dist/components/icon/Refresh.svelte.d.ts +1 -0
- package/dist/components/input/InputTokenAmount.svelte +16 -1
- package/dist/components/input/InputTokenAmount.svelte.d.ts +1 -1
- package/dist/components/tables/OrderTradesListTable.svelte +113 -98
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte +1 -1
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +1 -1
- package/dist/components/tables/OrdersListTable.svelte +19 -17
- package/dist/components/tables/OrdersListTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte +1 -1
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +1 -1
- package/dist/components/tables/VaultsListTable.svelte +24 -21
- package/dist/components/tables/VaultsListTable.svelte.d.ts +2 -2
- package/dist/components/transactions/FixedBottomTransaction.svelte +1 -0
- package/dist/components/transactions/getStatusEmoji.d.ts +1 -1
- package/dist/components/transactions/getStatusEmoji.js +13 -13
- package/dist/consts.js +1 -1
- package/dist/errors/DeploymentStepsError.js +3 -3
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/hooks/useLocalDb.d.ts +1 -1
- package/dist/hooks/useLocalDb.js +3 -3
- package/dist/hooks/useRaindexClient.d.ts +1 -1
- package/dist/hooks/useRaindexClient.js +4 -4
- package/dist/hooks/useRaindexOrderBuilder.d.ts +1 -1
- package/dist/hooks/useRaindexOrderBuilder.js +4 -4
- package/dist/index.d.ts +122 -114
- package/dist/index.js +115 -109
- package/dist/models/Transaction.d.ts +4 -4
- package/dist/models/Transaction.js +9 -9
- package/dist/providers/RaindexClientProvider.svelte +1 -1
- package/dist/providers/RaindexClientProvider.svelte.d.ts +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte +1 -1
- package/dist/providers/RaindexOrderBuilderProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/DotrainRegistryProvider.svelte.d.ts +1 -1
- package/dist/providers/dotrainRegistry/context.d.ts +2 -2
- package/dist/providers/dotrainRegistry/context.js +13 -10
- package/dist/providers/dotrainRegistry/useDotrainRegistry.d.ts +1 -1
- package/dist/providers/dotrainRegistry/useDotrainRegistry.js +8 -8
- package/dist/providers/registry/RegistryManager.js +8 -7
- package/dist/providers/registry/context.d.ts +1 -1
- package/dist/providers/registry/context.js +9 -9
- package/dist/providers/registry/useRegistry.d.ts +1 -1
- package/dist/providers/registry/useRegistry.js +5 -5
- package/dist/providers/toasts/context.d.ts +2 -2
- package/dist/providers/toasts/context.js +4 -4
- package/dist/providers/toasts/useToasts.d.ts +1 -1
- package/dist/providers/toasts/useToasts.js +4 -4
- package/dist/providers/transactions/TransactionManager.d.ts +14 -15
- package/dist/providers/transactions/TransactionManager.js +107 -107
- package/dist/providers/transactions/context.d.ts +1 -1
- package/dist/providers/transactions/context.js +4 -4
- package/dist/providers/transactions/useTransactions.js +2 -2
- package/dist/providers/wallet/context.d.ts +1 -1
- package/dist/providers/wallet/context.js +11 -11
- package/dist/providers/wallet/useAccount.js +27 -27
- package/dist/queries/keys.js +10 -10
- package/dist/queries/queryClient.d.ts +1 -1
- package/dist/queries/queryClient.js +8 -8
- package/dist/services/awaitTransactionIndexing.d.ts +8 -8
- package/dist/services/awaitTransactionIndexing.js +10 -8
- package/dist/services/getExplorerLink.js +2 -2
- package/dist/services/handleShareChoices.d.ts +1 -1
- package/dist/services/handleShareChoices.js +4 -4
- package/dist/services/historicalOrderCharts.d.ts +2 -2
- package/dist/services/historicalOrderCharts.js +260 -201
- package/dist/services/index.d.ts +5 -3
- package/dist/services/index.js +3 -2
- package/dist/services/loadRegistryUrl.d.ts +1 -1
- package/dist/services/loadRegistryUrl.js +5 -5
- package/dist/services/pairTradesChartData.d.ts +2 -2
- package/dist/services/pairTradesChartData.js +28 -24
- package/dist/services/registry.d.ts +1 -1
- package/dist/services/registry.js +10 -10
- package/dist/services/time.d.ts +1 -1
- package/dist/services/time.js +35 -35
- package/dist/services/validateAmount.d.ts +30 -0
- package/dist/services/validateAmount.js +53 -0
- package/dist/storesGeneric/cachedWritableStore.d.ts +2 -2
- package/dist/storesGeneric/cachedWritableStore.js +3 -3
- package/dist/storesGeneric/scrub.d.ts +14 -0
- package/dist/storesGeneric/scrub.js +22 -0
- package/dist/test/matchers.d.ts +2 -2
- package/dist/test/matchers.js +2 -2
- package/dist/types/account.d.ts +2 -2
- package/dist/types/appStores.d.ts +3 -3
- package/dist/types/modal.d.ts +3 -3
- package/dist/types/order.d.ts +1 -1
- package/dist/types/toast.d.ts +2 -2
- package/dist/types/tokenBalance.d.ts +1 -1
- package/dist/types/transaction.d.ts +4 -4
- package/dist/utils/breadcrumbs.js +2 -2
- package/dist/utils/codeMirrorThemes.js +80 -74
- package/dist/utils/configHelpers.d.ts +1 -1
- package/dist/utils/configHelpers.js +6 -6
- package/dist/utils/constructHashLink.d.ts +3 -3
- package/dist/utils/constructHashLink.js +39 -37
- package/dist/utils/getNetworkName.js +5 -5
- package/dist/utils/hex.js +1 -1
- package/dist/utils/lightweightChartsThemes.d.ts +1 -1
- package/dist/utils/lightweightChartsThemes.js +11 -11
- package/dist/utils/localDbStatus.d.ts +26 -0
- package/dist/utils/localDbStatus.js +22 -0
- package/dist/utils/number.js +5 -3
- package/dist/utils/stripTrailingWhitespace.d.ts +16 -0
- package/dist/utils/stripTrailingWhitespace.js +22 -0
- package/dist/utils/tokens.d.ts +1 -1
- package/dist/utils/tokens.js +1 -1
- package/dist/utils/vaultBalanceChangeLabels.d.ts +1 -1
- package/dist/utils/vaultBalanceChangeLabels.js +11 -11
- package/package.json +89 -89
- package/dist/components/dropdown/DropdownOrderbooksFilter.svelte.d.ts +0 -25
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>import { setContext } from "svelte";
|
|
2
|
-
import { RaindexOrderBuilder } from "@rainlanguage/
|
|
2
|
+
import { RaindexOrderBuilder } from "@rainlanguage/raindex";
|
|
3
3
|
import { RAINDEX_ORDER_BUILDER_CONTEXT_KEY } from "../hooks/useRaindexOrderBuilder";
|
|
4
4
|
export let builder;
|
|
5
5
|
setContext(RAINDEX_ORDER_BUILDER_CONTEXT_KEY, builder);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { DotrainRegistry } from '@rainlanguage/
|
|
2
|
+
import type { DotrainRegistry } from '@rainlanguage/raindex';
|
|
3
3
|
import type { RegistryManager } from '../registry/RegistryManager';
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DotrainRegistry } from
|
|
2
|
-
import type { RegistryManager } from
|
|
1
|
+
import type { DotrainRegistry } from "@rainlanguage/raindex";
|
|
2
|
+
import type { RegistryManager } from "../registry/RegistryManager";
|
|
3
3
|
export type DotrainRegistryContext = {
|
|
4
4
|
registry: DotrainRegistry | null;
|
|
5
5
|
error?: string;
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { getContext, setContext } from
|
|
2
|
-
const DOTRAIN_REGISTRY_CONTEXT_KEY =
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const DOTRAIN_REGISTRY_CONTEXT_KEY = "dotrain-registry-context";
|
|
3
3
|
export const setDotrainRegistryContext = (context) => {
|
|
4
4
|
setContext(DOTRAIN_REGISTRY_CONTEXT_KEY, context);
|
|
5
5
|
};
|
|
6
6
|
export const getDotrainRegistryContext = () => {
|
|
7
7
|
const ctx = getContext(DOTRAIN_REGISTRY_CONTEXT_KEY);
|
|
8
8
|
if (!ctx) {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error("Dotrain registry context not found. Did you forget to wrap your app in DotrainRegistryProvider?");
|
|
10
10
|
}
|
|
11
11
|
return ctx;
|
|
12
12
|
};
|
|
13
13
|
if (import.meta.vitest) {
|
|
14
14
|
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
15
|
-
vi.mock(
|
|
15
|
+
vi.mock("svelte", async (importOriginal) => ({
|
|
16
16
|
...(await importOriginal()),
|
|
17
|
-
getContext: vi.fn()
|
|
17
|
+
getContext: vi.fn(),
|
|
18
18
|
}));
|
|
19
|
-
describe(
|
|
19
|
+
describe("getDotrainRegistryContext", () => {
|
|
20
20
|
const mockGetContext = vi.mocked(getContext);
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
mockGetContext.mockReset();
|
|
23
23
|
});
|
|
24
|
-
it(
|
|
25
|
-
const mockCtx = {
|
|
24
|
+
it("should return the context when it exists", () => {
|
|
25
|
+
const mockCtx = {
|
|
26
|
+
registry: null,
|
|
27
|
+
manager: {},
|
|
28
|
+
};
|
|
26
29
|
mockGetContext.mockImplementation((key) => {
|
|
27
30
|
if (key === DOTRAIN_REGISTRY_CONTEXT_KEY)
|
|
28
31
|
return mockCtx;
|
|
@@ -32,9 +35,9 @@ if (import.meta.vitest) {
|
|
|
32
35
|
expect(mockGetContext).toHaveBeenCalledWith(DOTRAIN_REGISTRY_CONTEXT_KEY);
|
|
33
36
|
expect(result).toEqual(mockCtx);
|
|
34
37
|
});
|
|
35
|
-
it(
|
|
38
|
+
it("should throw an error when context is not set", () => {
|
|
36
39
|
mockGetContext.mockReturnValue(undefined);
|
|
37
|
-
expect(() => getDotrainRegistryContext()).toThrow(
|
|
40
|
+
expect(() => getDotrainRegistryContext()).toThrow("Dotrain registry context not found. Did you forget to wrap your app in DotrainRegistryProvider?");
|
|
38
41
|
});
|
|
39
42
|
});
|
|
40
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getDotrainRegistryContext } from
|
|
1
|
+
import { getDotrainRegistryContext, } from "./context";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to access the current Dotrain registry context.
|
|
4
4
|
*/
|
|
@@ -7,24 +7,24 @@ export function useDotrainRegistry() {
|
|
|
7
7
|
}
|
|
8
8
|
if (import.meta.vitest) {
|
|
9
9
|
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
10
|
-
vi.mock(
|
|
11
|
-
getDotrainRegistryContext: vi.fn()
|
|
10
|
+
vi.mock("./context", () => ({
|
|
11
|
+
getDotrainRegistryContext: vi.fn(),
|
|
12
12
|
}));
|
|
13
|
-
describe(
|
|
13
|
+
describe("useDotrainRegistry", () => {
|
|
14
14
|
const mockGetContext = vi.mocked(getDotrainRegistryContext);
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
mockGetContext.mockReset();
|
|
17
17
|
});
|
|
18
|
-
it(
|
|
18
|
+
it("should return the registry context", () => {
|
|
19
19
|
const mockContext = {
|
|
20
20
|
registry: null,
|
|
21
21
|
manager: {
|
|
22
|
-
getCurrentRegistry: vi.fn().mockReturnValue(
|
|
22
|
+
getCurrentRegistry: vi.fn().mockReturnValue(""),
|
|
23
23
|
setRegistry: vi.fn(),
|
|
24
24
|
resetToDefault: vi.fn(),
|
|
25
25
|
updateUrlWithRegistry: vi.fn(),
|
|
26
|
-
isCustomRegistry: vi.fn().mockReturnValue(false)
|
|
27
|
-
}
|
|
26
|
+
isCustomRegistry: vi.fn().mockReturnValue(false),
|
|
27
|
+
},
|
|
28
28
|
};
|
|
29
29
|
mockGetContext.mockReturnValue(mockContext);
|
|
30
30
|
const result = useDotrainRegistry();
|
|
@@ -7,7 +7,7 @@ export class RegistryManager {
|
|
|
7
7
|
/** The currently selected registry URL */
|
|
8
8
|
currentRegistry;
|
|
9
9
|
/** Key used for localStorage and URL parameters */
|
|
10
|
-
static STORAGE_KEY =
|
|
10
|
+
static STORAGE_KEY = "registry";
|
|
11
11
|
/**
|
|
12
12
|
* Create a new RegistryManager
|
|
13
13
|
* @param defaultRegistry The default registry URL to use.
|
|
@@ -38,7 +38,7 @@ export class RegistryManager {
|
|
|
38
38
|
return new URL(window.location.href).searchParams.get(RegistryManager.STORAGE_KEY);
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error("Failed to get registry parameter: " +
|
|
42
42
|
(error instanceof Error ? error.message : String(error)));
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -52,7 +52,7 @@ export class RegistryManager {
|
|
|
52
52
|
localStorage.setItem(RegistryManager.STORAGE_KEY, registry);
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
55
|
-
throw new Error(
|
|
55
|
+
throw new Error("Failed to save to localStorage: " +
|
|
56
56
|
(error instanceof Error ? error.message : String(error)));
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -66,7 +66,8 @@ export class RegistryManager {
|
|
|
66
66
|
return localStorage.getItem(RegistryManager.STORAGE_KEY);
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
|
-
throw new Error(
|
|
69
|
+
throw new Error("Failed to access localStorage: " +
|
|
70
|
+
(error instanceof Error ? error.message : String(error)));
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
@@ -95,7 +96,7 @@ export class RegistryManager {
|
|
|
95
96
|
localStorage.removeItem(RegistryManager.STORAGE_KEY);
|
|
96
97
|
}
|
|
97
98
|
catch (error) {
|
|
98
|
-
throw new Error(
|
|
99
|
+
throw new Error("Failed to clear registry from localStorage: " +
|
|
99
100
|
(error instanceof Error ? error.message : String(error)));
|
|
100
101
|
}
|
|
101
102
|
this.updateUrlWithRegistry(null);
|
|
@@ -114,10 +115,10 @@ export class RegistryManager {
|
|
|
114
115
|
else {
|
|
115
116
|
url.searchParams.delete(RegistryManager.STORAGE_KEY);
|
|
116
117
|
}
|
|
117
|
-
window.history.pushState({},
|
|
118
|
+
window.history.pushState({}, "", url.toString());
|
|
118
119
|
}
|
|
119
120
|
catch (error) {
|
|
120
|
-
throw new Error(
|
|
121
|
+
throw new Error("Failed to update URL parameter: " +
|
|
121
122
|
(error instanceof Error ? error.message : String(error)));
|
|
122
123
|
}
|
|
123
124
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getContext, setContext } from
|
|
2
|
-
export const REGISTRY_KEY =
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
export const REGISTRY_KEY = "registry_key";
|
|
3
3
|
/**
|
|
4
4
|
* Retrieves the registry manager directly from Svelte's context
|
|
5
5
|
*/
|
|
6
6
|
export const getRegistryContext = () => {
|
|
7
7
|
const registry = getContext(REGISTRY_KEY);
|
|
8
8
|
if (!registry) {
|
|
9
|
-
throw new Error(
|
|
9
|
+
throw new Error("No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?");
|
|
10
10
|
}
|
|
11
11
|
return registry;
|
|
12
12
|
};
|
|
@@ -18,16 +18,16 @@ export const setRegistryContext = (registry) => {
|
|
|
18
18
|
};
|
|
19
19
|
if (import.meta.vitest) {
|
|
20
20
|
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
21
|
-
vi.mock(
|
|
21
|
+
vi.mock("svelte", async (importOriginal) => ({
|
|
22
22
|
...(await importOriginal()),
|
|
23
|
-
getContext: vi.fn()
|
|
23
|
+
getContext: vi.fn(),
|
|
24
24
|
}));
|
|
25
|
-
describe(
|
|
25
|
+
describe("getRegistryContext", () => {
|
|
26
26
|
const mockGetContext = vi.mocked(getContext);
|
|
27
27
|
beforeEach(() => {
|
|
28
28
|
mockGetContext.mockReset();
|
|
29
29
|
});
|
|
30
|
-
it(
|
|
30
|
+
it("should return the registry from context when it exists", () => {
|
|
31
31
|
const mockRegistry = {};
|
|
32
32
|
mockGetContext.mockImplementation((key) => {
|
|
33
33
|
if (key === REGISTRY_KEY)
|
|
@@ -38,9 +38,9 @@ if (import.meta.vitest) {
|
|
|
38
38
|
expect(mockGetContext).toHaveBeenCalledWith(REGISTRY_KEY);
|
|
39
39
|
expect(result).toEqual(mockRegistry);
|
|
40
40
|
});
|
|
41
|
-
it(
|
|
41
|
+
it("should throw an error when registry is not in context", () => {
|
|
42
42
|
mockGetContext.mockReturnValue(undefined);
|
|
43
|
-
expect(() => getRegistryContext()).toThrow(
|
|
43
|
+
expect(() => getRegistryContext()).toThrow("No registry manager was found in Svelte context. Did you forget to wrap your component with RegistryProvider?");
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRegistryContext } from
|
|
1
|
+
import { getRegistryContext } from "./context";
|
|
2
2
|
/**
|
|
3
3
|
* Hook to access registry manager information from context
|
|
4
4
|
* Must be used within a component that is a child of RegistryProvider
|
|
@@ -10,15 +10,15 @@ export function useRegistry() {
|
|
|
10
10
|
}
|
|
11
11
|
if (import.meta.vitest) {
|
|
12
12
|
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
13
|
-
vi.mock(
|
|
14
|
-
getRegistryContext: vi.fn()
|
|
13
|
+
vi.mock("./context", () => ({
|
|
14
|
+
getRegistryContext: vi.fn(),
|
|
15
15
|
}));
|
|
16
|
-
describe(
|
|
16
|
+
describe("useRegistry", () => {
|
|
17
17
|
const mockGetRegistryContext = vi.mocked(getRegistryContext);
|
|
18
18
|
beforeEach(() => {
|
|
19
19
|
mockGetRegistryContext.mockReset();
|
|
20
20
|
});
|
|
21
|
-
it(
|
|
21
|
+
it("should return registry", () => {
|
|
22
22
|
const mockRegistry = {};
|
|
23
23
|
mockGetRegistryContext.mockReturnValue(mockRegistry);
|
|
24
24
|
const result = useRegistry();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Writable } from
|
|
2
|
-
import type { ToastProps } from
|
|
1
|
+
import { type Writable } from "svelte/store";
|
|
2
|
+
import type { ToastProps } from "../../types/toast";
|
|
3
3
|
export declare const TOASTS_KEY = "rain:ui-components:toasts";
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the toasts store from Svelte's context
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getContext, setContext } from
|
|
2
|
-
import {} from
|
|
3
|
-
export const TOASTS_KEY =
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
import {} from "svelte/store";
|
|
3
|
+
export const TOASTS_KEY = "rain:ui-components:toasts";
|
|
4
4
|
/**
|
|
5
5
|
* Retrieves the toasts store from Svelte's context
|
|
6
6
|
*/
|
|
7
7
|
export function getToastsContext() {
|
|
8
8
|
const toasts = getContext(TOASTS_KEY);
|
|
9
9
|
if (!toasts) {
|
|
10
|
-
throw new Error(
|
|
10
|
+
throw new Error("No toasts context found. Did you forget to wrap your component with ToastProvider?");
|
|
11
11
|
}
|
|
12
12
|
return toasts;
|
|
13
13
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getToastsContext } from
|
|
1
|
+
import { getToastsContext } from "./context";
|
|
2
2
|
/**
|
|
3
3
|
* Hook for managing toast notifications in the application.
|
|
4
4
|
* Provides functionality to add, remove, and access toast notifications.
|
|
@@ -50,14 +50,14 @@ export function useToasts() {
|
|
|
50
50
|
addToast({
|
|
51
51
|
message,
|
|
52
52
|
detail,
|
|
53
|
-
type:
|
|
54
|
-
color:
|
|
53
|
+
type: "error",
|
|
54
|
+
color: "red",
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
return {
|
|
58
58
|
toasts,
|
|
59
59
|
addToast,
|
|
60
60
|
removeToast,
|
|
61
|
-
errToast
|
|
61
|
+
errToast,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type Readable } from
|
|
2
|
-
import type { QueryClient } from
|
|
3
|
-
import { type Transaction } from
|
|
4
|
-
import type { InternalTransactionArgs, IndexingContext } from
|
|
5
|
-
import type { Config } from
|
|
6
|
-
import type { ToastLink, ToastProps } from
|
|
7
|
-
import { type RaindexVault, type RaindexOrder, RaindexClient, type Address, Float, type WasmEncodedResult } from
|
|
1
|
+
import { type Readable } from "svelte/store";
|
|
2
|
+
import type { QueryClient } from "@tanstack/svelte-query";
|
|
3
|
+
import { type Transaction } from "../../models/Transaction";
|
|
4
|
+
import type { InternalTransactionArgs, IndexingContext } from "../../types/transaction";
|
|
5
|
+
import type { Config } from "@wagmi/core";
|
|
6
|
+
import type { ToastLink, ToastProps } from "../../types/toast";
|
|
7
|
+
import { type RaindexVault, type RaindexOrder, RaindexClient, type Address, Float, type WasmEncodedResult } from "@rainlanguage/raindex";
|
|
8
8
|
/**
|
|
9
9
|
* Function type for adding toast notifications to the UI.
|
|
10
10
|
* @param toast - The toast notification configuration object.
|
|
@@ -13,11 +13,10 @@ import { type RaindexVault, type RaindexOrder, RaindexClient, type Address, Floa
|
|
|
13
13
|
* @param toast.color - The color theme of the toast.
|
|
14
14
|
* @param toast.links - Optional array of links to display in the toast.
|
|
15
15
|
*/
|
|
16
|
-
export type AddToastFunction = (toast: Omit<ToastProps,
|
|
16
|
+
export type AddToastFunction = (toast: Omit<ToastProps, "id">) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Creates an indexing function that wraps SDK-based polling logic.
|
|
19
|
-
* The SDK handles
|
|
20
|
-
* so we only need to call it once.
|
|
19
|
+
* The SDK handles the retry loop internally, so we only need to call it once.
|
|
21
20
|
*
|
|
22
21
|
* @param options Configuration for SDK-based indexing
|
|
23
22
|
* @param options.call Function that calls the SDK method (e.g. getAddOrdersForTransaction)
|
|
@@ -52,7 +51,7 @@ export declare class TransactionManager {
|
|
|
52
51
|
*/
|
|
53
52
|
constructor(queryClient: QueryClient, addToast: AddToastFunction, wagmiConfig: Config);
|
|
54
53
|
/**
|
|
55
|
-
* Creates and initializes a new transaction for removing an order from the
|
|
54
|
+
* Creates and initializes a new transaction for removing an order from the raindex.
|
|
56
55
|
* @param args - Configuration for the remove order transaction.
|
|
57
56
|
* @param args.txHash - Hash of the transaction to track.
|
|
58
57
|
* @param args.chainId - Chain ID where the transaction is being executed.
|
|
@@ -94,12 +93,12 @@ export declare class TransactionManager {
|
|
|
94
93
|
/**
|
|
95
94
|
* Creates a multicall withdrawal transaction.
|
|
96
95
|
*
|
|
97
|
-
* Precondition: all provided vaults must share the same
|
|
96
|
+
* Precondition: all provided vaults must share the same raindex.
|
|
98
97
|
* This is enforced upstream in handleVaultsWithdrawAll.ts:
|
|
99
|
-
* if (vaults.some(v => v.
|
|
98
|
+
* if (vaults.some(v => v.raindex !== vaults[0].raindex)) { … }
|
|
100
99
|
*
|
|
101
100
|
* @param args.chainId the target chain ID
|
|
102
|
-
* @param args.vaults list of RaindexVault instances (must share
|
|
101
|
+
* @param args.vaults list of RaindexVault instances (must share a raindex)
|
|
103
102
|
* @param args.txHash the transaction hash to wrap
|
|
104
103
|
* @param args.queryKey cache key for invalidation
|
|
105
104
|
* @param args.raindexClient Raindex API client * @example
|
|
@@ -181,7 +180,7 @@ export declare class TransactionManager {
|
|
|
181
180
|
* });
|
|
182
181
|
*/
|
|
183
182
|
createAddOrderTransaction(args: InternalTransactionArgs & {
|
|
184
|
-
|
|
183
|
+
raindex: Address;
|
|
185
184
|
raindexClient: RaindexClient;
|
|
186
185
|
}): Promise<Transaction>;
|
|
187
186
|
/**
|