Skip to content

Commit 8992c1d

Browse files
Merge pull request #130 from ethscriptions-protocol/rename
Big rename
2 parents a52fa7e + 7c5e457 commit 8992c1d

37 files changed

+585
-770
lines changed

app/models/fixed_fungible_token_params_extractor.rb renamed to app/models/erc20_fixed_denomination_parser.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
# Extracts fixed-fungible token parameters from content URIs using strict regex validation
2-
# Protocol uniqueness is based on exact text matching, so we validate the exact format
3-
class FixedFungibleTokenParamsExtractor
1+
# Extracts fixed-denomination ERC-20 parameters from strict JSON inscriptions.
2+
class Erc20FixedDenominationParser
43
# Constants
54
DEFAULT_PARAMS = [''.b, ''.b, ''.b, 0, 0, 0].freeze
65
UINT256_MAX = 2**256 - 1
76

87
# Exact regex patterns for valid formats
9-
# Protocol must be "erc-20" or "fixed-fungible" (case-sensitive)
8+
# Protocol must be "erc-20" (legacy inscription) or the canonical identifier
109
# Tick must be lowercase letters/numbers, max 28 chars
1110
# Numbers must be positive decimals without leading zeros
12-
PROTOCOL_PATTERN = '(?:erc-20|fixed-fungible)'
11+
PROTOCOL_PATTERN = '(?:erc-20|erc-20-fixed-denomination)'
1312
DEPLOY_REGEX = /\Adata:,\{"p":"#{PROTOCOL_PATTERN}","op":"deploy","tick":"([a-z0-9]{1,28})","max":"(0|[1-9][0-9]*)","lim":"(0|[1-9][0-9]*)"\}\z/
1413
MINT_REGEX = /\Adata:,\{"p":"#{PROTOCOL_PATTERN}","op":"mint","tick":"([a-z0-9]{1,28})","id":"(0|[1-9][0-9]*)","amt":"(0|[1-9][0-9]*)"\}\z/
1514

@@ -25,7 +24,7 @@ def self.extract(content_uri)
2524
# Validate uint256 bounds
2625
return DEFAULT_PARAMS if max > UINT256_MAX || lim > UINT256_MAX
2726

28-
return ['deploy'.b, 'fixed-fungible'.b, tick.b, max, lim, 0]
27+
return ['deploy'.b, 'erc-20-fixed-denomination'.b, tick.b, max, lim, 0]
2928
end
3029

3130
# Try mint format
@@ -37,7 +36,7 @@ def self.extract(content_uri)
3736
# Validate uint256 bounds
3837
return DEFAULT_PARAMS if id > UINT256_MAX || amt > UINT256_MAX
3938

40-
return ['mint'.b, 'fixed-fungible'.b, tick.b, id, 0, amt]
39+
return ['mint'.b, 'erc-20-fixed-denomination'.b, tick.b, id, 0, amt]
4140
end
4241

4342
# No match - return default

app/models/collections_params_extractor.rb renamed to app/models/erc721_ethscriptions_collection_parser.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Strict extractor for Collections protocol with canonical JSON validation
2-
class CollectionsParamsExtractor
1+
# Strict extractor for the ERC-721 Ethscriptions collection protocol with canonical JSON validation
2+
class Erc721EthscriptionsCollectionParser
33
# Default return for invalid input
44
DEFAULT_PARAMS = [''.b, ''.b, ''.b].freeze
55

@@ -114,7 +114,7 @@ def extract(content_uri)
114114
return DEFAULT_PARAMS unless data.is_a?(Hash)
115115

116116
# Check protocol
117-
return DEFAULT_PARAMS unless data['p'] == 'collections'
117+
return DEFAULT_PARAMS unless data['p'] == 'erc-721-ethscriptions-collection'
118118

119119
# Get operation
120120
operation = data['op']
@@ -131,7 +131,7 @@ def extract(content_uri)
131131
# Validate field types and encode
132132
encoded_data = encode_operation(operation, encoding_data, schema)
133133

134-
['collections'.b, operation.b, encoded_data.b]
134+
['erc-721-ethscriptions-collection'.b, operation.b, encoded_data.b]
135135

136136
rescue JSON::ParserError, ValidationError => e
137137
Rails.logger.debug "Collections extraction failed: #{e.message}" if defined?(Rails)

app/models/generic_protocol_extractor.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ def handle_bytes_hint(type_hint, value)
572572
[type_hint, [hex_part.downcase].pack('H*')]
573573
end
574574

575-
# Helper method for fixed-fungible protocol parsing (shared with protocol extractor)
575+
# Helper method for fixed-denomination ERC-20 parsing (shared with protocol extractor)
576576
def self.extract_token_params(content_uri)
577577
# Use the strict regex-based extractor for token protocol
578-
FixedFungibleTokenParamsExtractor.extract(content_uri)
578+
Erc20FixedDenominationParser.extract(content_uri)
579579
end
580580
end

