Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Adapt to work with cairo-lang v0.6.2 (#19)
Browse files Browse the repository at this point in the history
* Adapt to work with cairo-lang v0.6.2

* Set plugin-test no_output_timeout to 1m

* Use settings.ini in test-plugin.sh

* Install plugin from source
  • Loading branch information
FabijanC authored Dec 15, 2021
1 parent de26174 commit 8ba43cb
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 16 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- run:
name: Test plugin
command: ./scripts/test-plugin.sh
no_output_timeout: 1m
package_build_and_publish:
docker:
- image: cimg/python:3.7
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["starknet", "cairo", "testnet", "local", "server"]
python = "^3.7"
Flask = {extras = ["async"], version = "^2.0.2"}
flask-cors = "^3.0.10"
cairo-lang = "0.6.1"
cairo-lang = "0.6.2"

[tool.poetry.dev-dependencies]

Expand Down
11 changes: 10 additions & 1 deletion scripts/setup-example.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#!/bin/bash
set -e

echo "Cloning branch 'devnet'"
echo "Installing starknet-hardhat-plugin from source"
git clone -b master --single-branch [email protected]:Shard-Labs/starknet-hardhat-plugin.git
cd starknet-hardhat-plugin
npm ci
npm run build
npm link
cd ..

echo "Cloning starknet-hardhat-example branch 'devnet'"
git clone -b devnet --single-branch [email protected]:Shard-Labs/starknet-hardhat-example.git
cd starknet-hardhat-example
npm ci
npm link @shardlabs/starknet-hardhat-plugin

# generate artifacts
npx hardhat starknet-compile
4 changes: 2 additions & 2 deletions scripts/test-cli-auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ echo "tx_hash: $deploy_tx_hash"

# inspects status from tx_status object
deploy_tx_status=$(starknet tx_status --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".tx_status" -r)
if [ "$deploy_tx_status" != "PENDING" ]; then
if [ "$deploy_tx_status" != "ACCEPTED_ON_L2" ]; then
echo "Wrong tx_status: $deploy_tx_status"
exit 2
fi

# inspects status from tx object
deploy_tx_status2=$(starknet get_transaction --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".status" -r)
if [ "$deploy_tx_status2" != "PENDING" ]; then
if [ "$deploy_tx_status2" != "ACCEPTED_ON_L2" ]; then
echo "Wrong status in tx: $deploy_tx_status2"
exit 2
fi
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ echo "tx_hash: $deploy_tx_hash"

# inspects status from tx_status object
deploy_tx_status=$(starknet tx_status --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".tx_status" -r)
if [ "$deploy_tx_status" != "PENDING" ]; then
if [ "$deploy_tx_status" != "ACCEPTED_ON_L2" ]; then
echo "Wrong tx_status: $deploy_tx_status"
exit 2
fi

# inspects status from tx object
deploy_tx_status2=$(starknet get_transaction --hash $deploy_tx_hash --feeder_gateway_url $FEEDER_GATEWAY_URL | jq ".status" -r)
if [ "$deploy_tx_status2" != "PENDING" ]; then
if [ "$deploy_tx_status2" != "ACCEPTED_ON_L2" ]; then
echo "Wrong status in tx: $deploy_tx_status2"
exit 2
fi
Expand Down
6 changes: 4 additions & 2 deletions scripts/test-plugin.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash
set -e

source scripts/settings.ini
[ -f .env ] && source .env

trap 'kill $(jobs -p)' EXIT

poetry run starknet-devnet --host=localhost --port=5000 &
GATEWAY_URL=http://localhost:5000
poetry run starknet-devnet --host="$host" --port="$port" &
sleep 1 # give the server some time to get up

function extract_address () {
Expand Down
2 changes: 1 addition & 1 deletion starknet_devnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def add_transaction():

tx_type = transaction.tx_type.name
result_dict = {}
status = TxStatus.PENDING
status = TxStatus.ACCEPTED_ON_L2
error_message = None

if tx_type == TransactionType.DEPLOY.name:
Expand Down
11 changes: 7 additions & 4 deletions starknet_devnet/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ class TxStatus(Enum):
According to: https://www.cairo-lang.org/docs/hello_starknet/intro.html#interact-with-the-contract
"""

PENDING = auto()
"""The transaction passed the validation and is waiting to be sent on-chain."""

NOT_RECEIVED = auto()
"""The transaction has not been received yet (i.e., not written to storage"""

RECEIVED = auto()
"""The transaction was received by the operator."""

PENDING = auto()
"""The transaction passed the validation and entered the pending block."""

REJECTED = auto()
"""The transaction failed validation and thus was skipped."""

ACCEPTED_ONCHAIN = auto()
ACCEPTED_ON_L2 = auto()
"""The transaction passed the validation and entered an actual created block."""

ACCEPTED_ON_L1 = auto()
"""The transaction was accepted on-chain."""

def custom_int(arg: str) -> str:
Expand Down

0 comments on commit 8ba43cb

Please sign in to comment.