@shogun-sdk/swap 0.0.2-test.20 → 0.0.2-test.21

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/core.cjs CHANGED
@@ -177,7 +177,6 @@ async function getQuote(params) {
177
177
  tokenOut: params.tokenOut.address,
178
178
  amount: params.amount
179
179
  });
180
- console.log({ data });
181
180
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
182
181
  let warning;
183
182
  if (slippagePercent > 10) {
@@ -421,19 +420,15 @@ var import_intents_sdk7 = require("@shogun-sdk/intents-sdk");
421
420
  async function pollOrderStatus(address, orderId, options = {}) {
422
421
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
423
422
  const startTime = Date.now();
423
+ const isDebug = process.env.NODE_ENV !== "production";
424
424
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
425
425
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
426
426
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
427
427
  let queryParam;
428
- if (isEvmAddress) {
429
- queryParam = `evmWallets=${address}`;
430
- } else if (isSuiAddress) {
431
- queryParam = `suiWallets=${address}`;
432
- } else if (isSolanaAddress) {
433
- queryParam = `solanaWallets=${address}`;
434
- } else {
435
- throw new Error(`Unrecognized wallet address format: ${address}`);
436
- }
428
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
429
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
430
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
431
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
437
432
  const queryUrl = `${import_intents_sdk7.AUCTIONEER_URL}/user_intent?${queryParam}`;
438
433
  return new Promise((resolve, reject) => {
439
434
  const pollInterval = setInterval(async () => {
@@ -462,10 +457,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
462
457
  ];
463
458
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
464
459
  if (!targetOrder) {
465
- clearInterval(pollInterval);
466
- return resolve("NotFound");
460
+ if (isDebug)
461
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
462
+ return;
467
463
  }
468
464
  const { orderStatus } = targetOrder;
465
+ if (isDebug) {
466
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
467
+ console.debug(`targetOrder`, targetOrder);
468
+ console.debug(
469
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
470
+ );
471
+ }
469
472
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
470
473
  clearInterval(pollInterval);
471
474
  return resolve(orderStatus);
@@ -550,7 +553,7 @@ async function handleEvmExecution({
550
553
  data: (0, import_viem3.encodeFunctionData)({
551
554
  abi: import_viem3.erc20Abi,
552
555
  functionName: "approve",
553
- args: [import_intents_sdk8.PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
556
+ args: [import_intents_sdk8.PERMIT2_ADDRESS[chainId], quote.amountIn]
554
557
  }),
555
558
  value: 0n,
556
559
  from: accountAddress
@@ -564,6 +567,7 @@ async function handleEvmExecution({
564
567
  deadline,
565
568
  isSingleChain
566
569
  });
570
+ console.debug(`order`, order);
567
571
  update("processing", messageFor("signing"));
568
572
  const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk8.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk8.getEVMCrossChainOrderTypedData)(order);
569
573
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -691,7 +695,7 @@ async function executeOrder({
691
695
  }) {
692
696
  const isDev = process.env.NODE_ENV !== "production";
693
697
  const log = (...args) => {
694
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
698
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
695
699
  };
696
700
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
697
701
  const update = (stage, message) => {
package/dist/core.js CHANGED
@@ -139,7 +139,6 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- console.log({ data });
143
142
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
144
143
  let warning;
145
144
  if (slippagePercent > 10) {
@@ -389,19 +388,15 @@ import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
389
388
  async function pollOrderStatus(address, orderId, options = {}) {
390
389
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
391
390
  const startTime = Date.now();
391
+ const isDebug = process.env.NODE_ENV !== "production";
392
392
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
393
393
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
394
394
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
395
395
  let queryParam;
396
- if (isEvmAddress) {
397
- queryParam = `evmWallets=${address}`;
398
- } else if (isSuiAddress) {
399
- queryParam = `suiWallets=${address}`;
400
- } else if (isSolanaAddress) {
401
- queryParam = `solanaWallets=${address}`;
402
- } else {
403
- throw new Error(`Unrecognized wallet address format: ${address}`);
404
- }
396
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
397
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
398
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
399
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
405
400
  const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
406
401
  return new Promise((resolve, reject) => {
407
402
  const pollInterval = setInterval(async () => {
@@ -430,10 +425,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
430
425
  ];
431
426
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
432
427
  if (!targetOrder) {
433
- clearInterval(pollInterval);
434
- return resolve("NotFound");
428
+ if (isDebug)
429
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
430
+ return;
435
431
  }
436
432
  const { orderStatus } = targetOrder;
433
+ if (isDebug) {
434
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
435
+ console.debug(`targetOrder`, targetOrder);
436
+ console.debug(
437
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
438
+ );
439
+ }
437
440
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
438
441
  clearInterval(pollInterval);
439
442
  return resolve(orderStatus);
@@ -518,7 +521,7 @@ async function handleEvmExecution({
518
521
  data: encodeFunctionData({
519
522
  abi: erc20Abi,
520
523
  functionName: "approve",
521
- args: [PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
524
+ args: [PERMIT2_ADDRESS[chainId], quote.amountIn]
522
525
  }),
523
526
  value: 0n,
524
527
  from: accountAddress
@@ -532,6 +535,7 @@ async function handleEvmExecution({
532
535
  deadline,
533
536
  isSingleChain
534
537
  });
538
+ console.debug(`order`, order);
535
539
  update("processing", messageFor("signing"));
536
540
  const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
537
541
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -662,7 +666,7 @@ async function executeOrder({
662
666
  }) {
663
667
  const isDev = process.env.NODE_ENV !== "production";
664
668
  const log = (...args) => {
665
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
669
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
666
670
  };
667
671
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
668
672
  const update = (stage, message) => {
package/dist/index.cjs CHANGED
@@ -182,7 +182,6 @@ async function getQuote(params) {
182
182
  tokenOut: params.tokenOut.address,
183
183
  amount: params.amount
184
184
  });
185
- console.log({ data });
186
185
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
187
186
  let warning;
188
187
  if (slippagePercent > 10) {
@@ -302,7 +301,7 @@ var adaptSolanaWallet = (walletAddress, chainId, rpcUrl, signAndSendTransaction)
302
301
  const getChainId = async () => _chainId;
303
302
  const sendTransaction = async (transaction) => {
304
303
  const txHash = await signAndSendTransaction(transaction);
305
- console.log(`\u{1F6F0} Sent transaction: ${txHash}`);
304
+ console.debug(`\u{1F6F0} Sent transaction: ${txHash}`);
306
305
  const maxRetries = 20;
307
306
  const delayMs = 2e3;
308
307
  for (let attempt = 0; attempt < maxRetries; attempt++) {
@@ -505,19 +504,15 @@ var import_intents_sdk7 = require("@shogun-sdk/intents-sdk");
505
504
  async function pollOrderStatus(address, orderId, options = {}) {
506
505
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
507
506
  const startTime = Date.now();
507
+ const isDebug = process.env.NODE_ENV !== "production";
508
508
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
509
509
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
510
510
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
511
511
  let queryParam;
512
- if (isEvmAddress) {
513
- queryParam = `evmWallets=${address}`;
514
- } else if (isSuiAddress) {
515
- queryParam = `suiWallets=${address}`;
516
- } else if (isSolanaAddress) {
517
- queryParam = `solanaWallets=${address}`;
518
- } else {
519
- throw new Error(`Unrecognized wallet address format: ${address}`);
520
- }
512
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
513
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
514
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
515
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
521
516
  const queryUrl = `${import_intents_sdk7.AUCTIONEER_URL}/user_intent?${queryParam}`;
522
517
  return new Promise((resolve, reject) => {
523
518
  const pollInterval = setInterval(async () => {
@@ -546,10 +541,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
546
541
  ];
547
542
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
548
543
  if (!targetOrder) {
549
- clearInterval(pollInterval);
550
- return resolve("NotFound");
544
+ if (isDebug)
545
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
546
+ return;
551
547
  }
552
548
  const { orderStatus } = targetOrder;
549
+ if (isDebug) {
550
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
551
+ console.debug(`targetOrder`, targetOrder);
552
+ console.debug(
553
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
554
+ );
555
+ }
553
556
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
554
557
  clearInterval(pollInterval);
555
558
  return resolve(orderStatus);
@@ -634,7 +637,7 @@ async function handleEvmExecution({
634
637
  data: (0, import_viem3.encodeFunctionData)({
635
638
  abi: import_viem3.erc20Abi,
636
639
  functionName: "approve",
637
- args: [import_intents_sdk8.PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
640
+ args: [import_intents_sdk8.PERMIT2_ADDRESS[chainId], quote.amountIn]
638
641
  }),
639
642
  value: 0n,
640
643
  from: accountAddress
@@ -648,6 +651,7 @@ async function handleEvmExecution({
648
651
  deadline,
649
652
  isSingleChain
650
653
  });
654
+ console.debug(`order`, order);
651
655
  update("processing", messageFor("signing"));
652
656
  const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk8.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk8.getEVMCrossChainOrderTypedData)(order);
653
657
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -775,7 +779,7 @@ async function executeOrder({
775
779
  }) {
776
780
  const isDev = process.env.NODE_ENV !== "production";
777
781
  const log = (...args) => {
778
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
782
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
779
783
  };
780
784
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
781
785
  const update = (stage, message) => {
package/dist/index.js CHANGED
@@ -139,7 +139,6 @@ async function getQuote(params) {
139
139
  tokenOut: params.tokenOut.address,
140
140
  amount: params.amount
141
141
  });
142
- console.log({ data });
143
142
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
144
143
  let warning;
145
144
  if (slippagePercent > 10) {
@@ -261,7 +260,7 @@ var adaptSolanaWallet = (walletAddress, chainId, rpcUrl, signAndSendTransaction)
261
260
  const getChainId = async () => _chainId;
262
261
  const sendTransaction = async (transaction) => {
263
262
  const txHash = await signAndSendTransaction(transaction);
264
- console.log(`\u{1F6F0} Sent transaction: ${txHash}`);
263
+ console.debug(`\u{1F6F0} Sent transaction: ${txHash}`);
265
264
  const maxRetries = 20;
266
265
  const delayMs = 2e3;
267
266
  for (let attempt = 0; attempt < maxRetries; attempt++) {
@@ -470,19 +469,15 @@ import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
470
469
  async function pollOrderStatus(address, orderId, options = {}) {
471
470
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
472
471
  const startTime = Date.now();
472
+ const isDebug = process.env.NODE_ENV !== "production";
473
473
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
474
474
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
475
475
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
476
476
  let queryParam;
477
- if (isEvmAddress) {
478
- queryParam = `evmWallets=${address}`;
479
- } else if (isSuiAddress) {
480
- queryParam = `suiWallets=${address}`;
481
- } else if (isSolanaAddress) {
482
- queryParam = `solanaWallets=${address}`;
483
- } else {
484
- throw new Error(`Unrecognized wallet address format: ${address}`);
485
- }
477
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
478
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
479
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
480
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
486
481
  const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
487
482
  return new Promise((resolve, reject) => {
488
483
  const pollInterval = setInterval(async () => {
@@ -511,10 +506,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
511
506
  ];
512
507
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
513
508
  if (!targetOrder) {
514
- clearInterval(pollInterval);
515
- return resolve("NotFound");
509
+ if (isDebug)
510
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
511
+ return;
516
512
  }
517
513
  const { orderStatus } = targetOrder;
514
+ if (isDebug) {
515
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
516
+ console.debug(`targetOrder`, targetOrder);
517
+ console.debug(
518
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
519
+ );
520
+ }
518
521
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
519
522
  clearInterval(pollInterval);
520
523
  return resolve(orderStatus);
@@ -599,7 +602,7 @@ async function handleEvmExecution({
599
602
  data: encodeFunctionData({
600
603
  abi: erc20Abi,
601
604
  functionName: "approve",
602
- args: [PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
605
+ args: [PERMIT2_ADDRESS[chainId], quote.amountIn]
603
606
  }),
604
607
  value: 0n,
605
608
  from: accountAddress
@@ -613,6 +616,7 @@ async function handleEvmExecution({
613
616
  deadline,
614
617
  isSingleChain
615
618
  });
619
+ console.debug(`order`, order);
616
620
  update("processing", messageFor("signing"));
617
621
  const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
618
622
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -743,7 +747,7 @@ async function executeOrder({
743
747
  }) {
744
748
  const isDev = process.env.NODE_ENV !== "production";
745
749
  const log = (...args) => {
746
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
750
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
747
751
  };
748
752
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
749
753
  const update = (stage, message) => {
package/dist/react.cjs CHANGED
@@ -357,19 +357,15 @@ var import_intents_sdk5 = require("@shogun-sdk/intents-sdk");
357
357
  async function pollOrderStatus(address, orderId, options = {}) {
358
358
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
359
359
  const startTime = Date.now();
360
+ const isDebug = process.env.NODE_ENV !== "production";
360
361
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
361
362
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
362
363
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
363
364
  let queryParam;
364
- if (isEvmAddress) {
365
- queryParam = `evmWallets=${address}`;
366
- } else if (isSuiAddress) {
367
- queryParam = `suiWallets=${address}`;
368
- } else if (isSolanaAddress) {
369
- queryParam = `solanaWallets=${address}`;
370
- } else {
371
- throw new Error(`Unrecognized wallet address format: ${address}`);
372
- }
365
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
366
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
367
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
368
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
373
369
  const queryUrl = `${import_intents_sdk5.AUCTIONEER_URL}/user_intent?${queryParam}`;
374
370
  return new Promise((resolve, reject) => {
375
371
  const pollInterval = setInterval(async () => {
@@ -398,10 +394,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
398
394
  ];
399
395
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
400
396
  if (!targetOrder) {
401
- clearInterval(pollInterval);
402
- return resolve("NotFound");
397
+ if (isDebug)
398
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
399
+ return;
403
400
  }
404
401
  const { orderStatus } = targetOrder;
402
+ if (isDebug) {
403
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
404
+ console.debug(`targetOrder`, targetOrder);
405
+ console.debug(
406
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
407
+ );
408
+ }
405
409
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
406
410
  clearInterval(pollInterval);
407
411
  return resolve(orderStatus);
@@ -486,7 +490,7 @@ async function handleEvmExecution({
486
490
  data: (0, import_viem2.encodeFunctionData)({
487
491
  abi: import_viem2.erc20Abi,
488
492
  functionName: "approve",
489
- args: [import_intents_sdk6.PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
493
+ args: [import_intents_sdk6.PERMIT2_ADDRESS[chainId], quote.amountIn]
490
494
  }),
491
495
  value: 0n,
492
496
  from: accountAddress
@@ -500,6 +504,7 @@ async function handleEvmExecution({
500
504
  deadline,
501
505
  isSingleChain
502
506
  });
507
+ console.debug(`order`, order);
503
508
  update("processing", messageFor("signing"));
504
509
  const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk6.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk6.getEVMCrossChainOrderTypedData)(order);
505
510
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -627,7 +632,7 @@ async function executeOrder({
627
632
  }) {
628
633
  const isDev = process.env.NODE_ENV !== "production";
629
634
  const log = (...args) => {
630
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
635
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
631
636
  };
632
637
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
633
638
  const update = (stage, message) => {
@@ -806,7 +811,6 @@ async function getQuote(params) {
806
811
  tokenOut: params.tokenOut.address,
807
812
  amount: params.amount
808
813
  });
809
- console.log({ data });
810
814
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
811
815
  let warning;
812
816
  if (slippagePercent > 10) {
package/dist/react.js CHANGED
@@ -332,19 +332,15 @@ import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
332
332
  async function pollOrderStatus(address, orderId, options = {}) {
333
333
  const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
334
334
  const startTime = Date.now();
335
+ const isDebug = process.env.NODE_ENV !== "production";
335
336
  const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
336
337
  const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
337
338
  const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
338
339
  let queryParam;
339
- if (isEvmAddress) {
340
- queryParam = `evmWallets=${address}`;
341
- } else if (isSuiAddress) {
342
- queryParam = `suiWallets=${address}`;
343
- } else if (isSolanaAddress) {
344
- queryParam = `solanaWallets=${address}`;
345
- } else {
346
- throw new Error(`Unrecognized wallet address format: ${address}`);
347
- }
340
+ if (isEvmAddress) queryParam = `evmWallets=${address}`;
341
+ else if (isSuiAddress) queryParam = `suiWallets=${address}`;
342
+ else if (isSolanaAddress) queryParam = `solanaWallets=${address}`;
343
+ else throw new Error(`Unrecognized wallet address format: ${address}`);
348
344
  const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
349
345
  return new Promise((resolve, reject) => {
350
346
  const pollInterval = setInterval(async () => {
@@ -373,10 +369,18 @@ async function pollOrderStatus(address, orderId, options = {}) {
373
369
  ];
374
370
  const targetOrder = allOrders.find((o) => o.orderId === orderId);
375
371
  if (!targetOrder) {
376
- clearInterval(pollInterval);
377
- return resolve("NotFound");
372
+ if (isDebug)
373
+ console.debug(`[pollOrderStatus] [${orderId}] Not found yet`);
374
+ return;
378
375
  }
379
376
  const { orderStatus } = targetOrder;
377
+ if (isDebug) {
378
+ const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
379
+ console.debug(`targetOrder`, targetOrder);
380
+ console.debug(
381
+ `[pollOrderStatus] [${orderId}] status=${orderStatus} (elapsed ${elapsed}s)`
382
+ );
383
+ }
380
384
  if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
381
385
  clearInterval(pollInterval);
382
386
  return resolve(orderStatus);
@@ -461,7 +465,7 @@ async function handleEvmExecution({
461
465
  data: encodeFunctionData({
462
466
  abi: erc20Abi,
463
467
  functionName: "approve",
464
- args: [PERMIT2_ADDRESS[chainId], BigInt(quote.amountIn)]
468
+ args: [PERMIT2_ADDRESS[chainId], quote.amountIn]
465
469
  }),
466
470
  value: 0n,
467
471
  from: accountAddress
@@ -475,6 +479,7 @@ async function handleEvmExecution({
475
479
  deadline,
476
480
  isSingleChain
477
481
  });
482
+ console.debug(`order`, order);
478
483
  update("processing", messageFor("signing"));
479
484
  const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
480
485
  const typedData = serializeBigIntsToStrings(orderTypedData);
@@ -605,7 +610,7 @@ async function executeOrder({
605
610
  }) {
606
611
  const isDev = process.env.NODE_ENV !== "production";
607
612
  const log = (...args) => {
608
- if (isDev) console.log("[OneShot::executeOrder]", ...args);
613
+ if (isDev) console.debug("[OneShot::executeOrder]", ...args);
609
614
  };
610
615
  const messageFor = (stage) => DEFAULT_STAGE_MESSAGES[stage];
611
616
  const update = (stage, message) => {
@@ -784,7 +789,6 @@ async function getQuote(params) {
784
789
  tokenOut: params.tokenOut.address,
785
790
  amount: params.amount
786
791
  });
787
- console.log({ data });
788
792
  const slippagePercent = Math.min(Math.max(params.slippage ?? 0.5, 0), 50);
789
793
  let warning;
790
794
  if (slippagePercent > 10) {
@@ -34,7 +34,7 @@ var adaptSolanaWallet = (walletAddress, chainId, rpcUrl, signAndSendTransaction)
34
34
  const getChainId = async () => _chainId;
35
35
  const sendTransaction = async (transaction) => {
36
36
  const txHash = await signAndSendTransaction(transaction);
37
- console.log(`\u{1F6F0} Sent transaction: ${txHash}`);
37
+ console.debug(`\u{1F6F0} Sent transaction: ${txHash}`);
38
38
  const maxRetries = 20;
39
39
  const delayMs = 2e3;
40
40
  for (let attempt = 0; attempt < maxRetries; attempt++) {
@@ -8,7 +8,7 @@ var adaptSolanaWallet = (walletAddress, chainId, rpcUrl, signAndSendTransaction)
8
8
  const getChainId = async () => _chainId;
9
9
  const sendTransaction = async (transaction) => {
10
10
  const txHash = await signAndSendTransaction(transaction);
11
- console.log(`\u{1F6F0} Sent transaction: ${txHash}`);
11
+ console.debug(`\u{1F6F0} Sent transaction: ${txHash}`);
12
12
  const maxRetries = 20;
13
13
  const delayMs = 2e3;
14
14
  for (let attempt = 0; attempt < maxRetries; attempt++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shogun-sdk/swap",
3
- "version": "0.0.2-test.20",
3
+ "version": "0.0.2-test.21",
4
4
  "type": "module",
5
5
  "description": "Shogun Network Swap utilities and helpers",
6
6
  "author": "Shogun Network",
@@ -57,7 +57,7 @@
57
57
  "@solana/web3.js": "^1.98.4",
58
58
  "ethers": "^5.6.1",
59
59
  "wagmi": "2.18.0",
60
- "@shogun-sdk/intents-sdk": "1.2.6-test.4"
60
+ "@shogun-sdk/intents-sdk": "1.2.6-test.3"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "viem": "^2.38.1",