Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contract): devnet testing and new events support #462

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ca8464c
contracts: update starknet-foundry to 0.30.0
ptisserand Sep 10, 2024
3923f5f
contracts: add event testing in create_order
ptisserand Sep 10, 2024
fa46d5a
contracts: don't emit anymore `OrderExecuted` directly from starknet …
ptisserand Sep 10, 2024
0ec898c
conntracts: remove OrderExecuted event in executor and use #[flat] fo…
ptisserand Sep 11, 2024
86bbf23
contracts: add test cases for create auction & collection offer orders
ptisserand Sep 11, 2024
fc8798d
contracts: move create_* to setup.cairo
ptisserand Sep 11, 2024
424736b
contracts: WIP cancel_order tests
ptisserand Sep 11, 2024
61aab3a
fix(contracts): ensure caller is the canceller & canceller is the off…
ptisserand Sep 11, 2024
b5dc967
contracts: add cancel_order tests
ptisserand Sep 11, 2024
6e5a008
fix(contracts): ensure an order with same hash can't be created twice
ptisserand Sep 12, 2024
3045d3e
contracts: add test case for expired orders creation
ptisserand Sep 12, 2024
d3b6d26
contracts(starknet): arkchain orderbook is no more used
ptisserand Sep 13, 2024
5efaf02
CI: run SDK test with devnet
ptisserand Sep 14, 2024
2f9b030
fix(CI): add missing shell property for action
ptisserand Sep 14, 2024
55b36cb
turbo: ARKCHAIN_RPC_URL is no more needed
ptisserand Sep 14, 2024
8ef8bbe
fix(CI): add missing step for devnet environment
ptisserand Sep 14, 2024
e234097
CI: starknet-devnet-rs 0.2.0 have been released
ptisserand Sep 19, 2024
91454d8
feat(diri): update indexer to support new event format.
ptisserand Sep 19, 2024
8a110e0
fix(diri): ensure events are handled sorted by block number
ptisserand Aug 23, 2024
3df7dcc
feat(diri): add BLOCK_START, BLOCK_END, BLOCK_RANGE and SLEEP_PERIOD …
ptisserand Sep 19, 2024
19d59ca
feat(diri): use clap to parse display-events arguments
ptisserand Sep 23, 2024
1358eda
feat(diri): add JSON output support in display-events
ptisserand Sep 24, 2024
e00e087
feat(diri): add `order_type` field
ptisserand Sep 24, 2024
c00fd82
feat(diri): move type conversion to orderbook/events
ptisserand Sep 24, 2024
82a3fbe
feat(diri): update JSON output and add missing end update
ptisserand Sep 24, 2024
df3b518
CI: add step to dump devnet state after contract deployment
ptisserand Sep 24, 2024
a5bcdb0
restore turbo.json & pnpm-lock
ptisserand Sep 24, 2024
3f148b2
CI: update command to run SDK tests
ptisserand Sep 24, 2024
3de7c7f
CI: run SDK fulfill action test and reset starknet devnet state
ptisserand Sep 24, 2024
7689a2a
CI: store devnet state after setArkFees has been called.
ptisserand Sep 24, 2024
785ab1d
display-events: add limit_wait_retries to end indexing when reached
ptisserand Sep 26, 2024
3167efb
feat(diri): add address filtering when fetching events
ptisserand Sep 30, 2024
c17a7e2
contracts(starknet): remove not more needed order info storage
ptisserand Oct 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .env.devnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Starknet RPC URL
STARKNET_RPC_URL=http://0.0.0.0:5050

## starknet-devnet-rs 0.2.0 account --seed 0
# Starknet accounts
STARKNET_ADMIN_ADDRESS_DEV=0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691
STARKNET_ADMIN_PRIVATE_KEY_DEV=0x0000000000000000000000000000000071d7bb07b9a64f6f78ac4c816aff4da9

