• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

helix-onchain / filecoin / 4191081979

pending completion
4191081979

Pull #197

github

GitHub
Merge f696a6385 into b20a4687a
Pull Request #197: pin toolchain version to match ref-fvm

19 of 19 new or added lines in 3 files covered. (100.0%)

3600 of 4162 relevant lines covered (86.5%)

12.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

12.24
/frc53_nft/src/types.rs
1
//! Interfaces and types for the frc53 NFT standard
2
use cid::Cid;
3
use fvm_actor_utils::receiver::RecipientData;
4
use fvm_ipld_encoding::tuple::{Deserialize_tuple, Serialize_tuple};
5
use fvm_ipld_encoding::RawBytes;
6
use fvm_shared::address::Address;
7
use fvm_shared::ActorID;
8

9
type TokenID = u64;
10

11
/// A trait to be implemented by FRC-0053 compliant actors
12
pub trait FRC53NFT {
13
    /// A descriptive name for the collection of NFTs in this actor
14
    fn name(&self) -> String;
15

16
    /// An abbreviated name for NFTs in this contract
17
    fn symbol(&self) -> String;
18

19
    /// Gets a link to associated metadata for a given NFT
20
    fn metadata(&self, params: TokenID) -> Cid;
21

22
    /// Gets the total number of NFTs in this actor
23
    fn total_supply(&self) -> u64;
24

25
    /// Burns a given NFT, removing it from the total supply and preventing new NFTs from being
26
    /// minted with the same ID
27
    fn burn(&self, params: TokenID);
28

29
    /// Gets a list of all the tokens in the collection
30
    /// FIXME: make this paginated
31
    fn list_tokens(&self) -> Vec<TokenID>;
32

33
    /// Gets the number of tokens held by a particular address (if it exists)
34
    fn balance_of(&self, params: Address) -> u64;
35

36
    /// Returns the owner of the NFT specified by `token_id`
37
    fn owner_of(&self, params: TokenID) -> ActorID;
38

39
    /// Transfers specific NFTs from the caller to another account
40
    fn transfer(&self, params: TransferParams);
41

42
    /// Transfers specific NFTs between the `from` and `to` addresses
43
    fn transfer_from(&self, params: TransferFromParams);
44

45
    /// Change or reaffirm the approved address for a set of NFTs, setting to zero means there is no approved address
46
    fn approve(&self, params: ApproveParams);
47

48
    /// Set approval for all, allowing an operator to control all of the caller's tokens (including future tokens)
49
    /// until approval is revoked
50
    fn set_approval_for_all(&self, params: ApproveForAllParams);
51

52
    /// Get the approved address for a single NFT
53
    fn get_approved(&self, params: TokenID) -> ActorID;
54

55
    /// Query if the address is the approved operator for another address
56
    fn is_approved_for_all(&self, params: IsApprovedForAllParams) -> bool;
57
}
58

59
/// Return value after a successful mint
60
/// The mint method is not standardised, so this is merely a useful library-level type, and
61
/// recommendation for token implementations
62
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
63
pub struct MintReturn {
64
    /// The new balance of the owner address
65
    pub balance: u64,
×
66
    /// The new total supply
67
    pub supply: u64,
×
68
    /// List of the tokens that were minted successfully (some may have been burned during hook execution)
69
    pub token_ids: Vec<TokenID>,
×
70
    /// (Optional) data returned from the receiver hook
71
    pub recipient_data: RawBytes,
×
72
}
73

74
/// Intermediate data used by mint_return to construct the return data
75
#[derive(Clone, Debug)]
×
76
pub struct MintIntermediate {
77
    /// Receiving address used for querying balance
78
    pub to: ActorID,
×
79
    /// List of the newly minted tokens
80
    pub token_ids: Vec<TokenID>,
×
81
    /// (Optional) data returned from the receiver hook
82
    pub recipient_data: RawBytes,
×
83
}
84

85
impl RecipientData for MintIntermediate {
86
    fn set_recipient_data(&mut self, data: RawBytes) {
9✔
87
        self.recipient_data = data;
9✔
88
    }
9✔
89
}
90

91
/// Intermediate data used by transfer_return to construct the return data
92
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
93
pub struct TransferIntermediate {
94
    pub token_ids: Vec<TokenID>,
×
95
    pub from: ActorID,
×
96
    pub to: ActorID,
×
97
    /// (Optional) data returned from the receiver hook
98
    pub recipient_data: RawBytes,
×
99
}
100

101
impl RecipientData for TransferIntermediate {
102
    fn set_recipient_data(&mut self, data: RawBytes) {
4✔
103
        self.recipient_data = data;
4✔
104
    }
4✔
105
}
106

107
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
108
pub struct TransferParams {
109
    pub to: Address,
×
110
    pub token_ids: Vec<TokenID>,
×
111
    pub operator_data: RawBytes,
×
112
}
113

114
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
115
pub struct TransferReturn {
116
    pub from_balance: u64,
×
117
    pub to_balance: u64,
×
118
    pub token_ids: Vec<TokenID>,
×
119
}
120

121
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
122
pub struct TransferFromParams {
123
    pub from: Address,
×
124
    pub to: Address,
×
125
    pub token_ids: Vec<TokenID>,
×
126
    pub operator_data: RawBytes,
×
127
}
128

129
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
130
pub struct BurnFromParams {
131
    pub from: Address,
×
132
    pub token_ids: Vec<TokenID>,
×
133
}
134

135
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
136
pub struct ApproveParams {
137
    pub operator: Address,
×
138
    pub token_ids: Vec<TokenID>,
×
139
}
140

141
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
142
pub struct ApproveForAllParams {
143
    pub operator: Address,
×
144
}
145

146
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
147
pub struct IsApprovedForAllParams {
148
    pub owner: Address,
×
149
    pub operator: Address,
×
150
}
151

152
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
153
pub struct RevokeParams {
154
    pub operator: Address,
×
155
    pub token_ids: Vec<TokenID>,
×
156
}
157

158
#[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug)]
×
159
pub struct RevokeForAllParams {
160
    pub operator: Address,
×
161
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc