Skip to content

Commit 6bb50f9

Browse files
committed
2.0.0
1 parent bbde983 commit 6bb50f9

File tree

12 files changed

+378
-1010
lines changed

12 files changed

+378
-1010
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,20 @@ Generate an [elm-ethereum](https://github.com/cmditch/elm-ethereum) binding for
33

44
Example usage:
55
`elm-ethereum-generator some-abi.json src/MyContract.elm`
6+
7+
## Changelog
8+
9+
### 2.0.0
10+
11+
- Changed imports from Abi to AbiEncode and AbiDecode
12+
- Removed unsupported types for the time being.
13+
- De-pluralize "ies" in type alias names. Add "y" to end.
14+
Helpful for properly naming data returned from functions with multiple return values (structs/tuples).
15+
- Manually entry of staticByte length required for time being. Need to majorly refactor type parsing.
16+
17+
### 1.1.0
18+
19+
- Change all occurences of Evm to Abi
20+
- Add "Contracts." for generated module name
21+
- De-pluralize "s" in type-alias names.
22+
(Though not handling "ies")

changelog

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

elm-ethereum-generator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: elm-ethereum-generator
2-
version: 1.1.0
2+
version: 2.0.0
33
-- synopsis:
44
-- description:
55
homepage: https://github.com/cmditch/elm-ethereum-generator

examples/ERC20.elm

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module ERC20
1+
module Contracts.ERC20
22
exposing
33
( allowance
44
, allowed
@@ -24,8 +24,15 @@ import Json.Decode as Decode exposing (Decoder)
2424
import Json.Decode.Pipeline exposing (custom, decode)
2525
import Eth.Types exposing (..)
2626
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+
-}
2936

3037

3138
{-| "allowance(address,address)" function
@@ -37,9 +44,9 @@ allowance contractAddress owner spender =
3744
, gas = Nothing
3845
, gasPrice = Nothing
3946
, 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 ]
4148
, nonce = Nothing
42-
, decoder = toElmDecoder Evm.uint
49+
, decoder = toElmDecoder AbiDecode.uint
4350
}
4451

4552

@@ -52,9 +59,9 @@ allowed contractAddress a b =
5259
, gas = Nothing
5360
, gasPrice = Nothing
5461
, 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 ]
5663
, nonce = Nothing
57-
, decoder = toElmDecoder Evm.uint
64+
, decoder = toElmDecoder AbiDecode.uint
5865
}
5966

6067

@@ -67,9 +74,9 @@ approve contractAddress spender value =
6774
, gas = Nothing
6875
, gasPrice = Nothing
6976
, 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 ]
7178
, nonce = Nothing
72-
, decoder = toElmDecoder Evm.bool
79+
, decoder = toElmDecoder AbiDecode.bool
7380
}
7481

7582

@@ -82,9 +89,9 @@ balanceOf contractAddress owner =
8289
, gas = Nothing
8390
, gasPrice = Nothing
8491
, value = Nothing
85-
, data = Just <| Evm.encodeFunctionCall "balanceOf(address)" [ AddressE owner ]
92+
, data = Just <| AbiEncode.functionCall "balanceOf(address)" [ AbiEncode.address owner ]
8693
, nonce = Nothing
87-
, decoder = toElmDecoder Evm.uint
94+
, decoder = toElmDecoder AbiDecode.uint
8895
}
8996

9097

@@ -97,9 +104,9 @@ balances contractAddress a =
97104
, gas = Nothing
98105
, gasPrice = Nothing
99106
, value = Nothing
100-
, data = Just <| Evm.encodeFunctionCall "balances(address)" [ AddressE a ]
107+
, data = Just <| AbiEncode.functionCall "balances(address)" [ AbiEncode.address a ]
101108
, nonce = Nothing
102-
, decoder = toElmDecoder Evm.uint
109+
, decoder = toElmDecoder AbiDecode.uint
103110
}
104111

105112

@@ -112,9 +119,9 @@ decimals contractAddress =
112119
, gas = Nothing
113120
, gasPrice = Nothing
114121
, value = Nothing
115-
, data = Just <| Evm.encodeFunctionCall "decimals()" []
122+
, data = Just <| AbiEncode.functionCall "decimals()" []
116123
, nonce = Nothing
117-
, decoder = toElmDecoder Evm.uint
124+
, decoder = toElmDecoder AbiDecode.uint
118125
}
119126

120127

@@ -127,9 +134,9 @@ name contractAddress =
127134
, gas = Nothing
128135
, gasPrice = Nothing
129136
, value = Nothing
130-
, data = Just <| Evm.encodeFunctionCall "name()" []
137+
, data = Just <| AbiEncode.functionCall "name()" []
131138
, nonce = Nothing
132-
, decoder = toElmDecoder Evm.string
139+
, decoder = toElmDecoder AbiDecode.string
133140
}
134141

135142

@@ -142,9 +149,9 @@ symbol contractAddress =
142149
, gas = Nothing
143150
, gasPrice = Nothing
144151
, value = Nothing
145-
, data = Just <| Evm.encodeFunctionCall "symbol()" []
152+
, data = Just <| AbiEncode.functionCall "symbol()" []
146153
, nonce = Nothing
147-
, decoder = toElmDecoder Evm.string
154+
, decoder = toElmDecoder AbiDecode.string
148155
}
149156

150157

@@ -157,9 +164,9 @@ totalSupply contractAddress =
157164
, gas = Nothing
158165
, gasPrice = Nothing
159166
, value = Nothing
160-
, data = Just <| Evm.encodeFunctionCall "totalSupply()" []
167+
, data = Just <| AbiEncode.functionCall "totalSupply()" []
161168
, nonce = Nothing
162-
, decoder = toElmDecoder Evm.uint
169+
, decoder = toElmDecoder AbiDecode.uint
163170
}
164171

165172

@@ -172,9 +179,9 @@ transfer contractAddress to value =
172179
, gas = Nothing
173180
, gasPrice = Nothing
174181
, 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 ]
176183
, nonce = Nothing
177-
, decoder = toElmDecoder Evm.bool
184+
, decoder = toElmDecoder AbiDecode.bool
178185
}
179186

180187

@@ -187,9 +194,9 @@ transferFrom contractAddress from to value =
187194
, gas = Nothing
188195
, gasPrice = Nothing
189196
, 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 ]
191198
, nonce = Nothing
192-
, decoder = toElmDecoder Evm.bool
199+
, decoder = toElmDecoder AbiDecode.bool
193200
}
194201

195202

@@ -209,18 +216,18 @@ approvalEvent contractAddress owner spender =
209216
, address = contractAddress
210217
, topics =
211218
[ 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
214221
]
215222
}
216223

217224

218225
approvalDecoder : Decoder Approval
219226
approvalDecoder =
220227
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)
224231

225232

226233
{-| "Transfer(address,address,uint256)" event
@@ -239,17 +246,17 @@ transferEvent contractAddress from to =
239246
, address = contractAddress
240247
, topics =
241248
[ 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
244251
]
245252
}
246253

247254

248255
transferDecoder : Decoder Transfer
249256
transferDecoder =
250257
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)
254261

255262

0 commit comments

Comments
 (0)