Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
86 views
in Technique[技术] by (71.8m points)

node.js - Hyperledger checking asset owner

Hi I am stuck working on my project. I cannot handle simple check of the asset owner maybe I am already too tired.

The .cto:


participant Customer identified by customerID{
o String customerID regex=/[A-Z]{2}[0-9]{4}/
o DETAILS details
o ADDRESS address
}
asset Account identified by accID{
o String accID regex=/[0-9]{6}/
o Double funds
o Double eurofunds default=0.0 optional
o Double dollarfunds default=0.0 optional
o accType accType
--> Customer[] owners
}

And the script i wanted to use but does not work:

async function sendMoney(tx) {
    let tx_money = tx.amount;
    let tx_destinationNumber = tx.destinationAccNumber;
    let tx_sourceNumber = tx.sourceAccNumber;
    let tx_currency = tx.currency;
    let currentcustomer = getCurrentParticipant();
    let accounts = await getAssetRegistry(ns+'.Account');

    let resource = "resource:" + currentcustomer.getFullyQualifiedIdentifier();
    
    let exists1 = await accounts.exists(tx_sourceNumber.getIdentifier());
    let exists2 = await accounts.exists(tx_destinationNumber.getIdentifier()); 

  
    if(exists1){
            let account1 = await accounts.get(tx_sourceNumber.getIdentifier());
    if(account1.owners.includes(resource)) {
}

My question is how to properly check if the array of customers in Account asset contains current participant, because my method is always returning false.

question from:https://stackoverflow.com/questions/65645308/hyperledger-checking-asset-owner

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...