@@ -29,26 +29,28 @@ def self.try_token_parser(content_uri)
2929 params = Erc20FixedDenominationParser . extract ( content_uri )
3030
3131 # Check if extraction succeeded (returns non-default params)
32- if params != TOKEN_DEFAULT_PARAMS
33- {
34- type : :erc20_fixed_denomination ,
35- protocol : 'erc-20-fixed-denomination' ,
36- operation : params [ 0 ] , # 'deploy' or 'mint'
37- params : params ,
38- encoded_params : encode_token_params ( params )
39- }
40- else
41- nil
42- end
32+ return nil if params == TOKEN_DEFAULT_PARAMS
33+
34+ {
35+ type : :erc20_fixed_denomination ,
36+ protocol : 'erc-20-fixed-denomination' ,
37+ operation : params [ 0 ] , # 'deploy' or 'mint'
38+ params : params ,
39+ encoded_params : Erc20FixedDenominationParser . structured_params ( params )
40+ }
4341 end
4442
4543 def self . try_collections_parser ( content_uri , ethscription_id : nil )
4644 # Erc721EthscriptionsCollectionParser returns [''.b, ''.b, ''.b] if no match
47- protocol , operation , encoded_data = Erc721EthscriptionsCollectionParser . extract (
45+ params = Erc721EthscriptionsCollectionParser . extract (
4846 content_uri ,
4947 ethscription_id : ethscription_id
5048 )
5149
50+ return nil if params == COLLECTIONS_DEFAULT_PARAMS
51+
52+ protocol , operation , encoded_data = params
53+
5254 # Check if extraction succeeded
5355 if protocol != '' . b && operation != '' . b
5456 {
@@ -63,34 +65,6 @@ def self.try_collections_parser(content_uri, ethscription_id: nil)
6365 end
6466 end
6567
66- def self . encode_token_params ( params )
67- # Convert token params to format expected by contracts
68- # params format: [op, protocol, tick, val1, val2, val3]
69- op , _protocol , tick , val1 , val2 , val3 = params
70-
71- case op
72- when 'deploy' . b
73- # For deploy: tick, max, lim
74- {
75- op : op ,
76- tick : tick ,
77- max : val1 ,
78- lim : val2 ,
79- amt : 0
80- }
81- when 'mint' . b
82- # For mint: tick, id, amt
83- {
84- op : op ,
85- tick : tick ,
86- id : val1 ,
87- amt : val3
88- }
89- else
90- nil
91- end
92- end
93-
9468 # Get protocol data formatted for L2 calldata
9569 # Returns [protocol, operation, encoded_data] for contract consumption
9670 def self . for_calldata ( content_uri , ethscription_id : nil )
@@ -104,7 +78,7 @@ def self.for_calldata(content_uri, ethscription_id: nil)
10478 protocol = result [ :protocol ] . b
10579 operation = result [ :operation ]
10680 # For tokens, encode the params properly
107- encoded_data = encode_token_data ( result [ :params ] )
81+ encoded_data = Erc20FixedDenominationParser . encode_calldata ( result [ :params ] )
10882 [ protocol , operation , encoded_data ]
10983 elsif result [ :type ] == :erc721_ethscriptions_collection
11084 # Collections protocol - already has encoded data
@@ -115,26 +89,4 @@ def self.for_calldata(content_uri, ethscription_id: nil)
11589 end
11690 end
11791
118- # Encode token params as bytes for contract consumption
119- def self . encode_token_data ( params )
120- # params format: [op, protocol, tick, val1, val2, val3]
121- op , _protocol , tick , val1 , val2 , val3 = params
122-
123- # Encode based on operation type (operation is passed separately now)
124- # Use tuple encoding for struct compatibility with contracts
125- # IMPORTANT: Field order must match ERC20FixedDenominationManager's struct definitions!
126- if op == 'deploy' . b
127- # DeployOperation struct: tick, maxSupply, mintAmount
128- # Our params: tick, max (val1), lim (val2)
129- # So: tick, maxSupply=val1, mintAmount=val2
130- Eth ::Abi . encode ( [ '(string,uint256,uint256)' ] , [ [ tick . b , val1 , val2 ] ] )
131- elsif op == 'mint' . b
132- # MintOperation struct: tick, id, amount
133- # Our params: tick, id (val1), amt (val3)
134- # So: tick, id=val1, amount=val3
135- Eth ::Abi . encode ( [ '(string,uint256,uint256)' ] , [ [ tick . b , val1 , val3 ] ] )
136- else
137- '' . b
138- end
139- end
14092end
0 commit comments