Skip to content

Commit

Permalink
docs: 1113 core diagram reworked (#1272)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucanicoladebiasi authored Sep 10, 2024
1 parent 84f0c52 commit 3c8079e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 34 deletions.
64 changes: 38 additions & 26 deletions docs/diagrams/architecture/core-package.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,45 @@ It represents the architecture of the `core package` with its most important com
C4Context
title "Vechain SDK architecture overview: core package"
Boundary(b0, "core", "package") {
Boundary(b1, "Core components") {
System(abi, "Abi module", "Handles all abi related operations")
System(address, "Address module", "Handles all address related operations")
System(assertions, "Assertions module", "Provides a set of functions and utilities for writing and handling assertions in the code")
System(bloom, "Bloom module", "Handles all bloom related operations")
System(certificate, "Certificate module", "Handles all certificate related operations")
System(clause, "Clause", "Handles all clause related operations")
System(contract, "Smart contract module", "Handles all smart contract related operations")
System(encoding, "RLP encoding module", "Handles all RLP encoding related operations")
System(hash, "Hash module", "Handles all hash related operations")
System(hdkey, "HDKey module", "Handles all Hierarchical Deterministic Key related operations")
System(keystore, "Keystore module", "Handles all keystore related operations")
System(mnemonic, "Mnemonic module", "Handles all mnemonic related operations")
System(secp256k1, "Secp256k1 module", "Handles all secp256k1 related operations")
System(transaction, "Transaction module", "Handles all transaction related operations")
Boundary(core, "core", "package") {
Boundary(core_modules, "Core modules") {
System(abi, "ABI module", "Handle all ABI related operations.")
System(certificate, "Certificate module", "Handle all certificate related operations.")
System(clause, "Clause", "Handles all clause related operations.")
System(contract, "Smart contract module", "Handle all smart contract related operations.")
System(encoding, "RLP encoding module", "Handle RLP encoding related operations.")
Boundary(hdkey, "HDKey module") {
System(KDKey, "HDKey class", "Handle all Hierarchical Deterministic Key related operations.")
}
System(keystore, "Keystore module", "Handle all keystore related operations.")
Boundary(secp256k1, "Secp256k1 module") {
System(Secp256k1, "Secp256k1 class", "Handle all SECP256K1 related operations.")
}
System(transaction, "Transaction module", "Handle all transaction related operations.")
Boundary(vcdm, "VeChain Data Model module", "Provide types and methods to represent the data in Thor.") {
Boundary(account, "Account module") {
System(Account, "Account class", "Handle all account related operations.")
}
System(Address, "Address class", "Handle all address related operations.")
System(BloomFilter, "BloomFilter class", "Handle all Bloom filter related operations.")
Boundary(currency, "Currency module") {
System(Currency, "Currency", "Handle all currency related operations.")
}
System(FPN, "FPN class", "Handle all Fixed Point Number math.")
Boundary(hash, "Hash module") {
System(Blake2b256, "Blake2b256 class")
System(Keccak, "Blake2b256 class")
System(Sha256, "Sha256 class")
}
System(Hex, "Hex class", "Handle data in hexadecimal representation.")
System(HexInt, "HexInt class", "Handle the hexadecimal representation<br>for integer values.")
System(HexUInt, "HexUInt class", "Handle the hexadecimal representation<br>for unsigned integer (natural number) values.")
System(Mnemonic, "Mnemonic class", "Handle all BIP32 mnemonic related operations.")
System(Quantity, "Quantity class", "Represent Thor quantities.")
System(Revision, "Revision class", "Represents a revision for a Thor transaction or block.")
}
}
Boundary(b2, "Utils") {
System(bloom, "Bloom utils", "Handles all utils constructs for bloom module")
System(const, "Main constants utils", "Contains all core constants")
System(data, "Data utils", "Handles all data utils")
System(revision, "Revision utils", "Handles all revision-related utility operations")
System(transaction, "Transaction utils", "Handles all utils constructs for transaction module")
System(units, "Units utils", "Handles all units utils. Basic conversions.<br>e.g. Wei to VET")
}
}
}
UpdateLayoutConfig($c4ShapeInRow="2", $c4BoundaryInRow="1")
```
2 changes: 1 addition & 1 deletion packages/core/src/vcdm/account/Account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InvalidOperation } from '@vechain/sdk-errors';
import { type Address } from '../Address';
import { type Currency } from '../Currency';
import { type Currency } from '../currency/Currency';
import { type VeChainDataModel } from '../VeChainDataModel';

type AccountType = 'EOA' | 'Contract';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { type VeChainDataModel } from './VeChainDataModel';
import { type VeChainDataModel } from '../VeChainDataModel';
import { type FPN } from '../FPN';

export interface Currency extends VeChainDataModel<Currency> {
get bi(): bigint;

get code(): string;

get value(): FPN;
}

// class Wei<Digits> implements Currency<Digits.wei> {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/vcdm/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './account';
export * from './Address';
export * from './BloomFilter';
export * from './Currency';
export * from './currency/Currency';
export * from './FPN';
export * from './hash';
export * from './Hex';
Expand Down
7 changes: 4 additions & 3 deletions packages/core/tests/vcdm/account/Account.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Address, Mnemonic } from '../../../src';
import { Address, FPN, Mnemonic } from '../../../src';
import { Account } from '../../../src/vcdm/account';
import { type Currency } from '../../../src/vcdm/Currency';
import { type Currency } from '../../../src/vcdm/currency/Currency';

// Use actual Currency subclasses once they are implemented.
const mockCurrency: Currency = {
Expand All @@ -9,7 +9,8 @@ const mockCurrency: Currency = {
code: 'VET',
n: 0,
isEqual: jest.fn().mockReturnValue(true),
bytes: new Uint8Array(0)
bytes: new Uint8Array(0),
value: FPN.of(0)
};

/**
Expand Down

1 comment on commit 3c8079e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
99.41% (4073/4097) 98.23% (1278/1301) 99.75% (807/809)
Title Tests Skipped Failures Errors Time
core 794 0 💤 0 ❌ 0 🔥 1m 30s ⏱️
network 668 0 💤 0 ❌ 0 🔥 4m 7s ⏱️
errors 42 0 💤 0 ❌ 0 🔥 14.659s ⏱️

Please sign in to comment.