1.4.5 • Published 5 months ago

@kimafinance/kima-transaction-widget v1.4.5

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

kima-transaction-widget

Build & Deploy npm version Download NPM

Install

npm install --save @kimafinance/kima-transaction-widget
yarn add @kimafinance/kima-transaction-widget

Usage

Payment Scenario

import React from 'react'

import {
  KimaTransactionWidget,
  KimaProvider,
  FontSizeOptions,
  ModeOptions,
  SupportNetworks,
  ColorModeOptions
} from 'kima-transaction-widget'

const App = () => {
  return (
    <KimaProvider
      kimaBackendUrl='http://localhost:3001' // or your deployed backend instance
      walletConnectProjectId='e579511a495b5c312b572b036e60555a'
      externalProvider={} // in case you want to provide an already connected wallet
    >
      <KimaTransactionWidget
        theme={{
          colorMode: ColorModeOptions.light
        }}
        mode={ModeOptions.payment}
        titleOption={{
          initialTitle: 'New Purchase'
        }}
        paymentTitleOption={{
          title:
            'You can now purchase our NFT on Polygon, using funds from other chains.'
        }}
        compliantOption={false}
        transactionOption={{
          targetChain: SupportNetworks.AVALANCHE,
          targetAddress: '0x67cc400c434F691Ed45e452dC8F2Baf0101a9B63',
          amount: 5,
          currency: 'USDK'
        }}
      />
    </KimaProvider>
  )
}

export default App

Bridge Scenario

import React from 'react'

import {
  KimaTransactionWidget,
  KimaProvider,
  FontSizeOptions,
  ModeOptions,
  ColorModeOptions
} from 'kima-transaction-widget'

const App = () => {
  return (
    <KimaProvider
      kimaBackendUrl='http://localhost:3001' // or your deployed backend instance
      walletConnectProjectId='e579511a495b5c312b572b036e60555a'
      externalProvider={} // in case you want to provide an already connected wallet
    >
      <KimaTransactionWidget
        theme={{
          colorMode: ColorModeOptions.light,
          fontSize: FontSizeOptions.medium
        }}
        mode={ModeOptions.bridge}
        compliantOption={false}
        errorHandler={(e: any) => {
          console.log('error:', e)
        }}
        successHandler={() => {
          console.log('success')
        }}
        closeHandler={() => {
          console.log('closed')
        }}
      />
    </KimaProvider>
  )
}

export default App

Status Scenario

import React from 'react'

import {
  KimaTransactionWidget,
  KimaProvider,
  FontSizeOptions,
  ModeOptions,
  ColorModeOptions
} from 'kima-transaction-widget'

const App = () => {
  return (
    <KimaProvider
      kimaBackendUrl='http://localhost:3001' // or your deployed backend instance
      walletConnectProjectId='e579511a495b5c312b572b036e60555a'
    >
      <KimaTransactionWidget
        theme={{
          colorMode: ColorModeOptions.light,
          fontSize: FontSizeOptions.medium
        }}
        mode={ModeOptions.status}
        txId={10}
      />
    </KimaProvider>
  )
}

export default App

Props

theme

Used to specify theme options of kima-transaction-widget.

  • Required: true
  • Type: ThemeOptions
  • Example
<KimaTransactionWidget
  theme={{
    colorMode: ColorModeOptions.light,
    backgroundColorLight: '#CCCCCC', // background color of widget when light mode
    backgroundColorDark: '#FFDDFF' // background color of widget when dark mode
  }}
/>

mode

Used to specify the scenario of kima-transaction-widget. Available modes are payment, bridget and status.

  • Required: true
  • Type: ModeOptions Payment and bridge scenario for the purpose of widget, status mode is for tracking status of specific transaction of kima widget. To use status mode, txId prop should be determined
export declare enum ModeOptions {
  payment = 'payment',
  bridge = 'bridge',
  status = 'status'
}

txId

Used to specify transaction index to keep tracking of it's status and progress using kima-transaction-widget. Used for only status mode.

  • Required: false
  • Type: boolean
  • Default: -1

