Skip to content

Commit

Permalink
Use RPC instead of Gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementWalter committed Sep 4, 2023
1 parent 6918c54 commit 63e9501
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/starksheet-cairo/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/withdraw_starksheet.py
13 changes: 8 additions & 5 deletions packages/starksheet-cairo/utils/starknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from utils.constants import (
BUILD_DIR,
BUILD_DIR_FIXTURES,
CLIENT,
CONTRACTS,
CONTRACTS_FIXTURES,
DEPLOYMENTS_DIR,
Expand Down Expand Up @@ -85,14 +84,18 @@ async def get_starknet_account(
selector=get_selector_from_name(selector),
calldata=[],
)
public_key = (await CLIENT.call_contract(call=call, block_hash="latest"))[0]
public_key = (
await RPC_CLIENT.call_contract(call=call, block_hash="latest")
)[0]
break
except Exception as err:
if (
err.message == "Client failed with code 40: Contract error."
or err.message
== "Client failed with code 21: Invalid message selector."
or "StarknetErrorCode.ENTRY_POINT_NOT_FOUND_IN_CONTRACT" in err.message
or err.message
== "Client failed with code -32603: Internal error: invalid entry point."
):
continue
else:
Expand All @@ -111,7 +114,7 @@ async def get_starknet_account(

return Account(
address=address,
client=CLIENT,
client=RPC_CLIENT,
chain=NETWORK["chain_id"],
key_pair=key_pair,
)
Expand Down Expand Up @@ -314,7 +317,7 @@ async def deploy_starknet_account(
class_hash=class_hash,
salt=salt,
key_pair=key_pair,
client=CLIENT,
client=RPC_CLIENT,
chain=NETWORK["chain_id"],
constructor_calldata=constructor_calldata,
max_fee=_max_fee,
Expand All @@ -336,7 +339,7 @@ async def declare(contract_name):
contract_class = create_compiled_contract(compiled_contract=compiled_contract)
class_hash = compute_class_hash(contract_class=deepcopy(contract_class))
try:
await CLIENT.get_class_by_hash(class_hash)
await RPC_CLIENT.get_class_by_hash(class_hash)
logger.info(f"✅ Class already declared, skipping")
return class_hash
except Exception:
Expand Down

0 comments on commit 63e9501

Please sign in to comment.