-
Notifications
You must be signed in to change notification settings - Fork 18
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
0 parents
commit ebf1779
Showing
19 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 @@ | ||
* @drspacemn @glihm |
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,11 @@ | ||
--- | ||
name: Feature request | ||
about: suggest new feature | ||
title: "[feat] " | ||
labels: "feature" | ||
assignees: "" | ||
--- | ||
|
||
<!-- feature description --> | ||
|
||
#### References |
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,13 @@ | ||
--- | ||
name: Bug report | ||
about: create bug report | ||
title: "[bug] " | ||
labels: "bug" | ||
assignees: "" | ||
--- | ||
|
||
**ver:** | ||
|
||
<!-- reproducible report(current vs expected behavior) --> | ||
|
||
**How to reproduce:** |
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,7 @@ | ||
--- | ||
name: Codebase improvement | ||
about: docs, ci, tooling, other | ||
title: "[dev] " | ||
labels: "dev" | ||
assignees: "" | ||
--- |
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,8 @@ | ||
<!-- enter the gh issue after hash --> | ||
|
||
- [ ] issue # | ||
- [ ] follows contribution [guide](../CONTRIBUTING.md) | ||
- [ ] code change includes tests | ||
- [ ] breaking change | ||
|
||
<!-- PR description below --> |
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,4 @@ | ||
all | ||
# lame rules | ||
exclude_rule 'MD002' | ||
exclude_rule 'MD041' |
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,10 @@ | ||
all | ||
# allow inline HTML for README fmt | ||
exclude_rule 'MD033' | ||
# badges trigger rule | ||
exclude_rule 'MD034' | ||
# README img serves as 'First Header' | ||
exclude_rule 'MD002' | ||
exclude_rule 'MD041' | ||
# TODO: disable/enable not working for all-contribs | ||
exclude_rule 'MD013' |
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,18 @@ | ||
name: build | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: read-all | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: asdf-vm/actions/install@v3 | ||
- run: scarb fmt --check | ||
- run: scarb build |
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,26 @@ | ||
name: check | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
permissions: read-all | ||
|
||
jobs: | ||
markdown: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: | | ||
sudo gem install mdl | ||
mdl -s .github/linter/readme_style.rb README.md | ||
mdl -s .github/linter/base_style.rb book .github | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: asdf-vm/actions/install@v3 | ||
- run: snforge test |
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,10 @@ | ||
# Sys files | ||
**/.DS_Store | ||
|
||
# Scarb and Starknet Foundry | ||
**/target | ||
.snfoundry_cache/ | ||
|
||
# Starkli | ||
**/account.json | ||
**/keystore.json |
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 @@ | ||
scarb 2.4.4 | ||
starknet-foundry 0.16.0 |
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,58 @@ | ||
## 🛠️ Contributing to Piltover 🛠️ | ||
|
||
Welcome, contributing to `piltover` is easy! | ||
|
||
1. Submit or comment your intent on an issue | ||
1. We will try to respond quickly | ||
1. Fork this repo | ||
1. Submit your PR against `main` | ||
1. Address PR Review | ||
|
||
### Issue | ||
|
||
Project tracking is done via GitHub [issues](https://github.com/keep-starknet-strange/piltover/issues). | ||
First look at open issues to see if your request is already submitted. | ||
If it is comment on the issue requesting assignment, if not open an issue. | ||
|
||
We use 3 issue labels for development: | ||
|
||
- `feat` -> suggest new feature | ||
- `bug` -> create a reproducible bug report | ||
- `dev` -> non-functional repository changes | ||
|
||
These labels are used as prefixes as follows for `issue`, `branch name`, `pr title`: | ||
|
||
- `[feat]` -> `feat/{issue #}-{issue name}` -> `feat:` | ||
- `[bug]` -> `bug/{issue #}-{issue name}` -> `bug:` | ||
- `[dev]` -> `dev/{issue #}-{issue name}` -> `dev:` | ||
|
||
### Submit PR | ||
|
||
Ensure your code is well formatted, well tested and well documented. A core contributor | ||
will review your work. Address changes, ensure ci passes, | ||
and voilà you're a piltover contributor. | ||
|
||
Markdown [linter](https://github.com/markdownlint/markdownlint?tab=readme-ov-file#markdown-lint-tool): | ||
|
||
```bash | ||
mdl -s .github/linter/readme_style.rb README.md | ||
``` | ||
|
||
Scarb linter: | ||
|
||
```bash | ||
scarb fmt | ||
``` | ||
|
||
### Additional Resources | ||
|
||
- [Cairo Book](https://book.cairo-lang.org/) | ||
- [Starknet Book](https://book.starknet.io/) | ||
- [Starknet Foundry Book](https://foundry-rs.github.io/starknet-foundry/) | ||
- [Starknet By Example](https://starknet-by-example.voyager.online/) | ||
- [Starkli Book](https://book.starkli.rs/) | ||
- [Syncing a Fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork) | ||
|
||
## | ||
|
||
Thank you for your contribution! |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Keep Starknet Strange | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,29 @@ | ||
<div align="center"> | ||
<img src="book/src/assets/piltover.png" height="300"/> | ||
|
||
[![Check Workflow Status](https://github.com/keep-starknet-strange/blobstream-starknet/actions/workflows/check.yml/badge.svg)](https://github.com/keep-starknet-strange/blobstream-starknet/actions/workflows/check.yml) | ||
[![Build Workflow Status](https://github.com/keep-starknet-strange/blobstream-starknet/actions/workflows/build.yml/badge.svg)](https://github.com/keep-starknet-strange/blobstream-starknet/actions/workflows/build.yml) | ||
|
||
[![Exploration_Team](https://img.shields.io/badge/Exploration_Team-29296E.svg?&style=for-the-badge&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJhIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODEgMTgxIj48ZGVmcz48c3R5bGU+LmJ7ZmlsbDojZmZmO308L3N0eWxlPjwvZGVmcz48cGF0aCBjbGFzcz0iYiIgZD0iTTE3Ni43Niw4OC4xOGwtMzYtMzcuNDNjLTEuMzMtMS40OC0zLjQxLTIuMDQtNS4zMS0x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UuOGwxLjY4LTYuNzNjLjg0LTIuMTgsLjE1LTQuNjUtMS42OC02LjA5bC0xMi45NS0xNC4xMmMtLjY0LS40NS0xLjE0LTEuMDgtMS40Mi0xLjgxbDE5LjA0LDUuMTgsMi41OSwuNzhjMi4wNCwuNzYsNC4zMywuMTQsNS43LTEuNTVsMTIuOTUtMTQuMzhzLjc4LTEuMDQsMS42OC0xLjE3Yy0xLjgxLDYuNi0yLjk4LDE0LjEyLTUuNDQsMjAuNDYtMS4wOCwyLjk2LS4wOCw2LjI4LDIuNDYsOC4xNiw0LjI3LDQuMTQsOC4yOSw4LjU1LDEyLjk1LDEyLjk1LDAsMCwxLjMsLjkxLDEuNDIsMi4wN2wtMTMuMzQtMy42M1oiLz48L3N2Zz4=)](https://github.com/keep-starknet-strange) | ||
|
||
</div> | ||
|
||
## Overview | ||
|
||
Starknet Core Contract components in Cairo. | ||
|
||
## Build | ||
|
||
To build the project, run: | ||
|
||
```bash | ||
scarb build | ||
``` | ||
|
||
## Test | ||
|
||
To test the project, run: | ||
|
||
```bash | ||
snforge test | ||
``` |
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,14 @@ | ||
# Code generated by scarb DO NOT EDIT. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "piltover" | ||
version = "0.1.0" | ||
dependencies = [ | ||
"snforge_std", | ||
] | ||
|
||
[[package]] | ||
name = "snforge_std" | ||
version = "0.16.0" | ||
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.16.0#f58e0ab42b6095b7d0cb841ede595aecbc9cb45d" |
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,11 @@ | ||
[package] | ||
name = "piltover" | ||
version = "0.1.0" | ||
edition = "2023_10" | ||
|
||
[dependencies] | ||
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.16.0" } | ||
starknet = "2.4.4" | ||
|
||
[[target.starknet-contract]] | ||
casm = true |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
#[starknet::interface] | ||
trait IHelloStarknet<TContractState> { | ||
fn increase_balance(ref self: TContractState, amount: felt252); | ||
fn get_balance(self: @TContractState) -> felt252; | ||
} | ||
|
||
#[starknet::contract] | ||
mod HelloStarknet { | ||
#[storage] | ||
struct Storage { | ||
balance: felt252, | ||
} | ||
|
||
#[abi(embed_v0)] | ||
impl HelloStarknetImpl of super::IHelloStarknet<ContractState> { | ||
fn increase_balance(ref self: ContractState, amount: felt252) { | ||
assert(amount != 0, 'Amount cannot be 0'); | ||
self.balance.write(self.balance.read() + amount); | ||
} | ||
|
||
fn get_balance(self: @ContractState) -> felt252 { | ||
self.balance.read() | ||
} | ||
} | ||
} |
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 @@ | ||
use starknet::ContractAddress; | ||
|
||
use snforge_std::{declare, ContractClassTrait}; | ||
|
||
use piltover::IHelloStarknetSafeDispatcher; | ||
use piltover::IHelloStarknetSafeDispatcherTrait; | ||
use piltover::IHelloStarknetDispatcher; | ||
use piltover::IHelloStarknetDispatcherTrait; | ||
|
||
fn deploy_contract(name: felt252) -> ContractAddress { | ||
let contract = declare(name); | ||
contract.deploy(@ArrayTrait::new()).unwrap() | ||
} | ||
|
||
#[test] | ||
fn test_increase_balance() { | ||
let contract_address = deploy_contract('HelloStarknet'); | ||
|
||
let dispatcher = IHelloStarknetDispatcher { contract_address }; | ||
|
||
let balance_before = dispatcher.get_balance(); | ||
assert(balance_before == 0, 'Invalid balance'); | ||
|
||
dispatcher.increase_balance(42); | ||
|
||
let balance_after = dispatcher.get_balance(); | ||
assert(balance_after == 42, 'Invalid balance'); | ||
} | ||
|
||
#[test] | ||
fn test_cannot_increase_balance_with_zero_value() { | ||
let contract_address = deploy_contract('HelloStarknet'); | ||
|
||
let safe_dispatcher = IHelloStarknetSafeDispatcher { contract_address }; | ||
|
||
let balance_before = safe_dispatcher.get_balance().unwrap(); | ||
assert(balance_before == 0, 'Invalid balance'); | ||
|
||
match safe_dispatcher.increase_balance(0) { | ||
Result::Ok(_) => panic_with_felt252('Should have panicked'), | ||
Result::Err(panic_data) => { | ||
assert(*panic_data.at(0) == 'Amount cannot be 0', *panic_data.at(0)); | ||
} | ||
}; | ||
} |