app/models/protocol_extractor.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Unified protocol extractor that delegates to appropriate extractors
22
class ProtocolExtractor
33
# Default return values to check if extraction succeeded
4-
TOKEN_DEFAULT_PARAMS = FixedFungibleTokenParamsExtractor::DEFAULT_PARAMS
5-
COLLECTIONS_DEFAULT_PARAMS = CollectionsParamsExtractor::DEFAULT_PARAMS
4+
TOKEN_DEFAULT_PARAMS = Erc20FixedDenominationParser::DEFAULT_PARAMS
5+
COLLECTIONS_DEFAULT_PARAMS = Erc721EthscriptionsCollectionParser::DEFAULT_PARAMS
66
GENERIC_DEFAULT_PARAMS = GenericProtocolExtractor::DEFAULT_PARAMS
77

88
def self.extract(content_uri)
@@ -45,15 +45,15 @@ def self.extract(content_uri)
4545
private
4646

4747
def self.try_token_extractor(content_uri)
48-
# FixedFungibleTokenParamsExtractor uses strict regex and returns DEFAULT_PARAMS if no match
48+
# Erc20FixedDenominationParser uses strict regex and returns DEFAULT_PARAMS if no match
4949
# This enforces non-ESIP6 and exact JSON formatting implicitly.
50-
params = FixedFungibleTokenParamsExtractor.extract(content_uri)
50+
params = Erc20FixedDenominationParser.extract(content_uri)
5151

