@rainlanguage/ui-components 0.0.1-alpha.117 → 0.0.1-alpha.119

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/index.d.ts CHANGED
@@ -68,9 +68,8 @@ export { default as TransactionList } from './components/transactions/Transactio
68
68
  export { default as FixedBottomTransaction } from './components/transactions/FixedBottomTransaction.svelte';
69
69
  export type { AppStoresInterface } from './types/appStores.ts';
70
70
  export type { OrderbookConfigSource, OrderbookCfgRef } from '@rainlanguage/orderbook';
71
- export { TransactionStatusMessage, TransactionStoreErrorMessage, type ExtendedApprovalCalldata, type TransactionArgs } from './types/transaction';
71
+ export { TransactionStatusMessage, TransactionStoreErrorMessage, type ExtendedApprovalCalldata, type TransactionArgs, type DeploymentArgs, type VaultActionArgs } from './types/transaction';
72
72
  export type { TransactionErrorMessage } from './stores/transactionStore';
73
- export type { DeploymentArgs, VaultActionArgs } from './types/transaction';
74
73
  export type { VaultActionModalProps, QuoteDebugModalHandler, DebugTradeModalHandler, DeployModalProps, DisclaimerModalProps, TransactionConfirmationProps } from './types/modal';
75
74
  export type { ValidStrategyDetail, InvalidStrategyDetail } from './types/strategy';
76
75
  export type { ToastProps } from './types/toast';
@@ -59,6 +59,26 @@ export declare class TransactionManager {
59
59
  * });
60
60
  */
61
61
  createRemoveOrderTransaction(args: InternalTransactionArgs): Promise<Transaction>;
