entrypoint.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* This file is part of DarkFi (https://dark.fi)
  2. *
  3. * Copyright (C) 2020-2023 Dyne.org foundation
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. use darkfi_sdk::{
  19. crypto::ContractId,
  20. db::{db_init, db_lookup},
  21. error::ContractResult,
  22. };
  23. darkfi_sdk::define_contract!(
  24. init: init_contract,
  25. exec: process_instruction,
  26. apply: process_update,
  27. metadata: get_metadata
  28. );
  29. fn init_contract(cid: ContractId, _ix: &[u8]) -> ContractResult {
  30. let db = match db_lookup(cid, "dummy_db") {
  31. Ok(v) => v,
  32. Err(_) => db_init(cid, "dummy_db")?,
  33. };
  34. Ok(())
  35. }
  36. fn get_metadata(_cid: ContractId, _ix: &[u8]) -> ContractResult {
  37. Ok(())
  38. }
  39. fn process_instruction(cid: ContractId, _ix: &[u8]) -> ContractResult {
  40. let db = db_lookup(cid, "dummy_db")?;
  41. Ok(())
  42. }
  43. fn process_update(_cid: ContractId, _ix: &[u8]) -> ContractResult {
  44. Ok(())
  45. }