Skip to content

Commit ae75023

Browse files
committed
Update test service to include required manifest information
1 parent 4fb8d6f commit ae75023

File tree

3 files changed

+54
-40
lines changed

3 files changed

+54
-40
lines changed

stf/accumulate/test-service/Cargo.toml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
name = "test-service"
33
version = "0.1.0"
44
edition = "2021"
5+
license = "Apache-2.0"
6+
authors = ["nobody"]
7+
8+
[lib]
9+
crate-type = ["cdylib"]
510

611
[dependencies]
7-
jam-pvm-common = { version = "0.1.12", default-features = false, features = ["service"] }
8-
jam-types = { version = "0.1.12", default-features = false }
9-
polkavm-derive = "0.19.0"
12+
jam-pvm-common = { version = "0.1.22", default-features = false, features = ["service", "logging"] }
13+
jam-types = { version = "0.1.22", default-features = false }
14+
polkavm-derive = "0.24.0"
15+
16+
[features]
17+
tiny = ["jam-types/tiny", "jam-pvm-common/tiny"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#![cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), no_std)]
2+
3+
extern crate alloc;
4+
use alloc::format;
5+
use jam_pvm_common::*;
6+
use jam_types::*;
7+
8+
#[allow(dead_code)]
9+
struct Service;
10+
declare_service!(Service);
11+
12+
impl jam_pvm_common::Service for Service {
13+
fn refine(
14+
id: ServiceId,
15+
payload: WorkPayload,
16+
_package_hash: WorkPackageHash,
17+
_context: RefineContext,
18+
_auth_code_hash: CodeHash,
19+
) -> WorkOutput {
20+
info!("This is Refine in the Test Service {id:x}h with payload len {}", payload.len());
21+
[&b"Hello "[..], payload.take().as_slice()].concat().into()
22+
}
23+
fn accumulate(_slot: Slot, id: ServiceId, items: Vec<AccumulateItem>) -> Option<Hash> {
24+
info!("This is Accumulate in the Test Service {id:x}h with {} items", items.len());
25+
for out in items.into_iter().filter_map(|x| x.result.ok()) {
26+
accumulate::set_storage(b"last", &out).expect("balance low");
27+
}
28+
None
29+
}
30+
fn on_transfer(slot: Slot, id: ServiceId, items: Vec<TransferRecord>) {
31+
items.into_iter().for_each(|i| {
32+
info!(
33+
"Transfer at {slot} from {:x}h to {id:x}h of {} memo {}",
34+
i.source, i.amount, i.memo
35+
);
36+
let msg = format!(
37+
"Transfer at {slot} from {:x}h to {id:x}h of {} memo {}",
38+
i.source, i.amount, i.memo,
39+
);
40+
accumulate::set_storage(b"lasttx", msg.as_bytes()).expect("balance low");
41+
});
42+
}
43+
}

stf/accumulate/test-service/src/main.rs

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)