Skip to content

Commit

Permalink
fix: comment-out-not-working-examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ivaylonikolov7 committed Oct 30, 2024
1 parent 0c02eca commit c4e50c5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
16 changes: 14 additions & 2 deletions examples/multi-node-multi-signature-remove.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
import {
Client,
PrivateKey,
Expand All @@ -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 ||
Expand All @@ -46,6 +49,7 @@ async function main() {
* Step 2: Create keys for two users
*
*/
/*
aliceKey = PrivateKey.generate();
bobKey = PrivateKey.generate();
Expand All @@ -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);
Expand All @@ -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))
Expand All @@ -85,7 +91,7 @@ async function main() {
* & Collect multiple signatures (Uint8Array[]) from one key
*
*/

/*
const transferTransactionBytes = transferTransaction.toBytes();
const aliceSignatures = aliceKey.signTransaction(transferTransaction);
Expand All @@ -97,6 +103,7 @@ async function main() {
* & Add the previously collected signatures
*
*/
/*
const signedTransaction = Transaction.fromBytes(transferTransactionBytes);
signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures);
Expand Down Expand Up @@ -131,7 +138,7 @@ async function main() {
* Step 7: Remove the signatures for Alice from the transaction
*
*/

/*
const removedAliceSignatures = signedTransaction.removeSignature(
aliceKey.publicKey,
);
Expand All @@ -158,13 +165,15 @@ async function main() {
* Step 8: Add the removed signature back to the transaction
*
*/
/*
signedTransaction.addSignature(aliceKey.publicKey, removedAliceSignatures);
/**
*
* Step 9: Execute and take the receipt
*
*/
/*
const result = await signedTransaction.execute(client);
const receipt = await result.getReceipt(client);
Expand All @@ -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) => {
Expand All @@ -207,3 +218,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => {
return signatures;
};
*/
15 changes: 13 additions & 2 deletions examples/multi-node-multi-signature-removeAll.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
import {
Client,
PrivateKey,
Expand All @@ -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 ||
Expand All @@ -46,6 +49,7 @@ async function main() {
* Step 2: Create keys for two users
*
*/
/*
aliceKey = PrivateKey.generate();
bobKey = PrivateKey.generate();
Expand All @@ -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);
Expand All @@ -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))
Expand All @@ -88,7 +94,7 @@ async function main() {
* & Collect multiple signatures (Uint8Array[]) from one key
*
*/

/*
const transferTransactionBytes = transferTransaction.toBytes();
const aliceSignatures = aliceKey.signTransaction(transferTransaction);
Expand All @@ -100,6 +106,7 @@ async function main() {
* & Add the previously collected signatures
*
*/
/*
const signedTransaction = Transaction.fromBytes(transferTransactionBytes);
signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures);
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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);
Expand All @@ -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) => {
Expand All @@ -206,3 +216,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => {
return signatures;
};
*/
13 changes: 12 additions & 1 deletion examples/multi-node-multi-signature.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
import {
Client,
PrivateKey,
Expand All @@ -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 ||
Expand All @@ -45,6 +48,7 @@ async function main() {
* Step 2: Create keys for two users
*
*/
/*
aliceKey = PrivateKey.generate();
bobKey = PrivateKey.generate();
Expand All @@ -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);
Expand All @@ -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))
Expand All @@ -84,7 +90,7 @@ async function main() {
* & Collect multiple signatures (Uint8Array[]) from one key
*
*/

/*
const transferTransactionBytes = transferTransaction.toBytes();
const aliceSignatures = aliceKey.signTransaction(transferTransaction);
Expand All @@ -96,6 +102,7 @@ async function main() {
* & Add the previously collected signatures
*
*/
/*
const signedTransaction = Transaction.fromBytes(transferTransactionBytes);
signedTransaction.addSignature(aliceKey.publicKey, aliceSignatures);
Expand Down Expand Up @@ -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);
Expand All @@ -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) => {
Expand All @@ -172,3 +182,4 @@ const getAllSignaturesFromTransaction = (signedTransaction) => {
return signatures;
};
*/
6 changes: 6 additions & 0 deletions examples/multi-sig-offline.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
import {
Client,
PrivateKey,
Expand All @@ -14,9 +15,11 @@ import dotenv from "dotenv";
dotenv.config();
/** @type {PrivateKey | undefined} */
/*
let user1Key;
/** @type {PrivateKey | undefined} */
/*
let user2Key;
async function main() {
Expand Down Expand Up @@ -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);
Expand All @@ -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();
*/

0 comments on commit c4e50c5

Please sign in to comment.