From afb61a30030e07cf1c4fc9ae18834013fcdbbaf9 Mon Sep 17 00:00:00 2001 From: Ivaylo Nikolov Date: Wed, 30 Oct 2024 13:24:27 +0200 Subject: [PATCH] fix: comment-out-not-working-examples Signed-off-by: Ivaylo Nikolov --- examples/multi-node-multi-signature-remove.js | 16 ++++++++++++++-- examples/multi-node-multi-signature-removeAll.js | 15 +++++++++++++-- examples/multi-node-multi-signature.js | 13 ++++++++++++- examples/multi-sig-offline.js | 6 ++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/examples/multi-node-multi-signature-remove.js b/examples/multi-node-multi-signature-remove.js index 12f1db1ae..f5216c9aa 100644 --- a/examples/multi-node-multi-signature-remove.js +++ b/examples/multi-node-multi-signature-remove.js @@ -1,3 +1,4 @@ +/* import { Client, PrivateKey, @@ -20,12 +21,14 @@ let bobKey; * @description Create a transaction with multiple nodes and multiple signatures * and remove one of the signatures from the transaction then add it back */ +/* async function main() { /** * * Step 1: Create Client * */ +/* if ( process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null || @@ -46,6 +49,7 @@ async function main() { * Step 2: Create keys for two users * */ +/* aliceKey = PrivateKey.generate(); bobKey = PrivateKey.generate(); @@ -56,6 +60,7 @@ async function main() { * Step 3: Create an account with the keyList * */ +/* const createAccountTransaction = new AccountCreateTransaction() .setInitialBalance(new Hbar(2)) .setKey(keyList); @@ -68,6 +73,7 @@ async function main() { * Step 4: Create a transfer transaction with multiple nodes * */ +/* const transferTransaction = new TransferTransaction() .addHbarTransfer(createReceipt.accountId, new Hbar(-1)) .addHbarTransfer("0.0.3", new Hbar(1)) @@ -85,7 +91,7 @@ async function main() { * & Collect multiple signatures (Uint8Array[]) from one key * */ - +/* const transferTransactionBytes = transferTransaction.toBytes(); const aliceSignatures = aliceKey.signTransaction(transferTransaction); @@ -97,6 +103,7 @@ async function main() { * & Add the previously collected signatures * */ +/* const signedTransaction = Transaction.fromBytes(transferTransactionBytes); signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures); @@ -131,7 +138,7 @@ async function main() { * Step 7: Remove the signatures for Alice from the transaction * */ - +/* const removedAliceSignatures = signedTransaction.removeSignature( aliceKey.publicKey, ); @@ -158,6 +165,7 @@ async function main() { * Step 8: Add the removed signature back to the transaction * */ +/* signedTransaction.addSignature(aliceKey.publicKey, removedAliceSignatures); /** @@ -165,6 +173,7 @@ async function main() { * Step 9: Execute and take the receipt * */ +/* const result = await signedTransaction.execute(client); const receipt = await result.getReceipt(client); @@ -181,8 +190,10 @@ void main(); * @param {Transaction} signedTransaction - The signed transaction object containing the list of signed transactions. * @returns {string[]} An array of signatures in DER format. */ +/* const getAllSignaturesFromTransaction = (signedTransaction) => { /** @type {string[]} */ +/* const signatures = []; signedTransaction._signedTransactions.list.forEach((transaction) => { @@ -207,3 +218,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => { return signatures; }; +*/ diff --git a/examples/multi-node-multi-signature-removeAll.js b/examples/multi-node-multi-signature-removeAll.js index 491974a86..9bf79ca9d 100644 --- a/examples/multi-node-multi-signature-removeAll.js +++ b/examples/multi-node-multi-signature-removeAll.js @@ -1,3 +1,4 @@ +/* import { Client, PrivateKey, @@ -20,12 +21,14 @@ let bobKey; * @description Create a transaction with multiple nodes and multiple signatures * and remove all of the signatures from the transaction */ +/* async function main() { /** * * Step 1: Create Client * */ +/* if ( process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null || @@ -46,6 +49,7 @@ async function main() { * Step 2: Create keys for two users * */ +/* aliceKey = PrivateKey.generate(); bobKey = PrivateKey.generate(); @@ -59,6 +63,7 @@ async function main() { * Step 3: Create an account with the keyList * */ +/* const createAccountTransaction = new AccountCreateTransaction() .setInitialBalance(new Hbar(2)) .setKey(keyList); @@ -71,6 +76,7 @@ async function main() { * Step 4: Create a transfer transaction with multiple nodes * */ +/* const transferTransaction = new TransferTransaction() .addHbarTransfer(createReceipt.accountId, new Hbar(-1)) .addHbarTransfer("0.0.3", new Hbar(1)) @@ -88,7 +94,7 @@ async function main() { * & Collect multiple signatures (Uint8Array[]) from one key * */ - +/* const transferTransactionBytes = transferTransaction.toBytes(); const aliceSignatures = aliceKey.signTransaction(transferTransaction); @@ -100,6 +106,7 @@ async function main() { * & Add the previously collected signatures * */ +/* const signedTransaction = Transaction.fromBytes(transferTransactionBytes); signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures); @@ -134,7 +141,7 @@ async function main() { * Step 7: Remove all signatures from the transaction and add them back * */ - +/* const allSignaturesRemoved = signedTransaction.removeAllSignatures(); const signaturesInTheTransactionAfter = @@ -164,6 +171,7 @@ async function main() { * Step 8: Execute and take the receipt * */ +/* const result = await signedTransaction.execute(client); const receipt = await result.getReceipt(client); @@ -180,8 +188,10 @@ void main(); * @param {Transaction} signedTransaction - The signed transaction object containing the list of signed transactions. * @returns {string[]} An array of signatures in DER format. */ +/* const getAllSignaturesFromTransaction = (signedTransaction) => { /** @type {string[]} */ +/* const signatures = []; signedTransaction._signedTransactions.list.forEach((transaction) => { @@ -206,3 +216,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => { return signatures; }; +*/ diff --git a/examples/multi-node-multi-signature.js b/examples/multi-node-multi-signature.js index 558ba7396..d43410b20 100644 --- a/examples/multi-node-multi-signature.js +++ b/examples/multi-node-multi-signature.js @@ -1,3 +1,4 @@ +/* import { Client, PrivateKey, @@ -19,12 +20,14 @@ let bobKey; /** * @description Create a transaction with multiple nodes and multiple signatures */ +/* async function main() { /** * * Step 1: Create Client * */ +/* if ( process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null || @@ -45,6 +48,7 @@ async function main() { * Step 2: Create keys for two users * */ +/* aliceKey = PrivateKey.generate(); bobKey = PrivateKey.generate(); @@ -55,6 +59,7 @@ async function main() { * Step 3: Create an account with the keyList * */ +/* const createAccountTransaction = new AccountCreateTransaction() .setInitialBalance(new Hbar(2)) .setKey(keyList); @@ -67,6 +72,7 @@ async function main() { * Step 4: Create a transfer transaction with multiple nodes * */ +/* const transferTransaction = new TransferTransaction() .addHbarTransfer(createReceipt.accountId, new Hbar(-1)) .addHbarTransfer("0.0.3", new Hbar(1)) @@ -84,7 +90,7 @@ async function main() { * & Collect multiple signatures (Uint8Array[]) from one key * */ - +/* const transferTransactionBytes = transferTransaction.toBytes(); const aliceSignatures = aliceKey.signTransaction(transferTransaction); @@ -96,6 +102,7 @@ async function main() { * & Add the previously collected signatures * */ +/* const signedTransaction = Transaction.fromBytes(transferTransactionBytes); signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures); @@ -130,6 +137,7 @@ async function main() { * Step 7: Execute and take the receipt * */ +/* const result = await signedTransaction.execute(client); const receipt = await result.getReceipt(client); @@ -146,8 +154,10 @@ void main(); * @param {Transaction} signedTransaction - The signed transaction object containing the list of signed transactions. * @returns {string[]} An array of signatures in DER format. */ +/* const getAllSignaturesFromTransaction = (signedTransaction) => { /** @type {string[]} */ +/* const signatures = []; signedTransaction._signedTransactions.list.forEach((transaction) => { @@ -172,3 +182,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => { return signatures; }; +*/ diff --git a/examples/multi-sig-offline.js b/examples/multi-sig-offline.js index a574d07d1..ac9f05cb8 100644 --- a/examples/multi-sig-offline.js +++ b/examples/multi-sig-offline.js @@ -1,3 +1,4 @@ +/* import { Client, PrivateKey, @@ -14,9 +15,11 @@ import dotenv from "dotenv"; dotenv.config(); /** @type {PrivateKey | undefined} */ +/* let user1Key; /** @type {PrivateKey | undefined} */ +/* let user2Key; async function main() { @@ -91,6 +94,7 @@ async function main() { * @param {Uint8Array} transactionBytes * @returns {Uint8Array | Uint8Array[]} */ +/* function user1Signs(transactionBytes) { const transaction = Transaction.fromBytes(transactionBytes); return user1Key.signTransaction(transaction); @@ -100,9 +104,11 @@ function user1Signs(transactionBytes) { * @param {Uint8Array} transactionBytes * @returns {Uint8Array | Uint8Array[]} */ +/* function user2Signs(transactionBytes) { const transaction = Transaction.fromBytes(transactionBytes); return user2Key.signTransaction(transaction); } void main(); +*/