Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coinjinja/coinview-sdk

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coinjinja/coinview-sdk

> Client side JS SDK for creating CoinView DApps.

  • 1.1.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Coinview SDK

Client side JS SDK for creating CoinView DApps.

Install

Get from CDN:

https://unpkg.com/@coinjinja/coinview-sdk@1.0.10-dev/dist/coinview.min.js

Get from NPM:

npm install @coinjinja/coinview-sdk --save

Guide

Make sure you have installed the coinview-sdk. If you installed the SDK via npm, you can import it:

import coinview from '@coinjinja/coinview-sdk'

// or with common js require
const coinview = require('@coinjinja/coinview-sdk')

If you are using the SDK via CDN, it is available on window:

<script src="https://unpkg.com/@coinjinja/coinview-sdk@1.0.10-dev/dist/coinview.min.js"></script>
const coinview = window.coinview

Initialize

To use the CoinView SDK, an APP ID is required, you can find or create your App [TODO]. Then, use .init to initialize the CoinView SDK:

coinview.init(YOUR_APP_ID)

Note, the .init method should be called before using any other methods.

Example

Here is a full example of how to use the CoinView SDK:

import coinview from '@coinjinja/coinview-sdk'

coinview.init(YOUR_APP_ID).then(() => {

  coinview.app().then(app => {
    console.log(app)
  })

  coinview.user.profile().then(profile => {
    console.log(profile)
  })

})

async and await

Hint on using async and await:

import coinview from '@coinjinja/coinview-sdk'
coinview.init(YOUR_APP_ID)

async function fetchUserProfile () {
  const profile = await coinview.user.profile()
  return profile
}

Modules

Modules and functions in coinview. You need to call .init before using any of the below methods:

coinview.init(YOUR_APP_ID)

coinview.app()

It returns the information of your DApps:

coinview.app().then(app => {
  console.log(app)
})

/*
{
  name: 'Demo App',
  iconUrl: 'https://...',
  locale: 'ja',
  currency: 'JPY'
  params: 'customParam1=xxx&customParam2=xxx',
}
*/

coinview.user.profile()

It returns the current user's profile information:

coinview.user.profile().then(profile => {
  console.log(profile)
})

/*
{
  nickname: 'coinjinja',
  userId: '123'
}
*/

coinview.user.assets()

It returns a list of the current user's assets information:

coinview.user.assets().then(assets => {
  console.log(assets)
})

/*
[
  {
    assetId: string
    name: string
    symbol: string
    iconUrl: string
    balance: string
  }
]
*/

coinview.user.address(assetId)

It returns the address information of an asset:

coinview.user.address(assetId).then(address => {
  console.log(address)
})

/*
{
  assetId: string
  address: string
}
*/

coinview.payment.create(PaymentPayload)

It creates a payment:

/*
const payload = {
  traceId?: string
  assetId: string
  amount: number
  memo?: string
  description: string
}
*/

coinview.payment.create(payload).then(payment => {
  console.log(payment)
})

/*
{
  snapshotId: string
  traceId: string
  assetId: string
  mixinId: string
  amount: number
}
*/

coinview.navigate.back()

Navigation back.

coinview.navigate.close()

Navigation close.

coinview.ui.notice(payload)

It shows an alert message:

/*
const payload = {
  title: string
  content: string
  button: string
}
*/

const payload = {
  title: 'Notice',
  content: 'You have done something wrong',
  button: 'Ok'
}
coinview.ui.notice(payload)

coinview.ui.confirm(payload)

It shows a confirm message:

/*
const payload = {
  title: string
  content: string
  confirmButton: string
  cancelButton: string
}
*/

const payload = {
  title: 'Alert',
  content: 'Are you sure you want to delete it?',
  confirmButton: 'Sure',
  cancelButton: 'Cancel'
}
const answer = await coinview.ui.confirm(payload)
// true or false

coinview.utils.scanQR()

coinview.utils.setClipboard(text)

FAQs

Package last updated on 27 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc