@cordystackx/cordy_minikit 3.0.1 → 3.0.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 +1 -1
- package/dist/client/jwt.d.ts +0 -3
- package/dist/client/jwt.d.ts.map +1 -1
- package/dist/client/jwt.js +0 -3
- package/dist/client/runtimeConfig.d.ts +52 -0
- package/dist/client/runtimeConfig.d.ts.map +1 -0
- package/dist/client/runtimeConfig.js +15 -0
- package/dist/client/transfer.d.ts +3 -42
- package/dist/client/transfer.d.ts.map +1 -1
- package/dist/client/transfer.js +48 -60
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client__provider.js +2 -2
- package/dist/config/walletConfig.d.ts +3 -1
- package/dist/config/walletConfig.d.ts.map +1 -1
- package/dist/config/walletConfig.js +5 -31
- package/dist/controllers/Get_Balance.d.ts.map +1 -1
- package/dist/controllers/Get_Balance.js +7 -2
- package/dist/controllers/StellarButton.js +1 -1
- package/dist/controllers/Transactions.d.ts.map +1 -1
- package/dist/controllers/Transactions.js +18 -11
- package/dist/controllers/WagmiButton.js +1 -1
- package/dist/controllers/loadStellarBalance.d.ts.map +1 -1
- package/dist/controllers/loadStellarBalance.js +11 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/package.json +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { ethers, parseUnits } from 'ethers';
|
|
3
|
-
import { Horizon, Asset, BASE_FEE, Memo,
|
|
3
|
+
import { Horizon, Asset, BASE_FEE, Memo, Operation, TransactionBuilder } from "@stellar/stellar-sdk";
|
|
4
4
|
import { getNetworkDetails, requestAccess, signTransaction as freighterSignTransaction } from "@stellar/freighter-api";
|
|
5
5
|
import tokenAbi from '../config/ERC20_ABI.json';
|
|
6
|
-
|
|
7
|
-
const rpcEndpoint = process.env.NEXT_PUBLIC_RPC_ENDPOINT || "";
|
|
8
|
-
const stellarRpc = process.env.NEXT_PUBLIC_STELLAR_HORIZON || "https://horizon-testnet.stellar.org";
|
|
9
|
-
const stellarNetwork = process.env.NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE || Networks.TESTNET;
|
|
6
|
+
import { getCordyRuntimeConfig } from '../client/runtimeConfig';
|
|
10
7
|
/** @deprecated Use `cordy.transfer(amount, recipient, { asset })` instead. */
|
|
11
8
|
export default async function CordyStackTrans(address, cost) {
|
|
12
9
|
if (!address) {
|
|
@@ -14,6 +11,11 @@ export default async function CordyStackTrans(address, cost) {
|
|
|
14
11
|
return false;
|
|
15
12
|
}
|
|
16
13
|
try {
|
|
14
|
+
const runtimeConfig = getCordyRuntimeConfig();
|
|
15
|
+
const defaultNetwork = runtimeConfig?.networks?.[0];
|
|
16
|
+
const defaultAsset = runtimeConfig?.evm?.find((asset) => (asset.chainId ?? defaultNetwork?.chainId) === defaultNetwork?.chainId && asset.contractAddress);
|
|
17
|
+
const tokenAddress = defaultAsset?.contractAddress || "";
|
|
18
|
+
const rpcEndpoint = defaultAsset?.rpcUrl || defaultNetwork?.rpcUrl || "";
|
|
17
19
|
const ethereum = window?.ethereum;
|
|
18
20
|
if (!ethereum) {
|
|
19
21
|
console.error("Ethereum provider not found");
|
|
@@ -22,11 +24,11 @@ export default async function CordyStackTrans(address, cost) {
|
|
|
22
24
|
const provider = new ethers.BrowserProvider(ethereum);
|
|
23
25
|
const signer = await provider.getSigner();
|
|
24
26
|
if (!tokenAddress) {
|
|
25
|
-
console.error("
|
|
27
|
+
console.error("No EVM token is configured in the assets JSON");
|
|
26
28
|
return false;
|
|
27
29
|
}
|
|
28
30
|
if (!rpcEndpoint) {
|
|
29
|
-
console.error("
|
|
31
|
+
console.error("No EVM network RPC is configured in the assets JSON");
|
|
30
32
|
return false;
|
|
31
33
|
}
|
|
32
34
|
const tokenContract = new ethers.Contract(tokenAddress, tokenAbi, signer);
|
|
@@ -70,6 +72,11 @@ export async function CordyStackTransStellar(address, cost, options = {}) {
|
|
|
70
72
|
return false;
|
|
71
73
|
}
|
|
72
74
|
try {
|
|
75
|
+
const stellarConfig = getCordyRuntimeConfig()?.stellarNetwork;
|
|
76
|
+
if (!stellarConfig?.horizonUrl || !stellarConfig.networkPassphrase) {
|
|
77
|
+
console.error("Stellar network configuration is missing from the assets JSON");
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
73
80
|
const access = await requestAccess();
|
|
74
81
|
const sourceAddress = options.source || access.address;
|
|
75
82
|
if (!sourceAddress) {
|
|
@@ -77,16 +84,16 @@ export async function CordyStackTransStellar(address, cost, options = {}) {
|
|
|
77
84
|
return false;
|
|
78
85
|
}
|
|
79
86
|
const networkDetails = await getNetworkDetails();
|
|
80
|
-
const networkPassphrase = networkDetails.networkPassphrase ||
|
|
87
|
+
const networkPassphrase = networkDetails.networkPassphrase || stellarConfig.networkPassphrase;
|
|
81
88
|
if (!networkPassphrase) {
|
|
82
89
|
console.error("Stellar network passphrase not found");
|
|
83
90
|
return false;
|
|
84
91
|
}
|
|
85
|
-
if (networkDetails.networkPassphrase && networkDetails.networkPassphrase !==
|
|
86
|
-
console.error("Stellar network mismatch. Expected",
|
|
92
|
+
if (networkDetails.networkPassphrase && networkDetails.networkPassphrase !== stellarConfig.networkPassphrase) {
|
|
93
|
+
console.error("Stellar network mismatch. Expected", stellarConfig.networkPassphrase, "got", networkDetails.networkPassphrase);
|
|
87
94
|
return false;
|
|
88
95
|
}
|
|
89
|
-
const server = new Horizon.Server(
|
|
96
|
+
const server = new Horizon.Server(stellarConfig.horizonUrl);
|
|
90
97
|
const sourceAccount = await server.loadAccount(sourceAddress);
|
|
91
98
|
const asset = Asset.native();
|
|
92
99
|
const payment = Operation.payment({
|
|
@@ -34,7 +34,7 @@ export default function WalletButton({ onStatusChange, connectorGroup = "all", }
|
|
|
34
34
|
setPendingConnector(connector);
|
|
35
35
|
try {
|
|
36
36
|
if (!isEvmEnvironmentConfigured()) {
|
|
37
|
-
throw new Error("EVM
|
|
37
|
+
throw new Error("EVM is not configured. Add an EVM network and at least one asset to the JSON passed to ProvidersClientWrapper.");
|
|
38
38
|
}
|
|
39
39
|
await connectAsync({ connector });
|
|
40
40
|
if (typeof window !== "undefined")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadStellarBalance.d.ts","sourceRoot":"","sources":["../../controllers/loadStellarBalance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadStellarBalance.d.ts","sourceRoot":"","sources":["../../controllers/loadStellarBalance.ts"],"names":[],"mappings":"AAIA,wBAAgB,8BAA8B,IAAI,OAAO,CAExD;AAED,MAAM,MAAM,mBAAmB,GAC3B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9D;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjG,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,8EAA8E;AAC9E,wBAA8B,kBAAkB,CAC9C,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,oBAAoB,CAAC,CAwD/B"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { Horizon } from "@stellar/stellar-sdk";
|
|
2
2
|
import { getNetworkDetails } from "@stellar/freighter-api";
|
|
3
|
-
|
|
4
|
-
const STELLAR_NETWORK_PASSPHRASE = process.env.NEXT_PUBLIC_STELLAR_NETWORK_PASSPHRASE;
|
|
3
|
+
import { getCordyRuntimeConfig, isStellarConfigReady } from "../client/runtimeConfig";
|
|
5
4
|
export function isStellarEnvironmentConfigured() {
|
|
6
|
-
return
|
|
7
|
-
STELLAR_NETWORK_PASSPHRASE &&
|
|
8
|
-
process.env.NEXT_PUBLIC_STELLAR_CONTRACT_ID);
|
|
5
|
+
return isStellarConfigReady();
|
|
9
6
|
}
|
|
10
7
|
/** Shared Stellar account balance reader for wallet status and Cordy APIs. */
|
|
11
8
|
export default async function loadStellarBalance(accountId, options = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const runtimeConfig = getCordyRuntimeConfig();
|
|
10
|
+
const stellarConfig = runtimeConfig?.stellarNetwork;
|
|
11
|
+
const horizonUrl = options.horizonUrl || stellarConfig?.horizonUrl;
|
|
12
|
+
const configuredPassphrase = options.networkPassphrase || stellarConfig?.networkPassphrase;
|
|
13
|
+
if (!isStellarEnvironmentConfigured() || !horizonUrl || !configuredPassphrase) {
|
|
14
|
+
throw new Error("Stellar is not configured. Add stellarNetwork and Stellar assets to the JSON passed to ProvidersClientWrapper.");
|
|
14
15
|
}
|
|
15
|
-
const horizonUrl = STELLAR_HORIZON;
|
|
16
|
-
const configuredPassphrase = STELLAR_NETWORK_PASSPHRASE;
|
|
17
16
|
const networkDetails = await getNetworkDetails();
|
|
18
|
-
const expectedPassphrase =
|
|
17
|
+
const expectedPassphrase = configuredPassphrase;
|
|
19
18
|
const freighterPassphrase = networkDetails.networkPassphrase;
|
|
20
19
|
if (freighterPassphrase && freighterPassphrase !== expectedPassphrase) {
|
|
21
20
|
throw new Error(`Freighter network mismatch. Expected ${expectedPassphrase}, got ${freighterPassphrase}.`);
|
|
@@ -24,7 +23,7 @@ export default async function loadStellarBalance(accountId, options = {}) {
|
|
|
24
23
|
const requestedSymbol = options.asset?.symbol || options.assetSymbol || "XLM";
|
|
25
24
|
let asset = options.asset;
|
|
26
25
|
if (!asset) {
|
|
27
|
-
const candidates = (options.assets ?? []).filter((candidate) => candidate.symbol.toLowerCase() === requestedSymbol.toLowerCase() &&
|
|
26
|
+
const candidates = (options.assets ?? runtimeConfig?.stellar ?? []).filter((candidate) => candidate.symbol.toLowerCase() === requestedSymbol.toLowerCase() &&
|
|
28
27
|
(!candidate.networkPassphrase || candidate.networkPassphrase === networkPassphrase));
|
|
29
28
|
if (candidates.length > 1) {
|
|
30
29
|
throw new Error(`More than one ${requestedSymbol} asset matches this Stellar network; make the JSON entries unique.`);
|
|
@@ -39,7 +38,7 @@ export default async function loadStellarBalance(accountId, options = {}) {
|
|
|
39
38
|
if (asset.networkPassphrase && asset.networkPassphrase !== networkPassphrase) {
|
|
40
39
|
throw new Error(`The ${asset.symbol} asset is not configured for the connected Stellar network.`);
|
|
41
40
|
}
|
|
42
|
-
const server = new Horizon.Server(
|
|
41
|
+
const server = new Horizon.Server(horizonUrl);
|
|
43
42
|
const account = await server.loadAccount(accountId);
|
|
44
43
|
const balance = asset.type === "native"
|
|
45
44
|
? account.balances.find((item) => item.asset_type === "native")
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ export { default as getConfig } from "./config/walletConfig";
|
|
|
3
3
|
export { useWalletModal } from "./wagmi__providers";
|
|
4
4
|
export { ConnectWalletBT } from "./components";
|
|
5
5
|
export { CordyStackTrans, CordyStackTransStellar, useWalletStatus, useDisconnectWallets, WalletButton, StellarWalletButton } from "./controllers";
|
|
6
|
-
export { cordy,
|
|
6
|
+
export { cordy, jwt_verify, jwt_disconnect } from "./client";
|
|
7
7
|
export type { JwtDisconnectResult, JwtSessionRequestOptions, JwtSessionResult } from "./client";
|
|
8
8
|
export { configureCordyAssets, cordy_balance, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
|
|
9
|
-
export type { CordyAssetsConfig, CordyBalanceOptions, CordyBalanceResult, CordyTransferOptions, CordyTransferResult, CordySwapResult, CordyBridgeResult, CordyBridgeSide, EvmAssetConfig, EvmNetworkConfig, StellarAssetConfig } from "./client/transfer";
|
|
9
|
+
export type { CordyAssetsConfig, CordyBalanceOptions, CordyBalanceResult, CordyTransferOptions, CordyTransferResult, CordySwapResult, CordyBridgeResult, CordyBridgeSide, EvmAssetConfig, EvmNetworkConfig, StellarAssetConfig, StellarNetworkConfig } from "./client/transfer";
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;AAG7D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,KAAK,EAAE,
|
|
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,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEhG,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnI,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,eAAe,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,5 +9,5 @@ export { ConnectWalletBT } from "./components";
|
|
|
9
9
|
//Controllers
|
|
10
10
|
export { CordyStackTrans, CordyStackTransStellar, useWalletStatus, useDisconnectWallets, WalletButton, StellarWalletButton } from "./controllers";
|
|
11
11
|
// Client-side JWT session helpers (safe for browser imports).
|
|
12
|
-
export { cordy,
|
|
12
|
+
export { cordy, jwt_verify, jwt_disconnect } from "./client";
|
|
13
13
|
export { configureCordyAssets, cordy_balance, cordy_configure, cordy_bridge, cordy_swap, cordy_transfer } from "./client/transfer";
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cordystackx/cordy_minikit",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"author": "Marc Giestin Louis Cordova a.k.a. (CordyStackX)",
|
|
36
36
|
"license": "MIT",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@coinbase/wallet-sdk": "4.
|
|
38
|
+
"@coinbase/wallet-sdk": "4.4.0",
|
|
39
39
|
"@metamask/connect-evm": "^2.1.1",
|
|
40
40
|
"@stellar/freighter-api": "^6.0.1",
|
|
41
|
-
"@stellar/stellar-sdk": "^
|
|
41
|
+
"@stellar/stellar-sdk": "^17.4.0",
|
|
42
42
|
"@tanstack/react-query": "^5.104.5",
|
|
43
43
|
"@walletconnect/ethereum-provider": "^2.26.0",
|
|
44
44
|
"ethers": "^6.17.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"wagmi": "^3.7.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^
|
|
53
|
+
"@types/node": "^26.6.5",
|
|
54
54
|
"@types/react": "^19.3.0",
|
|
55
55
|
"@types/react-dom": "^19.3.0",
|
|
56
56
|
"typescript": "^7.0.2"
|