UNPKG

ark-monitor

Version:
124 lines (101 loc) 3.75 kB
const fetchAsync = require("../../utils/fetch"); const template = require("../../utils/templates"); const {url} = require("../../utils/globalvar") /*%%%%%%%%%%%%%%% List All Wallets %%%%%%%%%%%%%%%*/ async function getAllWallet (maxPage=1){ let path = url+"/wallets?" let res = await template.retrieve_with_limitation_template(path, maxPage) return res } /** test function */ // async function printR(){ // let res = await getAllWallet(4) // console.log(res) // } // printR() module.exports.getAllWallet = getAllWallet; /** %%%%%%%%%%%%%%% Retrieve a Wallet %%%%%%%%%%%%%%%%%%*/ // by Public key or address async function retrieve_a_wallet(id){ let path = url+`/wallets/${id}` let res = await template.retrieve_OBJ_template(path) return res } /** test function */ // async function printY(){ // let res = await retrieve_a_transaction("AUb3kavym8ZvRYHCcFo66aR1PQtPvUYxSs") // console.log(res) // } // printY() module.exports.retrieve_a_wallet = retrieve_a_wallet; /** %%%%%%%%%%%%% List All Transactions of a Wallet %%%%%%%%%%%%%%%*/ async function list_Of_All_Transactions_Wallet(id, maxPage=1){ if(id==null){ console.log("id not defined") } let path = url+`/wallets/${id}/transactions?` let res = await template.retrieve_with_limitation_template(path, maxPage) return res; } /** test function */ // async function printA(){ // let res = await list_Of_All_Transactions_Wallet("AHJJ29sCdR5UNZjdz3BYeDpvvkZCGBjde9", 2) // console.log(res) // } // printA() module.exports.list_Of_All_Transactions_Wallet = list_Of_All_Transactions_Wallet; /** %%%%%%%%%%%%% List All Sent Transactions of a Wallet %%%%%%%%%%%%%%%%%*/ async function list_All_Sent_Transactions_Wallet(id, maxPage=1){ if(id==null){ console.log("id not defined") return false } let path = url+`/wallets/${id}/transactions/sent?` let res = await template.retrieve_with_limitation_template(path, maxPage=1) return res; } /** test function */ // async function printB(){ // let res = await list_All_Sent_Transactions_Wallet("AHJJ29sCdR5UNZjdz3BYeDpvvkZCGBjde9", 4) // console.log(res) // } // printB() module.exports.list_All_Sent_Transactions_Wallet = list_All_Sent_Transactions_Wallet; /** %%%%%%%%%% List All Received Transactions of a Wallet %%%%%%%%%%%%% */ async function list_All_Received_Transactions_Wallet(id, maxPage=1){ if(maxPage==null){ console.log("maxPage not defined") } if(id==null){ console.log("id not defined") } let path = url+`/wallets/${id}/transactions/received?` let res = await template.retrieve_with_limitation_template(path, maxPage) return res; } /** test function */ // async function printC(){ // let res = await list_All_Received_Transactions_Wallet("AHJJ29sCdR5UNZjdz3BYeDpvvkZCGBjde9", 4) // console.log(res) // } // printC() module.exports.list_All_Received_Transactions_Wallet = list_All_Received_Transactions_Wallet; /** %%%%%%%%%% List All Votes of a Wallet %%%%%%%%%%%%%% */ async function list_All_Votes_Wallet(id, maxPage=1){ if(maxPage==null){ console.log("maxPage not defined") } if(id==null){ console.log("id not defined") } let path = url+`/wallets/${id}/votes?` let res = await template.retrieve_with_limitation_template(path, maxPage) return res; } /** test function */ // async function printD(){ // let res = await list_All_Votes_Wallet("AHJJ29sCdR5UNZjdz3BYeDpvvkZCGBjde9", 4) // console.log(res) // } // printD() module.exports.list_All_Votes_Wallet = list_All_Votes_Wallet;