@cordystackx/cordy_minikit 0.4.4 → 0.7.3

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
@@ -65,11 +65,11 @@ root
65
65
  ## Usage
66
66
  1. Create env file
67
67
  ```bash
68
- NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
69
- NEXT_PUBLIC_LINK_PROJECT_ID_COINBASED=
68
+ NEXT_PUBLIC_RPC_ENDPOINT=
70
69
  NEXT_PUBLIC_TOKENADDRESS=
71
70
  NEXT_PUBLIC_SYMBOL=
72
71
  NEXT_PUBLIC_PLATFORM_ADDRESS=
72
+ NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=
73
73
  ```
74
74
 
75
75
  2. Import the Providers inside the layout.ts
@@ -1,5 +1,5 @@
1
1
  import { createConfig } from 'wagmi';
2
2
  import type { Chain } from 'wagmi/chains';
3
- export default function getConfig(chains?: Record<string, Chain>): ReturnType<typeof createConfig>;
3
+ export default function getConfig(customChains?: Record<string, Chain>): ReturnType<typeof createConfig>;
4
4
  export declare const config: ReturnType<typeof createConfig>;
5
5
  //# sourceMappingURL=walletConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAK1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAsBrG;AAED,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAEV,CAAC"}
1
+ {"version":3,"file":"walletConfig.d.ts","sourceRoot":"","sources":["../../config/walletConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAI1C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAM,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAsB3G;AAED,eAAO,MAAM,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAGN,CAAC"}
@@ -2,13 +2,12 @@ import { http, createConfig } from 'wagmi';
2
2
  import { mainnet, base } from 'wagmi/chains';
3
3
  import { walletConnect, metaMask, coinbaseWallet } from 'wagmi/connectors';
4
4
  const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID;
5
- // Function to create config - only called on client side
6
- export default function getConfig(chains = {}) {
7
- // Combine default chains with custom chains
8
- const allChains = [mainnet, base, ...Object.values(chains)];
9
- // Create transports dynamically for all chains
5
+ export default function getConfig(customChains = {}) {
6
+ const allChains = [mainnet, base, ...Object.values(customChains)];
7
+ // Use the chain's RPC URL if available
10
8
  const transports = allChains.reduce((acc, chain) => {
11
- acc[chain.id] = http();
9
+ const rpcUrl = chain.rpcUrls?.default?.http?.[0];
10
+ acc[chain.id] = rpcUrl ? http(rpcUrl) : http();
12
11
  return acc;
13
12
  }, {});
14
13
  return createConfig({
@@ -18,12 +17,12 @@ export default function getConfig(chains = {}) {
18
17
  walletConnect({ projectId }),
19
18
  coinbaseWallet({
20
19
  appName: "cordy_minikit",
21
- version: "3"
22
- })
20
+ version: "3",
21
+ }),
23
22
  ],
24
23
  transports,
25
24
  });
26
25
  }
27
- export const config = typeof window !== 'undefined'
26
+ export const config = typeof window !== "undefined"
28
27
  ? getConfig()
29
28
  : {};
@@ -1,2 +1,2 @@
1
- export default function getTokenBalance(address: string, tokenAddress: string): Promise<string>;
1
+ export default function getTokenBalance(address: string, tokenAddress: string, decimals?: number): Promise<string>;
2
2
  //# sourceMappingURL=Get_Balance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAGA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAclF"}
1
+ {"version":3,"file":"Get_Balance.d.ts","sourceRoot":"","sources":["../../controllers/Get_Balance.tsx"],"names":[],"mappings":"AAGA,wBAA8B,eAAe,CAC3C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,QAAQ,GAAE,MAAW,mBAYtB"}
@@ -1,13 +1,11 @@
1
1
  import { ethers } from "ethers";
2
2
  import ERC20_ABI from "../config/ERC20_ABI.json";
3
- export default async function getTokenBalance(address, tokenAddress) {
4
- if (!address)
5
- return "0";
3
+ export default async function getTokenBalance(address, tokenAddress, decimals = 18) {
6
4
  try {
7
- const provider = new ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_LINK_PROJECT_ID_COINBASED);
5
+ const provider = new ethers.JsonRpcProvider(process.env.NEXT_PUBLIC_RPC_ENDPOINT);
8
6
  const contract = new ethers.Contract(tokenAddress, ERC20_ABI, provider);
9
7
  const balance = await contract.balanceOf(address);
10
- return ethers.formatUnits(balance, 18);
8
+ return ethers.formatUnits(balance, decimals);
11
9
  }
12
10
  catch (err) {
13
11
  console.error("Error fetching token balance:", err);
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAI7D,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG7D,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Clients
2
2
  export { default as ProvidersClientWrapper } from "./client__provider";
3
- //
3
+ // Config
4
4
  export { default as getConfig } from "./config/walletConfig";
5
5
  //Components
6
6
  export * from "./components";