LedgerStorage

Git Source

Storage library for the Ledger diamond containing all data structures

Uses diamond storage pattern to avoid storage collisions

State Variables

LEDGER_STORAGE_SLOT

bytes32 private constant LEDGER_STORAGE_SLOT = keccak256("capsign.storage.ledger");

Functions

getLedgerStorage

Get the storage for the ledger

function getLedgerStorage() internal pure returns (LedgerData storage s);

Returns

Name
Type
Description

s

LedgerData

The storage struct

initializeLedgerStorage

Initialize the ledger storage

function initializeLedgerStorage(address _owner, uint8 _decimals, string memory _currencyCode) internal;

Parameters

Name
Type
Description

_owner

address

The owner of this ledger

_decimals

uint8

The number of decimal places for amounts

_currencyCode

string

The ISO currency code for this ledger

isInitialized

Check if the ledger is initialized

function isInitialized() internal view returns (bool);

Returns

Name
Type
Description

<none>

bool

True if initialized

getOwner

Get the owner of the ledger

function getOwner() internal view returns (address);

Returns

Name
Type
Description

<none>

address

The owner address

setOwner

Set the owner of the ledger

function setOwner(address newOwner) internal;

Parameters

Name
Type
Description

newOwner

address

The new owner address

getAccountant

Get the accountant of the ledger

function getAccountant() internal view returns (address);

Returns

Name
Type
Description

<none>

address

The accountant address

setAccountant

Set the accountant of the ledger

function setAccountant(address newAccountant) internal;

Parameters

Name
Type
Description

newAccountant

address

The new accountant address

getDecimals

Get the decimals setting

function getDecimals() internal view returns (uint8);

Returns

Name
Type
Description

<none>

uint8

The number of decimal places

getCurrencyCode

Get the currency code

function getCurrencyCode() internal view returns (string memory);

Returns

Name
Type
Description

<none>

string

The ISO currency code

Structs

AccountSectionInfo

struct AccountSectionInfo {
    uint256 id;
    string name;
    uint256 codeStart;
    uint256 codeEnd;
    bool debitNormal;
    bool active;
}

Account

struct Account {
    string code;
    string name;
    string description;
    int256 balance;
    uint256 sectionId;
    string parentCode;
    bool active;
    bool isParent;
    bool isContraAccount;
}

Entry

struct Entry {
    uint256 entryId;
    string accountCode;
    int256 amount;
    uint256 timestamp;
    uint256 transactionId;
    string description;
}

Transaction

struct Transaction {
    uint256 id;
    uint256 timestamp;
    string description;
    TransactionStatus status;
    uint256 postedAt;
}

LedgerData

struct LedgerData {
    uint8 decimals;
    string currencyCode;
    mapping(string => Account) accounts;
    mapping(uint256 => AccountSectionInfo) accountSections;
    uint256 nextSectionId;
    mapping(uint256 => Entry) entries;
    uint256 nextEntryId;
    mapping(uint256 => Transaction) transactions;
    uint256 nextTransactionId;
    mapping(uint256 => uint256[]) transactionEntries;
    mapping(string => string[]) childAccounts;
    address accountant;
    address owner;
    bool initialized;
}

Enums

TransactionStatus

enum TransactionStatus {
    Pending,
    Posted,
    Archived
}

Last updated

Was this helpful?