@qhristen/paygrid 0.1.0 → 0.1.2

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.
@@ -1,8 +1,8 @@
1
1
  "use client";
2
+ import { initWASM, isWASMSupported, ShadowWireClient, } from "@radr/shadowwire";
2
3
  import { useEffect, useState } from "react";
3
4
  import { SUPPORTED_TOKENS } from "../config";
4
5
  import { PaymentMethod } from "../types";
5
- import { initWASM, isWASMSupported, ShadowWireClient, } from "@radr/shadowwire";
6
6
  export function CheckoutModal({ amount: propsAmount, method: propsMethod, tokenSymbol: propsTokenSymbol, sender: propsSender, onPaymentResponse, }) {
7
7
  const [isCheckoutOpen, setIsCheckoutOpen] = useState(false);
8
8
  const [step, setStep] = useState("config");
package/dist/client.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./types";
2
- export * from "./dashboard";
3
- export * from "./checkout";
2
+ export { PayGridDashboard } from "./dashboard";
3
+ export { CheckoutModal } from "./checkout";
4
+ export { PayGrid, initPayGrid } from "./core/paygrid";
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- // Client-side only exports - safe for browser bundling
2
1
  export * from "./types";
3
- export * from "./dashboard";
4
- export * from "./checkout";
2
+ export { PayGridDashboard } from "./dashboard";
3
+ export { CheckoutModal } from "./checkout";
4
+ export { PayGrid, initPayGrid } from "./core/paygrid";
@@ -0,0 +1,2 @@
1
+ export { PayGrid, initPayGrid } from "./paygrid";
2
+ export { initWrapper } from "./privacy-wrapper";
@@ -0,0 +1,2 @@
1
+ export { PayGrid, initPayGrid } from "./paygrid";
2
+ export { initWrapper } from "./privacy-wrapper";
@@ -1,5 +1,5 @@
1
- import { AnalyticsData, PayGridConfig, PaymentIntent, TokenSymbol } from "../types";
2
1
  import { DepositResponse } from "@radr/shadowwire";
2
+ import { AnalyticsData, PayGridConfig, PaymentIntent, TokenSymbol } from "../types";
3
3
  export declare class PayGrid {
4
4
  private db;
5
5
  private solana;
@@ -30,6 +30,16 @@ export declare class PayGrid {
30
30
  listApiKeys(): Promise<import("../types").ApiKey[]>;
31
31
  deleteApiKey(id: string): Promise<void>;
32
32
  getPayments(): Promise<PaymentIntent[]>;
33
+ deposit(amount: number, walletAddress: string, tokenMint: string, symbol: string): Promise<DepositResponse>;
34
+ transfer({ symbol, sender, amount, }: {
35
+ symbol: string;
36
+ sender: string;
37
+ amount: number;
38
+ }): Promise<import("@radr/shadowwire").TransferResponse>;
39
+ withdraw({ symbol, recipient }: {
40
+ symbol: string;
41
+ recipient: string;
42
+ }): Promise<import("@radr/shadowwire").WithdrawResponse | undefined>;
33
43
  getAnalytics(days?: number): Promise<AnalyticsData>;
34
44
  withdrawFromPrivacy(params: {
35
45
  tokenSymbol: TokenSymbol;
@@ -141,6 +141,20 @@ export class PayGrid {
141
141
  async getPayments() {
142
142
  return await this.db.getAllPayments();
143
143
  }
144
+ async deposit(amount, walletAddress, tokenMint, symbol) {
145
+ return await this.privacy.createDepositTransaction({
146
+ amount,
147
+ walletAddress,
148
+ tokenMint,
149
+ symbol,
150
+ });
151
+ }
152
+ async transfer({ symbol, sender, amount, }) {
153
+ return await this.privacy.transfer({ symbol, sender, amount });
154
+ }
155
+ async withdraw({ symbol, recipient }) {
156
+ return await this.privacy.withdraw({ symbol, recipient });
157
+ }
144
158
  async getAnalytics(days = 30) {
145
159
  const payments = await this.db.getAllPayments();
146
160
  const now = Date.now();
@@ -218,7 +232,7 @@ export class PayGrid {
218
232
  const res = await this.privacy.transfer({
219
233
  symbol: params.tokenSymbol,
220
234
  amount: params.amount,
221
- sender: params.sender
235
+ sender: params.sender,
222
236
  });
223
237
  }
224
238
  catch (error) {
@@ -27,3 +27,4 @@ export declare class PrivacyWrapper {
27
27
  symbol: string;
28
28
  }): Promise<DepositResponse>;
29
29
  }
30
+ export declare function initWrapper(config?: Partial<PayGridConfig>): Promise<PrivacyWrapper>;
@@ -1,3 +1,4 @@
1
+ import { validateConfig } from "../config";
1
2
  import { TokenSymbol as Symbol } from "../types";
2
3
  import { ShadowWireClient, } from "@radr/shadowwire";
3
4
  export class PrivacyWrapper {
@@ -19,6 +20,7 @@ export class PrivacyWrapper {
19
20
  console.log("No funds available");
20
21
  return;
21
22
  }
23
+ console.log(balance, "balance");
22
24
  const amount = symbol === Symbol.SOL
23
25
  ? (balance?.available ?? 0) / 1e9
24
26
  : (balance?.available ?? 0) / 1e6;
@@ -28,12 +30,13 @@ export class PrivacyWrapper {
28
30
  });
29
31
  }
30
32
  async transfer({ symbol, sender, amount, }) {
33
+ console.log(sender, symbol, amount, "transfer");
31
34
  return await this.client.transfer({
32
35
  amount,
33
36
  recipient: this.config.marchantWalletADdress,
34
37
  sender,
35
38
  token: symbol,
36
- type: "internal",
39
+ type: "external",
37
40
  });
38
41
  }
39
42
  async createTransferTransaction(params) {
@@ -70,3 +73,10 @@ export class PrivacyWrapper {
70
73
  }
71
74
  }
72
75
  }
76
+ export async function initWrapper(config) {
77
+ const fullConfig = config
78
+ ? { ...validateConfig(), ...config }
79
+ : validateConfig();
80
+ const paygrid = new PrivacyWrapper(fullConfig);
81
+ return paygrid;
82
+ }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from "./types";
2
- export * from "./dashboard";
3
- export * from "./checkout";
2
+ export { PayGridDashboard } from "./dashboard";
3
+ export { CheckoutModal } from "./checkout";
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- // Main export - client-safe only
2
1
  export * from "./types";
3
- export * from "./dashboard";
4
- export * from "./checkout";
5
- // For server-side usage, import from './server'
6
- // For client-side usage, import from './client' or this file
2
+ export { PayGridDashboard } from "./dashboard";
3
+ export { CheckoutModal } from "./checkout";
package/dist/server.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./core/paygrid";
2
- export * from "./api";
1
+ export { PayGrid, initPayGrid } from "./core/paygrid";
2
+ export { createApiHandler } from "./api";
3
3
  export * from "./types";
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Server-side only exports - Node.js modules only
2
- export * from "./core/paygrid";
3
- export * from "./api";
2
+ export { PayGrid, initPayGrid } from "./core/paygrid";
3
+ export { createApiHandler } from "./api";
4
4
  export * from "./types";