LedgerStorage
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
s
LedgerData
The storage struct
initializeLedgerStorage
Initialize the ledger storage
function initializeLedgerStorage(address _owner, uint8 _decimals, string memory _currencyCode) internal;
Parameters
_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
<none>
bool
True if initialized
getOwner
Get the owner of the ledger
function getOwner() internal view returns (address);
Returns
<none>
address
The owner address
setOwner
Set the owner of the ledger
function setOwner(address newOwner) internal;
Parameters
newOwner
address
The new owner address
getAccountant
Get the accountant of the ledger
function getAccountant() internal view returns (address);
Returns
<none>
address
The accountant address
setAccountant
Set the accountant of the ledger
function setAccountant(address newAccountant) internal;
Parameters
newAccountant
address
The new accountant address
getDecimals
Get the decimals setting
function getDecimals() internal view returns (uint8);
Returns
<none>
uint8
The number of decimal places
getCurrencyCode
Get the currency code
function getCurrencyCode() internal view returns (string memory);
Returns
<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?