Skip to content

Commit

Permalink
Clean up and system object script
Browse files Browse the repository at this point in the history
  • Loading branch information
gdanezis committed Jun 6, 2024
1 parent dcead3d commit 52a68bd
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# mdBook
build/

# Python
__pycache__/
*.pyc

# Misc
*.key
.env
Expand Down
34 changes: 34 additions & 0 deletions examples/CONFIG/config_dir/client_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
system_pkg: 0x17108fb344dbea0d315e6f44cdd3af12a028cd568bafcbfb7f7a7b152719d15d
system_object: 0x3fb18e675ad41158f59acbdb7f574136a198cbd83be9b968c0fdeaa139c312f9
wallet_config: null

# Default values for the client are commented out.
#
# There is no risk in playing aroud with these values.
# Worst case, you may not be able to store/read from Walrus.

# communication_config:
# max_concurrent_writes: null
# max_concurrent_sliver_reads: null
# max_concurrent_metadata_reads: 3
# reqwest_config:
# total_timeout:
# secs: 180
# nanos: 0
# pool_idle_timeout: null
# http2_keep_alive_timeout:
# secs: 5
# nanos: 0
# http2_keep_alive_interval:
# secs: 30
# nanos: 0
# http2_keep_alive_while_idle: true
# request_rate_config:
# max_node_connections: 10
# max_retries: 5
# min_backoff:
# secs: 2
# nanos: 0
# max_backoff:
# secs: 60
# nanos: 0
2 changes: 1 addition & 1 deletion examples/python/hello_walrus_jsonapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from utils import num_to_blob_id

PATH_TO_WALRUS = "../CONFIG/bin/walrus"
PATH_TO_WALRUS_CONFIG = "../CONFIG/working_dir/client_config.yaml"
PATH_TO_WALRUS_CONFIG = "../CONFIG/config_dir/client_config.yaml"

try:

Expand Down
45 changes: 45 additions & 0 deletions examples/python/hello_walrus_sui_system.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Example of querying the Walrus system object on Sui
#
# Prerequisites:
#
# - Configure Walrus
# see: TODO
#
# - Update the paths PATH_TO_WALRUS_CONFIG below
#

# Std lib imports
import requests
import re

PATH_TO_WALRUS_CONFIG = "../CONFIG/config_dir/client_config.yaml"

system_object_id = re.findall(r"system_object:[ ]*(.*)", open(PATH_TO_WALRUS_CONFIG).read())[0]
print(f'System object ID: {system_object_id}')
# Part 3. Check the availability of the blob
request = {
"jsonrpc": "2.0",
"id": 1,
"method": "sui_getObject",
"params": [
system_object_id,
{
"showType": True,
"showOwner": False,
"showPreviousTransaction": True,
"showDisplay": False,
"showContent": True,
"showBcs": False,
"showStorageRebate": False
}
]
}
response = requests.post("https://fullnode.testnet.sui.io:443", json=request)
system_object_content = response.json()["result"]["data"]["content"]["fields"]
committee = system_object_content["current_committee"]["fields"]["bls_committee"]["fields"]

print(f'Current walrus epoch: {system_object_content["current_committee"]["fields"]["epoch"]}')
print(f'Number of members: {len(committee["members"])} Number of shards: {committee["n_shards"]}')
print(f'Price per unit size: {system_object_content["price_per_unit_size"]} MIST')
print(f'Total capacity size: {system_object_content["total_capacity_size"]} bytes')
print(f'Used capacity size: {system_object_content["used_capacity_size"]} bytes')
2 changes: 1 addition & 1 deletion examples/python/hello_walrus_webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# see: TODO
#
# - Run the Walrus client in daemon mode:
# $ walrus --config working_dir/client_config.yaml daemon -b 127.0.0.1:8899
# $ walrus --config config_dir/client_config.yaml daemon -b 127.0.0.1:8899
#

# Std lib imports
Expand Down

0 comments on commit 52a68bd

Please sign in to comment.