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

@@ -15,15 +15,15 @@ async function main() {
const accountSetTx = { const accountSetTx = {
TransactionType: "AccountSet", TransactionType: "AccountSet",
Account: wallet.address, Account: wallet.address,
// Send a flag to turn on a global freeze on this account
SetFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze SetFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze
} }
// Sign and submit the settings transaction // Sign and submit the settings transaction
console.log('Sign and submit the transaction:', accountSetTx) console.log('Sign and submit the transaction:', accountSetTx)
await client.submitReliable(wallet, accountSetTx) await client.submitReliable(wallet, accountSetTx)
client.disconnect() await client.disconnect()
} }
main().catch(console.error) main().catch(console.error)

View File

@@ -74,7 +74,7 @@ async function main() {
const result = await client.submitReliable(wallet, trust_set) const result = await client.submitReliable(wallet, trust_set)
console.log('Submitted tx!') console.log('Submitted tx!')
client.disconnect() await client.disconnect()
} }
main().catch(console.error) main().catch(console.error)

View File

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