@bze/bze-ui-kit 1.0.7 → 1.0.8
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 +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +90 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -603,12 +603,82 @@ function truncateDenom(denom) {
|
|
|
603
603
|
}
|
|
604
604
|
var isIbcAsset = (asset) => asset.type === ASSET_TYPE_IBC;
|
|
605
605
|
|
|
606
|
+
// src/utils/coins.ts
|
|
607
|
+
var coin = (amount, denom) => {
|
|
608
|
+
let outAmount;
|
|
609
|
+
if (typeof amount === "number") {
|
|
610
|
+
if (!Number.isInteger(amount) || amount < 0 || amount > Number.MAX_SAFE_INTEGER) {
|
|
611
|
+
throw new Error("Given amount is not a safe integer. Consider using a string instead to overcome the limitations of JS numbers.");
|
|
612
|
+
}
|
|
613
|
+
outAmount = String(amount);
|
|
614
|
+
} else {
|
|
615
|
+
if (!amount.match(/^[0-9]+$/)) {
|
|
616
|
+
throw new Error("Invalid unsigned integer string format");
|
|
617
|
+
}
|
|
618
|
+
outAmount = amount.replace(/^0*/, "") || "0";
|
|
619
|
+
}
|
|
620
|
+
return { amount: outAmount, denom };
|
|
621
|
+
};
|
|
622
|
+
var coins = (amount, denom) => {
|
|
623
|
+
return [coin(amount, denom)];
|
|
624
|
+
};
|
|
625
|
+
var parseCoins = (input) => {
|
|
626
|
+
return input.replace(/\s/g, "").split(",").filter(Boolean).map((part) => {
|
|
627
|
+
const match = part.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/:._-]{2,127})$/);
|
|
628
|
+
if (!match) throw new Error("Got an invalid coin string");
|
|
629
|
+
return {
|
|
630
|
+
amount: match[1].replace(/^0+/, "") || "0",
|
|
631
|
+
denom: match[2]
|
|
632
|
+
};
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
|
|
606
636
|
// src/utils/events.ts
|
|
607
637
|
var getMarketOrderBookChangedEvent = (marketId) => getMarketEventKey(ORDER_BOOK_CHANGED_EVENT, marketId);
|
|
608
638
|
var getMarketEventKey = (eventType, marketId) => `${eventType}:${marketId}`;
|
|
609
639
|
var mapEventAttributes = (attributes) => {
|
|
610
640
|
return attributes.reduce((acc, attr) => __spreadProps(__spreadValues({}, acc), { [attr.key]: attr.value.replace('"', "").replace('"', "") }), {});
|
|
611
641
|
};
|
|
642
|
+
var getEventKeyValue = (event, key) => {
|
|
643
|
+
var _a2;
|
|
644
|
+
return (_a2 = event.attributes.find((attribute) => attribute.key === key)) == null ? void 0 : _a2.value;
|
|
645
|
+
};
|
|
646
|
+
var getEventMarketId = (event) => {
|
|
647
|
+
var _a2;
|
|
648
|
+
return (_a2 = getEventKeyValue(event, "market_id")) == null ? void 0 : _a2.replaceAll('"', "");
|
|
649
|
+
};
|
|
650
|
+
var isAddressTransfer = (address, event) => {
|
|
651
|
+
if (address === "" || event.type !== "transfer") return false;
|
|
652
|
+
return event.attributes.find((attribute) => attribute.value === address) !== void 0;
|
|
653
|
+
};
|
|
654
|
+
var isOrderBookEvent = (event) => {
|
|
655
|
+
return event.type.includes("bze.tradebin.Order");
|
|
656
|
+
};
|
|
657
|
+
var isOrderExecutedEvent = (event) => {
|
|
658
|
+
return event.type.includes("bze.tradebin.OrderExecutedEvent");
|
|
659
|
+
};
|
|
660
|
+
var isSwapEvent = (event) => {
|
|
661
|
+
return event.type.includes("bze.tradebin.SwapEvent");
|
|
662
|
+
};
|
|
663
|
+
var isCoinbaseEvent = (event) => {
|
|
664
|
+
return event.type.includes("coinbase");
|
|
665
|
+
};
|
|
666
|
+
var isBurnEvent = (event) => {
|
|
667
|
+
return event.type.includes("burn");
|
|
668
|
+
};
|
|
669
|
+
var isEpochStartEvent = (event) => {
|
|
670
|
+
return event.type.includes("bze.epochs.EpochStartEvent");
|
|
671
|
+
};
|
|
672
|
+
var getMintedAmount = (event) => {
|
|
673
|
+
const defaultCoin = coins(0, getChainNativeAssetDenom());
|
|
674
|
+
try {
|
|
675
|
+
const amountAttribute = event.attributes.find((attribute) => attribute.key === "amount");
|
|
676
|
+
return amountAttribute ? parseCoins(amountAttribute.value) : defaultCoin;
|
|
677
|
+
} catch (e) {
|
|
678
|
+
console.error("Failed to parse minted amount from coinbase event", e);
|
|
679
|
+
return defaultCoin;
|
|
680
|
+
}
|
|
681
|
+
};
|
|
612
682
|
|
|
613
683
|
// src/utils/formatter.ts
|
|
614
684
|
import BigNumber2 from "bignumber.js";
|
|
@@ -723,36 +793,6 @@ var openExternalLink = (url) => {
|
|
|
723
793
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
724
794
|
};
|
|
725
795
|
|
|
726
|
-
// src/utils/coins.ts
|
|
727
|
-
var coin = (amount, denom) => {
|
|
728
|
-
let outAmount;
|
|
729
|
-
if (typeof amount === "number") {
|
|
730
|
-
if (!Number.isInteger(amount) || amount < 0 || amount > Number.MAX_SAFE_INTEGER) {
|
|
731
|
-
throw new Error("Given amount is not a safe integer. Consider using a string instead to overcome the limitations of JS numbers.");
|
|
732
|
-
}
|
|
733
|
-
outAmount = String(amount);
|
|
734
|
-
} else {
|
|
735
|
-
if (!amount.match(/^[0-9]+$/)) {
|
|
736
|
-
throw new Error("Invalid unsigned integer string format");
|
|
737
|
-
}
|
|
738
|
-
outAmount = amount.replace(/^0*/, "") || "0";
|
|
739
|
-
}
|
|
740
|
-
return { amount: outAmount, denom };
|
|
741
|
-
};
|
|
742
|
-
var coins = (amount, denom) => {
|
|
743
|
-
return [coin(amount, denom)];
|
|
744
|
-
};
|
|
745
|
-
var parseCoins = (input) => {
|
|
746
|
-
return input.replace(/\s/g, "").split(",").filter(Boolean).map((part) => {
|
|
747
|
-
const match = part.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/:._-]{2,127})$/);
|
|
748
|
-
if (!match) throw new Error("Got an invalid coin string");
|
|
749
|
-
return {
|
|
750
|
-
amount: match[1].replace(/^0+/, "") || "0",
|
|
751
|
-
denom: match[2]
|
|
752
|
-
};
|
|
753
|
-
});
|
|
754
|
-
};
|
|
755
|
-
|
|
756
796
|
// src/utils/ibc.ts
|
|
757
797
|
import BigNumber3 from "bignumber.js";
|
|
758
798
|
var canDepositFromIBC = (ibcData2) => {
|
|
@@ -5473,6 +5513,8 @@ export {
|
|
|
5473
5513
|
getEcosystemApps,
|
|
5474
5514
|
getEpochDurationByIdentifier,
|
|
5475
5515
|
getEpochsInfo,
|
|
5516
|
+
getEventKeyValue,
|
|
5517
|
+
getEventMarketId,
|
|
5476
5518
|
getFactoryDenomAdminAddress,
|
|
5477
5519
|
getFromLocalStorage,
|
|
5478
5520
|
getHardcodedLockAddress,
|
|
@@ -5498,6 +5540,7 @@ export {
|
|
|
5498
5540
|
getMarketSellOrders,
|
|
5499
5541
|
getMarkets,
|
|
5500
5542
|
getMinAmount,
|
|
5543
|
+
getMintedAmount,
|
|
5501
5544
|
getModuleAddress,
|
|
5502
5545
|
getNextBurning,
|
|
5503
5546
|
getNoOfIntervalsNeeded,
|
|
@@ -5531,12 +5574,19 @@ export {
|
|
|
5531
5574
|
getWalletChainsNames,
|
|
5532
5575
|
getWeekEpochInfo,
|
|
5533
5576
|
intlDateFormat,
|
|
5577
|
+
isAddressTransfer,
|
|
5578
|
+
isBurnEvent,
|
|
5579
|
+
isCoinbaseEvent,
|
|
5580
|
+
isEpochStartEvent,
|
|
5534
5581
|
isFactoryDenom,
|
|
5535
5582
|
isIbcAsset,
|
|
5536
5583
|
isIbcDenom,
|
|
5537
5584
|
isLpDenom,
|
|
5538
5585
|
isNativeDenom,
|
|
5586
|
+
isOrderBookEvent,
|
|
5587
|
+
isOrderExecutedEvent,
|
|
5539
5588
|
isPoolSupportedByValidator,
|
|
5589
|
+
isSwapEvent,
|
|
5540
5590
|
isTestnetChain,
|
|
5541
5591
|
keplrSuggestChain,
|
|
5542
5592
|
mapEventAttributes,
|