@rainlanguage/ui-components 0.0.1-alpha.207 → 0.0.1-alpha.209
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/dist/components/detail/OrderDetail.svelte +14 -8
- package/dist/components/detail/OrderDetail.svelte.d.ts +3 -0
- package/dist/components/tables/OrdersListTable.svelte +92 -17
- package/dist/components/tables/OrdersListTable.svelte.d.ts +2 -0
- package/dist/providers/transactions/TransactionManager.d.ts +21 -0
- package/dist/providers/transactions/TransactionManager.js +43 -0
- package/dist/types/transaction.d.ts +2 -1
- package/dist/types/transaction.js +1 -0
- package/package.json +2 -2
|
@@ -43,6 +43,7 @@ export let onRemove;
|
|
|
43
43
|
export let onDeposit;
|
|
44
44
|
export let onWithdraw;
|
|
45
45
|
export let onWithdrawAll = void 0;
|
|
46
|
+
export let onTakeOrder = void 0;
|
|
46
47
|
let codeMirrorDisabled = true;
|
|
47
48
|
let codeMirrorStyles = {};
|
|
48
49
|
const queryClient = useQueryClient();
|
|
@@ -102,14 +103,19 @@ const formatGuiState = (guiState) => {
|
|
|
102
103
|
</div>
|
|
103
104
|
|
|
104
105
|
<div class="flex items-center gap-2">
|
|
105
|
-
{#if matchesAccount(data.owner)}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
{#if matchesAccount(data.owner) && data.active}
|
|
107
|
+
<Button
|
|
108
|
+
on:click={() => onRemove(raindexClient, data)}
|
|
109
|
+
data-testid="remove-button"
|
|
110
|
+
aria-label="Remove order">Remove</Button
|
|
111
|
+
>
|
|
112
|
+
{/if}
|
|
113
|
+
{#if data.active && onTakeOrder}
|
|
114
|
+
<Button
|
|
115
|
+
on:click={() => onTakeOrder(raindexClient, data)}
|
|
116
|
+
data-testid="take-order-button"
|
|
117
|
+
aria-label="Take order">Take Order</Button
|
|
118
|
+
>
|
|
113
119
|
{/if}
|
|
114
120
|
|
|
115
121
|
<Refresh
|
|
@@ -23,6 +23,9 @@ declare const __propDef: {
|
|
|
23
23
|
/** Callback function when withdraw all action is triggered for a vault
|
|
24
24
|
* @param vaultsList The VaultsList struct containing the vaults to withdraw from
|
|
25
25
|
*/ onWithdrawAll?: ((raindexClient: RaindexClient, vaultsList: RaindexVaultsList) => void) | undefined;
|
|
26
|
+
/** Callback function when take order action is triggered
|
|
27
|
+
* @param order The order to take
|
|
28
|
+
*/ onTakeOrder?: ((raindexClient: RaindexClient, order: RaindexOrder) => void) | undefined;
|
|
26
29
|
};
|
|
27
30
|
events: {
|
|
28
31
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>import { getNetworkName } from "../../utils/getNetworkName";
|
|
2
2
|
import { goto } from "$app/navigation";
|
|
3
|
+
import { DotsVerticalOutline } from "flowbite-svelte-icons";
|
|
3
4
|
import { createInfiniteQuery, createQuery } from "@tanstack/svelte-query";
|
|
4
5
|
import { RaindexOrder } from "@rainlanguage/orderbook";
|
|
5
6
|
import TanstackAppTable from "../TanstackAppTable.svelte";
|
|
@@ -9,9 +10,20 @@ import Hash, { HashType } from "../Hash.svelte";
|
|
|
9
10
|
import VaultCard from "../VaultCard.svelte";
|
|
10
11
|
import { DEFAULT_PAGE_SIZE, DEFAULT_REFRESH_INTERVAL } from "../../queries/constants";
|
|
11
12
|
import { QKEY_ORDERS, QKEY_TOKENS } from "../../queries/keys";
|
|
12
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Badge,
|
|
15
|
+
Button,
|
|
16
|
+
Dropdown,
|
|
17
|
+
DropdownItem,
|
|
18
|
+
TableBodyCell,
|
|
19
|
+
TableHeadCell
|
|
20
|
+
} from "flowbite-svelte";
|
|
13
21
|
import { useAccount } from "../../providers/wallet/useAccount";
|
|
14
22
|
import { useRaindexClient } from "../../hooks/useRaindexClient";
|
|
23
|
+
import { getAllContexts } from "svelte";
|
|
24
|
+
const context = getAllContexts();
|
|
25
|
+
export let handleOrderRemoveModal = void 0;
|
|
26
|
+
export let handleTakeOrderModal = void 0;
|
|
15
27
|
export let selectedChainIds;
|
|
16
28
|
export let activeAccountsItems;
|
|
17
29
|
export let showInactiveOrders;
|
|
@@ -21,7 +33,7 @@ export let hideInactiveOrdersVaults;
|
|
|
21
33
|
export let showMyItemsOnly;
|
|
22
34
|
export let activeTokens;
|
|
23
35
|
export let activeOrderbookAddresses;
|
|
24
|
-
const { account } = useAccount();
|
|
36
|
+
const { matchesAccount, account } = useAccount();
|
|
25
37
|
const raindexClient = useRaindexClient();
|
|
26
38
|
$: owners = $activeAccountsItems && Object.values($activeAccountsItems).length > 0 ? Object.values($activeAccountsItems) : $showMyItemsOnly && $account ? [$account] : [];
|
|
27
39
|
$: tokensQuery = createQuery({
|
|
@@ -115,21 +127,42 @@ const AppTable = TanstackAppTable;
|
|
|
115
127
|
</svelte:fragment>
|
|
116
128
|
|
|
117
129
|
<svelte:fragment slot="head">
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
{#if $account && (handleTakeOrderModal || handleOrderRemoveModal)}
|
|
131
|
+
<TableHeadCell data-testid="orderListHeadingOrderInfo" padding="p-4" class="w-[15%]"
|
|
132
|
+
>Order Info</TableHeadCell
|
|
133
|
+
>
|
|
134
|
+
<TableHeadCell data-testid="orderListHeadingAddresses" padding="p-4" class="w-[18%]"
|
|
135
|
+
>Addresses</TableHeadCell
|
|
136
|
+
>
|
|
137
|
+
<TableHeadCell data-testid="orderListHeadingInputs" padding="px-2 py-4" class="w-[23.5%]"
|
|
138
|
+
>Input Token(s)</TableHeadCell
|
|
139
|
+
>
|
|
140
|
+
<TableHeadCell data-testid="orderListHeadingOutputs" padding="px-2 py-4" class="w-[23.5%]"
|
|
141
|
+
>Output Token(s)</TableHeadCell
|
|
142
|
+
>
|
|
143
|
+
<TableHeadCell data-testid="orderListHeadingTrades" padding="px-2 py-4" class="w-[10%]"
|
|
144
|
+
>Trades</TableHeadCell
|
|
145
|
+
>
|
|
146
|
+
<TableHeadCell data-testid="orderListHeadingActions" padding="px-2 py-4" class="w-[10%]"
|
|
147
|
+
>Actions</TableHeadCell
|
|
148
|
+
>
|
|
149
|
+
{:else}
|
|
150
|
+
<TableHeadCell data-testid="orderListHeadingOrderInfo" padding="p-4" class="w-[15%]"
|
|
151
|
+
>Order Info</TableHeadCell
|
|
152
|
+
>
|
|
153
|
+
<TableHeadCell data-testid="orderListHeadingAddresses" padding="p-4" class="w-[20%]"
|
|
154
|
+
>Addresses</TableHeadCell
|
|
155
|
+
>
|
|
156
|
+
<TableHeadCell data-testid="orderListHeadingInputs" padding="px-2 py-4" class="w-[27.5%]"
|
|
157
|
+
>Input Token(s)</TableHeadCell
|
|
158
|
+
>
|
|
159
|
+
<TableHeadCell data-testid="orderListHeadingOutputs" padding="px-2 py-4" class="w-[27.5%]"
|
|
160
|
+
>Output Token(s)</TableHeadCell
|
|
161
|
+
>
|
|
162
|
+
<TableHeadCell data-testid="orderListHeadingTrades" padding="px-2 py-4" class="w-[10%]"
|
|
163
|
+
>Trades</TableHeadCell
|
|
164
|
+
>
|
|
165
|
+
{/if}
|
|
133
166
|
</svelte:fragment>
|
|
134
167
|
|
|
135
168
|
<svelte:fragment slot="bodyRow" let:item>
|
|
@@ -194,5 +227,47 @@ const AppTable = TanstackAppTable;
|
|
|
194
227
|
<TableBodyCell data-testid="orderListRowTrades" tdClass="break-word p-2">
|
|
195
228
|
{item.tradesCount > 99 ? '>99' : item.tradesCount}
|
|
196
229
|
</TableBodyCell>
|
|
230
|
+
{#if $account && (handleTakeOrderModal || handleOrderRemoveModal)}
|
|
231
|
+
<TableBodyCell data-testid="orderListRowActions" tdClass="px-2 py-2">
|
|
232
|
+
{#if item.active}
|
|
233
|
+
{#if handleTakeOrderModal}
|
|
234
|
+
<Button
|
|
235
|
+
size="xs"
|
|
236
|
+
data-testid={`order-take-${item.id}`}
|
|
237
|
+
on:click={(e) => {
|
|
238
|
+
e.stopPropagation();
|
|
239
|
+
handleTakeOrderModal(item, $query.refetch, context);
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
Take Order
|
|
243
|
+
</Button>
|
|
244
|
+
{/if}
|
|
245
|
+
{#if matchesAccount(item.owner) && handleOrderRemoveModal}
|
|
246
|
+
<div data-testid="wallet-actions">
|
|
247
|
+
<Button
|
|
248
|
+
color="alternative"
|
|
249
|
+
outline={false}
|
|
250
|
+
data-testid={`order-menu-${item.id}`}
|
|
251
|
+
id={`order-menu-${item.id}`}
|
|
252
|
+
class="border-none px-2"
|
|
253
|
+
on:click={(e) => {
|
|
254
|
+
e.stopPropagation();
|
|
255
|
+
}}
|
|
256
|
+
>
|
|
257
|
+
<DotsVerticalOutline class="dark:text-white" />
|
|
258
|
+
</Button>
|
|
259
|
+
<Dropdown placement="bottom-end" triggeredBy={`#order-menu-${item.id}`}>
|
|
260
|
+
<DropdownItem
|
|
261
|
+
on:click={(e) => {
|
|
262
|
+
e.stopPropagation();
|
|
263
|
+
handleOrderRemoveModal(item, $query.refetch, context);
|
|
264
|
+
}}>Remove</DropdownItem
|
|
265
|
+
>
|
|
266
|
+
</Dropdown>
|
|
267
|
+
</div>
|
|
268
|
+
{/if}
|
|
269
|
+
{/if}
|
|
270
|
+
</TableBodyCell>
|
|
271
|
+
{/if}
|
|
197
272
|
</svelte:fragment>
|
|
198
273
|
</AppTable>
|
|
@@ -2,6 +2,8 @@ import { SvelteComponent } from "svelte";
|
|
|
2
2
|
import type { AppStoresInterface } from '../../types/appStores';
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
|
+
handleOrderRemoveModal?: any;
|
|
6
|
+
handleTakeOrderModal?: any;
|
|
5
7
|
selectedChainIds: AppStoresInterface["selectedChainIds"];
|
|
6
8
|
activeAccountsItems: AppStoresInterface["activeAccountsItems"] | undefined;
|
|
7
9
|
showInactiveOrders: AppStoresInterface["showInactiveOrders"];
|
|
@@ -184,6 +184,27 @@ export declare class TransactionManager {
|
|
|
184
184
|
orderbook: Address;
|
|
185
185
|
raindexClient: RaindexClient;
|
|
186
186
|
}): Promise<Transaction>;
|
|
187
|
+
/**
|
|
188
|
+
* Creates and initializes a new transaction for taking orders.
|
|
189
|
+
* @param args - Configuration for the take order transaction.
|
|
190
|
+
* @param args.txHash - Hash of the transaction to track.
|
|
191
|
+
* @param args.chainId - Chain ID where the transaction is being executed.
|
|
192
|
+
* @param args.queryKey - The hash of the order being taken (used for query invalidation).
|
|
193
|
+
* @param args.entity - The `RaindexOrder` entity associated with this transaction.
|
|
194
|
+
* @returns A new Transaction instance configured for taking orders.
|
|
195
|
+
* @example
|
|
196
|
+
* const tx = await manager.createTakeOrderTransaction({
|
|
197
|
+
* txHash: '0x123...',
|
|
198
|
+
* chainId: 1,
|
|
199
|
+
* queryKey: '0x456...', // Order hash
|
|
200
|
+
* entity: raindexOrderInstance,
|
|
201
|
+
* raindexClient: clientInstance
|
|
202
|
+
* });
|
|
203
|
+
*/
|
|
204
|
+
createTakeOrderTransaction(args: InternalTransactionArgs & {
|
|
205
|
+
entity: RaindexOrder;
|
|
206
|
+
raindexClient: RaindexClient;
|
|
207
|
+
}): Promise<Transaction>;
|
|
187
208
|
/**
|
|
188
209
|
* Creates, initializes, and executes a new transaction instance.
|
|
189
210
|
* @param args - Configuration for the transaction.
|
|
@@ -407,6 +407,49 @@ export class TransactionManager {
|
|
|
407
407
|
awaitIndexingFn
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Creates and initializes a new transaction for taking orders.
|
|
412
|
+
* @param args - Configuration for the take order transaction.
|
|
413
|
+
* @param args.txHash - Hash of the transaction to track.
|
|
414
|
+
* @param args.chainId - Chain ID where the transaction is being executed.
|
|
415
|
+
* @param args.queryKey - The hash of the order being taken (used for query invalidation).
|
|
416
|
+
* @param args.entity - The `RaindexOrder` entity associated with this transaction.
|
|
417
|
+
* @returns A new Transaction instance configured for taking orders.
|
|
418
|
+
* @example
|
|
419
|
+
* const tx = await manager.createTakeOrderTransaction({
|
|
420
|
+
* txHash: '0x123...',
|
|
421
|
+
* chainId: 1,
|
|
422
|
+
* queryKey: '0x456...', // Order hash
|
|
423
|
+
* entity: raindexOrderInstance,
|
|
424
|
+
* raindexClient: clientInstance
|
|
425
|
+
* });
|
|
426
|
+
*/
|
|
427
|
+
async createTakeOrderTransaction(args) {
|
|
428
|
+
const name = TransactionName.TAKE_ORDER;
|
|
429
|
+
const errorMessage = 'Take order failed.';
|
|
430
|
+
const successMessage = 'Order taken successfully.';
|
|
431
|
+
const { chainId, entity: { orderbook }, queryKey, txHash, raindexClient } = args;
|
|
432
|
+
const explorerLink = await getExplorerLink(txHash, chainId, 'tx');
|
|
433
|
+
const toastLinks = [
|
|
434
|
+
{
|
|
435
|
+
link: explorerLink,
|
|
436
|
+
label: 'View on explorer'
|
|
437
|
+
}
|
|
438
|
+
];
|
|
439
|
+
const awaitIndexingFn = createSdkIndexingFn({
|
|
440
|
+
call: () => raindexClient.getTransaction(chainId, orderbook, txHash),
|
|
441
|
+
isSuccess: (tx) => !!tx
|
|
442
|
+
});
|
|
443
|
+
return this.createTransaction({
|
|
444
|
+
...args,
|
|
445
|
+
name,
|
|
446
|
+
errorMessage,
|
|
447
|
+
successMessage,
|
|
448
|
+
queryKey,
|
|
449
|
+
toastLinks,
|
|
450
|
+
awaitIndexingFn
|
|
451
|
+
});
|
|
452
|
+
}
|
|
410
453
|
/**
|
|
411
454
|
* Creates, initializes, and executes a new transaction instance.
|
|
412
455
|
* @param args - Configuration for the transaction.
|
|
@@ -33,7 +33,8 @@ export declare enum TransactionName {
|
|
|
33
33
|
WITHDRAWAL = "Vault Withdrawal",
|
|
34
34
|
WITHDRAWAL_MULTIPLE = "Vaults Withdrawal",
|
|
35
35
|
APPROVAL = "Token Approval",
|
|
36
|
-
DEPOSIT = "Vault Deposit"
|
|
36
|
+
DEPOSIT = "Vault Deposit",
|
|
37
|
+
TAKE_ORDER = "Take Order"
|
|
37
38
|
}
|
|
38
39
|
export declare enum TransactionStatusMessage {
|
|
39
40
|
IDLE = "Idle",
|
|
@@ -5,6 +5,7 @@ export var TransactionName;
|
|
|
5
5
|
TransactionName["WITHDRAWAL_MULTIPLE"] = "Vaults Withdrawal";
|
|
6
6
|
TransactionName["APPROVAL"] = "Token Approval";
|
|
7
7
|
TransactionName["DEPOSIT"] = "Vault Deposit";
|
|
8
|
+
TransactionName["TAKE_ORDER"] = "Take Order";
|
|
8
9
|
})(TransactionName || (TransactionName = {}));
|
|
9
10
|
export var TransactionStatusMessage;
|
|
10
11
|
(function (TransactionStatusMessage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainlanguage/ui-components",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.209",
|
|
4
4
|
"description": "A component library for building Svelte applications to be used with Raindex.",
|
|
5
5
|
"license": "LicenseRef-DCL-1.0",
|
|
6
6
|
"author": "Rain Open Source Software Ltd",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@fontsource/dm-sans": "5.1.0",
|
|
58
58
|
"@imask/svelte": "7.6.1",
|
|
59
59
|
"@observablehq/plot": "0.6.16",
|
|
60
|
-
"@rainlanguage/orderbook": "0.0.1-alpha.
|
|
60
|
+
"@rainlanguage/orderbook": "0.0.1-alpha.209",
|
|
61
61
|
"@reown/appkit": "1.6.4",
|
|
62
62
|
"@reown/appkit-adapter-wagmi": "1.6.4",
|
|
63
63
|
"@sentry/sveltekit": "7.120.0",
|