Skip to content

Commit 76710a3

Browse files
committed
Refactor ERC721 Ethscriptions Collection Parser for Address Handling
- Updated the `Erc721EthscriptionsCollectionParser` to convert `from_address` to a hexadecimal format using `to_hex` method for consistency. - Modified test cases to utilize `Address20.from_hex` for mock transactions, ensuring proper address handling in the context of collection creation. - Adjusted ABI encoding in tests to include the address type, reflecting the updated structure for collection operations.
1 parent 7e55b6c commit 76710a3

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

app/models/erc721_ethscriptions_collection_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def build_metadata_object(meta, eth_transaction: nil)
393393
result['initial_owner'] = to_address_hex(meta['initial_owner'])
394394
elsif eth_transaction && eth_transaction.respond_to?(:from_address)
395395
# Use the transaction sender as the actual owner
396-
result['initial_owner'] = to_address_hex(eth_transaction.from_address)
396+
result['initial_owner'] = eth_transaction.from_address.to_hex
397397
else
398398
# No transaction context - this shouldn't happen in production
399399
# For import, we always have the transaction

spec/integration/ethscriptions_creation_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
end
7979

8080
it "accepts GZIP input post-ESIP-7" do
81-
compressed_data_uri = Zlib.gzip("data:text/plain;charset=utf-8,Hello World") # Placeholder for GZIP data
81+
compressed_data_uri = Zlib.gzip("data:text/plain;charset=utf-8,Hello Worldaaa") # Placeholder for GZIP data
8282

8383
expect_ethscription_success(
8484
create_input(

spec/models/erc721_collections_import_fallback_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
it 'builds create_collection_and_add_self for the leader via import fallback' do
6262
# Create a mock eth_transaction with from_address
63-
mock_tx = double('eth_transaction', from_address: '0x0000000000000000000000000000000000000001')
63+
mock_tx = double('eth_transaction', from_address: Address20.from_hex('0x0000000000000000000000000000000000000001'))
6464

6565
protocol, operation, encoded = ProtocolParser.for_calldata(
6666
'data:,{}',
@@ -71,7 +71,7 @@
7171
expect(operation).to eq('create_collection_and_add_self'.b)
7272

7373
decoded = Eth::Abi.decode([
74-
'((string,string,uint256,string,string,string,string,string,string,string,bytes32),(bytes32,uint256,string,string,string,(string,string)[],bytes32[]))'
74+
'((string,string,uint256,string,string,string,string,string,string,string,bytes32,address),(bytes32,uint256,string,string,string,(string,string)[],bytes32[]))'
7575
], encoded)[0]
7676

7777
metadata = decoded[0]
@@ -150,7 +150,7 @@
150150
specific_id = '0x05aac415994e0e01e66c4970133a51a4cdcea1f3a967743b87e6eb08f2f4d9f9'
151151

152152
# Create a mock eth_transaction with from_address
153-
mock_tx = double('eth_transaction', from_address: '0x0000000000000000000000000000000000000001')
153+
mock_tx = double('eth_transaction', from_address: Address20.from_hex('0x0000000000000000000000000000000000000001'))
154154

155155
protocol, operation, encoded = ProtocolParser.for_calldata(
156156
'data:,{}',
@@ -162,7 +162,7 @@
162162

163163
# Decode to verify it's properly formed
164164
decoded = Eth::Abi.decode([
165-
'((string,string,uint256,string,string,string,string,string,string,string,bytes32),(bytes32,uint256,string,string,string,(string,string)[],bytes32[]))'
165+
'((string,string,uint256,string,string,string,string,string,string,string,bytes32,address),(bytes32,uint256,string,string,string,(string,string)[],bytes32[]))'
166166
], encoded)[0]
167167

168168
metadata = decoded[0]

spec/models/erc721_ethscriptions_collection_parser_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
# Decode and verify
107107
decoded = Eth::Abi.decode(
108-
['(string,string,uint256,string,string,string,string,string,string,string,bytes32)'],
108+
['(string,string,uint256,string,string,string,string,string,string,string,bytes32,address)'],
109109
result[2]
110110
)[0]
111111

@@ -130,7 +130,7 @@
130130
expect(result[1]).to eq('create_collection'.b)
131131

132132
decoded = Eth::Abi.decode(
133-
['(string,string,uint256,string,string,string,string,string,string,string,bytes32)'],
133+
['(string,string,uint256,string,string,string,string,string,string,string,bytes32,address)'],
134134
result[2]
135135
)[0]
136136

@@ -164,7 +164,7 @@
164164
expect(result[1]).to eq('create_collection'.b)
165165

166166
decoded = Eth::Abi.decode(
167-
['(string,string,uint256,string,string,string,string,string,string,string,bytes32)'],
167+
['(string,string,uint256,string,string,string,string,string,string,string,bytes32,address)'],
168168
result[2]
169169
)[0]
170170

0 commit comments

Comments
 (0)