|
| 1 | +// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +// file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 4 | +// |
| 5 | +// Copyright (c) DUSK NETWORK. All rights reserved. |
| 6 | + |
| 7 | +//! DRC20 event payloads. |
| 8 | +
|
| 9 | +use bytecheck::CheckBytes; |
| 10 | +use rkyv::{Archive, Deserialize, Serialize}; |
| 11 | + |
| 12 | +use crate::core::Principal; |
| 13 | + |
| 14 | +/// Transfer event topic. |
| 15 | +pub const TRANSFER_TOPIC: &str = "drc20/transfer"; |
| 16 | +/// Approval event topic. |
| 17 | +pub const APPROVAL_TOPIC: &str = "drc20/approval"; |
| 18 | + |
| 19 | +/// Transfer event. |
| 20 | +#[derive( |
| 21 | + Archive, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, |
| 22 | +)] |
| 23 | +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 24 | +#[archive_attr(derive(CheckBytes))] |
| 25 | +pub struct Transfer { |
| 26 | + /// Sender. |
| 27 | + pub from: Principal, |
| 28 | + /// Recipient. |
| 29 | + pub to: Principal, |
| 30 | + /// Amount. |
| 31 | + pub amount: u64, |
| 32 | +} |
| 33 | + |
| 34 | +/// Approval event. |
| 35 | +#[derive( |
| 36 | + Archive, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq, |
| 37 | +)] |
| 38 | +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] |
| 39 | +#[archive_attr(derive(CheckBytes))] |
| 40 | +pub struct Approval { |
| 41 | + /// Owner. |
| 42 | + pub owner: Principal, |
| 43 | + /// Spender. |
| 44 | + pub spender: Principal, |
| 45 | + /// Amount. |
| 46 | + pub amount: u64, |
| 47 | +} |
| 48 | + |
| 49 | +#[cfg(feature = "forge")] |
| 50 | +impl dusk_forge::ContractEvent for Transfer { |
| 51 | + const TOPICS: &'static [&'static str] = &[TRANSFER_TOPIC]; |
| 52 | +} |
| 53 | + |
| 54 | +#[cfg(feature = "forge")] |
| 55 | +impl dusk_forge::ContractEvent for Approval { |
| 56 | + const TOPICS: &'static [&'static str] = &[APPROVAL_TOPIC]; |
| 57 | +} |
0 commit comments