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

style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf #1615

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions sidra_chain_integration/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,40 @@ const repayButton = document.getElementById('repay-button');
const loanStatusDiv = document.getElementById('loan-status');

applyButton.addEventListener('click', async (e) => {
//... (same as before)
// ... (same as before)
});

repayButton.addEventListener('click', async (e) => {
e.preventDefault();
const repaymentAmount = document.getElementById('repayment-amount').value;
e.preventDefault();
const repaymentAmount = document.getElementById('repayment-amount').value;

// Call the smart contract's repayLoan function
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/v3/YOUR_PROJECT_ID'));
const contract = new web3.eth.Contract(LendingContract.abi, LendingContract.address);
const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
const tx = {
from: YOUR_ACCOUNT_ADDRESS,
to: LendingContract.address,
value: '0',
gas: '200000',
gasPrice: '20',
nonce: txCount,
data: contract.methods.repayLoan(repaymentAmount).encodeABI()
};
// Call the smart contract's repayLoan function
const web3 = new Web3(
new Web3.providers.HttpProvider(
'https://mainnet.infura.io/v3/YOUR_PROJECT_ID',
),
);
const contract = new web3.eth.Contract(
LendingContract.abi,
LendingContract.address,
);
const txCount = await web3.eth.getTransactionCount(YOUR_ACCOUNT_ADDRESS);
const tx = {
from: YOUR_ACCOUNT_ADDRESS,
to: LendingContract.address,
value: '0',
gas: '200000',
gasPrice: '20',
nonce: txCount,
data: contract.methods.repayLoan(repaymentAmount).encodeABI(),
};

web3.eth.accounts.signTransaction(tx, YOUR_PRIVATE_KEY)
.then(signedTx => web3.eth.sendSignedTransaction(signedTx.rawTransaction))
.on('transactionHash', hash => console.log(`Transaction hash: ${hash}`))
.on('confirmation', (confirmationNumber, receipt) => {
console.log(`Confirmation number: ${confirmationNumber}`);
loanStatusDiv.innerHTML = `Loan repayment successful!`;
});
web3.eth.accounts
.signTransaction(tx, YOUR_PRIVATE_KEY)
.then((signedTx) => web3.eth.sendSignedTransaction(signedTx.rawTransaction))
.on('transactionHash', (hash) => console.log(`Transaction hash: ${hash}`))
.on('confirmation', (confirmationNumber, receipt) => {
console.log(`Confirmation number: ${confirmationNumber}`);
loanStatusDiv.innerHTML = 'Loan repayment successful!';
});
});
Loading