Skip to content

Commit fe5c2b5

Browse files
committed
Cleanup
1 parent 3be3820 commit fe5c2b5

File tree

4 files changed

+60
-189
lines changed

4 files changed

+60
-189
lines changed

app/models/eth_transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class EthTransaction < T::Struct
33

44
# ESIP event signatures for detecting Ethscription events
55
def self.event_signature(event_name)
6-
"0x" + Digest::Keccak256.hexdigest(event_name)
6+
'0x' + Eth::Util.keccak256(event_name).unpack1('H*')
77
end
88

99
CreateEthscriptionEventSig = event_signature("ethscriptions_protocol_CreateEthscription(address,string)")
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'json'
4+
require 'digest'
5+
require 'base64'
6+
7+
# Read the existing genesis JSON file
8+
json_path = File.join(File.dirname(__FILE__), 'genesisEthscriptions.json')
9+
data = JSON.parse(File.read(json_path))
10+
11+
# Process each ethscription
12+
data['ethscriptions'].each do |ethscription|
13+
content_uri = ethscription['content_uri']
14+
15+
# Calculate content URI hash (as hex string with 0x prefix for JSON)
16+
content_uri_hash = '0x' + Digest::SHA256.hexdigest(content_uri)
17+
ethscription['content_uri_hash'] = content_uri_hash
18+
19+
# Parse the data URI
20+
if content_uri.start_with?('data:')
21+
# Remove 'data:' prefix
22+
uri_without_prefix = content_uri[5..-1]
23+
24+
# Find the comma that separates metadata from data
25+
comma_index = uri_without_prefix.index(',')
26+
27+
if comma_index
28+
metadata = uri_without_prefix[0...comma_index]
29+
data_part = uri_without_prefix[(comma_index + 1)..-1]
30+
31+
# Check if it's base64 encoded
32+
is_base64 = metadata.include?(';base64')
33+
34+
# Get the content
35+
if is_base64
36+
# Decode from base64 for storage
37+
content = Base64.decode64(data_part)
38+
# Store as hex string for JSON (with 0x prefix)
39+
ethscription['content'] = '0x' + content.unpack1('H*')
40+
else
41+
# For non-base64, keep the original encoded form (preserves percent-encoding)
42+
# Store as hex string for JSON (with 0x prefix)
43+
ethscription['content'] = '0x' + data_part.unpack('H*')[0]
44+
end
45+
else
46+
# Invalid data URI format, store empty content
47+
ethscription['content'] = '0x'
48+
end
49+
else
50+
# Not a data URI, store the whole thing as content
51+
ethscription['content'] = '0x' + content_uri.unpack('H*')[0]
52+
end
53+
end
54+
55+
# Write the updated JSON back
56+
File.write(json_path, JSON.pretty_generate(data))
57+
58+
puts "Processed #{data['ethscriptions'].length} ethscriptions"
59+
puts "Added content_uri_hash and content fields"

lib/digest/keccak256.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

test_token_validation_regex.rb

Lines changed: 0 additions & 179 deletions
This file was deleted.

0 commit comments

Comments
 (0)