@@ -18,190 +18,201 @@ module Contracts.ERC20 exposing
18
18
, transferFrom
19
19
)
20
20
21
- import Abi.Decode as AbiDecode exposing (abiDecode , andMap , data , toElmDecoder , topic )
22
- import Abi.Encode as AbiEncode exposing (Encoding (..) , abiEncode )
21
+ import Eth. Abi.Decode as D exposing (abiDecode , andMap , data , toElmDecoder , topic )
22
+ import Eth. Abi.Encode as E exposing (Encoding (..) , abiEncode )
23
23
import BigInt exposing (BigInt )
24
24
import Eth.Types exposing (..)
25
25
import Eth.Utils as U
26
- import Json.Decode as Decode exposing (Decoder )
27
- import Json.Decode.Pipeline exposing (custom , decode )
26
+ import Json.Decode as Decode exposing (Decoder , succeed )
27
+ import Json.Decode.Pipeline exposing (custom )
28
28
29
29
30
30
31
31
{-
32
32
33
- This file was generated by https://github.com/cmditch/elm-ethereum-generator
33
+ This file was generated by https://github.com/cmditch/elm-ethereum-generator v3.0.0
34
+ Compatible with elm-ethereum v4.0.0
34
35
35
36
-}
37
+ -- allowance(address,address) function
36
38
37
39
38
- {- | "allowance(address,address)" function
39
- -}
40
40
allowance : Address -> Address -> Address -> Call BigInt
41
- allowance contractAddress owner spender =
41
+ allowance contractAddress owner_ spender_ =
42
42
{ to = Just contractAddress
43
43
, from = Nothing
44
44
, gas = Nothing
45
45
, gasPrice = Nothing
46
46
, value = Nothing
47
- , data = Just <| AbiEncode . functionCall " allowance(address,address) " [ AbiEncode . address owner , AbiEncode . address spender ]
47
+ , data = Just <| E . functionCall " dd62ed3e " [ E . address owner_ , E . address spender_ ]
48
48
, nonce = Nothing
49
- , decoder = toElmDecoder AbiDecode . uint
49
+ , decoder = toElmDecoder D . uint
50
50
}
51
51
52
52
53
- {- | "allowed(address,address)" function
54
- -}
53
+ -- allowed(address,address) function
54
+
55
+
55
56
allowed : Address -> Address -> Address -> Call BigInt
56
- allowed contractAddress a b =
57
+ allowed contractAddress a_ b_ =
57
58
{ to = Just contractAddress
58
59
, from = Nothing
59
60
, gas = Nothing
60
61
, gasPrice = Nothing
61
62
, value = Nothing
62
- , data = Just <| AbiEncode . functionCall " allowed(address,address) " [ AbiEncode . address a , AbiEncode . address b ]
63
+ , data = Just <| E . functionCall " 5c658165 " [ E . address a_ , E . address b_ ]
63
64
, nonce = Nothing
64
- , decoder = toElmDecoder AbiDecode . uint
65
+ , decoder = toElmDecoder D . uint
65
66
}
66
67
67
68
68
- {- | "approve(address,uint256)" function
69
- -}
69
+ -- approve(address,uint256) function
70
+
71
+
70
72
approve : Address -> Address -> BigInt -> Call Bool
71
- approve contractAddress spender value =
73
+ approve contractAddress spender_ value_ =
72
74
{ to = Just contractAddress
73
75
, from = Nothing
74
76
, gas = Nothing
75
77
, gasPrice = Nothing
76
78
, value = Nothing
77
- , data = Just <| AbiEncode . functionCall " approve(address,uint256) " [ AbiEncode . address spender , AbiEncode . uint value ]
79
+ , data = Just <| E . functionCall " 095ea7b3 " [ E . address spender_ , E . uint value_ ]
78
80
, nonce = Nothing
79
- , decoder = toElmDecoder AbiDecode . bool
81
+ , decoder = toElmDecoder D . bool
80
82
}
81
83
82
84
83
- {- | "balanceOf(address)" function
84
- -}
85
+ -- balanceOf(address) function
86
+
87
+
85
88
balanceOf : Address -> Address -> Call BigInt
86
- balanceOf contractAddress owner =
89
+ balanceOf contractAddress owner_ =
87
90
{ to = Just contractAddress
88
91
, from = Nothing
89
92
, gas = Nothing
90
93
, gasPrice = Nothing
91
94
, value = Nothing
92
- , data = Just <| AbiEncode . functionCall " balanceOf(address) " [ AbiEncode . address owner ]
95
+ , data = Just <| E . functionCall " 70a08231 " [ E . address owner_ ]
93
96
, nonce = Nothing
94
- , decoder = toElmDecoder AbiDecode . uint
97
+ , decoder = toElmDecoder D . uint
95
98
}
96
99
97
100
98
- {- | "balances(address)" function
99
- -}
101
+ -- balances(address) function
102
+
103
+
100
104
balances : Address -> Address -> Call BigInt
101
- balances contractAddress a =
105
+ balances contractAddress a_ =
102
106
{ to = Just contractAddress
103
107
, from = Nothing
104
108
, gas = Nothing
105
109
, gasPrice = Nothing
106
110
, value = Nothing
107
- , data = Just <| AbiEncode . functionCall " balances(address) " [ AbiEncode . address a ]
111
+ , data = Just <| E . functionCall " 27e235e3 " [ E . address a_ ]
108
112
, nonce = Nothing
109
- , decoder = toElmDecoder AbiDecode . uint
113
+ , decoder = toElmDecoder D . uint
110
114
}
111
115
112
116
113
- {- | "decimals()" function
114
- -}
117
+ -- decimals() function
118
+
119
+
115
120
decimals : Address -> Call BigInt
116
121
decimals contractAddress =
117
122
{ to = Just contractAddress
118
123
, from = Nothing
119
124
, gas = Nothing
120
125
, gasPrice = Nothing
121
126
, value = Nothing
122
- , data = Just <| AbiEncode . functionCall " decimals() " []
127
+ , data = Just <| E . functionCall " 313ce567 " []
123
128
, nonce = Nothing
124
- , decoder = toElmDecoder AbiDecode . uint
129
+ , decoder = toElmDecoder D . uint
125
130
}
126
131
127
132
128
- {- | "name()" function
129
- -}
133
+ -- name() function
134
+
135
+
130
136
name : Address -> Call String
131
137
name contractAddress =
132
138
{ to = Just contractAddress
133
139
, from = Nothing
134
140
, gas = Nothing
135
141
, gasPrice = Nothing
136
142
, value = Nothing
137
- , data = Just <| AbiEncode . functionCall " name() " []
143
+ , data = Just <| E . functionCall " 06fdde03 " []
138
144
, nonce = Nothing
139
- , decoder = toElmDecoder AbiDecode . string
145
+ , decoder = toElmDecoder D . string
140
146
}
141
147
142
148
143
- {- | "symbol()" function
144
- -}
149
+ -- symbol() function
150
+
151
+
145
152
symbol : Address -> Call String
146
153
symbol contractAddress =
147
154
{ to = Just contractAddress
148
155
, from = Nothing
149
156
, gas = Nothing
150
157
, gasPrice = Nothing
151
158
, value = Nothing
152
- , data = Just <| AbiEncode . functionCall " symbol() " []
159
+ , data = Just <| E . functionCall " 95d89b41 " []
153
160
, nonce = Nothing
154
- , decoder = toElmDecoder AbiDecode . string
161
+ , decoder = toElmDecoder D . string
155
162
}
156
163
157
164
158
- {- | "totalSupply()" function
159
- -}
165
+ -- totalSupply() function
166
+
167
+
160
168
totalSupply : Address -> Call BigInt
161
169
totalSupply contractAddress =
162
170
{ to = Just contractAddress
163
171
, from = Nothing
164
172
, gas = Nothing
165
173
, gasPrice = Nothing
166
174
, value = Nothing
167
- , data = Just <| AbiEncode . functionCall " totalSupply() " []
175
+ , data = Just <| E . functionCall " 18160ddd " []
168
176
, nonce = Nothing
169
- , decoder = toElmDecoder AbiDecode . uint
177
+ , decoder = toElmDecoder D . uint
170
178
}
171
179
172
180
173
- {- | "transfer(address,uint256)" function
174
- -}
181
+ -- transfer(address,uint256) function
182
+
183
+
175
184
transfer : Address -> Address -> BigInt -> Call Bool
176
- transfer contractAddress to value =
185
+ transfer contractAddress to_ value_ =
177
186
{ to = Just contractAddress
178
187
, from = Nothing
179
188
, gas = Nothing
180
189
, gasPrice = Nothing
181
190
, value = Nothing
182
- , data = Just <| AbiEncode . functionCall " transfer(address,uint256) " [ AbiEncode . address to , AbiEncode . uint value ]
191
+ , data = Just <| E . functionCall " a9059cbb " [ E . address to_ , E . uint value_ ]
183
192
, nonce = Nothing
184
- , decoder = toElmDecoder AbiDecode . bool
193
+ , decoder = toElmDecoder D . bool
185
194
}
186
195
187
196
188
- {- | "transferFrom(address,address,uint256)" function
189
- -}
197
+ -- transferFrom(address,address,uint256) function
198
+
199
+
190
200
transferFrom : Address -> Address -> Address -> BigInt -> Call Bool
191
- transferFrom contractAddress from to value =
201
+ transferFrom contractAddress from_ to_ value_ =
192
202
{ to = Just contractAddress
193
203
, from = Nothing
194
204
, gas = Nothing
195
205
, gasPrice = Nothing
196
206
, value = Nothing
197
- , data = Just <| AbiEncode . functionCall " transferFrom(address,address,uint256) " [ AbiEncode . address from , AbiEncode . address to , AbiEncode . uint value ]
207
+ , data = Just <| E . functionCall " 23b872dd " [ E . address from_ , E . address to_ , E . uint value_ ]
198
208
, nonce = Nothing
199
- , decoder = toElmDecoder AbiDecode . bool
209
+ , decoder = toElmDecoder D . bool
200
210
}
201
211
202
212
203
- {- | "Approval(address,address,uint256)" event
204
- -}
213
+ -- Approval(address,address,uint256) event
214
+
215
+
205
216
type alias Approval =
206
217
{ owner : Address
207
218
, spender : Address
@@ -210,28 +221,29 @@ type alias Approval =
210
221
211
222
212
223
approvalEvent : Address -> Maybe Address -> Maybe Address -> LogFilter
213
- approvalEvent contractAddress owner spender =
224
+ approvalEvent contractAddress owner_ spender_ =
214
225
{ fromBlock = LatestBlock
215
226
, toBlock = LatestBlock
216
227
, address = contractAddress
217
- , topics =
218
- [ Just <| U . keccak256 " Approval(address,address,uint256) "
219
- , Maybe . map ( abiEncode << AbiEncode . address) owner
220
- , Maybe . map ( abiEncode << AbiEncode . address) spender
228
+ , topics =
229
+ [ Just <| U . unsafeToHex " 8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925 "
230
+ , Maybe . map ( abiEncode << E . address) owner_
231
+ , Maybe . map ( abiEncode << E . address) spender_
221
232
]
222
233
}
223
234
224
235
225
236
approvalDecoder : Decoder Approval
226
- approvalDecoder =
227
- decode Approval
228
- |> custom ( topic 1 AbiDecode . address)
229
- |> custom ( topic 2 AbiDecode . address)
230
- |> custom ( data 0 AbiDecode . uint)
237
+ approvalDecoder =
238
+ Decode . succeed Approval
239
+ |> custom ( topic 1 D . address)
240
+ |> custom ( topic 2 D . address)
241
+ |> custom ( data 0 D . uint)
242
+
243
+
244
+ -- Transfer(address,address,uint256) event
231
245
232
246
233
- {- | "Transfer(address,address,uint256)" event
234
- -}
235
247
type alias Transfer =
236
248
{ from : Address
237
249
, to : Address
@@ -240,21 +252,23 @@ type alias Transfer =
240
252
241
253
242
254
transferEvent : Address -> Maybe Address -> Maybe Address -> LogFilter
243
- transferEvent contractAddress from to =
255
+ transferEvent contractAddress from_ to_ =
244
256
{ fromBlock = LatestBlock
245
257
, toBlock = LatestBlock
246
258
, address = contractAddress
247
- , topics =
248
- [ Just <| U . keccak256 " Transfer(address,address,uint256) "
249
- , Maybe . map ( abiEncode << AbiEncode . address) from
250
- , Maybe . map ( abiEncode << AbiEncode . address) to
259
+ , topics =
260
+ [ Just <| U . unsafeToHex " ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef "
261
+ , Maybe . map ( abiEncode << E . address) from_
262
+ , Maybe . map ( abiEncode << E . address) to_
251
263
]
252
264
}
253
265
254
266
255
267
transferDecoder : Decoder Transfer
256
- transferDecoder =
257
- decode Transfer
258
- |> custom ( topic 1 AbiDecode . address)
259
- |> custom ( topic 2 AbiDecode . address)
260
- |> custom ( data 0 AbiDecode . uint)
268
+ transferDecoder =
269
+ Decode . succeed Transfer
270
+ |> custom ( topic 1 D . address)
271
+ |> custom ( topic 2 D . address)
272
+ |> custom ( data 0 D . uint)
273
+
274
+
0 commit comments