Skip to content

Commit f2e2d15

Browse files
committed
Update bindings & Makefile to apply bugfixes from pyabigen v0.2.8
1 parent 6a629d9 commit f2e2d15

File tree

14 files changed

+218
-186
lines changed

14 files changed

+218
-186
lines changed

Makefile

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
VERSION := $(shell cat AUTONITY_VERSION)
22
AUTONITY := build/autonity
33
ABIDIR := $(AUTONITY)/params/generated
4+
SRCDIR := $(AUTONITY)/autonity/solidity/contracts
45
OUTDIR := autonity/contracts
5-
ABIGEN = hatch run generate:pyabigen \
6-
--srcdir $(AUTONITY)/autonity/solidity/contracts \
7-
--version $(VERSION) \
8-
--userdoc $(word 2,$(1)) \
9-
--devdoc $(word 3,$(1)) \
10-
$(word 1,$(1))
6+
7+
abigen = hatch run generate:pyabigen \
8+
--version $(VERSION) \
9+
--src $(word 1,$(1)) \
10+
--devdoc $(word 2,$(1)) \
11+
--userdoc $(word 3,$(1)) \
12+
$(word 4,$(1))
13+
gentargets = $(shell find $(SRCDIR) -name $(1).sol) $(addprefix $(ABIDIR)/$(1),.docdev .docuser .abi)
1114

1215
all: $(OUTDIR)/accountability.py \
1316
$(OUTDIR)/acu.py \
@@ -21,38 +24,38 @@ all: $(OUTDIR)/accountability.py \
2124
$(OUTDIR)/supply_control.py \
2225
$(OUTDIR)/upgrade_manager.py
2326

24-
$(OUTDIR)/accountability.py: $(addprefix $(ABIDIR)/Accountability,.abi .docuser .docdev)
25-
$(call ABIGEN,$^) --exclude distributeRewards,finalize,setEpochPeriod >$@
27+
$(OUTDIR)/accountability.py: $(call gentargets,Accountability)
28+
$(call abigen,$^) --exclude distributeRewards,finalize,setEpochPeriod >$@
2629

27-
$(OUTDIR)/acu.py: $(addprefix $(ABIDIR)/ACU,.abi .docuser .docdev)
28-
$(call ABIGEN,$^) --exclude setOperator,setOracle,update >$@
30+
$(OUTDIR)/acu.py: $(call gentargets,ACU)
31+
$(call abigen,$^) --exclude setOperator,setOracle,update >$@
2932

30-
$(OUTDIR)/autonity.py: $(addprefix $(ABIDIR)/Autonity,.abi .docuser .docdev)
31-
$(call ABIGEN,$^) --exclude computeCommittee,finalize,finalizeInitialization >$@
33+
$(OUTDIR)/autonity.py: $(call gentargets,Autonity)
34+
$(call abigen,$^) --exclude computeCommittee,finalize,finalizeInitialization,updateValidatorAndTransferSlashedFunds >$@
3235

33-
$(OUTDIR)/ierc20.py: $(addprefix $(ABIDIR)/IERC20,.abi .docuser .docdev)
34-
$(call ABIGEN,$^) >$@
36+
$(OUTDIR)/ierc20.py: $(call gentargets,IERC20)
37+
$(call abigen,$^) >$@
3538

36-
$(OUTDIR)/inflation_controller.py: $(addprefix $(ABIDIR)/InflationController,.abi .docuser .docdev)
37-
$(call ABIGEN,$^) >$@
39+
$(OUTDIR)/inflation_controller.py: $(call gentargets,InflationController)
40+
$(call abigen,$^) >$@
3841

39-
$(OUTDIR)/liquid.py: $(addprefix $(ABIDIR)/Liquid,.abi .docuser .docdev)
40-
$(call ABIGEN,$^) --exclude burn,lock,mint,redistribute,setCommissionRate,unlock >$@
42+
$(OUTDIR)/liquid.py: $(call gentargets,Liquid)
43+
$(call abigen,$^) --exclude burn,lock,mint,redistribute,setCommissionRate,unlock >$@
4144

