@axerunners/insight-ui
Version:
An open-source frontend for the Insight API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the Axe network and build your own services with it.
41 lines (39 loc) • 1.07 kB
JavaScript
;
angular.module('insight.blocks')
.factory('Block',
function ($resource) {
return $resource(window.apiPrefix + '/block/:blockHash', {
blockHash: '@blockHash'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
});
})
.factory('Blocks',
function ($resource) {
return $resource(window.apiPrefix + '/blocks');
})
.factory('BlockHashValidator',
function (HashValidator) {
return {
test: function (blockHashStr, network) {
return HashValidator.test64(blockHashStr) ||
(HashValidator.test66(blockHashStr) && blockHashStr.startsWith('0x'));
}
};
})
.factory('BlockByHeight',
function ($resource) {
return $resource(window.apiPrefix + '/block-index/:blockHeight');
});