STARKNET_ACCOUNT1_ADDRESS=0x78662e7352d062084b0010068b99288486c2d8b914f6e2a55ce945f8792c8b1
STARKNET_ACCOUNT1_PRIVATE_KEY=0x000000000000000000000000000000000e1406455b7d66b1690803be066cbe5e
STARKNET_ACCOUNT1_PUBLIC_KEY=0x007a1bb2744a7dd29bffd44341dbd78008adb4bc11733601e7eddff322ada9cb

STARKNET_ACCOUNT2_ADDRESS=0x49dfb8ce986e21d354ac93ea65e6a11f639c1934ea253e5ff14ca62eca0f38e
STARKNET_ACCOUNT2_PRIVATE_KEY=0x00000000000000000000000000000000a20a02f0ac53692d144b20cb371a60d7
STARKNET_ACCOUNT2_PUBLIC_KEY=0x00b8fd4ddd415902d96f61b7ad201022d495997c2dff8eb9e0eb86253e30fabc

STARKNET_ARK_RECEIVER_ADDRESS=0x4f348398f859a55a0c80b1446c5fdc37edb3a8478a32f10764659fc241027d3
STARKNET_ARK_RECEIVER_PRIVATE_KEY=0x00000000000000000000000000000000a641611c17d4d92bd0790074e34beeb7

STARKNET_ARK_COLLECTION_RECEIVER_ADDRESS=0xd513de92c16aa42418cf7e5b60f8022dbee1b4dfd81bcf03ebee079cfb5cb5
STARKNET_ARK_COLLECTION_RECEIVER_PRIVATE_KEY=0x000000000000000000000000000000005b4ac23628a5749277bcabbf4726b025

STARKNET_ARK_COLLECTION_2981_RECEIVER_ADDRESS=0x1e8c6c17efa3a047506c0b1610bd188aa3e3dd6c5d9227549b65428de24de78
STARKNET_ARK_COLLECTION_2981_RECEIVER_PRIVATE_KEY=0x00000000000000000000000000000000836203aceb0e9b0066138c321dda5ae6

STARKNET_LISTING_BROKER_ACCOUNT_ADDRESS=0x557ba9ef60b52dad611d79b60563901458f2476a5c1002a8b4869fcb6654c7e
STARKNET_LISTING_BROKER_ACCOUNT_PRIVATE_KEY=0x0000000000000000000000000000000015b5e3013d752c909988204714f1ff35

STARKNET_SALE_BROKER_ACCOUNT_ADDRESS=0x3736286f1050d4ba816b4d56d15d80ca74c1752c4e847243f1da726c36e06f
STARKNET_SALE_BROKER_ACCOUNT_PRIVATE_KEY=0x00000000000000000000000000000000a56597ba3378fa9e6440ea9ae0cf2865

SOLIS_ADMIN_ADDRESS_DEV=0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca
SOLIS_ADMIN_PRIVATE_KEY_DEV=0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a
SOLIS_ADMIN_PUBLIC_KEY_DEV=0x640466ebd2ce505209d3e5c4494b4276ed8f1cde764d757eb48831961f7cdea

SOLIS_ADMIN_ADDRESS=0x6b86e40118f29ebe393a75469b4d926c7a44c2e2681b6d319520b7c1156d114
SOLIS_ADMIN_PRIVATE_KEY=0x1c9053c053edf324aec366a34c6901b1095b07af69495bffec7d7fe21effb1b

# Starknet network
STARKNET_NETWORK_ID=dev
# Solis network
SOLIS_NETWORK_ID=dev

BROKER_ID=
36 changes: 36 additions & 0 deletions .github/actions/install-snforge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "Install contract dependencies"
description: "Install dependencies for smart contract"

env:
SCARB_VERSION: 2.7.1
STARKNET_FOUNDRY_VERSION: 0.30.0

runs:
using: "composite"
steps:
- name: Install universal sierra compiler
shell: bash
run: |
curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh
echo "/root/.local/bin" >> ${GITHUB_PATH}

- name: Check universal sierra compiler version
shell: bash
run: universal-sierra-compiler --version

- name: Setup Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: ${{ env.SCARB_VERSION }}

