Get the next sequence number (nonce) of an account.
(client: &impl QueryClient, addr: &Address)
| 122 | |
| 123 | /// Get the next sequence number (nonce) of an account. |
| 124 | async fn sequence(client: &impl QueryClient, addr: &Address) -> anyhow::Result<u64> { |
| 125 | let state = client |
| 126 | .actor_state(&addr, FvmQueryHeight::default()) |
| 127 | .await |
| 128 | .context("failed to get actor state")?; |
| 129 | |
| 130 | match state.value { |
| 131 | Some((_id, state)) => Ok(state.sequence), |
| 132 | None => Err(anyhow!("cannot find actor {addr}")), |
| 133 | } |
| 134 | } |
no test coverage detected