@ziongateway/sdk 0.1.2 → 0.1.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.
@@ -4,7 +4,11 @@
4
4
  export interface ZionConfig {
5
5
  /** Your API key from the Zion Dashboard */
6
6
  apiKey: string;
7
- /** Price per request in USD (e.g., 0.01 for 1 cent) */
7
+ /**
8
+ * Price per request in USD (e.g., 0.01 for 1 cent).
9
+ * ⚠️ MAX 6 DECIMAL PLACES - USDC has 6 decimal precision.
10
+ * Invalid: 0.0000001 (7 decimals) | Valid: 0.000001 (6 decimals)
11
+ */
8
12
  price: number;
9
13
  /** Solana network to use */
10
14
  network?: "solana-mainnet" | "solana-devnet";
@@ -26,7 +26,7 @@ export declare class ZionGate {
26
26
  /**
27
27
  * Create a new ZionGate instance.
28
28
  * @param config - Configuration options
29
- * @throws Error if price is not positive
29
+ * @throws Error if price is not positive or has more than 6 decimal places
30
30
  */
31
31
  constructor(config: ZionConfig);
32
32
  /**
package/dist/ZionGate.js CHANGED
@@ -29,15 +29,24 @@ class ZionGate {
29
29
  /**
30
30
  * Create a new ZionGate instance.
31
31
  * @param config - Configuration options
32
- * @throws Error if price is not positive
32
+ * @throws Error if price is not positive or has more than 6 decimal places
33
33
  */
34
34
  constructor(config) {
35
35
  this.developerWallet = null;
36
36
  this.isInitialized = false;
37
- // Validate price
37
+ // Validate price is positive
38
38
  if (!config.price || config.price <= 0) {
39
39
  throw new Error("ZionGate: Price must be a positive number");
40
40
  }
41
+ // Validate price has max 6 decimal places (USDC precision)
42
+ const priceStr = config.price.toString();
43
+ const decimalIndex = priceStr.indexOf('.');
44
+ if (decimalIndex !== -1) {
45
+ const decimals = priceStr.length - decimalIndex - 1;
46
+ if (decimals > 6) {
47
+ throw new Error("ZionGate: Price cannot have more than 6 decimal places (USDC precision)");
48
+ }
49
+ }
41
50
  this.config = config;
42
51
  const defaults = Universal_1.NETWORKS[config.network || "solana-mainnet"];
43
52
  this.api = axios_1.default.create({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziongateway/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "TypeScript SDK for Zion x402 Facilitator",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",