@pollar/react 0.11.1 → 0.11.2

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.mjs CHANGED
@@ -1033,7 +1033,7 @@ var PollarModalFooter = () => {
1033
1033
  /* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
1034
1034
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
1035
1035
  "v",
1036
- "0.11.1"
1036
+ "0.11.2"
1037
1037
  ] })
1038
1038
  ] })
1039
1039
  ] });
@@ -4149,6 +4149,11 @@ function SendModal({ onClose }) {
4149
4149
  setFormError("Enter a destination address");
4150
4150
  return;
4151
4151
  }
4152
+ const isNativeAsset = selectedAsset.type === "native";
4153
+ if (isBaseUnitChain && !isNativeAsset && (!selectedAsset.issuer || selectedAsset.decimals === void 0)) {
4154
+ setFormError("This token is missing its mint or decimals and cannot be sent.");
4155
+ return;
4156
+ }
4152
4157
  let sendAmount = amount;
4153
4158
  if (isBaseUnitChain) {
4154
4159
  try {
@@ -4164,8 +4169,9 @@ function SendModal({ onClose }) {
4164
4169
  chain: "SOLANA",
4165
4170
  destination: destination.trim(),
4166
4171
  amount: sendAmount,
4167
- // Native SOL carries no mint; an SPL token's mint rides in `issuer`.
4168
- ...selectedAsset.type === "native" ? {} : { mint: selectedAsset.issuer ?? null }
4172
+ // Native SOL carries no mint; an SPL token's mint rides in `issuer`,
4173
+ // which the guard above proved is present.
4174
+ ...isNativeAsset ? {} : { mint: selectedAsset.issuer }
4169
4175
  });
4170
4176
  return;
4171
4177
  }
@@ -4637,7 +4643,7 @@ function SwapModal({ onClose }) {
4637
4643
  const assetRecords = enabledAssets.step === "loaded" ? enabledAssets.data.assets : [];
4638
4644
  const isLoadingData = walletBalance.step === "loading" || enabledAssets.step === "loading";
4639
4645
  const sellOptions = balances.filter(
4640
- (b) => b.type != null && (b.type === "native" || !b.trustlineRemoved)
4646
+ (b) => (b.chain === void 0 || b.chain === "STELLAR") && (b.type === "native" || (b.type === "credit_alphanum4" || b.type === "credit_alphanum12") && !b.trustlineRemoved)
4641
4647
  ).map((b) => ({
4642
4648
  ref: toRef(b),
4643
4649
  code: b.code,
@@ -4950,9 +4956,7 @@ function EarnModal({ onClose }) {
4950
4956
  if (!selectedOpportunity) return null;
4951
4957
  const balances = walletBalance.step === "loaded" ? walletBalance.data.balances : [];
4952
4958
  const issuer = selectedOpportunity.asset.issuer;
4953
- const rec = balances.find(
4954
- (b) => issuer === null ? b.type === "native" : b.code === assetCode && b.issuer === issuer
4955
- );
4959
+ const rec = balances.find((b) => issuer === null ? b.type === "native" : b.code === assetCode && b.issuer === issuer);
4956
4960
  return rec ? rec.available : null;
4957
4961
  })();
4958
4962
  const depositAssetRecord = (() => {
@@ -5629,6 +5633,12 @@ function TransactionModal({ onClose }) {
5629
5633
  ) });
5630
5634
  }
5631
5635
  var PAGE_SIZE = 10;
5636
+ function explorerUrlFor(chain, hash, network) {
5637
+ if (chain === "SOLANA") {
5638
+ return `https://explorer.solana.com/tx/${hash}${network === "testnet" ? "?cluster=devnet" : ""}`;
5639
+ }
5640
+ return `https://stellar.expert/explorer/${network === "testnet" ? "testnet" : "public"}/tx/${hash}`;
5641
+ }
5632
5642
  function StatusBadge({ status }) {
5633
5643
  return /* @__PURE__ */ jsx("span", { className: "pollar-hist-item-badge", "data-status": status, children: status });
5634
5644
  }
