Skip to content

Commit 705681c

Browse files
committed
Add events type
1 parent 139aeda commit 705681c

File tree

1 file changed

+170
-20
lines changed

1 file changed

+170
-20
lines changed

starcoin/starcoin_types/__init__.py

Lines changed: 170 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@
55
from starcoin import bcs
66

77

8+
@dataclass(frozen=True)
9+
class AcceptTokenEvent:
10+
token_code: "TokenCode"
11+
12+
def bcs_serialize(self) -> bytes:
13+
return bcs.serialize(self, AcceptTokenEvent)
14+
15+
@staticmethod
16+
def bcs_deserialize(input: bytes) -> 'AcceptTokenEvent':
17+
v, buffer = bcs.deserialize(input, AcceptTokenEvent)
18+
if buffer:
19+
raise st.DeserializationError("Some input bytes were not read")
20+
return v
21+
22+
823
@dataclass(frozen=True)
924
class AccessPath:
1025
address: "AccountAddress"
@@ -19,7 +34,7 @@ def bcs_deserialize(input: bytes) -> 'AccessPath':
1934
if buffer:
2035
raise st.DeserializationError("Some input bytes were not read")
2136
return v
22-
37+
2338

2439
@dataclass(frozen=True)
2540
class AccountAddress:
@@ -41,7 +56,6 @@ def from_hex(addr: str) -> 'AccountAddress':
4156
"""Create an account address from bytes."""
4257
return AccountAddress(tuple(st.uint8(x) for x in bytes.fromhex(addr)))
4358

44-
4559
@dataclass(frozen=True)
4660
class AccountResource:
4761
authentication_key: bytes
@@ -98,6 +112,40 @@ def bcs_deserialize(input: bytes) -> 'BlockMetadata':
98112
return v
99113

100114

115+
@dataclass(frozen=True)
116+
class BlockRewardEvent:
117+
block_number: st.uint64
118+
block_reward: st.uint128
119+
gas_fees: st.uint128
120+
miner: "AccountAddress"
121+
122+
def bcs_serialize(self) -> bytes:
123+
return bcs.serialize(self, BlockRewardEvent)
124+
125+
@staticmethod
126+
def bcs_deserialize(input: bytes) -> 'BlockRewardEvent':
127+
v, buffer = bcs.deserialize(input, BlockRewardEvent)
128+
if buffer:
129+
raise st.DeserializationError("Some input bytes were not read")
130+
return v
131+
132+
133+
@dataclass(frozen=True)
134+
class BurnEvent:
135+
amount: st.uint128
136+
token_code: "TokenCode"
137+
138+
def bcs_serialize(self) -> bytes:
139+
return bcs.serialize(self, BurnEvent)
140+
141+
@staticmethod
142+
def bcs_deserialize(input: bytes) -> 'BurnEvent':
143+
v, buffer = bcs.deserialize(input, BurnEvent)
144+
if buffer:
145+
raise st.DeserializationError("Some input bytes were not read")
146+
return v
147+
148+
101149
@dataclass(frozen=True)
102150
class ChainId:
103151
value: st.uint8
@@ -204,6 +252,23 @@ class DataPath__Resource(DataPath):
204252
]
205253

206254

255+
@dataclass(frozen=True)
256+
class DepositEvent:
257+
amount: st.uint128
258+
token_code: "TokenCode"
259+
metadata: typing.Sequence[st.uint8]
260+
261+
def bcs_serialize(self) -> bytes:
262+
return bcs.serialize(self, DepositEvent)
263+
264+
@staticmethod
265+
def bcs_deserialize(input: bytes) -> 'DepositEvent':
266+
v, buffer = bcs.deserialize(input, DepositEvent)
267+
if buffer:
268+
raise st.DeserializationError("Some input bytes were not read")
269+
return v
270+
271+
207272
@dataclass(frozen=True)
208273
class Ed25519PublicKey:
209274
value: bytes
@@ -462,6 +527,22 @@ class Metadata__UnstructuredBytesMetadata(Metadata):
462527
]
463528

464529

530+
@dataclass(frozen=True)
531+
class MintEvent:
532+
amount: st.uint128
533+
token_code: "TokenCode"
534+
535+
def bcs_serialize(self) -> bytes:
536+
return bcs.serialize(self, MintEvent)
537+
538+
@staticmethod
539+
def bcs_deserialize(input: bytes) -> 'MintEvent':
540+
v, buffer = bcs.deserialize(input, MintEvent)
541+
if buffer:
542+
raise st.DeserializationError("Some input bytes were not read")
543+
return v
544+
545+
465546
@dataclass(frozen=True)
466547
class Module:
467548
code: bytes
@@ -523,6 +604,24 @@ def bcs_deserialize(input: bytes) -> 'MultiEd25519Signature':
523604
return v
524605

525606

