mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 19:55:54 +00:00
Update set-no-freeze and add more debugging
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user