You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.rs 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. use prelude::TxExecutionError;
  2. pub mod client;
  3. pub mod rpc;
  4. pub mod types;
  5. pub mod prelude {
  6. pub use super::types::{
  7. self,
  8. crypto::{ED25519PublicKey, ED25519Signature, Keypair},
  9. near::TxExecutionError,
  10. };
  11. }
  12. #[derive(Debug, thiserror::Error)]
  13. pub enum Error {
  14. #[error("{0}")]
  15. Type(types::Error),
  16. #[error("Rpc request failed for {method} with {error}")]
  17. Rpc {
  18. error: rpc::Error,
  19. method: &'static str,
  20. },
  21. #[error("Couldn't get a previous block hash")]
  22. EmptyBlock,
  23. #[error("Couldn't serialize function arguments {0}")]
  24. ArgsSerialize(serde_json::Error),
  25. #[error("Couldn't deserialize tx response {0}")]
  26. DeserializeTxResp(serde_json::Error),
  27. #[error("Borsh can't serialize transaction {0}")]
  28. TransactionSerialize(std::io::Error),
  29. #[error("Execution of transaction failed {0:?}")]
  30. TransactionExec(TxExecutionError),
  31. #[error("Transaction not started yet")]
  32. TxNotStarted,
  33. #[error("Rpc:")]
  34. NoSigner,
  35. }
  36. impl From<types::Error> for Error {
  37. fn from(err: types::Error) -> Self {
  38. Self::Type(err)
  39. }
  40. }
  41. pub fn add(left: usize, right: usize) -> usize {
  42. left + right
  43. }
  44. #[cfg(test)]
  45. mod tests {
  46. use super::*;
  47. #[test]
  48. fn it_works() {
  49. let result = add(2, 2);
  50. assert_eq!(result, 4);
  51. }
  52. }