5252
# Check if extraction succeeded (returns non-default params)
5353
if params != TOKEN_DEFAULT_PARAMS
5454
{
55-
type: :fixed_fungible,
56-
protocol: 'fixed-fungible',
55+
type: :erc20_fixed_denomination,
56+
protocol: 'erc-20-fixed-denomination',
5757
operation: params[0], # 'deploy' or 'mint'
5858
params: params,
5959
encoded_params: encode_token_params(params)
@@ -64,13 +64,13 @@ def self.try_token_extractor(content_uri)
6464
end
6565

6666
def self.try_collections_extractor(content_uri)
67-
# CollectionsParamsExtractor returns [''.b, ''.b, ''.b] if no match
68-
protocol, operation, encoded_data = CollectionsParamsExtractor.extract(content_uri)
67+
# Erc721EthscriptionsCollectionParser returns [''.b, ''.b, ''.b] if no match
68+
protocol, operation, encoded_data = Erc721EthscriptionsCollectionParser.extract(content_uri)
6969

7070
# Check if extraction succeeded
7171
if protocol != ''.b && operation != ''.b
7272
{
73-
type: :collections,
73+
type: :erc721_ethscriptions_collection,
7474
protocol: protocol,
7575
operation: operation,
7676
params: nil, # Collections doesn't return decoded params
@@ -135,14 +135,14 @@ def self.for_calldata(content_uri)
135135
if result.nil?
136136
# No protocol detected - return empty protocol params
137137
[''.b, ''.b, ''.b]
138-
elsif result[:type] == :fixed_fungible
139-
# Fixed-fungible protocol - return in ABI-ready format
138+
elsif result[:type] == :erc20_fixed_denomination
139+
# Fixed denomination ERC-20 protocol - return in ABI-ready format
140140
protocol = result[:protocol].b
141141
operation = result[:operation]
142142
# For tokens, encode the params properly
143143
encoded_data = encode_token_data(result[:params])
144144
[protocol, operation, encoded_data]
145-
elsif result[:type] == :collections
145+
elsif result[:type] == :erc721_ethscriptions_collection
146146
# Collections protocol - already has encoded data
147147
[result[:protocol], result[:operation], result[:encoded_params]]
148148
else
@@ -158,7 +158,7 @@ def self.encode_token_data(params)
158158

159159
# Encode based on operation type (operation is passed separately now)
160160
# Use tuple encoding for struct compatibility with contracts
161-
# IMPORTANT: Field order must match FixedFungibleProtocolHandler's struct definitions!
161+
# IMPORTANT: Field order must match ERC20FixedDenominationManager's struct definitions!
162162
if op == 'deploy'.b
163163
# DeployOperation struct: tick, maxSupply, mintAmount
164164
# Our params: tick, max (val1), lim (val2)

app/services/eth_block_importer.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,11 @@ def import_single_block(block_number)
383383
ValidationJob.perform_later(block_number, l2_block_hashes)
384384
end
385385

386-
# Removed noisy per-block timing logs
387-
388386
ImportProfiler.stop("import_single_block")
389387

390388
[imported_ethscriptions_blocks, [eth_block]]
391389
end
392390

393-
# Legacy batch import method removed - use import_single_block instead
394-
395391
def import_next_block
396392
block_number = next_block_to_import
397393
import_single_block(block_number)

contracts/script/L2Genesis.s.sol

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,22 @@ contract L2Genesis is Script {
198198

199199
// Wire up implementations for the Ethscriptions predeploys that use proxies
200200
bool isProxiedContract = addr == Predeploys.ETHSCRIPTIONS ||
201-
addr == Predeploys.FIXED_FUNGIBLE_HANDLER ||
201+
addr == Predeploys.ERC20_FIXED_DENOMINATION_MANAGER ||
202202
addr == Predeploys.ETHSCRIPTIONS_PROVER ||
203-
addr == Predeploys.COLLECTIONS_PROTOCOL_HANDLER;
203+
addr == Predeploys.ERC721_ETHSCRIPTIONS_COLLECTION_MANAGER;
204204
if (isProxiedContract) {
205205
address impl = Predeploys.predeployToCodeNamespace(addr);
206206
setImplementation(addr, impl);
207207
}
208208
}
209209

210210
// Set implementation code for non-ETHSCRIPTIONS contracts now
211-
_setImplementationCodeNamed(Predeploys.FIXED_FUNGIBLE_HANDLER, "FixedFungibleProtocolHandler");
212-
_setImplementationCodeNamed(Predeploys.COLLECTIONS_PROTOCOL_HANDLER, "CollectionsProtocolHandler");
211+
_setImplementationCodeNamed(Predeploys.ERC20_FIXED_DENOMINATION_MANAGER, "ERC20FixedDenominationManager");
212+
_setImplementationCodeNamed(Predeploys.ERC721_ETHSCRIPTIONS_COLLECTION_MANAGER, "ERC721EthscriptionsCollectionManager");
213213
_setImplementationCodeNamed(Predeploys.ETHSCRIPTIONS_PROVER, "EthscriptionsProver");
214214
// Templates live directly at their implementation addresses (no proxy wrapping)
215-
_setCodeAt(Predeploys.FIXED_FUNGIBLE_TEMPLATE_IMPLEMENTATION, "FixedFungibleERC20");
216-
_setCodeAt(Predeploys.COLLECTIONS_TEMPLATE_IMPLEMENTATION, "CollectionsERC721");
215+
_setCodeAt(Predeploys.ERC20_FIXED_DENOMINATION_IMPLEMENTATION, "ERC20FixedDenomination");
216+
_setCodeAt(Predeploys.ERC721_ETHSCRIPTIONS_COLLECTION_IMPLEMENTATION, "ERC721EthscriptionsCollection");
217217

218218
// Create genesis Ethscriptions (writes via proxy to proxy storage)
219219
createGenesisEthscriptions();
@@ -226,18 +226,18 @@ contract L2Genesis is Script {
226226
function registerProtocolHandlers() internal {
227227
Ethscriptions ethscriptions = Ethscriptions(Predeploys.ETHSCRIPTIONS);
228228

229-
ethscriptions.registerProtocol("fixed-fungible", Predeploys.FIXED_FUNGIBLE_HANDLER);
230-
console.log("Registered fixed-fungible protocol handler:", Predeploys.FIXED_FUNGIBLE_HANDLER);
229+
ethscriptions.registerProtocol("erc-20-fixed-denomination", Predeploys.ERC20_FIXED_DENOMINATION_MANAGER);
230+
console.log("Registered erc-20-fixed-denomination protocol handler:", Predeploys.ERC20_FIXED_DENOMINATION_MANAGER);
231231

232232
// Check environment variable for collections
233233
// Default to true so forge tests work (they don't go through genesis_generator.rb)
234234
// Production explicitly sets ENABLE_COLLECTIONS=false
235235
bool enableCollections = vm.envOr("ENABLE_COLLECTIONS", true);
236236

237237
if (enableCollections) {
238-
// Register the collections protocol handler for collections operations
239-
ethscriptions.registerProtocol("collections", Predeploys.COLLECTIONS_PROTOCOL_HANDLER);
240-
console.log("Registered collections protocol handler:", Predeploys.COLLECTIONS_PROTOCOL_HANDLER);
238+
// Register the collections protocol handler for ERC-721 Ethscriptions collections
239+
ethscriptions.registerProtocol("erc-721-ethscriptions-collection", Predeploys.ERC721_ETHSCRIPTIONS_COLLECTION_MANAGER);
240+
console.log("Registered erc-721-ethscriptions-collection protocol handler:", Predeploys.ERC721_ETHSCRIPTIONS_COLLECTION_MANAGER);
241241
} else {
242242
console.log("Collections protocol not registered (ENABLE_COLLECTIONS=false)");
243243
}
Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ pragma solidity 0.8.24;
44
import "./ERC20NullOwnerCappedUpgradeable.sol";
55
import "./libraries/Predeploys.sol";
66

7-
/// @title FixedFungibleERC20
8-
/// @notice ERC-20 clone whose balances are controlled by the FixedFungible protocol handler
9-
/// @dev User-initiated transfers/approvals are disabled; only the handler can mutate balances.
10-
contract FixedFungibleERC20 is ERC20NullOwnerCappedUpgradeable {
7+
/// @title ERC20FixedDenomination
8+
/// @notice ERC-20 proxy whose supply is managed in a fixed denomination by the manager contract.
9+
/// @dev User-initiated transfers/approvals are disabled; only the manager can mutate balances.
10+
contract ERC20FixedDenomination is ERC20NullOwnerCappedUpgradeable {
1111

1212
// =============================================================
1313
// CONSTANTS
1414
// =============================================================
1515

16-
/// @notice The FixedFungible protocol handler that controls this token
17-
address public constant protocolHandler = Predeploys.FIXED_FUNGIBLE_HANDLER;
16+
/// @notice The manager contract that controls this token
17+
address public constant manager = Predeploys.ERC20_FIXED_DENOMINATION_MANAGER;
1818

1919
// =============================================================
2020
// STATE VARIABLES
@@ -27,28 +27,23 @@ contract FixedFungibleERC20 is ERC20NullOwnerCappedUpgradeable {
2727
// CUSTOM ERRORS
2828
// =============================================================
2929

30-
error OnlyProtocolHandler();
30+
error OnlyManager();
3131
error TransfersOnlyViaEthscriptions();
3232
error ApprovalsNotAllowed();
3333

3434
// =============================================================
3535
// MODIFIERS
3636
// =============================================================
3737

38-
modifier onlyProtocolHandler() {
39-
if (msg.sender != protocolHandler) revert OnlyProtocolHandler();
38+
modifier onlyManager() {
39+
if (msg.sender != manager) revert OnlyManager();
4040
_;
4141
}
4242

4343
// =============================================================
4444
// EXTERNAL FUNCTIONS
4545
// =============================================================
4646

47-
/// @notice Initialize the ERC20 token
48-
/// @param name_ The token name
49-
/// @param symbol_ The token symbol
50-
/// @param cap_ The maximum supply cap (in 18 decimals)
51-
/// @param deployEthscriptionId_ The ethscription ID that deployed this token
5247
function initialize(
5348
string memory name_,
5449
string memory symbol_,
@@ -60,41 +55,28 @@ contract FixedFungibleERC20 is ERC20NullOwnerCappedUpgradeable {
6055
deployEthscriptionId = deployEthscriptionId_;
6156
}
6257

63-
/// @notice Mint tokens (protocol handler only)
64-
/// @dev Allows minting to address(0) for null ownership
65-
/// @param to The recipient address (can be address(0))
66-
/// @param amount The amount to mint (in 18 decimals)
67-
function mint(address to, uint256 amount) external onlyProtocolHandler {
58+
/// @notice Mint tokens (manager only)
59+
function mint(address to, uint256 amount) external onlyManager {
6860
_mint(to, amount);
6961
}
7062

71-
/// @notice Force transfer tokens (protocol handler only)
72-
/// @dev Allows transfers to/from address(0) for null ownership
73-
/// @param from The sender address (can be address(0))
74-
/// @param to The recipient address (can be address(0))
75-
/// @param amount The amount to transfer (in 18 decimals)
76-
function forceTransfer(address from, address to, uint256 amount) external onlyProtocolHandler {
63+
/// @notice Force transfer tokens (manager only)
64+
function forceTransfer(address from, address to, uint256 amount) external onlyManager {
7765
_update(from, to, amount);
7866
}
7967

8068
// =============================================================
8169
// DISABLED ERC20 FUNCTIONS
8270
// =============================================================
8371

84-
/// @notice User-initiated transfers are disabled
85-
/// @dev All transfers must go through the Ethscriptions NFT
8672
function transfer(address, uint256) public pure override returns (bool) {
8773
revert TransfersOnlyViaEthscriptions();
8874
}
8975

90-
/// @notice User-initiated transfers are disabled
91-
/// @dev All transfers must go through the Ethscriptions NFT
9276
function transferFrom(address, address, uint256) public pure override returns (bool) {
9377
revert TransfersOnlyViaEthscriptions();
9478
}
9579

96-
/// @notice Approvals are disabled
97-
/// @dev All transfers are controlled by the FixedFungibleProtocolHandler
9880
function approve(address, uint256) public pure override returns (bool) {
9981
revert ApprovalsNotAllowed();
10082
}

0 commit comments

Comments
 (0)