titleOption

Used to specify title of widget. Consists of titles for each step of widget.

  • Required: false
  • Type: TitleOption
interface TitleOption {
  initialTitle?: string
  confirmTitle?: string
}
<KimaTransactionWidget
  titleOption={{
    initialTitle: 'New Purchase', // First screen's title
    confirmTitle: 'Confirm Purchase' // Second screen (confirmation step) title
  }}
/>

compliantOption

Used to specify usage of compliant check feature. Enable compliance check to prevent interacting with dangerous accounts.

  • Required: false
  • Type: boolean
  • Default: false

helpURL

Used to specify external url for help documentation

  • Required: false
  • Type: string

transactionOption

Used to specify payment scenario option.

  • Required: false
  • Type: TransactionOption
  • Example
<KimaTransactionWidget
  transactionOption={{
    targetChain: SupportNetworks.AVALANCHE, // target chain to receive payment
    targetAddress: '0x8222ADB2A2092c3774105a5F558987265D920C09', // target address to receive payment
    amount: 5 // token amount to receive payment
    currency: 'USDK' // token to be used (default as USDK for testnet)
  }}
/>

paymentTitleOption

Used to specify payment screen's title.

  • Required: false
  • Type: PaymentTitleOption
  • Example
<KimaTransactionWidget
  paymentTitleOption={{
    title:
      'You can now purchase our NFT on Polygon, using funds from other chains.',
    style: {
      fontSize: '1.2em',
      fontWeight: '500'
    }
  }}
/>

Kima Provider

<KimaProvider
  kimaBackendUrl='http://localhost:3001' // or your deployed backend instance
  externalProvider={new Web3Provider()}
  logLevel='debug' // optional, default is 'error'
  walletConnectProjectId='e579511a495b5c312b572b036e60555a'
>
  {/ * etc */}
</KimaProvider>

Used to provide the widget with wallet connection and chain switching functionality.

kimaBackendUrl

Used to specify kima transaction backend url.

  • Required: true
  • Type: string

walletConnectProjectId

Used to specify the WalletConnect project id. A default value is provided, but you can specify your own. To create a project, visit Reown Cloud and sign up for a free account (WalletConnect is now called Reown).

  • Required: false
  • Type: string

logLevel (optional)

For debugging purposes, you can specify the log level. Available levels are trace, debug, info, warn, error and silent. By default, the log level is set to error.

The log level can also be set using the LOG_LEVEL environment or the equivalent for your framework: NEXT_PUBLIC_LOG_LEVEL, VITE_LOG_LEVEL. The Widget property will take precedence over the environment variable as it is set last.

DEBUG mode: Type D E B U G while focus is on the Widget (not in the console) to enable debug mode. This will set the log level to debug and log all messages to the console. Type it again to disable debug mode and restore the default log level. Useful to temporarily toggle logging in the browser when in production or an already deployed app where changing the ENV variable would require a redeploy.

externalProvider

Used to provide an already connected wallet instance from your app. Depending on the network your dapp is currently connected to is the instance that you will need to provide.

interface ExternalProvider {
  type: 'evm' | 'solana' | 'tron'
  provider: Web3Provider | SolProvider | TronProvider
  signer: JsonRpcSigner | PublicKey | string
}
  • Required: false
  • Type: ExternalProvider

Event handlers

  • errorHandler: (e: any) => void: Callback function to handle errors.
  • closeHandler: (e: any) => void: Callback function to handle close event.
  • successHandler: (e: any) => void: Callback function to handle success event after transaction submission to kima transaction backend.

  • switchChainHandler: (chainId: number) => void: Callback function to handle chain switch event.

  • keplrHandler: (e: any) => void: Callback function to handle Keplr wallet events.

Note

How to fix Polyfill node core module error

1.2.76-beta.1

11 months ago

1.2.82-beta.1

9 months ago

1.4.5

5 months ago

1.4.4

5 months ago

1.4.3

5 months ago

1.4.2

5 months ago

1.4.1

