xrpl 4.0.0 → 4.0.1-mpt-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/xrpl-latest-min.js +1 -1
- package/build/xrpl-latest-min.js.map +1 -1
- package/build/xrpl-latest.js +358 -17
- package/build/xrpl-latest.js.map +1 -1
- package/dist/npm/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/client/partialPayment.js +9 -0
- package/dist/npm/client/partialPayment.js.map +1 -1
- package/dist/npm/models/common/index.d.ts +4 -0
- package/dist/npm/models/common/index.d.ts.map +1 -1
- package/dist/npm/models/index.d.ts +1 -1
- package/dist/npm/models/index.d.ts.map +1 -1
- package/dist/npm/models/index.js +2 -1
- package/dist/npm/models/index.js.map +1 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts +1 -1
- package/dist/npm/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/models/ledger/MPToken.d.ts +11 -0
- package/dist/npm/models/ledger/MPToken.d.ts.map +1 -0
- package/dist/npm/models/ledger/MPToken.js +3 -0
- package/dist/npm/models/ledger/MPToken.js.map +1 -0
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts +14 -0
- package/dist/npm/models/ledger/MPTokenIssuance.d.ts.map +1 -0
- package/dist/npm/models/ledger/MPTokenIssuance.js +3 -0
- package/dist/npm/models/ledger/MPTokenIssuance.js.map +1 -0
- package/dist/npm/models/ledger/index.d.ts +3 -1
- package/dist/npm/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/models/ledger/index.js.map +1 -1
- package/dist/npm/models/methods/ledgerEntry.d.ts +5 -0
- package/dist/npm/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts +15 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.js +15 -0
- package/dist/npm/models/transactions/MPTokenAuthorize.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js +26 -0
- package/dist/npm/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js +10 -0
- package/dist/npm/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js +22 -0
- package/dist/npm/models/transactions/MPTokenIssuanceSet.js.map +1 -0
- package/dist/npm/models/transactions/clawback.d.ts +3 -2
- package/dist/npm/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/models/transactions/clawback.js +11 -1
- package/dist/npm/models/transactions/clawback.js.map +1 -1
- package/dist/npm/models/transactions/common.d.ts +2 -1
- package/dist/npm/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/models/transactions/common.js +12 -2
- package/dist/npm/models/transactions/common.js.map +1 -1
- package/dist/npm/models/transactions/index.d.ts +5 -1
- package/dist/npm/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/models/transactions/index.js +9 -1
- package/dist/npm/models/transactions/index.js.map +1 -1
- package/dist/npm/models/transactions/metadata.d.ts +5 -4
- package/dist/npm/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/models/transactions/metadata.js.map +1 -1
- package/dist/npm/models/transactions/payment.d.ts +4 -4
- package/dist/npm/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.d.ts +5 -1
- package/dist/npm/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/models/transactions/transaction.js +16 -0
- package/dist/npm/models/transactions/transaction.js.map +1 -1
- package/dist/npm/models/utils/flags.d.ts +1 -0
- package/dist/npm/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/models/utils/flags.js +23 -1
- package/dist/npm/models/utils/flags.js.map +1 -1
- package/dist/npm/snippets/tsconfig.tsbuildinfo +1 -1
- package/dist/npm/src/client/partialPayment.d.ts.map +1 -1
- package/dist/npm/src/client/partialPayment.js +9 -0
- package/dist/npm/src/client/partialPayment.js.map +1 -1
- package/dist/npm/src/models/common/index.d.ts +4 -0
- package/dist/npm/src/models/common/index.d.ts.map +1 -1
- package/dist/npm/src/models/index.d.ts +1 -1
- package/dist/npm/src/models/index.d.ts.map +1 -1
- package/dist/npm/src/models/index.js +2 -1
- package/dist/npm/src/models/index.js.map +1 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts +1 -1
- package/dist/npm/src/models/ledger/LedgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/MPToken.d.ts +11 -0
- package/dist/npm/src/models/ledger/MPToken.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/MPToken.js +3 -0
- package/dist/npm/src/models/ledger/MPToken.js.map +1 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts +14 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.d.ts.map +1 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.js +3 -0
- package/dist/npm/src/models/ledger/MPTokenIssuance.js.map +1 -0
- package/dist/npm/src/models/ledger/index.d.ts +3 -1
- package/dist/npm/src/models/ledger/index.d.ts.map +1 -1
- package/dist/npm/src/models/ledger/index.js.map +1 -1
- package/dist/npm/src/models/methods/ledgerEntry.d.ts +5 -0
- package/dist/npm/src/models/methods/ledgerEntry.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts +15 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.js +15 -0
- package/dist/npm/src/models/transactions/MPTokenAuthorize.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts +31 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js +26 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceCreate.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts +7 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js +10 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceDestroy.js.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts +17 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.d.ts.map +1 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js +22 -0
- package/dist/npm/src/models/transactions/MPTokenIssuanceSet.js.map +1 -0
- package/dist/npm/src/models/transactions/clawback.d.ts +3 -2
- package/dist/npm/src/models/transactions/clawback.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/clawback.js +11 -1
- package/dist/npm/src/models/transactions/clawback.js.map +1 -1
- package/dist/npm/src/models/transactions/common.d.ts +2 -1
- package/dist/npm/src/models/transactions/common.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/common.js +12 -2
- package/dist/npm/src/models/transactions/common.js.map +1 -1
- package/dist/npm/src/models/transactions/index.d.ts +5 -1
- package/dist/npm/src/models/transactions/index.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/index.js +9 -1
- package/dist/npm/src/models/transactions/index.js.map +1 -1
- package/dist/npm/src/models/transactions/metadata.d.ts +5 -4
- package/dist/npm/src/models/transactions/metadata.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/metadata.js.map +1 -1
- package/dist/npm/src/models/transactions/payment.d.ts +4 -4
- package/dist/npm/src/models/transactions/payment.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.d.ts +5 -1
- package/dist/npm/src/models/transactions/transaction.d.ts.map +1 -1
- package/dist/npm/src/models/transactions/transaction.js +16 -0
- package/dist/npm/src/models/transactions/transaction.js.map +1 -1
- package/dist/npm/src/models/utils/flags.d.ts +1 -0
- package/dist/npm/src/models/utils/flags.d.ts.map +1 -1
- package/dist/npm/src/models/utils/flags.js +23 -1
- package/dist/npm/src/models/utils/flags.js.map +1 -1
- package/dist/npm/src/utils/index.d.ts +2 -1
- package/dist/npm/src/utils/index.d.ts.map +1 -1
- package/dist/npm/src/utils/index.js +3 -1
- package/dist/npm/src/utils/index.js.map +1 -1
- package/dist/npm/src/utils/mptConversion.d.ts +2 -0
- package/dist/npm/src/utils/mptConversion.d.ts.map +1 -0
- package/dist/npm/src/utils/mptConversion.js +31 -0
- package/dist/npm/src/utils/mptConversion.js.map +1 -0
- package/dist/npm/utils/index.d.ts +2 -1
- package/dist/npm/utils/index.d.ts.map +1 -1
- package/dist/npm/utils/index.js +3 -1
- package/dist/npm/utils/index.js.map +1 -1
- package/dist/npm/utils/mptConversion.d.ts +2 -0
- package/dist/npm/utils/mptConversion.d.ts.map +1 -0
- package/dist/npm/utils/mptConversion.js +31 -0
- package/dist/npm/utils/mptConversion.js.map +1 -0
- package/package.json +4 -4
- package/src/client/partialPayment.ts +22 -5
- package/src/models/common/index.ts +5 -0
- package/src/models/index.ts +1 -0
- package/src/models/ledger/LedgerEntry.ts +2 -0
- package/src/models/ledger/MPToken.ts +12 -0
- package/src/models/ledger/MPTokenIssuance.ts +14 -0
- package/src/models/ledger/index.ts +4 -0
- package/src/models/methods/ledgerEntry.ts +16 -0
- package/src/models/transactions/MPTokenAuthorize.ts +67 -0
- package/src/models/transactions/MPTokenIssuanceCreate.ts +132 -0
- package/src/models/transactions/MPTokenIssuanceDestroy.ts +34 -0
- package/src/models/transactions/MPTokenIssuanceSet.ts +76 -0
- package/src/models/transactions/clawback.ts +29 -6
- package/src/models/transactions/common.ts +22 -1
- package/src/models/transactions/index.ts +17 -1
- package/src/models/transactions/metadata.ts +9 -3
- package/src/models/transactions/payment.ts +4 -4
- package/src/models/transactions/transaction.ts +33 -0
- package/src/models/utils/flags.ts +33 -1
- package/src/utils/index.ts +2 -0
- package/src/utils/mptConversion.ts +61 -0
@@ -6,20 +6,23 @@ import type {
|
|
6
6
|
TransactionStream,
|
7
7
|
TxResponse,
|
8
8
|
} from '..'
|
9
|
-
import type { Amount, APIVersion, DEFAULT_API_VERSION } from '../models/common'
|
9
|
+
import type { Amount, IssuedCurrency,APIVersion, DEFAULT_API_VERSION , MPTAmount } from '../models/common'
|
10
10
|
import type {
|
11
11
|
AccountTxTransaction,
|
12
12
|
RequestResponseMap,
|
13
13
|
} from '../models/methods'
|
14
14
|
import { AccountTxVersionResponseMap } from '../models/methods/accountTx'
|
15
15
|
import { BaseRequest, BaseResponse } from '../models/methods/baseMethod'
|
16
|
-
import { PaymentFlags, Transaction } from '../models/transactions'
|
16
|
+
import { PaymentFlags, Transaction, isMPTAmount } from '../models/transactions'
|
17
17
|
import type { TransactionMetadata } from '../models/transactions/metadata'
|
18
18
|
import { isFlagEnabled } from '../models/utils'
|
19
19
|
|
20
20
|
const WARN_PARTIAL_PAYMENT_CODE = 2001
|
21
21
|
|
22
|
-
function amountsEqual(
|
22
|
+
function amountsEqual(
|
23
|
+
amt1: Amount | MPTAmount,
|
24
|
+
amt2: Amount | MPTAmount,
|
25
|
+
): boolean {
|
23
26
|
if (typeof amt1 === 'string' && typeof amt2 === 'string') {
|
24
27
|
return amt1 === amt2
|
25
28
|
}
|
@@ -28,12 +31,26 @@ function amountsEqual(amt1: Amount, amt2: Amount): boolean {
|
|
28
31
|
return false
|
29
32
|
}
|
30
33
|
|
34
|
+
if (isMPTAmount(amt1) && isMPTAmount(amt2)) {
|
35
|
+
const aValue = new BigNumber(amt1.value)
|
36
|
+
const bValue = new BigNumber(amt2.value)
|
37
|
+
|
38
|
+
return (
|
39
|
+
(amt1 as MPTAmount).mpt_issuance_id ===
|
40
|
+
(amt2 as MPTAmount).mpt_issuance_id && aValue.isEqualTo(bValue)
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
if (isMPTAmount(amt1) || isMPTAmount(amt2)) {
|
45
|
+
return false
|
46
|
+
}
|
47
|
+
|
31
48
|
const aValue = new BigNumber(amt1.value)
|
32
49
|
const bValue = new BigNumber(amt2.value)
|
33
50
|
|
34
51
|
return (
|
35
|
-
amt1.currency === amt2.currency &&
|
36
|
-
amt1.issuer === amt2.issuer &&
|
52
|
+
(amt1 as IssuedCurrency).currency === (amt2 as IssuedCurrency).currency &&
|
53
|
+
(amt1 as IssuedCurrency).issuer === (amt2 as IssuedCurrency).issuer &&
|
37
54
|
aValue.isEqualTo(bValue)
|
38
55
|
)
|
39
56
|
}
|
@@ -20,6 +20,11 @@ export interface IssuedCurrencyAmount extends IssuedCurrency {
|
|
20
20
|
value: string
|
21
21
|
}
|
22
22
|
|
23
|
+
export interface MPTAmount {
|
24
|
+
mpt_issuance_id: string
|
25
|
+
value: string
|
26
|
+
}
|
27
|
+
|
23
28
|
export type Amount = IssuedCurrencyAmount | string
|
24
29
|
|
25
30
|
export interface Balance {
|
package/src/models/index.ts
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
import { MPTAmount } from '../common'
|
2
|
+
|
3
|
+
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
|
4
|
+
|
5
|
+
export interface MPToken extends BaseLedgerEntry, HasPreviousTxnID {
|
6
|
+
LedgerEntryType: 'MPToken'
|
7
|
+
MPTokenIssuanceID: string
|
8
|
+
MPTAmount: MPTAmount
|
9
|
+
LockedAmount?: MPTAmount
|
10
|
+
Flags: number
|
11
|
+
OwnerNode?: string
|
12
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
|
2
|
+
|
3
|
+
export interface MPTokenIssuance extends BaseLedgerEntry, HasPreviousTxnID {
|
4
|
+
LedgerEntryType: 'MPTokenIssuance'
|
5
|
+
Flags: number
|
6
|
+
Issuer: string
|
7
|
+
AssetScale?: number
|
8
|
+
MaximumAmount?: string
|
9
|
+
OutstandingAmount: string
|
10
|
+
LockedAmount?: string
|
11
|
+
TransferFee?: number
|
12
|
+
MPTokenMetadata?: string
|
13
|
+
OwnerNode?: string
|
14
|
+
}
|
@@ -19,6 +19,8 @@ import { Ledger, LedgerV1 } from './Ledger'
|
|
19
19
|
import { LedgerEntry, LedgerEntryFilter } from './LedgerEntry'
|
20
20
|
import LedgerHashes from './LedgerHashes'
|
21
21
|
import NegativeUNL, { NEGATIVE_UNL_ID } from './NegativeUNL'
|
22
|
+
import { MPTokenIssuance } from './MPTokenIssuance'
|
23
|
+
import { MPToken } from './MPToken'
|
22
24
|
import { NFTokenOffer } from './NFTokenOffer'
|
23
25
|
import { NFToken, NFTokenPage } from './NFTokenPage'
|
24
26
|
import Offer, { OfferFlags } from './Offer'
|
@@ -55,6 +57,8 @@ export {
|
|
55
57
|
Majority,
|
56
58
|
NEGATIVE_UNL_ID,
|
57
59
|
NegativeUNL,
|
60
|
+
MPTokenIssuance,
|
61
|
+
MPToken,
|
58
62
|
NFTokenOffer,
|
59
63
|
NFTokenPage,
|
60
64
|
NFToken,
|
@@ -21,6 +21,22 @@ import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
|
|
21
21
|
*/
|
22
22
|
export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
|
23
23
|
command: 'ledger_entry'
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Retrieve a MPTokenIssuance object from the ledger.
|
27
|
+
*/
|
28
|
+
mpt_issuance?: string
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Retrieve a MPToken object from the ledger.
|
32
|
+
*/
|
33
|
+
mptoken?:
|
34
|
+
| {
|
35
|
+
mpt_issuance_id: string
|
36
|
+
account: string
|
37
|
+
}
|
38
|
+
| string
|
39
|
+
|
24
40
|
/**
|
25
41
|
* Retrieve an Automated Market Maker (AMM) object from the ledger.
|
26
42
|
* This is similar to amm_info method, but the ledger_entry version returns only the ledger entry as stored.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import {
|
2
|
+
BaseTransaction,
|
3
|
+
isString,
|
4
|
+
validateBaseTransaction,
|
5
|
+
validateRequiredField,
|
6
|
+
Account,
|
7
|
+
validateOptionalField,
|
8
|
+
isAccount,
|
9
|
+
GlobalFlags,
|
10
|
+
} from './common'
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Transaction Flags for an MPTokenAuthorize Transaction.
|
14
|
+
*
|
15
|
+
* @category Transaction Flags
|
16
|
+
*/
|
17
|
+
export enum MPTokenAuthorizeFlags {
|
18
|
+
/**
|
19
|
+
* If set and transaction is submitted by a holder, it indicates that the holder no
|
20
|
+
* longer wants to hold the MPToken, which will be deleted as a result. If the the holder's
|
21
|
+
* MPToken has non-zero balance while trying to set this flag, the transaction will fail. On
|
22
|
+
* the other hand, if set and transaction is submitted by an issuer, it would mean that the
|
23
|
+
* issuer wants to unauthorize the holder (only applicable for allow-listing),
|
24
|
+
* which would unset the lsfMPTAuthorized flag on the MPToken.
|
25
|
+
*/
|
26
|
+
tfMPTUnauthorize = 0x00000001,
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Map of flags to boolean values representing {@link MPTokenAuthorize} transaction
|
31
|
+
* flags.
|
32
|
+
*
|
33
|
+
* @category Transaction Flags
|
34
|
+
*/
|
35
|
+
export interface MPTokenAuthorizeFlagsInterface extends GlobalFlags {
|
36
|
+
tfMPTUnauthorize?: boolean
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* The MPTokenAuthorize transaction is used to globally lock/unlock a MPTokenIssuance,
|
41
|
+
* or lock/unlock an individual's MPToken.
|
42
|
+
*/
|
43
|
+
export interface MPTokenAuthorize extends BaseTransaction {
|
44
|
+
TransactionType: 'MPTokenAuthorize'
|
45
|
+
/**
|
46
|
+
* Identifies the MPTokenIssuance
|
47
|
+
*/
|
48
|
+
MPTokenIssuanceID: string
|
49
|
+
/**
|
50
|
+
* An optional XRPL Address of an individual token holder balance to lock/unlock.
|
51
|
+
* If omitted, this transaction will apply to all any accounts holding MPTs.
|
52
|
+
*/
|
53
|
+
MPTokenHolder?: Account
|
54
|
+
Flags?: number | MPTokenAuthorizeFlagsInterface
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Verify the form and type of an MPTokenAuthorize at runtime.
|
59
|
+
*
|
60
|
+
* @param tx - An MPTokenAuthorize Transaction.
|
61
|
+
* @throws When the MPTokenAuthorize is Malformed.
|
62
|
+
*/
|
63
|
+
export function validateMPTokenAuthorize(tx: Record<string, unknown>): void {
|
64
|
+
validateBaseTransaction(tx)
|
65
|
+
validateRequiredField(tx, 'MPTokenIssuanceID', isString)
|
66
|
+
validateOptionalField(tx, 'MPTokenHolder', isAccount)
|
67
|
+
}
|
@@ -0,0 +1,132 @@
|
|
1
|
+
import { ValidationError } from '../../errors'
|
2
|
+
import { isHex } from '../utils'
|
3
|
+
|
4
|
+
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
|
5
|
+
import type { TransactionMetadataBase } from './metadata'
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Transaction Flags for an MPTokenIssuanceCreate Transaction.
|
9
|
+
*
|
10
|
+
* @category Transaction Flags
|
11
|
+
*/
|
12
|
+
export enum MPTokenIssuanceCreateFlags {
|
13
|
+
/**
|
14
|
+
* If set, indicates that the MPT can be locked both individually and globally.
|
15
|
+
* If not set, the MPT cannot be locked in any way.
|
16
|
+
*/
|
17
|
+
tfMPTCanLock = 0x00000002,
|
18
|
+
/**
|
19
|
+
* If set, indicates that individual holders must be authorized.
|
20
|
+
* This enables issuers to limit who can hold their assets.
|
21
|
+
*/
|
22
|
+
tfMPTRequireAuth = 0x00000004,
|
23
|
+
/**
|
24
|
+
* If set, indicates that individual holders can place their balances into an escrow.
|
25
|
+
*/
|
26
|
+
tfMPTCanEscrow = 0x00000008,
|
27
|
+
/**
|
28
|
+
* If set, indicates that individual holders can trade their balances
|
29
|
+
* using the XRP Ledger DEX or AMM.
|
30
|
+
*/
|
31
|
+
tfMPTCanTrade = 0x00000010,
|
32
|
+
/**
|
33
|
+
* If set, indicates that tokens may be transferred to other accounts
|
34
|
+
* that are not the issuer.
|
35
|
+
*/
|
36
|
+
tfMPTCanTransfer = 0x00000020,
|
37
|
+
/**
|
38
|
+
* If set, indicates that the issuer may use the Clawback transaction
|
39
|
+
* to clawback value from individual holders.
|
40
|
+
*/
|
41
|
+
tfMPTCanClawback = 0x00000040,
|
42
|
+
}
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Map of flags to boolean values representing {@link MPTokenIssuanceCreate} transaction
|
46
|
+
* flags.
|
47
|
+
*
|
48
|
+
* @category Transaction Flags
|
49
|
+
*/
|
50
|
+
export interface MPTokenIssuanceCreateFlagsInterface extends GlobalFlags {
|
51
|
+
tfMPTCanLock?: boolean
|
52
|
+
tfMPTRequireAuth?: boolean
|
53
|
+
tfMPTCanEscrow?: boolean
|
54
|
+
tfMPTCanTrade?: boolean
|
55
|
+
tfMPTCanTransfer?: boolean
|
56
|
+
tfMPTCanClawback?: boolean
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* The MPTokenIssuanceCreate transaction creates a MPTokenIssuance object
|
61
|
+
* and adds it to the relevant directory node of the creator account.
|
62
|
+
* This transaction is the only opportunity an issuer has to specify any token fields
|
63
|
+
* that are defined as immutable (e.g., MPT Flags). If the transaction is successful,
|
64
|
+
* the newly created token will be owned by the account (the creator account) which
|
65
|
+
* executed the transaction.
|
66
|
+
*/
|
67
|
+
export interface MPTokenIssuanceCreate extends BaseTransaction {
|
68
|
+
TransactionType: 'MPTokenIssuanceCreate'
|
69
|
+
/**
|
70
|
+
* An asset scale is the difference, in orders of magnitude, between a standard unit and
|
71
|
+
* a corresponding fractional unit. More formally, the asset scale is a non-negative integer
|
72
|
+
* (0, 1, 2, …) such that one standard unit equals 10^(-scale) of a corresponding
|
73
|
+
* fractional unit. If the fractional unit equals the standard unit, then the asset scale is 0.
|
74
|
+
* Note that this value is optional, and will default to 0 if not supplied.
|
75
|
+
*/
|
76
|
+
AssetScale?: number
|
77
|
+
/**
|
78
|
+
* Specifies the hex-encoded maximum asset amount of this token that should ever be issued.
|
79
|
+
* It is a non-negative integer that can store a range of up to 63 bits. If not set, the max
|
80
|
+
* amount will default to the largest unsigned 63-bit integer (0x7FFFFFFFFFFFFFFF)
|
81
|
+
*
|
82
|
+
* Helper function `mptUint64ToHex` can be used to help converting from base 10 or 16 string
|
83
|
+
* to a valid value.
|
84
|
+
*
|
85
|
+
* Example:
|
86
|
+
* ```
|
87
|
+
* MaximumAmount: '3e8' // 0x3E8 in hex or 1000 in decimal
|
88
|
+
* MaximumAmount: mptUint64ToHex('1000') // 1000 in decimal using helper function
|
89
|
+
* ```
|
90
|
+
*/
|
91
|
+
MaximumAmount?: string
|
92
|
+
/**
|
93
|
+
* Specifies the fee to charged by the issuer for secondary sales of the Token,
|
94
|
+
* if such sales are allowed. Valid values for this field are between 0 and 50,000 inclusive,
|
95
|
+
* allowing transfer rates of between 0.000% and 50.000% in increments of 0.001.
|
96
|
+
* The field must NOT be present if the `tfMPTCanTransfer` flag is not set.
|
97
|
+
*/
|
98
|
+
TransferFee?: number
|
99
|
+
/**
|
100
|
+
* Arbitrary metadata about this issuance, in hex format.
|
101
|
+
*/
|
102
|
+
MPTokenMetadata?: string | null
|
103
|
+
Flags?: number | MPTokenIssuanceCreateFlagsInterface
|
104
|
+
}
|
105
|
+
|
106
|
+
export interface MPTokenIssuanceCreateMetadata extends TransactionMetadataBase {
|
107
|
+
mpt_issuance_id?: string
|
108
|
+
}
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Verify the form and type of an MPTokenIssuanceCreate at runtime.
|
112
|
+
*
|
113
|
+
* @param tx - An MPTokenIssuanceCreate Transaction.
|
114
|
+
* @throws When the MPTokenIssuanceCreate is Malformed.
|
115
|
+
*/
|
116
|
+
export function validateMPTokenIssuanceCreate(
|
117
|
+
tx: Record<string, unknown>,
|
118
|
+
): void {
|
119
|
+
validateBaseTransaction(tx)
|
120
|
+
|
121
|
+
if (typeof tx.MPTokenMetadata === 'string' && tx.MPTokenMetadata === '') {
|
122
|
+
throw new ValidationError(
|
123
|
+
'MPTokenIssuanceCreate: MPTokenMetadata must not be empty string',
|
124
|
+
)
|
125
|
+
}
|
126
|
+
|
127
|
+
if (typeof tx.MPTokenMetadata === 'string' && !isHex(tx.MPTokenMetadata)) {
|
128
|
+
throw new ValidationError(
|
129
|
+
'MPTokenIssuanceCreate: MPTokenMetadata must be in hex format',
|
130
|
+
)
|
131
|
+
}
|
132
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import {
|
2
|
+
BaseTransaction,
|
3
|
+
isString,
|
4
|
+
validateBaseTransaction,
|
5
|
+
validateRequiredField,
|
6
|
+
} from './common'
|
7
|
+
|
8
|
+
/**
|
9
|
+
* The MPTokenIssuanceDestroy transaction is used to remove an MPTokenIssuance object
|
10
|
+
* from the directory node in which it is being held, effectively removing the token
|
11
|
+
* from the ledger. If this operation succeeds, the corresponding
|
12
|
+
* MPTokenIssuance is removed and the owner’s reserve requirement is reduced by one.
|
13
|
+
* This operation must fail if there are any holders who have non-zero balances.
|
14
|
+
*/
|
15
|
+
export interface MPTokenIssuanceDestroy extends BaseTransaction {
|
16
|
+
TransactionType: 'MPTokenIssuanceDestroy'
|
17
|
+
/**
|
18
|
+
* Identifies the MPTokenIssuance object to be removed by the transaction.
|
19
|
+
*/
|
20
|
+
MPTokenIssuanceID: string
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Verify the form and type of an MPTokenIssuanceDestroy at runtime.
|
25
|
+
*
|
26
|
+
* @param tx - An MPTokenIssuanceDestroy Transaction.
|
27
|
+
* @throws When the MPTokenIssuanceDestroy is Malformed.
|
28
|
+
*/
|
29
|
+
export function validateMPTokenIssuanceDestroy(
|
30
|
+
tx: Record<string, unknown>,
|
31
|
+
): void {
|
32
|
+
validateBaseTransaction(tx)
|
33
|
+
validateRequiredField(tx, 'MPTokenIssuanceID', isString)
|
34
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
import {
|
2
|
+
BaseTransaction,
|
3
|
+
isString,
|
4
|
+
validateBaseTransaction,
|
5
|
+
validateRequiredField,
|
6
|
+
Account,
|
7
|
+
validateOptionalField,
|
8
|
+
isAccount,
|
9
|
+
GlobalFlags,
|
10
|
+
} from './common'
|
11
|
+
import { ValidationError } from '../../errors'
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Transaction Flags for an MPTokenIssuanceSet Transaction.
|
15
|
+
*
|
16
|
+
* @category Transaction Flags
|
17
|
+
*/
|
18
|
+
export enum MPTokenIssuanceSetFlags {
|
19
|
+
/**
|
20
|
+
* If set, indicates that issuer locks the MPT
|
21
|
+
*/
|
22
|
+
tfMPTLock = 0x00000001,
|
23
|
+
/**
|
24
|
+
* If set, indicates that issuer unlocks the MPT
|
25
|
+
*/
|
26
|
+
tfMPTUnlock = 0x00000002,
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Map of flags to boolean values representing {@link MPTokenIssuanceSet} transaction
|
31
|
+
* flags.
|
32
|
+
*
|
33
|
+
* @category Transaction Flags
|
34
|
+
*/
|
35
|
+
export interface MPTokenIssuanceSetFlagsInterface extends GlobalFlags {
|
36
|
+
tfMPTLock?: boolean
|
37
|
+
tfMPTUnlock?: boolean
|
38
|
+
}
|
39
|
+
|
40
|
+
/**
|
41
|
+
* The MPTokenIssuanceSet transaction is used to globally lock/unlock a MPTokenIssuance,
|
42
|
+
* or lock/unlock an individual's MPToken.
|
43
|
+
*/
|
44
|
+
export interface MPTokenIssuanceSet extends BaseTransaction {
|
45
|
+
TransactionType: 'MPTokenIssuanceSet'
|
46
|
+
/**
|
47
|
+
* Identifies the MPTokenIssuance
|
48
|
+
*/
|
49
|
+
MPTokenIssuanceID: string
|
50
|
+
/**
|
51
|
+
* An optional XRPL Address of an individual token holder balance to lock/unlock.
|
52
|
+
* If omitted, this transaction will apply to all any accounts holding MPTs.
|
53
|
+
*/
|
54
|
+
MPTokenHolder?: Account
|
55
|
+
Flags?: number | MPTokenIssuanceSetFlagsInterface
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Verify the form and type of an MPTokenIssuanceSet at runtime.
|
60
|
+
*
|
61
|
+
* @param tx - An MPTokenIssuanceSet Transaction.
|
62
|
+
* @throws When the MPTokenIssuanceSet is Malformed.
|
63
|
+
*/
|
64
|
+
export function validateMPTokenIssuanceSet(tx: Record<string, unknown>): void {
|
65
|
+
validateBaseTransaction(tx)
|
66
|
+
validateRequiredField(tx, 'MPTokenIssuanceID', isString)
|
67
|
+
validateOptionalField(tx, 'MPTokenHolder', isAccount)
|
68
|
+
|
69
|
+
const flags = tx.Flags as number
|
70
|
+
if (
|
71
|
+
BigInt(flags) & BigInt(MPTokenIssuanceSetFlags.tfMPTLock) &&
|
72
|
+
BigInt(flags) & BigInt(MPTokenIssuanceSetFlags.tfMPTUnlock)
|
73
|
+
) {
|
74
|
+
throw new ValidationError('MPTokenIssuanceSet: flag conflict')
|
75
|
+
}
|
76
|
+
}
|
@@ -1,10 +1,13 @@
|
|
1
1
|
import { ValidationError } from '../../errors'
|
2
|
-
import { IssuedCurrencyAmount } from '../common'
|
2
|
+
import { IssuedCurrencyAmount, MPTAmount } from '../common'
|
3
3
|
|
4
4
|
import {
|
5
5
|
BaseTransaction,
|
6
6
|
validateBaseTransaction,
|
7
7
|
isIssuedCurrency,
|
8
|
+
isMPTAmount,
|
9
|
+
isAccount,
|
10
|
+
validateOptionalField,
|
8
11
|
} from './common'
|
9
12
|
|
10
13
|
/**
|
@@ -15,15 +18,20 @@ export interface Clawback extends BaseTransaction {
|
|
15
18
|
TransactionType: 'Clawback'
|
16
19
|
/**
|
17
20
|
* Indicates the AccountID that submitted this transaction. The account MUST
|
18
|
-
* be the issuer of the currency.
|
21
|
+
* be the issuer of the currency or MPT.
|
19
22
|
*/
|
20
23
|
Account: string
|
21
24
|
/**
|
22
|
-
* The amount of currency to
|
23
|
-
* names MUST be lower-case.
|
25
|
+
* The amount of currency or MPT to clawback, and it must be non-XRP. The nested field
|
26
|
+
* names MUST be lower-case. If the amount is IOU, the `issuer` field MUST be the holder's address,
|
24
27
|
* whom to be clawed back.
|
25
28
|
*/
|
26
|
-
Amount: IssuedCurrencyAmount
|
29
|
+
Amount: IssuedCurrencyAmount | MPTAmount
|
30
|
+
/**
|
31
|
+
* Indicates the AccountID that the issuer wants to clawback. This field is only valid for clawing back
|
32
|
+
* MPTs.
|
33
|
+
*/
|
34
|
+
MPTokenHolder?: string
|
27
35
|
}
|
28
36
|
|
29
37
|
/**
|
@@ -34,16 +42,31 @@ export interface Clawback extends BaseTransaction {
|
|
34
42
|
*/
|
35
43
|
export function validateClawback(tx: Record<string, unknown>): void {
|
36
44
|
validateBaseTransaction(tx)
|
45
|
+
validateOptionalField(tx, 'MPTokenHolder', isAccount)
|
37
46
|
|
38
47
|
if (tx.Amount == null) {
|
39
48
|
throw new ValidationError('Clawback: missing field Amount')
|
40
49
|
}
|
41
50
|
|
42
|
-
if (!isIssuedCurrency(tx.Amount)) {
|
51
|
+
if (!isIssuedCurrency(tx.Amount) && !isMPTAmount(tx.Amount)) {
|
43
52
|
throw new ValidationError('Clawback: invalid Amount')
|
44
53
|
}
|
45
54
|
|
46
55
|
if (isIssuedCurrency(tx.Amount) && tx.Account === tx.Amount.issuer) {
|
47
56
|
throw new ValidationError('Clawback: invalid holder Account')
|
48
57
|
}
|
58
|
+
|
59
|
+
if (isMPTAmount(tx.Amount) && tx.Account === tx.MPTokenHolder) {
|
60
|
+
throw new ValidationError('Clawback: invalid holder Account')
|
61
|
+
}
|
62
|
+
|
63
|
+
if (isIssuedCurrency(tx.Amount) && tx.MPTokenHolder) {
|
64
|
+
throw new ValidationError(
|
65
|
+
'Clawback: cannot have MPTokenHolder for currency',
|
66
|
+
)
|
67
|
+
}
|
68
|
+
|
69
|
+
if (isMPTAmount(tx.Amount) && !tx.MPTokenHolder) {
|
70
|
+
throw new ValidationError('Clawback: missing MPTokenHolder')
|
71
|
+
}
|
49
72
|
}
|
@@ -9,6 +9,7 @@ import {
|
|
9
9
|
Memo,
|
10
10
|
Signer,
|
11
11
|
XChainBridge,
|
12
|
+
MPTAmount,
|
12
13
|
} from '../common'
|
13
14
|
import { onlyHasFields } from '../utils'
|
14
15
|
|
@@ -59,6 +60,7 @@ const XRP_CURRENCY_SIZE = 1
|
|
59
60
|
const ISSUE_SIZE = 2
|
60
61
|
const ISSUED_CURRENCY_SIZE = 3
|
61
62
|
const XCHAIN_BRIDGE_SIZE = 4
|
63
|
+
const MPTOKEN_SIZE = 2
|
62
64
|
|
63
65
|
function isRecord(value: unknown): value is Record<string, unknown> {
|
64
66
|
return value !== null && typeof value === 'object'
|
@@ -119,6 +121,21 @@ export function isIssuedCurrency(
|
|
119
121
|
)
|
120
122
|
}
|
121
123
|
|
124
|
+
/**
|
125
|
+
* Verify the form and type of an MPT at runtime.
|
126
|
+
*
|
127
|
+
* @param input - The input to check the form and type of.
|
128
|
+
* @returns Whether the MPTAmount is properly formed.
|
129
|
+
*/
|
130
|
+
export function isMPTAmount(input: unknown): input is MPTAmount {
|
131
|
+
return (
|
132
|
+
isRecord(input) &&
|
133
|
+
Object.keys(input).length === MPTOKEN_SIZE &&
|
134
|
+
typeof input.value === 'string' &&
|
135
|
+
typeof input.mpt_issuance_id === 'string'
|
136
|
+
)
|
137
|
+
}
|
138
|
+
|
122
139
|
/**
|
123
140
|
* Must be a valid account address
|
124
141
|
*/
|
@@ -144,7 +161,11 @@ export function isAccount(account: unknown): account is Account {
|
|
144
161
|
* @returns Whether the Amount is properly formed.
|
145
162
|
*/
|
146
163
|
export function isAmount(amount: unknown): amount is Amount {
|
147
|
-
return
|
164
|
+
return (
|
165
|
+
typeof amount === 'string' ||
|
166
|
+
isIssuedCurrency(amount) ||
|
167
|
+
isMPTAmount(amount)
|
168
|
+
)
|
148
169
|
}
|
149
170
|
|
150
171
|
/**
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { BaseTransaction } from './common'
|
1
|
+
export { BaseTransaction, isMPTAmount } from './common'
|
2
2
|
export {
|
3
3
|
validate,
|
4
4
|
PseudoTransaction,
|
@@ -39,6 +39,22 @@ export { EscrowCancel } from './escrowCancel'
|
|
39
39
|
export { EscrowCreate } from './escrowCreate'
|
40
40
|
export { EscrowFinish } from './escrowFinish'
|
41
41
|
export { EnableAmendment, EnableAmendmentFlags } from './enableAmendment'
|
42
|
+
export {
|
43
|
+
MPTokenAuthorize,
|
44
|
+
MPTokenAuthorizeFlags,
|
45
|
+
MPTokenAuthorizeFlagsInterface,
|
46
|
+
} from './MPTokenAuthorize'
|
47
|
+
export {
|
48
|
+
MPTokenIssuanceCreate,
|
49
|
+
MPTokenIssuanceCreateFlags,
|
50
|
+
MPTokenIssuanceCreateFlagsInterface,
|
51
|
+
} from './MPTokenIssuanceCreate'
|
52
|
+
export { MPTokenIssuanceDestroy } from './MPTokenIssuanceDestroy'
|
53
|
+
export {
|
54
|
+
MPTokenIssuanceSet,
|
55
|
+
MPTokenIssuanceSetFlags,
|
56
|
+
MPTokenIssuanceSetFlagsInterface,
|
57
|
+
} from './MPTokenIssuanceSet'
|
42
58
|
export { NFTokenAcceptOffer } from './NFTokenAcceptOffer'
|
43
59
|
export { NFTokenBurn } from './NFTokenBurn'
|
44
60
|
export { NFTokenCancelOffer } from './NFTokenCancelOffer'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Amount } from '../common'
|
1
|
+
import { Amount, MPTAmount } from '../common'
|
2
2
|
|
3
3
|
import { BaseTransaction } from './common'
|
4
4
|
import {
|
@@ -14,6 +14,10 @@ import {
|
|
14
14
|
NFTokenCreateOfferMetadata,
|
15
15
|
} from './NFTokenCreateOffer'
|
16
16
|
import { NFTokenMint, NFTokenMintMetadata } from './NFTokenMint'
|
17
|
+
import {
|
18
|
+
MPTokenIssuanceCreate,
|
19
|
+
MPTokenIssuanceCreateMetadata,
|
20
|
+
} from './MPTokenIssuanceCreate'
|
17
21
|
import { Payment, PaymentMetadata } from './payment'
|
18
22
|
import type { Transaction } from './transaction'
|
19
23
|
|
@@ -79,9 +83,9 @@ export function isDeletedNode(node: Node): node is DeletedNode {
|
|
79
83
|
|
80
84
|
export interface TransactionMetadataBase {
|
81
85
|
AffectedNodes: Node[]
|
82
|
-
DeliveredAmount?: Amount
|
86
|
+
DeliveredAmount?: Amount | MPTAmount
|
83
87
|
// "unavailable" possible for transactions before 2014-01-20
|
84
|
-
delivered_amount?: Amount | 'unavailable'
|
88
|
+
delivered_amount?: Amount | MPTAmount | 'unavailable'
|
85
89
|
TransactionIndex: number
|
86
90
|
TransactionResult: string
|
87
91
|
}
|
@@ -97,4 +101,6 @@ export type TransactionMetadata<T extends BaseTransaction = Transaction> =
|
|
97
101
|
? NFTokenAcceptOfferMetadata
|
98
102
|
: T extends NFTokenCancelOffer
|
99
103
|
? NFTokenCancelOfferMetadata
|
104
|
+
: T extends MPTokenIssuanceCreate
|
105
|
+
? MPTokenIssuanceCreateMetadata
|
100
106
|
: TransactionMetadataBase
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ValidationError } from '../../errors'
|
2
|
-
import { Amount, Path } from '../common'
|
2
|
+
import { Amount, Path, MPTAmount } from '../common'
|
3
3
|
import { isFlagEnabled } from '../utils'
|
4
4
|
|
5
5
|
import {
|
@@ -116,7 +116,7 @@ export interface Payment extends BaseTransaction {
|
|
116
116
|
* names MUST be lower-case. If the tfPartialPayment flag is set, deliver up
|
117
117
|
* to this amount instead.
|
118
118
|
*/
|
119
|
-
Amount: Amount
|
119
|
+
Amount: Amount | MPTAmount
|
120
120
|
/** The unique address of the account receiving the payment. */
|
121
121
|
Destination: Account
|
122
122
|
/**
|
@@ -153,8 +153,8 @@ export interface Payment extends BaseTransaction {
|
|
153
153
|
}
|
154
154
|
|
155
155
|
export interface PaymentMetadata extends TransactionMetadataBase {
|
156
|
-
DeliveredAmount?: Amount
|
157
|
-
delivered_amount?: Amount | 'unavailable'
|
156
|
+
DeliveredAmount?: Amount | MPTAmount
|
157
|
+
delivered_amount?: Amount | MPTAmount | 'unavailable'
|
158
158
|
}
|
159
159
|
|
160
160
|
/**
|