@sanketsaagar/polygon-kit 0.1.5 → 0.1.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/README.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  PolygonKit is a comprehensive React library inspired by OnchainKit, specifically designed for building web3 applications on Polygon. It provides battle-tested components, hooks, and utilities to create seamless onchain experiences.
6
6
 
7
+ ## 📚 Documentation
8
+
9
+ **[View Full Documentation →](https://polygonlabs.mintlify.app/)**
10
+
11
+ Complete guides, API reference, and examples available [here](https://polygonlabs.mintlify.app/)
12
+
7
13
  ## Features
8
14
 
9
15
  - **Wallet Management** - Easy wallet connection and account management
package/dist/index.d.mts CHANGED
@@ -97,6 +97,11 @@ interface TokenBalanceProps {
97
97
  token?: Address;
98
98
  className?: string;
99
99
  }
100
+ interface TokenIconProps {
101
+ symbol: string;
102
+ size?: number;
103
+ className?: string;
104
+ }
100
105
  interface SwapProps {
101
106
  className?: string;
102
107
  onSuccess?: (hash: string) => void;
@@ -137,6 +142,8 @@ declare function Token({ amount, symbol, className }: TokenProps): react_jsx_run
137
142
 
138
143
  declare function TokenBalance({ address, token, className }: TokenBalanceProps): react_jsx_runtime.JSX.Element;
139
144
 
145
+ declare function TokenIcon({ symbol, size, className }: TokenIconProps): react_jsx_runtime.JSX.Element;
146
+
140
147
  declare function Swap({ className, onSuccess, onError }: SwapProps): react_jsx_runtime.JSX.Element;
141
148
 
142
149
  interface UsePolygonKitReturn {
@@ -183,4 +190,4 @@ declare const polygonAmoy: Chain;
183
190
  declare const polygonZkEVM: Chain;
184
191
  declare const defaultChains: Chain[];
185
192
 
186
- export { Avatar, type AvatarProps, type Chain, ConnectWallet, type ConnectWalletProps, Identity, type IdentityProps, Name, type NameProps, type PolygonKitConfig, PolygonKitProvider, type PolygonKitProviderProps, Swap, type SwapProps, type ThemeMode, Token, TokenBalance, type TokenBalanceProps, type TokenProps, Transaction, TransactionButton, type TransactionButtonProps, type TransactionCall, type TransactionProps, TransactionStatus, Wallet, WalletDropdown, type WalletDropdownProps, type WalletProps, defaultChains, formatBalance, parseTokenAmount, polygon, polygonAmoy, polygonMumbai, polygonZkEVM, shortenAddress, truncateText, usePolygonBalance, usePolygonKit, usePolygonTransaction };
193
+ export { Avatar, type AvatarProps, type Chain, ConnectWallet, type ConnectWalletProps, Identity, type IdentityProps, Name, type NameProps, type PolygonKitConfig, PolygonKitProvider, type PolygonKitProviderProps, Swap, type SwapProps, type ThemeMode, Token, TokenBalance, type TokenBalanceProps, TokenIcon, type TokenIconProps, type TokenProps, Transaction, TransactionButton, type TransactionButtonProps, type TransactionCall, type TransactionProps, TransactionStatus, Wallet, WalletDropdown, type WalletDropdownProps, type WalletProps, defaultChains, formatBalance, parseTokenAmount, polygon, polygonAmoy, polygonMumbai, polygonZkEVM, shortenAddress, truncateText, usePolygonBalance, usePolygonKit, usePolygonTransaction };
package/dist/index.d.ts CHANGED
@@ -97,6 +97,11 @@ interface TokenBalanceProps {
97
97
  token?: Address;
98
98
  className?: string;
99
99
  }
100
+ interface TokenIconProps {
101
+ symbol: string;
102
+ size?: number;
103
+ className?: string;
104
+ }
100
105
  interface SwapProps {
101
106
  className?: string;
102
107
  onSuccess?: (hash: string) => void;
@@ -137,6 +142,8 @@ declare function Token({ amount, symbol, className }: TokenProps): react_jsx_run
137
142
 
138
143
  declare function TokenBalance({ address, token, className }: TokenBalanceProps): react_jsx_runtime.JSX.Element;
139
144
 
145
+ declare function TokenIcon({ symbol, size, className }: TokenIconProps): react_jsx_runtime.JSX.Element;
146
+
140
147
  declare function Swap({ className, onSuccess, onError }: SwapProps): react_jsx_runtime.JSX.Element;
141
148
 
142
149
  interface UsePolygonKitReturn {
@@ -183,4 +190,4 @@ declare const polygonAmoy: Chain;
183
190
  declare const polygonZkEVM: Chain;
184
191
  declare const defaultChains: Chain[];
185
192
 
186
- export { Avatar, type AvatarProps, type Chain, ConnectWallet, type ConnectWalletProps, Identity, type IdentityProps, Name, type NameProps, type PolygonKitConfig, PolygonKitProvider, type PolygonKitProviderProps, Swap, type SwapProps, type ThemeMode, Token, TokenBalance, type TokenBalanceProps, type TokenProps, Transaction, TransactionButton, type TransactionButtonProps, type TransactionCall, type TransactionProps, TransactionStatus, Wallet, WalletDropdown, type WalletDropdownProps, type WalletProps, defaultChains, formatBalance, parseTokenAmount, polygon, polygonAmoy, polygonMumbai, polygonZkEVM, shortenAddress, truncateText, usePolygonBalance, usePolygonKit, usePolygonTransaction };
193
+ export { Avatar, type AvatarProps, type Chain, ConnectWallet, type ConnectWalletProps, Identity, type IdentityProps, Name, type NameProps, type PolygonKitConfig, PolygonKitProvider, type PolygonKitProviderProps, Swap, type SwapProps, type ThemeMode, Token, TokenBalance, type TokenBalanceProps, TokenIcon, type TokenIconProps, type TokenProps, Transaction, TransactionButton, type TransactionButtonProps, type TransactionCall, type TransactionProps, TransactionStatus, Wallet, WalletDropdown, type WalletDropdownProps, type WalletProps, defaultChains, formatBalance, parseTokenAmount, polygon, polygonAmoy, polygonMumbai, polygonZkEVM, shortenAddress, truncateText, usePolygonBalance, usePolygonKit, usePolygonTransaction };
package/dist/index.js CHANGED
@@ -28,6 +28,7 @@ __export(index_exports, {
28
28
  Swap: () => Swap,
29
29
  Token: () => Token,
30
30
  TokenBalance: () => TokenBalance,
31
+ TokenIcon: () => TokenIcon,
31
32
  Transaction: () => Transaction,
32
33
  TransactionButton: () => TransactionButton,
33
34
  TransactionStatus: () => TransactionStatus,
@@ -57,11 +58,11 @@ var import_appkit_adapter_wagmi = require("@reown/appkit-adapter-wagmi");
57
58
  // src/constants/chains.ts
58
59
  var polygon = {
59
60
  id: 137,
60
- name: "Polygon",
61
+ name: "Polygon PoS",
61
62
  network: "matic",
62
63
  nativeCurrency: {
63
- name: "MATIC",
64
- symbol: "MATIC",
64
+ name: "POL",
65
+ symbol: "POL",
65
66
  decimals: 18
66
67
  },
67
68
  rpcUrls: {
@@ -105,11 +106,11 @@ var polygonMumbai = {
105
106
  };
106
107
  var polygonAmoy = {
107
108
  id: 80002,
108
- name: "Polygon Amoy",
109
+ name: "Amoy Testnet",
109
110
  network: "polygon-amoy",
110
111
  nativeCurrency: {
111
- name: "MATIC",
112
- symbol: "MATIC",
112
+ name: "POL",
113
+ symbol: "POL",
113
114
  decimals: 18
114
115
  },
115
116
  rpcUrls: {
@@ -538,9 +539,22 @@ function TokenBalance({ address, token, className = "" }) {
538
539
  ] });
539
540
  }
540
541
 
542
+ // src/components/Token/TokenIcon.tsx
543
+ var import_jsx_runtime13 = require("react/jsx-runtime");
544
+ function TokenIcon({ symbol, size = 24, className = "" }) {
545
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
546
+ "div",
547
+ {
548
+ className: `rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-bold ${className}`,
549
+ style: { width: size, height: size, fontSize: size * 0.5 },
550
+ children: symbol ? symbol.charAt(0).toUpperCase() : "?"
551
+ }
552
+ );
553
+ }
554
+
541
555
  // src/components/Swap/Swap.tsx
542
556
  var import_react6 = require("react");
543
- var import_jsx_runtime13 = require("react/jsx-runtime");
557
+ var import_jsx_runtime14 = require("react/jsx-runtime");
544
558
  function Swap({ className = "", onSuccess, onError }) {
545
559
  const [fromAmount, setFromAmount] = (0, import_react6.useState)("");
546
560
  const [toAmount, setToAmount] = (0, import_react6.useState)("");
@@ -556,13 +570,13 @@ function Swap({ className = "", onSuccess, onError }) {
556
570
  setIsLoading(false);
557
571
  }
558
572
  };
559
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: `bg-white dark:bg-gray-900 rounded-xl p-4 shadow-lg border border-gray-200 dark:border-gray-700 ${className}`, children: [
560
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { className: "text-lg font-bold mb-4", children: "Swap Tokens" }),
561
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "space-y-2", children: [
562
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
563
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "From" }),
564
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [
565
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
573
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `bg-white dark:bg-gray-900 rounded-xl p-4 shadow-lg border border-gray-200 dark:border-gray-700 ${className}`, children: [
574
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "text-lg font-bold mb-4", children: "Swap Tokens" }),
575
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "space-y-2", children: [
576
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
577
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "From" }),
578
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [
579
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
566
580
  "input",
567
581
  {
568
582
  type: "number",
@@ -572,14 +586,14 @@ function Swap({ className = "", onSuccess, onError }) {
572
586
  className: "flex-1 bg-transparent text-2xl font-medium outline-none"
573
587
  }
574
588
  ),
575
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "MATIC" })
589
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "MATIC" })
576
590
  ] })
