Skip to content

Commit fb2b911

Browse files
Merge pull request #136 from ethscriptions-protocol/fix_collections
Refactor Protocol Handling and Update Dependencies
2 parents 194c621 + a908067 commit fb2b911

16 files changed

Lines changed: 256 additions & 2332 deletions

Gemfile.lock

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ GIT
1616

1717
GIT
1818
remote: https://github.com/0xfacet/facet_rails_common.git
19-
revision: 3d32c04defdd12c1f93b99d272338a4578895d1c
19+
revision: e733e3877d835f68e8671d12d6ef9c0d24025af4
2020
branch: lenient_base64
2121
specs:
2222
facet_rails_common (0.1.0)
@@ -103,9 +103,9 @@ GEM
103103
airbrake-ruby (6.2.2)
104104
rbtree3 (~> 0.6)
105105
awesome_print (1.9.2)
106-
base64 (0.2.0)
107-
benchmark (0.4.1)
108-
bigdecimal (3.2.3)
106+
base64 (0.3.0)
107+
benchmark (0.5.0)
108+
bigdecimal (3.3.1)
109109
bls12-381 (0.3.0)
110110
h2c (~> 0.2.0)
111111
bootsnap (1.17.0)
@@ -117,7 +117,7 @@ GEM
117117
tzinfo
118118
coderay (1.1.3)
119119
concurrent-ruby (1.3.5)
120-
connection_pool (2.4.1)
120+
connection_pool (2.5.4)
121121
crass (1.0.6)
122122
csv (3.3.5)
123123
date (3.4.1)
@@ -129,8 +129,7 @@ GEM
129129
dotenv-rails (2.8.1)
130130
dotenv (= 2.8.1)
131131
railties (>= 3.2)
132-
drb (2.2.0)
133-
ruby2_keywords
132+
drb (2.2.3)
134133
ecdsa (1.2.0)
135134
erubi (1.12.0)
136135
et-orbi (1.3.0)
@@ -156,7 +155,7 @@ GEM
156155
multi_xml (>= 0.5.2)
157156
httpx (1.6.2)
158157
http-2 (>= 1.0.0)
159-
i18n (1.14.1)
158+
i18n (1.14.7)
160159
concurrent-ruby (~> 1.0)
161160
io-console (0.7.1)
162161
irb (1.15.2)
@@ -183,7 +182,7 @@ GEM
183182
method_source (1.0.0)
184183
mini_mime (1.1.5)
185184
mini_portile2 (2.8.9)
186-
minitest (5.20.0)
185+
minitest (5.26.0)
187186
msgpack (1.7.2)
188187
multi_xml (0.7.2)
189188
bigdecimal (~> 3.1)
@@ -298,7 +297,6 @@ GEM
298297
json-schema (>= 2.2, < 6.0)
299298
railties (>= 5.2, < 8.1)
300299
rspec-core (>= 2.14)
301-
ruby2_keywords (0.0.5)
302300
rubyzip (2.4.1)
303301
scrypt (3.1.0)
304302
ffi-compiler (>= 1.0, < 2.0)
@@ -343,10 +341,10 @@ GEM
343341
thor (>= 1.2.0)
344342
yard-sorbet
345343
thor (1.4.0)
346-
timeout (0.4.1)
344+
timeout (0.4.4)
347345
tzinfo (2.0.6)
348346
concurrent-ruby (~> 1.0)
349-
uri (1.0.3)
347+
uri (1.1.1)
350348
useragent (0.16.11)
351349
webrick (1.8.1)
352350
websocket-driver (0.8.0)

app/models/erc20_fixed_denomination_parser.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,42 @@ def self.extract(content_uri)
4242
# No match - return default
4343
DEFAULT_PARAMS
4444
end
45+
46+
# Returns a hash representation of params that downstream services expect.
47+
def self.structured_params(params)
48+
op, _protocol, tick, val1, val2, val3 = params
49+
50+
case op
51+
when 'deploy'.b
52+
{
53+
op: op,
54+
tick: tick,
55+
max: val1,
56+
lim: val2,
57+
amt: 0
58+
}
59+
when 'mint'.b
60+
{
61+
op: op,
62+
tick: tick,
63+
id: val1,
64+
amt: val3
65+
}
66+
else
67+
nil
68+
end
69+
end
70+
71+
# Encodes params into the ABI tuple required by the manager contract.
72+
def self.encode_calldata(params)
73+
op, _protocol, tick, val1, val2, val3 = params
74+
75+
if op == 'deploy'.b
76+
Eth::Abi.encode(['(string,uint256,uint256)'], [[tick.b, val1, val2]])
77+
elsif op == 'mint'.b
78+
Eth::Abi.encode(['(string,uint256,uint256)'], [[tick.b, val1, val3]])
79+
else
80+
''.b
81+
end
82+
end
4583
end

0 commit comments

Comments
 (0)