Skip to content

Commit c002f33

Browse files
committed
feat: add data structs
1 parent c1d5034 commit c002f33

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

src/structs/PackageStructs.sol

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
/// @title PackageStructs
5+
/// @notice All data structures from EIP-2678 (EthPM v3)
6+
/// @dev Based on https://eips.ethereum.org/EIPS/eip-2678
7+
library PackageStructs {
8+
9+
/// @notice Package Meta Object from EIP-2678
10+
struct PackageMeta {
11+
string[] authors; // Human readable author names
12+
string license; // SPDX format license
13+
string description; // Package description
14+
string[] keywords; // Relevant keywords
15+
string website; // Primary website
16+
string documentation; // Documentation link
17+
string repository; // Source code location
18+
}
19+
20+
/// @notice Compiler Information Object from EIP-2678
21+
struct CompilerInfo {
22+
string name; // Compiler name (e.g., "solc")
23+
string version; // Semver or commit hash (e.g., "0.8.0" or "0.4.8-commit.60cc1668")
24+
bytes settings; // Compiler settings as bytes
25+
}
26+
27+
/// @notice Contract Type from EIP-2678
28+
struct ContractType {
29+
string contractName; // Name from source code (e.g., "Wallet")
30+
bytes abi; // JSON ABI as bytes
31+
bytes bytecode; // Unlinked deployment bytecode
32+
bytes runtimeBytecode; // Unlinked runtime bytecode
33+
string sourceId; // Reference to source file
34+
uint256 compilerIndex; // Index in compilers array
35+
}
36+
37+
/// @notice Contract Instance Object from EIP-2678
38+
struct ContractInstance {
39+
string contractType; // Reference to Contract Type (e.g., "Wallet" or "owned:Owned")
40+
address instanceAddress; // Deployed contract address
41+
bytes32 transaction; // Deployment transaction hash
42+
uint256 blockNumber; // Deployment block number
43+
bytes runtimeBytecode; // Linked runtime bytecode
44+
}
45+
46+
/// @notice Link Reference Object from EIP-2678
47+
struct LinkReference {
48+
uint256[] offsets; // Start positions in bytecode (0-indexed)
49+
uint256 length; // Length in bytes of the reference
50+
string name; // Identifier for linking
51+
}
52+
53+
/// @notice Link Value Object from EIP-2678
54+
struct LinkValue {
55+
uint256[] offsets; // Locations where value was written
56+
string valueType; // "literal" for bytecode literals, "reference" for named references
57+
string value; // 0x-prefixed hex string or contract instance name
58+
}
59+
60+
/// @notice Deployment information per chain from EIP-2678
61+
struct DeploymentInfo {
62+
string chainURI; // BIP122 URI (e.g., blockchain://<chain_id>/block/<block_hash>)
63+
ContractInstance[] instances; // Array of deployed contract instances
64+
}
65+
66+
/// @notice Source file information from EIP-2678
67+
struct SourceInfo {
68+
string sourceId; // Unique identifier for source file
69+
string content; // Source code content or IPFS hash
70+
string license; // SPDX license (overrides package license)
71+
}
72+
}

0 commit comments

Comments
 (0)