607+
@dataclass(frozen=True)
608+
class NewBlockEvent:
609+
number: st.uint64
610+
author: "AccountAddress"
611+
timestamp: st.uint64
612+
uncles: st.uint64
613+
614+
def bcs_serialize(self) -> bytes:
615+
return bcs.serialize(self, NewBlockEvent)
616+
617+
@staticmethod
618+
def bcs_deserialize(input: bytes) -> 'NewBlockEvent':
619+
v, buffer = bcs.deserialize(input, NewBlockEvent)
620+
if buffer:
621+
raise st.DeserializationError("Some input bytes were not read")
622+
return v
623+
624+
526625
@dataclass(frozen=True)
527626
class Package:
528627
package_address: "AccountAddress"
@@ -540,6 +639,22 @@ def bcs_deserialize(input: bytes) -> 'Package':
540639
return v
541640

542641

642+
@dataclass(frozen=True)
643+
class ProposalCreatedEvent:
644+
proposal_id: st.uint64
645+
proposer: "AccountAddress"
646+
647+
def bcs_serialize(self) -> bytes:
648+
return bcs.serialize(self, ProposalCreatedEvent)
649+
650+
@staticmethod
651+
def bcs_deserialize(input: bytes) -> 'ProposalCreatedEvent':
652+
v, buffer = bcs.deserialize(input, ProposalCreatedEvent)
653+
if buffer:
654+
raise st.DeserializationError("Some input bytes were not read")
655+
return v
656+
657+
543658
@dataclass(frozen=True)
544659
class RawTransaction:
545660
sender: "AccountAddress"
@@ -631,6 +746,23 @@ def bcs_deserialize(input: bytes) -> 'StructTag':
631746
return v
632747

633748

749+
@dataclass(frozen=True)
750+
class TokenCode:
751+
address: "AccountAddress"
752+
module: str
753+
name: str
754+
755+
def bcs_serialize(self) -> bytes:
756+
return bcs.serialize(self, TokenCode)
757+
758+
@staticmethod
759+
def bcs_deserialize(input: bytes) -> 'TokenCode':
760+
v, buffer = bcs.deserialize(input, TokenCode)
761+
if buffer:
762+
raise st.DeserializationError("Some input bytes were not read")
763+
return v
764+
765+
634766
class Transaction:
635767
VARIANTS = [] # type: typing.Sequence[typing.Type[Transaction]]
636768

@@ -925,6 +1057,25 @@ def bcs_deserialize(input: bytes) -> 'UnstructuredBytesMetadata':
9251057
return v
9261058

9271059

1060+
@dataclass(frozen=True)
1061+
class VoteChangedEvent:
1062+
proposal_id: st.uint64
1063+
proposer: "AccountAddress"
1064+
voter: "AccountAddress"
1065+
agree: bool
1066+
vote: st.uint128
1067+
1068+
def bcs_serialize(self) -> bytes:
1069+
return bcs.serialize(self, VoteChangedEvent)
1070+
1071+
@staticmethod
1072+
def bcs_deserialize(input: bytes) -> 'VoteChangedEvent':
1073+
v, buffer = bcs.deserialize(input, VoteChangedEvent)
1074+
if buffer:
1075+
raise st.DeserializationError("Some input bytes were not read")
1076+
return v
1077+
1078+
9281079
@dataclass(frozen=True)
9291080
class WithdrawCapabilityResource:
9301081
account_address: "AccountAddress"
@@ -940,6 +1091,23 @@ def bcs_deserialize(input: bytes) -> 'WithdrawCapabilityResource':
9401091
return v
9411092

9421093

1094+
@dataclass(frozen=True)
1095+
class WithdrawEvent:
1096+
amount: st.uint128
1097+
token_code: "TokenCode"
1098+
metadata: typing.Sequence[st.uint8]
1099+
1100+
def bcs_serialize(self) -> bytes:
1101+
return bcs.serialize(self, WithdrawEvent)
1102+
1103+
@staticmethod
1104+
def bcs_deserialize(input: bytes) -> 'WithdrawEvent':
1105+
v, buffer = bcs.deserialize(input, WithdrawEvent)
1106+
if buffer:
1107+
raise st.DeserializationError("Some input bytes were not read")
1108+
return v
1109+
1110+
9431111
class WriteOp:
9441112
VARIANTS = [] # type: typing.Sequence[typing.Type[WriteOp]]
9451113

@@ -1033,21 +1201,3 @@ class WriteSetPayload__Script(WriteSetPayload):
10331201
WriteSetPayload__Direct,
10341202
WriteSetPayload__Script,
10351203
]
1036-
1037-
1038-
@dataclass
1039-
class BlockRewardEvent:
1040-
block_number: st.uint64
1041-
block_reward: st.uint128
1042-
gas_fees: st.uint128
1043-
miner: "AccountAddress"
1044-
1045-
def bcs_serialize(self) -> bytes:
1046-
return bcs.serialize(self, BlockRewardEvent)
1047-
1048-
@staticmethod
1049-
def bcs_deserialize(input: bytes) -> 'BlockMetadata':
1050-
v, buffer = bcs.deserialize(input, BlockRewardEvent)
1051-
if buffer:
1052-
raise ValueError("Some input bytes were not read")
1053-
return v

0 commit comments

Comments
 (0)