diff --git a/package-lock.json b/package-lock.json index 6290123..996ccbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "commander": "^11.1.0", - "mina-signer": "^2.1.2" + "mina-signer": "latest" }, "devDependencies": { "@babel/preset-env": "^7.16.4", @@ -6821,9 +6821,9 @@ } }, "node_modules/mina-signer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mina-signer/-/mina-signer-2.1.2.tgz", - "integrity": "sha512-fvi1L8vjEFHyZp66eUsCXp80A5WXEHKvGunwLikDWMilVC7bS36AvVZOc1s+8F48xNsKXuxcwkMrPWPzNgechA==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/mina-signer/-/mina-signer-3.0.7.tgz", + "integrity": "sha512-7eYp/6WWj2VzJjvfC8dNeGMud/brdBrzkUsCdysFFXnfV2/FVpVhAGCMfaS6hs0HJtS4+eplmiD2hXfshQS8CQ==", "dependencies": { "blakejs": "^1.2.1", "js-sha256": "^0.9.0" @@ -6928,9 +6928,9 @@ "license": "MIT" }, "node_modules/o1js": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/o1js/-/o1js-0.18.0.tgz", - "integrity": "sha512-A4XFfRLUHxB8ZUzctpxmYA4kBi3ZRwSgeK/KKuWxf2kDmaxjWOxbCzH/1wHelom4QKIgSIaJpXkAtR0jJv7tqw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/o1js/-/o1js-1.1.0.tgz", + "integrity": "sha512-rq+ndUFZBzC+Gk3VbXGNu97uFZJTLDmqglP1J8gGWP3Bdchjj+huCtPVvezfiw6+RyjPePaBVSbPWO11HMZiaQ==", "peer": true, "dependencies": { "blakejs": "1.2.1", @@ -6944,7 +6944,7 @@ "snarky-run": "src/build/run.js" }, "engines": { - "node": ">=16.4.0" + "node": ">=18.14.0" } }, "node_modules/once": { @@ -12635,9 +12635,9 @@ "dev": true }, "mina-signer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/mina-signer/-/mina-signer-2.1.2.tgz", - "integrity": "sha512-fvi1L8vjEFHyZp66eUsCXp80A5WXEHKvGunwLikDWMilVC7bS36AvVZOc1s+8F48xNsKXuxcwkMrPWPzNgechA==", + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/mina-signer/-/mina-signer-3.0.7.tgz", + "integrity": "sha512-7eYp/6WWj2VzJjvfC8dNeGMud/brdBrzkUsCdysFFXnfV2/FVpVhAGCMfaS6hs0HJtS4+eplmiD2hXfshQS8CQ==", "requires": { "blakejs": "^1.2.1", "js-sha256": "^0.9.0" @@ -12711,9 +12711,9 @@ "dev": true }, "o1js": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/o1js/-/o1js-0.18.0.tgz", - "integrity": "sha512-A4XFfRLUHxB8ZUzctpxmYA4kBi3ZRwSgeK/KKuWxf2kDmaxjWOxbCzH/1wHelom4QKIgSIaJpXkAtR0jJv7tqw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/o1js/-/o1js-1.1.0.tgz", + "integrity": "sha512-rq+ndUFZBzC+Gk3VbXGNu97uFZJTLDmqglP1J8gGWP3Bdchjj+huCtPVvezfiw6+RyjPePaBVSbPWO11HMZiaQ==", "peer": true, "requires": { "blakejs": "1.2.1", diff --git a/package.json b/package.json index b54cbaf..27301ab 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,6 @@ }, "dependencies": { "commander": "^11.1.0", - "mina-signer": "^2.1.2" + "mina-signer": "latest" } -} +} \ No newline at end of file diff --git a/src/combined.ts b/src/combined.ts index 1b5f406..5826a94 100644 --- a/src/combined.ts +++ b/src/combined.ts @@ -9,6 +9,7 @@ export async function applyGenerator( transactionAmount: string, transactionFee: string, transactionType: string, + networkProfile: 'mainnet' | 'testnet', i: number) { if (transactionType === 'regular') { await processTransaction( @@ -17,7 +18,8 @@ export async function applyGenerator( receiver, parseInt(transactionInterval), parseFloat(transactionAmount), - parseFloat(transactionFee) + parseFloat(transactionFee), + networkProfile ); } else if (transactionType === 'zkApp') { @@ -27,7 +29,8 @@ export async function applyGenerator( receiver, parseInt(transactionInterval), parseFloat(transactionAmount), - parseFloat(transactionFee)) + parseFloat(transactionFee), + networkProfile); } else { if (i % 2 === 0) { @@ -37,8 +40,9 @@ export async function applyGenerator( receiver, parseInt(transactionInterval), parseFloat(transactionAmount), - parseFloat(transactionFee) - ); + parseFloat(transactionFee), + networkProfile + ) } else { await processZKTransaction( @@ -47,7 +51,8 @@ export async function applyGenerator( receiver, parseInt(transactionInterval), parseFloat(transactionAmount), - parseFloat(transactionFee) + parseFloat(transactionFee), + networkProfile ); } } diff --git a/src/entry.ts b/src/entry.ts index 476e774..30aa5c7 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -14,6 +14,7 @@ program .option('-t, --transaction-type ', 'transaction type (zkApp or regular)', 'regular') .option('-a, --transaction-amount ', 'amount of Mina to send', '2') .option('-f, --transaction-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; @@ -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); @@ -50,6 +52,14 @@ program if (process.env.TRANSACTION_FEE) { transactionFee = process.env.TRANSACTION_FEE } + if (process.env.NETWORK_PROFILE) { + networkProfile = process.env.NETWORK_PROFILE + } + 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)) { @@ -63,6 +73,7 @@ program transactionAmount, transactionFee, transactionType, + networkProfile, incr); incr++ } diff --git a/src/paymentGenerator.ts b/src/paymentGenerator.ts index c1f26a3..a2488ae 100644 --- a/src/paymentGenerator.ts +++ b/src/paymentGenerator.ts @@ -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: 'testnet' }); + const client = new Client({ network: networkProfile }); let sender_public = client.derivePublicKey(deployerAccount) console.log("receiver: ", receiver); let amountToSend = amount * 1000000000; diff --git a/src/zkAppGenerator.ts b/src/zkAppGenerator.ts index feb5e0a..ccc6431 100644 --- a/src/zkAppGenerator.ts +++ b/src/zkAppGenerator.ts @@ -12,11 +12,13 @@ export async function processZKTransaction( receiver: string, timeDelayMS: number, amount: number, - fee: number + fee: number, + networkProfile: 'mainnet' | 'testnet' ) { - const devNet = Mina.Network( - network - ); + const devNet = Mina.Network({ + mina: network, + networkId: networkProfile + }); Mina.setActiveInstance(devNet); let amountToSend = amount * 1000000000;