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

Adding waitConfirmations function #48

Merged
5 commits merged into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
16 changes: 10 additions & 6 deletions commands/deploy_file.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ exports.handler = async function (argv) {
try {
const { fee: fee } = await archethic.getTransactionFee(transaction, argv.endpoint)
console.log(chalk.yellow("Transaction fee : " +fee))


archethic.waitConfirmations(transaction.address, argv.endpoint, function(nbConfirmations) {
console.log(chalk.magenta("Transaction confirmed with " + nbConfirmations + " replications"))
})

send_file = await archethic.sendTransaction(transaction, argv.endpoint)
if (send_file.status == 'ok') {
console.log(chalk.green("Transaction Sent Successfully !"))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + (toHex(transaction.address)) + "/content?mime=" + mime.getType(argv.file)))
} else {
throw new Error("Transaction not deployed ! Please check if funds are transferred successfully to the generated address")
}

console.log(chalk.green("Transaction Sent Successfully !"))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + (toHex(transaction.address)) + "/content?mime=" + mime.getType(argv.file)))

} catch (e) {
console.error(chalk.red(e.message))
return
Expand Down
17 changes: 11 additions & 6 deletions commands/deploy_folder.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,18 @@ exports.handler = async function (argv) {
try {
const { fee: fee } = await archethic.getTransactionFee(transaction, argv.endpoint)
console.log(chalk.yellow("Transaction fee : " +fee))


archethic.waitConfirmations(transaction.address, argv.endpoint, function(nbConfirmations) {
console.log(chalk.magenta("Transaction confirmed with " + nbConfirmations + " replications"))
})


send_folder = await archethic.sendTransaction(transaction, argv.endpoint)
if (send_folder.status == 'ok') {
console.log(chalk.yellow(Files[i]))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))
} else {
throw new Error(('Transaction not deployed ! Please check if funds are transferred successfully to the generated address'))
}

console.log(chalk.cyan(Files[i]))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))

} catch (e) {
console.error(chalk.red(e.message))
return
Expand Down
36 changes: 22 additions & 14 deletions commands/deploy_website.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,21 @@ exports.handler = async function (argv) {
try {
const { fee: fee } = await archethic.getTransactionFee(transaction, argv.endpoint)
console.log(chalk.yellow("Transaction fee : " +fee))


archethic.waitConfirmations(transaction.address, argv.endpoint, function(nbConfirmations) {
console.log(chalk.magenta("Transaction confirmed with " + nbConfirmations + " replications"))
})


send_folder = await archethic.sendTransaction(transaction, argv.endpoint)
if (send_folder.status == 'ok') {
console.log(chalk.yellow(Files[i]))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))
array_files.push((Files[i].substring(Files[i].indexOf('/') + 1)))
array_address.push(address)

console.log(chalk.cyan(Files[i]))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))
array_files.push((Files[i].substring(Files[i].indexOf('/') + 1)))
array_address.push(address)

} else {
throw new Error(('Transaction not deployed ! Please check if funds are transferred successfully to the generated address'))
}

} catch (e) {
console.error(chalk.red(e.message))
return
Expand Down Expand Up @@ -184,14 +189,17 @@ exports.handler = async function (argv) {
try {
const { fee: fee } = await archethic.getTransactionFee(transaction, argv.endpoint)
console.log(chalk.yellow("Transaction fee : " +fee))


archethic.waitConfirmations(transaction.address, argv.endpoint, function(nbConfirmations) {
console.log(chalk.magenta("Transaction confirmed with " + nbConfirmations + " replications"))
})

send_folder = await archethic.sendTransaction(transaction, argv.endpoint)
if (send_folder.status == 'ok') {
console.log(chalk.green('Check your website at-'))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))

console.log(chalk.green('Check your website at-'))
console.log(chalk.blue(argv.endpoint + "/api/last_transaction/" + address + "/content?mime=" + mime.getType(Files[i])))

} else {
throw new Error(('Transaction not deployed ! Please check if funds are transferred successfully to the generated address'))
}
} catch (e) {
console.error(chalk.red(e.message))
return
Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
"crypto": "^1.0.1",
"figlet": "^1.5.2",
"fs": "^0.0.1-security",
"isomorphic-ws": "^4.0.1",
"jsdom": "^19.0.0",
"mime": "^3.0.0",
"path": "^0.12.7",
"ws": "^8.5.0",
"yargs": "^17.3.0"
}
}