@rainlanguage/ui-components 0.0.1-alpha.238 → 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,7 +1,7 @@
|
|
|
1
|
-
import { get } from
|
|
2
|
-
import { isAddress, isAddressEqual } from
|
|
3
|
-
import { getAccountContext } from
|
|
4
|
-
import { readable } from
|
|
1
|
+
import { get } from "svelte/store";
|
|
2
|
+
import { isAddress, isAddressEqual } from "viem";
|
|
3
|
+
import { getAccountContext } from "./context";
|
|
4
|
+
import { readable } from "svelte/store";
|
|
5
5
|
/**
|
|
6
6
|
* Hook to access wallet account information from context
|
|
7
7
|
* Must be used within a component that is a child of WalletProvider
|
|
@@ -33,30 +33,30 @@ export function useAccount() {
|
|
|
33
33
|
};
|
|
34
34
|
return {
|
|
35
35
|
account,
|
|
36
|
-
matchesAccount
|
|
36
|
+
matchesAccount,
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
if (import.meta.vitest) {
|
|
40
40
|
const { describe, it, expect, vi, beforeEach } = import.meta.vitest;
|
|
41
|
-
vi.mock(
|
|
42
|
-
const actual = await vi.importActual(
|
|
41
|
+
vi.mock("viem", async () => {
|
|
42
|
+
const actual = await vi.importActual("viem");
|
|
43
43
|
return {
|
|
44
44
|
...actual,
|
|
45
45
|
isAddress: vi.fn(),
|
|
46
|
-
isAddressEqual: vi.fn()
|
|
46
|
+
isAddressEqual: vi.fn(),
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
|
-
vi.mock(
|
|
50
|
-
getAccountContext: vi.fn()
|
|
49
|
+
vi.mock("./context", () => ({
|
|
50
|
+
getAccountContext: vi.fn(),
|
|
51
51
|
}));
|
|
52
|
-
vi.mock(
|
|
53
|
-
const actual = await vi.importActual(
|
|
52
|
+
vi.mock("svelte/store", async () => {
|
|
53
|
+
const actual = await vi.importActual("svelte/store");
|
|
54
54
|
return {
|
|
55
55
|
...actual,
|
|
56
|
-
get: vi.fn()
|
|
56
|
+
get: vi.fn(),
|
|
57
57
|
};
|
|
58
58
|
});
|
|
59
|
-
describe(
|
|
59
|
+
describe("useAccount", () => {
|
|
60
60
|
const mockGetAccountContext = vi.mocked(getAccountContext);
|
|
61
61
|
const mockGet = vi.mocked(get);
|
|
62
62
|
const mockIsAddress = vi.mocked(isAddress);
|
|
@@ -64,24 +64,24 @@ if (import.meta.vitest) {
|
|
|
64
64
|
beforeEach(() => {
|
|
65
65
|
vi.clearAllMocks();
|
|
66
66
|
});
|
|
67
|
-
it(
|
|
68
|
-
const mockAccountStore = readable(
|
|
67
|
+
it("should return account wrapped in an object", () => {
|
|
68
|
+
const mockAccountStore = readable("0x123");
|
|
69
69
|
mockGetAccountContext.mockReturnValue(mockAccountStore);
|
|
70
70
|
const result = useAccount();
|
|
71
71
|
expect(mockGetAccountContext).toHaveBeenCalled();
|
|
72
72
|
expect(result.account).toBe(mockAccountStore);
|
|
73
73
|
expect(result.matchesAccount).toBeInstanceOf(Function);
|
|
74
74
|
});
|
|
75
|
-
describe(
|
|
76
|
-
const mockAccountStore = readable(
|
|
77
|
-
const currentAccount =
|
|
78
|
-
const testAddress1 =
|
|
79
|
-
const testAddress2 =
|
|
80
|
-
const invalidAddress =
|
|
75
|
+
describe("matchesAccount", () => {
|
|
76
|
+
const mockAccountStore = readable("0x123");
|
|
77
|
+
const currentAccount = "0x123";
|
|
78
|
+
const testAddress1 = "0x123";
|
|
79
|
+
const testAddress2 = "0xdef";
|
|
80
|
+
const invalidAddress = "invalid";
|
|
81
81
|
beforeEach(() => {
|
|
82
82
|
mockGetAccountContext.mockReturnValue(mockAccountStore);
|
|
83
83
|
});
|
|
84
|
-
it(
|
|
84
|
+
it("should return true if addresses are valid and equal", () => {
|
|
85
85
|
// Setup mocks
|
|
86
86
|
mockGet.mockReturnValue(currentAccount);
|
|
87
87
|
mockIsAddress.mockReturnValue(true);
|
|
@@ -94,7 +94,7 @@ if (import.meta.vitest) {
|
|
|
94
94
|
expect(mockIsAddressEqual).toHaveBeenCalledWith(currentAccount, testAddress1);
|
|
95
95
|
expect(result).toBe(true);
|
|
96
96
|
});
|
|
97
|
-
it(
|
|
97
|
+
it("should return false if addresses are valid but not equal", () => {
|
|
98
98
|
// Setup mocks
|
|
99
99
|
mockGet.mockReturnValue(currentAccount);
|
|
100
100
|
mockIsAddress.mockReturnValue(true);
|
|
@@ -107,7 +107,7 @@ if (import.meta.vitest) {
|
|
|
107
107
|
expect(mockIsAddressEqual).toHaveBeenCalledWith(currentAccount, testAddress2);
|
|
108
108
|
expect(result).toBe(false);
|
|
109
109
|
});
|
|
110
|
-
it(
|
|
110
|
+
it("should return false if current account is not set", () => {
|
|
111
111
|
// Setup mocks
|
|
112
112
|
mockGet.mockReturnValue(null);
|
|
113
113
|
const { matchesAccount } = useAccount();
|
|
@@ -117,7 +117,7 @@ if (import.meta.vitest) {
|
|
|
117
117
|
expect(mockIsAddressEqual).not.toHaveBeenCalled();
|
|
118
118
|
expect(result).toBe(false);
|
|
119
119
|
});
|
|
120
|
-
it(
|
|
120
|
+
it("should return false if provided address is invalid", () => {
|
|
121
121
|
// Setup mocks
|
|
122
122
|
mockGet.mockReturnValue(currentAccount);
|
|
123
123
|
// This is crucial: we need to ensure short-circuit evaluation works correctly
|
|
@@ -134,7 +134,7 @@ if (import.meta.vitest) {
|
|
|
134
134
|
expect(mockIsAddressEqual).not.toHaveBeenCalled(); // This should now pass
|
|
135
135
|
expect(result).toBe(false);
|
|
136
136
|
});
|
|
137
|
-
it(
|
|
137
|
+
it("should return false if provided address is null", () => {
|
|
138
138
|
// Setup mocks
|
|
139
139
|
mockGet.mockReturnValue(currentAccount);
|
|
140
140
|
const { matchesAccount } = useAccount();
|
package/dist/queries/keys.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export const QKEY_VAULTS =
|
|
2
|
-
export const QKEY_VAULT =
|
|
3
|
-
export const QKEY_VAULT_CHANGES =
|
|
4
|
-
export const QKEY_ORDERS =
|
|
5
|
-
export const QKEY_ORDER =
|
|
6
|
-
export const QKEY_ORDER_TRADES_LIST =
|
|
7
|
-
export const QKEY_ORDER_QUOTE =
|
|
8
|
-
export const QKEY_VAULTS_VOL_LIST =
|
|
9
|
-
export const QKEY_ORDER_APY =
|
|
10
|
-
export const QKEY_TOKENS =
|
|
1
|
+
export const QKEY_VAULTS = "vaults";
|
|
2
|
+
export const QKEY_VAULT = "vault";
|
|
3
|
+
export const QKEY_VAULT_CHANGES = "vaultBalanceChanges";
|
|
4
|
+
export const QKEY_ORDERS = "orders";
|
|
5
|
+
export const QKEY_ORDER = "order";
|
|
6
|
+
export const QKEY_ORDER_TRADES_LIST = "orderTradesList";
|
|
7
|
+
export const QKEY_ORDER_QUOTE = "orderQuote";
|
|
8
|
+
export const QKEY_VAULTS_VOL_LIST = "orderVaultsVolumeList";
|
|
9
|
+
export const QKEY_ORDER_APY = "orderApy";
|
|
10
|
+
export const QKEY_TOKENS = "tokens";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { browser } from
|
|
2
|
-
import { QueryClient } from
|
|
1
|
+
import { browser } from "$app/environment";
|
|
2
|
+
import { QueryClient } from "@tanstack/svelte-query";
|
|
3
3
|
export const queryClient = new QueryClient({
|
|
4
4
|
defaultOptions: {
|
|
5
5
|
queries: {
|
|
6
|
-
enabled: browser
|
|
7
|
-
}
|
|
8
|
-
}
|
|
6
|
+
enabled: browser,
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
9
|
});
|
|
10
10
|
export const invalidateTanstackQueries = async (queryClient, queryKey) => {
|
|
11
11
|
try {
|
|
12
12
|
await queryClient.invalidateQueries({
|
|
13
13
|
queryKey,
|
|
14
|
-
refetchType:
|
|
15
|
-
exact: false
|
|
14
|
+
refetchType: "all",
|
|
15
|
+
exact: false,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
catch {
|
|
19
|
-
throw new Error(
|
|
19
|
+
throw new Error("Failed to refresh data.");
|
|
20
20
|
}
|
|
21
21
|
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @module awaitTransactionIndexing
|
|
3
3
|
* @description Utilities for waiting for transactions to be indexed by a subgraph
|
|
4
4
|
*/
|
|
5
|
-
import type { WasmEncodedResult, RaindexTransaction, RaindexOrder, Address, Hex } from
|
|
5
|
+
import type { WasmEncodedResult, RaindexTransaction, RaindexOrder, Address, Hex } from "@rainlanguage/raindex";
|
|
6
6
|
export type AwaitSubgraphConfig = {
|
|
7
7
|
chainId: number;
|
|
8
|
-
|
|
8
|
+
raindex: Address;
|
|
9
9
|
txHash: Hex;
|
|
10
10
|
successMessage: string;
|
|
11
|
-
fetchEntityFn: (chainId: number,
|
|
11
|
+
fetchEntityFn: (chainId: number, raindex: Address, txHash: Hex) => Promise<WasmEncodedResult<RaindexTransaction | RaindexOrder[] | null | undefined>>;
|
|
12
12
|
isSuccess: (data: RaindexTransaction | RaindexOrder[]) => boolean;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
@@ -53,7 +53,7 @@ export type IndexingResult<T> = {
|
|
|
53
53
|
* @template T The type of data returned by the subgraph
|
|
54
54
|
* @param options Configuration options for the indexing operation
|
|
55
55
|
* @param options.chainId Chain ID to query
|
|
56
|
-
* @param options.
|
|
56
|
+
* @param options.raindex Raindex address to query
|
|
57
57
|
* @param options.txHash Transaction hash to check for indexing
|
|
58
58
|
* @param options.successMessage Message to display on successful indexing
|
|
59
59
|
* @param options.maxAttempts Maximum number of attempts before timing out (default: 10)
|
|
@@ -69,9 +69,9 @@ export declare const awaitSubgraphIndexing: <T>(options: {
|
|
|
69
69
|
*/
|
|
70
70
|
chainId: number;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Raindex address to query
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
raindex: Address;
|
|
75
75
|
/**
|
|
76
76
|
* Transaction hash to check for indexing
|
|
77
77
|
*/
|
|
@@ -95,10 +95,10 @@ export declare const awaitSubgraphIndexing: <T>(options: {
|
|
|
95
95
|
/**
|
|
96
96
|
* Function to fetch data from the subgraph
|
|
97
97
|
* @param chainId Chain ID to query
|
|
98
|
-
* @param
|
|
98
|
+
* @param raindex Raindex address to query
|
|
99
99
|
* @param txHash Transaction hash to query
|
|
100
100
|
*/
|
|
101
|
-
fetchEntityFn: (chainId: number,
|
|
101
|
+
fetchEntityFn: (chainId: number, raindex: Address, txHash: Hex) => Promise<WasmEncodedResult<T | null | undefined>>;
|
|
102
102
|
/**
|
|
103
103
|
* Function to determine if the fetched data indicates success
|
|
104
104
|
* @param data The data returned from the subgraph
|
|
@@ -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 { TransactionStoreErrorMessage } from
|
|
5
|
+
import { TransactionStoreErrorMessage } from "../types/transaction";
|
|
6
6
|
/**
|
|
7
7
|
* Generic function to handle waiting for subgraph indexing
|
|
8
8
|
* Returns a promise that resolves with an object containing either value or error
|
|
@@ -10,7 +10,7 @@ import { TransactionStoreErrorMessage } from '../types/transaction';
|
|
|
10
10
|
* @template T The type of data returned by the subgraph
|
|
11
11
|
* @param options Configuration options for the indexing operation
|
|
12
12
|
* @param options.chainId Chain ID to query
|
|
13
|
-
* @param options.
|
|
13
|
+
* @param options.raindex Raindex address to query
|
|
14
14
|
* @param options.txHash Transaction hash to check for indexing
|
|
15
15
|
* @param options.successMessage Message to display on successful indexing
|
|
16
16
|
* @param options.maxAttempts Maximum number of attempts before timing out (default: 10)
|
|
@@ -21,15 +21,17 @@ import { TransactionStoreErrorMessage } from '../types/transaction';
|
|
|
21
21
|
* @returns Promise resolving to an IndexingResult
|
|
22
22
|
*/
|
|
23
23
|
export const awaitSubgraphIndexing = async (options) => {
|
|
24
|
-
const { chainId,
|
|
24
|
+
const { chainId, raindex, txHash, successMessage, maxAttempts = 10, interval = 1000, network, fetchEntityFn, isSuccess, } = options;
|
|
25
25
|
const checkIndexing = async (attempt) => {
|
|
26
26
|
try {
|
|
27
|
-
const data = await fetchEntityFn(chainId,
|
|
27
|
+
const data = await fetchEntityFn(chainId, raindex, txHash);
|
|
28
28
|
if (data.value && isSuccess(data.value)) {
|
|
29
29
|
let newOrderHash;
|
|
30
30
|
// Extract orderHash from order data if it exists in the expected format
|
|
31
31
|
// This only applies to addOrder transactions
|
|
32
|
-
if (Array.isArray(data.value) &&
|
|
32
|
+
if (Array.isArray(data.value) &&
|
|
33
|
+
data.value.length > 0 &&
|
|
34
|
+
data.value[0]?.orderHash) {
|
|
33
35
|
newOrderHash = data.value[0].orderHash;
|
|
34
36
|
}
|
|
35
37
|
return {
|
|
@@ -38,8 +40,8 @@ export const awaitSubgraphIndexing = async (options) => {
|
|
|
38
40
|
successMessage,
|
|
39
41
|
orderHash: newOrderHash,
|
|
40
42
|
network,
|
|
41
|
-
data: data.value
|
|
42
|
-
}
|
|
43
|
+
data: data.value,
|
|
44
|
+
},
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
}
|
|
@@ -48,7 +50,7 @@ export const awaitSubgraphIndexing = async (options) => {
|
|
|
48
50
|
}
|
|
49
51
|
if (attempt >= maxAttempts) {
|
|
50
52
|
return {
|
|
51
|
-
error: TransactionStoreErrorMessage.SUBGRAPH_TIMEOUT_ERROR
|
|
53
|
+
error: TransactionStoreErrorMessage.SUBGRAPH_TIMEOUT_ERROR,
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as chains from
|
|
1
|
+
import * as chains from "viem/chains";
|
|
2
2
|
export const getExplorerLink = (hash, chainId, type) => {
|
|
3
3
|
const chain = Object.values(chains).find((chain) => chain.id === chainId);
|
|
4
4
|
if (chain?.blockExplorers) {
|
|
5
5
|
return chain.blockExplorers.default.url + `/${type}/${hash}`;
|
|
6
6
|
}
|
|
7
|
-
return
|
|
7
|
+
return "";
|
|
8
8
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RaindexOrderBuilder } from
|
|
1
|
+
import type { RaindexOrderBuilder } from "@rainlanguage/raindex";
|
|
2
2
|
export declare function handleShareChoices(builder: RaindexOrderBuilder, registryUrl: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { page } from
|
|
2
|
-
import { get } from
|
|
1
|
+
import { page } from "$app/stores";
|
|
2
|
+
import { get } from "svelte/store";
|
|
3
3
|
export async function handleShareChoices(builder, registryUrl) {
|
|
4
4
|
// get the current url
|
|
5
5
|
const url = get(page).url;
|
|
@@ -9,7 +9,7 @@ export async function handleShareChoices(builder, registryUrl) {
|
|
|
9
9
|
throw new Error(result.error.msg);
|
|
10
10
|
}
|
|
11
11
|
const state = result.value;
|
|
12
|
-
url.searchParams.set(
|
|
13
|
-
url.searchParams.set(
|
|
12
|
+
url.searchParams.set("state", state || "");
|
|
13
|
+
url.searchParams.set("registry", registryUrl);
|
|
14
14
|
navigator.clipboard.writeText(url.toString());
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RaindexTrade } from
|
|
2
|
-
import type { UTCTimestamp } from
|
|
1
|
+
import type { RaindexTrade } from "@rainlanguage/raindex";
|
|
2
|
+
import type { UTCTimestamp } from "lightweight-charts";
|
|
3
3
|
export type HistoricalOrderChartData = {
|
|
4
4
|
value: number;
|
|
5
5
|
time: UTCTimestamp;
|