0.0.12-11 • Published 8 months ago

super-bridge-sdk v0.0.12-11

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

bridge-sdk

Bridge-sdk Any-to-Any Cross-Chain-Swap SDK

Installation

coming soon

Supporting bridge

  • axelar
  • lifi
  • meson
  • miniBridge
  • orbiter
  • owlto
  • rubic

demo

import { excute, getQuote, init } from './lib/index'

async function runDemo() {
  const provider: ethers.providers.Web3Provider = new ethers.providers.Web3Provider(window.ethereum);
  
  const accounts = await provider.send("eth_requestAccounts", [])
  const account = accounts[0]
  
  const signer = provider.getSigner()

  await init()

  const quotes = await getQuote({
    fromChainId: '1',
    toChainId: '10',
    fromToken: {
      symbol: 'ETH',
      address: '0x0000000000000000000000000000000000000000',
      decimals: 18
    },
    toToken: {
      symbol: 'ETH',
      address: '0x0000000000000000000000000000000000000000',
      decimals: 18,
    },
    fromAddress: '0xC25d79fc4970479B88068Ce8891eD9bE5799210D',
    destAddress: '0xC25d79fc4970479B88068Ce8891eD9bE5799210D',
    // amount: new Big('0.05').mul(10 ** 18)
    amount: new Big('0.01').mul(10 ** 18)
  }, signer)

  if (quotes && quotes.length) {
    const list = quotes.map((item: any) => {
      return `<div class="bridge" style="cursor: pointer; border: 1px solid #ddd; margin-bottom: 10px" data-uuid="${item.uuid}">
      <img style="width: 20px; margin-right: 10px" src="${item.icon}"/>
      <span>${item.bridgeName}</span>
      </div>`
    })

    $app!.innerHTML = list.join('')

    const bridgeList = $app!.querySelectorAll('.bridge')
    bridgeList.forEach((item: any) => {
      item.addEventListener('click', async () => {
        document.querySelector<HTMLDivElement>('#layer')!.style.display = 'block'
        await excute({
          uuid: item.getAttribute('data-uuid')
        }, signer)

        document.querySelector<HTMLDivElement>('#layer')!.style.display = 'none'
      }, false)
    })
  }
}

SDK API

init

Initialize sdk

init()

getQuote

export interface QuoteRequest {
    fromChainId: string;
    toChainId: string;
    fromToken: {
        address: string;
        symbol: string;
        decimals: number;
    };
    toToken: {
        address: string;
        symbol: string;
        decimals: number;
    };
    fromAddress: string;
    destAddress: string;
    amount: Big;
}


interface QuoteResponse {
    uuid: string;
    icon: string;
    bridgeName: string;
    bridgeType: string;
    receiveAmount: string;
    gas?: string;
    fee?: string;
}



getQuote(quoteRequest: QuoteRequest) : Promise<QuoteResponse>

Gets routes for all Bridges

excute

Select a route to execute

interface ExcuteRequest {
    uuid: string;
}

excute(excuteRequest: ExcuteRequest): txHash

getStatus

getStatus(): boolean

Get transaction status

0.0.12-10

8 months ago

0.0.12-11

8 months ago

0.0.12-9

8 months ago

0.0.12-8

8 months ago

0.0.12-1

8 months ago

0.0.12-3

8 months ago

0.0.12-2

8 months ago

0.0.12-5

8 months ago

0.0.12-4

8 months ago

0.0.12-7

8 months ago

0.0.12-6

8 months ago

0.0.11-40

8 months ago

0.0.11-42

8 months ago

0.0.11-41

8 months ago

0.0.11-44

8 months ago

0.0.11-43

8 months ago

0.0.11-46

8 months ago

0.0.11-45

8 months ago

0.0.11-48

8 months ago

0.0.11-47

8 months ago

0.0.11-49

8 months ago

0.0.11-51

8 months ago

0.0.11-50

8 months ago

0.0.11-53

8 months ago

0.0.11-52

8 months ago

0.0.11-55

8 months ago

0.0.11-54

8 months ago

0.0.11-57

8 months ago

0.0.11-56

8 months ago

0.0.11-59

8 months ago

0.0.11-58

8 months ago

0.0.11-20

9 months ago

0.0.11-22

9 months ago

0.0.11-21

9 months ago

0.0.11-24

9 months ago

0.0.11-23

9 months ago

0.0.11-26

9 months ago

0.0.11-25

9 months ago

0.0.11-28

9 months ago

0.0.11-27

9 months ago

0.0.11-29

9 months ago

0.0.11-31

9 months ago

0.0.11-30

9 months ago

0.0.11-33

9 months ago

0.0.11-32

9 months ago

0.0.11-35

9 months ago

0.0.11-34

9 months ago

0.0.11-37

9 months ago

0.0.11-36

9 months ago

0.0.11-39

9 months ago

0.0.11-38

9 months ago

0.0.11-19

9 months ago

0.0.11-18

9 months ago

0.0.12

8 months ago

0.0.9-23

1 year ago

0.0.9-22

1 year ago

0.0.9-25

1 year ago

0.0.9-24

1 year ago

0.0.9-21

1 year ago

0.0.9-20

1 year ago

0.0.10-1

1 year ago

0.0.11-2

12 months ago

0.0.11-1

12 months ago

0.0.11-4

12 months ago

0.0.11-6

12 months ago

0.0.11-5

12 months ago

0.0.11-8

11 months ago

0.0.11-7

11 months ago

0.0.11-9

11 months ago

0.0.11-11

11 months ago

0.0.11-10

11 months ago

0.0.11-13

11 months ago

0.0.11-12

11 months ago

0.0.11-15

11 months ago

0.0.11-14

11 months ago

0.0.11-17

11 months ago

0.0.11-16

11 months ago

0.0.11-0

12 months ago

0.0.10-3

1 year ago

0.0.10-2

1 year ago

0.0.10-5

1 year ago

0.0.10-4

1 year ago

0.0.10

1 year ago

0.0.10-7

12 months ago

0.0.10-6

12 months ago

0.0.9-19

1 year ago

0.0.10-9

12 months ago

0.0.10-8

12 months ago

0.0.9-18

1 year ago

0.0.9-16

1 year ago

0.0.9-17

1 year ago

0.0.9-15

1 year ago

0.0.9-14

1 year ago

0.0.9-13

1 year ago

0.0.9-12

1 year ago

0.0.9-11

1 year ago

0.0.9-10

1 year ago

0.0.9-9

1 year ago

0.0.9-8

1 year ago

0.0.9-7

1 year ago

0.0.9-6

1 year ago

0.0.9-3

1 year ago

0.0.9-5

1 year ago

0.0.9-4

1 year ago

0.0.9-2

1 year ago

0.0.9-1

1 year ago

0.0.9-0

1 year ago

0.0.1

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.0

1 year ago