@interest-protocol/xswap-sdk 1.0.5 → 1.0.6

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/index.js CHANGED
@@ -6231,6 +6231,14 @@ const extractSecp256k1PublicKey = (publicOutput) => {
6231
6231
  invariant(keyLength === SECP256K1_COMPRESSED_PUBKEY_LENGTH, `Expected secp256k1 compressed key length ${SECP256K1_COMPRESSED_PUBKEY_LENGTH}, got ${keyLength}`);
6232
6232
  return publicOutput.slice(2, 2 + SECP256K1_COMPRESSED_PUBKEY_LENGTH);
6233
6233
  };
6234
+ const textEncoder = new TextEncoder();
6235
+ const textDecoder = new TextDecoder();
6236
+ const normalizeSuiTokenBytes = (tokenBytes, chainId) => {
6237
+ if (chainId !== ChainId.Sui)
6238
+ return tokenBytes;
6239
+ const tag = textDecoder.decode(tokenBytes);
6240
+ return textEncoder.encode(normalizeStructTag(tag));
6241
+ };
6234
6242
  const serializeSuiSecp256k1Signature = (signature, publicKey) => {
6235
6243
  invariant(signature.length === SECP256K1_SIGNATURE_LENGTH, `Expected signature length ${SECP256K1_SIGNATURE_LENGTH}, got ${signature.length}`);
6236
6244
  invariant(publicKey.length === SECP256K1_COMPRESSED_PUBKEY_LENGTH, `Expected public key length ${SECP256K1_COMPRESSED_PUBKEY_LENGTH}, got ${publicKey.length}`);
@@ -6326,6 +6334,8 @@ class XSwap {
6326
6334
  __classPrivateFieldSet(this, _XSwap_enclaveSharedObjectData, enclaveSharedObjectData, "f");
6327
6335
  }
6328
6336
  newRequestParams(tx, params) {
6337
+ const sourceToken = normalizeSuiTokenBytes(params.sourceToken, params.sourceChain);
6338
+ const destinationToken = normalizeSuiTokenBytes(params.destinationToken, params.destinationChain);
6329
6339
  return tx.moveCall({
6330
6340
  target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.Structs}::${Functions.NewRequestParams}`,
6331
6341
  arguments: [
@@ -6336,10 +6346,10 @@ class XSwap {
6336
6346
  tx.pure(bcsBytes.serialize(params.dwalletAddress)),
6337
6347
  tx.pure(bcsBytes.serialize(params.sourceAddress)),
6338
6348
  tx.pure.u64(params.sourceChain),
6339
- tx.pure(bcsBytes.serialize(params.sourceToken)),
6349
+ tx.pure(bcsBytes.serialize(sourceToken)),
6340
6350
  tx.pure.u256(params.sourceAmount),
6341
6351
  tx.pure.u64(params.destinationChain),
6342
- tx.pure(bcsBytes.serialize(params.destinationToken)),
6352
+ tx.pure(bcsBytes.serialize(destinationToken)),
6343
6353
  tx.pure(bcsBytes.serialize(params.destinationAddress)),
6344
6354
  tx.pure.u256(params.minDestinationAmount),
6345
6355
  tx.pure.u64(params.minConfirmations),
@@ -6970,6 +6980,7 @@ exports.XSWAP_TYPE = XSWAP_TYPE;
6970
6980
  exports.XSwap = XSwap;
6971
6981
  exports.extractEd25519PublicKey = extractEd25519PublicKey;
6972
6982
  exports.extractSecp256k1PublicKey = extractSecp256k1PublicKey;
6983
+ exports.normalizeSuiTokenBytes = normalizeSuiTokenBytes;
6973
6984
  exports.parseU256LittleEndian = parseU256LittleEndian;
6974
6985
  exports.serializeSuiSecp256k1Signature = serializeSuiSecp256k1Signature;
6975
6986
  //# sourceMappingURL=index.js.map