bcnmy / hyphen-sdk

Repository containing Hyphen SDK code that helps you integrate Hyphen cross-chain asset transfer protocol in your Dapp. Hyphen SDK provides you simple to use methods that connects directly with Hyphen liquidity pools on supported chains and hyphen nodes to fetch information related to cross chain transfer transactions.
MIT License
5 stars 2 forks source link

BSDK-153: Cross Chain Message Passing #35

Closed ankurdubey521 closed 1 year ago

ankurdubey521 commented 1 year ago

Description

Type of change

How Has This Been Tested?

Test Configuration:

Steps to reproduce

(async () => {
  const depositManager = hyphen[sourceChain].depositAndCallManager;

  // Perform Pre Deposit Check
  const status = await depositManager.preDepositStatus({
    tokenAddress: tokenAddress[sourceChain],
    amount,
    fromChainId: sourceChain,
    toChainId: destinationChain,
    userAddress: wallet[sourceChain].address,
  });
  console.log(`preDepositStatus: ${JSON.stringify(status)}`);

  // Get Fee Estimate
  const feeEstimate = await depositManager.getTransferFee({
    fromChainId: sourceChain,
    toChainId: destinationChain,
    tokenAddress: tokenAddress[sourceChain],
    receiver: batchHelper[destinationChain],
    amount,
    payloads: [
      {
        to: batchHelper[destinationChain],
        _calldata: batchHelperCalldata,
      },
    ],
    adaptorName: CCMPAdaptor.WORMHOLE,
    routerArgs: {
      consistencyLevel: 1,
    },
  });
  console.log(`feeEstimate: ${JSON.stringify(feeEstimate)}`);

  //   Perform Deposit
  const response = await depositManager.depositAndCall(
    {
      sender: wallet[sourceChain].address,
      depositContractAddress: liquidityPool[sourceChain],
      fromChainId: sourceChain.toString(),
      toChainId: destinationChain.toString(),
      tokenAddress: tokenAddress[sourceChain],
      receiver: batchHelper[destinationChain],
      amount: amount.toString(),
      payloads: [
        {
          to: batchHelper[destinationChain],
          _calldata: batchHelperCalldata,
        },
      ],
      dAppName: 'Hyphen SDK Deposit and Call Test',
      useBiconomy: false,
      adaptorName: CCMPAdaptor.WORMHOLE,
      routerArgs: {
        consistencyLevel: 1,
      },
    },
    wallet[sourceChain]
  );
  console.log(`Source txHash: ${response.hash}`);
  await response.wait();
})();

Automated Tests Added/Updated

Coverage

Checklist: