1
- module ERC20
1
+ module Contracts. ERC20
2
2
exposing
3
3
( allowance
4
4
, allowed
@@ -24,8 +24,15 @@ import Json.Decode as Decode exposing (Decoder)
24
24
import Json.Decode.Pipeline exposing (custom , decode )
25
25
import Eth.Types exposing (..)
26
26
import Eth.Utils as U
27
- import Evm.Decode as Evm exposing (evmDecode , andMap , toElmDecoder , topic , data )
28
- import Evm.Encode as Evm exposing (Encoding (..) , evmEncode )
27
+ import Abi.Decode as AbiDecode exposing (abiDecode , andMap , toElmDecoder , topic , data )
28
+ import Abi.Encode as AbiEncode exposing (Encoding (..) , abiEncode )
29
+
30
+
31
+ {-
32
+
33
+ This file was generated by https://github.com/cmditch/elm-ethereum-generator
34
+
35
+ -}
29
36
30
37
31
38
{- | "allowance(address,address)" function
@@ -37,9 +44,9 @@ allowance contractAddress owner spender =
37
44
, gas = Nothing
38
45
, gasPrice = Nothing
39
46
, value = Nothing
40
- , data = Just <| Evm . encodeFunctionCall " allowance(address,address)" [ AddressE owner, AddressE spender ]
47
+ , data = Just <| AbiEncode . functionCall " allowance(address,address)" [ AbiEncode . address owner, AbiEncode . address spender ]
41
48
, nonce = Nothing
42
- , decoder = toElmDecoder Evm . uint
49
+ , decoder = toElmDecoder AbiDecode . uint
43
50
}
44
51
45
52
@@ -52,9 +59,9 @@ allowed contractAddress a b =
52
59
, gas = Nothing
53
60
, gasPrice = Nothing
54
61
, value = Nothing
55
- , data = Just <| Evm . encodeFunctionCall " allowed(address,address)" [ AddressE a, AddressE b ]
62
+ , data = Just <| AbiEncode . functionCall " allowed(address,address)" [ AbiEncode . address a, AbiEncode . address b ]
56
63
, nonce = Nothing
57
- , decoder = toElmDecoder Evm . uint
64
+ , decoder = toElmDecoder AbiDecode . uint
58
65
}
59
66
60
67
@@ -67,9 +74,9 @@ approve contractAddress spender value =
67
74
, gas = Nothing
68
75
, gasPrice = Nothing
69
76
, value = Nothing
70
- , data = Just <| Evm . encodeFunctionCall " approve(address,uint256)" [ AddressE spender, UintE value ]
77
+ , data = Just <| AbiEncode . functionCall " approve(address,uint256)" [ AbiEncode . address spender, AbiEncode . uint value ]
71
78
, nonce = Nothing
72
- , decoder = toElmDecoder Evm . bool
79
+ , decoder = toElmDecoder AbiDecode . bool
73
80
}
74
81
75
82
@@ -82,9 +89,9 @@ balanceOf contractAddress owner =
82
89
, gas = Nothing
83
90
, gasPrice = Nothing
84
91
, value = Nothing
85
- , data = Just <| Evm . encodeFunctionCall " balanceOf(address)" [ AddressE owner ]
92
+ , data = Just <| AbiEncode . functionCall " balanceOf(address)" [ AbiEncode . address owner ]
86
93
, nonce = Nothing
87
- , decoder = toElmDecoder Evm . uint
94
+ , decoder = toElmDecoder AbiDecode . uint
88
95
}
89
96
90
97
@@ -97,9 +104,9 @@ balances contractAddress a =
97
104
, gas = Nothing
98
105
, gasPrice = Nothing
99
106
, value = Nothing
100
- , data = Just <| Evm . encodeFunctionCall " balances(address)" [ AddressE a ]
107
+ , data = Just <| AbiEncode . functionCall " balances(address)" [ AbiEncode . address a ]
101
108
, nonce = Nothing
102
- , decoder = toElmDecoder Evm . uint
109
+ , decoder = toElmDecoder AbiDecode . uint
103
110
}
104
111
105
112
@@ -112,9 +119,9 @@ decimals contractAddress =
112
119
, gas = Nothing
113
120
, gasPrice = Nothing
114
121
, value = Nothing
115
- , data = Just <| Evm . encodeFunctionCall " decimals()" []
122
+ , data = Just <| AbiEncode . functionCall " decimals()" []
116
123
, nonce = Nothing
117
- , decoder = toElmDecoder Evm . uint
124
+ , decoder = toElmDecoder AbiDecode . uint
118
125
}
119
126
120
127
@@ -127,9 +134,9 @@ name contractAddress =
127
134
, gas = Nothing
128
135
, gasPrice = Nothing
129
136
, value = Nothing
130
- , data = Just <| Evm . encodeFunctionCall " name()" []
137
+ , data = Just <| AbiEncode . functionCall " name()" []
131
138
, nonce = Nothing
132
- , decoder = toElmDecoder Evm . string
139
+ , decoder = toElmDecoder AbiDecode . string
133
140
}
134
141
135
142
@@ -142,9 +149,9 @@ symbol contractAddress =
142
149
, gas = Nothing
143
150
, gasPrice = Nothing
144
151
, value = Nothing
145
- , data = Just <| Evm . encodeFunctionCall " symbol()" []
152
+ , data = Just <| AbiEncode . functionCall " symbol()" []
146
153
, nonce = Nothing
147
- , decoder = toElmDecoder Evm . string
154
+ , decoder = toElmDecoder AbiDecode . string
148
155
}
149
156
150
157
@@ -157,9 +164,9 @@ totalSupply contractAddress =
157
164
, gas = Nothing
158
165
, gasPrice = Nothing
159
166
, value = Nothing
160
- , data = Just <| Evm . encodeFunctionCall " totalSupply()" []
167
+ , data = Just <| AbiEncode . functionCall " totalSupply()" []
161
168
, nonce = Nothing
162
- , decoder = toElmDecoder Evm . uint
169
+ , decoder = toElmDecoder AbiDecode . uint
163
170
}
164
171
165
172
@@ -172,9 +179,9 @@ transfer contractAddress to value =
172
179
, gas = Nothing
173
180
, gasPrice = Nothing
174
181
, value = Nothing
175
- , data = Just <| Evm . encodeFunctionCall " transfer(address,uint256)" [ AddressE to, UintE value ]
182
+ , data = Just <| AbiEncode . functionCall " transfer(address,uint256)" [ AbiEncode . address to, AbiEncode . uint value ]
176
183
, nonce = Nothing
177
- , decoder = toElmDecoder Evm . bool
184
+ , decoder = toElmDecoder AbiDecode . bool
178
185
}
179
186
180
187
@@ -187,9 +194,9 @@ transferFrom contractAddress from to value =
187
194
, gas = Nothing
188
195
, gasPrice = Nothing
189
196
, value = Nothing
190
- , data = Just <| Evm . encodeFunctionCall " transferFrom(address,address,uint256)" [ AddressE from, AddressE to, UintE value ]
197
+ , data = Just <| AbiEncode . functionCall " transferFrom(address,address,uint256)" [ AbiEncode . address from, AbiEncode . address to, AbiEncode . uint value ]
191
198
, nonce = Nothing
192
- , decoder = toElmDecoder Evm . bool
199
+ , decoder = toElmDecoder AbiDecode . bool
193
200
}
194
201
195
202
@@ -209,18 +216,18 @@ approvalEvent contractAddress owner spender =
209
216
, address = contractAddress
210
217
, topics =
211
218
[ Just <| U . keccak256 " Approval(address,address,uint256)"
212
- , Maybe . map ( evmEncode << AddressE ) owner
213
- , Maybe . map ( evmEncode << AddressE ) spender
219
+ , Maybe . map ( abiEncode << AbiEncode . address ) owner
220
+ , Maybe . map ( abiEncode << AbiEncode . address ) spender
214
221
]
215
222
}
216
223
217
224
218
225
approvalDecoder : Decoder Approval
219
226
approvalDecoder =
220
227
decode Approval
221
- |> custom ( topic 1 Evm . address)
222
- |> custom ( topic 2 Evm . address)
223
- |> custom ( data 0 Evm . uint)
228
+ |> custom ( topic 1 AbiDecode . address)
229
+ |> custom ( topic 2 AbiDecode . address)
230
+ |> custom ( data 0 AbiDecode . uint)
224
231
225
232
226
233
{- | "Transfer(address,address,uint256)" event
@@ -239,17 +246,17 @@ transferEvent contractAddress from to =
239
246
, address = contractAddress
240
247
, topics =
241
248
[ Just <| U . keccak256 " Transfer(address,address,uint256)"
242
- , Maybe . map ( evmEncode << AddressE ) from
243
- , Maybe . map ( evmEncode << AddressE ) to
249
+ , Maybe . map ( abiEncode << AbiEncode . address ) from
250
+ , Maybe . map ( abiEncode << AbiEncode . address ) to
244
251
]
245
252
}
246
253
247
254
248
255
transferDecoder : Decoder Transfer
249
256
transferDecoder =
250
257
decode Transfer
251
- |> custom ( topic 1 Evm . address)
252
- |> custom ( topic 2 Evm . address)
253
- |> custom ( data 0 Evm . uint)
258
+ |> custom ( topic 1 AbiDecode . address)
259
+ |> custom ( topic 2 AbiDecode . address)
260
+ |> custom ( data 0 AbiDecode . uint)
254
261
255
262
0 commit comments