moltspay 0.2.4 → 0.2.6

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/dist/index.d.mts CHANGED
@@ -50,6 +50,116 @@ declare class PaymentAgent {
50
50
  formatInvoiceMessage(invoice: Invoice, includeJson?: boolean): string;
51
51
  }
52
52
 
53
+ /**
54
+ * AgentWallet - Zero-config wallet for AI Agents
55
+ *
56
+ * Design principles:
57
+ * - Auto-initialize on first use (no manual setup)
58
+ * - Generate address locally (no gas needed)
59
+ * - Owner authorizes via Permit (can be CLI or UI)
60
+ * - Agent only needs gas when actually spending
61
+ */
62
+
63
+ interface OwnerPermit {
64
+ owner: string;
65
+ value: string;
66
+ deadline: number;
67
+ nonce: number;
68
+ v: number;
69
+ r: string;
70
+ s: string;
71
+ }
72
+ interface AgentWalletConfig {
73
+ /** Storage directory for wallet data (default: ~/.moltspay) */
74
+ storageDir?: string;
75
+ /** Chain to use */
76
+ chain?: ChainName;
77
+ /** Custom RPC URL */
78
+ rpcUrl?: string;
79
+ }
80
+ interface SpendResult {
81
+ success: boolean;
82
+ txHash?: string;
83
+ error?: string;
84
+ from: string;
85
+ to: string;
86
+ amount: number;
87
+ remainingAllowance?: string;
88
+ explorerUrl?: string;
89
+ }
90
+ declare class AgentWallet {
91
+ readonly chain: ChainName;
92
+ readonly chainConfig: ChainConfig;
93
+ readonly storageDir: string;
94
+ private _address;
95
+ private _privateKey;
96
+ private _wallet;
97
+ private _provider;
98
+ private _permits;
99
+ constructor(config?: AgentWalletConfig);
100
+ private getDefaultStorageDir;
101
+ private getWalletPath;
102
+ private getPermitsPath;
103
+ /**
104
+ * Auto-initialize: create wallet if not exists
105
+ * This is called automatically in constructor
106
+ */
107
+ private ensureInitialized;
108
+ /** Agent's address (auto-generated on first use) */
109
+ get address(): string;
110
+ private get wallet();
111
+ private get provider();
112
+ /**
113
+ * Store a Permit from Owner
114
+ */
115
+ storePermit(permit: OwnerPermit): void;
116
+ /**
117
+ * Get stored permit for an owner
118
+ */
119
+ getPermit(owner: string): OwnerPermit | undefined;
120
+ /**
121
+ * Check allowance from an owner
122
+ */
123
+ checkAllowance(owner: string): Promise<{
124
+ allowance: string;
125
+ ownerBalance: string;
126
+ canSpend: boolean;
127
+ }>;
128
+ /**
129
+ * Spend USDC from Owner's wallet
130
+ *
131
+ * @param to - Recipient (service provider)
132
+ * @param amount - Amount in USDC
133
+ * @param permit - Optional, uses stored permit if not provided
134
+ */
135
+ spend(to: string, amount: number, permit?: OwnerPermit): Promise<SpendResult>;
136
+ /**
137
+ * Get gas balance (ETH needed for transactions)
138
+ */
139
+ getGasBalance(): Promise<string>;
140
+ /**
141
+ * Check if agent has enough gas
142
+ */
143
+ hasGas(minEth?: number): Promise<boolean>;
144
+ /**
145
+ * Generate authorization request for Owner
146
+ * Owner can sign this with CLI (ethers) or MetaMask
147
+ */
148
+ generateAuthRequest(params: {
149
+ ownerAddress: string;
150
+ amount: number;
151
+ expiresInHours?: number;
152
+ }): Promise<{
153
+ message: string;
154
+ typedData: object;
155
+ cliCommand: string;
156
+ }>;
157
+ }
158
+ /**
159
+ * Quick helper to get agent address (auto-initializes if needed)
160
+ */
161
+ declare function getAgentAddress(config?: AgentWalletConfig): string;
162
+
53
163
  /**
54
164
  * AuditLog - Immutable Audit Log
55
165
  *
@@ -429,4 +539,4 @@ declare function parseStatusMarker(message: string): {
429
539
  data: Record<string, string>;
430
540
  } | null;
431
541
 
432
- export { AuditAction, AuditEntry, AuditLog, BuyerTemplates, ChainConfig, ChainName, CreateInvoiceParams, Invoice, PaymentAgent, PaymentAgentConfig, type Receipt, type ReceiptParams, SellerTemplates, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, parseStatusMarker };
542
+ export { AgentWallet, AuditAction, AuditEntry, AuditLog, BuyerTemplates, ChainConfig, ChainName, CreateInvoiceParams, Invoice, PaymentAgent, PaymentAgentConfig, type Receipt, type ReceiptParams, SellerTemplates, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, getAgentAddress, parseStatusMarker };
package/dist/index.d.ts CHANGED
@@ -50,6 +50,116 @@ declare class PaymentAgent {
50
50
  formatInvoiceMessage(invoice: Invoice, includeJson?: boolean): string;
51
51
  }
52
52
 
53
+ /**
54
+ * AgentWallet - Zero-config wallet for AI Agents
55
+ *
56
+ * Design principles:
57
+ * - Auto-initialize on first use (no manual setup)
58
+ * - Generate address locally (no gas needed)
59
+ * - Owner authorizes via Permit (can be CLI or UI)
60
+ * - Agent only needs gas when actually spending
61
+ */
62
+
63
+ interface OwnerPermit {
64
+ owner: string;
65
+ value: string;
66
+ deadline: number;
67
+ nonce: number;
68
+ v: number;
69
+ r: string;
70
+ s: string;
71
+ }
72
+ interface AgentWalletConfig {
73
+ /** Storage directory for wallet data (default: ~/.moltspay) */
74
+ storageDir?: string;
75
+ /** Chain to use */
76
+ chain?: ChainName;
77
+ /** Custom RPC URL */
78
+ rpcUrl?: string;
79
+ }
80
+ interface SpendResult {
81
+ success: boolean;
82
+ txHash?: string;
83
+ error?: string;
84
+ from: string;
85
+ to: string;
86
+ amount: number;
87
+ remainingAllowance?: string;
88
+ explorerUrl?: string;
89
+ }
90
+ declare class AgentWallet {
91
+ readonly chain: ChainName;
92
+ readonly chainConfig: ChainConfig;
93
+ readonly storageDir: string;
94
+ private _address;
95
+ private _privateKey;
96
+ private _wallet;
97
+ private _provider;
98
+ private _permits;
99
+ constructor(config?: AgentWalletConfig);
100
+ private getDefaultStorageDir;
101
+ private getWalletPath;
102
+ private getPermitsPath;
103
+ /**
104
+ * Auto-initialize: create wallet if not exists
105
+ * This is called automatically in constructor
106
+ */
107
+ private ensureInitialized;
108
+ /** Agent's address (auto-generated on first use) */
109
+ get address(): string;
110
+ private get wallet();
111
+ private get provider();
112
+ /**
113
+ * Store a Permit from Owner
114
+ */
115
+ storePermit(permit: OwnerPermit): void;
116
+ /**
117
+ * Get stored permit for an owner
118
+ */
119
+ getPermit(owner: string): OwnerPermit | undefined;
120
+ /**
121
+ * Check allowance from an owner
122
+ */
123
+ checkAllowance(owner: string): Promise<{
124
+ allowance: string;
125
+ ownerBalance: string;
126
+ canSpend: boolean;
127
+ }>;
128
+ /**
129
+ * Spend USDC from Owner's wallet
130
+ *
131
+ * @param to - Recipient (service provider)
132
+ * @param amount - Amount in USDC
133
+ * @param permit - Optional, uses stored permit if not provided
134
+ */
135
+ spend(to: string, amount: number, permit?: OwnerPermit): Promise<SpendResult>;
136
+ /**
137
+ * Get gas balance (ETH needed for transactions)
138
+ */
139
+ getGasBalance(): Promise<string>;
140
+ /**
141
+ * Check if agent has enough gas
142
+ */
143
+ hasGas(minEth?: number): Promise<boolean>;
144
+ /**
145
+ * Generate authorization request for Owner
146
+ * Owner can sign this with CLI (ethers) or MetaMask
147
+ */
148
+ generateAuthRequest(params: {
149
+ ownerAddress: string;
150
+ amount: number;
151
+ expiresInHours?: number;
152
+ }): Promise<{
153
+ message: string;
154
+ typedData: object;
155
+ cliCommand: string;
156
+ }>;
157
+ }
158
+ /**
159
+ * Quick helper to get agent address (auto-initializes if needed)
160
+ */
161
+ declare function getAgentAddress(config?: AgentWalletConfig): string;
162
+
53
163
  /**
54
164
  * AuditLog - Immutable Audit Log
55
165
  *
@@ -429,4 +539,4 @@ declare function parseStatusMarker(message: string): {
429
539
  data: Record<string, string>;
430
540
  } | null;
431
541
 
432
- export { AuditAction, AuditEntry, AuditLog, BuyerTemplates, ChainConfig, ChainName, CreateInvoiceParams, Invoice, PaymentAgent, PaymentAgentConfig, type Receipt, type ReceiptParams, SellerTemplates, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, parseStatusMarker };
542
+ export { AgentWallet, AuditAction, AuditEntry, AuditLog, BuyerTemplates, ChainConfig, ChainName, CreateInvoiceParams, Invoice, PaymentAgent, PaymentAgentConfig, type Receipt, type ReceiptParams, SellerTemplates, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, getAgentAddress, parseStatusMarker };