timelock-sdk 0.0.232 → 0.0.234
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/client.cjs +22 -15
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +14998 -2
- package/dist/client.d.ts +14998 -2
- package/dist/client.js +22 -15
- package/dist/client.js.map +1 -1
- package/dist/{client-DCMXLt5x.d.ts → index-BPRvX6JV.d.ts} +541 -15499
- package/dist/{client-BGl9aQIQ.d.cts → index-D4B1xOAE.d.cts} +541 -15499
- package/dist/{numberUtils-DYC2nVsT.cjs → numberUtils-B-inHOvt.cjs} +158 -35
- package/dist/numberUtils-B-inHOvt.cjs.map +1 -0
- package/dist/{numberUtils-CkLCUIO0.js → numberUtils-CjyQGUg6.js} +111 -35
- package/dist/numberUtils-CjyQGUg6.js.map +1 -0
- package/dist/package.cjs +10 -17
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -15
- package/package.json +1 -4
- package/dist/numberUtils-CkLCUIO0.js.map +0 -1
- package/dist/numberUtils-DYC2nVsT.cjs.map +0 -1
- package/dist/package.cjs.map +0 -1
- package/dist/package.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
const require_numberUtils = require('./numberUtils-
|
|
3
|
+
const require_numberUtils = require('./numberUtils-B-inHOvt.cjs');
|
|
4
4
|
const require_stateView = require('./stateView-BMkpa0rT.cjs');
|
|
5
5
|
const require_factory = require('./factory-5hUk9F0p.cjs');
|
|
6
6
|
let viem = require("viem");
|
|
@@ -12,7 +12,6 @@ graphql_tag = require_numberUtils.__toESM(graphql_tag);
|
|
|
12
12
|
let wagmi = require("wagmi");
|
|
13
13
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
14
14
|
let viem_actions = require("viem/actions");
|
|
15
|
-
let zod = require("zod");
|
|
16
15
|
|
|
17
16
|
//#region src/generated/timelock.ts
|
|
18
17
|
const UserOptionFieldsFragmentDoc = graphql_tag.default`
|
|
@@ -1101,7 +1100,8 @@ const useMintOption = (marketAddr) => {
|
|
|
1101
1100
|
amount,
|
|
1102
1101
|
strikeTick,
|
|
1103
1102
|
duration,
|
|
1104
|
-
0
|
|
1103
|
+
0,
|
|
1104
|
+
"0x"
|
|
1105
1105
|
]);
|
|
1106
1106
|
const maxPremium = (premium + protocolFee) * 11n / 10n;
|
|
1107
1107
|
await askForApproval(payoutAsset, marketAddr, maxPremium);
|
|
@@ -1117,7 +1117,8 @@ const useMintOption = (marketAddr) => {
|
|
|
1117
1117
|
duration,
|
|
1118
1118
|
maxPremium,
|
|
1119
1119
|
maxSteps,
|
|
1120
|
-
await timelockLens.read.getRefTick([vault, strikeTick])
|
|
1120
|
+
await timelockLens.read.getRefTick([vault, strikeTick]),
|
|
1121
|
+
"0x"
|
|
1121
1122
|
]
|
|
1122
1123
|
});
|
|
1123
1124
|
await (0, viem_actions.waitForTransactionReceipt)(client, { hash });
|
|
@@ -1457,7 +1458,7 @@ const useExtendOption = (marketAddr) => {
|
|
|
1457
1458
|
//#endregion
|
|
1458
1459
|
//#region src/hooks/options/useOptionTimeline.ts
|
|
1459
1460
|
const useOptionTimeline = (marketAddr, optionId) => {
|
|
1460
|
-
const {
|
|
1461
|
+
const { timelockGraphqlClient } = useTimelockConfig();
|
|
1461
1462
|
marketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
|
|
1462
1463
|
return (0, _tanstack_react_query.useQuery)({
|
|
1463
1464
|
queryKey: [
|
|
@@ -1466,8 +1467,8 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
1466
1467
|
(optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
|
|
1467
1468
|
],
|
|
1468
1469
|
queryFn: async () => {
|
|
1469
|
-
if (!
|
|
1470
|
-
const result = await
|
|
1470
|
+
if (!timelockGraphqlClient || !marketAddr || optionId === void 0) return [];
|
|
1471
|
+
const result = await timelockGraphqlClient.GetOptionEvents({
|
|
1471
1472
|
marketAddr,
|
|
1472
1473
|
optionId: optionId.toString()
|
|
1473
1474
|
});
|
|
@@ -1518,23 +1519,29 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
1518
1519
|
}))
|
|
1519
1520
|
].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
|
|
1520
1521
|
},
|
|
1521
|
-
enabled: !!marketAddr && optionId !== void 0 && !!
|
|
1522
|
+
enabled: !!marketAddr && optionId !== void 0 && !!timelockGraphqlClient
|
|
1522
1523
|
});
|
|
1523
1524
|
};
|
|
1524
1525
|
|
|
1525
1526
|
//#endregion
|
|
1526
1527
|
//#region src/hooks/perps/usePerpsOperator.ts
|
|
1527
|
-
const
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1528
|
+
const isValidHex = (value) => {
|
|
1529
|
+
return typeof value === "string" && /^0x[a-fA-F0-9]+$/.test(value);
|
|
1530
|
+
};
|
|
1531
|
+
const isValidSavedSignature = (data) => {
|
|
1532
|
+
return typeof data === "object" && data !== null && "signature" in data && "message" in data && isValidHex(data.signature) && typeof data.message === "string";
|
|
1533
|
+
};
|
|
1532
1534
|
const getSavedSignature = (userAddr) => {
|
|
1533
1535
|
const key = `perps-auth-${userAddr.toLowerCase()}`;
|
|
1534
1536
|
const raw = localStorage.getItem(key);
|
|
1535
1537
|
if (!raw) return;
|
|
1536
1538
|
try {
|
|
1537
|
-
|
|
1539
|
+
const parsed = JSON.parse(raw);
|
|
1540
|
+
if (!isValidSavedSignature(parsed)) {
|
|
1541
|
+
clearSignature(userAddr);
|
|
1542
|
+
throw new Error("Invalid stored signature: " + raw);
|
|
1543
|
+
}
|
|
1544
|
+
return parsed;
|
|
1538
1545
|
} catch (error) {
|
|
1539
1546
|
clearSignature(userAddr);
|
|
1540
1547
|
throw new Error("Invalid stored signature: " + raw);
|
|
@@ -1555,7 +1562,7 @@ const clearSignature = (userAddr) => {
|
|
|
1555
1562
|
const usePerpsOperator = () => {
|
|
1556
1563
|
const { address: userAddr } = (0, wagmi.useConnection)();
|
|
1557
1564
|
const { perpsOperatorUrl, perpsOperator: operator } = useTimelockConfig();
|
|
1558
|
-
const { signMessageAsync } = (0, wagmi.useSignMessage)();
|
|
1565
|
+
const { mutateAsync: signMessageAsync } = (0, wagmi.useSignMessage)();
|
|
1559
1566
|
const { data: address } = (0, _tanstack_react_query.useQuery)({
|
|
1560
1567
|
queryKey: ["perpsOperatorAddr", perpsOperatorUrl || "--"],
|
|
1561
1568
|
queryFn: () => operator === null || operator === void 0 ? void 0 : operator.getOperatorAddr(),
|