@cordystackx/cordy_minikit 1.3.1 → 1.3.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
@@ -50,7 +50,6 @@ Create a `.env.local` file in your project root:
50
50
  ```bash
51
51
  NEXT_PUBLIC_RPC_ENDPOINT=https://your-rpc-endpoint.com
52
52
  NEXT_PUBLIC_TOKENADDRESS=0x...
53
- NEXT_PUBLIC_PLATFORM_ADDRESS=0x...
54
53
  NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id
55
54
  ```
56
55
 
@@ -1 +1 @@
1
- {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAMA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAmC1E"}
1
+ {"version":3,"file":"Transactions.d.ts","sourceRoot":"","sources":["../../controllers/Transactions.tsx"],"names":[],"mappings":"AAOA,wBAA8B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAgD1E"}
@@ -1,27 +1,39 @@
1
- import { ethers, parseUnits } from 'ethers';
2
- import tokenAbi from '../config/ERC20_ABI.json';
1
+ import { ethers, parseUnits } from "ethers";
2
+ import tokenAbi from "../config/ERC20_ABI.json";
3
+ import { CoinbaseWalletSDK } from "@coinbase/wallet-sdk";
3
4
  const tokenAddress = process.env.NEXT_PUBLIC_TOKENADDRESS || "";
4
- const platformAddress = process.env.NEXT_PUBLIC_PLATFORM_ADDRESS || "";
5
+ const rpcUrl = process.env.NEXT_PUBLIC_RPC_ENDPOINT || "https://mainnet.base.org";
5
6
  export default async function CordyStackTrans(address, cost) {
6
7
  if (!address) {
7
8
  console.error("Address Not Found");
8
9
  return false;
9
10
  }
10
11
  try {
11
- const provider = new ethers.BrowserProvider(window.ethereum);
12
+ // ✅ Initialize Coinbase Wallet SDK
13
+ const coinbase = new CoinbaseWalletSDK({
14
+ appName: "Cordy Stack", // any name you want
15
+ appLogoUrl: "https://your-logo.png", // optional
16
+ });
17
+ // ✅ Connect to Coinbase Wallet
18
+ const ethereum = coinbase.makeWeb3Provider({ options: "all", keysUrl: rpcUrl }); // chainId handled by provider or wallet
19
+ const provider = new ethers.BrowserProvider(ethereum);
12
20
  const signer = await provider.getSigner();
13
21
  const tokenContract = new ethers.Contract(tokenAddress, tokenAbi, signer);
14
22
  const decimals = 18;
15
23
  const amount = parseUnits(String(cost), decimals);
16
- const balance = await tokenContract.balanceOf(await signer.getAddress());
24
+ // ✅ Always fetch balance using a read-only provider (not signer)
25
+ const readProvider = new ethers.JsonRpcProvider(rpcUrl);
26
+ const readContract = new ethers.Contract(tokenAddress, tokenAbi, readProvider);
27
+ const balance = await readContract.balanceOf(await signer.getAddress());
17
28
  if (balance < amount) {
18
- console.log("Insuficient Funds");
29
+ console.log("Insufficient Funds");
19
30
  return false;
20
31
  }
21
- const tx = await tokenContract.transfer(platformAddress, amount);
32
+ // ✅ Proceed with transfer
33
+ const tx = await tokenContract.transfer(address, amount);
22
34
  const receipt = await tx.wait();
23
- if (receipt) {
24
- console.log("Transaction Complete TX hash", receipt);
35
+ if (receipt.status === 1) {
36
+ console.log("Transaction Complete! TX hash:", receipt.hash);
25
37
  return true;
26
38
  }
27
39
  else {
@@ -30,8 +42,7 @@ export default async function CordyStackTrans(address, cost) {
30
42
  }
31
43
  }
32
44
  catch (err) {
33
- console.error(err);
45
+ console.error("Transaction error:", err);
34
46
  return false;
35
47
  }
36
48
  }
37
- ;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cordystackx/cordy_minikit",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"