0.0.1 • Published 6 years ago

lootsafe v0.0.1

Weekly downloads
4
License
UNLICENSED
Repository
github
Last release
6 years ago

LootSafe.JavaScript.API

LootSafe API abstraction written in JavaScript to aid developers with integrating LootSafe's services with their games.

Check out our website for more information.

Index

Requirements and Installation

This API wrapper works on a Node.js server and currently requires the usage of the following required libaries

Step 1

Clone/Download this repository

Step 2

Install dependencies using the node package manager

npm install

Running the example

Everything is installed, you're ready to see our example in action!

Run the following command

node index.js

Contents of index.js

const Loot = require('./lootsafe/LootSafe.js')

const baseurl = 'http://localhost:1337/v1/'
const apikey = 'pWpzWuxoKUKAmlHc0wPi7lFS38FTth'
const otpkey = 'otpkey'
const account = '0xb68066af702fe39ad76f486a9a1f971bccc10b1e'

const lootsafe = Loot.init(baseurl, apikey, otpkey)

lootsafe.itemBalances(account).then(res => {
  console.log(res)
})    

Unit Tests

Keep in mind that some of the unit tests can clear availability

Running an individual test

./node_modules/mocha/bin/mocha test/balances.test.js

Running all tests

./node_modules/mocha/bin/mocha test/*

Available Unit Tests

test/balances.test.js
test/crafter.test.js
test/events.test.js
test/general.test.js
test/items.test.js
test/lootbox.test.js

Endpoints

EndpointTypeAuthStatus
Balance
balanceOf(address)GETOPENAvailable
itemBalances(address)GETOPENAvailable
itemBalance(itemAddress,address)GETOPENAvailable
Crafter
getCraftables()GETOPENAvailable
getDeconstructables()GETOPENAvailable
getDeconstructionRecipe(itemAddress)GETOPENAvailable
getRecipe(itemAddress)GETOPENAvailable
newRecipe(apiKey, otp, result, materials, counts)POSTAUTHAvailable
removeRecipe(apiKey,otp, itemAddress)POSTAUTHAvailable
Events
fetchEvents()GETOPENAvailable
General
getMeta()GETOPENAvailable
getTokenAddress()GETOPENAvailable
newItem(apiKey, otp, name, id, totalSupply, metadata)POSTAUTHAvailable
Items
getItems()GETOPENAvailable
getItemAddresses()GETOPENAvailable
ledger()GETOPENAvailable
getItem(item)GETOPENAvailable
getItemByAddress(itemAddress)GETOPENAvailable
spawnItem(itemAddress, account)POSTOPENAvailable
clearAvailability(itemAddress)POSTOPENAvailable
LootBox
getChances()GETOPENAvailable
getCost()GETOPENAvailable
getItems(rarity)GETOPENAvailable
addItem(apikey,opt,itemAddress,rarity)POSTAUTHAvailable
updateChance(apikey, opt, epic, rare, uncommon)GETAUTHAvailable
updateLootBoxCost(apikey, opt, cost)GETAUTHAvailable

Future Development

  • Authentication on some routes
  • API key setup better documented
  • Less hardcoding