- name: Setup Starknet Foundry
uses: foundry-rs/setup-snfoundry@v3
with:
starknet-foundry-version: ${{ env.STARKNET_FOUNDRY_VERSION }}

- name: Set Up Stable Rust Toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

107 changes: 83 additions & 24 deletions .github/workflows/arkproject-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,106 @@ on:
paths:
- "contracts/**"

env:
SCARB_VERSION: 2.7.1
STARKNET_DEVNET_VERSION: 0.2.0
DEVNET_DUMP_PATH: /devnet-dump.json
DEVNET_DEPLOYMENT_DUMP_PATH: /tmp/devnet-deployment-dump.json
DEVNET_SET_FEES_DUMP_PATH: /tmp/devnet-set-fees-dump.json
jobs:
fmt:
runs-on: ubuntu-latest
name: Cairo formatting
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install universal sierra compiler
run: curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh
uses: actions/checkout@v4

- name: Setup Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: 2.7.1
scarb-version: ${{ env.SCARB_VERSION }}

- name: Check Scarb Formatting
run: cd contracts && scarb fmt --check
test:

forge-test:
runs-on: ubuntu-latest
name: Cairo starknet foundry tests
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install universal sierra compiler
run: curl -L https://raw.githubusercontent.com/software-mansion/universal-sierra-compiler/master/scripts/install.sh | sh
- name: Setup Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: 2.7.1
uses: actions/checkout@v4

- name: Setup Starknet Foundry
uses: foundry-rs/setup-snfoundry@v2
with:
starknet-foundry-version: 0.28.0
- name: Install starknet foundry & dependencies
uses: ./.github/actions/install-snforge

- name: Test contracts
run: cd contracts && snforge test

devnet-test:
runs-on: ubuntu-latest
name: Running SDK test with starknet-devnet
# needs: forge-test
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install starknet foundry & dependencies
uses: ./.github/actions/install-snforge

- name: Build smart contracts
run: cd contracts && scarb build --workspace

- name: Run starknet-devnet as a background process
run: |
docker run -d --rm --name starknet-devnet \
-p 5050:5050 \
shardlabs/starknet-devnet-rs:${STARKNET_DEVNET_VERSION} \
--seed 0 --dump-path $DEVNET_DUMP_PATH --dump-on exit --state-archive-capacity full
sleep 3 # Wait for 3 seconds for the Docker container to initialize

- name: Install SDK dependencies
uses: ./.github/actions/install-dependencies

- name: Setup environment for devnet
run: cp .env.devnet .env

- name: Deploy smart contract
run: pnpm deploy:starknet:local

- name: Store devnet state after contract deployment
run: |
curl -H "Content-type: application/json" \
-X POST http://localhost:5050/dump \
-d '{"path": "$DEVNET_DEPLOYMENT_DUMP_PATH"}'

- name: Setup environment
run: cp .env.devnet .env

- name: Run set Ark fees test
run: pnpm test --filter=core -- tests/setArkFees.test.ts

- name: Store devnet state after set ark fees
run: |
curl -H "Content-type: application/json" \
-X POST http://localhost:5050/dump \
-d '{"path": "$DEVNET_SET_FEES_DUMP_PATH"}'

- name: Test ark_common contracts
run: cd contracts/ark_common && snforge test
- name: Run fulfill auction test
run: |
pnpm test --filter=core -- tests/fulfillAuction.test.ts

- name: Restore devnet state
run: |
curl -H "Content-type: application/json" \
-X POST http://localhost:5050/load \
-d '{"path": "$DEVNET_SET_FEES_DUMP_PATH"}'

- name: Run SDK test
run: |
pnpm test --filter=core

- name: Test ark_orderbook contracts
run: cd contracts/ark_orderbook && snforge test
- name: Stop starknet-devnet container
if: always()
run: docker stop starknet-devnet

- name: Test ark_starknet contracts
run: cd contracts/ark_starknet && snforge test

- name: Test ark_tokens contracts
run: cd contracts/ark_tokens && snforge test
Loading
Loading