-
Notifications
You must be signed in to change notification settings - Fork 560
Support for Dynamic MPTs (XLS-94D) #3081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 17 commits
0681e0a
ad316b7
fd1513d
2a56be3
29b8e80
058ad5b
1e0aaa0
fc51d7e
b792695
7e2e712
0876e86
0e07910
02d4a96
d6ec04a
bda0c2e
cbdcbc3
565402b
747bfd2
ce16616
42049ac
13f9ec9
7260f2f
0f3ae2f
9a6c46c
4a3a978
0c228cd
020b895
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ import type { TransactionMetadataBase } from './metadata' | |
|
|
||
| // 2^63 - 1 | ||
| const MAX_AMT = '9223372036854775807' | ||
| const MAX_TRANSFER_FEE = 50000 | ||
| export const MAX_TRANSFER_FEE = 50000 | ||
|
|
||
| /** | ||
| * Transaction Flags for an MPTokenIssuanceCreate Transaction. | ||
|
|
@@ -53,8 +53,54 @@ export enum MPTokenIssuanceCreateFlags { | |
| * to clawback value from individual holders. | ||
| */ | ||
| tfMPTCanClawback = 0x00000040, | ||
|
|
||
| /** | ||
| * If set, Indicates flag lsfMPTCanLock can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanLock = 0x00000002, | ||
kuan121 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /** | ||
| * If set, Indicates flag lsfMPTRequireAuth can be changed | ||
| */ | ||
| tmfMPTCanMutateRequireAuth = 0x00000004, | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanEscrow can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanEscrow = 0x00000008, | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanTrade can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanTrade = 0x00000010, | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanTransfer can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanTransfer = 0x00000020, | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanClawback can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanClawback = 0x00000040, | ||
| /** | ||
| * If set, Allows field MPTokenMetadata to be modified. | ||
| */ | ||
| tmfMPTCanMutateMetadata = 0x00010000, | ||
| /** | ||
| * If set, Allows field TransferFee to be modified. | ||
| */ | ||
| tmfMPTCanMutateTransferFee = 0x00020000, | ||
| } | ||
|
|
||
| /* eslint-disable no-bitwise -- Need bitwise operations to replicate rippled behavior */ | ||
| export const tmfMPTokenIssuanceCreateMutableMask = ~( | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateCanLock | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateRequireAuth | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateCanEscrow | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateCanTrade | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateCanTransfer | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateCanClawback | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateMetadata | | ||
| MPTokenIssuanceCreateFlags.tmfMPTCanMutateTransferFee | ||
| ) | ||
| /* eslint-enable no-bitwise */ | ||
|
|
||
| /** | ||
| * Map of flags to boolean values representing {@link MPTokenIssuanceCreate} transaction | ||
| * flags. | ||
|
|
@@ -63,12 +109,68 @@ export enum MPTokenIssuanceCreateFlags { | |
| */ | ||
| export interface MPTokenIssuanceCreateFlagsInterface | ||
| extends GlobalFlagsInterface { | ||
| /** | ||
| * If set, indicates that the MPT can be locked both individually and globally. | ||
| * If not set, the MPT cannot be locked in any way. | ||
| */ | ||
| tfMPTCanLock?: boolean | ||
| /** | ||
| * If set, indicates that individual holders must be authorized. | ||
| * This enables issuers to limit who can hold their assets. | ||
| */ | ||
| tfMPTRequireAuth?: boolean | ||
| /** | ||
| * If set, indicates that individual holders can place their balances into an escrow. | ||
| */ | ||
| tfMPTCanEscrow?: boolean | ||
| /** | ||
| * If set, indicates that individual holders can trade their balances | ||
| * using the XRP Ledger DEX or AMM. | ||
| */ | ||
| tfMPTCanTrade?: boolean | ||
| /** | ||
| * If set, indicates that tokens may be transferred to other accounts | ||
| * that are not the issuer. | ||
| */ | ||
| tfMPTCanTransfer?: boolean | ||
| /** | ||
| * If set, indicates that the issuer may use the Clawback transaction | ||
| * to clawback value from individual holders. | ||
| */ | ||
| tfMPTCanClawback?: boolean | ||
|
|
||
| /** | ||
| * If set, Indicates flag lsfMPTCanLock can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanLock?: boolean | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These flags are only available for MutableFlags field. Should it be separated into its own interface, similar to what we did with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is the xrpl.org documentation updated already? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the XLS specification is a good source of info for unreleased amendments. Usually, you can find the pre-release documentation for amendments on https://opensource.ripple.com/ as well, however LendingProtocol docs have not been published yet. You can look at pre-release docs for other amendments on that website. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were separating the flags that can be set with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| /** | ||
| * If set, Indicates flag lsfMPTRequireAuth can be changed. | ||
| */ | ||
| tmfMPTCanMutateRequireAuth?: boolean | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanEscrow can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanEscrow?: boolean | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanTrade can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanTrade?: boolean | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanTransfer can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanTransfer?: boolean | ||
| /** | ||
| * If set, Indicates flag lsfMPTCanClawback can be changed. | ||
| */ | ||
| tmfMPTCanMutateCanClawback?: boolean | ||
| /** | ||
| * If set, Allows field MPTokenMetadata to be modified. | ||
| */ | ||
| tmfMPTCanMutateMetadata?: boolean | ||
| /** | ||
| * If set, Allows field TransferFee to be modified. | ||
| */ | ||
| tmfMPTCanMutateTransferFee?: boolean | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -120,13 +222,14 @@ export interface MPTokenIssuanceCreate extends BaseTransaction { | |
| MPTokenMetadata?: string | ||
|
|
||
| Flags?: number | MPTokenIssuanceCreateFlagsInterface | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flags cannot accept the mutable flags so the above change will be needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code has been changed in ce16616 |
||
| MutableFlags?: number | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add docstring for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a recent commit to fix this. However, I could not find the documentation for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: I have added a docstring for the |
||
| } | ||
|
|
||
| export interface MPTokenIssuanceCreateMetadata extends TransactionMetadataBase { | ||
| mpt_issuance_id?: string | ||
| } | ||
|
|
||
| /* eslint-disable max-lines-per-function -- Not needed to reduce function */ | ||
| /* eslint-disable max-lines-per-function, max-statements -- Not needed to reduce function */ | ||
| /** | ||
| * Verify the form and type of an MPTokenIssuanceCreate at runtime. | ||
| * | ||
|
|
@@ -141,6 +244,17 @@ export function validateMPTokenIssuanceCreate( | |
| validateOptionalField(tx, 'MPTokenMetadata', isString) | ||
| validateOptionalField(tx, 'TransferFee', isNumber) | ||
| validateOptionalField(tx, 'AssetScale', isNumber) | ||
| validateOptionalField(tx, 'MutableFlags', isNumber) | ||
kuan121 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if ( | ||
| tx.MutableFlags != null && | ||
| // eslint-disable-next-line no-bitwise -- Need bitwise operations to replicate rippled behavior | ||
| tx.MutableFlags & tmfMPTokenIssuanceCreateMutableMask | ||
| ) { | ||
| throw new ValidationError( | ||
| 'MPTokenIssuanceCreate: Invalid MutableFlags value', | ||
| ) | ||
| } | ||
|
|
||
| if ( | ||
| typeof tx.MPTokenMetadata === 'string' && | ||
|
|
@@ -202,4 +316,4 @@ export function validateMPTokenIssuanceCreate( | |
| } | ||
| } | ||
| } | ||
| /* eslint-enable max-lines-per-function */ | ||
| /* eslint-enable max-lines-per-function, max-statements */ | ||
Uh oh!
There was an error while loading. Please reload this page.