Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 4.3.5

- **Development:**
- Add in getEternalReport method

## 4.3.4

- **Development:**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dragonchain-sdk",
"version": "4.3.4",
"version": "4.3.5",
"description": "Dragonchain SDK for Node.JS and the Browser",
"license": "Apache-2.0",
"homepage": "https://github.com/dragonchain/dragonchain-sdk-javascript#readme",
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/DragonchainClientInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,12 @@ export interface PermissionsDocument {
};
};
}

export interface EternalReportV1 {
l1Transaction: L1DragonchainTransactionFull;
l1Block: BlockSchemaType;
l2Verifications: L2BlockAtRest[];
l3Verifications: L3BlockAtRest[];
l4Verifications: L4BlockAtRest[];
l5Verifications: L5BlockAtRest[];
}
27 changes: 27 additions & 0 deletions src/services/dragonchain-client/DragonchainClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
CustomTagFieldOptions,
SmartContractLogs,
PermissionsDocument,
EternalReportV1,
} from '../../interfaces/DragonchainClientInterfaces';
import { CredentialService, HmacAlgorithm } from '../credential-service/CredentialService';
import { getDragonchainId, getDragonchainEndpoint } from '../config-service';
Expand Down Expand Up @@ -1437,6 +1438,32 @@ export class DragonchainClient {
return (await this.post('/v1/public-blockchain-transaction', body)) as Response<PublicBlockchainTransactionResponse>;
};

/**
* Get/Generate an Eternal-type report given a transaction ID
*/
public getEternalReport = async (options: {
/**
* the transaction ID of the transaction to generate report for
*/
transactionId: string;
}) => {
if (!options.transactionId) throw new FailureByDesign('PARAM_ERROR', 'Parameter `transactionId` is required');
const transaction = await this.getTransaction({ transactionId: options.transactionId });
if (transaction && !transaction.ok) throw new FailureByDesign('NOT_FOUND', 'transaction not found');
const blockId = transaction.response.header.block_id;
const block = await this.getBlock({ blockId });
if (block && !block.ok) throw new FailureByDesign('NOT_FOUND', 'block not found');
const verifications = await this.getVerifications({ blockId });
return {
l1Transaction: transaction.response,
l1Block: block.response,
l2Verifications: verifications.response && verifications.response['2'],
l3Verifications: verifications.response && verifications.response['3'],
l4Verifications: verifications.response && verifications.response['4'],
l5Verifications: verifications.response && verifications.response['5'],
} as EternalReportV1;
};

/**
* @hidden
*/
Expand Down