62
+ /**
63
+ * Creates and initializes a new transaction for withdrawing funds from a vault
64
+ * @param args - Configuration for the withdrawal transaction
65
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status
66
+ * @param args.txHash - Hash of the transaction to track
67
+ * @param args.orderHash - Identifier related to the transaction (e.g. vault ID or context-specific ID if applicable).
68
+ * @param args.chainId - Chain ID where the transaction is being executed
69
+ * @param args.queryKey - Identifier for the vault, used for cache invalidation and UI links.
70
+ * @param args.networkKey - Network identifier for UI links.
71
+ * @returns A new Transaction instance configured for withdrawal
72
+ * @throws {Error} If required transaction parameters are missing
73
+ * @example
74
+ * const tx = await manager.createWithdrawTransaction({
75
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
76
+ * txHash: '0x123...',
77
+ * orderHash: '0x456...',
78
+ * chainId: 1
79
+ * });
80
+ */
81
+ createWithdrawTransaction(args: InternalTransactionArgs): Promise<Transaction>;
62
82
  /**
63
83
  * Creates and executes a new transaction instance
64
84
  * @param args - Configuration for the transaction
@@ -2,7 +2,7 @@ import { writable } from 'svelte/store';
2
2
  import { TransactionStore } from '../../models/Transaction';
3
3
  import { getExplorerLink } from '../../services/getExplorerLink';
4
4
  import { TransactionName } from '../../types/transaction';
5
- import { getTransactionRemoveOrders } from '@rainlanguage/orderbook';
5
+ import { getTransaction, getTransactionRemoveOrders } from '@rainlanguage/orderbook';
6
6
  /**
7
7
  * Manages blockchain transactions with toast notifications and query invalidation.
8
8
  * Handles transaction lifecycle, status updates, and UI feedback.
@@ -88,6 +88,58 @@ export class TransactionManager {
88
88
  }
89
89
  });
90
90
  }
91
+ /**
92
+ * Creates and initializes a new transaction for withdrawing funds from a vault
93
+ * @param args - Configuration for the withdrawal transaction
94
+ * @param args.subgraphUrl - URL of the subgraph to query for transaction status
95
+ * @param args.txHash - Hash of the transaction to track
96
+ * @param args.orderHash - Identifier related to the transaction (e.g. vault ID or context-specific ID if applicable).
97
+ * @param args.chainId - Chain ID where the transaction is being executed
98
+ * @param args.queryKey - Identifier for the vault, used for cache invalidation and UI links.
99
+ * @param args.networkKey - Network identifier for UI links.
100
+ * @returns A new Transaction instance configured for withdrawal
101
+ * @throws {Error} If required transaction parameters are missing
102
+ * @example
103
+ * const tx = await manager.createWithdrawTransaction({
104
+ * subgraphUrl: 'https://api.thegraph.com/subgraphs/name/...',
105
+ * txHash: '0x123...',
106
+ * orderHash: '0x456...',
107
+ * chainId: 1
108
+ * });
109
+ */
110
+ async createWithdrawTransaction(args) {
111
+ const name = TransactionName.WITHDRAWAL;
112
+ const errorMessage = 'Withdrawal failed.';
113
+ const successMessage = 'Withdrawal successful.';
114
+ const queryKey = args.queryKey;
115
+ const networkKey = args.networkKey;
116
+ const explorerLink = await getExplorerLink(args.txHash, args.chainId, 'tx');
117
+ const toastLinks = [
118
+ {
119
+ link: `/vaults/${networkKey}-${args.queryKey}`,
120
+ label: 'View vault'
121
+ },
122
+ {
123
+ link: explorerLink,
124
+ label: 'View transaction'
125
+ }
126
+ ];
127
+ return this.createTransaction({
128
+ ...args,
129
+ name,
130
+ errorMessage,
131
+ successMessage,
132
+ queryKey,
133
+ toastLinks,
134
+ awaitSubgraphConfig: {
135
+ subgraphUrl: args.subgraphUrl,
136
+ txHash: args.txHash,
137
+ successMessage,
138
+ fetchEntityFn: getTransaction,
139
+ isSuccess: (data) => !!data
140
+ }
141
+ });
142
+ }
91
143
  /**
92
144
  * Creates and executes a new transaction instance
93
145
  * @param args - Configuration for the transaction
@@ -1,9 +1,9 @@
1
1
  import { writable } from 'svelte/store';
2
2
  import { sendTransaction, switchChain, waitForTransactionReceipt } from '@wagmi/core';
3
- import { TransactionStatusMessage } from '../types/transaction';
4
- import { getTransaction, getTransactionAddOrders } from '@rainlanguage/orderbook';
5
3
  import { getExplorerLink } from '../services/getExplorerLink';
4
+ import { TransactionStatusMessage } from '../types/transaction';
6
5
  import { awaitSubgraphIndexing } from '../services/awaitTransactionIndexing';
6
+ import { getTransaction, getTransactionAddOrders } from '@rainlanguage/orderbook';
7
7
  export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000';
8
8
  export const ONE = BigInt('1000000000000000000');
9
9
  export var TransactionErrorMessage;
@@ -1,9 +1,10 @@
1
- import type { SgOrder } from '@rainlanguage/orderbook';
2
- import type { VaultActionArgs, DeploymentArgs } from './transaction';
1
+ import type { SgOrder, SgVault } from '@rainlanguage/orderbook';
2
+ import type { DeploymentArgs, VaultActionArgs } from './transaction';
3
3
  import type { Hex } from 'viem';
4
4
  export type VaultActionModalProps = {
5
5
  open: boolean;
6
6
  args: VaultActionArgs;
7
+ onSubmit: (amount: bigint) => void;
7
8
  };
8
9
  export type DeployModalProps = {
9
10
  open: boolean;
@@ -20,7 +21,7 @@ export type TransactionConfirmationProps = {
20
21
  chainId: number;
21
22
  orderbookAddress: Hex;
22
23
  onConfirm: (hash: Hex) => void;
23
- order: SgOrder;
24
+ entity: SgOrder | SgVault;
24
25
  calldata: string;
25
26
  };
26
27
  };
@@ -16,14 +16,15 @@ export type DeploymentArgs = {
16
16
  };
17
17
  export type VaultActionArgs = {
18
18
  vault: SgVault;
19
- onSuccess: () => void;
20
19
  chainId: number;
20
+ onDeposit?: () => void;
21
21
  rpcUrl: string;
22
22
  subgraphUrl: string;
23
23
  account: Hex;
24
24
  };
25
25
  export declare enum TransactionName {
26
- REMOVAL = "Order Removal"
26
+ REMOVAL = "Order Removal",
27
+ WITHDRAWAL = "Vault Withdrawal"
27
28
  }
28
29
  export declare enum TransactionStatusMessage {
29
30
  IDLE = "Idle",
@@ -55,11 +56,11 @@ export type DepositOrWithdrawTransactionArgs = {
55
56
  subgraphUrl: string;
56
57
  };
57
58
  export type InternalTransactionArgs = {
58
- queryKey: string;
59
59
  chainId: number;
60
60
  subgraphUrl: string;
61
61
  txHash: Hex;
62
62
  networkKey: string;
63
+ queryKey: string;
63
64
  };
64
65
  export type TransactionArgs = InternalTransactionArgs & {
65
66
  name: TransactionName;
@@ -1,6 +1,7 @@
1
1
  export var TransactionName;
2
2
  (function (TransactionName) {
3
3
  TransactionName["REMOVAL"] = "Order Removal";
4
+ TransactionName["WITHDRAWAL"] = "Vault Withdrawal";
4
5
  })(TransactionName || (TransactionName = {}));
5
6
  export var TransactionStatusMessage;
6
7
  (function (TransactionStatusMessage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainlanguage/ui-components",
3
- "version": "0.0.1-alpha.117",
3
+ "version": "0.0.1-alpha.119",
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",
@@ -53,7 +53,7 @@
53
53
  "@fontsource/dm-sans": "5.1.0",
54
54
  "@imask/svelte": "7.6.1",
55
55
  "@observablehq/plot": "0.6.16",
56
- "@rainlanguage/orderbook": "0.0.1-alpha.117",
56
+ "@rainlanguage/orderbook": "0.0.1-alpha.119",
57
57
  "@reown/appkit": "1.6.4",
58
58
  "@reown/appkit-adapter-wagmi": "1.6.4",
59
59
  "@sentry/sveltekit": "7.120.0",