Skip to content

Commit 5752a65

Browse files
committed
New method: getEternalReport
1 parent ab63753 commit 5752a65

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 4.3.5
4+
5+
- **Development:**
6+
- Add in getEternalReport method
7+
38
## 4.3.4
49

510
- **Development:**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dragonchain-sdk",
3-
"version": "4.3.4",
3+
"version": "4.3.5",
44
"description": "Dragonchain SDK for Node.JS and the Browser",
55
"license": "Apache-2.0",
66
"homepage": "https://github.com/dragonchain/dragonchain-sdk-javascript#readme",

src/interfaces/DragonchainClientInterfaces.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,3 +1236,12 @@ export interface PermissionsDocument {
12361236
};
12371237
};
12381238
}
1239+
1240+
export interface EternalReportV1 {
1241+
l1Transaction: L1DragonchainTransactionFull;
1242+
l1Block: BlockSchemaType;
1243+
l2Verifications: L2BlockAtRest[];
1244+
l3Verifications: L3BlockAtRest[];
1245+
l4Verifications: L4BlockAtRest[];
1246+
l5Verifications: L5BlockAtRest[];
1247+
}

src/services/dragonchain-client/DragonchainClient.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
CustomTagFieldOptions,
5858
SmartContractLogs,
5959
PermissionsDocument,
60+
EternalReportV1,
6061
} from '../../interfaces/DragonchainClientInterfaces';
6162
import { CredentialService, HmacAlgorithm } from '../credential-service/CredentialService';
6263
import { getDragonchainId, getDragonchainEndpoint } from '../config-service';
@@ -1437,6 +1438,32 @@ export class DragonchainClient {
14371438
return (await this.post('/v1/public-blockchain-transaction', body)) as Response<PublicBlockchainTransactionResponse>;
14381439
};
14391440

1441+
/**
1442+
* Get/Generate an Eternal-type report given a transaction ID
1443+
*/
1444+
public getEternalReport = async (options: {
1445+
/**
1446+
* the transaction ID of the transaction to generate report for
1447+
*/
1448+
transactionId: string;
1449+
}) => {
1450+
if (!options.transactionId) throw new FailureByDesign('PARAM_ERROR', 'Parameter `transactionId` is required');
1451+
const transaction = await this.getTransaction({ transactionId: options.transactionId });
1452+
if (transaction && !transaction.ok) throw new FailureByDesign('NOT_FOUND', 'transaction not found');
1453+
const blockId = transaction.response.header.block_id;
1454+
const block = await this.getBlock({ blockId });
1455+
if (block && !block.ok) throw new FailureByDesign('NOT_FOUND', 'block not found');
1456+
const verifications = await this.getVerifications({ blockId });
1457+
return {
1458+
l1Transaction: transaction.response,
1459+
l1Block: block.response,
1460+
l2Verifications: verifications.response && verifications.response['2'],
1461+
l3Verifications: verifications.response && verifications.response['3'],
1462+
l4Verifications: verifications.response && verifications.response['4'],
1463+
l5Verifications: verifications.response && verifications.response['5'],
1464+
} as EternalReportV1;
1465+
};
1466+
14401467
/**
14411468
* @hidden
14421469
*/

0 commit comments

Comments
 (0)