1use evm_coder::{solidity_interface, solidity, types::*, ToLog};2use sp_std::vec::Vec;34#[solidity_interface]5pub trait InlineNameSymbol {6 type Error;78 fn name(&self) -> Result<string, Self::Error>;9 fn symbol(&self) -> Result<string, Self::Error>;10}1112#[solidity_interface]13pub trait InlineTotalSupply {14 type Error;1516 fn total_supply(&self) -> Result<uint256, Self::Error>;17}1819#[solidity_interface]20pub trait ERC165 {21 type Error;2223 fn supports_interface(&self, interface_id: bytes4) -> Result<bool, Self::Error>;24}2526#[solidity_interface(inline_is(InlineNameSymbol))]27pub trait ERC721Metadata {28 type Error;2930 #[solidity(rename_selector = "tokenURI")]31 fn token_uri(&self, token_id: uint256) -> Result<string, Self::Error>;32}3334#[solidity_interface(inline_is(InlineTotalSupply))]35pub trait ERC721Enumerable {36 type Error;3738 fn token_by_index(&self, index: uint256) -> Result<uint256, Self::Error>;39 fn token_of_owner_by_index(40 &self,41 owner: address,42 index: uint256,43 ) -> Result<uint256, Self::Error>;44}4546#[derive(ToLog)]47pub enum ERC721Events {48 Transfer {49 #[indexed]50 from: address,51 #[indexed]52 to: address,53 #[indexed]54 token_id: uint256,55 },56 Approval {57 #[indexed]58 owner: address,59 #[indexed]60 approved: address,61 #[indexed]62 token_id: uint256,63 },64 #[allow(dead_code)]65 ApprovalForAll {66 #[indexed]67 owner: address,68 #[indexed]69 operator: address,70 approved: bool,71 },72}7374#[solidity_interface(is(ERC165), events(ERC721Events))]75pub trait ERC721 {76 type Error;7778 fn balance_of(&self, owner: address) -> Result<uint256, Self::Error>;79 fn owner_of(&self, token_id: uint256) -> Result<address, Self::Error>;8081 #[solidity(rename_selector = "safeTransferFrom")]82 fn safe_transfer_from_with_data(83 &mut self,84 from: address,85 to: address,86 token_id: uint256,87 data: bytes,88 value: value,89 ) -> Result<void, Self::Error>;90 fn safe_transfer_from(91 &mut self,92 from: address,93 to: address,94 token_id: uint256,95 value: value,96 ) -> Result<void, Self::Error>;9798 fn transfer_from(99 &mut self,100 caller: caller,101 from: address,102 to: address,103 token_id: uint256,104 value: value,105 ) -> Result<void, Self::Error>;106 fn approve(107 &mut self,108 caller: caller,109 approved: address,110 token_id: uint256,111 value: value,112 ) -> Result<void, Self::Error>;113 fn set_approval_for_all(114 &mut self,115 caller: caller,116 operator: address,117 approved: bool,118 ) -> Result<void, Self::Error>;119120 fn get_approved(&self, token_id: uint256) -> Result<address, Self::Error>;121 fn is_approved_for_all(122 &self,123 owner: address,124 operator: address,125 ) -> Result<address, Self::Error>;126}127128#[solidity_interface]129pub trait ERC721UniqueExtensions {130 type Error;131132 fn transfer(133 &mut self,134 caller: caller,135 to: address,136 token_id: uint256,137 value: value,138 ) -> Result<void, Self::Error>;139}140141#[solidity_interface(is(142 ERC165,143 ERC721,144 ERC721Metadata,145 ERC721Enumerable,146 ERC721UniqueExtensions147))]148pub trait UniqueNFT {149 type Error;150}151152#[derive(ToLog)]153pub enum ERC20Events {154 Transfer {155 #[indexed]156 from: address,157 #[indexed]158 to: address,159 value: uint256,160 },161 Approval {162 #[indexed]163 owner: address,164 #[indexed]165 spender: address,166 value: uint256,167 },168}169170#[solidity_interface(inline_is(InlineNameSymbol, InlineTotalSupply), events(ERC20Events))]171pub trait ERC20 {172 type Error;173174 fn decimals(&self) -> Result<uint8, Self::Error>;175 fn balance_of(&self, owner: address) -> Result<uint256, Self::Error>;176 fn transfer(177 &mut self,178 caller: caller,179 to: address,180 value: uint256,181 ) -> Result<bool, Self::Error>;182 fn transfer_from(183 &mut self,184 caller: caller,185 from: address,186 to: address,187 value: uint256,188 ) -> Result<bool, Self::Error>;189 fn approve(190 &mut self,191 caller: caller,192 spender: address,193 value: uint256,194 ) -> Result<bool, Self::Error>;195 fn allowance(&self, owner: address, spender: address) -> Result<uint256, Self::Error>;196}197198#[solidity_interface(is(ERC165, ERC20))]199pub trait UniqueFungible {200 type Error;201}