@shogun-sdk/swap 0.0.2-test.28 → 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 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/core.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-CapCmdE-.cjs';
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/core.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-BYkOqhW8.js';
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';
package/dist/core.js CHANGED
@@ -946,6 +946,304 @@ async function getOrders({
946
946
  return orders;
947
947
  }
948
948
 
949
+ // src/core/orders/cancelOrder.ts
950
+ import {
951
+ cancelCrossChainOrderInstructionsAsBytes,
952
+ cancelSingleChainOrderInstructionsAsBytes,
953
+ ChainID as ChainID3,
954
+ CROSS_CHAIN_GUARD_ADDRESSES,
955
+ PERMIT2_ADDRESS as PERMIT2_ADDRESS2,
956
+ SINGLE_CHAIN_GUARD_ADDRESSES
957
+ } from "@shogun-sdk/intents-sdk";
958
+ import {
959
+ VersionedMessage,
960
+ VersionedTransaction as VersionedTransaction2
961
+ } from "@solana/web3.js";
962
+ import { encodeFunctionData as encodeFunctionData3 } from "viem";
963
+ async function cancelIntentsOrder({
964
+ order,
965
+ wallet,
966
+ sol_rpc
967
+ }) {
968
+ const isCrossChain = "srcChainId" in order && "destChainId" in order && order.srcChainId !== order.destChainId;
969
+ const srcChain = "srcChainId" in order ? order.srcChainId : order.chainId;
970
+ const isSolanaOrder = srcChain === ChainID3.Solana;
971
+ if (isSolanaOrder) {
972
+ if (!isCrossChain) {
973
+ const { versionedMessageBytes: versionedMessageBytes2 } = await cancelSingleChainOrderInstructionsAsBytes(
974
+ order.orderId,
975
+ order.user,
976
+ { rpcUrl: sol_rpc }
977
+ );
978
+ const message2 = VersionedMessage.deserialize(
979
+ versionedMessageBytes2
980
+ );
981
+ const tx2 = new VersionedTransaction2(message2);
982
+ return await wallet.sendTransaction(tx2);
983
+ }
984
+ const { versionedMessageBytes } = await cancelCrossChainOrderInstructionsAsBytes(
985
+ order.orderId,
986
+ order.user,
987
+ { rpcUrl: sol_rpc }
988
+ );
989
+ const message = VersionedMessage.deserialize(
990
+ versionedMessageBytes
991
+ );
992
+ const tx = new VersionedTransaction2(message);
993
+ return await wallet.sendTransaction(tx);
994
+ }
995
+ const chainId = srcChain;
996
+ const { readContract } = wallet;
997
+ if (!readContract) {
998
+ throw new Error("Wallet does not support readContract");
999
+ }
1000
+ const nonce = BigInt(order.nonce ?? "0");
1001
+ const nonceWordPos = nonce >> 8n;
1002
+ const nonceBitPos = nonce - nonceWordPos * 256n;
1003
+ if (isCrossChain) {
1004
+ const [orderData = [false, false], currentNonceBitmap = 0n] = await Promise.all([
1005
+ readContract({
1006
+ address: CROSS_CHAIN_GUARD_ADDRESSES[chainId],
1007
+ abi: [
1008
+ {
1009
+ inputs: [{ name: "orderId", type: "bytes32" }],
1010
+ name: "orderData",
1011
+ outputs: [
1012
+ { name: "initialized", type: "bool" },
1013
+ { name: "deactivated", type: "bool" }
1014
+ ],
1015
+ stateMutability: "view",
1016
+ type: "function"
1017
+ }
1018
+ ],
1019
+ functionName: "orderData",
1020
+ args: [order.orderId]
1021
+ }),
1022
+ readContract({
1023
+ address: PERMIT2_ADDRESS2[chainId],
1024
+ abi: [
1025
+ {
1026
+ inputs: [
1027
+ { name: "owner", type: "address" },
1028
+ { name: "wordPos", type: "uint256" }
1029
+ ],
1030
+ name: "nonceBitmap",
1031
+ outputs: [{ name: "", type: "uint256" }],
1032
+ stateMutability: "view",
1033
+ type: "function"
1034
+ }
1035
+ ],
1036
+ functionName: "nonceBitmap",
1037
+ args: [order.user, nonceWordPos]
1038
+ })
1039
+ ]);
1040
+ const [initialized, deactivated] = orderData;
1041
+ if (initialized) {
1042
+ if (deactivated) {
1043
+ throw new Error("Order is already deactivated");
1044
+ }
1045
+ return await wallet.sendTransaction({
1046
+ to: CROSS_CHAIN_GUARD_ADDRESSES[order.srcChainId],
1047
+ data: encodeFunctionData3({
1048
+ abi: [
1049
+ {
1050
+ inputs: [
1051
+ {
1052
+ components: [
1053
+ { name: "user", type: "address" },
1054
+ { name: "tokenIn", type: "address" },
1055
+ { name: "srcChainId", type: "uint256" },
1056
+ { name: "deadline", type: "uint256" },
1057
+ { name: "amountIn", type: "uint256" },
1058
+ { name: "minStablecoinsAmount", type: "uint256" },
1059
+ { name: "executionDetailsHash", type: "bytes32" },
1060
+ { name: "nonce", type: "uint256" }
1061
+ ],
1062
+ name: "orderInfo",
1063
+ type: "tuple"
1064
+ }
1065
+ ],
1066
+ name: "cancelOrder",
1067
+ outputs: [],
1068
+ stateMutability: "nonpayable",
1069
+ type: "function"
1070
+ }
1071
+ ],
1072
+ functionName: "cancelOrder",
1073
+ args: [
1074
+ {
1075
+ user: order.user,
1076
+ tokenIn: order.tokenIn,
1077
+ srcChainId: BigInt(order.srcChainId),
1078
+ deadline: BigInt(order.deadline),
1079
+ amountIn: BigInt(order.amountIn),
1080
+ minStablecoinsAmount: BigInt(order.minStablecoinsAmount),
1081
+ executionDetailsHash: order.executionDetailsHash,
1082
+ nonce
1083
+ }
1084
+ ]
1085
+ }),
1086
+ value: BigInt(0),
1087
+ from: order.user
1088
+ });
1089
+ } else {
1090
+ if ((currentNonceBitmap & 1n << nonceBitPos) !== 0n) {
1091
+ throw new Error("Nonce is already invalidated");
1092
+ }
1093
+ const mask2 = 1n << nonceBitPos;
1094
+ return await wallet.sendTransaction({
1095
+ to: PERMIT2_ADDRESS2[order.srcChainId],
1096
+ data: encodeFunctionData3({
1097
+ abi: [
1098
+ {
1099
+ inputs: [
1100
+ { name: "wordPos", type: "uint256" },
1101
+ { name: "mask", type: "uint256" }
1102
+ ],
1103
+ name: "invalidateUnorderedNonces",
1104
+ outputs: [],
1105
+ stateMutability: "nonpayable",
1106
+ type: "function"
1107
+ }
1108
+ ],
1109
+ functionName: "invalidateUnorderedNonces",
1110
+ args: [nonceWordPos, mask2]
1111
+ }),
1112
+ value: BigInt(0),
1113
+ from: order.user
1114
+ });
1115
+ }
1116
+ }
1117
+ const [wasManuallyInitialized, currentBitmap = 0n] = await Promise.all([
1118
+ readContract({
1119
+ address: SINGLE_CHAIN_GUARD_ADDRESSES[chainId],
1120
+ abi: [
1121
+ {
1122
+ inputs: [{ name: "orderHash", type: "bytes32" }],
1123
+ name: "orderManuallyInitialized",
1124
+ outputs: [{ name: "", type: "bool" }],
1125
+ stateMutability: "view",
1126
+ type: "function"
1127
+ }
1128
+ ],
1129
+ functionName: "orderManuallyInitialized",
1130
+ args: [order.orderId]
1131
+ }),
1132
+ readContract({
1133
+ address: PERMIT2_ADDRESS2[chainId],
1134
+ abi: [
1135
+ {
1136
+ inputs: [
1137
+ { name: "owner", type: "address" },
1138
+ { name: "wordPos", type: "uint256" }
1139
+ ],
1140
+ name: "nonceBitmap",
1141
+ outputs: [{ name: "", type: "uint256" }],
1142
+ stateMutability: "view",
1143
+ type: "function"
1144
+ }
1145
+ ],
1146
+ functionName: "nonceBitmap",
1147
+ args: [order.user, nonceWordPos]
1148
+ })
1149
+ ]);
1150
+ if (wasManuallyInitialized) {
1151
+ return await wallet.sendTransaction({
1152
+ to: SINGLE_CHAIN_GUARD_ADDRESSES[chainId],
1153
+ data: encodeFunctionData3({
1154
+ abi: [
1155
+ {
1156
+ inputs: [
1157
+ {
1158
+ name: "order",
1159
+ type: "tuple",
1160
+ components: [
1161
+ { name: "amountIn", type: "uint256" },
1162
+ { name: "tokenIn", type: "address" },
1163
+ { name: "deadline", type: "uint256" },
1164
+ { name: "nonce", type: "uint256" },
1165
+ { name: "encodedExternalCallData", type: "bytes" },
1166
+ {
1167
+ name: "extraTransfers",
1168
+ type: "tuple[]",
1169
+ components: [
1170
+ { name: "amount", type: "uint256" },
1171
+ { name: "receiver", type: "address" },
1172
+ { name: "token", type: "address" }
1173
+ ]
1174
+ },
1175
+ {
1176
+ name: "requestedOutput",
1177
+ type: "tuple",
1178
+ components: [
1179
+ { name: "amount", type: "uint256" },
1180
+ { name: "receiver", type: "address" },
1181
+ { name: "token", type: "address" }
1182
+ ]
1183
+ },
1184
+ { name: "user", type: "address" }
1185
+ ]
1186
+ }
1187
+ ],
1188
+ name: "cancelManuallyCreatedOrder",
1189
+ outputs: [],
1190
+ stateMutability: "nonpayable",
1191
+ type: "function"
1192
+ }
1193
+ ],
1194
+ functionName: "cancelManuallyCreatedOrder",
1195
+ args: [
1196
+ {
1197
+ amountIn: BigInt(order.amountIn),
1198
+ tokenIn: order.tokenIn,
1199
+ deadline: BigInt(order.deadline),
1200
+ nonce,
1201
+ encodedExternalCallData: "0x",
1202
+ extraTransfers: (order.extraTransfers || []).map((t) => ({
1203
+ amount: BigInt(t.amount),
1204
+ receiver: t.receiver,
1205
+ token: t.token
1206
+ })),
1207
+ requestedOutput: {
1208
+ amount: BigInt(order.amountOutMin),
1209
+ receiver: order.destinationAddress,
1210
+ token: order.tokenOut
1211
+ },
1212
+ user: order.user
1213
+ }
1214
+ ]
1215
+ }),
1216
+ value: 0n,
1217
+ from: order.user
1218
+ });
1219
+ }
1220
+ const mask = 1n << nonceBitPos;
1221
+ if ((currentBitmap & mask) !== 0n) {
1222
+ throw new Error("Nonce is already invalidated");
1223
+ }
1224
+ return await wallet.sendTransaction({
1225
+ to: PERMIT2_ADDRESS2[chainId],
1226
+ data: encodeFunctionData3({
1227
+ abi: [
1228
+ {
1229
+ inputs: [
1230
+ { name: "wordPos", type: "uint256" },
1231
+ { name: "mask", type: "uint256" }
1232
+ ],
1233
+ name: "invalidateUnorderedNonces",
1234
+ outputs: [],
1235
+ stateMutability: "nonpayable",
1236
+ type: "function"
1237
+ }
1238
+ ],
1239
+ functionName: "invalidateUnorderedNonces",
1240
+ args: [nonceWordPos, mask]
1241
+ }),
1242
+ value: 0n,
1243
+ from: order.user
1244
+ });
1245
+ }
1246
+
949
1247
  // src/core/client.ts
950
1248
  var SwapSDK = class {
951
1249
  constructor(config) {
@@ -1106,6 +1404,25 @@ var SwapSDK = class {
1106
1404
  async getOrders(params) {
1107
1405
  return getOrders(params);
1108
1406
  }
1407
+ /**
1408
+ * Cancels an order (single-chain or cross-chain) on EVM or Solana.
1409
+ *
1410
+ * Internally routes to the correct guard contract or Solana program to
1411
+ * deactivate the order or invalidate its nonce.
1412
+ *
1413
+ * @param params.order - Order payload returned from the Intents API.
1414
+ * @param params.wallet - Adapted wallet used to submit the cancellation transaction.
1415
+ * @param params.solRpc - Solana RPC URL used for SVM cancellations.
1416
+ *
1417
+ * @returns A transaction signature or hash from the underlying wallet.
1418
+ */
1419
+ async cancelOrder(params) {
1420
+ return cancelIntentsOrder({
1421
+ order: params.order,
1422
+ wallet: params.wallet,
1423
+ sol_rpc: params.solRpc
1424
+ });
1425
+ }
1109
1426
  };
1110
1427
  export {
1111
1428
  ChainId,
@@ -1,4 +1,4 @@
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
 
@@ -325,6 +325,23 @@ declare class SwapSDK {
325
325
  evmAddress?: string | null;
326
326
  solAddress?: string | null;
327
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>;
328
345
  }
329
346
 
330
347
  /**