@anywalletkit/protocol-swap2-omniston 0.3.0 → 0.3.1

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/provider.cjs CHANGED
@@ -1229,7 +1229,27 @@ function omnistonVerifyBuild(hooks) {
1229
1229
  return async (quote, tx, params) => {
1230
1230
  if (tx.bodyBoc === void 0) return null;
1231
1231
  if (!params) return "the request this quote answered is unknown";
1232
- if (quote.providerData?.settlement !== "swap") return "only TON swap bodies can be checked on the client";
1232
+ if (quote.providerData?.settlement !== "swap") {
1233
+ if (params.sourceChain.startsWith("ton:") && params.destChain.startsWith("eip155:")) {
1234
+ if (!hooks.verifyTonEscrowBuild) return "a TON \u2192 EVM escrow body needs verifyTonEscrowBuild (createOmnistonTonValidators)";
1235
+ if (!params.refundAddress) return "the trader's TON address (refundAddress) is unknown";
1236
+ const floor = [quote.minDestAmount, params.minAmountOut ?? "0"].filter((v) => /^\d{1,80}$/.test(v)).map((v) => BigInt(v)).reduce((a, b) => a > b ? a : b, 0n);
1237
+ try {
1238
+ return await hooks.verifyTonEscrowBuild({
1239
+ payloadBocHex: import_buffer2.Buffer.from(tx.bodyBoc, "base64").toString("hex"),
1240
+ ownerAddress: params.refundAddress,
1241
+ inputUnits: quote.sourceAmount,
1242
+ destinationChain: params.destChain,
1243
+ destinationAddress: params.destAddress,
1244
+ outputTokenAddress: params.destToken,
1245
+ minResolverSendsUnits: floor.toString()
1246
+ });
1247
+ } catch {
1248
+ return "the escrow body could not be checked";
1249
+ }
1250
+ }
1251
+ return "only TON swap and TON \u2192 EVM escrow bodies can be checked on the client";
1252
+ }
1233
1253
  let steps;
1234
1254
  try {
1235
1255
  steps = JSON.parse(quote.providerData.routeSteps ?? "");