5 months ago

1.4.0

5 months ago

1.2.78-beta.1

11 months ago

1.2.74-beta.1

12 months ago

1.3.10

8 months ago

1.2.81-beta.1

11 months ago

1.3.13

7 months ago

1.3.14

7 months ago

1.3.11

8 months ago

1.3.12

8 months ago

1.4.0-rc.9

5 months ago

1.4.0-rc.2

6 months ago

1.4.0-rc.1

6 months ago

1.4.0-rc.4

5 months ago

1.4.0-rc.3

5 months ago

1.4.0-rc.6

5 months ago

1.4.0-rc.5

5 months ago

1.4.0-rc.8

5 months ago

1.4.0-rc.7

5 months ago

1.3.7

8 months ago

1.3.6

8 months ago

1.3.5

8 months ago

1.3.4

8 months ago

1.3.3

8 months ago

1.3.2

8 months ago

1.2.72-beta.1

12 months ago

1.2.83-beta.1

9 months ago

1.3.9

8 months ago

1.3.8

8 months ago

1.2.80-beta.1

11 months ago

1.3.1-beta.1

8 months ago

1.4.0-rc.11

5 months ago

1.4.0-rc.10

5 months ago

1.4.0-rc.13

5 months ago

1.4.0-rc.12

5 months ago

1.4.0-rc.15

5 months ago

1.4.0-rc.14

5 months ago

1.4.0-rc.16

5 months ago

1.2.73-beta.1

12 months ago

1.2.71-beta.1

12 months ago

1.2.77-beta.1

11 months ago

1.2.79-beta.1

11 months ago

1.2.75-beta.1

12 months ago

1.2.69-beta.1

1 year ago

1.2.70-beta.1

1 year ago

1.2.65-beta.1

1 year ago

1.2.67-beta.1

1 year ago

1.2.66-beta.1

1 year ago

1.2.68-beta.1

1 year ago

1.2.64-beta.1

1 year ago

1.2.61-beta.1

1 year ago

1.2.63-beta.1

1 year ago

1.2.62-beta.1

1 year ago

1.2.60-beta.1

1 year ago

1.2.59-beta.1

1 year ago

1.2.58-beta.1

1 year ago

1.2.57-beta.1

1 year ago

1.2.55-beta.1

1 year ago

1.2.56-beta.1

1 year ago

1.2.54-beta.1

1 year ago

1.2.53-beta.1

1 year ago

1.2.52-beta.1

1 year ago

1.2.47-beta.1

1 year ago

1.2.46-beta.1

1 year ago

1.2.29-beta.1

1 year ago

1.2.25-beta.1

1 year ago

1.2.24-beta.1

1 year ago

1.2.28-beta.1

1 year ago

1.2.21-beta.1

1 year ago

1.2.20-beta.1

1 year ago

1.2.50-beta.1

1 year ago

1.2.18-beta.1

1 year ago

1.2.17-beta.1

1 year ago

1.2.16-beta.1

1 year ago

1.2.19-beta.1

1 year ago

1.2.41

1 year ago

1.2.42

1 year ago

1.2.40

1 year ago

1.2.45

1 year ago

1.2.43

1 year ago

1.2.48

1 year ago

1.2.44-beta.1

1 year ago

1.2.49-beta.1

1 year ago

1.2.27-beta.1

1 year ago

1.2.26-beta.1

1 year ago

1.2.23-beta.1

1 year ago

1.2.22-beta.1

1 year ago

1.2.51

1 year ago

1.2.38-beta.1

1 year ago

1.2.37-beta.1

1 year ago

1.2.39-beta.1

1 year ago

1.2.32-beta.1

1 year ago

1.2.30-beta.1

1 year ago

1.2.31-beta.1

1 year ago

1.2.36-beta.1

1 year ago

1.2.35-beta.1

1 year ago

1.2.34-beta.1

1 year ago

1.2.33-beta.1

1 year ago

1.2.12-beta.1

1 year ago

1.2.11-beta.1

1 year ago

1.2.10-beta.1

