@orderly.network/hooks 1.0.28-alpha.10 → 1.0.28-alpha.11
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.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +39 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -28,9 +28,9 @@ var useSWRSubscription__default = /*#__PURE__*/_interopDefault(useSWRSubscriptio
|
|
|
28
28
|
// src/version.ts
|
|
29
29
|
if (typeof window !== "undefined") {
|
|
30
30
|
window.__ORDERLY_VERSION__ = window.__ORDERLY_VERSION__ || {};
|
|
31
|
-
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.
|
|
31
|
+
window.__ORDERLY_VERSION__["@orderly.network/hooks"] = "1.0.28-alpha.11";
|
|
32
32
|
}
|
|
33
|
-
var version_default = "1.0.28-alpha.
|
|
33
|
+
var version_default = "1.0.28-alpha.11";
|
|
34
34
|
var fetcher = (url, init = {}, queryOptions) => net.get(url, init, queryOptions?.formatter);
|
|
35
35
|
var OrderlyContext = React.createContext({
|
|
36
36
|
// configStore: new MemoryConfigStore(),
|
|
@@ -201,7 +201,6 @@ var signatureMiddleware = (useSWRNext) => {
|
|
|
201
201
|
};
|
|
202
202
|
return useSWRNext(key, extendedFetcher, config);
|
|
203
203
|
} catch (e) {
|
|
204
|
-
console.error("signature error:", e);
|
|
205
204
|
throw e;
|
|
206
205
|
}
|
|
207
206
|
};
|
|
@@ -346,23 +345,16 @@ function useSessionStorage(key, initialValue) {
|
|
|
346
345
|
const item = window.sessionStorage.getItem(key);
|
|
347
346
|
return item ? parseJSON(item) : initialValue;
|
|
348
347
|
} catch (error) {
|
|
349
|
-
console.warn(`Error reading sessionStorage key \u201C${key}\u201D:`, error);
|
|
350
348
|
return initialValue;
|
|
351
349
|
}
|
|
352
350
|
}, [initialValue, key]);
|
|
353
351
|
const [storedValue, setStoredValue] = React.useState(readValue);
|
|
354
352
|
const setValue = (value) => {
|
|
355
|
-
if (typeof window == "undefined") {
|
|
356
|
-
console.warn(
|
|
357
|
-
`Tried setting sessionStorage key \u201C${key}\u201D even though environment is not a client`
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
353
|
try {
|
|
361
354
|
const newValue = value instanceof Function ? value(storedValue) : value;
|
|
362
355
|
window.sessionStorage.setItem(key, JSON.stringify(newValue));
|
|
363
356
|
setStoredValue(newValue);
|
|
364
357
|
} catch (error) {
|
|
365
|
-
console.warn(`Error setting sessionStorage key \u201C${key}\u201D:`, error);
|
|
366
358
|
}
|
|
367
359
|
};
|
|
368
360
|
React.useEffect(() => {
|
|
@@ -397,24 +389,17 @@ function useLocalStorage(key, initialValue) {
|
|
|
397
389
|
const item = window.localStorage.getItem(key);
|
|
398
390
|
return item ? parseJSON(item) : initialValue;
|
|
399
391
|
} catch (error) {
|
|
400
|
-
console.warn(`Error reading localStorage key \u201C${key}\u201D:`, error);
|
|
401
392
|
return initialValue;
|
|
402
393
|
}
|
|
403
394
|
}, [initialValue, key]);
|
|
404
395
|
const [storedValue, setStoredValue] = React.useState(readValue);
|
|
405
396
|
const setValue = React.useCallback(
|
|
406
397
|
(value) => {
|
|
407
|
-
if (typeof window === "undefined") {
|
|
408
|
-
console.warn(
|
|
409
|
-
`Tried setting localStorage key \u201C${key}\u201D even though environment is not a client`
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
398
|
try {
|
|
413
399
|
const newValue = value instanceof Function ? value(storedValue) : value;
|
|
414
400
|
window.localStorage.setItem(key, JSON.stringify(newValue));
|
|
415
401
|
setStoredValue(() => newValue);
|
|
416
402
|
} catch (error) {
|
|
417
|
-
console.warn(`Error setting localStorage key \u201C${key}\u201D:`, error);
|
|
418
403
|
}
|
|
419
404
|
},
|
|
420
405
|
[storedValue]
|
|
@@ -568,9 +553,6 @@ var OrderlyConfigProvider = (props) => {
|
|
|
568
553
|
enableSwapDeposit,
|
|
569
554
|
contracts
|
|
570
555
|
} = props;
|
|
571
|
-
if (!brokerId && typeof configStore === "undefined") {
|
|
572
|
-
console.error("[OrderlyConfigProvider]: brokerId is required");
|
|
573
|
-
}
|
|
574
556
|
const innerConfigStore = useConstant4__default.default(() => {
|
|
575
557
|
return configStore || new core.DefaultConfigStore({ brokerId, networkId });
|
|
576
558
|
});
|
|
@@ -1762,7 +1744,6 @@ var LimitOrderCreator = class extends BaseOrderCreator {
|
|
|
1762
1744
|
const { price_range } = symbol;
|
|
1763
1745
|
const maxPriceNumber = maxPrice(config.markPrice, price_range);
|
|
1764
1746
|
const minPriceNumber = minPrice(config.markPrice, price_range);
|
|
1765
|
-
console.log(`side: ${side} value:`, values);
|
|
1766
1747
|
if (side === "BUY" && price.gt(maxPriceNumber)) {
|
|
1767
1748
|
errors.order_price = {
|
|
1768
1749
|
type: "max",
|
|
@@ -3379,6 +3360,7 @@ var useChains = (networkId, options = {}) => {
|
|
|
3379
3360
|
// "public_rpc_url": "https://arb1.arbitrum.io/rpc",
|
|
3380
3361
|
chain_id: chainId,
|
|
3381
3362
|
withdrawal_fee: chain.withdrawal_fee,
|
|
3363
|
+
cross_chain_withdrawal_fee: chain.cross_chain_withdrawal_fee,
|
|
3382
3364
|
bridgeless: true
|
|
3383
3365
|
},
|
|
3384
3366
|
token_infos: [
|
|
@@ -3432,6 +3414,25 @@ var useChains = (networkId, options = {}) => {
|
|
|
3432
3414
|
]
|
|
3433
3415
|
}
|
|
3434
3416
|
];
|
|
3417
|
+
if (networkEnv === "testnet") {
|
|
3418
|
+
const opGoerli = {
|
|
3419
|
+
network_infos: {
|
|
3420
|
+
name: "Optimism Goerli",
|
|
3421
|
+
shortName: "Optimism Goerli",
|
|
3422
|
+
public_rpc_url: "https://optimism-goerli.gateway.tenderly.co",
|
|
3423
|
+
chain_id: 420,
|
|
3424
|
+
currency_symbol: "ETH",
|
|
3425
|
+
bridge_enable: true,
|
|
3426
|
+
mainnet: false,
|
|
3427
|
+
explorer_base_url: "https://goerli-optimism.etherscan.io",
|
|
3428
|
+
est_txn_mins: null,
|
|
3429
|
+
woofi_dex_cross_chain_router: "",
|
|
3430
|
+
woofi_dex_depositor: ""
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
testnetArr.push(opGoerli);
|
|
3434
|
+
map.current.set(420, opGoerli);
|
|
3435
|
+
}
|
|
3435
3436
|
let mainnetArr = [];
|
|
3436
3437
|
map.current.set(421613, testnetArr[0]);
|
|
3437
3438
|
if (wooSwapEnabled) {
|
|
@@ -3676,7 +3677,6 @@ var useDeposit = (options) => {
|
|
|
3676
3677
|
const balance2 = await fetchBalanceHandler(address, decimals);
|
|
3677
3678
|
setBalance(() => balance2);
|
|
3678
3679
|
} catch (e) {
|
|
3679
|
-
console.warn("----- refresh balance error -----", e);
|
|
3680
3680
|
setBalance(() => "0");
|
|
3681
3681
|
}
|
|
3682
3682
|
},
|
|
@@ -3726,18 +3726,30 @@ var useDeposit = (options) => {
|
|
|
3726
3726
|
}
|
|
3727
3727
|
}
|
|
3728
3728
|
}, [options, dst]);
|
|
3729
|
+
const queryBalance = useDebounce.useDebouncedCallback(
|
|
3730
|
+
(tokenAddress, decimals) => {
|
|
3731
|
+
fetchBalance(options?.address, options?.decimals).finally(() => {
|
|
3732
|
+
setBalanceRevalidating(false);
|
|
3733
|
+
});
|
|
3734
|
+
},
|
|
3735
|
+
100
|
|
3736
|
+
);
|
|
3737
|
+
const queryAllowance = useDebounce.useDebouncedCallback(
|
|
3738
|
+
(tokenAddress, vaultAddress) => {
|
|
3739
|
+
getAllowance(tokenAddress, vaultAddress);
|
|
3740
|
+
},
|
|
3741
|
+
100
|
|
3742
|
+
);
|
|
3729
3743
|
React.useEffect(() => {
|
|
3730
3744
|
if (state.status < types.AccountStatusEnum.Connected)
|
|
3731
3745
|
return;
|
|
3732
3746
|
setBalanceRevalidating(true);
|
|
3733
|
-
|
|
3734
|
-
setBalanceRevalidating(false);
|
|
3735
|
-
});
|
|
3747
|
+
queryBalance(options?.address, options?.decimals);
|
|
3736
3748
|
if (dst.chainId !== options?.srcChainId) {
|
|
3737
|
-
|
|
3749
|
+
queryAllowance(options?.address, options?.crossChainRouteAddress);
|
|
3738
3750
|
} else {
|
|
3739
3751
|
if (dst.symbol !== options?.srcToken) {
|
|
3740
|
-
|
|
3752
|
+
queryAllowance(options?.address, options?.depositorAddress);
|
|
3741
3753
|
} else {
|
|
3742
3754
|
getAllowanceByDefaultAddress(options?.address);
|
|
3743
3755
|
}
|
|
@@ -3801,9 +3813,7 @@ var useDeposit = (options) => {
|
|
|
3801
3813
|
new utils.Decimal(res.toString()).mul(types.DEPOSIT_FEE_RATE).toFixed(0, utils.Decimal.ROUND_UP).toString()
|
|
3802
3814
|
);
|
|
3803
3815
|
setDepositFee(fee);
|
|
3804
|
-
console.log("getDepositFee", fee);
|
|
3805
3816
|
}).catch((error) => {
|
|
3806
|
-
console.log("getDepositFee error", error);
|
|
3807
3817
|
}).finally(() => {
|
|
3808
3818
|
setDepositFeeRevalidating(false);
|
|
3809
3819
|
});
|