42-
$(OUTDIR)/non_stakable_vesting.py: $(addprefix $(ABIDIR)/NonStakableVesting,.abi .docuser .docdev)
43-
$(call ABIGEN,$^) --exclude unlockTokens >$@
45+
$(OUTDIR)/non_stakable_vesting.py: $(call gentargets,NonStakableVesting)
46+
$(call abigen,$^) --exclude unlockTokens >$@
4447

45-
$(OUTDIR)/oracle.py: $(addprefix $(ABIDIR)/Oracle,.abi .docuser .docdev)
46-
$(call ABIGEN,$^) --exclude finalize,setOperator,setVoters >$@
48+
$(OUTDIR)/oracle.py: $(call gentargets,Oracle)
49+
$(call abigen,$^) --exclude finalize,setOperator,setVoters >$@
4750

48-
$(OUTDIR)/stabilization.py: $(addprefix $(ABIDIR)/Stabilization,.abi .docuser .docdev)
49-
$(call ABIGEN,$^) --exclude setOperator,setOracle >$@
51+
$(OUTDIR)/stabilization.py: $(call gentargets,Stabilization)
52+
$(call abigen,$^) --exclude setOperator,setOracle >$@
5053

51-
$(OUTDIR)/supply_control.py: $(addprefix $(ABIDIR)/SupplyControl,.abi .docuser .docdev)
52-
$(call ABIGEN,$^) --exclude setOperator >$@
54+
$(OUTDIR)/supply_control.py: $(call gentargets,SupplyControl)
55+
$(call abigen,$^) --exclude setOperator >$@
5356

54-
$(OUTDIR)/upgrade_manager.py: $(addprefix $(ABIDIR)/UpgradeManager,.abi .docuser .docdev)
55-
$(call ABIGEN,$^) --exclude setOperator >$@
57+
$(OUTDIR)/upgrade_manager.py: $(call gentargets,UpgradeManager)
58+
$(call abigen,$^) --exclude setOperator >$@
5659

5760
$(ABIDIR)/%.abi: $(AUTONITY) AUTONITY_VERSION
5861
cd $< && \

