-
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.
chore: update to use new job runner (#16)
Co-authored-by: shekohex <[email protected]>
- Loading branch information
1 parent
7b27edf
commit 4a1b73b
Showing
9 changed files
with
1,757 additions
and
3,647 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Submodule forge-std
updated
24 files
+193 −0 | CONTRIBUTING.md | |
+17 −1 | README.md | |
+1 −1 | package.json | |
+12 −1 | scripts/vm.py | |
+4 −0 | src/StdChains.sol | |
+3 −3 | src/StdCheats.sol | |
+104 −0 | src/StdJson.sol | |
+1 −1 | src/StdStorage.sol | |
+104 −0 | src/StdToml.sol | |
+388 −73 | src/Vm.sol | |
+471 −463 | src/console.sol | |
+2 −2 | src/interfaces/IERC4626.sol | |
+693 −4 | src/safeconsole.sol | |
+1 −1 | test/StdAssertions.t.sol | |
+14 −12 | test/StdChains.t.sol | |
+10 −10 | test/StdCheats.t.sol | |
+12 −12 | test/StdError.t.sol | |
+1 −1 | test/StdJson.t.sol | |
+4 −14 | test/StdMath.t.sol | |
+13 −5 | test/StdStorage.t.sol | |
+1 −1 | test/StdStyle.t.sol | |
+1 −1 | test/StdToml.t.sol | |
+12 −12 | test/StdUtils.t.sol | |
+9 −6 | test/Vm.t.sol |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,47 @@ | ||
use gadget_sdk as sdk; | ||
use sdk::job; | ||
use gadget_sdk::tangle_subxt::tangle_testnet_runtime::api; | ||
use std::convert::Infallible; | ||
|
||
/// Returns "Hello World!" if `who` is `None`, otherwise returns "Hello, <who>!" | ||
#[job(id = 0, params(who), result(_), verifier(evm = "HelloBlueprint"))] | ||
pub fn say_hello(who: Option<String>) -> Result<String, Infallible> { | ||
use api::services::events::JobCalled; | ||
use sdk::event_listener::tangle::{ | ||
jobs::{services_post_processor, services_pre_processor}, | ||
TangleEventListener, | ||
}; | ||
|
||
#[derive(Clone)] | ||
pub struct ServiceContext { | ||
pub config: sdk::config::StdGadgetConfiguration, | ||
} | ||
|
||
/// Returns "Hello World!" if `who` is `None`, otherwise returns "Hello, {who}!" | ||
#[sdk::job( | ||
id = 0, | ||
params(who), | ||
result(_), | ||
event_listener( | ||
listener = TangleEventListener::<JobCalled, ServiceContext>, | ||
pre_processor = services_pre_processor, | ||
post_processor = services_post_processor, | ||
), | ||
)] | ||
pub fn say_hello(who: Option<String>, context: ServiceContext) -> Result<String, Infallible> { | ||
match who { | ||
Some(who) => Ok(format!("Hello, {}!", who)), | ||
Some(who) => Ok(format!("Hello, {who}!")), | ||
None => Ok("Hello World!".to_string()), | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let config = sdk::config::StdGadgetConfiguration::default(); | ||
let context = ServiceContext { config }; | ||
let result = say_hello(None, context).unwrap(); | ||
assert_eq!(result, "Hello World!"); | ||
let result = say_hello(Some("Alice".to_string()), context).unwrap(); | ||
assert_eq!(result, "Hello, Alice!"); | ||
} | ||
} |
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