@bze/bze-ui-kit 0.6.1 → 1.0.1
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 +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +74 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -19
package/dist/index.d.mts
CHANGED
|
@@ -50,8 +50,7 @@ import * as _bze_bzejs_cosmos_distribution_v1beta1_distribution from '@bze/bzejs
|
|
|
50
50
|
import * as _bze_bzejs_cosmos_distribution_v1beta1_query from '@bze/bzejs/cosmos/distribution/v1beta1/query';
|
|
51
51
|
import * as react from 'react';
|
|
52
52
|
import { PropsWithChildren } from 'react';
|
|
53
|
-
import { DeliverTxResponse } from '@
|
|
54
|
-
import { StdFee, EncodeObject } from 'interchainjs/types';
|
|
53
|
+
import { StdFee, DeliverTxResponse, EncodeObject } from '@bze/bzejs/types';
|
|
55
54
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
56
55
|
import { TextProps } from '@chakra-ui/react';
|
|
57
56
|
|
|
@@ -1029,10 +1028,8 @@ declare function useConnectionType(): {
|
|
|
1029
1028
|
|
|
1030
1029
|
interface UseSigningClientProps {
|
|
1031
1030
|
chainName?: string;
|
|
1032
|
-
isIbc?: boolean;
|
|
1033
|
-
isCosmos?: boolean;
|
|
1034
1031
|
}
|
|
1035
|
-
declare const useSigningClient: ({ chainName
|
|
1032
|
+
declare const useSigningClient: ({ chainName }: UseSigningClientProps) => {
|
|
1036
1033
|
signingClientError: unknown;
|
|
1037
1034
|
signingClient: unknown;
|
|
1038
1035
|
isSigningClientReady: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -50,8 +50,7 @@ import * as _bze_bzejs_cosmos_distribution_v1beta1_distribution from '@bze/bzejs
|
|
|
50
50
|
import * as _bze_bzejs_cosmos_distribution_v1beta1_query from '@bze/bzejs/cosmos/distribution/v1beta1/query';
|
|
51
51
|
import * as react from 'react';
|
|
52
52
|
import { PropsWithChildren } from 'react';
|
|
53
|
-
import { DeliverTxResponse } from '@
|
|
54
|
-
import { StdFee, EncodeObject } from 'interchainjs/types';
|
|
53
|
+
import { StdFee, DeliverTxResponse, EncodeObject } from '@bze/bzejs/types';
|
|
55
54
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
56
55
|
import { TextProps } from '@chakra-ui/react';
|
|
57
56
|
|
|
@@ -1029,10 +1028,8 @@ declare function useConnectionType(): {
|
|
|
1029
1028
|
|
|
1030
1029
|
interface UseSigningClientProps {
|
|
1031
1030
|
chainName?: string;
|
|
1032
|
-
isIbc?: boolean;
|
|
1033
|
-
isCosmos?: boolean;
|
|
1034
1031
|
}
|
|
1035
|
-
declare const useSigningClient: ({ chainName
|
|
1032
|
+
declare const useSigningClient: ({ chainName }: UseSigningClientProps) => {
|
|
1036
1033
|
signingClientError: unknown;
|
|
1037
1034
|
signingClient: unknown;
|
|
1038
1035
|
isSigningClientReady: boolean;
|
package/dist/index.js
CHANGED
|
@@ -3319,99 +3319,17 @@ function useConnectionType() {
|
|
|
3319
3319
|
}
|
|
3320
3320
|
|
|
3321
3321
|
// src/hooks/useSigningClient.ts
|
|
3322
|
-
var import_bzejs4 = require("@bze/bzejs");
|
|
3323
|
-
var import_react4 = require("react");
|
|
3324
|
-
var import_react5 = require("@interchain-kit/react");
|
|
3325
|
-
|
|
3326
|
-
// src/hooks/useSettings.ts
|
|
3327
3322
|
var import_react3 = require("react");
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
const
|
|
3323
|
+
var import_react4 = require("@interchain-kit/react");
|
|
3324
|
+
var useSigningClient = ({ chainName }) => {
|
|
3325
|
+
const { getSigningClient, signingClientError, wallet, chain } = (0, import_react4.useChain)(chainName != null ? chainName : getChainName());
|
|
3326
|
+
const [signingClient, setSigningClient] = (0, import_react3.useState)(null);
|
|
3327
|
+
const [isSigningClientReady, setIsSigningClientReady] = (0, import_react3.useState)(false);
|
|
3328
|
+
const hasInitialized = (0, import_react3.useRef)(false);
|
|
3329
|
+
const createSigningClient = (0, import_react3.useCallback)(async () => {
|
|
3330
|
+
return getSigningClient();
|
|
3331
|
+
}, [getSigningClient]);
|
|
3331
3332
|
(0, import_react3.useEffect)(() => {
|
|
3332
|
-
setSettingsState(getSettings());
|
|
3333
|
-
setIsLoaded(true);
|
|
3334
|
-
}, []);
|
|
3335
|
-
const saveSettings = (0, import_react3.useCallback)((newSettings) => {
|
|
3336
|
-
setSettings(newSettings);
|
|
3337
|
-
setSettingsState(newSettings);
|
|
3338
|
-
return true;
|
|
3339
|
-
}, []);
|
|
3340
|
-
const updateEndpoints = (0, import_react3.useCallback)((endpoints) => {
|
|
3341
|
-
const newSettings = __spreadProps(__spreadValues({}, settings), { endpoints });
|
|
3342
|
-
return saveSettings(newSettings);
|
|
3343
|
-
}, [settings, saveSettings]);
|
|
3344
|
-
const updatePreferredFeeDenom = (0, import_react3.useCallback)((preferredFeeDenom) => {
|
|
3345
|
-
const newSettings = __spreadProps(__spreadValues({}, settings), { preferredFeeDenom });
|
|
3346
|
-
return saveSettings(newSettings);
|
|
3347
|
-
}, [settings, saveSettings]);
|
|
3348
|
-
const resetToDefaults = (0, import_react3.useCallback)(() => {
|
|
3349
|
-
saveSettings(DEFAULT_SETTINGS);
|
|
3350
|
-
return true;
|
|
3351
|
-
}, [saveSettings]);
|
|
3352
|
-
const getEndpoints = (0, import_react3.useCallback)(() => {
|
|
3353
|
-
return settings.endpoints;
|
|
3354
|
-
}, [settings.endpoints]);
|
|
3355
|
-
const defaultSettings = (0, import_react3.useMemo)(() => DEFAULT_SETTINGS, []);
|
|
3356
|
-
const feeDenom = (0, import_react3.useMemo)(() => settings.preferredFeeDenom || getChainNativeAssetDenom(), [settings.preferredFeeDenom]);
|
|
3357
|
-
return {
|
|
3358
|
-
settings,
|
|
3359
|
-
isLoaded,
|
|
3360
|
-
saveSettings,
|
|
3361
|
-
updateEndpoints,
|
|
3362
|
-
updatePreferredFeeDenom,
|
|
3363
|
-
resetToDefaults,
|
|
3364
|
-
getEndpoints,
|
|
3365
|
-
defaultSettings,
|
|
3366
|
-
feeDenom
|
|
3367
|
-
};
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
// src/hooks/useSigningClient.ts
|
|
3371
|
-
var useSigningClient = ({ chainName, isIbc, isCosmos }) => {
|
|
3372
|
-
const { getSigningClient, signingClientError, wallet, chain } = (0, import_react5.useChain)(chainName != null ? chainName : getChainName());
|
|
3373
|
-
const [signingClient, setSigningClient] = (0, import_react4.useState)(null);
|
|
3374
|
-
const [isSigningClientReady, setIsSigningClientReady] = (0, import_react4.useState)(false);
|
|
3375
|
-
const { settings } = useSettings();
|
|
3376
|
-
const hasInitialized = (0, import_react4.useRef)(false);
|
|
3377
|
-
const defaultChainName = (0, import_react4.useMemo)(() => getChainName(), []);
|
|
3378
|
-
const createSigningClient = (0, import_react4.useCallback)(async () => {
|
|
3379
|
-
var _a2;
|
|
3380
|
-
const signingResult = await getSigningClient();
|
|
3381
|
-
const offlineSigner = signingResult == null ? void 0 : signingResult.offlineSigner;
|
|
3382
|
-
const rpcEndpoint = settings.endpoints.rpcEndpoint.replace("wss://", "https://").replace("ws://", "http://");
|
|
3383
|
-
if (!offlineSigner) {
|
|
3384
|
-
return;
|
|
3385
|
-
}
|
|
3386
|
-
let clientFn = import_bzejs4.getSigningBzeClient;
|
|
3387
|
-
if (isIbc) {
|
|
3388
|
-
clientFn = import_bzejs4.getSigningIbcClient;
|
|
3389
|
-
} else if (isCosmos) {
|
|
3390
|
-
clientFn = import_bzejs4.getSigningCosmosClient;
|
|
3391
|
-
}
|
|
3392
|
-
const signer = (_a2 = offlineSigner == null ? void 0 : offlineSigner.offlineSigner) != null ? _a2 : offlineSigner;
|
|
3393
|
-
const getRpcForChain = (name) => {
|
|
3394
|
-
switch (name) {
|
|
3395
|
-
case "archway":
|
|
3396
|
-
return getArchwayRpcURL();
|
|
3397
|
-
case "osmosis":
|
|
3398
|
-
return getOsmosisRpcUrl();
|
|
3399
|
-
case "noble":
|
|
3400
|
-
return getNobleRpcUrl();
|
|
3401
|
-
case "jackal":
|
|
3402
|
-
return getJackalRpcUrl();
|
|
3403
|
-
case "omniflixhub":
|
|
3404
|
-
return getOmniFlixRpcUrl();
|
|
3405
|
-
case "atomone":
|
|
3406
|
-
return getAtomOneRpcUrl();
|
|
3407
|
-
default:
|
|
3408
|
-
return rpcEndpoint;
|
|
3409
|
-
}
|
|
3410
|
-
};
|
|
3411
|
-
const endpoint = chainName && chainName !== defaultChainName ? getRpcForChain(chainName) : rpcEndpoint;
|
|
3412
|
-
return clientFn({ rpcEndpoint: endpoint, signer });
|
|
3413
|
-
}, [getSigningClient, settings.endpoints.rpcEndpoint, isIbc, isCosmos, chainName, defaultChainName]);
|
|
3414
|
-
(0, import_react4.useEffect)(() => {
|
|
3415
3333
|
if (!wallet || !chain || hasInitialized.current) {
|
|
3416
3334
|
return;
|
|
3417
3335
|
}
|
|
@@ -3433,12 +3351,12 @@ var useSigningClient = ({ chainName, isIbc, isCosmos }) => {
|
|
|
3433
3351
|
};
|
|
3434
3352
|
|
|
3435
3353
|
// src/hooks/usePrices.ts
|
|
3436
|
-
var
|
|
3354
|
+
var import_react5 = require("react");
|
|
3437
3355
|
function useAssetPrice(denom) {
|
|
3438
3356
|
const { usdPricesMap, marketsDataMap, isLoadingPrices } = useAssetsContext();
|
|
3439
|
-
const usdDenom = (0,
|
|
3440
|
-
const bzeDenom = (0,
|
|
3441
|
-
const change = (0,
|
|
3357
|
+
const usdDenom = (0, import_react5.useMemo)(() => getUSDCDenom(), []);
|
|
3358
|
+
const bzeDenom = (0, import_react5.useMemo)(() => getChainNativeAssetDenom(), []);
|
|
3359
|
+
const change = (0, import_react5.useMemo)(() => {
|
|
3442
3360
|
const marketData = marketsDataMap.get(createMarketId(denom, usdDenom));
|
|
3443
3361
|
if (marketData) {
|
|
3444
3362
|
return marketData.change;
|
|
@@ -3449,20 +3367,20 @@ function useAssetPrice(denom) {
|
|
|
3449
3367
|
}
|
|
3450
3368
|
return 0;
|
|
3451
3369
|
}, [marketsDataMap, denom, usdDenom, bzeDenom]);
|
|
3452
|
-
const price = (0,
|
|
3370
|
+
const price = (0, import_react5.useMemo)(() => {
|
|
3453
3371
|
const zeroBN = toBigNumber(0);
|
|
3454
3372
|
if (denom === "") return zeroBN;
|
|
3455
3373
|
if (denom === usdDenom) return toBigNumber(1);
|
|
3456
3374
|
return usdPricesMap.get(denom) || zeroBN;
|
|
3457
3375
|
}, [usdPricesMap, denom, usdDenom]);
|
|
3458
|
-
const totalUsdValue = (0,
|
|
3376
|
+
const totalUsdValue = (0, import_react5.useCallback)((amount) => {
|
|
3459
3377
|
return price.multipliedBy(amount);
|
|
3460
3378
|
}, [price]);
|
|
3461
|
-
const uAmountUsdValue = (0,
|
|
3379
|
+
const uAmountUsdValue = (0, import_react5.useCallback)((amount, decimals) => {
|
|
3462
3380
|
return totalUsdValue(uAmountToBigNumberAmount(amount, decimals));
|
|
3463
3381
|
}, [totalUsdValue]);
|
|
3464
|
-
const isUSDC = (0,
|
|
3465
|
-
const hasPrice = (0,
|
|
3382
|
+
const isUSDC = (0, import_react5.useMemo)(() => denom === usdDenom, [denom, usdDenom]);
|
|
3383
|
+
const hasPrice = (0, import_react5.useMemo)(() => price.gt(0), [price]);
|
|
3466
3384
|
return {
|
|
3467
3385
|
price,
|
|
3468
3386
|
change,
|
|
@@ -3474,6 +3392,50 @@ function useAssetPrice(denom) {
|
|
|
3474
3392
|
};
|
|
3475
3393
|
}
|
|
3476
3394
|
|
|
3395
|
+
// src/hooks/useSettings.ts
|
|
3396
|
+
var import_react6 = require("react");
|
|
3397
|
+
function useSettings() {
|
|
3398
|
+
const [settings, setSettingsState] = (0, import_react6.useState)(DEFAULT_SETTINGS);
|
|
3399
|
+
const [isLoaded, setIsLoaded] = (0, import_react6.useState)(false);
|
|
3400
|
+
(0, import_react6.useEffect)(() => {
|
|
3401
|
+
setSettingsState(getSettings());
|
|
3402
|
+
setIsLoaded(true);
|
|
3403
|
+
}, []);
|
|
3404
|
+
const saveSettings = (0, import_react6.useCallback)((newSettings) => {
|
|
3405
|
+
setSettings(newSettings);
|
|
3406
|
+
setSettingsState(newSettings);
|
|
3407
|
+
return true;
|
|
3408
|
+
}, []);
|
|
3409
|
+
const updateEndpoints = (0, import_react6.useCallback)((endpoints) => {
|
|
3410
|
+
const newSettings = __spreadProps(__spreadValues({}, settings), { endpoints });
|
|
3411
|
+
return saveSettings(newSettings);
|
|
3412
|
+
}, [settings, saveSettings]);
|
|
3413
|
+
const updatePreferredFeeDenom = (0, import_react6.useCallback)((preferredFeeDenom) => {
|
|
3414
|
+
const newSettings = __spreadProps(__spreadValues({}, settings), { preferredFeeDenom });
|
|
3415
|
+
return saveSettings(newSettings);
|
|
3416
|
+
}, [settings, saveSettings]);
|
|
3417
|
+
const resetToDefaults = (0, import_react6.useCallback)(() => {
|
|
3418
|
+
saveSettings(DEFAULT_SETTINGS);
|
|
3419
|
+
return true;
|
|
3420
|
+
}, [saveSettings]);
|
|
3421
|
+
const getEndpoints = (0, import_react6.useCallback)(() => {
|
|
3422
|
+
return settings.endpoints;
|
|
3423
|
+
}, [settings.endpoints]);
|
|
3424
|
+
const defaultSettings = (0, import_react6.useMemo)(() => DEFAULT_SETTINGS, []);
|
|
3425
|
+
const feeDenom = (0, import_react6.useMemo)(() => settings.preferredFeeDenom || getChainNativeAssetDenom(), [settings.preferredFeeDenom]);
|
|
3426
|
+
return {
|
|
3427
|
+
settings,
|
|
3428
|
+
isLoaded,
|
|
3429
|
+
saveSettings,
|
|
3430
|
+
updateEndpoints,
|
|
3431
|
+
updatePreferredFeeDenom,
|
|
3432
|
+
resetToDefaults,
|
|
3433
|
+
getEndpoints,
|
|
3434
|
+
defaultSettings,
|
|
3435
|
+
feeDenom
|
|
3436
|
+
};
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3477
3439
|
// src/hooks/useBalances.ts
|
|
3478
3440
|
var import_bignumber8 = __toESM(require("bignumber.js"));
|
|
3479
3441
|
var import_react7 = require("react");
|
|
@@ -4065,10 +4027,10 @@ var useToast = () => {
|
|
|
4065
4027
|
};
|
|
4066
4028
|
|
|
4067
4029
|
// src/hooks/useTx.tsx
|
|
4068
|
-
var import_stargate = require("@cosmjs/stargate");
|
|
4069
4030
|
var import_react15 = require("@interchain-kit/react");
|
|
4070
4031
|
var import_bignumber13 = __toESM(require("bignumber.js"));
|
|
4071
4032
|
var import_react16 = require("react");
|
|
4033
|
+
var coins = (amount, denom) => [{ amount: String(amount), denom }];
|
|
4072
4034
|
var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
4073
4035
|
TxStatus2["Failed"] = "Transaction Failed";
|
|
4074
4036
|
TxStatus2["Successful"] = "Transaction Successful";
|
|
@@ -4076,34 +4038,34 @@ var TxStatus = /* @__PURE__ */ ((TxStatus2) => {
|
|
|
4076
4038
|
return TxStatus2;
|
|
4077
4039
|
})(TxStatus || {});
|
|
4078
4040
|
var defaultFee = {
|
|
4079
|
-
amount:
|
|
4041
|
+
amount: coins(2e4, getChainNativeAssetDenom()),
|
|
4080
4042
|
gas: "500000"
|
|
4081
4043
|
};
|
|
4082
4044
|
var useSDKTx = (chainName) => {
|
|
4083
|
-
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName()
|
|
4045
|
+
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName());
|
|
4084
4046
|
return {
|
|
4085
4047
|
tx,
|
|
4086
4048
|
progressTrack
|
|
4087
4049
|
};
|
|
4088
4050
|
};
|
|
4089
4051
|
var useBZETx = () => {
|
|
4090
|
-
const { tx, progressTrack } = useTx(getChainName()
|
|
4052
|
+
const { tx, progressTrack } = useTx(getChainName());
|
|
4091
4053
|
return {
|
|
4092
4054
|
tx,
|
|
4093
4055
|
progressTrack
|
|
4094
4056
|
};
|
|
4095
4057
|
};
|
|
4096
4058
|
var useIBCTx = (chainName) => {
|
|
4097
|
-
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName()
|
|
4059
|
+
const { tx, progressTrack } = useTx(chainName != null ? chainName : getChainName());
|
|
4098
4060
|
return {
|
|
4099
4061
|
tx,
|
|
4100
4062
|
progressTrack
|
|
4101
4063
|
};
|
|
4102
4064
|
};
|
|
4103
|
-
var useTx = (chainName
|
|
4065
|
+
var useTx = (chainName) => {
|
|
4104
4066
|
const { address, disconnect } = (0, import_react15.useChain)(chainName);
|
|
4105
4067
|
const { toast } = useToast();
|
|
4106
|
-
const { signingClient, isSigningClientReady, signingClientError } = useSigningClient({ chainName
|
|
4068
|
+
const { signingClient, isSigningClientReady, signingClientError } = useSigningClient({ chainName });
|
|
4107
4069
|
const [progressTrack, setProgressTrack] = (0, import_react16.useState)("");
|
|
4108
4070
|
const { getDenomsPool } = useLiquidityPools();
|
|
4109
4071
|
const { feeDenom } = useSettings();
|
|
@@ -4122,7 +4084,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
4122
4084
|
const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
|
|
4123
4085
|
const gasPayment = gasAmount.multipliedBy(gasPrice);
|
|
4124
4086
|
const nativeFee = {
|
|
4125
|
-
amount:
|
|
4087
|
+
amount: coins(gasPayment.toFixed(0).toString(), nativeDenom),
|
|
4126
4088
|
gas: gasAmount.toFixed(0)
|
|
4127
4089
|
};
|
|
4128
4090
|
if (feeDenom === nativeDenom) {
|
|
@@ -4141,7 +4103,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
4141
4103
|
expectedAmount = toBigNumber(1).dividedBy(pool.fee).integerValue(import_bignumber13.default.ROUND_CEIL);
|
|
4142
4104
|
}
|
|
4143
4105
|
return {
|
|
4144
|
-
amount:
|
|
4106
|
+
amount: coins(expectedAmount.toFixed(0).toString(), feeDenom),
|
|
4145
4107
|
gas: gasAmount.multipliedBy(1.5).toFixed(0)
|
|
4146
4108
|
};
|
|
4147
4109
|
}, [signingClient, address, feeDenom, getDenomsPool]);
|
|
@@ -4180,7 +4142,7 @@ var useTx = (chainName, isCosmos, isIBC) => {
|
|
|
4180
4142
|
const fee = await getFee(msgs, options);
|
|
4181
4143
|
setProgressTrack("Signing transaction");
|
|
4182
4144
|
const resp = await signingClient.signAndBroadcast(address, msgs, fee, (_a2 = options == null ? void 0 : options.memo) != null ? _a2 : DEFAULT_TX_MEMO);
|
|
4183
|
-
if (
|
|
4145
|
+
if (resp.code === 0) {
|
|
4184
4146
|
setProgressTrack("Transaction sent");
|
|
4185
4147
|
toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
|
|
4186
4148
|
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${resp.transactionHash}`);
|
|
@@ -4755,7 +4717,7 @@ var import_lu3 = require("react-icons/lu");
|
|
|
4755
4717
|
var import_react27 = require("react");
|
|
4756
4718
|
var import_core = require("@interchain-kit/core");
|
|
4757
4719
|
var import_bignumber14 = __toESM(require("bignumber.js"));
|
|
4758
|
-
var
|
|
4720
|
+
var import_bzejs4 = require("@bze/bzejs");
|
|
4759
4721
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
4760
4722
|
var validateAmount = (amount, coin, onError) => {
|
|
4761
4723
|
if (!coin) return;
|
|
@@ -4870,7 +4832,7 @@ var SendForm = ({ balances, onClose, selectedTicker, accentColor }) => {
|
|
|
4870
4832
|
toast.error("Wallet not connected!", "Please connect your wallet first.");
|
|
4871
4833
|
return;
|
|
4872
4834
|
}
|
|
4873
|
-
const { send } =
|
|
4835
|
+
const { send } = import_bzejs4.cosmos.bank.v1beta1.MessageComposer.withTypeUrl;
|
|
4874
4836
|
const msg = send({
|
|
4875
4837
|
fromAddress: address,
|
|
4876
4838
|
toAddress: recipient,
|