Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(!Array.isArray(commandArgs)){
commands = [commandArgs];
}else{
commands = commandArgs;
}
let privateKeys = commandOption.privateKeys;
let creatorAccountId = commandOption.creatorAccountId;
let quorum = commandOption.quorum;
let txClient = commandOption.commandService;
let timeoutLimit = commandOption.timeoutLimit;
let txToSends = [];
for (let i = 0; i < commands.length; i++) {
let commandArg = commands[i];
let tx = txHelper.addCommand(txHelper.emptyTransaction(), commandArg.fn, commandArg.args);
let txToSend = txHelper.addMeta(tx,{
creatorAccountId: creatorAccountId,
quorum: quorum
});
txToSend = irohaUtil.signWithArrayOfKeys(txToSend, privateKeys);
txToSends.push(txToSend);
}
let hashes = await sendTransactions(txToSends,txClient,timeoutLimit);// batch mode
let results = await getTxStatus(hashes,txClient,timeoutLimit);
return Promise.resolve(results);
}
catch(err) {
logger.error(err);
return Promise.reject('Failed to submit Iroha transaction');
}
commands = [commandArgs];
}else{
commands = commandArgs;
}
let privateKeys = commandOption.privateKeys;
let creatorAccountId = commandOption.creatorAccountId;
let quorum = commandOption.quorum;
let txClient = commandOption.commandService;
let timeoutLimit = commandOption.timeoutLimit;
let txToSends = [];
for (let i = 0; i < commands.length; i++) {
let commandArg = commands[i];
let tx = txHelper.addCommand(txHelper.emptyTransaction(), commandArg.fn, commandArg.args);
let txToSend = txHelper.addMeta(tx,{
creatorAccountId: creatorAccountId,
quorum: quorum
});
txToSend = irohaUtil.signWithArrayOfKeys(txToSend, privateKeys);
txToSends.push(txToSend);
}
let hashes = await sendTransactions(txToSends,txClient,timeoutLimit);// batch mode
let results = await getTxStatus(hashes,txClient,timeoutLimit);
return Promise.resolve(results);
}
catch(err) {
logger.error(err);
return Promise.reject('Failed to submit Iroha transaction');
}
}
let privateKeys = commandOption.privateKeys;
let creatorAccountId = commandOption.creatorAccountId;
let quorum = commandOption.quorum;
let txClient = commandOption.commandService;
let timeoutLimit = commandOption.timeoutLimit;
let txToSends = [];
for (let i = 0; i < commands.length; i++) {
let commandArg = commands[i];
let tx = txHelper.addCommand(txHelper.emptyTransaction(), commandArg.fn, commandArg.args);
let txToSend = txHelper.addMeta(tx,{
creatorAccountId: creatorAccountId,
quorum: quorum
});
txToSend = irohaUtil.signWithArrayOfKeys(txToSend, privateKeys);
txToSends.push(txToSend);
}
let hashes = await sendTransactions(txToSends,txClient,timeoutLimit);// batch mode
let results = await getTxStatus(hashes,txClient,timeoutLimit);
return Promise.resolve(results);
}
catch(err) {
logger.error(err);
return Promise.reject('Failed to submit Iroha transaction');
}
}
async function sendTransactions(txs, txClient, timeoutLimit){
try{
const hashes = txs.map(x => txHelper.hash(x));
const txList = txHelper.createTxListFromArray(txs);
let p = new Promise((resolve, reject) => {
const timer = setTimeout(()=>{
txClient.$channel.close();
reject(new Error('Please check IP address OR your internet connection'));
}, timeoutLimit);
txClient.listTorii(txList, (err) => {
clearTimeout(timer);
if(err) {
return reject(err);
}
resolve();
});
});
await p;
return hashes;
}catch(e){
let commands = args.map(item => {
let keypairs = generateKeypair.generateKeyPair();
let argsIroha = {
accountName: item.account,
domainId: context.domain,
publicKey: keypairs.publicKey,
verb: item.verb
};
return context.contract[contractID](context, argsIroha);
});
name += seed.charAt(Math.floor(Math.random() * seed.length));
}
if(accountNames.indexOf(name) < 0) {
return name;
}
else {
return generateName();
}
};
let promises = [];
for(let i = 0 ; i < number ; i++) {
let name = generateName();
let id = name + '@' + domain;
accountNames.push(name);
let keypairs = generateKeypair.generateKeyPair();
//client information
result.push({
name: name,
domain: domain,
id: id,
pubKey: keypairs.publicKey,
privKey: keypairs.privateKey
});
let commands = [{
fn: 'createAccount',
args: {accountName: name, domainId: domain, publicKey: keypairs.publicKey}
},
{
fn: 'appendRole',
args: {accountId: id, roleName: 'admin'}
let statuses = values.map(x => x!== null ? irohaUtil.getProtoEnumName(TxStatusLib, 'iroha.protocol.Txstatus', x) : null);
let results = [];
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const fs = require('fs');
const grpc = require('grpc');
const IrohaService_v1Client = require('iroha-helpers/lib/proto/endpoint_grpc_pb');
const CommandService_v1Client = IrohaService_v1Client.CommandService_v1Client;
const QueryService_v1Client = IrohaService_v1Client.QueryService_v1Client;
const generateKeypair = require('iroha-helpers/lib/cryptoHelper.js').default;
const {BlockchainInterface, CaliperUtils, TxStatus} = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('iroha.js');
const irohaQueries = require('iroha-helpers/lib/queries').default;
const irohaUtil = require('iroha-helpers/lib/util.js');
const txHelper = require('iroha-helpers/lib/txHelper.js').default;
const TxStatusLib = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatus;
const TxStatusRequest = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatusRequest;
/**
* Create Iroha transactions and send them to a node.
* @param {Array} txs txToSends
* @param {Object} txClient - transaction client
* @param {timeoutLimit} timeoutLimit timeout
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const fs = require('fs');
const grpc = require('grpc');
const IrohaService_v1Client = require('iroha-helpers/lib/proto/endpoint_grpc_pb');
const CommandService_v1Client = IrohaService_v1Client.CommandService_v1Client;
const QueryService_v1Client = IrohaService_v1Client.QueryService_v1Client;
const generateKeypair = require('iroha-helpers/lib/cryptoHelper.js').default;
const {BlockchainInterface, CaliperUtils, TxStatus} = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('iroha.js');
const irohaQueries = require('iroha-helpers/lib/queries').default;
const irohaUtil = require('iroha-helpers/lib/util.js');
const txHelper = require('iroha-helpers/lib/txHelper.js').default;
const TxStatusLib = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatus;
const TxStatusRequest = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatusRequest;
/**
* Create Iroha transactions and send them to a node.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const fs = require('fs');
const grpc = require('grpc');
const IrohaService_v1Client = require('iroha-helpers/lib/proto/endpoint_grpc_pb');
const CommandService_v1Client = IrohaService_v1Client.CommandService_v1Client;
const QueryService_v1Client = IrohaService_v1Client.QueryService_v1Client;
const generateKeypair = require('iroha-helpers/lib/cryptoHelper.js').default;
const {BlockchainInterface, CaliperUtils, TxStatus} = require('@hyperledger/caliper-core');
const logger = CaliperUtils.getLogger('iroha.js');
const irohaQueries = require('iroha-helpers/lib/queries').default;
const irohaUtil = require('iroha-helpers/lib/util.js');
const txHelper = require('iroha-helpers/lib/txHelper.js').default;
const TxStatusLib = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatus;
const TxStatusRequest = require('iroha-helpers/lib/proto/endpoint_pb.js').TxStatusRequest;
/**
* Create Iroha transactions and send them to a node.
* @param {Array} txs txToSends