Skip to content

Commit

Permalink
Merge pull request #1 from nzpr/update
Browse files Browse the repository at this point in the history
Update to the latest legacy code
  • Loading branch information
nzpr authored Feb 11, 2024
2 parents 54bc8cd + 41e6d2a commit ff762b8
Show file tree
Hide file tree
Showing 31 changed files with 3,239 additions and 12,845 deletions.
8 changes: 5 additions & 3 deletions examples/client_insert_signed.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# https://github.com/tgrospic/rnode-client-js/blob/master/src/nodejs/client-insert-signed.js
# the logic below mostly copied from the logic of the link above

from rchain.crypto import PrivateKey, blake2b_32
from rchain.client import RClient
from rchain.pb.RhoTypes_pb2 import Par, Expr, ETuple, Bundle, GPrivate, GUnforgeable
from rchain.crypto import PrivateKey
from rchain.pb.RhoTypes_pb2 import (
Bundle, ETuple, Expr, GPrivate, GUnforgeable, Par,
)

host = "localhost"
port = 40402
Expand Down Expand Up @@ -53,4 +55,4 @@
}}
""".format(publicKeyHex=publicKeyHex, nonce=nonce, signatureHex=signatureHex)

print(contract)
print(contract)
14 changes: 6 additions & 8 deletions examples/grpc_api_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import time

import grpc

from rchain.client import RClient
from rchain.crypto import PrivateKey

Expand All @@ -20,6 +18,7 @@

admin_key = PrivateKey.generate()
contract = "@1!(2)"
shard_id = 'root-shard'

exploratory_term = 'new return in{return!("a")}'

Expand All @@ -41,23 +40,22 @@
assert client.is_finalized(block_hash)

# get blocks from blockNumber 10 to blockNumber 20
block_at_heights = client.get_blocks_by_heights(last_finalize_block.blockInfo.blockNumber, last_finalize_block.blockInfo.blockNumber+10)
block_at_heights = client.get_blocks_by_heights(last_finalize_block.blockInfo.blockNumber,
last_finalize_block.blockInfo.blockNumber + 10)

# exploratory deploy can only used for read-only node
# this method is for exploring the data in the tuple space
result = client.exploratory_deploy(exploratory_term, last_finalize_block.blockInfo.blockHash)

# find deploy by the deploy id
block_deploy = client.find_deploy(find_deploy)

block_deploy = client.find_deploy(find_deploy)

# only valid validator can process deploy request
# all the methods above can be processed by the validator except exploratory deploy
with RClient(MAINNET_SERVER[1], 40401) as client:

# normal deploy
deploy_id = client.deploy(key=admin_key, term=contract, phlo_price=1, phlo_limit=1000000, valid_after_block_no=100,
timestamp_millis=int(time.time() * 1000))
timestamp_millis=int(time.time() * 1000), shard_id=shard_id)
# deploy with validate after block number argument
# the difference between `deploy` and `deploy_with_vabn_filled` is that
# valid after block number is not auto filled by fetching the newest block number which would be assure
Expand All @@ -66,6 +64,6 @@
deploy_id2 = client.deploy_with_vabn_filled(key=admin_key,
term=contract,
phlo_price=1, phlo_limit=1000000,
timestamp_millis=int(time.time() * 1000))
timestamp_millis=int(time.time() * 1000), shard_id=shard_id)
# this will raise a exception
client.exploratory_deploy(exploratory_term, last_finalize_block.blockInfo.blockHash)
Loading

0 comments on commit ff762b8

Please sign in to comment.