-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
708 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Cairo Contracts | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
fmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Scarb | ||
uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.8.2" | ||
|
||
- name: Check cairo format | ||
run: scarb fmt --check | ||
working-directory: onchain | ||
|
||
- name: Build cairo onchain | ||
run: scarb build | ||
working-directory: onchain | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@main | ||
|
||
- name: Set up Scarb | ||
uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.8.2" | ||
|
||
- name: Set up SNForge | ||
uses: foundry-rs/setup-snfoundry@v3 | ||
with: | ||
starknet-foundry-version: "0.30.0" | ||
|
||
- name: Run tests and generate report | ||
run: snforge test | ||
working-directory: onchain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Contracts Coverage | ||
|
||
on: | ||
# Trigger the workflow on pushes to only the 'main' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) | ||
push: | ||
branches: [ main ] | ||
# Trigger the workflow on any pull request | ||
pull_request: | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
coverage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@main | ||
|
||
- name: Set up Scarb | ||
uses: software-mansion/setup-scarb@v1 | ||
with: | ||
scarb-version: "2.8.2" | ||
|
||
- name: Set up SNForge | ||
uses: foundry-rs/setup-snfoundry@v3 | ||
with: | ||
starknet-foundry-version: "0.30.0" | ||
|
||
- name: Set up cairo-coverage | ||
run: curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh | ||
|
||
- name: Run tests and generate report | ||
run: cd onchain/ && snforge test --coverage | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
file: ./coverage.lcov | ||
token: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,116 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "openzeppelin" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_access", | ||
"openzeppelin_account", | ||
"openzeppelin_governance", | ||
"openzeppelin_introspection", | ||
"openzeppelin_merkle_tree", | ||
"openzeppelin_presets", | ||
"openzeppelin_security", | ||
"openzeppelin_token", | ||
"openzeppelin_upgrades", | ||
"openzeppelin_utils", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_access" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_introspection", | ||
"openzeppelin_utils", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_account" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_introspection", | ||
"openzeppelin_utils", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_governance" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_access", | ||
"openzeppelin_introspection", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_introspection" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
|
||
[[package]] | ||
name = "openzeppelin_merkle_tree" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
|
||
[[package]] | ||
name = "openzeppelin_presets" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_access", | ||
"openzeppelin_account", | ||
"openzeppelin_introspection", | ||
"openzeppelin_token", | ||
"openzeppelin_upgrades", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_security" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
|
||
[[package]] | ||
name = "openzeppelin_token" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
dependencies = [ | ||
"openzeppelin_account", | ||
"openzeppelin_governance", | ||
"openzeppelin_introspection", | ||
] | ||
|
||
[[package]] | ||
name = "openzeppelin_upgrades" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
|
||
[[package]] | ||
name = "openzeppelin_utils" | ||
version = "0.16.0" | ||
source = "git+https://github.com/openzeppelin/cairo-contracts?tag=v0.16.0#ba00ce76a93dcf25c081ab2698da20690b5a1cfb" | ||
|
||
[[package]] | ||
name = "peach" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"openzeppelin", | ||
"snforge_std", | ||
] | ||
|
||
[[package]] | ||
name = "snforge_scarb_plugin" | ||
version = "0.2.0" | ||
source = "registry+https://scarbs.xyz/" | ||
checksum = "sha256:2e4ce3ebe3f49548bd26908391b5d78537a765d827df0d96c32aeb88941d0d67" | ||
|
||
[[package]] | ||
name = "snforge_std" | ||
version = "0.30.0" | ||
source = "registry+https://scarbs.xyz/" | ||
checksum = "sha256:2f3c4846881813ac0f5d1460981249c9f5e2a6831e752beedf9b70975495b4ec" | ||
dependencies = [ | ||
"snforge_scarb_plugin", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod peach; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod interface; | ||
pub mod peach; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use starknet::{ContractAddress, ClassHash}; | ||
|
||
#[derive(Copy, Drop, Serde, starknet::Store)] | ||
pub struct TicketTierParams { | ||
pub price: u256, | ||
pub max_supply: u32, | ||
} | ||
|
||
#[derive(Copy, Drop, Serde, starknet::Store)] | ||
pub struct TicketTier { | ||
pub params: TicketTierParams, | ||
pub supply: u32, | ||
} | ||
|
||
#[derive(Copy, Drop, Serde)] | ||
pub struct PeachEvent { | ||
pub id: u64, | ||
pub ticket_tiers_params: Span<TicketTierParams>, | ||
pub treasury_address: ContractAddress, | ||
} | ||
|
||
#[starknet::interface] | ||
pub trait IPeach<TState> { | ||
fn get_treasury_address(self: @TState, event_id: u64) -> Option<ContractAddress>; | ||
fn get_ticket_tier(self: @TState, event_id: u64, ticket_tier_id: u8) -> Option<TicketTier>; | ||
|
||
fn create_event(ref self: TState, event: PeachEvent); | ||
fn buy_ticket(ref self: TState, event_id: u64, ticket_tier_id: u8, recipient: ContractAddress, amount: u32); | ||
} | ||
|
||
#[starknet::interface] | ||
pub trait PeachABI<TState> { | ||
// IPeach | ||
fn get_treasury_address(self: @TState, event_id: u64) -> Option<ContractAddress>; | ||
fn get_ticket_tier(self: @TState, event_id: u64, ticket_tier_id: u8) -> Option<TicketTier>; | ||
fn create_event(ref self: TState, event: PeachEvent); | ||
fn buy_ticket(ref self: TState, event_id: u64, ticket_tier_id: u8, recipient: ContractAddress, amount: u32); | ||
|
||
// IERC1155 | ||
fn balance_of(self: @TState, account: ContractAddress, token_id: u256) -> u256; | ||
fn balance_of_batch(self: @TState, accounts: Span<ContractAddress>, token_ids: Span<u256>) -> Span<u256>; | ||
fn safe_transfer_from( | ||
ref self: TState, from: ContractAddress, to: ContractAddress, token_id: u256, value: u256, data: Span<felt252> | ||
); | ||
fn safe_batch_transfer_from( | ||
ref self: TState, | ||
from: ContractAddress, | ||
to: ContractAddress, | ||
token_ids: Span<u256>, | ||
values: Span<u256>, | ||
data: Span<felt252> | ||
); | ||
fn is_approved_for_all(self: @TState, owner: ContractAddress, operator: ContractAddress) -> bool; | ||
fn set_approval_for_all(ref self: TState, operator: ContractAddress, approved: bool); | ||
|
||
// ISRC5 | ||
fn supports_interface(self: @TState, interface_id: felt252) -> bool; | ||
|
||
// IERC1155MetadataURI | ||
fn uri(self: @TState, token_id: u256) -> ByteArray; | ||
|
||
// IERC1155Camel | ||
fn balanceOf(self: @TState, account: ContractAddress, tokenId: u256) -> u256; | ||
fn balanceOfBatch(self: @TState, accounts: Span<ContractAddress>, tokenIds: Span<u256>) -> Span<u256>; | ||
fn safeTransferFrom( | ||
ref self: TState, from: ContractAddress, to: ContractAddress, tokenId: u256, value: u256, data: Span<felt252> | ||
); | ||
fn safeBatchTransferFrom( | ||
ref self: TState, | ||
from: ContractAddress, | ||
to: ContractAddress, | ||
tokenIds: Span<u256>, | ||
values: Span<u256>, | ||
data: Span<felt252> | ||
); | ||
fn isApprovedForAll(self: @TState, owner: ContractAddress, operator: ContractAddress) -> bool; | ||
fn setApprovalForAll(ref self: TState, operator: ContractAddress, approved: bool); | ||
|
||
// IOwnable | ||
fn owner(self: @TState) -> ContractAddress; | ||
fn transfer_ownership(ref self: TState, new_owner: ContractAddress); | ||
fn renounce_ownership(ref self: TState); | ||
|
||
// IOwnableCamelOnly | ||
fn transferOwnership(ref self: TState, newOwner: ContractAddress); | ||
fn renounceOwnership(ref self: TState); | ||
|
||
// IUpgradeable | ||
fn upgrade(ref self: TState, new_class_hash: ClassHash); | ||
} |
Oops, something went wrong.