Skip to content

Commit 0735a4a

Browse files
author
Yucong Sun
committed
Update libra to af6b3fd
1 parent 939ad57 commit 0735a4a

File tree

10 files changed

+101
-295
lines changed

10 files changed

+101
-295
lines changed

libra

Submodule libra updated from 93c0d0e to af6b3fd

python/lib/data.h

Lines changed: 74 additions & 257 deletions
Large diffs are not rendered by default.
-118 KB
Binary file not shown.
-187 KB
Binary file not shown.
-109 KB
Binary file not shown.

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run(self):
7878
setup(
7979
name="pylibra-beta",
8080
# change to 0.1.YYYYMMDDNN on release
81-
version="0.5.master",
81+
version="0.5.2020081001",
8282
description="",
8383
python_requires=">=3.7",
8484
packages=find_packages("src"),

python/src/pylibra/lcs/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ def serialize(obj: typing.Any, obj_type) -> bytes:
211211
if not dataclasses.is_dataclass(obj_type):
212212
raise ValueError("Unexpected type", obj_type)
213213

214-
# pyre-ignore
215214
if not isinstance(obj, obj_type):
216215
raise ValueError("Wrong Value for the type", obj, obj_type)
217216

python/src/pylibra/libra_types/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ class Transaction__UserTransaction(Transaction):
212212

213213

214214
@dataclass
215-
class Transaction__WaypointWriteSet(Transaction):
215+
class Transaction__GenesisTransaction(Transaction):
216216
INDEX = 1
217-
value: "ChangeSet"
217+
value: "WriteSetPayload"
218218

219219

220220
@dataclass
@@ -225,7 +225,7 @@ class Transaction__BlockMetadata(Transaction):
225225

226226
Transaction.VARIANTS = [
227227
Transaction__UserTransaction,
228-
Transaction__WaypointWriteSet,
228+
Transaction__GenesisTransaction,
229229
Transaction__BlockMetadata,
230230
]
231231

python/src/pylibra/stdlib/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def encode_create_designated_dealer_script(
182182

183183
def encode_create_parent_vasp_account_script(
184184
coin_type: TypeTag,
185+
sliding_nonce: st.uint64,
185186
new_account_address: AccountAddress,
186187
auth_key_prefix: bytes,
187188
human_name: bytes,
@@ -193,11 +194,13 @@ def encode_create_parent_vasp_account_script(
193194
194195
If `add_all_currencies` is true, 0 balances for all available currencies in the system
195196
will also be added. This can only be invoked by an Association account.
197+
`sliding_nonce` is a unique nonce for operation, see sliding_nonce.move for details.
196198
"""
197199
return Script(
198-
code=b"\xa1\x1c\xeb\x0b\x01\x00\x00\x00\x06\x01\x00\x02\x03\x02\x06\x04\x08\x02\x05\x0a\x11\x07\x1b\x28\x08\x43\x10\x00\x00\x00\x01\x00\x01\x01\x01\x00\x02\x07\x06\x0c\x05\x0a\x02\x0a\x02\x0a\x02\x0a\x02\x01\x00\x01\x09\x00\x0c\x4c\x69\x62\x72\x61\x41\x63\x63\x6f\x75\x6e\x74\x1a\x63\x72\x65\x61\x74\x65\x5f\x70\x61\x72\x65\x6e\x74\x5f\x76\x61\x73\x70\x5f\x61\x63\x63\x6f\x75\x6e\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x00\x01\x09\x0b\x00\x0a\x01\x0b\x02\x0b\x03\x0b\x04\x0b\x05\x0a\x06\x38\x00\x02",
200+
code=b"\xa1\x1c\xeb\x0b\x01\x00\x00\x00\x06\x01\x00\x04\x03\x04\x0b\x04\x0f\x02\x05\x11\x23\x07\x34\x4b\x08\x7f\x10\x00\x00\x00\x01\x01\x02\x00\x01\x00\x00\x03\x02\x01\x01\x01\x01\x04\x02\x06\x0c\x03\x00\x07\x06\x0c\x05\x0a\x02\x0a\x02\x0a\x02\x0a\x02\x01\x08\x06\x0c\x03\x05\x0a\x02\x0a\x02\x0a\x02\x0a\x02\x01\x01\x09\x00\x0c\x4c\x69\x62\x72\x61\x41\x63\x63\x6f\x75\x6e\x74\x0c\x53\x6c\x69\x64\x69\x6e\x67\x4e\x6f\x6e\x63\x65\x15\x72\x65\x63\x6f\x72\x64\x5f\x6e\x6f\x6e\x63\x65\x5f\x6f\x72\x5f\x61\x62\x6f\x72\x74\x1a\x63\x72\x65\x61\x74\x65\x5f\x70\x61\x72\x65\x6e\x74\x5f\x76\x61\x73\x70\x5f\x61\x63\x63\x6f\x75\x6e\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x01\x01\x03\x01\x0c\x0a\x00\x0a\x01\x11\x00\x0b\x00\x0a\x02\x0b\x03\x0b\x04\x0b\x05\x0b\x06\x0a\x07\x38\x00\x02",
199201
ty_args=[coin_type],
200202
args=[
203+
TransactionArgument__U64(sliding_nonce),
201204
TransactionArgument__Address(new_account_address),
202205
TransactionArgument__U8Vector(auth_key_prefix),
203206
TransactionArgument__U8Vector(human_name),
@@ -730,12 +733,15 @@ def encode_update_exchange_rate_script(
730733
)
731734

732735

733-
def encode_update_libra_version_script(major: st.uint64) -> Script:
734-
"""Update Libra version."""
736+
def encode_update_libra_version_script(sliding_nonce: st.uint64, major: st.uint64) -> Script:
737+
"""Update Libra version.
738+
739+
`sliding_nonce` is a unique nonce for operation, see sliding_nonce.move for details.
740+
"""
735741
return Script(
736-
code=b"\xa1\x1c\xeb\x0b\x01\x00\x00\x00\x05\x01\x00\x02\x03\x02\x05\x05\x07\x05\x07\x0c\x11\x08\x1d\x10\x00\x00\x00\x01\x00\x01\x00\x02\x06\x0c\x03\x00\x0c\x4c\x69\x62\x72\x61\x56\x65\x72\x73\x69\x6f\x6e\x03\x73\x65\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x01\x04\x0b\x00\x0a\x01\x11\x00\x02",
742+
code=b"\xa1\x1c\xeb\x0b\x01\x00\x00\x00\x05\x01\x00\x04\x03\x04\x0a\x05\x0e\x0a\x07\x18\x34\x08\x4c\x10\x00\x00\x00\x01\x00\x02\x00\x01\x00\x01\x03\x00\x01\x00\x02\x06\x0c\x03\x00\x03\x06\x0c\x03\x03\x0c\x4c\x69\x62\x72\x61\x56\x65\x72\x73\x69\x6f\x6e\x0c\x53\x6c\x69\x64\x69\x6e\x67\x4e\x6f\x6e\x63\x65\x03\x73\x65\x74\x15\x72\x65\x63\x6f\x72\x64\x5f\x6e\x6f\x6e\x63\x65\x5f\x6f\x72\x5f\x61\x62\x6f\x72\x74\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x02\x01\x07\x0a\x00\x0a\x01\x11\x01\x0b\x00\x0a\x02\x11\x00\x02",
737743
ty_args=[],
738-
args=[TransactionArgument__U64(major)],
744+
args=[TransactionArgument__U64(sliding_nonce), TransactionArgument__U64(major)],
739745
)
740746

741747

python/tests/test_lcs.py

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@
33

44
# pyre-strict
55

6-
from pylibra import (
7-
TransactionUtils,
8-
lcs,
9-
libra_types as libra,
10-
serde_types as st,
11-
stdlib,
12-
)
6+
from pylibra import TransactionUtils
7+
from pylibra import libra_types as libra
8+
from pylibra import serde_types as st
9+
from pylibra import lcs
10+
from pylibra import stdlib
1311

1412

1513
def test_lcs_e2e() -> None:
1614
print("Testing serialization: ")
1715

18-
obj = libra.Transaction__WaypointWriteSet(
19-
libra.ChangeSet(libra.WriteSet(libra.WriteSetMut(write_set=[])), [])
16+
obj = libra.Transaction__GenesisTransaction(
17+
libra.WriteSetPayload__Direct(libra.ChangeSet(libra.WriteSet(libra.WriteSetMut(write_set=[])), []))
2018
)
2119
content = lcs.serialize(obj, libra.Transaction)
2220

@@ -34,12 +32,7 @@ def test_lcs_e2e() -> None:
3432

3533
def test_lcs_e2e_native() -> None:
3634
content = TransactionUtils.createSignedP2PTransaction(
37-
bytes.fromhex("11" * 32),
38-
bytes.fromhex("22" * 16),
39-
255,
40-
1_234_567,
41-
expiration_time=123456789,
42-
chain_id=255,
35+
bytes.fromhex("11" * 32), bytes.fromhex("22" * 16), 255, 1_234_567, expiration_time=123456789, chain_id=255
4336
)
4437

4538
print("Testing Deserialization native bytes: ", content)
@@ -68,16 +61,9 @@ def make_address(content: bytes) -> libra.AccountAddress:
6861

6962
def test_stdlib() -> None:
7063
content = TransactionUtils.createSignedP2PTransaction(
71-
bytes.fromhex("11" * 32),
72-
bytes.fromhex("22" * 16),
73-
255,
74-
1_234_567,
75-
expiration_time=123456789,
76-
chain_id=255,
64+
bytes.fromhex("11" * 32), bytes.fromhex("22" * 16), 255, 1_234_567, expiration_time=123456789, chain_id=255
7765
)
78-
raw_txn = lcs.deserialize(content, libra.Transaction__UserTransaction)[
79-
0
80-
].value.raw_txn
66+
raw_txn = lcs.deserialize(content, libra.Transaction__UserTransaction)[0].value.raw_txn
8167

8268
assert isinstance(raw_txn.payload, libra.TransactionPayload__Script)
8369

@@ -91,9 +77,7 @@ def test_stdlib() -> None:
9177
)
9278
payee = make_address(b"\x22" * 16)
9379
amount = st.uint64(1_234_567)
94-
script = stdlib.encode_peer_to_peer_with_metadata_script(
95-
token, payee, amount, b"", b""
96-
)
80+
script = stdlib.encode_peer_to_peer_with_metadata_script(token, payee, amount, b"", b"")
9781

9882
# We have successfully generated an (unsigned) P2P transaction in python.
9983
assert script == raw_txn.payload.value

0 commit comments

Comments
 (0)