Update set-no-freeze and add more debugging

This commit is contained in:
Jackson Mills
2021-10-18 09:50:55 -07:00
parent ea5bc3a31a
commit 95a1de45f7
3 changed files with 26 additions and 32 deletions

View File

@@ -1,36 +1,30 @@
const {RippleAPI} = require('ripple-lib')
const xrpl = require('xrpl')
const api = new RippleAPI({
server: 'wss://s1.ripple.com' // Public rippled server
})
api.on('error', (errorCode, errorMessage) => {
console.log(errorCode + ': ' + errorMessage)
})
async function main() {
// Connect -------------------------------------------------------------------
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
await client.connect()
console.log("Connected to TestNet")
const issuing_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v'
const issuing_secret = 'snnDVkSW3aV6jvMJTPdCiE2Qxv1RW'
// Best practice: get your secret from an encrypted
// config file instead
client.on('error', (errorCode, errorMessage) => {
console.log(errorCode + ': ' + errorMessage)
})
api.connect().then(() => {
const { wallet, balance } = await client.fundWallet()
// Prepare a settings transaction to enable no freeze
const settings = {
'noFreeze': true
// Prepare a settings transaction to enable global freeze
const accountSetTx = {
TransactionType: "AccountSet",
Account: wallet.address,
// Set the NoFreeze flag for this account
SetFlag: xrpl.AccountSetAsfFlags.asfNoFreeze
}
console.log('preparing settings transaction for account:',
issuing_address)
return api.prepareSettings(issuing_address, settings)
console.log('Sign and submit the transaction:', accountSetTx)
await client.submitReliable(wallet, accountSetTx)
console.log("Finished submitting. Now disconnecting.")
await client.disconnect()
}
}).then(prepared_tx => {
// Sign and submit the settings transaction
console.log('signing tx:', prepared_tx.txJSON)
const signed1 = api.sign(prepared_tx.txJSON, issuing_secret)
console.log('submitting tx:', signed1.id)
return api.submit(signed1.signedTransaction)
}).then(() => {
return api.disconnect()
}).catch(console.error)
main().catch(console.error)