diff --git a/index.js b/index.js index c3ae6b0..d5dceb3 100644 --- a/index.js +++ b/index.js @@ -276,10 +276,13 @@ function request(url, config = {}) { export function getApiUrls(API_PATH) { return { + 'blocks': API_PATH + 'blocks', + 'blocks_detail': API_PATH + 'blocks/%(blockId)s', + 'outputs': API_PATH + 'outputs', + 'statuses': API_PATH + 'statuses', 'transactions': API_PATH + 'transactions', 'transactions_detail': API_PATH + 'transactions/%(txId)s', - 'outputs': API_PATH + 'outputs', - 'statuses': API_PATH + 'statuses' + 'votes': API_PATH + 'votes' }; } @@ -344,4 +347,29 @@ export function getStatus(tx_id, API_PATH) { }); } +export function getBlock(blockId, API_PATH) { + return request(getApiUrls(API_PATH)['blocks_detail'], { + urlTemplateSpec: { + blockId + } + }); +} + +export function listBlocks({tx_id, status}, API_PATH) { + return request(getApiUrls(API_PATH)['blocks'], { + query: { + tx_id, + status + } + }); +} + +export function listVotes(block_id, API_PATH) { + return request(getApiUrls(API_PATH)['votes'], { + query: { + block_id + } + }); +} +