Skip to content

Commit

Permalink
Add network profile as argu
Browse files Browse the repository at this point in the history
  • Loading branch information
ejMina226 committed Apr 24, 2024
1 parent 67bdcee commit 591abad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/combined.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export async function applyGenerator(
transactionAmount: string,
transactionFee: string,
transactionType: string,
networkProfile: 'mainnet' | 'testnet',
i: number) {
if (transactionType === 'regular') {
await processTransaction(
Expand All @@ -17,7 +18,8 @@ export async function applyGenerator(
receiver,
parseInt(transactionInterval),
parseFloat(transactionAmount),
parseFloat(transactionFee)
parseFloat(transactionFee),
networkProfile
);
}
else if (transactionType === 'zkApp') {
Expand All @@ -27,7 +29,7 @@ export async function applyGenerator(
receiver,
parseInt(transactionInterval),
parseFloat(transactionAmount),
parseFloat(transactionFee))
parseFloat(transactionFee));
}
else {
if (i % 2 === 0) {
Expand All @@ -37,8 +39,9 @@ export async function applyGenerator(
receiver,
parseInt(transactionInterval),
parseFloat(transactionAmount),
parseFloat(transactionFee)
);
parseFloat(transactionFee),
networkProfile
)
}
else {
await processZKTransaction(
Expand Down
11 changes: 11 additions & 0 deletions src/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ program
.option('-t, --transaction-type <type>', 'transaction type (zkApp or regular)', 'regular')
.option('-a, --transaction-amount <amount>', 'amount of Mina to send', '2')
.option('-f, --transaction-fee <fee>', 'transaction fee', '0.1')
.option('-n, --network-profile', 'use network profile', 'testnet')
.action(async (options) => {
const url = options.url || process.env.MINA_GRAPHQL_URL;
const senderPrivateKey = options.senderPrivateKey || process.env.SENDER_PRIVATE_KEY;
Expand All @@ -23,6 +24,7 @@ program
let transactionType = options.transactionType;
let transactionAmount = options.transactionAmount;
let transactionFee = options.transactionFee;
let networkProfile = options.networkProfile;
if (!url) {
console.error("url is not specified or MINA_GRAPHQL_URL is not set.");
process.exit(1);
Expand Down Expand Up @@ -50,6 +52,14 @@ program
if (process.env.TRANSACTION_FEE) {
transactionFee = process.env.TRANSACTION_FEE
}
if (process.env.NETWORK_PROFILE) {
transactionInterval = process.env.TRANSACTION_INTERVAL
}
let networkProfileTypes = ['testnet', 'mainnet'];
if (!networkProfileTypes.includes(networkProfile)) {
console.log('Invalid network profile');
return;
}
let receivers = fs.readFileSync(walletList).toString().split("\n");
let transactionTypes = ['regular', 'zkApp', 'mixed']
if (transactionTypes.includes(transactionType)) {
Expand All @@ -63,6 +73,7 @@ program
transactionAmount,
transactionFee,
transactionType,
networkProfile,
incr);
incr++
}
Expand Down
5 changes: 3 additions & 2 deletions src/paymentGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export async function processTransaction(
receiver: string,
timeDelayMS: number,
amount: number,
fee: number
fee: number,
networkProfile: 'mainnet' | 'testnet'
) {
const client = new Client({ network: 'mainnet' });
const client = new Client({ network: networkProfile });
let sender_public = client.derivePublicKey(deployerAccount)
console.log("receiver: ", receiver);
let amountToSend = amount * 1000000000;
Expand Down

0 comments on commit 591abad

Please sign in to comment.