From decc395e5bb9187946a2fcbc6a04e27d70ad6123 Mon Sep 17 00:00:00 2001 From: Nathan Nichols Date: Thu, 12 Aug 2021 13:30:26 -0500 Subject: [PATCH] docs: export and document asf Flags (#1525) * docs: export and document asf Flags --- docs/index.md | 16 ++++++++++++++++ docs/src/accountSetFlags.md.ejs | 15 +++++++++++++++ docs/src/index.md.ejs | 1 + src/api.ts | 4 +++- src/common/constants.ts | 4 ++-- src/transaction/settings.ts | 6 +++--- 6 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 docs/src/accountSetFlags.md.ejs diff --git a/docs/index.md b/docs/index.md index 126ac5df..e459a5fd 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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. diff --git a/docs/src/accountSetFlags.md.ejs b/docs/src/accountSetFlags.md.ejs new file mode 100644 index 00000000..df9ca081 --- /dev/null +++ b/docs/src/accountSetFlags.md.ejs @@ -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. diff --git a/docs/src/index.md.ejs b/docs/src/index.md.ejs index 1eaa6ca6..59e4a491 100644 --- a/docs/src/index.md.ejs +++ b/docs/src/index.md.ejs @@ -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') %> diff --git a/src/api.ts b/src/api.ts index 783cfcb3..4a6f911e 100644 --- a/src/api.ts +++ b/src/api.ts @@ -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 diff --git a/src/common/constants.ts b/src/common/constants.ts index c3101703..555fb8f1 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -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} diff --git a/src/transaction/settings.ts b/src/transaction/settings.ts index f2c25e88..104a1b85 100644 --- a/src/transaction/settings.ts +++ b/src/transaction/settings.ts @@ -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