@rainlanguage/ui-components 0.0.1-alpha.10
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 +58 -0
- package/dist/__fixtures__/orderDetail.d.ts +99 -0
- package/dist/__fixtures__/orderDetail.js +204 -0
- package/dist/__fixtures__/settings-12-11-24.json +160 -0
- package/dist/__mocks__/MockComponent.d.ts +1 -0
- package/dist/__mocks__/MockComponent.js +2 -0
- package/dist/__mocks__/MockComponent.svelte +3 -0
- package/dist/__mocks__/MockComponent.svelte.d.ts +18 -0
- package/dist/__mocks__/mockTransactionStore.d.ts +22 -0
- package/dist/__mocks__/mockTransactionStore.js +56 -0
- package/dist/__mocks__/mockWeb3Config.d.ts +2 -0
- package/dist/__mocks__/mockWeb3Config.js +15 -0
- package/dist/__mocks__/queries.d.ts +13 -0
- package/dist/__mocks__/queries.js +64 -0
- package/dist/__mocks__/settings.d.ts +3 -0
- package/dist/__mocks__/settings.js +37 -0
- package/dist/__mocks__/stores.d.ts +94 -0
- package/dist/__mocks__/stores.js +113 -0
- package/dist/app.css +3 -0
- package/dist/assets/ledger.svg +6 -0
- package/dist/assets/logo-dark.svg +15 -0
- package/dist/assets/logo-light.svg +15 -0
- package/dist/assets/walletconnect.svg +1 -0
- package/dist/components/BadgeActive.svelte +9 -0
- package/dist/components/BadgeActive.svelte.d.ts +19 -0
- package/dist/components/BlockQuote.svelte +1 -0
- package/dist/components/BlockQuote.svelte.d.ts +29 -0
- package/dist/components/ButtonDarkMode.svelte +14 -0
- package/dist/components/ButtonDarkMode.svelte.d.ts +18 -0
- package/dist/components/ButtonLoading.svelte +11 -0
- package/dist/components/ButtonLoading.svelte.d.ts +24 -0
- package/dist/components/ButtonTab.svelte +7 -0
- package/dist/components/ButtonTab.svelte.d.ts +23 -0
- package/dist/components/ButtonVaultLink.svelte +29 -0
- package/dist/components/ButtonVaultLink.svelte.d.ts +22 -0
- package/dist/components/CardProperty.svelte +11 -0
- package/dist/components/CardProperty.svelte.d.ts +31 -0
- package/dist/components/CheckboxMyItemsOnly.svelte +23 -0
- package/dist/components/CheckboxMyItemsOnly.svelte.d.ts +21 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte +20 -0
- package/dist/components/CheckboxZeroBalanceVault.svelte.d.ts +19 -0
- package/dist/components/CodeMirrorDotrain.svelte +35 -0
- package/dist/components/CodeMirrorDotrain.svelte.d.ts +23 -0
- package/dist/components/CodeMirrorRainlang.svelte +34 -0
- package/dist/components/CodeMirrorRainlang.svelte.d.ts +23 -0
- package/dist/components/DropdownProperty.svelte +12 -0
- package/dist/components/DropdownProperty.svelte.d.ts +19 -0
- package/dist/components/EditableSpan.svelte +46 -0
- package/dist/components/EditableSpan.svelte.d.ts +21 -0
- package/dist/components/Hash.svelte +85 -0
- package/dist/components/Hash.svelte.d.ts +28 -0
- package/dist/components/Heading.svelte +19 -0
- package/dist/components/Heading.svelte.d.ts +29 -0
- package/dist/components/IconError.svelte +8 -0
- package/dist/components/IconError.svelte.d.ts +16 -0
- package/dist/components/IconExternalLink.svelte +18 -0
- package/dist/components/IconExternalLink.svelte.d.ts +18 -0
- package/dist/components/IconInfo.svelte +8 -0
- package/dist/components/IconInfo.svelte.d.ts +16 -0
- package/dist/components/IconLedger.svelte +13 -0
- package/dist/components/IconLedger.svelte.d.ts +16 -0
- package/dist/components/IconSuccess.svelte +8 -0
- package/dist/components/IconSuccess.svelte.d.ts +16 -0
- package/dist/components/IconTelegram.svelte +12 -0
- package/dist/components/IconTelegram.svelte.d.ts +25 -0
- package/dist/components/IconWalletConnect.svelte +13 -0
- package/dist/components/IconWalletConnect.svelte.d.ts +16 -0
- package/dist/components/IconWarning.svelte +8 -0
- package/dist/components/IconWarning.svelte.d.ts +16 -0
- package/dist/components/License.svelte +29 -0
- package/dist/components/License.svelte.d.ts +25 -0
- package/dist/components/ListViewOrderbookFilters.svelte +58 -0
- package/dist/components/ListViewOrderbookFilters.svelte.d.ts +28 -0
- package/dist/components/OrderOrVaultHash.svelte +24 -0
- package/dist/components/OrderOrVaultHash.svelte.d.ts +22 -0
- package/dist/components/PageHeader.svelte +33 -0
- package/dist/components/PageHeader.svelte.d.ts +21 -0
- package/dist/components/TanstackAppTable.svelte +73 -0
- package/dist/components/TanstackAppTable.svelte.d.ts +30 -0
- package/dist/components/Text.svelte +12 -0
- package/dist/components/Text.svelte.d.ts +31 -0
- package/dist/components/charts/APYTimeFilters.svelte +47 -0
- package/dist/components/charts/APYTimeFilters.svelte.d.ts +19 -0
- package/dist/components/charts/ChartTimeFilters.svelte +35 -0
- package/dist/components/charts/ChartTimeFilters.svelte.d.ts +18 -0
- package/dist/components/charts/LightweightChart.svelte +110 -0
- package/dist/components/charts/LightweightChart.svelte.d.ts +29 -0
- package/dist/components/charts/OrderTradesChart.svelte +36 -0
- package/dist/components/charts/OrderTradesChart.svelte.d.ts +21 -0
- package/dist/components/charts/TableTimeFilters.svelte +48 -0
- package/dist/components/charts/TableTimeFilters.svelte.d.ts +19 -0
- package/dist/components/charts/TanstackLightweightChartLine.svelte +24 -0
- package/dist/components/charts/TanstackLightweightChartLine.svelte.d.ts +23 -0
- package/dist/components/charts/VaultBalanceChart.svelte +37 -0
- package/dist/components/charts/VaultBalanceChart.svelte.d.ts +22 -0
- package/dist/components/checkbox/Checkbox.svelte +17 -0
- package/dist/components/checkbox/Checkbox.svelte.d.ts +21 -0
- package/dist/components/deployment/ButtonSelectOption.svelte +14 -0
- package/dist/components/deployment/ButtonSelectOption.svelte.d.ts +20 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte +35 -0
- package/dist/components/deployment/ComposedRainlangModal.svelte.d.ts +19 -0
- package/dist/components/deployment/DeploymentSectionHeader.svelte +14 -0
- package/dist/components/deployment/DeploymentSectionHeader.svelte.d.ts +19 -0
- package/dist/components/deployment/DeploymentSteps.svelte +252 -0
- package/dist/components/deployment/DeploymentSteps.svelte.d.ts +38 -0
- package/dist/components/deployment/DeploymentTile.svelte +19 -0
- package/dist/components/deployment/DeploymentTile.svelte.d.ts +21 -0
- package/dist/components/deployment/DeploymentsSection.svelte +20 -0
- package/dist/components/deployment/DeploymentsSection.svelte.d.ts +19 -0
- package/dist/components/deployment/DepositInput.svelte +93 -0
- package/dist/components/deployment/DepositInput.svelte.d.ts +20 -0
- package/dist/components/deployment/DepositsSection.svelte +8 -0
- package/dist/components/deployment/DepositsSection.svelte.d.ts +20 -0
- package/dist/components/deployment/DisclaimerModal.svelte +54 -0
- package/dist/components/deployment/DisclaimerModal.svelte.d.ts +19 -0
- package/dist/components/deployment/FieldDefinitionInput.svelte +66 -0
- package/dist/components/deployment/FieldDefinitionInput.svelte.d.ts +20 -0
- package/dist/components/deployment/FieldDefinitionsSection.svelte +9 -0
- package/dist/components/deployment/FieldDefinitionsSection.svelte.d.ts +20 -0
- package/dist/components/deployment/InvalidStrategiesSection.svelte +19 -0
- package/dist/components/deployment/InvalidStrategiesSection.svelte.d.ts +19 -0
- package/dist/components/deployment/SelectToken.svelte +88 -0
- package/dist/components/deployment/SelectToken.svelte.d.ts +21 -0
- package/dist/components/deployment/SelectTokensSection.svelte +17 -0
- package/dist/components/deployment/SelectTokensSection.svelte.d.ts +21 -0
- package/dist/components/deployment/ShareChoicesButton.svelte +26 -0
- package/dist/components/deployment/ShareChoicesButton.svelte.d.ts +18 -0
- package/dist/components/deployment/StrategyPage.svelte +70 -0
- package/dist/components/deployment/StrategyPage.svelte.d.ts +19 -0
- package/dist/components/deployment/TokenIOInput.svelte +62 -0
- package/dist/components/deployment/TokenIOInput.svelte.d.ts +22 -0
- package/dist/components/deployment/TokenIOSection.svelte +17 -0
- package/dist/components/deployment/TokenIOSection.svelte.d.ts +21 -0
- package/dist/components/deployment/ValidStrategiesSection.svelte +25 -0
- package/dist/components/deployment/ValidStrategiesSection.svelte.d.ts +19 -0
- package/dist/components/deployment/getDeploymentTransactionArgs.d.ts +17 -0
- package/dist/components/deployment/getDeploymentTransactionArgs.js +24 -0
- package/dist/components/detail/DepositOrWithdrawButtons.svelte +44 -0
- package/dist/components/detail/DepositOrWithdrawButtons.svelte.d.ts +26 -0
- package/dist/components/detail/OrderDetail.svelte +195 -0
- package/dist/components/detail/OrderDetail.svelte.d.ts +36 -0
- package/dist/components/detail/TanstackOrderQuote.svelte +173 -0
- package/dist/components/detail/TanstackOrderQuote.svelte.d.ts +22 -0
- package/dist/components/detail/TanstackPageContentDetail.svelte +56 -0
- package/dist/components/detail/TanstackPageContentDetail.svelte.d.ts +31 -0
- package/dist/components/detail/VaultDetail.svelte +178 -0
- package/dist/components/detail/VaultDetail.svelte.d.ts +35 -0
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte +38 -0
- package/dist/components/dropdown/DropdownActiveSubgraphs.svelte.d.ts +21 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte +77 -0
- package/dist/components/dropdown/DropdownCheckbox.svelte.d.ts +26 -0
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte +15 -0
- package/dist/components/dropdown/DropdownOrderListAccounts.svelte.d.ts +20 -0
- package/dist/components/dropdown/DropdownOrderStatus.svelte +31 -0
- package/dist/components/dropdown/DropdownOrderStatus.svelte.d.ts +19 -0
- package/dist/components/dropdown/DropdownRadio.svelte +45 -0
- package/dist/components/dropdown/DropdownRadio.svelte.d.ts +30 -0
- package/dist/components/icon/RainLogo.svelte +54 -0
- package/dist/components/icon/RainLogo.svelte.d.ts +25 -0
- package/dist/components/icon/Refresh.svelte +57 -0
- package/dist/components/icon/Refresh.svelte.d.ts +40 -0
- package/dist/components/input/InputHex.svelte +42 -0
- package/dist/components/input/InputHex.svelte.d.ts +19 -0
- package/dist/components/input/InputOrderHash.svelte +22 -0
- package/dist/components/input/InputOrderHash.svelte.d.ts +20 -0
- package/dist/components/input/InputRegistryUrl.svelte +18 -0
- package/dist/components/input/InputRegistryUrl.svelte.d.ts +16 -0
- package/dist/components/input/InputToken.svelte +53 -0
- package/dist/components/input/InputToken.svelte.d.ts +19 -0
- package/dist/components/input/InputTokenAmount.svelte +63 -0
- package/dist/components/input/InputTokenAmount.svelte.d.ts +21 -0
- package/dist/components/tables/OrderAPY.svelte +57 -0
- package/dist/components/tables/OrderAPY.svelte.d.ts +19 -0
- package/dist/components/tables/OrderTradesListTable.svelte +145 -0
- package/dist/components/tables/OrderTradesListTable.svelte.d.ts +21 -0
- package/dist/components/tables/OrderVaultsVolTable.svelte +67 -0
- package/dist/components/tables/OrderVaultsVolTable.svelte.d.ts +19 -0
- package/dist/components/tables/OrdersListTable.svelte +181 -0
- package/dist/components/tables/OrdersListTable.svelte.d.ts +35 -0
- package/dist/components/tables/VaultBalanceChangesTable.svelte +74 -0
- package/dist/components/tables/VaultBalanceChangesTable.svelte.d.ts +17 -0
- package/dist/components/tables/VaultsListTable.svelte +229 -0
- package/dist/components/tables/VaultsListTable.svelte.d.ts +40 -0
- package/dist/components/wallet/WalletConnect.svelte +28 -0
- package/dist/components/wallet/WalletConnect.svelte.d.ts +23 -0
- package/dist/errors/DeploymentStepsError.d.ts +24 -0
- package/dist/errors/DeploymentStepsError.js +45 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +89 -0
- package/dist/queries/constants.d.ts +2 -0
- package/dist/queries/constants.js +2 -0
- package/dist/queries/keys.d.ts +9 -0
- package/dist/queries/keys.js +9 -0
- package/dist/queries/queryClient.d.ts +3 -0
- package/dist/queries/queryClient.js +16 -0
- package/dist/services/getExplorerLink.d.ts +1 -0
- package/dist/services/getExplorerLink.js +10 -0
- package/dist/services/handleShareChoices.d.ts +2 -0
- package/dist/services/handleShareChoices.js +10 -0
- package/dist/services/historicalOrderCharts.d.ts +12 -0
- package/dist/services/historicalOrderCharts.js +496 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +1 -0
- package/dist/services/registry.d.ts +25 -0
- package/dist/services/registry.js +133 -0
- package/dist/services/time.d.ts +6 -0
- package/dist/services/time.js +17 -0
- package/dist/stores/transactionStore.d.ts +98 -0
- package/dist/stores/transactionStore.js +303 -0
- package/dist/test/matchers.d.ts +6 -0
- package/dist/test/matchers.js +4 -0
- package/dist/types/appStores.d.ts +19 -0
- package/dist/types/appStores.js +1 -0
- package/dist/types/modal.d.ts +20 -0
- package/dist/types/modal.js +1 -0
- package/dist/types/strategy.d.ts +10 -0
- package/dist/types/strategy.js +1 -0
- package/dist/types/transaction.d.ts +27 -0
- package/dist/types/transaction.js +1 -0
- package/dist/utils/breadcrumbs.d.ts +5 -0
- package/dist/utils/breadcrumbs.js +9 -0
- package/dist/utils/codeMirrorThemes.d.ts +2 -0
- package/dist/utils/codeMirrorThemes.js +86 -0
- package/dist/utils/hex.d.ts +2 -0
- package/dist/utils/hex.js +3 -0
- package/dist/utils/lightweightChartsThemes.d.ts +52 -0
- package/dist/utils/lightweightChartsThemes.js +21 -0
- package/dist/utils/number.d.ts +14 -0
- package/dist/utils/number.js +43 -0
- package/dist/utils/time.d.ts +12 -0
- package/dist/utils/time.js +27 -0
- package/dist/utils/vault.d.ts +2 -0
- package/dist/utils/vault.js +29 -0
- package/package.json +86 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ColorType } from 'lightweight-charts';
|
|
2
|
+
export interface ChartTheme {
|
|
3
|
+
layout: {
|
|
4
|
+
textColor: string;
|
|
5
|
+
background: {
|
|
6
|
+
type: ColorType;
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
grid: {
|
|
11
|
+
vertLines: {
|
|
12
|
+
color: string;
|
|
13
|
+
};
|
|
14
|
+
horzLines: {
|
|
15
|
+
color: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare const darkChartTheme: {
|
|
20
|
+
layout: {
|
|
21
|
+
textColor: string;
|
|
22
|
+
background: {
|
|
23
|
+
type: ColorType;
|
|
24
|
+
color: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
grid: {
|
|
28
|
+
vertLines: {
|
|
29
|
+
color: string;
|
|
30
|
+
};
|
|
31
|
+
horzLines: {
|
|
32
|
+
color: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare const lightChartTheme: {
|
|
37
|
+
layout: {
|
|
38
|
+
textColor: string;
|
|
39
|
+
background: {
|
|
40
|
+
type: ColorType;
|
|
41
|
+
color: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
grid: {
|
|
45
|
+
vertLines: {
|
|
46
|
+
color: string;
|
|
47
|
+
};
|
|
48
|
+
horzLines: {
|
|
49
|
+
color: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ColorType } from 'lightweight-charts';
|
|
2
|
+
export const darkChartTheme = {
|
|
3
|
+
layout: {
|
|
4
|
+
textColor: 'white',
|
|
5
|
+
background: { type: ColorType.Solid, color: 'transparent' }
|
|
6
|
+
},
|
|
7
|
+
grid: {
|
|
8
|
+
vertLines: { color: '#484848' },
|
|
9
|
+
horzLines: { color: '#484848' }
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const lightChartTheme = {
|
|
13
|
+
layout: {
|
|
14
|
+
textColor: 'black',
|
|
15
|
+
background: { type: ColorType.Solid, color: 'transparent' }
|
|
16
|
+
},
|
|
17
|
+
grid: {
|
|
18
|
+
vertLines: { color: '#ECECEC' },
|
|
19
|
+
horzLines: { color: '#ECECEC' }
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a bigint string value to a percentage with optionally given number of decimal points
|
|
3
|
+
* @param value - The bigint string value
|
|
4
|
+
* @param valueDecimals - The bigint string value decimals point
|
|
5
|
+
* @param decimalPoint - (optional) The number of digits to keep after "." in final result, defaults to valueDecimals
|
|
6
|
+
*/
|
|
7
|
+
export declare function bigintStringToPercentage(value: string, valueDecimals: number, finalDecimalsDigits?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a bigint value to a floating point number with the specified number of decimals
|
|
10
|
+
* @param value - The bigint value to convert
|
|
11
|
+
* @param decimals - The number of decimal places to use in the conversion
|
|
12
|
+
* @returns The converted floating point number
|
|
13
|
+
*/
|
|
14
|
+
export declare function bigintToFloat(value: bigint, decimals: number): number;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { formatUnits } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a bigint string value to a percentage with optionally given number of decimal points
|
|
4
|
+
* @param value - The bigint string value
|
|
5
|
+
* @param valueDecimals - The bigint string value decimals point
|
|
6
|
+
* @param decimalPoint - (optional) The number of digits to keep after "." in final result, defaults to valueDecimals
|
|
7
|
+
*/
|
|
8
|
+
export function bigintStringToPercentage(value, valueDecimals, finalDecimalsDigits) {
|
|
9
|
+
const finalDecimals = typeof finalDecimalsDigits !== 'undefined' ? finalDecimalsDigits : valueDecimals;
|
|
10
|
+
let valueString = formatUnits(BigInt(value) * 100n, valueDecimals);
|
|
11
|
+
const index = valueString.indexOf('.');
|
|
12
|
+
if (index > -1) {
|
|
13
|
+
valueString = valueString.substring(0, finalDecimals === 0 ? index : index + finalDecimals + 1);
|
|
14
|
+
}
|
|
15
|
+
return valueString;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converts a bigint value to a floating point number with the specified number of decimals
|
|
19
|
+
* @param value - The bigint value to convert
|
|
20
|
+
* @param decimals - The number of decimal places to use in the conversion
|
|
21
|
+
* @returns The converted floating point number
|
|
22
|
+
*/
|
|
23
|
+
export function bigintToFloat(value, decimals) {
|
|
24
|
+
return parseFloat(formatUnits(value, decimals));
|
|
25
|
+
}
|
|
26
|
+
if (import.meta.vitest) {
|
|
27
|
+
const { it, expect } = import.meta.vitest;
|
|
28
|
+
it('should get percentage string from bigint string', () => {
|
|
29
|
+
const value = '123456000000000000';
|
|
30
|
+
const decimals = 18;
|
|
31
|
+
const finalDecimalsDigits = 4;
|
|
32
|
+
const result = bigintStringToPercentage(value, decimals, finalDecimalsDigits);
|
|
33
|
+
const expected = '12.3456';
|
|
34
|
+
expect(result).toEqual(expected);
|
|
35
|
+
});
|
|
36
|
+
it('should convert bigint to float', () => {
|
|
37
|
+
const value = 123456000000000000n;
|
|
38
|
+
const decimals = 18;
|
|
39
|
+
const result = bigintToFloat(value, decimals);
|
|
40
|
+
const expected = 0.123456;
|
|
41
|
+
expect(result).toEqual(expected);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UTCTimestamp } from 'lightweight-charts';
|
|
2
|
+
export declare function formatTimestampSecondsAsLocal(timestampSeconds: bigint): string;
|
|
3
|
+
export declare function timestampSecondsToUTCTimestamp(timestampSeconds: bigint): UTCTimestamp;
|
|
4
|
+
/**
|
|
5
|
+
* Method to put a timeout on a promise, throws the exception if promise is not settled within the time
|
|
6
|
+
* @param promise - The original promise
|
|
7
|
+
* @param time - The time in ms
|
|
8
|
+
* @param exception - The exception to reject with if time runs out before original promise settlement
|
|
9
|
+
* @returns A new promise that gets settled with initial promise settlement or rejected with exception value
|
|
10
|
+
* if the time runs out before the main promise settlement
|
|
11
|
+
*/
|
|
12
|
+
export declare function promiseTimeout<T>(promise: Promise<T>, time: number, exception: unknown): Promise<T>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import bigIntSupport from 'dayjs/plugin/bigIntSupport';
|
|
3
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
+
dayjs.extend(bigIntSupport);
|
|
5
|
+
dayjs.extend(localizedFormat);
|
|
6
|
+
export function formatTimestampSecondsAsLocal(timestampSeconds) {
|
|
7
|
+
return dayjs(timestampSeconds * BigInt('1000')).format('L LT');
|
|
8
|
+
}
|
|
9
|
+
export function timestampSecondsToUTCTimestamp(timestampSeconds) {
|
|
10
|
+
return dayjs(timestampSeconds * BigInt('1000')).unix();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Method to put a timeout on a promise, throws the exception if promise is not settled within the time
|
|
14
|
+
* @param promise - The original promise
|
|
15
|
+
* @param time - The time in ms
|
|
16
|
+
* @param exception - The exception to reject with if time runs out before original promise settlement
|
|
17
|
+
* @returns A new promise that gets settled with initial promise settlement or rejected with exception value
|
|
18
|
+
* if the time runs out before the main promise settlement
|
|
19
|
+
*/
|
|
20
|
+
export async function promiseTimeout(promise, time, exception) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
let timeout;
|
|
23
|
+
return Promise.race([
|
|
24
|
+
promise,
|
|
25
|
+
new Promise((_resolve, reject) => (timeout = setTimeout(reject, time, exception)))
|
|
26
|
+
]).finally(() => clearTimeout(timeout));
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { formatUnits } from 'viem';
|
|
2
|
+
export const vaultBalanceDisplay = (vault) => {
|
|
3
|
+
return formatUnits(BigInt(vault.balance), +(vault.token?.decimals || 0));
|
|
4
|
+
};
|
|
5
|
+
if (import.meta.vitest) {
|
|
6
|
+
const { it, expect } = import.meta.vitest;
|
|
7
|
+
it('formats the vault balance correctly', () => {
|
|
8
|
+
const vault = {
|
|
9
|
+
id: '1',
|
|
10
|
+
balance: '1000000000000000000',
|
|
11
|
+
token: {
|
|
12
|
+
id: '1',
|
|
13
|
+
decimals: '18',
|
|
14
|
+
address: '0x00'
|
|
15
|
+
},
|
|
16
|
+
vaultId: '1',
|
|
17
|
+
owner: '0x00',
|
|
18
|
+
ordersAsInput: [],
|
|
19
|
+
ordersAsOutput: [],
|
|
20
|
+
balanceChanges: [],
|
|
21
|
+
orderbook: {
|
|
22
|
+
id: '0x00'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
expect(vaultBalanceDisplay(vault)).toEqual('1');
|
|
26
|
+
vault.token.decimals = '6';
|
|
27
|
+
expect(vaultBalanceDisplay(vault)).toEqual('1000000000000');
|
|
28
|
+
});
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rainlanguage/ui-components",
|
|
3
|
+
"version": "0.0.1-alpha.10",
|
|
4
|
+
"description": "A component library for building Svelte applications to be used with Raindex.",
|
|
5
|
+
"license": "LicenseRef-DCL-1.0",
|
|
6
|
+
"author": "Rain Open Source Software Ltd",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.js",
|
|
14
|
+
"svelte": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./services": {
|
|
17
|
+
"types": "./dist/services/index.d.ts",
|
|
18
|
+
"import": "./dist/services/index.js",
|
|
19
|
+
"require": "./dist/services/index.js",
|
|
20
|
+
"svelte": "./dist/services/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dev": "vite dev",
|
|
25
|
+
"build": "vite build && npm run package",
|
|
26
|
+
"preview": "vite preview",
|
|
27
|
+
"package": "svelte-kit sync && svelte-package && publint",
|
|
28
|
+
"build:watch": "vite build --watch & svelte-package --watch",
|
|
29
|
+
"prepublishOnly": "npm run package",
|
|
30
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
31
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
32
|
+
"format": "prettier --write src",
|
|
33
|
+
"lint": "prettier --list-different src && eslint src",
|
|
34
|
+
"lint-check": "eslint src",
|
|
35
|
+
"test:unit": "vitest",
|
|
36
|
+
"test": "npm run test:unit -- --run",
|
|
37
|
+
"format-check": "prettier --list-different src",
|
|
38
|
+
"svelte-lint-format-check": "npm run lint && npm run check"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"!dist/**/*.test.*",
|
|
43
|
+
"!dist/**/*.spec.*"
|
|
44
|
+
],
|
|
45
|
+
"sideEffects": [
|
|
46
|
+
"**/*.css"
|
|
47
|
+
],
|
|
48
|
+
"svelte": "./dist/index.js",
|
|
49
|
+
"types": "./dist/index.d.ts",
|
|
50
|
+
"type": "module",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@codemirror/lang-yaml": "^6.0.0",
|
|
53
|
+
"@fontsource/dm-sans": "^5.0.18",
|
|
54
|
+
"@imask/svelte": "^7.3.0",
|
|
55
|
+
"@observablehq/plot": "^0.6.13",
|
|
56
|
+
"@rainlanguage/orderbook": "0.0.1-alpha.10",
|
|
57
|
+
"@reown/appkit": "^1.6.4",
|
|
58
|
+
"@reown/appkit-adapter-wagmi": "^1.6.4",
|
|
59
|
+
"@sentry/sveltekit": "^7.107.0",
|
|
60
|
+
"@square/svelte-store": "^1.0.18",
|
|
61
|
+
"@sveltejs/kit": "^2.0.0",
|
|
62
|
+
"@tanstack/svelte-query": "^5.59.20",
|
|
63
|
+
"@wagmi/core": "^2.16.3",
|
|
64
|
+
"@walletconnect/ethereum-provider": "^2.11.3",
|
|
65
|
+
"@walletconnect/modal": "^2.6.2",
|
|
66
|
+
"@web3modal/ethers5": "^4.1.1",
|
|
67
|
+
"camelcase-keys": "^9.1.3",
|
|
68
|
+
"codemirror-rainlang": "^3.0.13",
|
|
69
|
+
"dayjs": "^1.11.13",
|
|
70
|
+
"ethers": "^5.7.2",
|
|
71
|
+
"flowbite": "^2.2.1",
|
|
72
|
+
"flowbite-svelte": "^0.44.21",
|
|
73
|
+
"flowbite-svelte-icons": "^0.4.5",
|
|
74
|
+
"fuse.js": "^7.0.0",
|
|
75
|
+
"lightweight-charts": "^4.1.3",
|
|
76
|
+
"lodash": "^4.17.21",
|
|
77
|
+
"svelte": "^4.2.7",
|
|
78
|
+
"svelte-codemirror-editor": "^1.3.0",
|
|
79
|
+
"svelte-markdown": "^0.4.1",
|
|
80
|
+
"tailwind-merge": "^2.5.4",
|
|
81
|
+
"thememirror": "^2.0.1",
|
|
82
|
+
"uuid": "^9.0.1",
|
|
83
|
+
"viem": "^2.22.8",
|
|
84
|
+
"wagmi": "^2.14.7"
|
|
85
|
+
}
|
|
86
|
+
}
|