Get the next sequence number (nonce) of an account.
(client: &impl QueryClient, sk: &SecretKey)
| 178 | |
| 179 | /// Get the next sequence number (nonce) of an account. |
| 180 | async 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 | |
| 194 | async fn actor_id(client: &impl QueryClient, addr: &Address) -> anyhow::Result<u64> { |
| 195 | let state = client |
no test coverage detected