Skip to content

Commit c319ffa

Browse files
author
Yucong Sun
authored
Merge pull request #8 from novifinancial/fallentree
Release 0.5.2020081401
2 parents 0506bf9 + 260df36 commit c319ffa

15 files changed

+197
-168
lines changed

libra

Submodule libra updated from d641f94 to 001cda3
-3.61 KB
Binary file not shown.
-3.9 KB
Binary file not shown.
-2.06 KB
Binary file not shown.

python/setup.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,27 @@ def run(self):
3838

3939
extra_link_args = []
4040
if platform.system() == "Darwin":
41-
LIBRA_LIB_FILE = "%s/%s-%s.a" % (LIBRA_LIB_DIR, "liblibra_dev", "darwin-%s" % platform.machine(),)
41+
LIBRA_LIB_FILE = "%s/%s-%s.a" % (
42+
LIBRA_LIB_DIR,
43+
"liblibra_dev",
44+
"darwin-%s" % platform.machine(),
45+
)
4246
extra_link_args.extend(["-framework", "Security"])
4347
elif platform.system() == "Linux":
44-
LIBRA_LIB_FILE = "%s/%s-%s.a" % (LIBRA_LIB_DIR, "liblibra_dev", "linux-%s" % platform.machine(),)
48+
LIBRA_LIB_FILE = "%s/%s-%s.a" % (
49+
LIBRA_LIB_DIR,
50+
"liblibra_dev",
51+
"linux-%s" % platform.machine(),
52+
)
4553
extra_link_args.append("-ldl")
4654
extra_link_args.append("-lm")
4755
extra_link_args.append("-pthread")
4856
elif platform.system() == "Windows":
49-
LIBRA_LIB_FILE = "%s/%s-%s.a" % (LIBRA_LIB_DIR, "liblibra_dev", "windows-%s" % platform.machine(),)
57+
LIBRA_LIB_FILE = "%s/%s-%s.a" % (
58+
LIBRA_LIB_DIR,
59+
"liblibra_dev",
60+
"windows-%s" % platform.machine(),
61+
)
5062

5163

