Waits for a created token address to return non-empty bytecode.
(
&self,
token: Address,
wait_timeout: Duration,
poll_interval: Duration,
)
| 232 | |
| 233 | /// Waits for a created token address to return non-empty bytecode. |
| 234 | pub async fn wait_for_token_code( |
| 235 | &self, |
| 236 | token: Address, |
| 237 | wait_timeout: Duration, |
| 238 | poll_interval: Duration, |
| 239 | ) -> Result<()> { |
| 240 | timeout(wait_timeout, async { |
| 241 | loop { |
| 242 | let code = self.provider.get_code_at(token).await?; |
| 243 | if !code.is_empty() { |
| 244 | return Ok::<_, eyre::Error>(()); |
| 245 | } |
| 246 | sleep(poll_interval).await; |
| 247 | } |
| 248 | }) |
| 249 | .await |
| 250 | .wrap_err("Timed out waiting for B-20 token code")? |
| 251 | } |
| 252 | |
| 253 | /// Reads the B-20 balance for an account. |
| 254 | pub async fn balance_of(&self, token: Address, account: Address) -> Result<U256> { |