@@ -5667,6 +5677,10 @@ function TxHistoryModalTemplate({
5667
5677
  accentColor,
5668
5678
  txHistory,
5669
5679
  offset,
5680
+ chains,
5681
+ selectedChain,
5682
+ walletAddress,
5683
+ onSelectChain,
5670
5684
  onRefresh,
5671
5685
  onPrev,
5672
5686
  onNext,
@@ -5742,6 +5756,11 @@ function TxHistoryModalTemplate({
5742
5756
  /* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
5743
5757
  ] })
5744
5758
  ] }),
5759
+ /* @__PURE__ */ jsx(ChainSelect, { value: selectedChain, options: chains, onChange: onSelectChain, disabled: isLoading }),
5760
+ walletAddress && /* @__PURE__ */ jsxs("div", { className: "pollar-address-row", children: [
5761
+ /* @__PURE__ */ jsx("span", { className: "pollar-address", children: cropAddress(walletAddress) }),
5762
+ /* @__PURE__ */ jsx(CopyButton, { value: walletAddress, label: "Copy wallet address" })
5763
+ ] }),
5745
5764
  /* @__PURE__ */ jsxs("div", { className: "pollar-hist-list", children: [
5746
5765
  txHistory.step === "idle" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Click Refresh to load transactions." }),
5747
5766
  isLoading && /* @__PURE__ */ jsxs("div", { className: "pollar-loading-block", children: [
@@ -5752,7 +5771,7 @@ function TxHistoryModalTemplate({
5752
5771
  txHistory.step === "loaded" && records.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No transactions yet." }),
5753
5772
  records.map((record) => {
5754
5773
  const hash = typeof record.hash === "string" && record.hash.length > 0 ? record.hash : void 0;
5755
- const explorerUrl = hash ? `https://stellar.expert/explorer/${record.network === "testnet" ? "testnet" : "public"}/tx/${hash}` : void 0;
5774
+ const explorerUrl = hash ? explorerUrlFor(record.chain, hash, record.network) : void 0;
5756
5775
  const asset = typeof record.details?.asset === "string" ? record.details.asset : void 0;
5757
5776
  const colon = asset ? asset.indexOf(":") : -1;
5758
5777
  const trustline = record.operation === "change_trust" && asset && colon > 0 ? {
@@ -5786,10 +5805,11 @@ function TxHistoryModalTemplate({
5786
5805
  "\xB7 ",
5787
5806
  record.details.sponsored ? "Sponsored" : "Self-paid"
5788
5807
  ] }),
5789
- record.feeXlm && /* @__PURE__ */ jsxs("span", { children: [
5808
+ record.fee && /* @__PURE__ */ jsxs("span", { children: [
5790
5809
  "\xB7 ",
5791
- record.feeXlm,
5792
- " XLM"
5810
+ record.fee.amount,
5811
+ " ",
5812
+ record.fee.unit
5793
5813
  ] })
5794
5814
  ] }),
5795
5815
  /* @__PURE__ */ jsxs("div", { className: "pollar-hist-item-footer", children: [
@@ -5805,7 +5825,7 @@ function TxHistoryModalTemplate({
5805
5825
  href: explorerUrl,
5806
5826
  target: "_blank",
5807
5827
  rel: "noopener noreferrer",
5808
- "aria-label": "View on Stellar Explorer",
5828
+ "aria-label": "View on block explorer",
5809
5829
  children: /* @__PURE__ */ jsxs("svg", { width: "12", height: "12", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
5810
5830
  /* @__PURE__ */ jsx(
5811
5831
  "path",
@@ -5854,19 +5874,29 @@ function TxHistoryModalTemplate({
5854
5874
  }
5855
5875
  var PAGE_SIZE2 = 10;
5856
5876
  function TxHistoryModal({ onClose }) {
5857
- const { getClient, styles, txHistory } = usePollar();
5877
+ const { getClient, styles, txHistory, wallets } = usePollar();
5858
5878
  const { theme = "light", accentColor = "#005DB4" } = styles;
5859
5879
  const [offset, setOffset] = useState(0);
5880
+ const { chains } = useChains();
5881
+ const [selectedChain, setSelectedChain] = useState(null);
5882
+ useEffect(() => {
5883
+ if (selectedChain === null && chains.length > 0) setSelectedChain(chains[0]);
5884
+ }, [chains, selectedChain]);
5885
+ const walletAddress = addressForChain(wallets, selectedChain);
5860
5886
  const load = useCallback(
5861
- (nextOffset) => {
5887
+ (nextOffset, chain) => {
5862
5888
  setOffset(nextOffset);
5863
- void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
5889
+ void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset, chain });
5864
5890
  },
5865
5891
  [getClient]
5866
5892
  );
5867
5893
  useEffect(() => {
5868
- load(0);
5869
- }, [load]);
5894
+ if (selectedChain) load(0, selectedChain);
5895
+ }, [selectedChain, load]);
5896
+ const onSelectChain = (chain) => setSelectedChain(chain);
5897
+ const paged = (nextOffset) => {
5898
+ if (selectedChain) load(nextOffset, selectedChain);
5899
+ };
5870
5900
  return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
5871
5901
  TxHistoryModalTemplate,
5872
5902
  {
@@ -5874,9 +5904,13 @@ function TxHistoryModal({ onClose }) {
5874
5904
  accentColor,
5875
5905
  txHistory,
5876
5906
  offset,
5877
- onRefresh: () => load(offset),
5878
- onPrev: () => load(Math.max(0, offset - PAGE_SIZE2)),
5879
- onNext: () => load(offset + PAGE_SIZE2),
5907
+ chains,
5908
+ selectedChain,
5909
+ walletAddress,
5910
+ onSelectChain,
5911
+ onRefresh: () => paged(offset),
5912
+ onPrev: () => paged(Math.max(0, offset - PAGE_SIZE2)),
5913
+ onNext: () => paged(offset + PAGE_SIZE2),
5880
5914
  onClose
5881
5915
  }
5882
5916
  ) });
@@ -6145,6 +6179,9 @@ function PollarProvider({
6145
6179
  );
6146
6180
  const [configRetry, setConfigRetry] = useState(0);
6147
6181
  const retryConfig = useCallback(() => setConfigRetry((n) => n + 1), []);
6182
+ const appConfigKey = appConfigProp === void 0 ? "" : JSON.stringify(appConfigProp);
6183
+ const appConfigPropRef = useRef(appConfigProp);
6184
+ appConfigPropRef.current = appConfigProp;
6148
6185
  useEffect(() => {
6149
6186
  return pollarClient.onTransactionStateChange(setTransaction);
6150
6187
  }, [pollarClient]);
@@ -6208,7 +6245,9 @@ function PollarProvider({
6208
6245
  setModalErrorLogger(pollarClient.getLogger());
6209
6246
  }, [pollarClient]);
6210
6247
  useEffect(() => {
6211
- if (appConfigProp !== void 0) {
6248
+ const localConfig = appConfigPropRef.current;
6249
+ if (localConfig !== void 0) {
6250
+ setResolvedConfig(localConfig ?? DEFAULT_APP_CONFIG);
6212
6251
  setConfigStatus("ready");
6213
6252
  return;
6214
6253
  }
@@ -6230,7 +6269,7 @@ function PollarProvider({
6230
6269
  return () => {
6231
6270
  cancelled = true;
6232
6271
  };
6233
- }, [pollarClient, appConfigProp, configRetry]);
6272
+ }, [pollarClient, appConfigKey, configRetry]);
6234
6273
  const [loginModalOpen, setLoginModalOpen] = useState(false);
6235
6274
  const [transactionModalOpen, setTransactionModalOpen] = useState(false);
6236
6275
  const [kycModalOpen, setKycModalOpen] = useState(false);