Skip to content

Commit b13cd10

Browse files
Merge pull request #126 from ethscriptions-protocol/recator
Big rename and reorg
2 parents 0f47d8d + 3260421 commit b13cd10

28 files changed

+345
-314
lines changed

app/models/ethscription_transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def build_create_calldata
199199

200200
# Encode parameters
201201
params = [
202-
tx_hash_bin, # bytes32 transactionHash
202+
tx_hash_bin, # bytes32 ethscriptionId (L1 tx hash)
203203
content_uri_hash, # bytes32 contentUriHash
204204
owner_bin, # address
205205
raw_content, # bytes content

contracts/script/L2Genesis.s.sol

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import "forge-std/console.sol";
1313
/// @dev Used only during genesis, then replaced with the real Ethscriptions contract
1414
contract GenesisEthscriptions is Ethscriptions {
1515

16-
/// @notice Store a genesis ethscription transaction hash for later event emission
16+
/// @notice Store a genesis ethscription ID for later event emission
1717
/// @dev Internal function only used during genesis setup
18-
/// @param transactionHash The transaction hash to store
19-
function _storePendingGenesisEvent(bytes32 transactionHash) internal {
20-
pendingGenesisEvents.push(transactionHash);
18+
/// @param ethscriptionId The ethscription ID (L1 tx hash) to store
19+
function _storePendingGenesisEvent(bytes32 ethscriptionId) internal {
20+
pendingGenesisEvents.push(ethscriptionId);
2121
}
2222

2323
/// @notice Create an ethscription with all values explicitly set for genesis
@@ -29,7 +29,7 @@ contract GenesisEthscriptions is Ethscriptions {
2929
bytes32 l1BlockHash
3030
) public returns (uint256 tokenId) {
3131
require(creator != address(0), "Invalid creator");
32-
require(ethscriptions[params.transactionHash].creator == address(0), "Ethscription already exists");
32+
require(ethscriptions[params.ethscriptionId].creator == address(0), "Ethscription already exists");
3333

3434
// Check protocol uniqueness using content URI hash
3535
if (firstEthscriptionByContentUri[params.contentUriHash] != bytes32(0)) {
@@ -40,10 +40,10 @@ contract GenesisEthscriptions is Ethscriptions {
4040
bytes32 contentSha = _storeContent(params.content);
4141

4242
// Mark content URI as used by storing this ethscription's tx hash
43-
firstEthscriptionByContentUri[params.contentUriHash] = params.transactionHash;
43+
firstEthscriptionByContentUri[params.contentUriHash] = params.ethscriptionId;
4444

4545
// Set all values including genesis-specific ones
46-
ethscriptions[params.transactionHash] = Ethscription({
46+
ethscriptions[params.ethscriptionId] = Ethscription({
4747
// Fixed-size fields
4848
contentUriHash: params.contentUriHash,
4949
contentSha: contentSha,
@@ -66,8 +66,8 @@ contract GenesisEthscriptions is Ethscriptions {
6666
// Use ethscription number as token ID
6767
tokenId = totalSupply();
6868

69-
// Store the mapping from token ID to transaction hash
70-
tokenIdToTransactionHash[tokenId] = params.transactionHash;
69+
// Store the mapping from token ID to ethscription ID
70+
tokenIdToEthscriptionId[tokenId] = params.ethscriptionId;
7171

7272
// Token count is automatically tracked by enumerable's _update
7373

@@ -82,7 +82,7 @@ contract GenesisEthscriptions is Ethscriptions {
8282
// Store the transaction hash so all events can be emitted later
8383
// The emission logic in _emitPendingGenesisEvents will figure out
8484
// what events to emit based on the ethscription data
85-
_storePendingGenesisEvent(params.transactionHash);
85+
_storePendingGenesisEvent(params.ethscriptionId);
8686

8787
// Skip token handling for genesis
8888
}
@@ -333,7 +333,7 @@ contract L2Genesis is Script {
333333
// Create params struct with parsed data from JSON
334334
// The JSON already has all the properly processed data
335335
Ethscriptions.CreateEthscriptionParams memory params;
336-
params.transactionHash = vm.parseJsonBytes32(json, string.concat(basePath, ".transaction_hash"));
336+
params.ethscriptionId = vm.parseJsonBytes32(json, string.concat(basePath, ".transaction_hash"));
337337
params.contentUriHash = vm.parseJsonBytes32(json, string.concat(basePath, ".content_uri_hash"));
338338
params.initialOwner = initialOwner;
339339
params.content = vm.parseJsonBytes(json, string.concat(basePath, ".content"));

contracts/script/TestTokenUri.s.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ contract TestTokenUri is Script {
1717
// Test case 1: Plain text (should use viewer)
1818
vm.prank(address(0x1111));
1919
eth.createEthscription(Ethscriptions.CreateEthscriptionParams({
20-
transactionHash: keccak256("text1"),
20+
ethscriptionId: keccak256("text1"),
2121
contentUriHash: keccak256("data:text/plain,Hello World!"),
2222
initialOwner: address(0x1111),
2323
content: bytes("Hello World!"),
@@ -29,7 +29,7 @@ contract TestTokenUri is Script {
2929
// Test case 2: JSON content (should use viewer with pretty print)
3030
vm.prank(address(0x2222));
3131
eth.createEthscription(Ethscriptions.CreateEthscriptionParams({
32-
transactionHash: keccak256("json1"),
32+
ethscriptionId: keccak256("json1"),
3333
contentUriHash: keccak256('data:application/json,{"p":"erc-20","op":"mint","tick":"test","amt":"1000"}'),
3434
initialOwner: address(0x2222),
3535
content: bytes('{"p":"erc-20","op":"mint","tick":"test","amt":"1000"}'),
@@ -41,7 +41,7 @@ contract TestTokenUri is Script {
4141
// Test case 3: HTML content (should pass through directly)
4242
vm.prank(address(0x3333));
4343
eth.createEthscription(Ethscriptions.CreateEthscriptionParams({
44-
transactionHash: keccak256("html1"),
44+
ethscriptionId: keccak256("html1"),
4545
contentUriHash: keccak256('data:text/html,<html><body style="background:linear-gradient(45deg,#ff006e,#8338ec);color:white;font-family:monospace;display:flex;align-items:center;justify-content:center;height:100vh;margin:0"><h1>Ethscriptions Rule!</h1></body></html>'),
4646
initialOwner: address(0x3333),
4747
content: bytes('<html><body style="background:linear-gradient(45deg,#ff006e,#8338ec);color:white;font-family:monospace;display:flex;align-items:center;justify-content:center;height:100vh;margin:0"><h1>Ethscriptions Rule!</h1></body></html>'),
@@ -54,7 +54,7 @@ contract TestTokenUri is Script {
5454
bytes memory redPixelPng = Base64.decode("iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAm0lEQVR42mNgGITgPxTTxvBleTo0swBsOK0s+N8aJkczC1AMR7KAKpb8v72xAY5hFsD4lFoCN+j56ZUoliBbSoklGIZjwxRbQAjT1YK7d+82kGUBeuQii5FrAYYrL81NwCpGFQtoEUT/6RoHWAyknQV0S6ZI5RE6Jt8CZIOOHTuGgR9Fq5FkCf19QM3wx5rZKHEtsRZQt5qkhgUAR6cGaUehOD4AAAAASUVORK5CYII=");
5555
vm.prank(address(0x4444));
5656
eth.createEthscription(Ethscriptions.CreateEthscriptionParams({
57-
transactionHash: keccak256("image1"),
57+
ethscriptionId: keccak256("image1"),
5858
contentUriHash: keccak256("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAm0lEQVR42mNgGITgPxTTxvBleTo0swBsOK0s+N8aJkczC1AMR7KAKpb8v72xAY5hFsD4lFoCN+j56ZUoliBbSoklGIZjwxRbQAjT1YK7d+82kGUBeuQii5FrAYYrL81NwCpGFQtoEUT/6RoHWAyknQV0S6ZI5RE6Jt8CZIOOHTuGgR9Fq5FkCf19QM3wx5rZKHEtsRZQt5qkhgUAR6cGaUehOD4AAAAASUVORK5CYII="),
5959
initialOwner: address(0x4444),
6060
content: redPixelPng,
@@ -66,7 +66,7 @@ contract TestTokenUri is Script {
6666
// Test case 5: CSS content (should use viewer)
6767
vm.prank(address(0x5555));
6868
eth.createEthscription(Ethscriptions.CreateEthscriptionParams({
69-
transactionHash: keccak256("css1"),
69+
ethscriptionId: keccak256("css1"),
7070
contentUriHash: keccak256("data:text/css,body { background: #000; color: #0f0; font-family: 'Courier New'; }"),
7171
initialOwner: address(0x5555),
7272
content: bytes("body { background: #000; color: #0f0; font-family: 'Courier New'; }"),
@@ -110,4 +110,4 @@ contract TestTokenUri is Script {
110110

111111
console.log("=== PASTE ANY OF THE ABOVE data: URIs INTO YOUR BROWSER ===");
112112
}
113-
}
113+
}

contracts/src/CollectionsManager.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ contract CollectionsManager is IProtocolHandler {
3636
// Runtime state for a collection (separate from metadata)
3737
struct CollectionState {
3838
address collectionContract;
39-
bytes32 createTxHash;
39+
bytes32 createEthscriptionId;
4040
uint256 currentSize;
4141
bool locked;
4242
}
@@ -135,7 +135,7 @@ contract CollectionsManager is IProtocolHandler {
135135
event CollectionLocked(bytes32 indexed collectionId);
136136

137137
// Mirror success signaling so indexers can detect success without relying on router
138-
event ProtocolHandlerSuccess(bytes32 indexed transactionHash, string protocol);
138+
event ProtocolHandlerSuccess(bytes32 indexed ethscriptionId, string protocol);
139139

140140
modifier onlyEthscriptions() {
141141
require(msg.sender == ethscriptions, "Only Ethscriptions contract");
@@ -169,7 +169,7 @@ contract CollectionsManager is IProtocolHandler {
169169
// Store collection state
170170
collectionState[collectionId] = CollectionState({
171171
collectionContract: collectionContract,
172-
createTxHash: txHash,
172+
createEthscriptionId: txHash,
173173
currentSize: 0,
174174
locked: false
175175
});
@@ -408,7 +408,7 @@ contract CollectionsManager is IProtocolHandler {
408408
/// @notice Handle transfer notification from Ethscriptions contract
409409
/// @dev When an ethscription that's part of a collection is transferred, sync the ERC721
410410
function onTransfer(
411-
bytes32 txHash,
411+
bytes32 ethscriptionId,
412412
address from,
413413
address to
414414
) external override onlyEthscriptions {

0 commit comments

Comments
 (0)