Classes

Definition for Classes

Wallet

creates a new wallet

new Wallet(bankHandle: Bank, uid: string, balance: (bigint | number | string))
Parameters
bankHandle (Bank) the bank to which the wallet belongs to
uid (string) the uid to who the wallet belongs to
balance ((bigint | number | string)) the amount of funds a wallet has
Static Members
convertToBigInt(num)
Instance Members
_addHistory(change, reason)
serializeBalance()
hasFunds(amount)
addBalance(amount, reason = "")
setBalance(amount, reason = "")
removeBalance(amount, reason = "")
getBalance()
getOwner()
getHistory(limit)

Bank

Bank manages wallets of multiple users

new Bank(storeHandle: object, saveInterval: object)
Parameters
storeHandle (object) the store object from where transactions get handled
saveInterval (object) timeout until data gets saved to the store
Instance Members
queueSave(wallet)
flushQueue()
_createWallet(args)
getWallet(uid)
getHistory(uid, limit)

DefaultStore

Creates a new Store class

new DefaultStore()
Instance Members
reset()
getBalance(uids)
getAllBalances()
getHistory(uid, limit)
getAllHistory()
addHistory(data)
setBalance(data)
updateNicks(list)
getNicknames(uids)
getAllNicknames()
getTopList(offset, limit)

Exports

These Functions gets exported as object when imported through require("MultiConomy")

getCurrencySign

Retrieves the currency sign

getCurrencySign(): string
Returns
string: returns the set currency sign

getCurrencyName

Retrieves the currency name

getCurrencyName(): string
Returns
string: returns the currency name

getWallet

Retrieves a wallet from a client BEWARE, never cache the wallet on your side, always request a new wallet

getWallet(client: (client | string)): Promise
Parameters
client ((client | string)) takes a Sinusbot Client Object or uid which should be looked up
Returns
Promise: returns a Promise object which resolves to the wallet

getBalance

Retrieves the amount of money a client has

getBalance(client: (client | string)): Promise
Parameters
client ((client | string)) takes a Sinusbot Client Object or uid which should be looked up
Returns
Promise: returns a Promise object which returns the amount of money a client has

getBalances

Retrieves the amount of money multiple clients have

getBalances(clients: (Array<client> | Array<string>)): Promise
Parameters
clients ((Array<client> | Array<string>)) takes a mix of Sinusbot Clients and uids which should be looked up
Returns
Promise: returns a Promise object with an object of all client uids, nickname and their balance

getTopList

Retrieves the toplist of uids sorted by their balance

getTopList(offset: number, limit: number): Promise
Parameters
offset (number = 0) the offset from where the first user should be display
limit (number = 10) the amount of users which should be retrieved
Returns
Promise: returns a Promise which resolves to an array of objects with uid and the balance amount