| 62 | } |
| 63 | |
| 64 | pub fn new_fund_msg( |
| 65 | sub_id: &SubnetID, |
| 66 | from: &Address, |
| 67 | to: &Address, |
| 68 | value: TokenAmount, |
| 69 | ) -> anyhow::Result<Self> { |
| 70 | let from = IPCAddress::new( |
| 71 | &match sub_id.parent() { |
| 72 | Some(s) => s, |
| 73 | None => return Err(anyhow!("error getting parent for subnet addr")), |
| 74 | }, |
| 75 | from, |
| 76 | )?; |
| 77 | let to = IPCAddress::new(sub_id, to)?; |
| 78 | |
| 79 | // the nonce and the rest of message fields are set when the message is committed. |
| 80 | Ok(Self { |
| 81 | kind: IpcMsgKind::Transfer, |
| 82 | from, |
| 83 | to, |
| 84 | value, |
| 85 | nonce: 0, |
| 86 | message: Default::default(), |
| 87 | }) |
| 88 | } |
| 89 | |
| 90 | pub fn ipc_type(&self) -> anyhow::Result<IPCMsgType> { |
| 91 | let sto = self.to.subnet()?; |