@zkproofport-ai/sdk 0.3.0 → 0.4.0

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.
Files changed (60) hide show
  1. package/README.md +52 -134
  2. package/dist/actionApproval.js +1 -1
  3. package/dist/actionApproval.js.map +1 -1
  4. package/dist/attestation.d.ts +6 -1
  5. package/dist/attestation.d.ts.map +1 -1
  6. package/dist/attestation.js +41 -4
  7. package/dist/attestation.js.map +1 -1
  8. package/dist/cdp.d.ts +3 -3
  9. package/dist/circuits.d.ts +1 -3
  10. package/dist/circuits.d.ts.map +1 -1
  11. package/dist/circuits.js +0 -4
  12. package/dist/circuits.js.map +1 -1
  13. package/dist/constants.d.ts.map +1 -1
  14. package/dist/constants.js +0 -10
  15. package/dist/constants.js.map +1 -1
  16. package/dist/extract.d.ts.map +1 -1
  17. package/dist/extract.js +5 -7
  18. package/dist/extract.js.map +1 -1
  19. package/dist/flow.d.ts.map +1 -1
  20. package/dist/flow.js +13 -14
  21. package/dist/flow.js.map +1 -1
  22. package/dist/index.d.ts +1 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -12
  25. package/dist/index.js.map +1 -1
  26. package/dist/inputs.d.ts +4 -3
  27. package/dist/inputs.d.ts.map +1 -1
  28. package/dist/inputs.js +4 -7
  29. package/dist/inputs.js.map +1 -1
  30. package/dist/payment.d.ts +7 -9
  31. package/dist/payment.d.ts.map +1 -1
  32. package/dist/payment.js +20 -43
  33. package/dist/payment.js.map +1 -1
  34. package/dist/typedAction.js +1 -1
  35. package/dist/typedAction.js.map +1 -1
  36. package/dist/types.d.ts +5 -9
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +0 -2
  39. package/dist/types.js.map +1 -1
  40. package/dist/usdc.d.ts +6 -10
  41. package/dist/usdc.d.ts.map +1 -1
  42. package/dist/usdc.js +6 -11
  43. package/dist/usdc.js.map +1 -1
  44. package/dist/wallets.d.ts +8 -34
  45. package/dist/wallets.d.ts.map +1 -1
  46. package/dist/wallets.js +10 -87
  47. package/dist/wallets.js.map +1 -1
  48. package/package.json +2 -12
  49. package/dist/arcWallet.d.ts +0 -50
  50. package/dist/arcWallet.d.ts.map +0 -1
  51. package/dist/arcWallet.js +0 -161
  52. package/dist/arcWallet.js.map +0 -1
  53. package/dist/delegation.d.ts +0 -107
  54. package/dist/delegation.d.ts.map +0 -1
  55. package/dist/delegation.js +0 -126
  56. package/dist/delegation.js.map +0 -1
  57. package/dist/nanopayment.d.ts +0 -71
  58. package/dist/nanopayment.d.ts.map +0 -1
  59. package/dist/nanopayment.js +0 -77
  60. package/dist/nanopayment.js.map +0 -1
@@ -1,77 +0,0 @@
1
- /**
2
- * Paying with Arc nanopayments: deposit once, then pay many times for free.
3
- *
4
- * ## What is different from the ordinary path
5
- *
6
- * An ordinary x402 payment puts one authorization on chain per purchase, and
7
- * on Arc that costs gas in USDC — measured 2026-09-12 at 0.0035 USDC to settle
8
- * a payment of 0.001, which is four times the price of the thing being bought.
9
- * That is fine for a one-off and absurd for an agent buying thousands of
10
- * proofs.
11
- *
12
- * Circle Gateway takes the same EIP-3009 authorization, verifies it off chain
13
- * in under a second, and settles thousands of them in one transaction. The
14
- * buyer's money moves into Gateway once, by depositing; after that each
15
- * payment is a signature and nothing more.
16
- *
17
- * ## What the buyer has to do
18
- *
19
- * Deposit first. A signature drawn against a Gateway balance that is not there
20
- * is refused, and the refusal names the balance rather than the signature, so
21
- * `ensureGatewayBalance` checks before paying rather than after failing.
22
- */
23
- import { GatewayClient } from '@circle-fin/x402-batching/client';
24
- /** Arc Testnet, as `@circle-fin/x402-batching` names it. */
25
- export const ARC_GATEWAY_CHAIN = 'arcTestnet';
26
- function client(wallet) {
27
- return new GatewayClient({
28
- chain: ARC_GATEWAY_CHAIN,
29
- privateKey: wallet.privateKey,
30
- rpcUrl: wallet.rpcUrl,
31
- });
32
- }
33
- /** What the buyer currently has inside Gateway. */
34
- export async function gatewayBalance(wallet) {
35
- const balance = await client(wallet).getBalance();
36
- return { available: balance.available, withdrawing: balance.withdrawing };
37
- }
38
- /**
39
- * Make sure the buyer can pay `atLeast`, depositing `topUp` if not.
40
- *
41
- * Deposits are the one on-chain step in this flow and they cost gas, so this
42
- * is deliberately not called before every payment — an agent deposits once and
43
- * spends against it.
44
- */
45
- export async function ensureGatewayBalance(wallet,
46
- /** In USDC's smallest units. Undefined requests an unconditional deposit. */
47
- atLeast,
48
- /** In whole USDC, like everything the deposit call takes. */
49
- topUp) {
50
- const before = await gatewayBalance(wallet);
51
- if (atLeast !== undefined && before.available >= atLeast)
52
- return { deposited: false, balance: before };
53
- const result = await client(wallet).deposit(topUp);
54
- return {
55
- deposited: true,
56
- balance: await gatewayBalance(wallet),
57
- depositTxHash: result.depositTxHash,
58
- };
59
- }
60
- /**
61
- * Buy something priced in x402, paying through Gateway.
62
- *
63
- * The 402 answer must carry a batched offer; a service that offers only the
64
- * ordinary on-chain options is not reachable this way, and saying so is better
65
- * than silently paying the expensive way.
66
- */
67
- export async function payWithNanopayments(wallet, url, options) {
68
- const gateway = client(wallet);
69
- const supported = await gateway.supports(url);
70
- if (!supported.supported) {
71
- throw new Error(`${url} offers no batched payment option, so it cannot be paid through Circle Gateway. ` +
72
- `Pay it the ordinary way, or have the service offer arc-testnet-nano.`);
73
- }
74
- const paid = await gateway.pay(url, options);
75
- return { data: paid.data, amount: String(paid.amount ?? '0') };
76
- }
77
- //# sourceMappingURL=nanopayment.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nanopayment.js","sourceRoot":"","sources":["../src/nanopayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAqB,CAAC;AAiBvD,SAAS,MAAM,CAAC,MAAyB;IACvC,OAAO,IAAI,aAAa,CAAC;QACvB,KAAK,EAAE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