@bze/bze-ui-kit 1.0.3 → 1.0.4
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.js +108 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3353,6 +3353,104 @@ function useConnectionType() {
|
|
|
3353
3353
|
// src/hooks/useSigningClient.ts
|
|
3354
3354
|
var import_react3 = require("react");
|
|
3355
3355
|
var import_react4 = require("@interchain-kit/react");
|
|
3356
|
+
|
|
3357
|
+
// src/utils/signing_client_setup.ts
|
|
3358
|
+
var import_tx = require("@bze/bzejs/bze/tradebin/tx");
|
|
3359
|
+
var import_tx2 = require("@bze/bzejs/bze/rewards/tx");
|
|
3360
|
+
var import_tx3 = require("@bze/bzejs/bze/burner/tx");
|
|
3361
|
+
var import_tx4 = require("@bze/bzejs/bze/tokenfactory/tx");
|
|
3362
|
+
var import_tx5 = require("@bze/bzejs/bze/cointrunk/tx");
|
|
3363
|
+
var import_tx6 = require("@bze/bzejs/cosmos/bank/v1beta1/tx");
|
|
3364
|
+
var import_tx7 = require("@bze/bzejs/cosmos/staking/v1beta1/tx");
|
|
3365
|
+
var import_tx8 = require("@bze/bzejs/cosmos/distribution/v1beta1/tx");
|
|
3366
|
+
var import_tx9 = require("@bze/bzejs/cosmos/gov/v1/tx");
|
|
3367
|
+
var import_tx10 = require("@bze/bzejs/cosmos/authz/v1beta1/tx");
|
|
3368
|
+
var import_tx11 = require("@bze/bzejs/cosmos/feegrant/v1beta1/tx");
|
|
3369
|
+
var import_tx12 = require("@bze/bzejs/ibc/applications/transfer/v1/tx");
|
|
3370
|
+
var toEncoder = (g) => ({
|
|
3371
|
+
typeUrl: g.typeUrl,
|
|
3372
|
+
fromPartial: g.fromPartial,
|
|
3373
|
+
encode: (data) => {
|
|
3374
|
+
const encoded = g.encode(g.fromPartial(data));
|
|
3375
|
+
return encoded.finish ? encoded.finish() : encoded;
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
var toConverter = (g) => ({
|
|
3379
|
+
typeUrl: g.typeUrl,
|
|
3380
|
+
aminoType: g.aminoType,
|
|
3381
|
+
fromAmino: g.fromAmino,
|
|
3382
|
+
toAmino: g.toAmino
|
|
3383
|
+
});
|
|
3384
|
+
var ALL_MSG_TYPES = [
|
|
3385
|
+
// BZE tradebin
|
|
3386
|
+
import_tx.MsgCreateMarket,
|
|
3387
|
+
import_tx.MsgCreateOrder,
|
|
3388
|
+
import_tx.MsgCancelOrder,
|
|
3389
|
+
import_tx.MsgFillOrders,
|
|
3390
|
+
import_tx.MsgCreateLiquidityPool,
|
|
3391
|
+
import_tx.MsgAddLiquidity,
|
|
3392
|
+
import_tx.MsgRemoveLiquidity,
|
|
3393
|
+
import_tx.MsgMultiSwap,
|
|
3394
|
+
// BZE rewards
|
|
3395
|
+
import_tx2.MsgCreateStakingReward,
|
|
3396
|
+
import_tx2.MsgUpdateStakingReward,
|
|
3397
|
+
import_tx2.MsgJoinStaking,
|
|
3398
|
+
import_tx2.MsgExitStaking,
|
|
3399
|
+
import_tx2.MsgClaimStakingRewards,
|
|
3400
|
+
import_tx2.MsgCreateTradingReward,
|
|
3401
|
+
import_tx2.MsgActivateTradingReward,
|
|
3402
|
+
// BZE burner
|
|
3403
|
+
import_tx3.MsgFundBurner,
|
|
3404
|
+
import_tx3.MsgStartRaffle,
|
|
3405
|
+
import_tx3.MsgJoinRaffle,
|
|
3406
|
+
// BZE tokenfactory
|
|
3407
|
+
import_tx4.MsgCreateDenom,
|
|
3408
|
+
import_tx4.MsgMint,
|
|
3409
|
+
import_tx4.MsgBurn,
|
|
3410
|
+
import_tx4.MsgChangeAdmin,
|
|
3411
|
+
import_tx4.MsgSetDenomMetadata,
|
|
3412
|
+
// BZE cointrunk
|
|
3413
|
+
import_tx5.MsgAddArticle,
|
|
3414
|
+
import_tx5.MsgPayPublisherRespect,
|
|
3415
|
+
import_tx5.MsgAcceptDomain,
|
|
3416
|
+
import_tx5.MsgSavePublisher,
|
|
3417
|
+
// Cosmos bank
|
|
3418
|
+
import_tx6.MsgSend,
|
|
3419
|
+
import_tx6.MsgMultiSend,
|
|
3420
|
+
// Cosmos staking
|
|
3421
|
+
import_tx7.MsgDelegate,
|
|
3422
|
+
import_tx7.MsgUndelegate,
|
|
3423
|
+
import_tx7.MsgBeginRedelegate,
|
|
3424
|
+
import_tx7.MsgCancelUnbondingDelegation,
|
|
3425
|
+
// Cosmos distribution
|
|
3426
|
+
import_tx8.MsgSetWithdrawAddress,
|
|
3427
|
+
import_tx8.MsgWithdrawDelegatorReward,
|
|
3428
|
+
import_tx8.MsgWithdrawValidatorCommission,
|
|
3429
|
+
import_tx8.MsgFundCommunityPool,
|
|
3430
|
+
// Cosmos gov
|
|
3431
|
+
import_tx9.MsgSubmitProposal,
|
|
3432
|
+
import_tx9.MsgVote,
|
|
3433
|
+
import_tx9.MsgVoteWeighted,
|
|
3434
|
+
import_tx9.MsgDeposit,
|
|
3435
|
+
import_tx9.MsgCancelProposal,
|
|
3436
|
+
// Cosmos authz
|
|
3437
|
+
import_tx10.MsgGrant,
|
|
3438
|
+
import_tx10.MsgExec,
|
|
3439
|
+
import_tx10.MsgRevoke,
|
|
3440
|
+
// Cosmos feegrant
|
|
3441
|
+
import_tx11.MsgGrantAllowance,
|
|
3442
|
+
import_tx11.MsgRevokeAllowance,
|
|
3443
|
+
// IBC transfer
|
|
3444
|
+
import_tx12.MsgTransfer
|
|
3445
|
+
];
|
|
3446
|
+
var registerBzeEncoders = (client) => {
|
|
3447
|
+
var _a2, _b2;
|
|
3448
|
+
if (!client) return;
|
|
3449
|
+
(_a2 = client.addEncoders) == null ? void 0 : _a2.call(client, ALL_MSG_TYPES.map(toEncoder));
|
|
3450
|
+
(_b2 = client.addConverters) == null ? void 0 : _b2.call(client, ALL_MSG_TYPES.map(toConverter));
|
|
3451
|
+
};
|
|
3452
|
+
|
|
3453
|
+
// src/hooks/useSigningClient.ts
|
|
3356
3454
|
var useSigningClient = ({ chainName }) => {
|
|
3357
3455
|
const { getSigningClient, signingClientError, wallet, chain } = (0, import_react4.useChain)(chainName != null ? chainName : getChainName());
|
|
3358
3456
|
const [signingClient, setSigningClient] = (0, import_react3.useState)(null);
|
|
@@ -3368,6 +3466,7 @@ var useSigningClient = ({ chainName }) => {
|
|
|
3368
3466
|
const load = async () => {
|
|
3369
3467
|
const client = await createSigningClient();
|
|
3370
3468
|
if (client) {
|
|
3469
|
+
registerBzeEncoders(client);
|
|
3371
3470
|
setSigningClient(client);
|
|
3372
3471
|
setIsSigningClientReady(true);
|
|
3373
3472
|
hasInitialized.current = true;
|
|
@@ -4059,7 +4158,7 @@ var useToast = () => {
|
|
|
4059
4158
|
};
|
|
4060
4159
|
|
|
4061
4160
|
// src/hooks/useTx.tsx
|
|
4062
|
-
var
|
|
4161
|
+
var import_tx13 = require("@bze/bzejs/cosmos/tx/v1beta1/tx");
|
|
4063
4162
|
var import_react15 = require("@interchain-kit/react");
|
|
4064
4163
|
var import_bignumber13 = __toESM(require("bignumber.js"));
|
|
4065
4164
|
var import_react16 = require("react");
|
|
@@ -4120,8 +4219,8 @@ var useTx = (chainName) => {
|
|
|
4120
4219
|
const encodedValue = typeof (encodedWriter == null ? void 0 : encodedWriter.finish) === "function" ? encodedWriter.finish() : encodedWriter;
|
|
4121
4220
|
return { typeUrl, value: encodedValue };
|
|
4122
4221
|
});
|
|
4123
|
-
const txBody =
|
|
4124
|
-
const signerInfo =
|
|
4222
|
+
const txBody = import_tx13.TxBody.fromPartial({ messages: encodedMessages, memo: memo != null ? memo : "" });
|
|
4223
|
+
const signerInfo = import_tx13.SignerInfo.fromPartial({ modeInfo: { single: { mode: 1 } }, sequence: BigInt(0) });
|
|
4125
4224
|
const { gasInfo } = await signer.simulateByTxBody(txBody, [signerInfo]);
|
|
4126
4225
|
const gasEstimated = Number((_a2 = gasInfo == null ? void 0 : gasInfo.gasUsed) != null ? _a2 : BigInt(0));
|
|
4127
4226
|
const gasAmount = (0, import_bignumber13.default)(gasEstimated).multipliedBy(1.5);
|
|
@@ -4184,11 +4283,14 @@ var useTx = (chainName) => {
|
|
|
4184
4283
|
try {
|
|
4185
4284
|
const fee = await getFee(msgs, options);
|
|
4186
4285
|
setProgressTrack("Signing transaction");
|
|
4187
|
-
const
|
|
4188
|
-
|
|
4286
|
+
const broadcastResult = await signingClient.signAndBroadcast(address, msgs, fee, (_a2 = options == null ? void 0 : options.memo) != null ? _a2 : DEFAULT_TX_MEMO);
|
|
4287
|
+
setProgressTrack("Waiting for confirmation");
|
|
4288
|
+
const resp = await broadcastResult.wait();
|
|
4289
|
+
const txHash = (resp == null ? void 0 : resp.txhash) || broadcastResult.transactionHash;
|
|
4290
|
+
if ((resp == null ? void 0 : resp.code) === 0) {
|
|
4189
4291
|
setProgressTrack("Transaction sent");
|
|
4190
4292
|
toast.clickableSuccess("Transaction Successful" /* Successful */, () => {
|
|
4191
|
-
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${
|
|
4293
|
+
openExternalLink(`${getChainExplorerURL(chainName != null ? chainName : defaultChainName)}/tx/${txHash}`);
|
|
4192
4294
|
}, "View in Explorer");
|
|
4193
4295
|
if (options == null ? void 0 : options.onSuccess) {
|
|
4194
4296
|
options.onSuccess(resp);
|