feat(target_chains/starknet): create project

This commit is contained in:
Pavel Strakhov 2024-04-05 17:25:24 +01:00
parent b4ed825cd6
commit 2c7dfa92dd
6 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1 @@
target

View File

@ -0,0 +1,6 @@
# Code generated by scarb DO NOT EDIT.
version = 1
[[package]]
name = "pyth"
version = "0.1.0"

View File

@ -0,0 +1,9 @@
[package]
name = "pyth"
version = "0.1.0"
edition = "2023_11"
[dependencies]
starknet = ">=2.5.4"
[[target.starknet-contract]]

View File

@ -0,0 +1,2 @@
mod pyth;
mod wormhole;

View File

@ -0,0 +1,29 @@
#[starknet::interface]
trait IPyth<T> {
fn get_name(self: @T) -> felt252;
fn set_name(ref self: T, name: felt252);
}
#[starknet::contract]
mod pyth {
#[storage]
struct Storage {
name: felt252,
}
#[constructor]
fn constructor(ref self: ContractState, name: felt252) {
self.name.write(name);
}
#[abi(embed_v0)]
impl HelloImpl of super::IPyth<ContractState> {
fn get_name(self: @ContractState) -> felt252 {
self.name.read() + 1
}
fn set_name(ref self: ContractState, name: felt252) {
self.name.write(name - 1);
}
}
}

View File

@ -0,0 +1,29 @@
#[starknet::interface]
trait IWormhole<T> {
fn get_value(self: @T) -> felt252;
fn set_value(ref self: T, name: felt252);
}
#[starknet::contract]
mod wormhole {
#[storage]
struct Storage {
name: felt252,
}
#[constructor]
fn constructor(ref self: ContractState, name: felt252) {
self.name.write(name);
}
#[abi(embed_v0)]
impl HelloImpl of super::IWormhole<ContractState> {
fn get_value(self: @ContractState) -> felt252 {
self.name.read() + 2
}
fn set_value(ref self: ContractState, name: felt252) {
self.name.write(name - 2);
}
}
}