New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@khgame/conv

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@khgame/conv

token conversion based game framework

latest
Source
npmnpm
Version
0.0.1-beta.1
Version published
Maintainers
1
Created
Source

tconv

token conversion based game framework

Usage

const TConv = require('tconv')
const userStore = require('../userStore') // for example

let conv = new TConv()
conv.use(async (ctx, next) => {
  console.log('event', ctx.params.event, ctx.params.nonce)
  await next()
  console.log('asset operations', JSON.stringify(ctx))
  for (let i in ctx.t.in) {
    let { uid, tid, num } = ctx.t.in[i]
    ctx.assert(num && num > 0, 'token-in error, invalid num')
    await userStore.incToken(uid, { tid, num: -num })
  }
  for (let i in ctx.t.out) {
    let { uid, tid, num } = ctx.t.out[i]
    ctx.assert(num && num > 0, 'token-out error, invalid num')
    await userStore.incToken(uid, { tid, num: num })
  }
})

conv.init()
conv.apply({ event: 'gather', uid: '0000001' })

Keywords

game

FAQs

Package last updated on 09 Feb 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