mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
Remove semi-colons
This commit is contained in:
@@ -12,19 +12,19 @@ async function main() {
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
client.on('error', (errorCode, errorMessage) => {
|
client.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage)
|
||||||
});
|
})
|
||||||
|
|
||||||
const my_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
|
const my_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
|
||||||
|
|
||||||
// Look up settings object
|
// Look up settings object
|
||||||
const response = await client.request({command: 'account_info', account: my_address });
|
const response = await client.request({command: 'account_info', account: my_address })
|
||||||
const settings = response.result
|
const settings = response.result
|
||||||
|
|
||||||
console.log('Got settings for address', my_address);
|
console.log('Got settings for address', my_address);
|
||||||
console.log('Global Freeze enabled?',
|
console.log('Global Freeze enabled?',
|
||||||
(settings.globalFreeze === true));
|
(settings.globalFreeze === true))
|
||||||
console.log('No Freeze enabled?', (settings.noFreeze === true));
|
console.log('No Freeze enabled?', (settings.noFreeze === true))
|
||||||
|
|
||||||
await client.disconnect()
|
await client.disconnect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,28 +12,28 @@ async function main() {
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
client.on('error', (errorCode, errorMessage) => {
|
client.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage)
|
||||||
});
|
})
|
||||||
|
|
||||||
const my_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
|
const my_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'
|
||||||
const counterparty_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v';
|
const counterparty_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v'
|
||||||
const frozen_currency = 'USD';
|
const frozen_currency = 'USD'
|
||||||
|
|
||||||
// Look up current state of trust line
|
// Look up current state of trust line
|
||||||
const account_lines = {
|
const account_lines = {
|
||||||
command: 'account_lines',
|
command: 'account_lines',
|
||||||
account: my_address,
|
account: my_address,
|
||||||
peer: counterparty_address,
|
peer: counterparty_address,
|
||||||
};
|
}
|
||||||
|
|
||||||
console.log('looking up all trust lines from',
|
console.log('looking up all trust lines from',
|
||||||
counterparty_address, 'to', my_address);
|
counterparty_address, 'to', my_address)
|
||||||
|
|
||||||
const data = await client.request(account_lines)
|
const data = await client.request(account_lines)
|
||||||
|
|
||||||
// There is only one trust line per currency code per account,
|
// There is only one trust line per currency code per account,
|
||||||
// so we stop after the first match
|
// so we stop after the first match
|
||||||
let trustline = null;
|
let trustline = null
|
||||||
for (let i = 0; i < data.result.lines.length; i++) {
|
for (let i = 0; i < data.result.lines.length; i++) {
|
||||||
if(data.result.lines[i].currency === frozen_currency) {
|
if(data.result.lines[i].currency === frozen_currency) {
|
||||||
trustline = data.result.lines[i]
|
trustline = data.result.lines[i]
|
||||||
@@ -46,9 +46,9 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('Trust line frozen from our side?',
|
console.log('Trust line frozen from our side?',
|
||||||
trustline.freeze === true);
|
trustline.freeze === true)
|
||||||
console.log('Trust line frozen from counterparty\'s side?',
|
console.log('Trust line frozen from counterparty\'s side?',
|
||||||
trustline.freeze_peer === true);
|
trustline.freeze_peer === true)
|
||||||
|
|
||||||
await client.disconnect()
|
await client.disconnect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ async function main() {
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
client.on('error', (errorCode, errorMessage) => {
|
client.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage)
|
||||||
});
|
})
|
||||||
|
|
||||||
const { wallet, balance } = await client.fundWallet()
|
const { wallet, balance } = await client.fundWallet()
|
||||||
|
|
||||||
@@ -16,12 +16,12 @@ async function main() {
|
|||||||
TransactionType: "AccountSet",
|
TransactionType: "AccountSet",
|
||||||
Account: wallet.address,
|
Account: wallet.address,
|
||||||
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()
|
client.disconnect()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { validate } = require('xrpl');
|
const { validate } = require('xrpl')
|
||||||
const xrpl = require('xrpl')
|
const xrpl = require('xrpl')
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
@@ -7,32 +7,32 @@ async function main() {
|
|||||||
await client.connect()
|
await client.connect()
|
||||||
|
|
||||||
client.on('error', (errorCode, errorMessage) => {
|
client.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage)
|
||||||
});
|
})
|
||||||
|
|
||||||
// Generates a test account
|
// Generates a test account
|
||||||
const { wallet, balance } = await client.fundWallet()
|
const { wallet, balance } = await client.fundWallet()
|
||||||
|
|
||||||
const issuing_address = wallet.classicAddress
|
const issuing_address = wallet.classicAddress
|
||||||
const address_to_freeze = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v';
|
const address_to_freeze = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v'
|
||||||
const currency_to_freeze = 'USD';
|
const currency_to_freeze = 'USD'
|
||||||
|
|
||||||
// Look up current state of trust line
|
// Look up current state of trust line
|
||||||
const account_lines = {
|
const account_lines = {
|
||||||
command: 'account_lines',
|
command: 'account_lines',
|
||||||
account: issuing_address,
|
account: issuing_address,
|
||||||
peer: address_to_freeze,
|
peer: address_to_freeze,
|
||||||
};
|
}
|
||||||
|
|
||||||
console.log('Looking up', currency_to_freeze, 'trust line from',
|
console.log('Looking up', currency_to_freeze, 'trust line from',
|
||||||
issuing_address, 'to', address_to_freeze);
|
issuing_address, 'to', address_to_freeze)
|
||||||
|
|
||||||
const data = await client.request(account_lines)
|
const data = await client.request(account_lines)
|
||||||
const trustlines = data.result.lines
|
const trustlines = data.result.lines
|
||||||
|
|
||||||
// There can only be one trust line per currency code per account,
|
// There can only be one trust line per currency code per account,
|
||||||
// so we stop after the first match
|
// so we stop after the first match
|
||||||
let trustline = null;
|
let trustline = null
|
||||||
for (let i = 0; i < trustlines.length; i++) {
|
for (let i = 0; i < trustlines.length; i++) {
|
||||||
if(trustlines[i].currency === currency_to_freeze) {
|
if(trustlines[i].currency === currency_to_freeze) {
|
||||||
trustline = trustlines[i]
|
trustline = trustlines[i]
|
||||||
@@ -40,9 +40,9 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let limit = null;
|
let limit = null
|
||||||
if(trustline === null) {
|
if(trustline === null) {
|
||||||
console.log('Trustline not found, making a default one');
|
console.log('Trustline not found, making a default one')
|
||||||
|
|
||||||
limit = {
|
limit = {
|
||||||
value: '0',
|
value: '0',
|
||||||
@@ -70,7 +70,7 @@ async function main() {
|
|||||||
// For JS users, validate lets you check if your transaction is well-formed
|
// For JS users, validate lets you check if your transaction is well-formed
|
||||||
validate(trust_set)
|
validate(trust_set)
|
||||||
|
|
||||||
console.log('Submitting TrustSet tx:', trust_set);
|
console.log('Submitting TrustSet tx:', trust_set)
|
||||||
const result = await client.submitReliable(wallet, trust_set)
|
const result = await client.submitReliable(wallet, trust_set)
|
||||||
|
|
||||||
console.log('Submitted tx!')
|
console.log('Submitted tx!')
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
const {RippleAPI} = require('ripple-lib');
|
const {RippleAPI} = require('ripple-lib')
|
||||||
|
|
||||||
const api = new RippleAPI({
|
const api = new RippleAPI({
|
||||||
server: 'wss://s1.ripple.com' // Public rippled server
|
server: 'wss://s1.ripple.com' // Public rippled server
|
||||||
});
|
})
|
||||||
api.on('error', (errorCode, errorMessage) => {
|
api.on('error', (errorCode, errorMessage) => {
|
||||||
console.log(errorCode + ': ' + errorMessage);
|
console.log(errorCode + ': ' + errorMessage)
|
||||||
});
|
})
|
||||||
|
|
||||||
const issuing_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v';
|
const issuing_address = 'rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v'
|
||||||
const issuing_secret = 'snnDVkSW3aV6jvMJTPdCiE2Qxv1RW';
|
const issuing_secret = 'snnDVkSW3aV6jvMJTPdCiE2Qxv1RW'
|
||||||
// Best practice: get your secret from an encrypted
|
// Best practice: get your secret from an encrypted
|
||||||
// config file instead
|
// config file instead
|
||||||
|
|
||||||
@@ -17,20 +17,20 @@ api.connect().then(() => {
|
|||||||
// Prepare a settings transaction to enable no freeze
|
// Prepare a settings transaction to enable no freeze
|
||||||
const settings = {
|
const settings = {
|
||||||
'noFreeze': true
|
'noFreeze': true
|
||||||
};
|
}
|
||||||
|
|
||||||
console.log('preparing settings transaction for account:',
|
console.log('preparing settings transaction for account:',
|
||||||
issuing_address);
|
issuing_address)
|
||||||
return api.prepareSettings(issuing_address, settings);
|
return api.prepareSettings(issuing_address, settings)
|
||||||
|
|
||||||
}).then(prepared_tx => {
|
}).then(prepared_tx => {
|
||||||
|
|
||||||
// Sign and submit the settings transaction
|
// Sign and submit the settings transaction
|
||||||
console.log('signing tx:', prepared_tx.txJSON);
|
console.log('signing tx:', prepared_tx.txJSON)
|
||||||
const signed1 = api.sign(prepared_tx.txJSON, issuing_secret);
|
const signed1 = api.sign(prepared_tx.txJSON, issuing_secret)
|
||||||
console.log('submitting tx:', signed1.id);
|
console.log('submitting tx:', signed1.id)
|
||||||
|
|
||||||
return api.submit(signed1.signedTransaction);
|
return api.submit(signed1.signedTransaction)
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return api.disconnect();
|
return api.disconnect()
|
||||||
}).catch(console.error);
|
}).catch(console.error)
|
||||||
|
|||||||
Reference in New Issue
Block a user