Warning

作者: 空乱木 | 来源:发表于2019-10-26 12:33 被阅读0次

    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));

    函数的返回值需要时Result--- 大坑
    273 | ensure!(_id_owner.,"_token_id has existed");
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum core::result::Result 这个我总是搞不对;

    result::Result<T::KittyIndex, &'static str>

    origin函数中的第一个参数必须为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

    接口分几种,一种是给前端用的,一种是给其他模块用的。你这边考虑的应该是给其他模块用的,那就是一个Rust模块的接口。
    可以参考Currency trait。
    有什么传递参数的问题?
    其他模块调用NFT模块的话有两种方法,直接依赖,或者间接极赖。
    直接依赖就类似模块依赖于system module,可以直接调用system module的方法。
    间接依赖就是建立一个独立的trait,Kitties模块Trait加个associated type,然后NFT模块实现这trait。
    初期可以直接依赖会简单一点。

    : system::Trait???

    /// Abstraction over a fungible assets system.
    pub trait Currency<AccountId> {

    • 继承的实现1
      pub trait ReservableCurrency<AccountId>: Currency<AccountId> {
    • 继承的实现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 {}

    这个泛型语法你要先学习下,自己瞎试是不想的
    这边假设OnTest是一个trait,那impl应该是 impl<T> OnTest for Module<T> {}
    或者如果OnTest自己有泛型参数的话 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

    相关文章

      网友评论

        本文标题:Warning

        本文链接:https://www.haomeiwen.com/subject/xbbsvctx.html