consider prefixing with an underscore: _tokenOwner
convert the identifier to snake case: token_owner
help: convert the identifier to snake case: _token_id
173 | fn validNFToken(_tokenId:u128)->bool{
| ^^^^^^^^^^^^ help: convert the identifier to snake case: valid_nftoken
146 | if(_token_owner == origin || OwnerToOperators::get((_token_owner,_origin))){
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove these parentheses
i128::min_value()
pub fn checked_sub(self, rhs: i128) -> Option<i128>
u128取值unwrap
let _owner_count_u128 = _owner_count.checked_sub(1).unwrap();
事件:
Self::deposit_event(RawEvent::Transfer(se_fromnder, _to,_token_id));
函數(shù)的返回值需要時Result--- 大坑
273 | ensure!(_id_owner.,"_token_id has existed");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum core::result::Result 這個我總是搞不對;
result::Result<T::KittyIndex, &'static str>
origin函數(shù)中的第一個參數(shù)必須為origin
error: Implicit conversion to privileged function has been removed. First parameter of dispatch should be marked origin. For root-matching dispatch, also add ensure_root(origin)?.
--> /Users/zhouhe/blockchain/SubstrateOrg/Morning-Star-done/runtime/src/nftoken.rs:54:1
接口分幾種,一種是給前端用的,一種是給其他模塊用的。你這邊考慮的應(yīng)該是給其他模塊用的,那就是一個Rust模塊的接口。
可以參考Currency trait。
有什么傳遞參數(shù)的問題?
其他模塊調(diào)用NFT模塊的話有兩種方法,直接依賴,或者間接極賴。
直接依賴就類似模塊依賴于system module,可以直接調(diào)用system module的方法。
間接依賴就是建立一個獨(dú)立的trait,Kitties模塊Trait加個associated type,然后NFT模塊實(shí)現(xiàn)這trait。
初期可以直接依賴會簡單一點(diǎn)。
: system::Trait???
/// Abstraction over a fungible assets system.
pub trait Currency<AccountId> {
- 繼承的實(shí)現(xiàn)1
pub trait ReservableCurrency<AccountId>: Currency<AccountId> { - 繼承的實(shí)現(xiàn)2
/// A currency whose accounts can have liquidity restrictions.
pub trait LockableCurrency<AccountId>: Currency<AccountId> {
pub trait Time {
type Moment: SimpleArithmetic + Codec + Clone + Default + Copy;
fn now() -> Self::Moment;
}
???
pub trait Currency {}
pub trait StorageValue<T: Codec> {
impl<K: Codec, V: Codec, U> StorageMap<K, V> for U where U: hashed::generator::StorageMap<K, V> {
pub trait Codec: Decode + Encode {}
這個泛型語法你要先學(xué)習(xí)下,自己瞎試是不想的
這邊假設(shè)OnTest是一個trait,那impl應(yīng)該是 impl<T> OnTest for Module<T> {}
或者如果OnTest自己有泛型參數(shù)的話 impl<T> OnTest<T::AccountId, u128> for Module<T> {}
//問題2
error[E0405]: cannot find trait Trait in this scope
--> /Users/zhouhe/blockchain/SubstrateOrg/Morning-Star/runtime/src/test.rs:13:10
|
13 | impl<T: Trait> OnTest<T::AccountId, u128> for Module<T> {
| ^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope
//問題3
17 | impl<T: Trait> OnTest<T::AccountId, u128> for Module<T> {
| ^^^^^^ not found in this scope
help: possible candidates are found in other modules, you can import them into scope