@rainlanguage/ui-components 0.0.1-alpha.74 → 0.0.1-alpha.76
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.
|
@@ -20,7 +20,7 @@ export declare enum TransactionStatus {
|
|
|
20
20
|
export declare enum TransactionErrorMessage {
|
|
21
21
|
BAD_CALLLDATA = "Bad calldata.",
|
|
22
22
|
DEPLOY_FAILED = "Lock transaction failed.",
|
|
23
|
-
TIMEOUT = "The subgraph took too long to respond.
|
|
23
|
+
TIMEOUT = "The subgraph took too long to respond.",
|
|
24
24
|
APPROVAL_FAILED = "Approval transaction failed.",
|
|
25
25
|
USER_REJECTED_APPROVAL = "User rejected approval transaction.",
|
|
26
26
|
USER_REJECTED_TRANSACTION = "User rejected the transaction.",
|
|
@@ -22,7 +22,7 @@ export var TransactionErrorMessage;
|
|
|
22
22
|
(function (TransactionErrorMessage) {
|
|
23
23
|
TransactionErrorMessage["BAD_CALLLDATA"] = "Bad calldata.";
|
|
24
24
|
TransactionErrorMessage["DEPLOY_FAILED"] = "Lock transaction failed.";
|
|
25
|
-
TransactionErrorMessage["TIMEOUT"] = "The subgraph took too long to respond.
|
|
25
|
+
TransactionErrorMessage["TIMEOUT"] = "The subgraph took too long to respond.";
|
|
26
26
|
TransactionErrorMessage["APPROVAL_FAILED"] = "Approval transaction failed.";
|
|
27
27
|
TransactionErrorMessage["USER_REJECTED_APPROVAL"] = "User rejected approval transaction.";
|
|
28
28
|
TransactionErrorMessage["USER_REJECTED_TRANSACTION"] = "User rejected the transaction.";
|
|
@@ -46,15 +46,11 @@ export const initialState = {
|
|
|
46
46
|
const transactionStore = () => {
|
|
47
47
|
const { subscribe, set, update } = writable(initialState);
|
|
48
48
|
const reset = () => set(initialState);
|
|
49
|
-
const returnError = (interval) => {
|
|
50
|
-
clearInterval(interval);
|
|
51
|
-
return transactionError(TransactionErrorMessage.TIMEOUT);
|
|
52
|
-
};
|
|
53
49
|
const awaitTransactionIndexing = async (subgraphUrl, txHash, successMessage) => {
|
|
54
50
|
update((state) => ({
|
|
55
51
|
...state,
|
|
56
52
|
status: TransactionStatus.PENDING_SUBGRAPH,
|
|
57
|
-
message: '
|
|
53
|
+
message: 'Waiting for transaction to be indexed...'
|
|
58
54
|
}));
|
|
59
55
|
let attempts = 0;
|
|
60
56
|
let newTx;
|
|
@@ -66,16 +62,12 @@ const transactionStore = () => {
|
|
|
66
62
|
clearInterval(interval);
|
|
67
63
|
transactionSuccess(txHash, successMessage);
|
|
68
64
|
}
|
|
69
|
-
else if (attempts >= 10) {
|
|
70
|
-
update((state) => ({
|
|
71
|
-
...state,
|
|
72
|
-
message: 'The subgraph took too long to respond. Please check again later.'
|
|
73
|
-
}));
|
|
74
|
-
return returnError(interval);
|
|
75
|
-
}
|
|
76
65
|
}
|
|
77
66
|
catch {
|
|
78
|
-
|
|
67
|
+
if (attempts >= 10) {
|
|
68
|
+
clearInterval(interval);
|
|
69
|
+
return transactionError(TransactionErrorMessage.TIMEOUT);
|
|
70
|
+
}
|
|
79
71
|
}
|
|
80
72
|
}, 1000);
|
|
81
73
|
};
|
|
@@ -90,16 +82,16 @@ const transactionStore = () => {
|
|
|
90
82
|
attempts++;
|
|
91
83
|
try {
|
|
92
84
|
const addOrders = await getTransactionAddOrders(subgraphUrl, txHash);
|
|
93
|
-
if (
|
|
94
|
-
return returnError(interval);
|
|
95
|
-
}
|
|
96
|
-
else if (addOrders?.length > 0) {
|
|
85
|
+
if (addOrders?.length > 0) {
|
|
97
86
|
clearInterval(interval);
|
|
98
87
|
return transactionSuccess(txHash, '', addOrders[0].order.orderHash, network);
|
|
99
88
|
}
|
|
100
89
|
}
|
|
101
90
|
catch {
|
|
102
|
-
|
|
91
|
+
if (attempts >= 10) {
|
|
92
|
+
clearInterval(interval);
|
|
93
|
+
return transactionError(TransactionErrorMessage.TIMEOUT);
|
|
94
|
+
}
|
|
103
95
|
}
|
|
104
96
|
}, 1000);
|
|
105
97
|
};
|
|
@@ -114,20 +106,16 @@ const transactionStore = () => {
|
|
|
114
106
|
attempts++;
|
|
115
107
|
try {
|
|
116
108
|
const removeOrders = await getTransactionRemoveOrders(subgraphUrl, txHash);
|
|
117
|
-
if (
|
|
118
|
-
update((state) => ({
|
|
119
|
-
...state,
|
|
120
|
-
message: 'The subgraph took too long to respond. Please check again later.'
|
|
121
|
-
}));
|
|
122
|
-
return returnError(interval);
|
|
123
|
-
}
|
|
124
|
-
else if (removeOrders?.length > 0) {
|
|
109
|
+
if (removeOrders?.length > 0) {
|
|
125
110
|
clearInterval(interval);
|
|
126
111
|
return transactionSuccess(txHash, 'Order removed successfully');
|
|
127
112
|
}
|
|
128
113
|
}
|
|
129
114
|
catch {
|
|
130
|
-
|
|
115
|
+
if (attempts >= 10) {
|
|
116
|
+
clearInterval(interval);
|
|
117
|
+
return transactionError(TransactionErrorMessage.TIMEOUT);
|
|
118
|
+
}
|
|
131
119
|
}
|
|
132
120
|
}, 1000);
|
|
133
121
|
};
|
|
@@ -260,9 +248,10 @@ const transactionStore = () => {
|
|
|
260
248
|
return transactionError(TransactionErrorMessage.USER_REJECTED_TRANSACTION);
|
|
261
249
|
}
|
|
262
250
|
try {
|
|
251
|
+
const transactionExplorerLink = await getExplorerLink(hash, chainId, 'tx');
|
|
263
252
|
awaitTx(hash, action === 'deposit'
|
|
264
253
|
? TransactionStatus.PENDING_DEPOSIT
|
|
265
|
-
: TransactionStatus.PENDING_WITHDRAWAL);
|
|
254
|
+
: TransactionStatus.PENDING_WITHDRAWAL, transactionExplorerLink);
|
|
266
255
|
await waitForTransactionReceipt(config, { hash });
|
|
267
256
|
return awaitTransactionIndexing(subgraphUrl, hash, `The ${action === 'deposit' ? 'deposit' : 'withdrawal'} was successful.`);
|
|
268
257
|
}
|
|
@@ -291,7 +280,8 @@ const transactionStore = () => {
|
|
|
291
280
|
return transactionError(TransactionErrorMessage.USER_REJECTED_TRANSACTION);
|
|
292
281
|
}
|
|
293
282
|
try {
|
|
294
|
-
|
|
283
|
+
const transactionExplorerLink = await getExplorerLink(hash, chainId, 'tx');
|
|
284
|
+
awaitTx(hash, TransactionStatus.PENDING_REMOVE_ORDER, transactionExplorerLink);
|
|
295
285
|
await waitForTransactionReceipt(config, { hash });
|
|
296
286
|
return awaitRemoveOrderIndexing(subgraphUrl, hash);
|
|
297
287
|
}
|
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.76",
|
|
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.
|
|
56
|
+
"@rainlanguage/orderbook": "0.0.1-alpha.76",
|
|
57
57
|
"@reown/appkit": "1.6.4",
|
|
58
58
|
"@reown/appkit-adapter-wagmi": "1.6.4",
|
|
59
59
|
"@sentry/sveltekit": "7.120.0",
|