@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,9 +1,9 @@
|
|
|
1
1
|
export function generateBreadcrumbs(path) {
|
|
2
|
-
const crumbs = path.split(
|
|
2
|
+
const crumbs = path.split("/");
|
|
3
3
|
return crumbs
|
|
4
4
|
.map((c, i) => ({
|
|
5
5
|
label: c,
|
|
6
|
-
href: crumbs.slice(0, i + 1).join(
|
|
6
|
+
href: crumbs.slice(0, i + 1).join("/"),
|
|
7
7
|
}))
|
|
8
8
|
.slice(1, -1);
|
|
9
9
|
}
|
|
@@ -1,86 +1,92 @@
|
|
|
1
|
-
import { createTheme } from
|
|
2
|
-
import { tags } from
|
|
1
|
+
import { createTheme } from "thememirror";
|
|
2
|
+
import { tags } from "@lezer/highlight";
|
|
3
3
|
// configured to resemble vscode default light theme
|
|
4
4
|
export const lightCodeMirrorTheme = createTheme({
|
|
5
|
-
variant:
|
|
5
|
+
variant: "light",
|
|
6
6
|
settings: {
|
|
7
|
-
background:
|
|
8
|
-
foreground:
|
|
9
|
-
caret:
|
|
10
|
-
selection:
|
|
11
|
-
lineHighlight:
|
|
12
|
-
gutterBackground:
|
|
13
|
-
gutterForeground:
|
|
7
|
+
background: "#ffffff",
|
|
8
|
+
foreground: "#001080",
|
|
9
|
+
caret: "#000000",
|
|
10
|
+
selection: "#add6ff",
|
|
11
|
+
lineHighlight: "#77777740",
|
|
12
|
+
gutterBackground: "#eeeeee",
|
|
13
|
+
gutterForeground: "#237893",
|
|
14
14
|
},
|
|
15
15
|
styles: [
|
|
16
|
-
{ tag: tags.comment, color:
|
|
17
|
-
{ tag: tags.variableName, color:
|
|
18
|
-
{ tag: [tags.string, tags.special(tags.brace)], color:
|
|
19
|
-
{ tag: tags.number, color:
|
|
20
|
-
{ tag: tags.bool, color:
|
|
21
|
-
{ tag: tags.null, color:
|
|
22
|
-
{ tag: tags.unit, color:
|
|
23
|
-
{ tag: tags.keyword, color:
|
|
24
|
-
{ tag: tags.operator, color:
|
|
25
|
-
{ tag: tags.className, color:
|
|
26
|
-
{ tag: tags.meta, color:
|
|
27
|
-
{ tag: tags.definition(tags.typeName), color:
|
|
28
|
-
{ tag: tags.angleBracket, color:
|
|
29
|
-
{ tag: tags.brace, color:
|
|
30
|
-
{ tag: tags.bracket, color:
|
|
31
|
-
{ tag: tags.squareBracket, color:
|
|
32
|
-
{ tag: tags.paren, color:
|
|
33
|
-
{ tag: tags.punctuation, color:
|
|
34
|
-
{ tag: tags.separator, color:
|
|
35
|
-
{ tag: tags.typeName, color:
|
|
36
|
-
{ tag: tags.tagName, color:
|
|
37
|
-
{ tag: tags.attributeName, color:
|
|
38
|
-
{ tag: tags.attributeValue, color:
|
|
39
|
-
{ tag: tags.content, color:
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
{ tag: tags.comment, color: "#008001" },
|
|
17
|
+
{ tag: tags.variableName, color: "#0070c1" },
|
|
18
|
+
{ tag: [tags.string, tags.special(tags.brace)], color: "#b55b00" },
|
|
19
|
+
{ tag: tags.number, color: "#00b97b" },
|
|
20
|
+
{ tag: tags.bool, color: "#0000ff" },
|
|
21
|
+
{ tag: tags.null, color: "#0000ff" },
|
|
22
|
+
{ tag: tags.unit, color: "#0000ff" },
|
|
23
|
+
{ tag: tags.keyword, color: "#af01db" },
|
|
24
|
+
{ tag: tags.operator, color: "#000000" },
|
|
25
|
+
{ tag: tags.className, color: "#257f99" },
|
|
26
|
+
{ tag: tags.meta, color: "#0950a9" },
|
|
27
|
+
{ tag: tags.definition(tags.typeName), color: "#257f99" },
|
|
28
|
+
{ tag: tags.angleBracket, color: "#213CF1" },
|
|
29
|
+
{ tag: tags.brace, color: "#213CF1" },
|
|
30
|
+
{ tag: tags.bracket, color: "#213CF1" },
|
|
31
|
+
{ tag: tags.squareBracket, color: "#213CF1" },
|
|
32
|
+
{ tag: tags.paren, color: "#213CF1" },
|
|
33
|
+
{ tag: tags.punctuation, color: "#464646" },
|
|
34
|
+
{ tag: tags.separator, color: "#464646" },
|
|
35
|
+
{ tag: tags.typeName, color: "#257f99" },
|
|
36
|
+
{ tag: tags.tagName, color: "#800000" },
|
|
37
|
+
{ tag: tags.attributeName, color: "#eb3d36" },
|
|
38
|
+
{ tag: tags.attributeValue, color: "#444444" },
|
|
39
|
+
{ tag: tags.content, color: "#b55b00" },
|
|
40
|
+
{
|
|
41
|
+
tag: [tags.propertyName, tags.definition(tags.propertyName)],
|
|
42
|
+
color: "#0469ff",
|
|
43
|
+
},
|
|
44
|
+
{ tag: tags.labelName, color: "#4fc4ff" },
|
|
45
|
+
{ tag: tags.deleted, color: "#cc0000" },
|
|
46
|
+
],
|
|
44
47
|
});
|
|
45
48
|
// configured to resemble vscode default dark theme
|
|
46
49
|
export const darkCodeMirrorTheme = createTheme({
|
|
47
|
-
variant:
|
|
50
|
+
variant: "dark",
|
|
48
51
|
settings: {
|
|
49
|
-
background:
|
|
50
|
-
foreground:
|
|
51
|
-
caret:
|
|
52
|
-
selection:
|
|
53
|
-
lineHighlight:
|
|
54
|
-
gutterBackground:
|
|
55
|
-
gutterForeground:
|
|
52
|
+
background: "#1e1e1e",
|
|
53
|
+
foreground: "#d4d4d4",
|
|
54
|
+
caret: "#d4d4d4",
|
|
55
|
+
selection: "#ffffff",
|
|
56
|
+
lineHighlight: "#99999940",
|
|
57
|
+
gutterBackground: "#282828",
|
|
58
|
+
gutterForeground: "#858585",
|
|
56
59
|
},
|
|
57
60
|
styles: [
|
|
58
|
-
{ tag: [tags.comment, tags.lineComment], color:
|
|
59
|
-
{ tag: tags.variableName, color:
|
|
60
|
-
{ tag: [tags.string, tags.special(tags.brace)], color:
|
|
61
|
-
{ tag: tags.number, color:
|
|
62
|
-
{ tag: tags.bool, color:
|
|
63
|
-
{ tag: tags.null, color:
|
|
64
|
-
{ tag: tags.unit, color:
|
|
65
|
-
{ tag: tags.keyword, color:
|
|
66
|
-
{ tag: tags.operator, color:
|
|
67
|
-
{ tag: tags.className, color:
|
|
68
|
-
{ tag: tags.meta, color:
|
|
69
|
-
{ tag: tags.definition(tags.typeName), color:
|
|
70
|
-
{ tag: tags.angleBracket, color:
|
|
71
|
-
{ tag: tags.brace, color:
|
|
72
|
-
{ tag: tags.bracket, color:
|
|
73
|
-
{ tag: tags.squareBracket, color:
|
|
74
|
-
{ tag: tags.paren, color:
|
|
75
|
-
{ tag: tags.punctuation, color:
|
|
76
|
-
{ tag: tags.separator, color:
|
|
77
|
-
{ tag: tags.typeName, color:
|
|
78
|
-
{ tag: tags.tagName, color:
|
|
79
|
-
{ tag: tags.attributeName, color:
|
|
80
|
-
{ tag: tags.attributeValue, color:
|
|
81
|
-
{ tag: tags.content, color:
|
|
82
|
-
{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
61
|
+
{ tag: [tags.comment, tags.lineComment], color: "#6c9e57" },
|
|
62
|
+
{ tag: tags.variableName, color: "#9cdcfe" },
|
|
63
|
+
{ tag: [tags.string, tags.special(tags.brace)], color: "#ce9178" },
|
|
64
|
+
{ tag: tags.number, color: "#B6CFA9" },
|
|
65
|
+
{ tag: tags.bool, color: "#4fc4ff" },
|
|
66
|
+
{ tag: tags.null, color: "#4fc4ff" },
|
|
67
|
+
{ tag: tags.unit, color: "#608FC2" },
|
|
68
|
+
{ tag: tags.keyword, color: "#d18dcc" },
|
|
69
|
+
{ tag: tags.operator, color: "#d4d4d4" },
|
|
70
|
+
{ tag: tags.className, color: "#4dcab1" },
|
|
71
|
+
{ tag: tags.meta, color: "#608FC2" },
|
|
72
|
+
{ tag: tags.definition(tags.typeName), color: "#4fcfb5" },
|
|
73
|
+
{ tag: tags.angleBracket, color: "#F9D849" },
|
|
74
|
+
{ tag: tags.brace, color: "#F9D849" },
|
|
75
|
+
{ tag: tags.bracket, color: "#F9D849" },
|
|
76
|
+
{ tag: tags.squareBracket, color: "#F9D849" },
|
|
77
|
+
{ tag: tags.paren, color: "#F9D849" },
|
|
78
|
+
{ tag: tags.punctuation, color: "#d4d4d4" },
|
|
79
|
+
{ tag: tags.separator, color: "#d4d4d4" },
|
|
80
|
+
{ tag: tags.typeName, color: "#4ecdb4" },
|
|
81
|
+
{ tag: tags.tagName, color: "#59a3df" },
|
|
82
|
+
{ tag: tags.attributeName, color: "#ffffff" },
|
|
83
|
+
{ tag: tags.attributeValue, color: "#ffffff" },
|
|
84
|
+
{ tag: tags.content, color: "#ce9178" },
|
|
85
|
+
{
|
|
86
|
+
tag: [tags.propertyName, tags.definition(tags.propertyName)],
|
|
87
|
+
color: "#608FC2",
|
|
88
|
+
},
|
|
89
|
+
{ tag: tags.labelName, color: "#4fc4ff" },
|
|
90
|
+
{ tag: tags.deleted, color: "#c86464" },
|
|
91
|
+
],
|
|
86
92
|
});
|
|
@@ -5,16 +5,16 @@ export function getAccountsAsOptions(accounts) {
|
|
|
5
5
|
}
|
|
6
6
|
if (import.meta.vitest) {
|
|
7
7
|
const { expect, it, describe } = import.meta.vitest;
|
|
8
|
-
describe(
|
|
9
|
-
it(
|
|
8
|
+
describe("getAccountsAsOptions", () => {
|
|
9
|
+
it("should return the correct accounts as options", () => {
|
|
10
10
|
const accounts = new Map([
|
|
11
|
-
[
|
|
12
|
-
[
|
|
11
|
+
["account1", { address: "0x1234567890abcdef", key: "account1" }],
|
|
12
|
+
["account2", { address: "0xabcdef1234567890", key: "account2" }],
|
|
13
13
|
]);
|
|
14
14
|
const result = getAccountsAsOptions(accounts);
|
|
15
15
|
expect(result).toEqual({
|
|
16
|
-
account1:
|
|
17
|
-
account2:
|
|
16
|
+
account1: "0x1234567890abcdef",
|
|
17
|
+
account2: "0xabcdef1234567890",
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { Address, RaindexOrder, RaindexOrderAsIO, RaindexVault } from
|
|
1
|
+
import type { Address, RaindexOrder, RaindexOrderAsIO, RaindexVault } from "@rainlanguage/raindex";
|
|
2
2
|
type OrderOrVault = RaindexOrder | RaindexOrderAsIO | RaindexVault;
|
|
3
3
|
/**
|
|
4
4
|
* Constructs a link path for an order or vault based on its type and network
|
|
5
5
|
* @param orderOrVault - The order or vault object
|
|
6
6
|
* @param type - The type of resource ('orders' or 'vaults')
|
|
7
7
|
* @param chainId - The chain id
|
|
8
|
-
* @param
|
|
8
|
+
* @param raindexAddress - The raindex address
|
|
9
9
|
* @returns The constructed link path
|
|
10
10
|
*/
|
|
11
|
-
export declare function constructHashLink(orderOrVault: OrderOrVault, type:
|
|
11
|
+
export declare function constructHashLink(orderOrVault: OrderOrVault, type: "orders" | "vaults", chainId: number, raindexAddress: Address): string;
|
|
12
12
|
/**
|
|
13
13
|
* Determines if an order or vault is active
|
|
14
14
|
* @param orderOrVault - The order or vault object
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import fc from
|
|
2
|
-
import { test } from
|
|
1
|
+
import fc from "fast-check";
|
|
2
|
+
import { test } from "@fast-check/vitest";
|
|
3
3
|
function isOrder(obj) {
|
|
4
|
-
return obj &&
|
|
4
|
+
return obj && "orderHash" in obj;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
7
|
* Constructs a link path for an order or vault based on its type and network
|
|
8
8
|
* @param orderOrVault - The order or vault object
|
|
9
9
|
* @param type - The type of resource ('orders' or 'vaults')
|
|
10
10
|
* @param chainId - The chain id
|
|
11
|
-
* @param
|
|
11
|
+
* @param raindexAddress - The raindex address
|
|
12
12
|
* @returns The constructed link path
|
|
13
13
|
*/
|
|
14
|
-
export function constructHashLink(orderOrVault, type, chainId,
|
|
14
|
+
export function constructHashLink(orderOrVault, type, chainId, raindexAddress) {
|
|
15
15
|
if (!orderOrVault) {
|
|
16
16
|
return `/${type}`;
|
|
17
17
|
}
|
|
18
|
-
const slug = isOrder(orderOrVault)
|
|
19
|
-
|
|
18
|
+
const slug = isOrder(orderOrVault)
|
|
19
|
+
? orderOrVault.orderHash
|
|
20
|
+
: orderOrVault.id;
|
|
21
|
+
return `/${type}/${chainId}-${raindexAddress}-${slug}`;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Determines if an order or vault is active
|
|
@@ -36,80 +38,80 @@ export function extractHash(orderOrVault) {
|
|
|
36
38
|
const _isOrder = isOrder(orderOrVault);
|
|
37
39
|
return _isOrder
|
|
38
40
|
? orderOrVault.orderHash
|
|
39
|
-
: orderOrVault?.id ||
|
|
41
|
+
: orderOrVault?.id || "";
|
|
40
42
|
}
|
|
41
43
|
if (import.meta.vitest) {
|
|
42
44
|
const { expect, it, describe } = import.meta.vitest;
|
|
43
|
-
describe(
|
|
45
|
+
describe("constructHashLink", () => {
|
|
44
46
|
test.prop([
|
|
45
47
|
fc.record({
|
|
46
48
|
orderHash: fc.string(),
|
|
47
|
-
active: fc.boolean()
|
|
49
|
+
active: fc.boolean(),
|
|
48
50
|
}),
|
|
49
|
-
fc.oneof(fc.constant(
|
|
51
|
+
fc.oneof(fc.constant("orders"), fc.constant("vaults")),
|
|
50
52
|
fc.integer(),
|
|
51
|
-
fc.string()
|
|
52
|
-
])(
|
|
53
|
-
const result = constructHashLink(order, type, chainId,
|
|
54
|
-
expect(result).toBe(`/${type}/${chainId}-${
|
|
53
|
+
fc.string(),
|
|
54
|
+
])("constructs correct link for orders", (order, type, chainId, raindexAddress) => {
|
|
55
|
+
const result = constructHashLink(order, type, chainId, raindexAddress);
|
|
56
|
+
expect(result).toBe(`/${type}/${chainId}-${raindexAddress}-${order.orderHash}`);
|
|
55
57
|
});
|
|
56
58
|
test.prop([
|
|
57
59
|
fc.record({
|
|
58
60
|
id: fc.string(),
|
|
59
|
-
owner: fc.string()
|
|
61
|
+
owner: fc.string(),
|
|
60
62
|
}),
|
|
61
|
-
fc.oneof(fc.constant(
|
|
63
|
+
fc.oneof(fc.constant("orders"), fc.constant("vaults")),
|
|
62
64
|
fc.integer(),
|
|
63
|
-
fc.string()
|
|
64
|
-
])(
|
|
65
|
-
const result = constructHashLink(vault, type, chainId,
|
|
66
|
-
expect(result).toBe(`/${type}/${chainId}-${
|
|
65
|
+
fc.string(),
|
|
66
|
+
])("constructs correct link for vaults", (vault, type, chainId, raindexAddress) => {
|
|
67
|
+
const result = constructHashLink(vault, type, chainId, raindexAddress);
|
|
68
|
+
expect(result).toBe(`/${type}/${chainId}-${raindexAddress}-${vault.id}`);
|
|
67
69
|
});
|
|
68
70
|
});
|
|
69
|
-
describe(
|
|
71
|
+
describe("isOrderOrVaultActive", () => {
|
|
70
72
|
test.prop([
|
|
71
73
|
fc.record({
|
|
72
74
|
orderHash: fc.string(),
|
|
73
|
-
active: fc.boolean()
|
|
74
|
-
})
|
|
75
|
-
])(
|
|
75
|
+
active: fc.boolean(),
|
|
76
|
+
}),
|
|
77
|
+
])("returns correct active status for orders", (order) => {
|
|
76
78
|
const result = isOrderOrVaultActive(order);
|
|
77
79
|
expect(result).toBe(order.active);
|
|
78
80
|
});
|
|
79
81
|
test.prop([
|
|
80
82
|
fc.record({
|
|
81
83
|
id: fc.string(),
|
|
82
|
-
owner: fc.string()
|
|
83
|
-
})
|
|
84
|
-
])(
|
|
84
|
+
owner: fc.string(),
|
|
85
|
+
}),
|
|
86
|
+
])("returns false for vaults", (vault) => {
|
|
85
87
|
const result = isOrderOrVaultActive(vault);
|
|
86
88
|
expect(result).toBe(false);
|
|
87
89
|
});
|
|
88
90
|
});
|
|
89
|
-
describe(
|
|
91
|
+
describe("extractHash", () => {
|
|
90
92
|
test.prop([
|
|
91
93
|
fc.record({
|
|
92
94
|
orderHash: fc.string(),
|
|
93
|
-
active: fc.boolean()
|
|
94
|
-
})
|
|
95
|
-
])(
|
|
95
|
+
active: fc.boolean(),
|
|
96
|
+
}),
|
|
97
|
+
])("extracts hash from orders", (order) => {
|
|
96
98
|
const result = extractHash(order);
|
|
97
99
|
expect(result).toBe(order.orderHash);
|
|
98
100
|
});
|
|
99
101
|
test.prop([
|
|
100
102
|
fc.record({
|
|
101
103
|
id: fc.string(),
|
|
102
|
-
owner: fc.string()
|
|
103
|
-
})
|
|
104
|
-
])(
|
|
104
|
+
owner: fc.string(),
|
|
105
|
+
}),
|
|
106
|
+
])("extracts hash from vaults", (vault) => {
|
|
105
107
|
const result = extractHash(vault);
|
|
106
108
|
expect(result).toBe(vault.id);
|
|
107
109
|
});
|
|
108
|
-
it(
|
|
110
|
+
it("handles undefined vault id", () => {
|
|
109
111
|
// Create a partial vault object with undefined id
|
|
110
112
|
const vault = { id: undefined };
|
|
111
113
|
const result = extractHash(vault);
|
|
112
|
-
expect(result).toBe(
|
|
114
|
+
expect(result).toBe("");
|
|
113
115
|
});
|
|
114
116
|
});
|
|
115
117
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import * as chains from
|
|
1
|
+
import * as chains from "viem/chains";
|
|
2
2
|
export function getNetworkName(chainId) {
|
|
3
3
|
const chain = Object.values(chains).find((chain) => chain.id === chainId);
|
|
4
4
|
return chain?.name;
|
|
5
5
|
}
|
|
6
6
|
if (import.meta.vitest) {
|
|
7
|
-
describe(
|
|
8
|
-
it(
|
|
9
|
-
expect(getNetworkName(1)).toBe(
|
|
10
|
-
expect(getNetworkName(137)).toBe(
|
|
7
|
+
describe("getNetworkName", () => {
|
|
8
|
+
it("should return the network name for a given chain id", () => {
|
|
9
|
+
expect(getNetworkName(1)).toBe("Ethereum");
|
|
10
|
+
expect(getNetworkName(137)).toBe("Polygon");
|
|
11
11
|
});
|
|
12
12
|
});
|
|
13
13
|
}
|
package/dist/utils/hex.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { ColorType } from
|
|
1
|
+
import { ColorType } from "lightweight-charts";
|
|
2
2
|
export const darkChartTheme = {
|
|
3
3
|
layout: {
|
|
4
|
-
textColor:
|
|
5
|
-
background: { type: ColorType.Solid, color:
|
|
4
|
+
textColor: "white",
|
|
5
|
+
background: { type: ColorType.Solid, color: "transparent" },
|
|
6
6
|
},
|
|
7
7
|
grid: {
|
|
8
|
-
vertLines: { color:
|
|
9
|
-
horzLines: { color:
|
|
10
|
-
}
|
|
8
|
+
vertLines: { color: "#484848" },
|
|
9
|
+
horzLines: { color: "#484848" },
|
|
10
|
+
},
|
|
11
11
|
};
|
|
12
12
|
export const lightChartTheme = {
|
|
13
13
|
layout: {
|
|
14
|
-
textColor:
|
|
15
|
-
background: { type: ColorType.Solid, color:
|
|
14
|
+
textColor: "black",
|
|
15
|
+
background: { type: ColorType.Solid, color: "transparent" },
|
|
16
16
|
},
|
|
17
17
|
grid: {
|
|
18
|
-
vertLines: { color:
|
|
19
|
-
horzLines: { color:
|
|
20
|
-
}
|
|
18
|
+
vertLines: { color: "#ECECEC" },
|
|
19
|
+
horzLines: { color: "#ECECEC" },
|
|
20
|
+
},
|
|
21
21
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LocalDbStatus } from "@rainlanguage/raindex";
|
|
2
|
+
/**
|
|
3
|
+
* The minimal shape required to aggregate a top-level localdb status: anything
|
|
4
|
+
* carrying a per-chain/per-raindex {@link LocalDbStatus} and an optional error
|
|
5
|
+
* message (e.g. `NetworkSyncStatus` or `RaindexSyncStatus`).
|
|
6
|
+
*/
|
|
7
|
+
export interface AggregableSyncStatus {
|
|
8
|
+
status: LocalDbStatus;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Collapses many per-chain / per-raindex sync statuses into the single
|
|
13
|
+
* top-level localdb status shown in the sidebar badge.
|
|
14
|
+
*
|
|
15
|
+
* Priority is `failure` > `syncing` > `active`:
|
|
16
|
+
* - If any status is `failure`, the result is `failure` (carrying that
|
|
17
|
+
* status's error).
|
|
18
|
+
* - Else if any status is `syncing`, the result is `syncing`.
|
|
19
|
+
* - Else the result is `active`.
|
|
20
|
+
*
|
|
21
|
+
* An empty input (nothing configured) is treated as `active`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function aggregateLocalDbStatus(statuses: AggregableSyncStatus[]): {
|
|
24
|
+
status: LocalDbStatus;
|
|
25
|
+
error: string | undefined;
|
|
26
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collapses many per-chain / per-raindex sync statuses into the single
|
|
3
|
+
* top-level localdb status shown in the sidebar badge.
|
|
4
|
+
*
|
|
5
|
+
* Priority is `failure` > `syncing` > `active`:
|
|
6
|
+
* - If any status is `failure`, the result is `failure` (carrying that
|
|
7
|
+
* status's error).
|
|
8
|
+
* - Else if any status is `syncing`, the result is `syncing`.
|
|
9
|
+
* - Else the result is `active`.
|
|
10
|
+
*
|
|
11
|
+
* An empty input (nothing configured) is treated as `active`.
|
|
12
|
+
*/
|
|
13
|
+
export function aggregateLocalDbStatus(statuses) {
|
|
14
|
+
const failure = statuses.find((s) => s.status === "failure");
|
|
15
|
+
if (failure) {
|
|
16
|
+
return { status: "failure", error: failure.error };
|
|
17
|
+
}
|
|
18
|
+
if (statuses.some((s) => s.status === "syncing")) {
|
|
19
|
+
return { status: "syncing", error: undefined };
|
|
20
|
+
}
|
|
21
|
+
return { status: "active", error: undefined };
|
|
22
|
+
}
|
package/dist/utils/number.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatUnits } from
|
|
1
|
+
import { formatUnits } from "viem";
|
|
2
2
|
/**
|
|
3
3
|
* Converts a bigint string value to a percentage with optionally given number of decimal points
|
|
4
4
|
* @param value - The bigint string value
|
|
@@ -6,9 +6,11 @@ import { formatUnits } from 'viem';
|
|
|
6
6
|
* @param decimalPoint - (optional) The number of digits to keep after "." in final result, defaults to valueDecimals
|
|
7
7
|
*/
|
|
8
8
|
export function bigintStringToPercentage(value, valueDecimals, finalDecimalsDigits) {
|
|
9
|
-
const finalDecimals = typeof finalDecimalsDigits !==
|
|
9
|
+
const finalDecimals = typeof finalDecimalsDigits !== "undefined"
|
|
10
|
+
? finalDecimalsDigits
|
|
11
|
+
: valueDecimals;
|
|
10
12
|
let valueString = formatUnits(BigInt(value) * 100n, valueDecimals);
|
|
11
|
-
const index = valueString.indexOf(
|
|
13
|
+
const index = valueString.indexOf(".");
|
|
12
14
|
if (index > -1) {
|
|
13
15
|
valueString = valueString.substring(0, finalDecimals === 0 ? index : index + finalDecimals + 1);
|
|
14
16
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace from rainlang/dotrain editor text, mirroring the
|
|
3
|
+
* "delete trailing whitespace on save" behaviour of common code editors.
|
|
4
|
+
*
|
|
5
|
+
* - Trailing spaces and tabs are removed from the end of every line.
|
|
6
|
+
* - Line breaks between content are preserved (`\r\n` is normalised to `\n`).
|
|
7
|
+
* - Internal blank lines are preserved (only their trailing whitespace is
|
|
8
|
+
* stripped) so deliberate spacing in the source is kept.
|
|
9
|
+
* - Trailing blank lines and a trailing newline at the very end of the text are
|
|
10
|
+
* removed, so the saved text never ends in dangling whitespace.
|
|
11
|
+
* - Leading whitespace (indentation) is never touched.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The editor contents to normalise.
|
|
14
|
+
* @returns The text with trailing whitespace stripped.
|
|
15
|
+
*/
|
|
16
|
+
export declare function stripTrailingWhitespace(text: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes trailing whitespace from rainlang/dotrain editor text, mirroring the
|
|
3
|
+
* "delete trailing whitespace on save" behaviour of common code editors.
|
|
4
|
+
*
|
|
5
|
+
* - Trailing spaces and tabs are removed from the end of every line.
|
|
6
|
+
* - Line breaks between content are preserved (`\r\n` is normalised to `\n`).
|
|
7
|
+
* - Internal blank lines are preserved (only their trailing whitespace is
|
|
8
|
+
* stripped) so deliberate spacing in the source is kept.
|
|
9
|
+
* - Trailing blank lines and a trailing newline at the very end of the text are
|
|
10
|
+
* removed, so the saved text never ends in dangling whitespace.
|
|
11
|
+
* - Leading whitespace (indentation) is never touched.
|
|
12
|
+
*
|
|
13
|
+
* @param text - The editor contents to normalise.
|
|
14
|
+
* @returns The text with trailing whitespace stripped.
|
|
15
|
+
*/
|
|
16
|
+
export function stripTrailingWhitespace(text) {
|
|
17
|
+
return text
|
|
18
|
+
.split(/\r\n|\r|\n/)
|
|
19
|
+
.map((line) => line.replace(/[ \t]+$/, ""))
|
|
20
|
+
.join("\n")
|
|
21
|
+
.replace(/\n+$/, "");
|
|
22
|
+
}
|
package/dist/utils/tokens.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RaindexVaultToken } from
|
|
1
|
+
import type { RaindexVaultToken } from "@rainlanguage/raindex";
|
|
2
2
|
export declare function getTokenDisplayName(token: RaindexVaultToken): string;
|
package/dist/utils/tokens.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RaindexVaultBalanceChangeType, VaultBalanceChangeFilter } from
|
|
1
|
+
import type { RaindexVaultBalanceChangeType, VaultBalanceChangeFilter } from "@rainlanguage/raindex";
|
|
2
2
|
export declare const VAULT_BALANCE_CHANGE_LABELS: Record<RaindexVaultBalanceChangeType, string>;
|
|
3
3
|
export declare const VAULT_BALANCE_CHANGE_FILTER_LABELS: Record<VaultBalanceChangeFilter, string>;
|
|
4
4
|
export declare function labelForVaultBalanceChangeType(type: RaindexVaultBalanceChangeType): string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const VAULT_BALANCE_CHANGE_LABELS = {
|
|
2
|
-
deposit:
|
|
3
|
-
withdrawal:
|
|
4
|
-
takeOrder:
|
|
5
|
-
clear:
|
|
6
|
-
clearBounty:
|
|
7
|
-
unknown:
|
|
2
|
+
deposit: "Deposit",
|
|
3
|
+
withdrawal: "Withdrawal",
|
|
4
|
+
takeOrder: "Take order",
|
|
5
|
+
clear: "Clear",
|
|
6
|
+
clearBounty: "Clear Bounty",
|
|
7
|
+
unknown: "Unknown",
|
|
8
8
|
};
|
|
9
9
|
export const VAULT_BALANCE_CHANGE_FILTER_LABELS = {
|
|
10
|
-
deposit:
|
|
11
|
-
withdrawal:
|
|
12
|
-
takeOrder:
|
|
13
|
-
clear:
|
|
14
|
-
clearBounty:
|
|
10
|
+
deposit: "Deposit",
|
|
11
|
+
withdrawal: "Withdrawal",
|
|
12
|
+
takeOrder: "Take order",
|
|
13
|
+
clear: "Clear",
|
|
14
|
+
clearBounty: "Clear Bounty",
|
|
15
15
|
};
|
|
16
16
|
export function labelForVaultBalanceChangeType(type) {
|
|
17
17
|
return VAULT_BALANCE_CHANGE_LABELS[type] ?? type;
|