gpt4 book ai didi

hyperledger-composer - 错误 : Object with ID 'Participant:com.test.participant' in collection with ID '$sysregistries' does not exist

转载 作者:行者123 更新时间:2023-12-01 14:41:47 26 4
gpt4 key购买 nike

我正在尝试使用事务更改参与者的值。它抛出错误“错误:ID 为‘$sysregistries’的集合中 ID 为‘Participant:com.test.participant’的对象不存在”

请让我知道是什么问题。新版本有什么变化吗??

基地首席技术官:

namespace com.test.base

enum Gender {
o MALE
o FEMALE
o OTHER
}

/**
* A concept for a simple street address
*/
concept Address {
o String address
o Boolean isAddressValidated
}

参与首席技术官:

/**
* New model file
*/

namespace com.test.participant
import com.test.base.*

abstract participant User{
o String lastname
}

participant Customer identified by userId extends User {
o String userId
o String fName
o Address address
}

transaction ValidateAddress {
o Boolean isAddressValidated
--> Customer customer
}

Js文件:

 /**
* Sample transaction processor function.
* @param {com.test.participant.ValidateAddress} tx The sample transaction instance.
* @transaction
*/
async function sampleTransaction(tx) {
tx.customer.address.isAddressValidated = tx.isAddressValidated;

const participantRegistry = await getParticipantRegistry('com.test.participant','Costumer');
await participantRegistry.update(tx.customer);

}

测试值:

{
"$class": "com.test.participant.Customer",
"uId": "customer1",
"fName": "Pradeep",
"address": {
"$class": "com.test.base.Address",
"address": "",
"isAddressValidated": false
},
"lastname": "P"
}

{
"$class": "com.test.participant.ValidateAddress",
"isAddressValidated": true,
"customer": "resource:com.test.participant.Customer#customer1"
}

在链接中同时下载bna文件 https://drive.google.com/file/d/1NQYELmLzMyuN2V4yvDhUoLWackjs18Fa/view?usp=sharing

最佳答案

我在你的网络定义中编辑了两个东西,注意:我在 Hyperldger Playground 上测试了它并且它有效

  1. 将测试数据中的 uId 更改为 userId
  2. 清除您获取参与者注册表的交易代码中的客户拼写错误。

所以我在所有更改之后想出了这段代码

namespace com.test.base

enum Gender {
o MALE
o FEMALE
o OTHER
}

/**
* A concept for a simple street address
*/
concept Address {
o String address
o Boolean isAddressValidated
}


/**
* New model file
*/

namespace com.test.participant
import com.test.base.*

abstract participant User{
o String lastname
}

participant Customer identified by userId extends User {
o String userId
o String fName
o Address address
}

transaction ValidateAddress {
o Boolean isAddressValidated
--> Customer customer
}

测试数据如下

{
"$class": "com.test.participant.Customer",
"userId": "customer1",
"fName": "Pradeep",
"address": {
"$class": "com.test.base.Address",
"address": "New York",
"isAddressValidated": true
},
"lastname": "P"
}

对于交易我没有改变任何东西。希望对您有所帮助

关于hyperledger-composer - 错误 : Object with ID 'Participant:com.test.participant' in collection with ID '$sysregistries' does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50735957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com