Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update dependencies and apply new linter rules #2043

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = {
"jsdoc/require-property-description": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/require-param-description": "off",
"jsdoc/tag-lines": ["error"|"warn", "any",{"startLines":0}],
"jsdoc/check-tag-names": [
"warn",
{
Expand Down
10 changes: 5 additions & 5 deletions examples/ContractHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export default class ContractHelper {

return (/** @type {hashgraph.ContractFunctionResult} */ result) => {
const responseStatus = hashgraph.Status._fromCode(
result.getInt32(0)
result.getInt32(0),
);
const isValid = responseStatus == hashgraph.Status.Success;
if (!isValid) {
console.log(
`Encountered invalid response status ${responseStatus.toString()}`
`Encountered invalid response status ${responseStatus.toString()}`,
);
}
return isValid;
Expand Down Expand Up @@ -232,7 +232,7 @@ export default class ContractHelper {
const feePayerAccountId = this.stepFeePayers.get(stepIndex);
if (feePayerAccountId != null) {
transaction.setTransactionId(
hashgraph.TransactionId.generate(feePayerAccountId)
hashgraph.TransactionId.generate(feePayerAccountId),
);
}

Expand All @@ -257,11 +257,11 @@ export default class ContractHelper {

if (this.getResultValidator(stepIndex)(functionResult)) {
console.log(
`step ${stepIndex} completed, and returned valid result. (TransactionId "${record.transactionId.toString()}")`
`step ${stepIndex} completed, and returned valid result. (TransactionId "${record.transactionId.toString()}")`,
);
} else {
console.log(
`Transaction record: ${JSON.stringify(record, null, 2)}`
`Transaction record: ${JSON.stringify(record, null, 2)}`,
);
throw new Error(`step ${stepIndex} returned invalid result`);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/account-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
process.env.HEDERA_NETWORK == null
) {
throw new Error(
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required."
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required.",
);
}

Expand All @@ -30,7 +30,7 @@ async function main() {
const wallet = new Wallet(
process.env.OPERATOR_ID,
process.env.OPERATOR_KEY,
provider
provider,
);

/*
Expand Down Expand Up @@ -82,11 +82,11 @@ async function main() {
*/

AccountId.fromString(
"0.0.302a300506032b6570032100114e6abc371b82dab5c15ea149f02d34a012087b163516dd70f44acafabf7777"
"0.0.302a300506032b6570032100114e6abc371b82dab5c15ea149f02d34a012087b163516dd70f44acafabf7777",
);

PublicKey.fromString(
"302a300506032b6570032100114e6abc371b82dab5c15ea149f02d34a012087b163516dd70f44acafabf7777"
"302a300506032b6570032100114e6abc371b82dab5c15ea149f02d34a012087b163516dd70f44acafabf7777",
).toAccountId(0, 0);

console.log("Transferring some Hbar to the new account");
Expand Down
30 changes: 15 additions & 15 deletions examples/account-allowance.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function main() {
process.env.HEDERA_NETWORK == null
) {
throw new Error(
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required."
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required.",
);
}

Expand All @@ -35,7 +35,7 @@ async function main() {
const wallet = new Wallet(
process.env.OPERATOR_ID,
process.env.OPERATOR_KEY,
provider
provider,
);

console.log("Generating accounts for example...");
Expand Down Expand Up @@ -85,7 +85,7 @@ async function main() {
await printBalances(wallet, aliceId, bobId, charlieId);

console.log(
"Approving an allowance of 2 Hbar with owner Alice and spender Bob"
"Approving an allowance of 2 Hbar with owner Alice and spender Bob",
);

await (
Expand All @@ -103,7 +103,7 @@ async function main() {
await printBalances(wallet, aliceId, bobId, charlieId);

console.log(
"Transferring 1 Hbar from Alice to Charlie, but the transaction is signed _only_ by Bob (Bob is dipping into his allowance from Alice)"
"Transferring 1 Hbar from Alice to Charlie, but the transaction is signed _only_ by Bob (Bob is dipping into his allowance from Alice)",
);

await (
Expand All @@ -114,7 +114,7 @@ async function main() {
// "addApproved*Transfer()" means that the transfer has been approved by an allowance
.addApprovedHbarTransfer(
aliceId,
new Hbar(1).negated()
new Hbar(1).negated(),
)
.addHbarTransfer(charlieId, new Hbar(1))
// The allowance spender must pay the fee for the transaction.
Expand All @@ -127,17 +127,17 @@ async function main() {
).getReceiptWithSigner(wallet);

console.log(
"Transfer succeeded. Bob should now have 1 Hbar left in his allowance."
"Transfer succeeded. Bob should now have 1 Hbar left in his allowance.",
);

await printBalances(wallet, aliceId, bobId, charlieId);

try {
console.log(
"Attempting to transfer 2 Hbar from Alice to Charlie using Bob's allowance."
"Attempting to transfer 2 Hbar from Alice to Charlie using Bob's allowance.",
);
console.log(
"This should fail, because there is only 1 Hbar left in Bob's allowance."
"This should fail, because there is only 1 Hbar left in Bob's allowance.",
);

await (
Expand All @@ -147,7 +147,7 @@ async function main() {
await new TransferTransaction()
.addApprovedHbarTransfer(
aliceId,
new Hbar(2).negated()
new Hbar(2).negated(),
)
.addHbarTransfer(charlieId, new Hbar(2))
.setTransactionId(TransactionId.generate(bobId))
Expand Down Expand Up @@ -178,7 +178,7 @@ async function main() {
).getReceiptWithSigner(wallet);

console.log(
"Attempting to transfer 2 Hbar from Alice to Charlie using Bob's allowance again."
"Attempting to transfer 2 Hbar from Alice to Charlie using Bob's allowance again.",
);
console.log("This time it should succeed.");

Expand All @@ -189,7 +189,7 @@ async function main() {
await new TransferTransaction()
.addApprovedHbarTransfer(
aliceId,
new Hbar(2).negated()
new Hbar(2).negated(),
)
.addHbarTransfer(charlieId, new Hbar(2))
.setTransactionId(TransactionId.generate(bobId))
Expand All @@ -213,7 +213,7 @@ async function main() {
.approveHbarAllowance(
aliceId,
bobId,
Hbar.fromTinybars(0)
Hbar.fromTinybars(0),
)
.freezeWithSigner(wallet)
).sign(aliceKey)
Expand Down Expand Up @@ -280,21 +280,21 @@ async function printBalances(wallet, aliceId, bobId, charlieId) {
await new AccountBalanceQuery()
.setAccountId(aliceId)
.executeWithSigner(wallet)
).hbars.toString()}`
).hbars.toString()}`,
);
console.log(
`Bob's balance: ${(
await new AccountBalanceQuery()
.setAccountId(bobId)
.executeWithSigner(wallet)
).hbars.toString()}`
).hbars.toString()}`,
);
console.log(
`Charlie's balance: ${(
await new AccountBalanceQuery()
.setAccountId(charlieId)
.executeWithSigner(wallet)
).hbars.toString()}`
).hbars.toString()}`,
);
}

Expand Down
12 changes: 6 additions & 6 deletions examples/account-create-with-hts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function main() {

if (process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null) {
throw new Error(
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required."
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required.",
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
Expand Down Expand Up @@ -118,7 +118,7 @@ async function main() {
console.log(
`Created NFT ${nftTokenId.toString()} with serial: ${nftCollection[
i
].serials[0].toString()}`
].serials[0].toString()}`,
);
}

Expand Down Expand Up @@ -188,7 +188,7 @@ async function main() {

nftOwnerAccountId === accountId
? console.log(
`The NFT owner accountId matches the accountId created with the HTS\n`
`The NFT owner accountId matches the accountId created with the HTS\n`,
)
: console.log(`The two account IDs does not match\n`);

Expand Down Expand Up @@ -296,16 +296,16 @@ async function main() {
const balance = (
await axios.get(link)
).data.accounts[0].balance.tokens.find(
(token) => token.token_id === tokenId
(token) => token.token_id === tokenId,
).balance;
/* eslint-enable */

balance === 10
? console.log(
`Account is created successfully using HTS 'TransferTransaction'`
`Account is created successfully using HTS 'TransferTransaction'`,
)
: console.log(
"Creating account with HTS using public key alias failed"
"Creating account with HTS using public key alias failed",
);
} catch (e) {
console.log(e);
Expand Down
10 changes: 5 additions & 5 deletions examples/account-creation-ways.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function main() {
const hederaFormat = AccountId.fromString("0.0.10");
console.log(`Account ID: ${hederaFormat.toString()}`);
console.log(
`Account 0.0.10 corresponding Long-Zero address: ${hederaFormat.toSolidityAddress()}`
`Account 0.0.10 corresponding Long-Zero address: ${hederaFormat.toSolidityAddress()}`,
);

/*
Expand All @@ -38,20 +38,20 @@ function main() {
Hedera Account Long-Zero address - 0x000000000000000000000000000000000000000a (for accountId 0.0.10)
*/
const longZeroAddress = AccountId.fromString(
"0x000000000000000000000000000000000000000a"
"0x000000000000000000000000000000000000000a",
);
console.log(
`Hedera Account Long-Zero address: ${longZeroAddress.toString()}`
`Hedera Account Long-Zero address: ${longZeroAddress.toString()}`,
);

/*
Ethereum Account Address / public-address - 0xb794f5ea0ba39494ce839613fffba74279579268
*/
const evmAddress = AccountId.fromString(
"0xb794f5ea0ba39494ce839613fffba74279579268"
"0xb794f5ea0ba39494ce839613fffba74279579268",
);
console.log(
`Ethereum Account Address / public-address: ${evmAddress.toString()}`
`Ethereum Account Address / public-address: ${evmAddress.toString()}`,
);

if (
Expand Down
6 changes: 3 additions & 3 deletions examples/consensus-pub-sub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions examples/contract-nonces.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function main() {
process.env.HEDERA_NETWORK == null
) {
throw new Error(
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required."
"Environment variables OPERATOR_ID, HEDERA_NETWORK, and OPERATOR_KEY are required.",
);
}

Expand All @@ -26,7 +26,7 @@ async function main() {
const wallet = new Wallet(
process.env.OPERATOR_ID,
process.env.OPERATOR_KEY,
provider
provider,
);

// The contract bytecode is located on the `object` field
Expand All @@ -52,19 +52,18 @@ async function main() {
.setGas(100000)
.setBytecodeFileId(newFileId)
.setContractMemo(
"[e2e::ContractADeploysContractBInConstructor]"
"[e2e::ContractADeploysContractBInConstructor]",
)
.freezeWithSigner(wallet)
).executeWithSigner(wallet);

const record = await contractCreateTxResponse.getRecordWithSigner(
wallet
);
const record =
await contractCreateTxResponse.getRecordWithSigner(wallet);

console.log(
`contractNonces: ${JSON.stringify(
record.contractFunctionResult.contractNonces
)}`
record.contractFunctionResult.contractNonces,
)}`,
);
} catch (error) {
console.error(error);
Expand Down
11 changes: 5 additions & 6 deletions examples/create-account-with-alias-and-receiver-signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Reference: [HIP-583 Expand alias support in CryptoCreate & CryptoTransfer Transa
async function main() {
if (process.env.OPERATOR_ID == null || process.env.OPERATOR_KEY == null) {
throw new Error(
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required."
"Environment variables OPERATOR_ID, and OPERATOR_KEY are required.",
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
Expand All @@ -40,7 +40,7 @@ async function main() {

const client = Client.forNetwork(nodes).setOperator(
operatorId,
operatorKey
operatorKey,
);

try {
Expand Down Expand Up @@ -96,9 +96,8 @@ async function main() {
const accountCreateTxSign = await (
await accountCreateTx.sign(privateKey)
).sign(adminKey);
const accountCreateTxResponse = await accountCreateTxSign.execute(
client
);
const accountCreateTxResponse =
await accountCreateTxSign.execute(client);

/**
*
Expand All @@ -125,7 +124,7 @@ async function main() {

accountInfo.contractAccountId !== null
? console.log(
`The newly created account has an alias: ${accountInfo.contractAccountId}`
`The newly created account has an alias: ${accountInfo.contractAccountId}`,
)
: console.log(`The new account doesn't have an alias`);
} catch (error) {
Expand Down
Loading