5264
exts = [

python/src/pylibra/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
NETWORK_DEFAULT: str = NETWORK_TESTNET
1111

1212
ENDPOINT_CONFIG: typing.Dict[str, typing.Dict[str, str]] = {
13-
NETWORK_TESTNET: {"json-rpc": "https://client.testnet.libra.org/", "faucet": "http://faucet.testnet.libra.org"},
13+
NETWORK_TESTNET: {"json-rpc": "https://testnet.libra.org/v1", "faucet": "http://testnet.libra.org/mint"},
1414
NETWORK_DEV: {
1515
"json-rpc": "http://client.dev.aws.hlw3truzy4ls.com/",
1616
"faucet": "http://faucet.dev.aws.hlw3truzy4ls.com",

python/src/pylibra/_jsonrpc_transport.py

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class GetAccountStateResp:
5050

5151
@dataclasses.dataclass
5252
class GetMetadataResp:
53+
chain_id: int
5354
version: int
5455
timestamp: int
5556

@@ -182,10 +183,10 @@ def __init__(self, address_hex: str, state: GetAccountStateResp):
182183
self._role = typing.cast(str, self._state.role)
183184
else:
184185
role_dict = typing.cast(typing.Dict, self._state.role)
185-
if "parent_vasp" in self._state.role:
186-
self._role = ParentVASP(**(role_dict["parent_vasp"]))
187-
elif "child_vasp" in self._state.role:
188-
self._role = ChildVASP(**(role_dict["child_vasp"]))
186+
if self._state.role["type"] == "parent_vasp":
187+
self._role = ParentVASP(**(role_dict))
188+
elif self._state.role["type"] == "child_vasp":
189+
self._role = ChildVASP(**(role_dict))
189190

190191
@property
191192
def address(self) -> bytes:
@@ -443,19 +444,34 @@ def __del__(self):
443444

444445
def currentVersion(self) -> int:
445446
result = make_json_rpc_request(
446-
self._url, self._session, self._timeout, "get_metadata", ["NULL"], GetMetadataResp,
447+
self._url,
448+
self._session,
449+
self._timeout,
450+
"get_metadata",
451+
["NULL"],
452+
GetMetadataResp,
447453
)
448454
return result.version
449455

450456
def currentTimestampUsecs(self) -> int:
451457
result = make_json_rpc_request(
452-
self._url, self._session, self._timeout, "get_metadata", ["NULL"], GetMetadataResp,
458+
self._url,
459+
self._session,
460+
self._timeout,
461+
"get_metadata",
462+
["NULL"],
463+
GetMetadataResp,
453464
)
454465
return result.timestamp
455466

456467
def getAccount(self, address_hex: str) -> typing.Optional[AccountResource]:
457468
resp = make_json_rpc_request(
458-
self._url, self._session, self._timeout, "get_account", [address_hex], GetAccountStateResp,
469+
self._url,
470+
self._session,
471+
self._timeout,
472+
"get_account",
473+
[address_hex],
474+
GetAccountStateResp,
459475
)
460476
if resp is None:
461477
return None
@@ -466,7 +482,12 @@ def getAccount(self, address_hex: str) -> typing.Optional[AccountResource]:
466482

467483
def sendTransaction(self, signed_transaction_bytes: bytes) -> None:
468484
resp = make_json_rpc_request(
469-
self._url, self._session, self._timeout, "submit", [signed_transaction_bytes.hex()], SubmitResp,
485+
self._url,
486+
self._session,
487+
self._timeout,
488+
"submit",
489+
[signed_transaction_bytes.hex()],
490+
SubmitResp,
470491
)
471492
if resp is None:
472493
return None
@@ -479,7 +500,12 @@ def transactions_by_range(
479500
self, start_version: int, limit: int, include_events: bool = False
480501
) -> typing.List[typing.Tuple[SignedTransaction, EventsType]]:
481502
resp_dict = make_json_rpc_request(
482-
self._url, self._session, self._timeout, "get_transactions", [start_version, limit, include_events], None,
503+
self._url,
504+
self._session,
505+
self._timeout,
506+
"get_transactions",
507+
[start_version, limit, include_events],
508+
None,
483509
)
484510

485511
results = []
@@ -497,7 +523,12 @@ def transaction_by_acc_seq(
497523
self, addr_hex: str, seq: int, include_events: bool = False
498524
) -> typing.Tuple[typing.Optional[SignedTransaction], EventsType]:
499525
resp_dict = make_json_rpc_request(
500-
self._url, self._session, self._timeout, "get_account_transaction", [addr_hex, seq, include_events], None,
526+
self._url,
527+
self._session,
528+
self._timeout,
529+
"get_account_transaction",
530+
[addr_hex, seq, include_events],
531+
None,
501532
)
502533

503534
if resp_dict is None:
@@ -513,7 +544,12 @@ def transaction_by_acc_seq(
513544

514545
def get_events(self, key_hex: str, start: int, limit: int) -> EventsType:
515546
resp_list = make_json_rpc_request(
516-
self._url, self._session, self._timeout, "get_events", [key_hex, start, limit], None,
547+
self._url,
548+
self._session,
549+
self._timeout,
550+
"get_events",
551+
[key_hex, start, limit],
552+
None,
517553
)
518554
return as_events(resp_list)
519555

python/src/pylibra/_transport.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def transactions_by_range(
5555

5656
def transaction_by_acc_seq(
5757
self, addr_hex: str, seq: int, include_events: bool = False
58-
) -> typing.Tuple[
59-
typing.Optional[SignedTransaction], typing.List[typing.Union[Event, PaymentEvent]],
60-
]:
58+
) -> typing.Tuple[typing.Optional[SignedTransaction], typing.List[typing.Union[Event, PaymentEvent]],]:
6159
raise NotImplementedError()
6260

6361
def get_events(self, key_hex: str, start: int, limit: int) -> typing.List[typing.Union[Event, PaymentEvent]]:

python/src/pylibra/_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
@dataclasses.dataclass
1111
class ParentVASP:
12+
type: str
1213
base_url: str
1314
compliance_key: bytes
1415
expiration_time: int
@@ -18,6 +19,7 @@ class ParentVASP:
1819

1920
@dataclasses.dataclass
2021
class ChildVASP:
22+
type: str
2123
parent_vasp_address: bytes
2224

2325

python/src/pylibra/lcs/__init__.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,46 @@ def not_implemented():
105105
}
106106

107107
primitive_decode_map = {
108-
st.bool: lambda content: (st.bool(int.from_bytes(content[:1], byteorder="little", signed=False)), content[1:],),
109-
st.uint8: lambda content: (st.uint8(int.from_bytes(content[:1], byteorder="little", signed=False)), content[1:],),
110-
st.uint16: lambda content: (st.uint16(int.from_bytes(content[:2], byteorder="little", signed=False)), content[2:],),
111-
st.uint32: lambda content: (st.uint32(int.from_bytes(content[:4], byteorder="little", signed=False)), content[4:],),
112-
st.uint64: lambda content: (st.uint64(int.from_bytes(content[:8], byteorder="little", signed=False)), content[8:],),
108+
st.bool: lambda content: (
109+
st.bool(int.from_bytes(content[:1], byteorder="little", signed=False)),
110+
content[1:],
111+
),
112+
st.uint8: lambda content: (
113+
st.uint8(int.from_bytes(content[:1], byteorder="little", signed=False)),
114+
content[1:],
115+
),
116+
st.uint16: lambda content: (
117+
st.uint16(int.from_bytes(content[:2], byteorder="little", signed=False)),
118+
content[2:],
119+
),
120+
st.uint32: lambda content: (
121+
st.uint32(int.from_bytes(content[:4], byteorder="little", signed=False)),
122+
content[4:],
123+
),
124+
st.uint64: lambda content: (
125+
st.uint64(int.from_bytes(content[:8], byteorder="little", signed=False)),
126+
content[8:],
127+
),
113128
st.uint128: lambda content: (
114129
st.uint128(int.from_bytes(content[:16], byteorder="little", signed=False)),
115130
content[16:],
116131
),
117-
st.int8: lambda content: (st.int8(int.from_bytes(content[:1], byteorder="little", signed=True)), content[1:],),
118-
st.int16: lambda content: (st.int16(int.from_bytes(content[:2], byteorder="little", signed=True)), content[2:],),
119-
st.int32: lambda content: (st.int32(int.from_bytes(content[:4], byteorder="little", signed=True)), content[4:],),
120-
st.int64: lambda content: (st.int64(int.from_bytes(content[:8], byteorder="little", signed=True)), content[8:],),
132+
st.int8: lambda content: (
133+
st.int8(int.from_bytes(content[:1], byteorder="little", signed=True)),
134+
content[1:],
135+
),
136+
st.int16: lambda content: (
137+
st.int16(int.from_bytes(content[:2], byteorder="little", signed=True)),
138+
content[2:],
139+
),
140+
st.int32: lambda content: (
141+
st.int32(int.from_bytes(content[:4], byteorder="little", signed=True)),
142+
content[4:],
143+
),
144+
st.int64: lambda content: (
145+
st.int64(int.from_bytes(content[:8], byteorder="little", signed=True)),
146+
content[8:],
147+
),
121148
st.int128: lambda content: (
122149
st.int128(int.from_bytes(content[:16], byteorder="little", signed=True)),
123150
content[16:],

0 commit comments

Comments
 (0)