Skip to content

Commit

Permalink
feat: ci for fmt and testing, + new cairo edition (#1)
Browse files Browse the repository at this point in the history
* ci for fmt and testing,  + new cairo edition

* remove go fmt

* add badge

* badge fmt
  • Loading branch information
drspacemn authored Sep 11, 2024
1 parent cc86a08 commit 53604fb
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @drspacemn @zackattax
26 changes: 26 additions & 0 deletions .github/workflows/check.yml
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:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scarb fmt --check
working-directory: contracts

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: asdf-vm/actions/install@v3
- run: scarb test
working-directory: contracts
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Kudos

[![Check Workflow Status](https://github.com/keep-starknet-strange/kudos/actions/workflows/check.yml/badge.svg)](https://github.com/keep-starknet-strange/kudos/actions/workflows/check.yml)

An internal application to delegate `kudos` on Starknet by using Google OAuth.

## API
Expand Down
4 changes: 2 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package main

import (
import (
"github.com/gin-gonic/gin"
"github.com/keep-starknet-strange/kudos/api/internal/config"
"github.com/keep-starknet-strange/kudos/api/internal/handlers"
"github.com/gin-gonic/gin"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion contracts/Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "kudos"
version = "0.1.0"
edition = "2023_11"
edition = "2024_07"

[scripts]
test = "snforge test"
Expand Down
28 changes: 15 additions & 13 deletions contracts/src/credential_registry/component.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ pub mod CredentialRegistryComponent {
use core::num::traits::zero::Zero;
use kudos::credential_registry::interface::ICredentialRegistry;
use openzeppelin::account::interface::{AccountABIDispatcherTrait, AccountABIDispatcher};
use starknet::storage::Map;
use starknet::storage::{
StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map
};
use starknet::{ContractAddress, contract_address_const, get_caller_address};

#[storage]
struct Storage {
pub struct Storage {
credentials: Map::<felt252, ContractAddress>,
user_to_credentials: Map::<ContractAddress, felt252>,
credentials_w_pin: Map::<felt252, ContractAddress>,
Expand Down Expand Up @@ -64,33 +66,33 @@ pub mod CredentialRegistryComponent {
fn get_credential(
self: @ComponentState<TContractState>, address: ContractAddress
) -> felt252 {
self.user_to_credentials.read(address)
self.user_to_credentials.entry(address).read()
}

fn get_credential_address(
self: @ComponentState<TContractState>, hash: felt252
) -> ContractAddress {
self.credentials.read(hash)
self.credentials.entry(hash).read()
}

fn get_credential_w_pin(
self: @ComponentState<TContractState>, address: ContractAddress
) -> felt252 {
self.user_to_credentials_w_pin.read(address)
self.user_to_credentials_w_pin.entry(address).read()
}

fn get_credential_address_w_pin(
self: @ComponentState<TContractState>, hash: felt252
) -> ContractAddress {
self.credentials_w_pin.read(hash)
self.credentials_w_pin.entry(hash).read()
}

fn get_total_credentials(self: @ComponentState<TContractState>) -> u128 {
self.total_credentials.read()
}

fn is_registered(self: @ComponentState<TContractState>, address: ContractAddress) -> bool {
self.user_to_credentials.read(address).is_non_zero()
self.user_to_credentials.entry(address).read().is_non_zero()
}
}

Expand All @@ -105,7 +107,7 @@ pub mod CredentialRegistryComponent {
signature: Array<felt252>
) {
assert(
self.credentials.read(hash) == contract_address_const::<0>(),
self.credentials.entry(hash).read() == contract_address_const::<0>(),
CredentialRegistryErrors::CREDENTIAL_REGISTERED
);

Expand All @@ -115,8 +117,8 @@ pub mod CredentialRegistryComponent {
CredentialRegistryErrors::INVALID_SIGNATURE
);

self.credentials.write(hash, contract_address);
self.user_to_credentials.write(contract_address, hash);
self.credentials.entry(hash).write(contract_address);
self.user_to_credentials.entry(contract_address).write(hash);
}

fn _register_credential_w_pin(
Expand All @@ -126,7 +128,7 @@ pub mod CredentialRegistryComponent {
signature: Array<felt252>
) {
assert(
self.credentials_w_pin.read(hash) == contract_address_const::<0>(),
self.credentials_w_pin.entry(hash).read() == contract_address_const::<0>(),
CredentialRegistryErrors::CREDENTIAL_W_PIN_REGISTERED
);

Expand All @@ -136,8 +138,8 @@ pub mod CredentialRegistryComponent {
CredentialRegistryErrors::INVALID_SIGNATURE
);

self.credentials_w_pin.write(hash, contract_address);
self.user_to_credentials_w_pin.write(contract_address, hash);
self.credentials_w_pin.entry(hash).write(contract_address);
self.user_to_credentials_w_pin.entry(contract_address).write(hash);
}
}
}

0 comments on commit 53604fb

Please sign in to comment.