@shogun-sdk/swap 0.0.2-test.27 → 0.0.2-test.29
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 +307 -0
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +317 -0
- package/dist/{index-CmsKzdEu.d.cts → index-6Wt_Nfub.d.cts} +35 -18
- package/dist/{index-Qoc6Q9XN.d.ts → index-DdO3mOAE.d.ts} +35 -18
- package/dist/index.cjs +307 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +317 -0
- package/dist/react.cjs +348 -0
- package/dist/react.d.cts +32 -4
- package/dist/react.d.ts +32 -4
- package/dist/react.js +358 -0
- package/package.json +1 -1
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
1
|
+
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, ApiCrossChainOrder, ApiSingleChainOrder, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.cjs';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
|
|
5
|
+
type ChainId$1 = ChainID;
|
|
6
|
+
interface SupportedChain {
|
|
7
|
+
id: ChainId$1;
|
|
8
|
+
name: string;
|
|
9
|
+
isEVM: boolean;
|
|
10
|
+
wrapped: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
decimals: number;
|
|
13
|
+
tokenAddress: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
/**
|
|
6
17
|
* Token metadata used in quotes.
|
|
7
18
|
* Provides address, decimals, and optional symbol.
|
|
@@ -26,9 +37,9 @@ type SwapQuoteParams = {
|
|
|
26
37
|
/** Token you’re swapping *to* */
|
|
27
38
|
tokenOut: QuoteTokenInfo;
|
|
28
39
|
/** The source chain ID — where the swap starts */
|
|
29
|
-
sourceChainId:
|
|
40
|
+
sourceChainId: ChainId$1;
|
|
30
41
|
/** The destination chain ID — where the swap ends */
|
|
31
|
-
destChainId:
|
|
42
|
+
destChainId: ChainId$1;
|
|
32
43
|
/** Input amount (smallest unit — wei, lamports, etc.) */
|
|
33
44
|
amount: string;
|
|
34
45
|
slippage?: number;
|
|
@@ -49,11 +60,11 @@ type SwapQuoteResponse = {
|
|
|
49
60
|
minStablecoinsAmount: bigint;
|
|
50
61
|
/** Metadata for input token (includes decimals & chain ID) */
|
|
51
62
|
tokenIn: QuoteTokenInfo & {
|
|
52
|
-
chainId:
|
|
63
|
+
chainId: ChainId$1;
|
|
53
64
|
};
|
|
54
65
|
/** Metadata for output token (includes decimals & chain ID) */
|
|
55
66
|
tokenOut: QuoteTokenInfo & {
|
|
56
|
-
chainId:
|
|
67
|
+
chainId: ChainId$1;
|
|
57
68
|
};
|
|
58
69
|
/**
|
|
59
70
|
* Derived: how many tokenOut for 1 tokenIn (raw, 1e18 scaled bigint)
|
|
@@ -314,6 +325,23 @@ declare class SwapSDK {
|
|
|
314
325
|
evmAddress?: string | null;
|
|
315
326
|
solAddress?: string | null;
|
|
316
327
|
}): Promise<ApiUserOrders>;
|
|
328
|
+
/**
|
|
329
|
+
* Cancels an order (single-chain or cross-chain) on EVM or Solana.
|
|
330
|
+
*
|
|
331
|
+
* Internally routes to the correct guard contract or Solana program to
|
|
332
|
+
* deactivate the order or invalidate its nonce.
|
|
333
|
+
*
|
|
334
|
+
* @param params.order - Order payload returned from the Intents API.
|
|
335
|
+
* @param params.wallet - Adapted wallet used to submit the cancellation transaction.
|
|
336
|
+
* @param params.solRpc - Solana RPC URL used for SVM cancellations.
|
|
337
|
+
*
|
|
338
|
+
* @returns A transaction signature or hash from the underlying wallet.
|
|
339
|
+
*/
|
|
340
|
+
cancelOrder(params: {
|
|
341
|
+
order: ApiCrossChainOrder | ApiSingleChainOrder;
|
|
342
|
+
wallet: AdaptedWallet;
|
|
343
|
+
solRpc: string;
|
|
344
|
+
}): Promise<string>;
|
|
317
345
|
}
|
|
318
346
|
|
|
319
347
|
/**
|
|
@@ -340,7 +368,7 @@ declare enum OrderExecutionType {
|
|
|
340
368
|
* Public filtered enum — exposes only currently supported chains.
|
|
341
369
|
*
|
|
342
370
|
*/
|
|
343
|
-
declare const ChainId
|
|
371
|
+
declare const ChainId: Partial<Record<"Arbitrum" | "Optimism" | "Base" | "Hyperliquid" | "BSC" | "Solana" | "Sui", number>>;
|
|
344
372
|
/**
|
|
345
373
|
* Public chains — only currently supported ones.
|
|
346
374
|
*/
|
|
@@ -363,15 +391,4 @@ declare const SupportedChains: ({
|
|
|
363
391
|
})[];
|
|
364
392
|
declare const isEvmChain: typeof isEvmChain$1;
|
|
365
393
|
|
|
366
|
-
type ChainId
|
|
367
|
-
interface SupportedChain {
|
|
368
|
-
id: ChainId;
|
|
369
|
-
name: string;
|
|
370
|
-
isEVM: boolean;
|
|
371
|
-
wrapped: string;
|
|
372
|
-
symbol: string;
|
|
373
|
-
decimals: number;
|
|
374
|
-
tokenAddress: string;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export { type BalanceRequestParams as B, ChainId$1 as C, type ExecuteOrderParams as E, OrderExecutionType as O, type PlaceOrderResult as P, type SwapSDKConfig as S, type TokenInfo as T, SwapSDK as a, type SwapQuoteParams as b, type SwapQuoteResponse as c, type Stage as d, type BalanceResponse as e, buildQuoteParams as f, SupportedChains as g, type TokenBalance as h, isEvmChain as i, type SupportedChain as j };
|
|
394
|
+
export { type BalanceRequestParams as B, ChainId as C, type ExecuteOrderParams as E, OrderExecutionType as O, type PlaceOrderResult as P, type SwapSDKConfig as S, type TokenInfo as T, SwapSDK as a, type SwapQuoteParams as b, type SwapQuoteResponse as c, type Stage as d, type BalanceResponse as e, buildQuoteParams as f, SupportedChains as g, type TokenBalance as h, isEvmChain as i, type SupportedChain as j };
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
1
|
+
import { ChainID, QuoteResponse, ChainOrderStatus, TokenSearchResponse as TokenSearchResponse$1, TokenSearchParams, ApiUserOrders, ApiCrossChainOrder, ApiSingleChainOrder, isEvmChain as isEvmChain$1 } from '@shogun-sdk/intents-sdk';
|
|
2
2
|
import { A as AdaptedWallet } from './wallet-B9bKceyN.js';
|
|
3
3
|
import { WalletClient } from 'viem';
|
|
4
4
|
|
|
5
|
+
type ChainId$1 = ChainID;
|
|
6
|
+
interface SupportedChain {
|
|
7
|
+
id: ChainId$1;
|
|
8
|
+
name: string;
|
|
9
|
+
isEVM: boolean;
|
|
10
|
+
wrapped: string;
|
|
11
|
+
symbol: string;
|
|
12
|
+
decimals: number;
|
|
13
|
+
tokenAddress: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
/**
|
|
6
17
|
* Token metadata used in quotes.
|
|
7
18
|
* Provides address, decimals, and optional symbol.
|
|
@@ -26,9 +37,9 @@ type SwapQuoteParams = {
|
|
|
26
37
|
/** Token you’re swapping *to* */
|
|
27
38
|
tokenOut: QuoteTokenInfo;
|
|
28
39
|
/** The source chain ID — where the swap starts */
|
|
29
|
-
sourceChainId:
|
|
40
|
+
sourceChainId: ChainId$1;
|
|
30
41
|
/** The destination chain ID — where the swap ends */
|
|
31
|
-
destChainId:
|
|
42
|
+
destChainId: ChainId$1;
|
|
32
43
|
/** Input amount (smallest unit — wei, lamports, etc.) */
|
|
33
44
|
amount: string;
|
|
34
45
|
slippage?: number;
|
|
@@ -49,11 +60,11 @@ type SwapQuoteResponse = {
|
|
|
49
60
|
minStablecoinsAmount: bigint;
|
|
50
61
|
/** Metadata for input token (includes decimals & chain ID) */
|
|
51
62
|
tokenIn: QuoteTokenInfo & {
|
|
52
|
-
chainId:
|
|
63
|
+
chainId: ChainId$1;
|
|
53
64
|
};
|
|
54
65
|
/** Metadata for output token (includes decimals & chain ID) */
|
|
55
66
|
tokenOut: QuoteTokenInfo & {
|
|
56
|
-
chainId:
|
|
67
|
+
chainId: ChainId$1;
|
|
57
68
|
};
|
|
58
69
|
/**
|
|
59
70
|
* Derived: how many tokenOut for 1 tokenIn (raw, 1e18 scaled bigint)
|
|
@@ -314,6 +325,23 @@ declare class SwapSDK {
|
|
|
314
325
|
evmAddress?: string | null;
|
|
315
326
|
solAddress?: string | null;
|
|
316
327
|
}): Promise<ApiUserOrders>;
|
|
328
|
+
/**
|
|
329
|
+
* Cancels an order (single-chain or cross-chain) on EVM or Solana.
|
|
330
|
+
*
|
|
331
|
+
* Internally routes to the correct guard contract or Solana program to
|
|
332
|
+
* deactivate the order or invalidate its nonce.
|
|
333
|
+
*
|
|
334
|
+
* @param params.order - Order payload returned from the Intents API.
|
|
335
|
+
* @param params.wallet - Adapted wallet used to submit the cancellation transaction.
|
|
336
|
+
* @param params.solRpc - Solana RPC URL used for SVM cancellations.
|
|
337
|
+
*
|
|
338
|
+
* @returns A transaction signature or hash from the underlying wallet.
|
|
339
|
+
*/
|
|
340
|
+
cancelOrder(params: {
|
|
341
|
+
order: ApiCrossChainOrder | ApiSingleChainOrder;
|
|
342
|
+
wallet: AdaptedWallet;
|
|
343
|
+
solRpc: string;
|
|
344
|
+
}): Promise<string>;
|
|
317
345
|
}
|
|
318
346
|
|
|
319
347
|
/**
|
|
@@ -340,7 +368,7 @@ declare enum OrderExecutionType {
|
|
|
340
368
|
* Public filtered enum — exposes only currently supported chains.
|
|
341
369
|
*
|
|
342
370
|
*/
|
|
343
|
-
declare const ChainId
|
|
371
|
+
declare const ChainId: Partial<Record<"Arbitrum" | "Optimism" | "Base" | "Hyperliquid" | "BSC" | "Solana" | "Sui", number>>;
|
|
344
372
|
/**
|
|
345
373
|
* Public chains — only currently supported ones.
|
|
346
374
|
*/
|
|
@@ -363,15 +391,4 @@ declare const SupportedChains: ({
|
|
|
363
391
|
})[];
|
|
364
392
|
declare const isEvmChain: typeof isEvmChain$1;
|
|
365
393
|
|
|
366
|
-
type ChainId
|
|
367
|
-
interface SupportedChain {
|
|
368
|
-
id: ChainId;
|
|
369
|
-
name: string;
|
|
370
|
-
isEVM: boolean;
|
|
371
|
-
wrapped: string;
|
|
372
|
-
symbol: string;
|
|
373
|
-
decimals: number;
|
|
374
|
-
tokenAddress: string;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
export { type BalanceRequestParams as B, ChainId$1 as C, type ExecuteOrderParams as E, OrderExecutionType as O, type PlaceOrderResult as P, type SwapSDKConfig as S, type TokenInfo as T, SwapSDK as a, type SwapQuoteParams as b, type SwapQuoteResponse as c, type Stage as d, type BalanceResponse as e, buildQuoteParams as f, SupportedChains as g, type TokenBalance as h, isEvmChain as i, type SupportedChain as j };
|
|
394
|
+
export { type BalanceRequestParams as B, ChainId as C, type ExecuteOrderParams as E, OrderExecutionType as O, type PlaceOrderResult as P, type SwapSDKConfig as S, type TokenInfo as T, SwapSDK as a, type SwapQuoteParams as b, type SwapQuoteResponse as c, type Stage as d, type BalanceResponse as e, buildQuoteParams as f, SupportedChains as g, type TokenBalance as h, isEvmChain as i, type SupportedChain as j };
|
package/dist/index.cjs
CHANGED
|
@@ -966,6 +966,294 @@ async function getOrders({
|
|
|
966
966
|
return orders;
|
|
967
967
|
}
|
|
968
968
|
|
|
969
|
+
// src/core/orders/cancelOrder.ts
|
|
970
|
+
var import_intents_sdk14 = require("@shogun-sdk/intents-sdk");
|
|
971
|
+
var import_web32 = require("@solana/web3.js");
|
|
972
|
+
var import_viem8 = require("viem");
|
|
973
|
+
async function cancelIntentsOrder({
|
|
974
|
+
order,
|
|
975
|
+
wallet,
|
|
976
|
+
sol_rpc
|
|
977
|
+
}) {
|
|
978
|
+
const isCrossChain = "srcChainId" in order && "destChainId" in order && order.srcChainId !== order.destChainId;
|
|
979
|
+
const srcChain = "srcChainId" in order ? order.srcChainId : order.chainId;
|
|
980
|
+
const isSolanaOrder = srcChain === import_intents_sdk14.ChainID.Solana;
|
|
981
|
+
if (isSolanaOrder) {
|
|
982
|
+
if (!isCrossChain) {
|
|
983
|
+
const { versionedMessageBytes: versionedMessageBytes2 } = await (0, import_intents_sdk14.cancelSingleChainOrderInstructionsAsBytes)(
|
|
984
|
+
order.orderId,
|
|
985
|
+
order.user,
|
|
986
|
+
{ rpcUrl: sol_rpc }
|
|
987
|
+
);
|
|
988
|
+
const message2 = import_web32.VersionedMessage.deserialize(
|
|
989
|
+
versionedMessageBytes2
|
|
990
|
+
);
|
|
991
|
+
const tx2 = new import_web32.VersionedTransaction(message2);
|
|
992
|
+
return await wallet.sendTransaction(tx2);
|
|
993
|
+
}
|
|
994
|
+
const { versionedMessageBytes } = await (0, import_intents_sdk14.cancelCrossChainOrderInstructionsAsBytes)(
|
|
995
|
+
order.orderId,
|
|
996
|
+
order.user,
|
|
997
|
+
{ rpcUrl: sol_rpc }
|
|
998
|
+
);
|
|
999
|
+
const message = import_web32.VersionedMessage.deserialize(
|
|
1000
|
+
versionedMessageBytes
|
|
1001
|
+
);
|
|
1002
|
+
const tx = new import_web32.VersionedTransaction(message);
|
|
1003
|
+
return await wallet.sendTransaction(tx);
|
|
1004
|
+
}
|
|
1005
|
+
const chainId = srcChain;
|
|
1006
|
+
const { readContract } = wallet;
|
|
1007
|
+
if (!readContract) {
|
|
1008
|
+
throw new Error("Wallet does not support readContract");
|
|
1009
|
+
}
|
|
1010
|
+
const nonce = BigInt(order.nonce ?? "0");
|
|
1011
|
+
const nonceWordPos = nonce >> 8n;
|
|
1012
|
+
const nonceBitPos = nonce - nonceWordPos * 256n;
|
|
1013
|
+
if (isCrossChain) {
|
|
1014
|
+
const [orderData = [false, false], currentNonceBitmap = 0n] = await Promise.all([
|
|
1015
|
+
readContract({
|
|
1016
|
+
address: import_intents_sdk14.CROSS_CHAIN_GUARD_ADDRESSES[chainId],
|
|
1017
|
+
abi: [
|
|
1018
|
+
{
|
|
1019
|
+
inputs: [{ name: "orderId", type: "bytes32" }],
|
|
1020
|
+
name: "orderData",
|
|
1021
|
+
outputs: [
|
|
1022
|
+
{ name: "initialized", type: "bool" },
|
|
1023
|
+
{ name: "deactivated", type: "bool" }
|
|
1024
|
+
],
|
|
1025
|
+
stateMutability: "view",
|
|
1026
|
+
type: "function"
|
|
1027
|
+
}
|
|
1028
|
+
],
|
|
1029
|
+
functionName: "orderData",
|
|
1030
|
+
args: [order.orderId]
|
|
1031
|
+
}),
|
|
1032
|
+
readContract({
|
|
1033
|
+
address: import_intents_sdk14.PERMIT2_ADDRESS[chainId],
|
|
1034
|
+
abi: [
|
|
1035
|
+
{
|
|
1036
|
+
inputs: [
|
|
1037
|
+
{ name: "owner", type: "address" },
|
|
1038
|
+
{ name: "wordPos", type: "uint256" }
|
|
1039
|
+
],
|
|
1040
|
+
name: "nonceBitmap",
|
|
1041
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1042
|
+
stateMutability: "view",
|
|
1043
|
+
type: "function"
|
|
1044
|
+
}
|
|
1045
|
+
],
|
|
1046
|
+
functionName: "nonceBitmap",
|
|
1047
|
+
args: [order.user, nonceWordPos]
|
|
1048
|
+
})
|
|
1049
|
+
]);
|
|
1050
|
+
const [initialized, deactivated] = orderData;
|
|
1051
|
+
if (initialized) {
|
|
1052
|
+
if (deactivated) {
|
|
1053
|
+
throw new Error("Order is already deactivated");
|
|
1054
|
+
}
|
|
1055
|
+
return await wallet.sendTransaction({
|
|
1056
|
+
to: import_intents_sdk14.CROSS_CHAIN_GUARD_ADDRESSES[order.srcChainId],
|
|
1057
|
+
data: (0, import_viem8.encodeFunctionData)({
|
|
1058
|
+
abi: [
|
|
1059
|
+
{
|
|
1060
|
+
inputs: [
|
|
1061
|
+
{
|
|
1062
|
+
components: [
|
|
1063
|
+
{ name: "user", type: "address" },
|
|
1064
|
+
{ name: "tokenIn", type: "address" },
|
|
1065
|
+
{ name: "srcChainId", type: "uint256" },
|
|
1066
|
+
{ name: "deadline", type: "uint256" },
|
|
1067
|
+
{ name: "amountIn", type: "uint256" },
|
|
1068
|
+
{ name: "minStablecoinsAmount", type: "uint256" },
|
|
1069
|
+
{ name: "executionDetailsHash", type: "bytes32" },
|
|
1070
|
+
{ name: "nonce", type: "uint256" }
|
|
1071
|
+
],
|
|
1072
|
+
name: "orderInfo",
|
|
1073
|
+
type: "tuple"
|
|
1074
|
+
}
|
|
1075
|
+
],
|
|
1076
|
+
name: "cancelOrder",
|
|
1077
|
+
outputs: [],
|
|
1078
|
+
stateMutability: "nonpayable",
|
|
1079
|
+
type: "function"
|
|
1080
|
+
}
|
|
1081
|
+
],
|
|
1082
|
+
functionName: "cancelOrder",
|
|
1083
|
+
args: [
|
|
1084
|
+
{
|
|
1085
|
+
user: order.user,
|
|
1086
|
+
tokenIn: order.tokenIn,
|
|
1087
|
+
srcChainId: BigInt(order.srcChainId),
|
|
1088
|
+
deadline: BigInt(order.deadline),
|
|
1089
|
+
amountIn: BigInt(order.amountIn),
|
|
1090
|
+
minStablecoinsAmount: BigInt(order.minStablecoinsAmount),
|
|
1091
|
+
executionDetailsHash: order.executionDetailsHash,
|
|
1092
|
+
nonce
|
|
1093
|
+
}
|
|
1094
|
+
]
|
|
1095
|
+
}),
|
|
1096
|
+
value: BigInt(0),
|
|
1097
|
+
from: order.user
|
|
1098
|
+
});
|
|
1099
|
+
} else {
|
|
1100
|
+
if ((currentNonceBitmap & 1n << nonceBitPos) !== 0n) {
|
|
1101
|
+
throw new Error("Nonce is already invalidated");
|
|
1102
|
+
}
|
|
1103
|
+
const mask2 = 1n << nonceBitPos;
|
|
1104
|
+
return await wallet.sendTransaction({
|
|
1105
|
+
to: import_intents_sdk14.PERMIT2_ADDRESS[order.srcChainId],
|
|
1106
|
+
data: (0, import_viem8.encodeFunctionData)({
|
|
1107
|
+
abi: [
|
|
1108
|
+
{
|
|
1109
|
+
inputs: [
|
|
1110
|
+
{ name: "wordPos", type: "uint256" },
|
|
1111
|
+
{ name: "mask", type: "uint256" }
|
|
1112
|
+
],
|
|
1113
|
+
name: "invalidateUnorderedNonces",
|
|
1114
|
+
outputs: [],
|
|
1115
|
+
stateMutability: "nonpayable",
|
|
1116
|
+
type: "function"
|
|
1117
|
+
}
|
|
1118
|
+
],
|
|
1119
|
+
functionName: "invalidateUnorderedNonces",
|
|
1120
|
+
args: [nonceWordPos, mask2]
|
|
1121
|
+
}),
|
|
1122
|
+
value: BigInt(0),
|
|
1123
|
+
from: order.user
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
const [wasManuallyInitialized, currentBitmap = 0n] = await Promise.all([
|
|
1128
|
+
readContract({
|
|
1129
|
+
address: import_intents_sdk14.SINGLE_CHAIN_GUARD_ADDRESSES[chainId],
|
|
1130
|
+
abi: [
|
|
1131
|
+
{
|
|
1132
|
+
inputs: [{ name: "orderHash", type: "bytes32" }],
|
|
1133
|
+
name: "orderManuallyInitialized",
|
|
1134
|
+
outputs: [{ name: "", type: "bool" }],
|
|
1135
|
+
stateMutability: "view",
|
|
1136
|
+
type: "function"
|
|
1137
|
+
}
|
|
1138
|
+
],
|
|
1139
|
+
functionName: "orderManuallyInitialized",
|
|
1140
|
+
args: [order.orderId]
|
|
1141
|
+
}),
|
|
1142
|
+
readContract({
|
|
1143
|
+
address: import_intents_sdk14.PERMIT2_ADDRESS[chainId],
|
|
1144
|
+
abi: [
|
|
1145
|
+
{
|
|
1146
|
+
inputs: [
|
|
1147
|
+
{ name: "owner", type: "address" },
|
|
1148
|
+
{ name: "wordPos", type: "uint256" }
|
|
1149
|
+
],
|
|
1150
|
+
name: "nonceBitmap",
|
|
1151
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
1152
|
+
stateMutability: "view",
|
|
1153
|
+
type: "function"
|
|
1154
|
+
}
|
|
1155
|
+
],
|
|
1156
|
+
functionName: "nonceBitmap",
|
|
1157
|
+
args: [order.user, nonceWordPos]
|
|
1158
|
+
})
|
|
1159
|
+
]);
|
|
1160
|
+
if (wasManuallyInitialized) {
|
|
1161
|
+
return await wallet.sendTransaction({
|
|
1162
|
+
to: import_intents_sdk14.SINGLE_CHAIN_GUARD_ADDRESSES[chainId],
|
|
1163
|
+
data: (0, import_viem8.encodeFunctionData)({
|
|
1164
|
+
abi: [
|
|
1165
|
+
{
|
|
1166
|
+
inputs: [
|
|
1167
|
+
{
|
|
1168
|
+
name: "order",
|
|
1169
|
+
type: "tuple",
|
|
1170
|
+
components: [
|
|
1171
|
+
{ name: "amountIn", type: "uint256" },
|
|
1172
|
+
{ name: "tokenIn", type: "address" },
|
|
1173
|
+
{ name: "deadline", type: "uint256" },
|
|
1174
|
+
{ name: "nonce", type: "uint256" },
|
|
1175
|
+
{ name: "encodedExternalCallData", type: "bytes" },
|
|
1176
|
+
{
|
|
1177
|
+
name: "extraTransfers",
|
|
1178
|
+
type: "tuple[]",
|
|
1179
|
+
components: [
|
|
1180
|
+
{ name: "amount", type: "uint256" },
|
|
1181
|
+
{ name: "receiver", type: "address" },
|
|
1182
|
+
{ name: "token", type: "address" }
|
|
1183
|
+
]
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
name: "requestedOutput",
|
|
1187
|
+
type: "tuple",
|
|
1188
|
+
components: [
|
|
1189
|
+
{ name: "amount", type: "uint256" },
|
|
1190
|
+
{ name: "receiver", type: "address" },
|
|
1191
|
+
{ name: "token", type: "address" }
|
|
1192
|
+
]
|
|
1193
|
+
},
|
|
1194
|
+
{ name: "user", type: "address" }
|
|
1195
|
+
]
|
|
1196
|
+
}
|
|
1197
|
+
],
|
|
1198
|
+
name: "cancelManuallyCreatedOrder",
|
|
1199
|
+
outputs: [],
|
|
1200
|
+
stateMutability: "nonpayable",
|
|
1201
|
+
type: "function"
|
|
1202
|
+
}
|
|
1203
|
+
],
|
|
1204
|
+
functionName: "cancelManuallyCreatedOrder",
|
|
1205
|
+
args: [
|
|
1206
|
+
{
|
|
1207
|
+
amountIn: BigInt(order.amountIn),
|
|
1208
|
+
tokenIn: order.tokenIn,
|
|
1209
|
+
deadline: BigInt(order.deadline),
|
|
1210
|
+
nonce,
|
|
1211
|
+
encodedExternalCallData: "0x",
|
|
1212
|
+
extraTransfers: (order.extraTransfers || []).map((t) => ({
|
|
1213
|
+
amount: BigInt(t.amount),
|
|
1214
|
+
receiver: t.receiver,
|
|
1215
|
+
token: t.token
|
|
1216
|
+
})),
|
|
1217
|
+
requestedOutput: {
|
|
1218
|
+
amount: BigInt(order.amountOutMin),
|
|
1219
|
+
receiver: order.destinationAddress,
|
|
1220
|
+
token: order.tokenOut
|
|
1221
|
+
},
|
|
1222
|
+
user: order.user
|
|
1223
|
+
}
|
|
1224
|
+
]
|
|
1225
|
+
}),
|
|
1226
|
+
value: 0n,
|
|
1227
|
+
from: order.user
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
const mask = 1n << nonceBitPos;
|
|
1231
|
+
if ((currentBitmap & mask) !== 0n) {
|
|
1232
|
+
throw new Error("Nonce is already invalidated");
|
|
1233
|
+
}
|
|
1234
|
+
return await wallet.sendTransaction({
|
|
1235
|
+
to: import_intents_sdk14.PERMIT2_ADDRESS[chainId],
|
|
1236
|
+
data: (0, import_viem8.encodeFunctionData)({
|
|
1237
|
+
abi: [
|
|
1238
|
+
{
|
|
1239
|
+
inputs: [
|
|
1240
|
+
{ name: "wordPos", type: "uint256" },
|
|
1241
|
+
{ name: "mask", type: "uint256" }
|
|
1242
|
+
],
|
|
1243
|
+
name: "invalidateUnorderedNonces",
|
|
1244
|
+
outputs: [],
|
|
1245
|
+
stateMutability: "nonpayable",
|
|
1246
|
+
type: "function"
|
|
1247
|
+
}
|
|
1248
|
+
],
|
|
1249
|
+
functionName: "invalidateUnorderedNonces",
|
|
1250
|
+
args: [nonceWordPos, mask]
|
|
1251
|
+
}),
|
|
1252
|
+
value: 0n,
|
|
1253
|
+
from: order.user
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
|
|
969
1257
|
// src/core/client.ts
|
|
970
1258
|
var SwapSDK = class {
|
|
971
1259
|
constructor(config) {
|
|
@@ -1126,4 +1414,23 @@ var SwapSDK = class {
|
|
|
1126
1414
|
async getOrders(params) {
|
|
1127
1415
|
return getOrders(params);
|
|
1128
1416
|
}
|
|
1417
|
+
/**
|
|
1418
|
+
* Cancels an order (single-chain or cross-chain) on EVM or Solana.
|
|
1419
|
+
*
|
|
1420
|
+
* Internally routes to the correct guard contract or Solana program to
|
|
1421
|
+
* deactivate the order or invalidate its nonce.
|
|
1422
|
+
*
|
|
1423
|
+
* @param params.order - Order payload returned from the Intents API.
|
|
1424
|
+
* @param params.wallet - Adapted wallet used to submit the cancellation transaction.
|
|
1425
|
+
* @param params.solRpc - Solana RPC URL used for SVM cancellations.
|
|
1426
|
+
*
|
|
1427
|
+
* @returns A transaction signature or hash from the underlying wallet.
|
|
1428
|
+
*/
|
|
1429
|
+
async cancelOrder(params) {
|
|
1430
|
+
return cancelIntentsOrder({
|
|
1431
|
+
order: params.order,
|
|
1432
|
+
wallet: params.wallet,
|
|
1433
|
+
sol_rpc: params.solRpc
|
|
1434
|
+
});
|
|
1435
|
+
}
|
|
1129
1436
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-6Wt_Nfub.cjs';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.cjs';
|
|
4
4
|
import '@solana/web3.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-
|
|
1
|
+
export { B as BalanceRequestParams, e as BalanceResponse, C as ChainId, O as OrderExecutionType, j as SupportedChain, g as SupportedChains, b as SwapQuoteParams, c as SwapQuoteResponse, a as SwapSDK, S as SwapSDKConfig, h as TokenBalance, f as buildQuoteParams, i as isEvmChain } from './index-DdO3mOAE.js';
|
|
2
2
|
import '@shogun-sdk/intents-sdk';
|
|
3
3
|
import './wallet-B9bKceyN.js';
|
|
4
4
|
import '@solana/web3.js';
|