@shogun-sdk/swap 0.0.2-test.19 → 0.0.2-test.20
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 +20 -11
- package/dist/core.js +20 -11
- package/dist/index.cjs +20 -11
- package/dist/index.js +20 -11
- package/dist/react.cjs +20 -11
- package/dist/react.js +20 -11
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -418,9 +418,23 @@ async function buildOrder({
|
|
|
418
418
|
|
|
419
419
|
// src/utils/pollOrderStatus.ts
|
|
420
420
|
var import_intents_sdk7 = require("@shogun-sdk/intents-sdk");
|
|
421
|
-
async function pollOrderStatus(
|
|
421
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
422
422
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
423
423
|
const startTime = Date.now();
|
|
424
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
425
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
426
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
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
|
+
}
|
|
437
|
+
const queryUrl = `${import_intents_sdk7.AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
424
438
|
return new Promise((resolve, reject) => {
|
|
425
439
|
const pollInterval = setInterval(async () => {
|
|
426
440
|
try {
|
|
@@ -428,12 +442,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
428
442
|
clearInterval(pollInterval);
|
|
429
443
|
return resolve("Timeout");
|
|
430
444
|
}
|
|
431
|
-
const res = await fetch(
|
|
445
|
+
const res = await fetch(queryUrl, {
|
|
432
446
|
method: "GET",
|
|
433
|
-
headers: {
|
|
434
|
-
Authorization: `Bearer ${jwt}`,
|
|
435
|
-
"Content-Type": "application/json"
|
|
436
|
-
}
|
|
447
|
+
headers: { "Content-Type": "application/json" }
|
|
437
448
|
});
|
|
438
449
|
if (!res.ok) {
|
|
439
450
|
clearInterval(pollInterval);
|
|
@@ -455,7 +466,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
455
466
|
return resolve("NotFound");
|
|
456
467
|
}
|
|
457
468
|
const { orderStatus } = targetOrder;
|
|
458
|
-
if (
|
|
469
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
459
470
|
clearInterval(pollInterval);
|
|
460
471
|
return resolve(orderStatus);
|
|
461
472
|
}
|
|
@@ -556,7 +567,6 @@ async function handleEvmExecution({
|
|
|
556
567
|
update("processing", messageFor("signing"));
|
|
557
568
|
const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk8.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk8.getEVMCrossChainOrderTypedData)(order);
|
|
558
569
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
559
|
-
console.log({ order, orderTypedData: typedData });
|
|
560
570
|
if (!wallet.signTypedData) {
|
|
561
571
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
562
572
|
}
|
|
@@ -565,7 +575,6 @@ async function handleEvmExecution({
|
|
|
565
575
|
types: typedData.types,
|
|
566
576
|
primaryType: typedData.primaryType,
|
|
567
577
|
value: typedData.message,
|
|
568
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
569
578
|
message: typedData.message
|
|
570
579
|
});
|
|
571
580
|
update("processing", messageFor("submitting"));
|
|
@@ -574,9 +583,9 @@ async function handleEvmExecution({
|
|
|
574
583
|
throw new Error("Auctioneer submission failed");
|
|
575
584
|
}
|
|
576
585
|
update("initiated", messageFor("initiated"));
|
|
577
|
-
const {
|
|
586
|
+
const { intentId: orderId } = res.data;
|
|
578
587
|
update("initiated", messageFor("shogun_processing"));
|
|
579
|
-
const status = await pollOrderStatus(
|
|
588
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
580
589
|
return await handleOrderPollingResult({
|
|
581
590
|
status,
|
|
582
591
|
orderId,
|
package/dist/core.js
CHANGED
|
@@ -386,9 +386,23 @@ async function buildOrder({
|
|
|
386
386
|
|
|
387
387
|
// src/utils/pollOrderStatus.ts
|
|
388
388
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
389
|
-
async function pollOrderStatus(
|
|
389
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
390
390
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
391
391
|
const startTime = Date.now();
|
|
392
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
393
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
394
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
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
|
+
}
|
|
405
|
+
const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
392
406
|
return new Promise((resolve, reject) => {
|
|
393
407
|
const pollInterval = setInterval(async () => {
|
|
394
408
|
try {
|
|
@@ -396,12 +410,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
396
410
|
clearInterval(pollInterval);
|
|
397
411
|
return resolve("Timeout");
|
|
398
412
|
}
|
|
399
|
-
const res = await fetch(
|
|
413
|
+
const res = await fetch(queryUrl, {
|
|
400
414
|
method: "GET",
|
|
401
|
-
headers: {
|
|
402
|
-
Authorization: `Bearer ${jwt}`,
|
|
403
|
-
"Content-Type": "application/json"
|
|
404
|
-
}
|
|
415
|
+
headers: { "Content-Type": "application/json" }
|
|
405
416
|
});
|
|
406
417
|
if (!res.ok) {
|
|
407
418
|
clearInterval(pollInterval);
|
|
@@ -423,7 +434,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
423
434
|
return resolve("NotFound");
|
|
424
435
|
}
|
|
425
436
|
const { orderStatus } = targetOrder;
|
|
426
|
-
if (
|
|
437
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
427
438
|
clearInterval(pollInterval);
|
|
428
439
|
return resolve(orderStatus);
|
|
429
440
|
}
|
|
@@ -524,7 +535,6 @@ async function handleEvmExecution({
|
|
|
524
535
|
update("processing", messageFor("signing"));
|
|
525
536
|
const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
|
|
526
537
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
527
|
-
console.log({ order, orderTypedData: typedData });
|
|
528
538
|
if (!wallet.signTypedData) {
|
|
529
539
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
530
540
|
}
|
|
@@ -533,7 +543,6 @@ async function handleEvmExecution({
|
|
|
533
543
|
types: typedData.types,
|
|
534
544
|
primaryType: typedData.primaryType,
|
|
535
545
|
value: typedData.message,
|
|
536
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
537
546
|
message: typedData.message
|
|
538
547
|
});
|
|
539
548
|
update("processing", messageFor("submitting"));
|
|
@@ -542,9 +551,9 @@ async function handleEvmExecution({
|
|
|
542
551
|
throw new Error("Auctioneer submission failed");
|
|
543
552
|
}
|
|
544
553
|
update("initiated", messageFor("initiated"));
|
|
545
|
-
const {
|
|
554
|
+
const { intentId: orderId } = res.data;
|
|
546
555
|
update("initiated", messageFor("shogun_processing"));
|
|
547
|
-
const status = await pollOrderStatus(
|
|
556
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
548
557
|
return await handleOrderPollingResult({
|
|
549
558
|
status,
|
|
550
559
|
orderId,
|
package/dist/index.cjs
CHANGED
|
@@ -502,9 +502,23 @@ async function buildOrder({
|
|
|
502
502
|
|
|
503
503
|
// src/utils/pollOrderStatus.ts
|
|
504
504
|
var import_intents_sdk7 = require("@shogun-sdk/intents-sdk");
|
|
505
|
-
async function pollOrderStatus(
|
|
505
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
506
506
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
507
507
|
const startTime = Date.now();
|
|
508
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
509
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
510
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
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
|
+
}
|
|
521
|
+
const queryUrl = `${import_intents_sdk7.AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
508
522
|
return new Promise((resolve, reject) => {
|
|
509
523
|
const pollInterval = setInterval(async () => {
|
|
510
524
|
try {
|
|
@@ -512,12 +526,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
512
526
|
clearInterval(pollInterval);
|
|
513
527
|
return resolve("Timeout");
|
|
514
528
|
}
|
|
515
|
-
const res = await fetch(
|
|
529
|
+
const res = await fetch(queryUrl, {
|
|
516
530
|
method: "GET",
|
|
517
|
-
headers: {
|
|
518
|
-
Authorization: `Bearer ${jwt}`,
|
|
519
|
-
"Content-Type": "application/json"
|
|
520
|
-
}
|
|
531
|
+
headers: { "Content-Type": "application/json" }
|
|
521
532
|
});
|
|
522
533
|
if (!res.ok) {
|
|
523
534
|
clearInterval(pollInterval);
|
|
@@ -539,7 +550,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
539
550
|
return resolve("NotFound");
|
|
540
551
|
}
|
|
541
552
|
const { orderStatus } = targetOrder;
|
|
542
|
-
if (
|
|
553
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
543
554
|
clearInterval(pollInterval);
|
|
544
555
|
return resolve(orderStatus);
|
|
545
556
|
}
|
|
@@ -640,7 +651,6 @@ async function handleEvmExecution({
|
|
|
640
651
|
update("processing", messageFor("signing"));
|
|
641
652
|
const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk8.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk8.getEVMCrossChainOrderTypedData)(order);
|
|
642
653
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
643
|
-
console.log({ order, orderTypedData: typedData });
|
|
644
654
|
if (!wallet.signTypedData) {
|
|
645
655
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
646
656
|
}
|
|
@@ -649,7 +659,6 @@ async function handleEvmExecution({
|
|
|
649
659
|
types: typedData.types,
|
|
650
660
|
primaryType: typedData.primaryType,
|
|
651
661
|
value: typedData.message,
|
|
652
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
653
662
|
message: typedData.message
|
|
654
663
|
});
|
|
655
664
|
update("processing", messageFor("submitting"));
|
|
@@ -658,9 +667,9 @@ async function handleEvmExecution({
|
|
|
658
667
|
throw new Error("Auctioneer submission failed");
|
|
659
668
|
}
|
|
660
669
|
update("initiated", messageFor("initiated"));
|
|
661
|
-
const {
|
|
670
|
+
const { intentId: orderId } = res.data;
|
|
662
671
|
update("initiated", messageFor("shogun_processing"));
|
|
663
|
-
const status = await pollOrderStatus(
|
|
672
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
664
673
|
return await handleOrderPollingResult({
|
|
665
674
|
status,
|
|
666
675
|
orderId,
|
package/dist/index.js
CHANGED
|
@@ -467,9 +467,23 @@ async function buildOrder({
|
|
|
467
467
|
|
|
468
468
|
// src/utils/pollOrderStatus.ts
|
|
469
469
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
470
|
-
async function pollOrderStatus(
|
|
470
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
471
471
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
472
472
|
const startTime = Date.now();
|
|
473
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
474
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
475
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
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
|
+
}
|
|
486
|
+
const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
473
487
|
return new Promise((resolve, reject) => {
|
|
474
488
|
const pollInterval = setInterval(async () => {
|
|
475
489
|
try {
|
|
@@ -477,12 +491,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
477
491
|
clearInterval(pollInterval);
|
|
478
492
|
return resolve("Timeout");
|
|
479
493
|
}
|
|
480
|
-
const res = await fetch(
|
|
494
|
+
const res = await fetch(queryUrl, {
|
|
481
495
|
method: "GET",
|
|
482
|
-
headers: {
|
|
483
|
-
Authorization: `Bearer ${jwt}`,
|
|
484
|
-
"Content-Type": "application/json"
|
|
485
|
-
}
|
|
496
|
+
headers: { "Content-Type": "application/json" }
|
|
486
497
|
});
|
|
487
498
|
if (!res.ok) {
|
|
488
499
|
clearInterval(pollInterval);
|
|
@@ -504,7 +515,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
504
515
|
return resolve("NotFound");
|
|
505
516
|
}
|
|
506
517
|
const { orderStatus } = targetOrder;
|
|
507
|
-
if (
|
|
518
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
508
519
|
clearInterval(pollInterval);
|
|
509
520
|
return resolve(orderStatus);
|
|
510
521
|
}
|
|
@@ -605,7 +616,6 @@ async function handleEvmExecution({
|
|
|
605
616
|
update("processing", messageFor("signing"));
|
|
606
617
|
const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
|
|
607
618
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
608
|
-
console.log({ order, orderTypedData: typedData });
|
|
609
619
|
if (!wallet.signTypedData) {
|
|
610
620
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
611
621
|
}
|
|
@@ -614,7 +624,6 @@ async function handleEvmExecution({
|
|
|
614
624
|
types: typedData.types,
|
|
615
625
|
primaryType: typedData.primaryType,
|
|
616
626
|
value: typedData.message,
|
|
617
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
618
627
|
message: typedData.message
|
|
619
628
|
});
|
|
620
629
|
update("processing", messageFor("submitting"));
|
|
@@ -623,9 +632,9 @@ async function handleEvmExecution({
|
|
|
623
632
|
throw new Error("Auctioneer submission failed");
|
|
624
633
|
}
|
|
625
634
|
update("initiated", messageFor("initiated"));
|
|
626
|
-
const {
|
|
635
|
+
const { intentId: orderId } = res.data;
|
|
627
636
|
update("initiated", messageFor("shogun_processing"));
|
|
628
|
-
const status = await pollOrderStatus(
|
|
637
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
629
638
|
return await handleOrderPollingResult({
|
|
630
639
|
status,
|
|
631
640
|
orderId,
|
package/dist/react.cjs
CHANGED
|
@@ -354,9 +354,23 @@ async function buildOrder({
|
|
|
354
354
|
|
|
355
355
|
// src/utils/pollOrderStatus.ts
|
|
356
356
|
var import_intents_sdk5 = require("@shogun-sdk/intents-sdk");
|
|
357
|
-
async function pollOrderStatus(
|
|
357
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
358
358
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
359
359
|
const startTime = Date.now();
|
|
360
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
361
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
362
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
363
|
+
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
|
+
}
|
|
373
|
+
const queryUrl = `${import_intents_sdk5.AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
360
374
|
return new Promise((resolve, reject) => {
|
|
361
375
|
const pollInterval = setInterval(async () => {
|
|
362
376
|
try {
|
|
@@ -364,12 +378,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
364
378
|
clearInterval(pollInterval);
|
|
365
379
|
return resolve("Timeout");
|
|
366
380
|
}
|
|
367
|
-
const res = await fetch(
|
|
381
|
+
const res = await fetch(queryUrl, {
|
|
368
382
|
method: "GET",
|
|
369
|
-
headers: {
|
|
370
|
-
Authorization: `Bearer ${jwt}`,
|
|
371
|
-
"Content-Type": "application/json"
|
|
372
|
-
}
|
|
383
|
+
headers: { "Content-Type": "application/json" }
|
|
373
384
|
});
|
|
374
385
|
if (!res.ok) {
|
|
375
386
|
clearInterval(pollInterval);
|
|
@@ -391,7 +402,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
391
402
|
return resolve("NotFound");
|
|
392
403
|
}
|
|
393
404
|
const { orderStatus } = targetOrder;
|
|
394
|
-
if (
|
|
405
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
395
406
|
clearInterval(pollInterval);
|
|
396
407
|
return resolve(orderStatus);
|
|
397
408
|
}
|
|
@@ -492,7 +503,6 @@ async function handleEvmExecution({
|
|
|
492
503
|
update("processing", messageFor("signing"));
|
|
493
504
|
const { orderTypedData, nonce } = isSingleChain ? await (0, import_intents_sdk6.getEVMSingleChainOrderTypedData)(order) : await (0, import_intents_sdk6.getEVMCrossChainOrderTypedData)(order);
|
|
494
505
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
495
|
-
console.log({ order, orderTypedData: typedData });
|
|
496
506
|
if (!wallet.signTypedData) {
|
|
497
507
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
498
508
|
}
|
|
@@ -501,7 +511,6 @@ async function handleEvmExecution({
|
|
|
501
511
|
types: typedData.types,
|
|
502
512
|
primaryType: typedData.primaryType,
|
|
503
513
|
value: typedData.message,
|
|
504
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
505
514
|
message: typedData.message
|
|
506
515
|
});
|
|
507
516
|
update("processing", messageFor("submitting"));
|
|
@@ -510,9 +519,9 @@ async function handleEvmExecution({
|
|
|
510
519
|
throw new Error("Auctioneer submission failed");
|
|
511
520
|
}
|
|
512
521
|
update("initiated", messageFor("initiated"));
|
|
513
|
-
const {
|
|
522
|
+
const { intentId: orderId } = res.data;
|
|
514
523
|
update("initiated", messageFor("shogun_processing"));
|
|
515
|
-
const status = await pollOrderStatus(
|
|
524
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
516
525
|
return await handleOrderPollingResult({
|
|
517
526
|
status,
|
|
518
527
|
orderId,
|
package/dist/react.js
CHANGED
|
@@ -329,9 +329,23 @@ async function buildOrder({
|
|
|
329
329
|
|
|
330
330
|
// src/utils/pollOrderStatus.ts
|
|
331
331
|
import { AUCTIONEER_URL } from "@shogun-sdk/intents-sdk";
|
|
332
|
-
async function pollOrderStatus(
|
|
332
|
+
async function pollOrderStatus(address, orderId, options = {}) {
|
|
333
333
|
const { intervalMs = 2e3, timeoutMs = 3e5 } = options;
|
|
334
334
|
const startTime = Date.now();
|
|
335
|
+
const isEvmAddress = /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
336
|
+
const isSuiAddress = /^0x[a-fA-F0-9]{64}$/.test(address);
|
|
337
|
+
const isSolanaAddress = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
|
|
338
|
+
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
|
+
}
|
|
348
|
+
const queryUrl = `${AUCTIONEER_URL}/user_intent?${queryParam}`;
|
|
335
349
|
return new Promise((resolve, reject) => {
|
|
336
350
|
const pollInterval = setInterval(async () => {
|
|
337
351
|
try {
|
|
@@ -339,12 +353,9 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
339
353
|
clearInterval(pollInterval);
|
|
340
354
|
return resolve("Timeout");
|
|
341
355
|
}
|
|
342
|
-
const res = await fetch(
|
|
356
|
+
const res = await fetch(queryUrl, {
|
|
343
357
|
method: "GET",
|
|
344
|
-
headers: {
|
|
345
|
-
Authorization: `Bearer ${jwt}`,
|
|
346
|
-
"Content-Type": "application/json"
|
|
347
|
-
}
|
|
358
|
+
headers: { "Content-Type": "application/json" }
|
|
348
359
|
});
|
|
349
360
|
if (!res.ok) {
|
|
350
361
|
clearInterval(pollInterval);
|
|
@@ -366,7 +377,7 @@ async function pollOrderStatus(jwt, orderId, options = {}) {
|
|
|
366
377
|
return resolve("NotFound");
|
|
367
378
|
}
|
|
368
379
|
const { orderStatus } = targetOrder;
|
|
369
|
-
if (
|
|
380
|
+
if (["Fulfilled", "Cancelled", "Outdated"].includes(orderStatus)) {
|
|
370
381
|
clearInterval(pollInterval);
|
|
371
382
|
return resolve(orderStatus);
|
|
372
383
|
}
|
|
@@ -467,7 +478,6 @@ async function handleEvmExecution({
|
|
|
467
478
|
update("processing", messageFor("signing"));
|
|
468
479
|
const { orderTypedData, nonce } = isSingleChain ? await getEVMSingleChainOrderTypedData(order) : await getEVMCrossChainOrderTypedData(order);
|
|
469
480
|
const typedData = serializeBigIntsToStrings(orderTypedData);
|
|
470
|
-
console.log({ order, orderTypedData: typedData });
|
|
471
481
|
if (!wallet.signTypedData) {
|
|
472
482
|
throw new Error("Wallet does not support EIP-712 signing");
|
|
473
483
|
}
|
|
@@ -476,7 +486,6 @@ async function handleEvmExecution({
|
|
|
476
486
|
types: typedData.types,
|
|
477
487
|
primaryType: typedData.primaryType,
|
|
478
488
|
value: typedData.message,
|
|
479
|
-
// Preserve `message` for adapters that might still expect original viem shape.
|
|
480
489
|
message: typedData.message
|
|
481
490
|
});
|
|
482
491
|
update("processing", messageFor("submitting"));
|
|
@@ -485,9 +494,9 @@ async function handleEvmExecution({
|
|
|
485
494
|
throw new Error("Auctioneer submission failed");
|
|
486
495
|
}
|
|
487
496
|
update("initiated", messageFor("initiated"));
|
|
488
|
-
const {
|
|
497
|
+
const { intentId: orderId } = res.data;
|
|
489
498
|
update("initiated", messageFor("shogun_processing"));
|
|
490
|
-
const status = await pollOrderStatus(
|
|
499
|
+
const status = await pollOrderStatus(accountAddress, orderId);
|
|
491
500
|
return await handleOrderPollingResult({
|
|
492
501
|
status,
|
|
493
502
|
orderId,
|