代码之家  ›  专栏  ›  技术社区  ›  Paradox

无法创建资产(factory.newResource())

  •  1
  • Paradox  · 技术社区  · 7 年前

    我试图使用事务创建资产,但它引发了一个错误:

    Error: Invalid or missing identifier for Type Temp in namespace org.acme.mynetwork

    昨天我更新了我的节点包,从那时起它就不工作了。任何潜在客户都将不胜感激。

    型号:

    namespace org.acme.mynetwork
    
    asset Temp identified by id {
        o String id
    }
    transaction Test {}
    

    脚本:

     /**
      * blah
      * @param {org.acme.mynetwork.Test} blah
      * @transaction
      */
     async function Test() {
       let factory = getFactory()
       let registry = await getAssetRegistry("org.acme.mynetwork.Temp")
       let resource = factory.newResource("org.acme.mynetwork","Temp",1)      //Error
       await registry.add(resource)
     }
    

    访问控制

     rule Default {
         description: "Allow all participants access to all resources"
         participant: "ANY"
         operation: ALL
         resource: "org.acme.mynetwork.*"
         action: ALLOW
     }
    
     rule SystemACL {
       description:  "System ACL to permit all access"
       participant: "ANY"
       operation: ALL
       resource: "org.hyperledger.composer.system.**"
       action: ALLOW
     }
    

    谢谢

    1 回复  |  直到 7 年前
        1
  •  3
  •   Paul O'Mahony    7 年前

    您的标识符是字符串

    因此(在Composer v0.18.x在线测试 https://composer-playground-next.mybluemix.net/

     /**
     * blah
     * @param {org.acme.trading.Test} blah
     * @transaction
     */
    
    async function Test() {
      let factory = getFactory();
      let registry = await getAssetRegistry("org.acme.trading.Temp");
      let resource = factory.newResource("org.acme.trading","Temp", 't1');      
    
      await registry.add(resource);
    }