autonity/contracts/accountability.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""Accountability contract binding and data structures."""
22

3-
# This module has been generated using pyabigen v0.2.6
3+
# This module has been generated using pyabigen v0.2.8
44

55
import enum
66
import typing
77

88
import eth_typing
99
import hexbytes
1010
import web3
11-
from web3 import types
11+
from dataclasses import dataclass
1212
from web3.contract import base_contract, contract
1313

1414
__version__ = "v0.14.0"
@@ -37,7 +37,8 @@ class EventType(enum.IntEnum):
3737
INNOCENCE_PROOF = 2
3838

3939

40-
class Config(typing.NamedTuple):
40+
@dataclass
41+
class Config:
4142
"""Port of `struct Config` on the Accountability contract."""
4243

4344
innocence_proof_submission_window: int
@@ -49,7 +50,8 @@ class Config(typing.NamedTuple):
4950
slashing_rate_precision: int
5051

5152

52-
class Event(typing.NamedTuple):
53+
@dataclass
54+
class Event:
5355
"""Port of `struct Event` on the Accountability contract."""
5456

5557
chunks: int
@@ -163,7 +165,7 @@ def can_accuse(
163165
"""
164166
return_value = self._contract.functions.canAccuse(
165167
_offender,
166-
_rule,
168+
int(_rule),
167169
_block,
168170
).call()
169171
return (
@@ -191,7 +193,7 @@ def can_slash(
191193
"""
192194
return_value = self._contract.functions.canSlash(
193195
_offender,
194-
_rule,
196+
int(_rule),
195197
_block,
196198
).call()
197199
return bool(return_value)
@@ -333,6 +335,11 @@ def handle_event(
333335
) -> contract.ContractFunction:
334336
"""Binding for `handleEvent` on the Accountability contract.
335337
338+
Handle an accountability event. Need to be called by a registered validator
339+
account as the treasury-linked account will be used in case of a successful
340+
slashing event. todo(youssef): rethink modifiers here, consider splitting this
341+
into multiple functions.
342+
336343
Parameters
337344
----------
338345
_event : Event
@@ -343,7 +350,20 @@ def handle_event(
343350
A contract function instance to be sent in a transaction.
344351
"""
345352
return self._contract.functions.handleEvent(
346-
_event,
353+
(
354+
_event.chunks,
355+
_event.chunk_id,
356+
int(_event.event_type),
357+
int(_event.rule),
358+
_event.reporter,
359+
_event.offender,
360+
_event.raw_proof,
361+
_event.id,
362+
_event.block,
363+
_event.epoch,
364+
_event.reporting_block,
365+
_event.message_hash,
366+
),
347367
)
348368

349369
def slashing_history(
@@ -370,7 +390,7 @@ def slashing_history(
370390

371391

372392
ABI = typing.cast(
373-
types.ABI,
393+
eth_typing.ABI,
374394
[
375395
{
376396
"inputs": [

autonity/contracts/acu.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
"""ACU contract binding and data structures."""
22

3-
# This module has been generated using pyabigen v0.2.6
3+
# This module has been generated using pyabigen v0.2.8
44

55
import typing
66

77
import eth_typing
88
import web3
9-
from web3 import types
109
from web3.contract import base_contract, contract
1110

1211
__version__ = "v0.14.0"
@@ -15,6 +14,9 @@
1514
class ACU:
1615
"""ACU contract binding.
1716
17+
Computes the value of the ACU, an optimal currency basket of 7 free-floating fiat
18+
currencies. Intended to be deployed by the protocol at genesis.
19+
1820
Parameters
1921
----------
2022
w3 : web3.Web3
@@ -171,7 +173,7 @@ def value(
171173

172174

173175
ABI = typing.cast(
174-
types.ABI,
176+
eth_typing.ABI,
175177
[
176178
{
177179
"inputs": [
@@ -189,6 +191,9 @@ def value(
189191
"stateMutability": "nonpayable",
190192
"type": "constructor",
191193
},
194+
{"inputs": [], "name": "InvalidBasket", "type": "error"},
195+
{"inputs": [], "name": "NoACUValue", "type": "error"},
196+
{"inputs": [], "name": "Unauthorized", "type": "error"},
192197
{
193198
"anonymous": False,
194199
"inputs": [
@@ -214,9 +219,6 @@ def value(
214219
"name": "BasketModified",
215220
"type": "event",
216221
},
217-
{"inputs": [], "name": "InvalidBasket", "type": "error"},
218-
{"inputs": [], "name": "NoACUValue", "type": "error"},
219-
{"inputs": [], "name": "Unauthorized", "type": "error"},
220222
{
221223
"anonymous": False,
222224
"inputs": [

autonity/contracts/autonity.py

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""Autonity contract binding and data structures."""
22

3-
# This module has been generated using pyabigen v0.2.6
3+
# This module has been generated using pyabigen v0.2.8
44

55
import enum
66
import typing
77

88
import eth_typing
99
import hexbytes
1010
import web3
11-
from web3 import types
11+
from dataclasses import dataclass
1212
from web3.contract import base_contract, contract
1313

1414
__version__ = "v0.14.0"
@@ -32,7 +32,8 @@ class UnbondingReleaseState(enum.IntEnum):
3232
REVERTED = 3
3333

3434

35-
class Validator(typing.NamedTuple):
35+
@dataclass
36+
class Validator:
3637
"""Port of `struct Validator` on the Autonity contract."""
3738

3839
treasury: eth_typing.ChecksumAddress
@@ -57,7 +58,8 @@ class Validator(typing.NamedTuple):
5758
state: ValidatorState
5859

5960

60-
class Policy(typing.NamedTuple):
61+
@dataclass
62+
class Policy:
6163
"""Port of `struct Policy` on the Autonity contract."""
6264

6365
treasury_fee: int
@@ -68,7 +70,8 @@ class Policy(typing.NamedTuple):
6870
treasury_account: eth_typing.ChecksumAddress
6971

7072

71-
class Contracts(typing.NamedTuple):
73+
@dataclass
74+
class Contracts:
7275
"""Port of `struct Contracts` on the Autonity contract."""
7376

7477
accountability_contract: eth_typing.ChecksumAddress
@@ -81,7 +84,8 @@ class Contracts(typing.NamedTuple):
8184
non_stakable_vesting_contract: eth_typing.ChecksumAddress
8285

8386

84-
class Protocol(typing.NamedTuple):
87+
@dataclass
88+
class Protocol:
8589
"""Port of `struct Protocol` on the Autonity contract."""
8690

8791
operator_account: eth_typing.ChecksumAddress
@@ -90,7 +94,8 @@ class Protocol(typing.NamedTuple):
9094
committee_size: int
9195

9296

93-
class Config(typing.NamedTuple):
97+
@dataclass
98+
class Config:
9499
"""Port of `struct Config` on the Autonity contract."""
95100

96101
policy: Policy
@@ -99,7 +104,8 @@ class Config(typing.NamedTuple):
99104
contract_version: int
100105

101106

102-
class CommitteeMember(typing.NamedTuple):
107+
@dataclass
108+
class CommitteeMember:
103109
"""Port of `struct CommitteeMember` on the Autonity contract."""
104110

105111
addr: eth_typing.ChecksumAddress
@@ -1690,25 +1696,6 @@ def update_enode(
16901696
_enode,
16911697
)
16921698

1693-
def update_validator_and_transfer_slashed_funds(
1694-
self,
1695-
_val: Validator,
1696-
) -> contract.ContractFunction:
1697-
"""Binding for `updateValidatorAndTransferSlashedFunds` on the Autonity contract.
1698-
1699-
Parameters
1700-
----------
1701-
_val : Validator
1702-
1703-
Returns
1704-
-------
1705-
web3.contract.contract.ContractFunction
1706-
A contract function instance to be sent in a transaction.
1707-
"""
1708-
return self._contract.functions.updateValidatorAndTransferSlashedFunds(
1709-
_val,
1710-
)
1711-
17121699
def upgrade_contract(
17131700
self,
17141701
_bytecode: hexbytes.HexBytes,
@@ -1736,7 +1723,7 @@ def upgrade_contract(
17361723

17371724

17381725
ABI = typing.cast(
1739-
types.ABI,
1726+
eth_typing.ABI,
17401727
[
17411728
{
17421729
"inputs": [
@@ -1970,8 +1957,6 @@ def upgrade_contract(
19701957
"stateMutability": "nonpayable",
19711958
"type": "constructor",
19721959
},
1973-
{"stateMutability": "payable", "type": "fallback"},
1974-
{"stateMutability": "payable", "type": "receive"},
19751960
{
19761961
"anonymous": False,
19771962
"inputs": [
@@ -2128,13 +2113,6 @@ def upgrade_contract(
21282113
"name": "BurnedStake",
21292114
"type": "event",
21302115
},
2131-
{
2132-
"inputs": [],
2133-
"name": "COMMISSION_RATE_PRECISION",
2134-
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
2135-
"stateMutability": "view",
2136-
"type": "function",
2137-
},
21382116
{
21392117
"anonymous": False,
21402118
"inputs": [
@@ -2461,6 +2439,14 @@ def upgrade_contract(
24612439
"name": "UnlockingScheduleFailed",
24622440
"type": "event",
24632441
},
2442+
{"stateMutability": "payable", "type": "fallback"},
2443+
{
2444+
"inputs": [],
2445+
"name": "COMMISSION_RATE_PRECISION",
2446+
"outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
2447+
"stateMutability": "view",
2448+
"type": "function",
2449+
},
24642450
{
24652451
"inputs": [
24662452
{"internalType": "address", "name": "_address", "type": "address"}
@@ -3512,5 +3498,6 @@ def upgrade_contract(
35123498
"stateMutability": "nonpayable",
35133499
"type": "function",
35143500
},
3501+
{"stateMutability": "payable", "type": "receive"},
35153502
],
35163503
)

0 commit comments

Comments
 (0)