1 year ago

1.2.15-beta.1

1 year ago

1.2.13-beta.1

1 year ago

1.2.14-beta.1

1 year ago

1.2.9-beta.1

2 years ago

1.2.8-beta.1

2 years ago

1.2.7-beta.1

2 years ago

1.2.6-beta.1

2 years ago

1.2.5-beta.1

2 years ago

1.2.4-beta.1

2 years ago

1.2.3-beta.1

2 years ago

1.2.2-beta.1

2 years ago

1.2.1-beta.1

2 years ago

1.1.99-beta.1

2 years ago

1.1.98-beta.1

2 years ago

1.1.97-beta.1

2 years ago

1.1.95-beta.1

2 years ago

1.1.93-beta.1

2 years ago

1.1.92-beta.1

2 years ago

1.1.96-beta.1

2 years ago

1.1.94-beta.1

2 years ago

1.1.91-beta.1

2 years ago

1.1.90-beta.1

2 years ago

1.1.89-beta.1

2 years ago

1.1.88-beta.1

2 years ago

1.1.87-beta.1

2 years ago

1.1.85-beta.1

2 years ago

1.1.84-beta.1

2 years ago

1.1.83-beta.1

2 years ago

1.1.86-beta.1

2 years ago

1.1.82-beta.1

2 years ago

1.1.81-beta.1

2 years ago

1.1.80-beta.1

2 years ago

1.1.79-beta.1

2 years ago

1.1.78-beta.1

2 years ago

1.1.74-beta.1

2 years ago

1.1.73-beta.1

2 years ago

1.1.77-beta.1

2 years ago

1.1.76-beta.1

2 years ago

1.1.71-beta.1

2 years ago

1.1.72-beta.1

2 years ago

1.1.70-beta.1

2 years ago

1.1.64-beta.1

2 years ago

1.1.62-beta.1

2 years ago

1.1.68-beta.1

2 years ago

1.1.66-beta.1

2 years ago

1.1.67-beta.1

2 years ago

1.1.69-beta.1

2 years ago

1.1.65-beta.1

2 years ago

1.1.63-beta.1

2 years ago

1.1.59-beta.1

2 years ago

1.1.60-beta.1

2 years ago

1.1.61-beta.1

2 years ago

1.1.58-beta.1

2 years ago

1.1.57-beta.1

2 years ago

1.1.56-beta.1

2 years ago

1.1.55-beta.1

2 years ago

1.1.53-beta.1

2 years ago

1.1.54-beta.1

2 years ago

1.1.52-beta.1

2 years ago

1.1.51-beta.1

2 years ago

1.1.48-beta.1

2 years ago

1.1.50-beta.1

2 years ago

1.1.49-beta.1

2 years ago

1.1.47-beta.1

2 years ago

1.1.46-beta.1

2 years ago

1.1.42-beta.1

3 years ago

1.1.44-beta.1

2 years ago

1.1.43-beta.1

2 years ago

1.1.45-beta.1

2 years ago

1.1.41-beta.1

3 years ago

1.1.40-beta.1

3 years ago

1.1.39-beta.1

3 years ago

1.1.38-beta.1

3 years ago

1.1.37-beta.1

3 years ago

1.1.36-beta.1

3 years ago

1.1.35-beta.1

3 years ago

1.1.34-beta.1

3 years ago

1.1.33-beta.1

3 years ago

1.1.32-beta.1

3 years ago

1.1.31-beta.1

3 years ago

1.1.30-beta.1

3 years ago

1.1.29-beta.1

3 years ago

1.1.28-beta.1

3 years ago

1.1.27-beta.1

3 years ago

1.1.26-beta.1

3 years ago

1.1.25-beta.1

3 years ago

1.1.24-beta.1

3 years ago

1.1.23-beta.1

3 years ago

1.1.22-beta.1

3 years ago

1.1.21-beta.1

3 years ago

1.1.20-beta.1

3 years ago

1.1.19

3 years ago

1.1.18

3 years ago

1.1.17

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago