docs: export and document asf Flags (#1525)

* docs: export and document asf Flags
This commit is contained in:
Nathan Nichols
2021-08-12 13:30:26 -05:00
committed by GitHub
parent 8b79fe6ba1
commit decc395e5b
6 changed files with 40 additions and 6 deletions

View File

@@ -101,6 +101,7 @@
- [iso8601ToRippleTime](#iso8601torippletime)
- [rippleTimeToISO8601](#rippletimetoiso8601)
- [txFlags](#txflags)
- [accountSetFlags](#accountsetflags)
- [schemaValidator](#schemavalidator)
- [schemaValidate](#schemavalidate)
- [API Events](#api-events)
@@ -6410,6 +6411,21 @@ The remaining transaction types do not have any flags at this time.
* PaymentChannelCreate
* PaymentChannelFund
## accountSetFlags
To modify account flags, you can use an AccountSet transaction and its `SetFlag` or `ClearFlag` fields.
The flags are called [AccountSet flags (asf*)](https://xrpl.org/accountset.html#accountset-flags):
`RippleAPI.accountSetFlags.requireDestinationTag`: Require a destination tag to send transactions to this account.
`RippleAPI.accountSetFlags.requireAuthorization`: Require authorization for users to hold balances issued by this address. Can only be enabled if the address has no trust lines connected to it.
`RippleAPI.accountSetFlags.disallowIncomingXRP`: XRP should not be sent to this account. (Enforced by client applications, not by rippled)
`RippleAPI.accountSetFlags.disableMasterKey`: Disallow use of the master key pair. Can only be enabled if the account has configured another way to sign transactions.
`RippleAPI.accountSetFlags.enableTransactionIDTracking`: Track the ID of this account's most recent transaction.
`RippleAPI.accountSetFlags.noFreeze`: Permanently give up the ability to freeze individual trust lines or disable Global Freeze. This flag can never be disabled after being enabled.
`RippleAPI.accountSetFlags.globalFreeze`: Freeze all assets issued by this account.
`RippleAPI.accountSetFlags.defaultRipple`: Enable [rippling](https://xrpl.org/rippling.html) on this account's trust lines by default.
`RippleAPI.accountSetFlags.depositAuth`:Enable Deposit Authorization on this account.
## schemaValidator
Unlike the rest of the ripple-lib API, schemaValidator is a static object on RippleAPI. It provides utility methods that do not use a server.

View File

@@ -0,0 +1,15 @@
## accountSetFlags
To modify account flags, you can use an AccountSet transaction and its `SetFlag` or `ClearFlag` fields.
The flags are called [AccountSet flags (asf*)](https://xrpl.org/accountset.html#accountset-flags):
`RippleAPI.accountSetFlags.requireDestinationTag`: Require a destination tag to send transactions to this account.
`RippleAPI.accountSetFlags.requireAuthorization`: Require authorization for users to hold balances issued by this address. Can only be enabled if the address has no trust lines connected to it.
`RippleAPI.accountSetFlags.disallowIncomingXRP`: XRP should not be sent to this account. (Enforced by client applications, not by rippled)
`RippleAPI.accountSetFlags.disableMasterKey`: Disallow use of the master key pair. Can only be enabled if the account has configured another way to sign transactions.
`RippleAPI.accountSetFlags.enableTransactionIDTracking`: Track the ID of this account's most recent transaction.
`RippleAPI.accountSetFlags.noFreeze`: Permanently give up the ability to freeze individual trust lines or disable Global Freeze. This flag can never be disabled after being enabled.
`RippleAPI.accountSetFlags.globalFreeze`: Freeze all assets issued by this account.
`RippleAPI.accountSetFlags.defaultRipple`: Enable [rippling](https://xrpl.org/rippling.html) on this account's trust lines by default.
`RippleAPI.accountSetFlags.depositAuth`:Enable Deposit Authorization on this account.

View File

@@ -66,5 +66,6 @@
<%- include('iso8601ToRippleTime.md.ejs') %>
<%- include('rippleTimeToISO8601.md.ejs') %>
<%- include('txFlags.md.ejs') %>
<%- include('accountSetFlags.md.ejs') %>
<%- include('schemaValidator.md.ejs') %>
<%- include('events.md.ejs') %>

View File

@@ -1,6 +1,7 @@
import {EventEmitter} from 'events'
import {
Connection,
constants,
errors,
validate,
xrpToDrops,
@@ -8,7 +9,7 @@ import {
rippleTimeToISO8601,
iso8601ToRippleTime,
txFlags,
ensureClassicAddress
ensureClassicAddress,
} from './common'
import {
connect,
@@ -487,6 +488,7 @@ class RippleAPI extends EventEmitter {
rippleTimeToISO8601 = rippleTimeToISO8601 // @deprecated Invoke from top-level package instead
iso8601ToRippleTime = iso8601ToRippleTime // @deprecated Invoke from top-level package instead
txFlags = txFlags
static accountSetFlags = constants.AccountSetFlags
isValidAddress = schemaValidator.isValidAddress
isValidSecret = schemaValidator.isValidSecret

View File

@@ -70,7 +70,7 @@ export interface Settings {
defaultRipple?: boolean
}
const AccountFlagIndices = {
const AccountSetFlags = {
requireDestinationTag: txFlagIndices.AccountSet.asfRequireDest,
requireAuthorization: txFlagIndices.AccountSet.asfRequireAuth,
depositAuth: txFlagIndices.AccountSet.asfDepositAuth,
@@ -96,4 +96,4 @@ const AccountFields = {
TickSize: {name: 'tickSize', defaults: 0}
}
export {AccountFields, AccountFlagIndices, AccountFlags}
export {AccountFields, AccountSetFlags, AccountFlags}

View File

@@ -2,7 +2,7 @@ import * as assert from 'assert'
import BigNumber from 'bignumber.js'
import * as utils from './utils'
const validate = utils.common.validate
const AccountFlagIndices = utils.common.constants.AccountFlagIndices
const AccountSetFlags = utils.common.constants.AccountSetFlags
const AccountFields = utils.common.constants.AccountFields
import {
Instructions,
@@ -17,14 +17,14 @@ function setTransactionFlags(
txJSON: TransactionJSON,
values: FormattedSettings
) {
const keys = Object.keys(values).filter((key) => AccountFlagIndices[key] != null)
const keys = Object.keys(values).filter((key) => AccountSetFlags[key] != null)
assert.ok(
keys.length <= 1,
'ERROR: can only set one setting per transaction'
)
const flagName = keys[0]
const value = values[flagName]
const index = AccountFlagIndices[flagName]
const index = AccountSetFlags[flagName]
if (index != null) {
if (value) {
txJSON.SetFlag = index