0.0.17 • Published 5 months ago

navi-web-component v0.0.17

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Navi Web Component

Installation

npm i navi-web-component

Usage

import { SwapPanelClient } from 'navi-web-component'

const swapPanelClient = SwapPanelClient.getInstance()

// Developers need to register the onSignTransaction method for transaction signing
swapPanelClient.onSignTransaction = async (txb) => {
  // run sign transaction logic in your app
  // after signed, return the signature and bytes
  const resp = await signTransaction({
    transaction: txb,
  })
  return {
    signature: resp.signature,
    bytes: resp.bytes,
  }
}

// set user address
swapPanelClient.setUserAddress('0x1234567890123456789012345678901234567890')

// show swap panel
swapPanelClient.show()

// set token swap from
swapPanelClient.setTokenFrom(
'0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX')

// set token swap to
swapPanelClient.setTokenTo('0x02::sui::SUI')

// set token swap from amount
swapPanelClient.setTokenFromAmount('1000')

// listen ready event
// this event will be triggered when the swap panel is ready
swapPanelClient.events.on('ready', () => {
  console.log('ready')
})

// listen click connect event
// this event will be triggered when the connect button is clicked
swapPanelClient.events.on('clickConnect', () => {
  // run connect wallet logic in your app
  // after connected, set user address in swap panel
  swapPanelClient.setUserAddress('0x1234567890123456789012345678901234567890')
})

// listen swap success event
// this event will be triggered when the swap is successful
swapPanelClient.events.on('swapSuccess', (data) => {
  console.log(data)
})

// listen hide event
// this event will be triggered when the swap panel is hidden
swapPanelClient.events.on('hide', () => {
  console.log('hide')
})

// listen show event
// this event will be triggered when the swap panel is shown
swapPanelClient.events.on('show', () => {
  console.log('show')
})

// hide swap panel
swapPanelClient.hide()

// change theme
swapPanelClient.changeTheme('dark')
swapPanelClient.changeTheme('light')

// set service fee
// max fee is 0.01
swapPanelClient.setServiceFee({ fee: 0.01, receiverAddress: '0x1234567890123456789012345678901234567890' })
0.0.17

5 months ago

0.0.16

5 months ago

0.0.15

7 months ago

0.0.14

7 months ago

0.0.13

7 months ago

0.0.12

7 months ago

0.0.11

8 months ago

0.0.10

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago