Adding custom messages before or after route execution

The executeRoute method now accepts beforeMsg and afterMsg parameter to allow for the execution of custom Cosmos messages before and/or after the route is executed. This is useful for executing custom messages that are not part of the route definition.

const msg = JSON.stringify({
  fromAddress: 'cosmos1...',  // Replace with sender address
  toAddress: 'cosmos1...',    // Replace with recipient address
  amount: [{
    denom: 'uatom',           // Replace with the actual denom, e.g., 'uatom' for ATOM
    amount: '1000000'         // Replace with the actual amount (in smallest unit, e.g., micro-ATOM)
  }]
});

await executeRoute({
  route,
  userAddresses,
  beforeMsg: { msg, msgTypeUrl: '/cosmos.bank.v1beta1.MsgSend' }
});

Use the Go Fast Transfer system

The route function accepts a goFast parameter to enable the Go Fast Transfers. Then pass this route to the executeRoute method to execute.

import { executeRoute, route } from '@skip-go/client';

const route = await route({
  goFast: true
  ...otherParams,
});

await executeRoute({
  route,
  ...otherParams,
});

Add a fee payer in solana transaction

The executeRoute method accepts a svmFeePayer parameter to specify a fee payer for Solana transactions. This is useful when you want to have a different account pay the transaction fees.

import { Keypair } from "@solana/web3.js";
import nacl from "tweetnacl";
import bs58 from "bs58";
import { executeRoute, route } from '@skip-go/client';


const route = await route({
  // ... other parameters
});

await executeRoute({
  route,
  userAddresses,
  svmFeePayer: {
    address: 'FEE_PAYER_ADDRESS.', // Replace with the fee payer's Solana address
    signTransaction: async (dataToSign: Buffer) => {
      // this is an example the fee payer signer is using a private key
      const privateKey = "FEE_PAYER_PRIVATE_KEY";
      const keypairBytes = bs58.decode(privateKey);
      const keypair = Keypair.fromSecretKey(keypairBytes);
      return nacl.sign.detached(dataToSign, keypair.secretKey);
    },
  }
  ...otherParams,
})