Skip to content
Snippets Groups Projects
Commit 30d76fda authored by Igor Markin's avatar Igor Markin
Browse files

Merge branch '28-get-seal-time-from-aeternity-api' into 'master'

28 get seal time from aeternity api

See merge request !80
parents a50db5f2 e266c1c0
No related branches found
No related tags found
1 merge request!8028 get seal time from aeternity api
Pipeline #44859 passed
......@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [2.0.2] - 2021-08-24
### Added
- Obtain microblock timestamp and provide it as transaction time via VerificationService
## [2.0.1] - 2021-06-23
### Changed
......
......@@ -15,6 +15,11 @@ declare class AeternityService {
requestApi: (apiUrls: string[]) => Request;
getTxDataByHash(hash: string): Promise<TxData>;
decodeContractCallData(callData: string): Promise<DecodedCallData>;
getMicroBlock(hash: string): Promise<{
height: number;
time: number;
hash: string;
}>;
getBlock(height: number): Promise<{
height: number;
time: number;
......
......@@ -83,6 +83,7 @@ class AeternityService {
tx: {
callData: data.tx.call_data,
},
blockHash: data.block_hash,
};
});
}
......@@ -106,6 +107,18 @@ class AeternityService {
};
});
}
getMicroBlock(hash) {
return __awaiter(this, void 0, void 0, function* () {
const { time, height } = yield this.requestNode({
url: `/v2/micro-blocks/hash/${hash}/header`,
}).then(({ data }) => data);
return {
height,
time,
hash,
};
});
}
getBlock(height) {
return __awaiter(this, void 0, void 0, function* () {
const { time, hash } = yield this.requestNode({
......
export interface AeternityAPITxData {
hash: string;
block_height: number;
block_hash: string;
tx: {
call_data: string;
};
......
......@@ -113,7 +113,13 @@ class VerificationService extends EventEmitter {
batchHash,
};
this.emit(exports.STATUS_BATCH_VERIFIED, batchVerificationDetails);
blockData = yield this.getBlockData(txData.blockHeight);
const blockRequests = yield Promise.all([
this.getBlockData(txData.blockHeight),
this._aeternityService.getMicroBlock(txData.blockHash),
]);
blockData = blockRequests[0];
const microBlockData = blockRequests[1];
txData.time = microBlockData.time;
this.emit(exports.BLOCK_DATA_RETRIEVED, blockData);
}
catch (e) {
......
......@@ -56,9 +56,11 @@ export interface BlockData {
export interface TxData {
hash: string;
blockHeight: number;
blockHash: string;
tx: {
callData: string;
};
time?: number;
}
export interface DecodedCallData {
key: string;
......
{
"name": "@vereign/light-utils",
"version": "2.0.1",
"version": "2.0.2",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
......
......@@ -95,6 +95,7 @@ class AeternityService {
tx: {
callData: data.tx.call_data,
},
blockHash: data.block_hash,
};
}
......@@ -117,6 +118,20 @@ class AeternityService {
};
}
async getMicroBlock(
hash: string
): Promise<{ height: number; time: number; hash: string }> {
const { time, height } = await this.requestNode({
url: `/v2/micro-blocks/hash/${hash}/header`,
}).then(({ data }: Response<AeternityAPIBlockData>) => data);
return {
height,
time,
hash,
};
}
async getBlock(
height: number
): Promise<{ height: number; time: number; hash: string }> {
......
export interface AeternityAPITxData {
hash: string;
block_height: number;
block_hash: string;
tx: {
call_data: string;
};
......
......@@ -144,7 +144,14 @@ class VerificationService extends EventEmitter {
this.emit(STATUS_BATCH_VERIFIED, batchVerificationDetails);
blockData = await this.getBlockData(txData.blockHeight);
const blockRequests = await Promise.all([
this.getBlockData(txData.blockHeight),
this._aeternityService.getMicroBlock(txData.blockHash),
]);
blockData = blockRequests[0];
const microBlockData = blockRequests[1];
txData.time = microBlockData.time;
this.emit(BLOCK_DATA_RETRIEVED, blockData);
} catch (e) {
......
......@@ -65,9 +65,11 @@ export interface BlockData {
export interface TxData {
hash: string;
blockHeight: number;
blockHash: string;
tx: {
callData: string;
};
time?: number;
}
export interface DecodedCallData {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment