MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / sequence

Function sequence

fendermint/rpc/examples/simplecoin.rs:180–192  ·  view source on GitHub ↗

Get the next sequence number (nonce) of an account.

(client: &impl QueryClient, sk: &SecretKey)

Source from the content-addressed store, hash-verified

178
179/// Get the next sequence number (nonce) of an account.
180async fn sequence(client: &impl QueryClient, sk: &SecretKey) -> anyhow::Result<u64> {
181 let pk = sk.public_key();
182 let addr = Address::new_secp256k1(&pk.serialize()).unwrap();
183 let state = client
184 .actor_state(&addr, FvmQueryHeight::default())
185 .await
186 .context("failed to get actor state")?;
187
188 match state.value {
189 Some((_id, state)) => Ok(state.sequence),
190 None => Err(anyhow!("cannot find actor {addr}")),
191 }
192}
193
194async fn actor_id(client: &impl QueryClient, addr: &Address) -> anyhow::Result<u64> {
195 let state = client

Callers 1

mainFunction · 0.70

Calls 4

contextMethod · 0.80
public_keyMethod · 0.45
serializeMethod · 0.45
actor_stateMethod · 0.45

Tested by

no test coverage detected