577
591
  ] }),
578
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "p-2 bg-purple-100 dark:bg-purple-900 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-800 transition-colors", children: "\u2193" }) }),
579
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
580
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "To" }),
581
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [
582
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
592
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { className: "p-2 bg-purple-100 dark:bg-purple-900 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-800 transition-colors", children: "\u2193" }) }),
593
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
594
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "To" }),
595
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2 mt-1", children: [
596
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
583
597
  "input",
584
598
  {
585
599
  type: "number",
@@ -589,11 +603,11 @@ function Swap({ className = "", onSuccess, onError }) {
589
603
  className: "flex-1 bg-transparent text-2xl font-medium outline-none"
590
604
  }
591
605
  ),
592
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "USDC" })
606
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "USDC" })
593
607
  ] })
594
608
  ] })
595
609
  ] }),
596
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
610
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
597
611
  "button",
598
612
  {
599
613
  onClick: handleSwap,
@@ -602,7 +616,7 @@ function Swap({ className = "", onSuccess, onError }) {
602
616
  children: isLoading ? "Swapping..." : "Swap"
603
617
  }
604
618
  ),
605
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "mt-3 text-xs text-gray-500 dark:text-gray-400 text-center", children: "Powered by Polygon DEX Aggregators" })
619
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "mt-3 text-xs text-gray-500 dark:text-gray-400 text-center", children: "Powered by Polygon DEX Aggregators" })
606
620
  ] });
