Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async CashTrade(ctx, cashRate, cashValue, cashReceiverId, cashSenderId) {
var cid = new ClientIdentity(ctx.stub);
console.info(`Received "CashTrade" transaction from ${cid.getID()}`);
var coinsValue = Number(cashRate) * Number(cashValue);
// first check: tx invoker can only send from his account
const senderData = await ctx.stub.getState(cashSenderId);
if (!senderData) {
throw new Error('Sender does not exist, create participant first');
}
const receiverData = await ctx.stub.getState(cashReceiverId);
if (!receiverData) {
throw new Error('Receiver does not exist, create participant first');
}
// console.log(JSON.parse(senderData))
var sender = JSON.parse(senderData);
var receiver = JSON.parse(receiverData);
async clientIdentityInstance({stub}) {
const cid = new shim.ClientIdentity(stub);
return {mspId: cid.mspId, id: cid.id};
}
testClientIdentity(stub: ChaincodeStub): void {
const cID = new ClientIdentity(stub);
const name = 'mockName';
const value = 'mockValue';
const attributeValue: string | null = cID.getAttributeValue(name);
const id: string = cID.getID();
const mspid: string = cID.getMSPID();
const newAttributeValue: boolean = cID.assertAttributeValue(name, value);
const X509Certificate: X509.Certificate = cID.getX509Certificate();
this.testCert(X509Certificate);
}
async AddUtilityCompany(ctx, utilityCompanyId, name, coinsBalance, energyValue, energyUnits) {
var cid = new ClientIdentity(ctx.stub);
console.info(`Received "AddUtilityCompany" transaction from ${cid.getID()}`);
var coins = {
"value": Number(coinsBalance)
};
var energy = {
"value": Number(energyValue),
"units": energyUnits
};
var utilityCompany = {
"participantId": cid.getID(),
"utilityCompanyId": utilityCompanyId,
"name": name,
"coins": coins,
"energy": energy,
return tslib_1.__generator(this, function (_a) {
identity = new fabric_shim_1.ClientIdentity(stubHelper.getStub());
fingerprint = identity.getX509Certificate().fingerPrint;
return [2, obj[fnName].call(this, stubHelper, _args, {
sender: {
value: fingerprint
},
tx: {
value: new chaincode_tx_1.ChaincodeTx(stubHelper, identity)
}
})];
});
}); } : obj[fnName], _b)));
async (stubHelper: StubHelper, _args: string[]) => {
const identity = new ClientIdentity(stubHelper.getStub());
const fingerprint = identity.getX509Certificate().fingerPrint;
return obj[fnName].call(this, stubHelper, _args, {
sender: {
value: fingerprint
},
tx: {
value: new ChaincodeTx(stubHelper, identity)
}
});
} : obj[fnName]
}), { [ctrlInvokables.namespace]: obj });
get fullIdentity(): ClientIdentity {
const stub = (BaseStorage.current as any).stubHelper;
return new ClientIdentity(stub.getStub());
};
get: function () {
var stub = convector_core_storage_1.BaseStorage.current.stubHelper;
return new fabric_shim_1.ClientIdentity(stub.getStub());
},
enumerable: true,