Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update swapAndBridge function #116

Merged
merged 2 commits into from
Jun 17, 2024

Conversation

zemyblue
Copy link
Member

@zemyblue zemyblue commented Jun 14, 2024

Description

  • Modify to allow partial swap and bridging.
  • Add the function to broadcast the tx in Async mode in swapAndBridge function.

How to Use

export interface SwapAndBridgeOptions {
  readonly gas?: StdFee | number;
  readonly memo?: string;
  /** The balance to swap and bridge. */
  readonly amount?: string | number;
  /** Set broadcast mode. If true, BROADCAST_ASYNC_MODE, if false, BROADCAST_SYNC_MODE */
  readonly asyncBroadcast?: boolean;
}

// swapAndBridge define
public async swapAndBridge(
    senderAddress: string,
    toAddress: string,
    { gas = 150_000, memo = "", amount = undefined, asyncBroadcast = false }: SwapAndBridgeOptions = {},
  ): Promise<Uint8Array | DeliverTxResponse>

// Usage
const fromAddr = "link146asaycmtydq45kxc8evntqfgepagygelel00h";
const toAddr = "0xf7bAc63fc7CEaCf0589F25454Ecf5C2ce904997c";
// If you swap and bridge all balance. 
const result = await client.swapAndBridge(fromAddr, toAddr);

// if you swap and bridge part of the balance.
const result2 = await client.swapAndBridge(fromAddr, toAddr, { amount: 500_000 });

// if you want to broadcast tx in async mode
const result3 = await client.swapAndBridge(from, toAddr, { asyncBroadcast: true });

Motivation and context

How has this been tested?

Screenshots (if appropriate):

Checklist:

  • I have added a relevant changelog to CHANGELOG.md.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.

Signed-off-by: zemyblue <zemyblue@gmail.com>
Signed-off-by: zemyblue <zemyblue@gmail.com>
@zemyblue zemyblue self-assigned this Jun 14, 2024
@zemyblue zemyblue merged commit ca0afa3 into Finschia:main Jun 17, 2024
2 checks passed
@zemyblue zemyblue deleted the feat/upgrade_swap_bridge branch June 17, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants