mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
rename XLS-20 fields (#1966)
* rename TokenTaxon -> NFTokenTaxon * rename MintedTokens -> MintedNFTokens * rename BurnedTokens -> BurnedNFTokens * update binary for NFTokenID rename * rename TokenID -> NFTokenID * rename TokenOffers -> NFTokenOffers * rename BrokerFee -> NFTokenBrokerFee * rename Minter -> NFTokenMinter * rename NonFungibleToken -> NFToken * rename NonFungibleTokens -> NFTokens * rename BuyOffer -> NFTokenBuyOffer * rename SellOffer -> NFTokenSellOffer * rename OfferNode -> NFTokenOfferNode * fix binary for serialize tests * Add missing MintedNFTokens def + fix tests * nftokenid -> nft_id * asfAuthorizedMinter -> asfAuthorizedNFTokenMinter * Update tec/tem error codes * Add new definitions * Update HISTORY.md * Change to 1.4.0 for binary-codec * Docgen * Update HISTORY.md Co-authored-by: Jackson Mills <jmills@ripple.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xrpl-announce) for release announcements. We recommend that xrpl.js (ripple-lib) users stay up-to-date with the latest stable release.
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 2.2.0 (2022-04-19)
|
||||
### Added
|
||||
* `federator_info` RPC support
|
||||
* Helper method for creating a cross-chain payment to/from a sidechain
|
||||
@@ -11,6 +13,7 @@ Subscribe to [the **xrpl-announce** mailing list](https://groups.google.com/g/xr
|
||||
### Fixed
|
||||
* Type of TrustSet transaction edited, specifically LimitAmount property type (fixed typescript issue)
|
||||
* Remove unnecessary console.warn for partial payments (#1783, #1784, #1896)
|
||||
* Matched 1.9.0's breaking changes to NFT fields.
|
||||
|
||||
## 2.1.1 (2021-12-23)
|
||||
### Fixed
|
||||
|
||||
@@ -32,8 +32,8 @@ export interface AccountNFTsRequest extends BaseRequest {
|
||||
interface AccountNFToken {
|
||||
Flags: number
|
||||
Issuer: string
|
||||
TokenID: string
|
||||
TokenTaxon: number
|
||||
NFTokenID: string
|
||||
NFTokenTaxon: number
|
||||
URI?: string
|
||||
nft_serial: number
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface NFTBuyOffersRequest extends BaseRequest {
|
||||
/**
|
||||
* The unique identifier of an NFToken. The request returns buy offers for this NFToken.
|
||||
*/
|
||||
tokenid: string
|
||||
nft_id: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,6 @@ export interface NFTBuyOffersResponse extends BaseResponse {
|
||||
/**
|
||||
* The token ID of the NFToken to which these offers pertain.
|
||||
*/
|
||||
tokenid: string
|
||||
nft_id: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export interface NFTSellOffersRequest extends BaseRequest {
|
||||
/**
|
||||
* The unique identifier of an NFToken. The request returns sell offers for this NFToken.
|
||||
*/
|
||||
tokenid: string
|
||||
nft_id: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,6 +30,6 @@ export interface NFTSellOffersResponse extends BaseResponse {
|
||||
/**
|
||||
* The token ID of the NFToken to which these offers pertain.
|
||||
*/
|
||||
tokenid: string
|
||||
nft_id: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,19 +28,19 @@ export interface NFTokenAcceptOffer extends BaseTransaction {
|
||||
/**
|
||||
* Identifies the NFTokenOffer that offers to sell the NFToken.
|
||||
*
|
||||
* In direct mode this field is optional, but either SellOffer or
|
||||
* BuyOffer must be specified. In brokered mode, both SellOffer
|
||||
* and BuyOffer must be specified.
|
||||
* In direct mode this field is optional, but either NFTokenSellOffer or
|
||||
* NFTokenBuyOffer must be specified. In brokered mode, both NFTokenSellOffer
|
||||
* and NFTokenBuyOffer must be specified.
|
||||
*/
|
||||
SellOffer?: string
|
||||
NFTokenSellOffer?: string
|
||||
/**
|
||||
* Identifies the NFTokenOffer that offers to buy the NFToken.
|
||||
*
|
||||
* In direct mode this field is optional, but either SellOffer or
|
||||
* BuyOffer must be specified. In brokered mode, both SellOffer
|
||||
* and BuyOffer must be specified.
|
||||
* In direct mode this field is optional, but either NFTokenSellOffer or
|
||||
* NFTokenBuyOffer must be specified. In brokered mode, both NFTokenSellOffer
|
||||
* and NFTokenBuyOffer must be specified.
|
||||
*/
|
||||
BuyOffer?: string
|
||||
NFTokenBuyOffer?: string
|
||||
/**
|
||||
* This field is only valid in brokered mode. It specifies the
|
||||
* amount that the broker will keep as part of their fee for
|
||||
@@ -57,28 +57,28 @@ export interface NFTokenAcceptOffer extends BaseTransaction {
|
||||
* larger amount, without the broker having to own the NFToken
|
||||
* or custody funds.
|
||||
*
|
||||
* Note: in brokered mode, the offers referenced by BuyOffer
|
||||
* and SellOffer must both specify the same TokenID; that is,
|
||||
* Note: in brokered mode, the offers referenced by NFTokenBuyOffer
|
||||
* and NFTokenSellOffer must both specify the same NFTokenID; that is,
|
||||
* both must be for the same NFToken.
|
||||
*/
|
||||
BrokerFee?: Amount
|
||||
NFTokenBrokerFee?: Amount
|
||||
}
|
||||
|
||||
function validateBrokerFee(tx: Record<string, unknown>): void {
|
||||
const value = parseAmountValue(tx.BrokerFee)
|
||||
function validateNFTokenBrokerFee(tx: Record<string, unknown>): void {
|
||||
const value = parseAmountValue(tx.NFTokenBrokerFee)
|
||||
if (Number.isNaN(value)) {
|
||||
throw new ValidationError('NFTokenAcceptOffer: invalid BrokerFee')
|
||||
throw new ValidationError('NFTokenAcceptOffer: invalid NFTokenBrokerFee')
|
||||
}
|
||||
|
||||
if (value <= 0) {
|
||||
throw new ValidationError(
|
||||
'NFTokenAcceptOffer: BrokerFee must be greater than 0; omit if there is no fee',
|
||||
'NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee',
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.SellOffer == null || tx.BuyOffer == null) {
|
||||
if (tx.NFTokenSellOffer == null || tx.NFTokenBuyOffer == null) {
|
||||
throw new ValidationError(
|
||||
'NFTokenAcceptOffer: both SellOffer and BuyOffer must be set if using brokered mode',
|
||||
'NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode',
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -92,13 +92,13 @@ function validateBrokerFee(tx: Record<string, unknown>): void {
|
||||
export function validateNFTokenAcceptOffer(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.BrokerFee != null) {
|
||||
validateBrokerFee(tx)
|
||||
if (tx.NFTokenBrokerFee != null) {
|
||||
validateNFTokenBrokerFee(tx)
|
||||
}
|
||||
|
||||
if (tx.SellOffer == null && tx.BuyOffer == null) {
|
||||
if (tx.NFTokenSellOffer == null && tx.NFTokenBuyOffer == null) {
|
||||
throw new ValidationError(
|
||||
'NFTokenAcceptOffer: must set either SellOffer or BuyOffer',
|
||||
'NFTokenAcceptOffer: must set either NFTokenSellOffer or NFTokenBuyOffer',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export interface NFTokenBurn extends BaseTransaction {
|
||||
/**
|
||||
* Identifies the NFToken object to be removed by the transaction.
|
||||
*/
|
||||
TokenID: string
|
||||
NFTokenID: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ export interface NFTokenBurn extends BaseTransaction {
|
||||
export function validateNFTokenBurn(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (tx.TokenID == null) {
|
||||
throw new ValidationError('NFTokenBurn: missing field TokenID')
|
||||
if (tx.NFTokenID == null) {
|
||||
throw new ValidationError('NFTokenBurn: missing field NFTokenID')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface NFTokenCancelOffer extends BaseTransaction {
|
||||
* error if an entry in this list points to an object that
|
||||
* does not exist. This field is required.
|
||||
*/
|
||||
TokenOffers: string[]
|
||||
NFTokenOffers: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,11 +35,11 @@ export interface NFTokenCancelOffer extends BaseTransaction {
|
||||
export function validateNFTokenCancelOffer(tx: Record<string, unknown>): void {
|
||||
validateBaseTransaction(tx)
|
||||
|
||||
if (!Array.isArray(tx.TokenOffers)) {
|
||||
throw new ValidationError('NFTokenCancelOffer: missing field TokenOffers')
|
||||
if (!Array.isArray(tx.NFTokenOffers)) {
|
||||
throw new ValidationError('NFTokenCancelOffer: missing field NFTokenOffers')
|
||||
}
|
||||
|
||||
if (tx.TokenOffers.length < 1) {
|
||||
throw new ValidationError('NFTokenCancelOffer: empty field TokenOffers')
|
||||
if (tx.NFTokenOffers.length < 1) {
|
||||
throw new ValidationError('NFTokenCancelOffer: empty field NFTokenOffers')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,10 @@ export interface NFTokenCreateOfferFlagsInterface extends GlobalFlags {
|
||||
export interface NFTokenCreateOffer extends BaseTransaction {
|
||||
TransactionType: 'NFTokenCreateOffer'
|
||||
/**
|
||||
* Identifies the TokenID of the NFToken object that the
|
||||
* Identifies the NFTokenID of the NFToken object that the
|
||||
* offer references.
|
||||
*/
|
||||
TokenID: string
|
||||
NFTokenID: string
|
||||
/**
|
||||
* Indicates the amount expected or offered for the Token.
|
||||
*
|
||||
@@ -83,7 +83,7 @@ export interface NFTokenCreateOffer extends BaseTransaction {
|
||||
Flags?: number | NFTokenCreateOfferFlagsInterface
|
||||
}
|
||||
|
||||
function validateSellOfferCases(tx: Record<string, unknown>): void {
|
||||
function validateNFTokenSellOfferCases(tx: Record<string, unknown>): void {
|
||||
if (tx.Owner != null) {
|
||||
throw new ValidationError(
|
||||
'NFTokenCreateOffer: Owner must not be present for sell offers',
|
||||
@@ -91,7 +91,7 @@ function validateSellOfferCases(tx: Record<string, unknown>): void {
|
||||
}
|
||||
}
|
||||
|
||||
function validateBuyOfferCases(tx: Record<string, unknown>): void {
|
||||
function validateNFTokenBuyOfferCases(tx: Record<string, unknown>): void {
|
||||
if (tx.Owner == null) {
|
||||
throw new ValidationError(
|
||||
'NFTokenCreateOffer: Owner must be present for buy offers',
|
||||
@@ -126,8 +126,8 @@ export function validateNFTokenCreateOffer(tx: Record<string, unknown>): void {
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.TokenID == null) {
|
||||
throw new ValidationError('NFTokenCreateOffer: missing field TokenID')
|
||||
if (tx.NFTokenID == null) {
|
||||
throw new ValidationError('NFTokenCreateOffer: missing field NFTokenID')
|
||||
}
|
||||
|
||||
if (!isAmount(tx.Amount)) {
|
||||
@@ -138,8 +138,8 @@ export function validateNFTokenCreateOffer(tx: Record<string, unknown>): void {
|
||||
typeof tx.Flags === 'number' &&
|
||||
isFlagEnabled(tx.Flags, NFTokenCreateOfferFlags.tfSellToken)
|
||||
) {
|
||||
validateSellOfferCases(tx)
|
||||
validateNFTokenSellOfferCases(tx)
|
||||
} else {
|
||||
validateBuyOfferCases(tx)
|
||||
validateNFTokenBuyOfferCases(tx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ export interface NFTokenMint extends BaseTransaction {
|
||||
* than or equal to 2147483648 (0x80000000). If you have no use for this
|
||||
* field, set it to 0.
|
||||
*/
|
||||
TokenTaxon: number
|
||||
NFTokenTaxon: number
|
||||
/**
|
||||
* Indicates the account that should be the issuer of this token. This value
|
||||
* is optional and should only be specified if the account executing the
|
||||
@@ -105,7 +105,7 @@ export function validateNFTokenMint(tx: Record<string, unknown>): void {
|
||||
)
|
||||
}
|
||||
|
||||
if (tx.TokenTaxon == null) {
|
||||
throw new ValidationError('NFTokenMint: missing field TokenTaxon')
|
||||
if (tx.NFTokenTaxon == null) {
|
||||
throw new ValidationError('NFTokenMint: missing field NFTokenTaxon')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export enum AccountSetAsfFlags {
|
||||
/**
|
||||
* Allow another account to mint and burn tokens on behalf of this account.
|
||||
*/
|
||||
asfAuthorizedMinter = 10,
|
||||
asfAuthorizedNFTokenMinter = 10,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ export interface AccountSet extends BaseTransaction {
|
||||
* Sets an alternate account that is allowed to mint NFTokens on this
|
||||
* account's behalf using NFTokenMint's `Issuer` field.
|
||||
*/
|
||||
Minter?: string
|
||||
NFTokenMinter?: string
|
||||
}
|
||||
|
||||
const MIN_TICK_SIZE = 3
|
||||
|
||||
@@ -47,12 +47,12 @@ function unscrambleTaxon(taxon: number, tokenSeq: number): number {
|
||||
* |
|
||||
* `---> Flags: 11 -> lsfBurnable, lsfOnlyXRP and lsfTransferable
|
||||
*
|
||||
* @param tokenID - A hex string which identifies an NFToken on the ledger.
|
||||
* @throws XrplError when given an invalid tokenID.
|
||||
* @returns a decoded tokenID with all fields encoded within.
|
||||
* @param nftokenID - A hex string which identifies an NFToken on the ledger.
|
||||
* @throws XrplError when given an invalid nftokenID.
|
||||
* @returns a decoded nftokenID with all fields encoded within.
|
||||
*/
|
||||
export default function parseNFTokenID(tokenID: string): {
|
||||
TokenID: string
|
||||
export default function parseNFTokenID(nftokenID: string): {
|
||||
NFTokenID: string
|
||||
Flags: number
|
||||
TransferFee: number
|
||||
Issuer: string
|
||||
@@ -60,19 +60,22 @@ export default function parseNFTokenID(tokenID: string): {
|
||||
Sequence: number
|
||||
} {
|
||||
const expectedLength = 64
|
||||
if (tokenID.length !== expectedLength) {
|
||||
throw new XrplError(`Attempting to parse a tokenID with length ${tokenID.length}
|
||||
if (nftokenID.length !== expectedLength) {
|
||||
throw new XrplError(`Attempting to parse a nftokenID with length ${nftokenID.length}
|
||||
, but expected a token with length ${expectedLength}`)
|
||||
}
|
||||
|
||||
const scrambledTaxon = new BigNumber(tokenID.substring(48, 56), 16).toNumber()
|
||||
const sequence = new BigNumber(tokenID.substring(56, 64), 16).toNumber()
|
||||
const scrambledTaxon = new BigNumber(
|
||||
nftokenID.substring(48, 56),
|
||||
16,
|
||||
).toNumber()
|
||||
const sequence = new BigNumber(nftokenID.substring(56, 64), 16).toNumber()
|
||||
|
||||
const NFTokenIDData = {
|
||||
TokenID: tokenID,
|
||||
Flags: new BigNumber(tokenID.substring(0, 4), 16).toNumber(),
|
||||
TransferFee: new BigNumber(tokenID.substring(4, 8), 16).toNumber(),
|
||||
Issuer: encodeAccountID(Buffer.from(tokenID.substring(8, 48), 'hex')),
|
||||
NFTokenID: nftokenID,
|
||||
Flags: new BigNumber(nftokenID.substring(0, 4), 16).toNumber(),
|
||||
TransferFee: new BigNumber(nftokenID.substring(4, 8), 16).toNumber(),
|
||||
Issuer: encodeAccountID(Buffer.from(nftokenID.substring(8, 48), 'hex')),
|
||||
Taxon: unscrambleTaxon(scrambledTaxon, sequence),
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { assert } from 'chai'
|
||||
import { validate, ValidationError } from 'xrpl-local'
|
||||
|
||||
const BUY_OFFER =
|
||||
const NFTOKEN_BUY_OFFER =
|
||||
'AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AF'
|
||||
const SELL_OFFER =
|
||||
const NFTOKEN_SELL_OFFER =
|
||||
'AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE'
|
||||
|
||||
/**
|
||||
@@ -12,10 +12,10 @@ const SELL_OFFER =
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('NFTokenAcceptOffer', function () {
|
||||
it(`verifies valid NFTokenAcceptOffer with BuyOffer`, function () {
|
||||
it(`verifies valid NFTokenAcceptOffer with NFTokenBuyOffer`, function () {
|
||||
const validNFTokenAcceptOffer = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
BuyOffer: BUY_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -25,10 +25,10 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenAcceptOffer))
|
||||
})
|
||||
|
||||
it(`verifies valid NFTokenAcceptOffer with SellOffer`, function () {
|
||||
it(`verifies valid NFTokenAcceptOffer with NFTokenSellOffer`, function () {
|
||||
const validNFTokenAcceptOffer = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
SellOffer: SELL_OFFER,
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -38,7 +38,7 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenAcceptOffer))
|
||||
})
|
||||
|
||||
it(`throws w/ missing SellOffer and BuyOffer`, function () {
|
||||
it(`throws w/ missing NFTokenSellOffer and NFTokenBuyOffer`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
@@ -50,16 +50,16 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: must set either SellOffer or BuyOffer',
|
||||
'NFTokenAcceptOffer: must set either NFTokenSellOffer or NFTokenBuyOffer',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing SellOffer and present BrokerFee`, function () {
|
||||
it(`throws w/ missing NFTokenSellOffer and present NFTokenBrokerFee`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
BuyOffer: BUY_OFFER,
|
||||
BrokerFee: '1',
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
NFTokenBrokerFee: '1',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -68,16 +68,16 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: both SellOffer and BuyOffer must be set if using brokered mode',
|
||||
'NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ missing BuyOffer and present BrokerFee`, function () {
|
||||
it(`throws w/ missing NFTokenBuyOffer and present NFTokenBrokerFee`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
SellOffer: SELL_OFFER,
|
||||
BrokerFee: '1',
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBrokerFee: '1',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -86,15 +86,15 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: both SellOffer and BuyOffer must be set if using brokered mode',
|
||||
'NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode',
|
||||
)
|
||||
})
|
||||
|
||||
it(`verifies valid NFTokenAcceptOffer with both offers and no BrokerFee`, function () {
|
||||
it(`verifies valid NFTokenAcceptOffer with both offers and no NFTokenBrokerFee`, function () {
|
||||
const validNFTokenAcceptOffer = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
SellOffer: SELL_OFFER,
|
||||
BuyOffer: BUY_OFFER,
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -104,12 +104,12 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenAcceptOffer))
|
||||
})
|
||||
|
||||
it(`verifies valid NFTokenAcceptOffer with BrokerFee`, function () {
|
||||
it(`verifies valid NFTokenAcceptOffer with NFTokenBrokerFee`, function () {
|
||||
const validNFTokenAcceptOffer = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
SellOffer: SELL_OFFER,
|
||||
BuyOffer: BUY_OFFER,
|
||||
BrokerFee: '1',
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
NFTokenBrokerFee: '1',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -119,13 +119,13 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenAcceptOffer))
|
||||
})
|
||||
|
||||
it(`throws w/ BrokerFee === 0`, function () {
|
||||
it(`throws w/ NFTokenBrokerFee === 0`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
SellOffer: SELL_OFFER,
|
||||
BuyOffer: BUY_OFFER,
|
||||
BrokerFee: '0',
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
NFTokenBrokerFee: '0',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -134,17 +134,17 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: BrokerFee must be greater than 0; omit if there is no fee',
|
||||
'NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ BrokerFee < 0`, function () {
|
||||
it(`throws w/ NFTokenBrokerFee < 0`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
SellOffer: SELL_OFFER,
|
||||
BuyOffer: BUY_OFFER,
|
||||
BrokerFee: '-1',
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
NFTokenBrokerFee: '-1',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -153,17 +153,17 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: BrokerFee must be greater than 0; omit if there is no fee',
|
||||
'NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ invalid BrokerFee`, function () {
|
||||
it(`throws w/ invalid NFTokenBrokerFee`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenAcceptOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
SellOffer: SELL_OFFER,
|
||||
BuyOffer: BUY_OFFER,
|
||||
BrokerFee: 1,
|
||||
NFTokenSellOffer: NFTOKEN_SELL_OFFER,
|
||||
NFTokenBuyOffer: NFTOKEN_BUY_OFFER,
|
||||
NFTokenBrokerFee: 1,
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -172,7 +172,7 @@ describe('NFTokenAcceptOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenAcceptOffer: invalid BrokerFee',
|
||||
'NFTokenAcceptOffer: invalid NFTokenBrokerFee',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('NFTokenBurn', function () {
|
||||
it(`verifies valid NFTokenBurn`, function () {
|
||||
const validNFTokenBurn = {
|
||||
TransactionType: 'NFTokenBurn',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: TOKEN_ID,
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -23,7 +23,7 @@ describe('NFTokenBurn', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenBurn))
|
||||
})
|
||||
|
||||
it(`throws w/ missing TokenID`, function () {
|
||||
it(`throws w/ missing NFTokenID`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenBurn',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
@@ -35,7 +35,7 @@ describe('NFTokenBurn', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenBurn: missing field TokenID',
|
||||
'NFTokenBurn: missing field NFTokenID',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('NFTokenCancelOffer', function () {
|
||||
it(`verifies valid NFTokenCancelOffer`, function () {
|
||||
const validNFTokenCancelOffer = {
|
||||
TransactionType: 'NFTokenCancelOffer',
|
||||
TokenOffers: [BUY_OFFER],
|
||||
NFTokenOffers: [BUY_OFFER],
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
@@ -23,7 +23,7 @@ describe('NFTokenCancelOffer', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenCancelOffer))
|
||||
})
|
||||
|
||||
it(`throws w/ missing TokenOffers`, function () {
|
||||
it(`throws w/ missing NFTokenOffers`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCancelOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
@@ -35,15 +35,15 @@ describe('NFTokenCancelOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenCancelOffer: missing field TokenOffers',
|
||||
'NFTokenCancelOffer: missing field NFTokenOffers',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ empty TokenOffers`, function () {
|
||||
it(`throws w/ empty NFTokenOffers`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCancelOffer',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
TokenOffers: [],
|
||||
NFTokenOffers: [],
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: 2147483648,
|
||||
@@ -52,7 +52,7 @@ describe('NFTokenCancelOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenCancelOffer: empty field TokenOffers',
|
||||
'NFTokenCancelOffer: empty field NFTokenOffers',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { assert } from 'chai'
|
||||
import { validate, ValidationError, NFTokenCreateOfferFlags } from 'xrpl-local'
|
||||
|
||||
const TOKEN_ID =
|
||||
const NFTOKEN_ID =
|
||||
'00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003'
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
it(`verifies valid NFTokenCreateOffer buyside`, function () {
|
||||
const validNFTokenCreateOffer = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: '1',
|
||||
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
||||
Expiration: 1000,
|
||||
@@ -29,7 +29,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
it(`verifies valid NFTokenCreateOffer sellside`, function () {
|
||||
const validNFTokenCreateOffer = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: '1',
|
||||
Flags: NFTokenCreateOfferFlags.tfSellToken,
|
||||
Expiration: 1000,
|
||||
@@ -45,7 +45,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
it(`verifies w/ 0 Amount NFTokenCreateOffer sellside`, function () {
|
||||
const validNFTokenCreateOffer = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: '0',
|
||||
Flags: NFTokenCreateOfferFlags.tfSellToken,
|
||||
Expiration: 1000,
|
||||
@@ -61,7 +61,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
it(`throws w/ Account === Owner`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: '1',
|
||||
Expiration: 1000,
|
||||
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
@@ -80,7 +80,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
it(`throws w/ Account === Destination`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: '1',
|
||||
Flags: NFTokenCreateOfferFlags.tfSellToken,
|
||||
Expiration: 1000,
|
||||
@@ -97,7 +97,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/out TokenID`, function () {
|
||||
it(`throws w/out NFTokenID`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
Amount: '1',
|
||||
@@ -112,14 +112,14 @@ describe('NFTokenCreateOffer', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenCreateOffer: missing field TokenID',
|
||||
'NFTokenCreateOffer: missing field NFTokenID',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ invalid Amount`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Amount: 1,
|
||||
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXe',
|
||||
Expiration: 1000,
|
||||
@@ -141,7 +141,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
TransactionType: 'NFTokenCreateOffer',
|
||||
Owner: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXe',
|
||||
Expiration: 1000,
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Destination: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Fee: '5000000',
|
||||
@@ -161,7 +161,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
Expiration: 1000,
|
||||
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Flags: NFTokenCreateOfferFlags.tfSellToken,
|
||||
Amount: '1',
|
||||
Fee: '5000000',
|
||||
@@ -181,7 +181,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
Expiration: 1000,
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
Amount: '1',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
} as any
|
||||
@@ -201,7 +201,7 @@ describe('NFTokenCreateOffer', function () {
|
||||
Owner: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
||||
Amount: '0',
|
||||
Fee: '5000000',
|
||||
TokenID: TOKEN_ID,
|
||||
NFTokenID: NFTOKEN_ID,
|
||||
Sequence: 2470665,
|
||||
} as any
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('NFTokenMint', function () {
|
||||
Fee: '5000000',
|
||||
Sequence: 2470665,
|
||||
Flags: NFTokenMintFlags.tfTransferable,
|
||||
TokenTaxon: 0,
|
||||
NFTokenTaxon: 0,
|
||||
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
|
||||
TransferFee: 1,
|
||||
URI: convertStringToHex('http://xrpl.org'),
|
||||
@@ -28,7 +28,7 @@ describe('NFTokenMint', function () {
|
||||
assert.doesNotThrow(() => validate(validNFTokenMint))
|
||||
})
|
||||
|
||||
it(`throws w/ missing TokenTaxon`, function () {
|
||||
it(`throws w/ missing NFTokenTaxon`, function () {
|
||||
const invalid = {
|
||||
TransactionType: 'NFTokenMint',
|
||||
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
@@ -43,7 +43,7 @@ describe('NFTokenMint', function () {
|
||||
assert.throws(
|
||||
() => validate(invalid),
|
||||
ValidationError,
|
||||
'NFTokenMint: missing field TokenTaxon',
|
||||
'NFTokenMint: missing field NFTokenTaxon',
|
||||
)
|
||||
})
|
||||
|
||||
@@ -56,7 +56,7 @@ describe('NFTokenMint', function () {
|
||||
Flags: NFTokenMintFlags.tfTransferable,
|
||||
Issuer: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
|
||||
TransferFee: 1,
|
||||
TokenTaxon: 0,
|
||||
NFTokenTaxon: 0,
|
||||
URI: convertStringToHex('http://xrpl.org'),
|
||||
} as any
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import { assertResultMatch } from '../testUtils'
|
||||
|
||||
describe('parseNFTokenID', function () {
|
||||
it('decode a valid NFTokenID', function () {
|
||||
const tokenID =
|
||||
const nftokenID =
|
||||
'000B0539C35B55AA096BA6D87A6E6C965A6534150DC56E5E12C5D09E0000000C'
|
||||
const result = parseNFTokenID(tokenID)
|
||||
const result = parseNFTokenID(nftokenID)
|
||||
const expected = {
|
||||
TokenID: tokenID,
|
||||
NFTokenID: nftokenID,
|
||||
Flags: 11,
|
||||
TransferFee: 1337,
|
||||
Issuer: 'rJoxBSzpXhPtAuqFmqxQtGKjA13jUJWthE',
|
||||
|
||||
Reference in New Issue
Block a user