607
621
  }
608
622
 
@@ -683,6 +697,7 @@ function usePolygonTransaction() {
683
697
  Swap,
684
698
  Token,
685
699
  TokenBalance,
700
+ TokenIcon,
686
701
  Transaction,
687
702
  TransactionButton,
688
703
  TransactionStatus,
package/dist/index.mjs CHANGED
@@ -7,11 +7,11 @@ import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
7
7
  // src/constants/chains.ts
8
8
  var polygon = {
9
9
  id: 137,
10
- name: "Polygon",
10
+ name: "Polygon PoS",
11
11
  network: "matic",
12
12
  nativeCurrency: {
13
- name: "MATIC",
14
- symbol: "MATIC",
13
+ name: "POL",
14
+ symbol: "POL",
15
15
  decimals: 18
16
16
  },
17
17
  rpcUrls: {
@@ -55,11 +55,11 @@ var polygonMumbai = {
55
55
  };
56
56
  var polygonAmoy = {
57
57
  id: 80002,
58
- name: "Polygon Amoy",
58
+ name: "Amoy Testnet",
59
59
  network: "polygon-amoy",
60
60
  nativeCurrency: {
61
- name: "MATIC",
62
- symbol: "MATIC",
61
+ name: "POL",
62
+ symbol: "POL",
63
63
  decimals: 18
64
64
  },
65
65
  rpcUrls: {
@@ -488,9 +488,22 @@ function TokenBalance({ address, token, className = "" }) {
488
488
  ] });
489
489
  }
490
490
 
491
+ // src/components/Token/TokenIcon.tsx
492
+ import { jsx as jsx13 } from "react/jsx-runtime";
493
+ function TokenIcon({ symbol, size = 24, className = "" }) {
494
+ return /* @__PURE__ */ jsx13(
495
+ "div",
496
+ {
497
+ className: `rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-bold ${className}`,
498
+ style: { width: size, height: size, fontSize: size * 0.5 },
499
+ children: symbol ? symbol.charAt(0).toUpperCase() : "?"
500
+ }
501
+ );
502
+ }
503
+
491
504
  // src/components/Swap/Swap.tsx
492
505
  import { useState as useState3 } from "react";
493
- import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
506
+ import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
494
507
  function Swap({ className = "", onSuccess, onError }) {
495
508
  const [fromAmount, setFromAmount] = useState3("");
496
509
  const [toAmount, setToAmount] = useState3("");
@@ -507,12 +520,12 @@ function Swap({ className = "", onSuccess, onError }) {
507
520
  }
508
521
  };
509
522
  return /* @__PURE__ */ jsxs6("div", { className: `bg-white dark:bg-gray-900 rounded-xl p-4 shadow-lg border border-gray-200 dark:border-gray-700 ${className}`, children: [
510
- /* @__PURE__ */ jsx13("h3", { className: "text-lg font-bold mb-4", children: "Swap Tokens" }),
523
+ /* @__PURE__ */ jsx14("h3", { className: "text-lg font-bold mb-4", children: "Swap Tokens" }),
511
524
  /* @__PURE__ */ jsxs6("div", { className: "space-y-2", children: [
512
525
  /* @__PURE__ */ jsxs6("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
513
- /* @__PURE__ */ jsx13("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "From" }),
526
+ /* @__PURE__ */ jsx14("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "From" }),
514
527
  /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 mt-1", children: [
515
- /* @__PURE__ */ jsx13(
528
+ /* @__PURE__ */ jsx14(
516
529
  "input",
517
530
  {
518
531
  type: "number",
@@ -522,14 +535,14 @@ function Swap({ className = "", onSuccess, onError }) {
522
535
  className: "flex-1 bg-transparent text-2xl font-medium outline-none"
523
536
  }
524
537
  ),
525
- /* @__PURE__ */ jsx13("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "MATIC" })
538
+ /* @__PURE__ */ jsx14("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "MATIC" })
526
539
  ] })
527
540
  ] }),
528
- /* @__PURE__ */ jsx13("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx13("button", { className: "p-2 bg-purple-100 dark:bg-purple-900 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-800 transition-colors", children: "\u2193" }) }),
541
+ /* @__PURE__ */ jsx14("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx14("button", { className: "p-2 bg-purple-100 dark:bg-purple-900 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-800 transition-colors", children: "\u2193" }) }),
529
542
  /* @__PURE__ */ jsxs6("div", { className: "bg-gray-50 dark:bg-gray-800 rounded-lg p-3", children: [
530
- /* @__PURE__ */ jsx13("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "To" }),
543
+ /* @__PURE__ */ jsx14("label", { className: "text-sm text-gray-600 dark:text-gray-400", children: "To" }),
531
544
  /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2 mt-1", children: [
532
- /* @__PURE__ */ jsx13(
545
+ /* @__PURE__ */ jsx14(
533
546
  "input",
534
547
  {
535
548
  type: "number",
@@ -539,11 +552,11 @@ function Swap({ className = "", onSuccess, onError }) {
539
552
  className: "flex-1 bg-transparent text-2xl font-medium outline-none"
540
553
  }
541
554
  ),
542
- /* @__PURE__ */ jsx13("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "USDC" })
555
+ /* @__PURE__ */ jsx14("button", { className: "px-3 py-1 bg-gray-200 dark:bg-gray-700 rounded-lg font-medium", children: "USDC" })
543
556
  ] })
544
557
  ] })
545
558
  ] }),
546
- /* @__PURE__ */ jsx13(
559
+ /* @__PURE__ */ jsx14(
547
560
  "button",
548
561
  {
549
562
  onClick: handleSwap,
@@ -552,7 +565,7 @@ function Swap({ className = "", onSuccess, onError }) {
552
565
  children: isLoading ? "Swapping..." : "Swap"
553
566
  }
554
567
  ),
555
- /* @__PURE__ */ jsx13("div", { className: "mt-3 text-xs text-gray-500 dark:text-gray-400 text-center", children: "Powered by Polygon DEX Aggregators" })
568
+ /* @__PURE__ */ jsx14("div", { className: "mt-3 text-xs text-gray-500 dark:text-gray-400 text-center", children: "Powered by Polygon DEX Aggregators" })
556
569
  ] });
557
570
  }
558
571
 
@@ -632,6 +645,7 @@ export {
632
645
  Swap,
633
646
  Token,
634
647
  TokenBalance,
648
+ TokenIcon,
635
649
  Transaction,
636
650
  TransactionButton,
637
651
  TransactionStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanketsaagar/polygon-kit",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "React components and TypeScript utilities for building onchain apps on Polygon",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",