@ziongateway/sdk 0.1.6 → 0.1.7
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/ZionAgent.js +15 -5
- package/package.json +2 -2
package/dist/ZionAgent.js
CHANGED
|
@@ -283,12 +283,17 @@ class ZionAgent {
|
|
|
283
283
|
console.log("[ZionAgent] Attempting Gasless Transaction via Kora...");
|
|
284
284
|
const assetMint = new web3_js_1.PublicKey(requirements.asset);
|
|
285
285
|
// 1. Get payer signer from Kora (this is the account paying gas)
|
|
286
|
-
const
|
|
286
|
+
const payerResponse = await this.koraClient.getPayerSigner();
|
|
287
|
+
// Handle potential API format changes
|
|
288
|
+
if (!payerResponse || !payerResponse.signer_address) {
|
|
289
|
+
throw new Error("Kora API error: Invalid response format - missing signer_address");
|
|
290
|
+
}
|
|
291
|
+
const feePayerAddress = payerResponse.signer_address;
|
|
287
292
|
const feePayer = new web3_js_1.PublicKey(feePayerAddress);
|
|
288
|
-
// 2. Build instructions
|
|
293
|
+
// 2. Build instructions (use payTo for x402 v2)
|
|
289
294
|
const instructions = await index_1.PaymentBuilder.createExactInstructions({
|
|
290
295
|
sender: this.wallet.publicKey.toBase58(),
|
|
291
|
-
recipient: requirements.recipient,
|
|
296
|
+
recipient: requirements.payTo || requirements.recipient, // v2 uses payTo
|
|
292
297
|
amount: requirements.amount,
|
|
293
298
|
asset: requirements.asset,
|
|
294
299
|
connection: this.connection
|
|
@@ -316,6 +321,9 @@ class ZionAgent {
|
|
|
316
321
|
signature = bs58_1.default.encode(signedTx.signature);
|
|
317
322
|
}
|
|
318
323
|
}
|
|
324
|
+
if (!signature) {
|
|
325
|
+
throw new Error("Kora API error: No signature returned from transaction");
|
|
326
|
+
}
|
|
319
327
|
if (this.debug)
|
|
320
328
|
console.log(`[ZionAgent] Kora Transaction Sent: ${signature}`);
|
|
321
329
|
await this.connection.confirmTransaction(signature, "confirmed");
|
|
@@ -332,7 +340,9 @@ class ZionAgent {
|
|
|
332
340
|
*/
|
|
333
341
|
async executePayment(requirements) {
|
|
334
342
|
const assetMint = new web3_js_1.PublicKey(requirements.asset);
|
|
335
|
-
|
|
343
|
+
// x402 v2 uses payTo, fallback to recipient for compatibility
|
|
344
|
+
const recipientAddress = requirements.payTo || requirements.recipient;
|
|
345
|
+
const recipient = new web3_js_1.PublicKey(recipientAddress);
|
|
336
346
|
const senderAta = await (0, spl_token_1.getAssociatedTokenAddress)(assetMint, this.wallet.publicKey);
|
|
337
347
|
const recipientAta = await (0, spl_token_1.getAssociatedTokenAddress)(assetMint, recipient);
|
|
338
348
|
try {
|
|
@@ -357,7 +367,7 @@ class ZionAgent {
|
|
|
357
367
|
}
|
|
358
368
|
const instructions = await index_1.PaymentBuilder.createExactInstructions({
|
|
359
369
|
sender: this.wallet.publicKey.toBase58(),
|
|
360
|
-
recipient:
|
|
370
|
+
recipient: recipientAddress, // Use the resolved address
|
|
361
371
|
amount: requirements.amount,
|
|
362
372
|
asset: requirements.asset,
|
|
363
373
|
connection: this.connection
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziongateway/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "TypeScript SDK for Zion x402 Facilitator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,4 +40,4 @@
|
|
|
40
40
|
"README.md"
|
|
41
41
|
],
|
|
42
42
|
"homepage": "https://docs.ziongateway.xyz"
|
|
43
|
-
}
|
|
43
|
+
}
|