Classes
Definition for Classes
Wallet
creates a new wallet
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
Converts a number to a BigInt, this will remove any floating point
Parameters
num ((bigint | number | string))
the number which should be parsed to a bigint
Returns
bigint
:
returns the converted bigint
Instance Members
▸
_addHistory(change, reason)
Queues a history update
_addHistory(change: bigint, reason:
string)
Parameters
change (bigint)
the amount which had changed
reason (string)
the text wich should be used in the log
Serializes the balace and uid of the Wallet
Returns
Object
:
returns a JSON.stringify able object
Checks if a user has enough funds to do a transaction
Parameters
amount ((bigint | number | string))
checks if a user has the amount of funds
Returns
boolean
:
returns true when the user has at least as much funds
▸
addBalance(amount, reason = "")
Adds an amount of funds to the wallet
Parameters
amount ((bigint | number | string))
the amount of funds which should be added
reason (string?
= ""
)
the reason which gets logged inside the transaction history
Returns
Wallet
:
returns this to chain functions
▸
setBalance(amount, reason = "")
Sets the amount of funds in the wallet
Parameters
amount ((bigint | number | string))
the amount of funds which should be set
reason (string?
= ""
)
the reason which gets logged inside the transaction history
Returns
Wallet
:
returns this to chain functions
▸
removeBalance(amount, reason = "")
Removes an amount of funds from the wallet
Parameters
amount ((bigint | number | string))
the amount of funds which should be removed
reason (string?
= ""
)
the reason which gets logged inside the transaction history
Returns
Wallet
:
returns this to chain functions
Retrieve the current balance
Returns
string
:
returns the current balance as string
Retrieve the owner of the wallet
Returns
string
:
returns the uid of the wallet owner
Retrieves the transaction history
Parameters
limit (number
= 25
)
the amount of entries which should get retrieved
Returns
Array<Promise>
:
returns a Promise which has an array with the last n transactions
Bank
Bank manages wallets of multiple users
Parameters
storeHandle (object)
the store object from where transactions get handled
saveInterval (object)
timeout until data gets saved to the store
Instance Members
Adds a new wallet to the saving Queue
Parameters
wallet (Wallet)
the wallet which should get saved
Forces the save of all wallets in the queue
flushQueue()
Creates a wallet and returns it
_createWallet(args: ...any):
Wallet
Parameters
args (...any)
the arguments which will passed to the Wallet constructor
Returns
Wallet
:
returns the created wallet
Retrieves a wallet instance of the owner with the given uid
Parameters
uid (string)
the uid from who the wallet should get retrieved
Returns
Promise
:
fulfills with the Wallet of the given uid
Retrieves the transaction history of a uid
Parameters
uid (string)
the uid for which the history should be retrieved
limit (number)
the amount of entries which should be retrieved
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the transaction array as value
DefaultStore
Creates a new Store class
new DefaultStore()
Instance Members
Resets and wipes the complete Store except the dump
Returns
Promise
:
Retrieves the balance of multiple uids
Parameters
uids (Array<string>)
takes an array of uids as argument
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the balance as value
Retrieves the balance of all existing users in the db
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the balance as value
Retrieves the transaction history of an uid
Parameters
uid (string)
the uid for which the history should be retrieved
limit (number)
the amount of entries which should be retrieved
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the transaction array as value
Retrieves the transaction history of an uid
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the transaction array as value
Adds transaction to the transaction history of an uid
Parameters
data (Array<Object>)
the transaction data which should be added
Name |
Description |
data[].uid string
|
the uid from the owner of the transaction
|
data[].change number
|
the value of how much the balance changed
|
data[].date number
|
the date as Date.now() format
|
data[].reason string
|
the reason text (max 255 chars)
|
Returns
Promise
:
returns a Promise which resolves on success
Sets the balance of multiple uids to the given value
Parameters
Name |
Description |
data[].uid string
|
the uid of the client
|
data[].balance string
|
the balance which should get saved
|
Returns
Promise
:
returns a Promise which resolves on success
Updates the nicknames and uid map
Parameters
list (object)
a list of uids as key and their nickname as value which should get updated and stored
Returns
Promise
:
returns a Promise which resolves on success
retrieves multiple nicknames from cache
Parameters
uids (array)
a list of uids which should get resolved
Returns
Promise
:
returns a promise which resolves with the found nicknames, returns the uid if no nickname has been found
Retrieves the transaction history of an uid
Returns
Promise
:
returns a Promise which resolves to an object with the uids as key and the transaction array as value
▸
getTopList(offset, limit)
Retrieves the toplist of uids sorted by their balance
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 a sorted array of objects with uid and the balance amount
Exports
These Functions gets exported as object when imported through require("MultiConomy")
getCurrencySign
Retrieves the currency sign
Returns
string
:
returns the set currency sign
getCurrencyName
Retrieves the currency name
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
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
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
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
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