mirror of
				https://github.com/Xahau/xahau.js.git
				synced 2025-11-04 04:55:48 +00:00 
			
		
		
		
	xahau-functionality
This commit is contained in:
		@@ -14,6 +14,7 @@ import {
 | 
			
		||||
} from './enums'
 | 
			
		||||
import { STObject } from './types/st-object'
 | 
			
		||||
import { JsonObject } from './types/serialized-type'
 | 
			
		||||
import { AmountObject } from './types/amount'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Construct a BinaryParser
 | 
			
		||||
@@ -128,7 +129,7 @@ function signingData(
 | 
			
		||||
 */
 | 
			
		||||
interface ClaimObject extends JsonObject {
 | 
			
		||||
  channel: string
 | 
			
		||||
  amount: string | number
 | 
			
		||||
  amount: AmountObject
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -139,16 +140,21 @@ interface ClaimObject extends JsonObject {
 | 
			
		||||
 * @returns the serialized object with appropriate prefix
 | 
			
		||||
 */
 | 
			
		||||
function signingClaimData(claim: ClaimObject): Uint8Array {
 | 
			
		||||
  const num = BigInt(String(claim.amount))
 | 
			
		||||
  const prefix = HashPrefix.paymentChannelClaim
 | 
			
		||||
  const channel = coreTypes.Hash256.from(claim.channel).toBytes()
 | 
			
		||||
  const amount = coreTypes.UInt64.from(num).toBytes()
 | 
			
		||||
 | 
			
		||||
  const bytesList = new BytesList()
 | 
			
		||||
 | 
			
		||||
  bytesList.put(prefix)
 | 
			
		||||
  bytesList.put(channel)
 | 
			
		||||
  bytesList.put(amount)
 | 
			
		||||
  if (typeof claim.amount === 'string') {
 | 
			
		||||
    const num = BigInt(String(claim.amount))
 | 
			
		||||
    const amount = coreTypes.UInt64.from(num).toBytes()
 | 
			
		||||
    bytesList.put(amount)
 | 
			
		||||
  } else {
 | 
			
		||||
    const amount = coreTypes.Amount.from(claim.amount).toBytes()
 | 
			
		||||
    bytesList.put(amount)
 | 
			
		||||
  }
 | 
			
		||||
  return bytesList.toBytes()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -19,6 +19,7 @@ const Field = DEFAULT_DEFINITIONS.field
 | 
			
		||||
 * @brief: All valid transaction types
 | 
			
		||||
 */
 | 
			
		||||
const TRANSACTION_TYPES = DEFAULT_DEFINITIONS.transactionNames
 | 
			
		||||
const TRANSACTION_TYPE_MAP = DEFAULT_DEFINITIONS.transactionMap
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
  Bytes,
 | 
			
		||||
@@ -31,4 +32,5 @@ export {
 | 
			
		||||
  TransactionResult,
 | 
			
		||||
  TransactionType,
 | 
			
		||||
  TRANSACTION_TYPES,
 | 
			
		||||
  TRANSACTION_TYPE_MAP,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,8 @@ class XrplDefinitionsBase {
 | 
			
		||||
  transactionType: BytesLookup
 | 
			
		||||
  // Valid transaction names
 | 
			
		||||
  transactionNames: string[]
 | 
			
		||||
  // Valid transaction map
 | 
			
		||||
  transactionMap: Record<string, number>
 | 
			
		||||
  // Maps serializable types to their TypeScript class implementation
 | 
			
		||||
  dataTypes: Record<string, typeof SerializedType>
 | 
			
		||||
 | 
			
		||||
@@ -72,6 +74,15 @@ class XrplDefinitionsBase {
 | 
			
		||||
      .filter(([_key, value]) => value >= 0)
 | 
			
		||||
      .map(([key, _value]) => key)
 | 
			
		||||
 | 
			
		||||
    const ignoreList = ['EnableAmendment', 'SetFee', 'UNLModify', 'EmitFailure']
 | 
			
		||||
    this.transactionMap = Object.assign(
 | 
			
		||||
      {},
 | 
			
		||||
      ...Object.entries(enums.TRANSACTION_TYPES)
 | 
			
		||||
 | 
			
		||||
        .filter(([_key, _value]) => _value >= 0 || ignoreList.includes(_key))
 | 
			
		||||
        .map(([key, value]) => ({ [key]: value })),
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    this.dataTypes = {} // Filled in via associateTypes
 | 
			
		||||
    this.associateTypes(types)
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import { JsonObject } from './types/serialized-type'
 | 
			
		||||
import {
 | 
			
		||||
  XrplDefinitionsBase,
 | 
			
		||||
  TRANSACTION_TYPES,
 | 
			
		||||
  TRANSACTION_TYPE_MAP,
 | 
			
		||||
  DEFAULT_DEFINITIONS,
 | 
			
		||||
} from './enums'
 | 
			
		||||
import { XrplDefinitions } from './enums/xahau-definitions'
 | 
			
		||||
@@ -146,6 +147,7 @@ export {
 | 
			
		||||
  decodeQuality,
 | 
			
		||||
  decodeLedgerData,
 | 
			
		||||
  TRANSACTION_TYPES,
 | 
			
		||||
  TRANSACTION_TYPE_MAP,
 | 
			
		||||
  XrplDefinitions,
 | 
			
		||||
  XrplDefinitionsBase,
 | 
			
		||||
  DEFAULT_DEFINITIONS,
 | 
			
		||||
 
 | 
			
		||||
@@ -104,6 +104,17 @@ let json_omitted = {
 | 
			
		||||
 | 
			
		||||
const NegativeUNL = require('./fixtures/negative-unl.json')
 | 
			
		||||
 | 
			
		||||
const UNLReport = {
 | 
			
		||||
  tx: require('./fixtures/unl-report.json'),
 | 
			
		||||
  binary: require('./fixtures/unl-report-binary.json'),
 | 
			
		||||
  meta: require('./fixtures/unl-report-meta-binary.json'),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const Remit = {
 | 
			
		||||
  tx: require('./fixtures/remit-tx.json'),
 | 
			
		||||
  binary: require('./fixtures/remit-binary.json'),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function bytesListTest() {
 | 
			
		||||
  const list = new BytesList()
 | 
			
		||||
    .put(Uint8Array.from([0]))
 | 
			
		||||
@@ -235,6 +246,18 @@ function NegativeUNLTest() {
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function UNLReportTest() {
 | 
			
		||||
  test('can serialize UNLReport', () => {
 | 
			
		||||
    expect(encode(UNLReport.tx)).toEqual(UNLReport.binary)
 | 
			
		||||
  })
 | 
			
		||||
  test('can serialize UNLReport metadata', () => {
 | 
			
		||||
    expect(encode(UNLReport.tx.meta)).toEqual(UNLReport.meta)
 | 
			
		||||
  })
 | 
			
		||||
  test('can deserialize UNLReport metadata', () => {
 | 
			
		||||
    expect(decode(UNLReport.meta)).toEqual(UNLReport.tx.meta)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function omitUndefinedTest() {
 | 
			
		||||
  it('omits fields with undefined value', () => {
 | 
			
		||||
    let encodedOmitted = encode(json_omitted)
 | 
			
		||||
@@ -250,34 +273,10 @@ function ticketTest() {
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function nfTokenTest() {
 | 
			
		||||
  const fixtures = require('./fixtures/nf-token.json')
 | 
			
		||||
 | 
			
		||||
  for (const txName of Object.keys(fixtures)) {
 | 
			
		||||
    it(`can serialize transaction ${txName}`, () => {
 | 
			
		||||
      expect(encode(fixtures[txName].tx.json)).toEqual(
 | 
			
		||||
        fixtures[txName].tx.binary,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it(`can deserialize transaction ${txName}`, () => {
 | 
			
		||||
      expect(decode(fixtures[txName].tx.binary)).toEqual(
 | 
			
		||||
        fixtures[txName].tx.json,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it(`can serialize meta ${txName}`, () => {
 | 
			
		||||
      expect(encode(fixtures[txName].meta.json)).toEqual(
 | 
			
		||||
        fixtures[txName].meta.binary,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it(`can deserialize meta ${txName}`, () => {
 | 
			
		||||
      expect(decode(fixtures[txName].meta.binary)).toEqual(
 | 
			
		||||
        fixtures[txName].meta.json,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
function remitTest() {
 | 
			
		||||
  test('can serialize Remit', () => {
 | 
			
		||||
    expect(encode(Remit.tx)).toEqual(Remit.binary)
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
describe('Binary Serialization', function () {
 | 
			
		||||
@@ -289,7 +288,8 @@ describe('Binary Serialization', function () {
 | 
			
		||||
  describe('Escrow', EscrowTest)
 | 
			
		||||
  describe('PaymentChannel', PaymentChannelTest)
 | 
			
		||||
  describe('NegativeUNLTest', NegativeUNLTest)
 | 
			
		||||
  describe('UNLReportTest', UNLReportTest)
 | 
			
		||||
  describe('OmitUndefined', omitUndefinedTest)
 | 
			
		||||
  describe('RemitTest', remitTest)
 | 
			
		||||
  describe('TicketTest', ticketTest)
 | 
			
		||||
  describe('NFToken', nfTokenTest)
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ describe('encode and decode using new types as a parameter', function () {
 | 
			
		||||
    definitions.FIELDS.push([
 | 
			
		||||
      'NewFieldDefinition',
 | 
			
		||||
      {
 | 
			
		||||
        nth: 100,
 | 
			
		||||
        nth: 101,
 | 
			
		||||
        isVLEncoded: false,
 | 
			
		||||
        isSerialized: true,
 | 
			
		||||
        isSigningField: true,
 | 
			
		||||
 
 | 
			
		||||
@@ -1,547 +0,0 @@
 | 
			
		||||
{
 | 
			
		||||
  "NFTokenMint": {
 | 
			
		||||
    "tx": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
        "Fee": "12",
 | 
			
		||||
        "Flags": 9,
 | 
			
		||||
        "LastLedgerSequence": 22,
 | 
			
		||||
        "Sequence": 5,
 | 
			
		||||
        "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
 | 
			
		||||
        "NFTokenTaxon": 0,
 | 
			
		||||
        "TransactionType": "NFTokenMint",
 | 
			
		||||
        "TransferFee": 50,
 | 
			
		||||
        "TxnSignature": "3045022100DAB7343B26035702FF7E0736E04A092AC9512964E41C3CA64926CDFBE777946602202F295A3BB1282E0AF98F9F5978D4037D75EDEB0EC642519D966D7B9B5826E61B",
 | 
			
		||||
        "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "12001914003222000000092400000005201B00000016202A0000000068400000000000000C73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100DAB7343B26035702FF7E0736E04A092AC9512964E41C3CA64926CDFBE777946602202F295A3BB1282E0AF98F9F5978D4037D75EDEB0EC642519D966D7B9B5826E61B751868747470733A2F2F677265677765697362726F642E636F6D8114B5F762798A53D543A014CAF8B297CFF8F2F937E8"
 | 
			
		||||
    },
 | 
			
		||||
    "meta": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "AffectedNodes": [
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "Balance": "99999999999999940",
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "MintedNFTokens": 5,
 | 
			
		||||
                "OwnerCount": 1,
 | 
			
		||||
                "Sequence": 6
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "99999999999999952",
 | 
			
		||||
                "MintedNFTokens": 4,
 | 
			
		||||
                "Sequence": 5
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "E9BFEE7C403F74445B59B8FA8E972ABD642A360E1FBC15C53BAA717573BEC462",
 | 
			
		||||
              "PreviousTxnLgrSeq": 3
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F00000004",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "NFTokenPage",
 | 
			
		||||
              "LedgerIndex": "B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFF",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "E9BFEE7C403F74445B59B8FA8E972ABD642A360E1FBC15C53BAA717573BEC462",
 | 
			
		||||
              "PreviousTxnLgrSeq": 3
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionIndex": 4,
 | 
			
		||||
        "TransactionResult": "tesSUCCESS"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "201C00000004F8E5110061250000000355E9BFEE7C403F74445B59B8FA8E972ABD642A360E1FBC15C53BAA717573BEC462562B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8E62400000005202B0000000462416345785D89FFD0E1E7220000000024000000062D00000001202B0000000562416345785D89FFC48114B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E5110050250000000355E9BFEE7C403F74445B59B8FA8E972ABD642A360E1FBC15C53BAA717573BEC46256B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFFE6FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E72200000000FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F00000004751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E1F1031000"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "NFTokenBurn": {
 | 
			
		||||
    "tx": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
        "Fee": "12",
 | 
			
		||||
        "Flags": 0,
 | 
			
		||||
        "LastLedgerSequence": 23,
 | 
			
		||||
        "Sequence": 6,
 | 
			
		||||
        "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
 | 
			
		||||
        "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F00000004",
 | 
			
		||||
        "TransactionType": "NFTokenBurn",
 | 
			
		||||
        "TxnSignature": "3045022100D614E1F0A1C41A05652B8998FC2C4DC8658B95BFD89F4A0DEBE3FFDCB75CE1D8022027DF89138FC442C803DC2BEC07636CEB8D0EC6297E23262A729B83D32F93FD3D"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "12001A22000000002400000006201B000000175A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F0000000468400000000000000C73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100D614E1F0A1C41A05652B8998FC2C4DC8658B95BFD89F4A0DEBE3FFDCB75CE1D8022027DF89138FC442C803DC2BEC07636CEB8D0EC6297E23262A729B83D32F93FD3D8114B5F762798A53D543A014CAF8B297CFF8F2F937E8"
 | 
			
		||||
    },
 | 
			
		||||
    "meta": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "AffectedNodes": [
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "Balance": "99999999999999928",
 | 
			
		||||
                "BurnedNFTokens": 1,
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "MintedNFTokens": 5,
 | 
			
		||||
                "OwnerCount": 1,
 | 
			
		||||
                "Sequence": 7
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "99999999999999940",
 | 
			
		||||
                "Sequence": 6
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "5F0E3A19F1D5B028A31B8A0FDE8533B0FD185E4AE306F79CFF51D18E68985231",
 | 
			
		||||
              "PreviousTxnLgrSeq": 3
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "NFTokenPage",
 | 
			
		||||
              "LedgerIndex": "B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFF",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F00000004",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "5F0E3A19F1D5B028A31B8A0FDE8533B0FD185E4AE306F79CFF51D18E68985231",
 | 
			
		||||
              "PreviousTxnLgrSeq": 3
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionIndex": 0,
 | 
			
		||||
        "TransactionResult": "tesSUCCESS"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "201C00000000F8E51100612500000003555F0E3A19F1D5B028A31B8A0FDE8533B0FD185E4AE306F79CFF51D18E68985231562B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8E6240000000662416345785D89FFC4E1E7220000000024000000072D00000001202B00000005202C0000000162416345785D89FFB88114B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E51100502500000003555F0E3A19F1D5B028A31B8A0FDE8533B0FD185E4AE306F79CFF51D18E6898523156B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFFE6FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E85B974D9F00000004751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E72200000000FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E1F1031000"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "NFTokenCreateOffer": {
 | 
			
		||||
    "tx": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
        "Amount": "100",
 | 
			
		||||
        "Destination": "rV3WAvwwXgvPrYiUgSoytn9w3mejtPgLo",
 | 
			
		||||
        "Expiration": 999999999,
 | 
			
		||||
        "Fee": "12",
 | 
			
		||||
        "Flags": 1,
 | 
			
		||||
        "LastLedgerSequence": 26,
 | 
			
		||||
        "Sequence": 9,
 | 
			
		||||
        "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
 | 
			
		||||
        "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
        "TransactionType": "NFTokenCreateOffer",
 | 
			
		||||
        "TxnSignature": "3045022100BCEEEF98B9DB3A2ACA7CE80AB91B9398E3429B93F660BB8A063F134AA798AE970220667C560D16E555DF5EF30536804C082DAEC7A446DF2C7533ADB1E2437AF2CCB0"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "12001B220000000124000000092A3B9AC9FF201B0000001A5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B0000000061400000000000006468400000000000000C73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074473045022100BCEEEF98B9DB3A2ACA7CE80AB91B9398E3429B93F660BB8A063F134AA798AE970220667C560D16E555DF5EF30536804C082DAEC7A446DF2C7533ADB1E2437AF2CCB08114B5F762798A53D543A014CAF8B297CFF8F2F937E883140551EBD684BF2ADE0EF093A92B6E2C55D15BD9AE"
 | 
			
		||||
    },
 | 
			
		||||
    "meta": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "AffectedNodes": [
 | 
			
		||||
          {
 | 
			
		||||
            "CreatedNode": {
 | 
			
		||||
              "LedgerEntryType": "NFTokenOffer",
 | 
			
		||||
              "LedgerIndex": "1DEF39A07F364CB73BF5F8306BE22628D0AE517A2CB0AE5341269B1E671F2052",
 | 
			
		||||
              "NewFields": {
 | 
			
		||||
                "Amount": "100",
 | 
			
		||||
                "Expiration": 999999999,
 | 
			
		||||
                "Flags": 1,
 | 
			
		||||
                "Owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000"
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "Balance": "99999999999999892",
 | 
			
		||||
                "BurnedNFTokens": 1,
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "MintedNFTokens": 5,
 | 
			
		||||
                "OwnerCount": 2,
 | 
			
		||||
                "Sequence": 10
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "99999999999999904",
 | 
			
		||||
                "OwnerCount": 1,
 | 
			
		||||
                "Sequence": 9
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "D73C0ACEA1D4C9186A4AF1EAE2A4BD0A719A78AF6CE897C289AB297D371BEF53",
 | 
			
		||||
              "PreviousTxnLgrSeq": 6
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "CreatedNode": {
 | 
			
		||||
              "LedgerEntryType": "DirectoryNode",
 | 
			
		||||
              "LedgerIndex": "86992C19DA69763CAA9A4FC1697508140A995F15173EB00892C8EE23D5FD8FC3",
 | 
			
		||||
              "NewFields": {
 | 
			
		||||
                "Flags": 2,
 | 
			
		||||
                "RootIndex": "86992C19DA69763CAA9A4FC1697508140A995F15173EB00892C8EE23D5FD8FC3",
 | 
			
		||||
                "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000"
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "CreatedNode": {
 | 
			
		||||
              "LedgerEntryType": "DirectoryNode",
 | 
			
		||||
              "LedgerIndex": "D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204",
 | 
			
		||||
              "NewFields": {
 | 
			
		||||
                "Owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "RootIndex": "D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204"
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionIndex": 0,
 | 
			
		||||
        "TransactionResult": "tesSUCCESS"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "201C00000000F8E3110037561DEF39A07F364CB73BF5F8306BE22628D0AE517A2CB0AE5341269B1E671F2052E822000000012A3B9AC9FF5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B000000006140000000000000648214B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E5110061250000000655D73C0ACEA1D4C9186A4AF1EAE2A4BD0A719A78AF6CE897C289AB297D371BEF53562B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8E624000000092D0000000162416345785D89FFA0E1E72200000000240000000A2D00000002202B00000005202C0000000162416345785D89FF948114B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E31100645686992C19DA69763CAA9A4FC1697508140A995F15173EB00892C8EE23D5FD8FC3E822000000025886992C19DA69763CAA9A4FC1697508140A995F15173EB00892C8EE23D5FD8FC35A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000E1E1E311006456D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204E858D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA6352048214B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1F1031000"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "NFTokenCancelOffer": {
 | 
			
		||||
    "tx": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
        "Fee": "12",
 | 
			
		||||
        "Flags": 0,
 | 
			
		||||
        "LastLedgerSequence": 27,
 | 
			
		||||
        "Sequence": 10,
 | 
			
		||||
        "SigningPubKey": "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
 | 
			
		||||
        "NFTokenOffers": [
 | 
			
		||||
          "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000"
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionType": "NFTokenCancelOffer",
 | 
			
		||||
        "TxnSignature": "3044022075EAF267D19A626B3D970A96C363380FC7CCFB81178D75F723C5F097309B9FBC022027A896B759E882BFCB810C8AB5B3D819AEBFCAD6E0AF17F909BB3AFA9085EBEE"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "12001C2200000000240000000A201B0000001B68400000000000000C73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD02074463044022075EAF267D19A626B3D970A96C363380FC7CCFB81178D75F723C5F097309B9FBC022027A896B759E882BFCB810C8AB5B3D819AEBFCAD6E0AF17F909BB3AFA9085EBEE8114B5F762798A53D543A014CAF8B297CFF8F2F937E804132000090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000"
 | 
			
		||||
    },
 | 
			
		||||
    "meta": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "AffectedNodes": [
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "Balance": "99999999999999880",
 | 
			
		||||
                "BurnedNFTokens": 1,
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "MintedNFTokens": 5,
 | 
			
		||||
                "OwnerCount": 2,
 | 
			
		||||
                "Sequence": 11
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "99999999999999892",
 | 
			
		||||
                "Sequence": 10
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "4D43E602582E492DC685408C36B18CFB326FBC06C03DA46580F03356F91D590D",
 | 
			
		||||
              "PreviousTxnLgrSeq": 7
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionIndex": 0,
 | 
			
		||||
        "TransactionResult": "tesSUCCESS"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "201C00000000F8E51100612500000007554D43E602582E492DC685408C36B18CFB326FBC06C03DA46580F03356F91D590D562B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8E6240000000A62416345785D89FF94E1E72200000000240000000B2D00000002202B00000005202C0000000162416345785D89FF888114B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1F1031000"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "NFTokenAcceptOffer": {
 | 
			
		||||
    "tx": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "Account": "rKBmBAi3cWzuj6iZYx6K7F3xF1LSs3br3o",
 | 
			
		||||
        "Fee": "12",
 | 
			
		||||
        "Flags": 0,
 | 
			
		||||
        "LastLedgerSequence": 37,
 | 
			
		||||
        "NFTokenSellOffer": "AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AF",
 | 
			
		||||
        "Sequence": 9,
 | 
			
		||||
        "SigningPubKey": "ED3C94824B6696F16CA54F0E3085A5ED8867D19DC4BA572086E03DCAB30B094D79",
 | 
			
		||||
        "TransactionType": "NFTokenAcceptOffer",
 | 
			
		||||
        "TxnSignature": "D6653C5BDA53E29CFF05905BE4EA36A913D28D8730EAAB339FFC57D0484230349E195303A301490DDF5DC3BC01AD22047D9A0BBC37983D96ED06DBBFE43F9A08"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "12001D22000000002400000009201B00000025501DAED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AF68400000000000000C7321ED3C94824B6696F16CA54F0E3085A5ED8867D19DC4BA572086E03DCAB30B094D797440D6653C5BDA53E29CFF05905BE4EA36A913D28D8730EAAB339FFC57D0484230349E195303A301490DDF5DC3BC01AD22047D9A0BBC37983D96ED06DBBFE43F9A088114C77B4F8423139A8F0939DDEB9EB076CC74F4A3B3"
 | 
			
		||||
    },
 | 
			
		||||
    "meta": {
 | 
			
		||||
      "json": {
 | 
			
		||||
        "AffectedNodes": [
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "Balance": "99997999999999932",
 | 
			
		||||
                "BurnedNFTokens": 1,
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "MintedNFTokens": 5,
 | 
			
		||||
                "OwnerCount": 3,
 | 
			
		||||
                "Sequence": 15
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "99997999999999832",
 | 
			
		||||
                "OwnerCount": 4
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "BB2608749900A1762B2C7E60AFB437091F56810B39E85545E9541A5F33FD2785",
 | 
			
		||||
              "PreviousTxnLgrSeq": 16
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "DeletedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Flags": 2,
 | 
			
		||||
                "RootIndex": "45D3F54AACBCD7F8A5FB0737DA561BE9F0EA924276B2FDB0B8EA8D7FE4319632",
 | 
			
		||||
                "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003"
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "DirectoryNode",
 | 
			
		||||
              "LedgerIndex": "45D3F54AACBCD7F8A5FB0737DA561BE9F0EA924276B2FDB0B8EA8D7FE4319632"
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Account": "rKBmBAi3cWzuj6iZYx6K7F3xF1LSs3br3o",
 | 
			
		||||
                "Balance": "1999999999888",
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "OwnerCount": 1,
 | 
			
		||||
                "Sequence": 10
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "AccountRoot",
 | 
			
		||||
              "LedgerIndex": "4BDDA92DDF4C9702E2952261A181E7E1EFF37E9C2AC9D390D0E81AF34FC8A325",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "Balance": "2000000000000",
 | 
			
		||||
                "OwnerCount": 0,
 | 
			
		||||
                "Sequence": 9
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "2B07B79F67C41680E07ED8EDCA5BC20827F1694D51207EFD800F5174FE76ADB3",
 | 
			
		||||
              "PreviousTxnLgrSeq": 13
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "DeletedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Amount": "100",
 | 
			
		||||
                "Flags": 1,
 | 
			
		||||
                "NFTokenOfferNode": "0000000000000000",
 | 
			
		||||
                "Owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "OwnerNode": "0000000000000000",
 | 
			
		||||
                "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003"
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "NFTokenOffer",
 | 
			
		||||
              "LedgerIndex": "AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AF"
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "NFTokenPage",
 | 
			
		||||
              "LedgerIndex": "B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFF",
 | 
			
		||||
              "PreviousFields": {
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  },
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              },
 | 
			
		||||
              "PreviousTxnID": "EF14A0EB3B1E7E928A07F4B6A659EEA4FB0F839499397B224E19DE61CAA884C7",
 | 
			
		||||
              "PreviousTxnLgrSeq": 4
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "CreatedNode": {
 | 
			
		||||
              "LedgerEntryType": "NFTokenPage",
 | 
			
		||||
              "LedgerIndex": "C77B4F8423139A8F0939DDEB9EB076CC74F4A3B3FFFFFFFFFFFFFFFFFFFFFFFF",
 | 
			
		||||
              "NewFields": {
 | 
			
		||||
                "NFTokens": [
 | 
			
		||||
                  {
 | 
			
		||||
                    "NFToken": {
 | 
			
		||||
                      "NFTokenID": "00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003",
 | 
			
		||||
                      "URI": "68747470733A2F2F677265677765697362726F642E636F6D"
 | 
			
		||||
                    }
 | 
			
		||||
                  }
 | 
			
		||||
                ]
 | 
			
		||||
              }
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          {
 | 
			
		||||
            "ModifiedNode": {
 | 
			
		||||
              "FinalFields": {
 | 
			
		||||
                "Flags": 0,
 | 
			
		||||
                "Owner": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
 | 
			
		||||
                "RootIndex": "D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204"
 | 
			
		||||
              },
 | 
			
		||||
              "LedgerEntryType": "DirectoryNode",
 | 
			
		||||
              "LedgerIndex": "D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204"
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        ],
 | 
			
		||||
        "TransactionIndex": 0,
 | 
			
		||||
        "TransactionResult": "tesSUCCESS"
 | 
			
		||||
      },
 | 
			
		||||
      "binary": "201C00000000F8E5110061250000001055BB2608749900A1762B2C7E60AFB437091F56810B39E85545E9541A5F33FD2785562B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8E62D0000000462416343A6B43FDF58E1E72200000000240000000F2D00000003202B00000005202C0000000162416343A6B43FDFBC8114B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E41100645645D3F54AACBCD7F8A5FB0737DA561BE9F0EA924276B2FDB0B8EA8D7FE4319632E722000000025845D3F54AACBCD7F8A5FB0737DA561BE9F0EA924276B2FDB0B8EA8D7FE43196325A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003E1E1E5110061250000000D552B07B79F67C41680E07ED8EDCA5BC20827F1694D51207EFD800F5174FE76ADB3564BDDA92DDF4C9702E2952261A181E7E1EFF37E9C2AC9D390D0E81AF34FC8A325E624000000092D0000000062400001D1A94A2000E1E72200000000240000000A2D0000000162400001D1A94A1F908114C77B4F8423139A8F0939DDEB9EB076CC74F4A3B3E1E1E411003756AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AFE722000000013400000000000000003C00000000000000005A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E000000036140000000000000648214B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1E5110050250000000455EF14A0EB3B1E7E928A07F4B6A659EEA4FB0F839499397B224E19DE61CAA884C756B5F762798A53D543A014CAF8B297CFF8F2F937E8FFFFFFFFFFFFFFFFFFFFFFFFE6FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E72200000000FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E80000099B00000000751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E816E5DA9C00000001751868747470733A2F2F677265677765697362726F642E636F6DE1EC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E82DCBAB9D00000002751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E1E311005056C77B4F8423139A8F0939DDEB9EB076CC74F4A3B3FFFFFFFFFFFFFFFFFFFFFFFFE8FAEC5A00090032B5F762798A53D543A014CAF8B297CFF8F2F937E844B17C9E00000003751868747470733A2F2F677265677765697362726F642E636F6DE1F1E1E1E511006456D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA635204E7220000000058D8120FC732737A2CF2E9968FDF3797A43B457F2A81AA06D2653171A1EA6352048214B5F762798A53D543A014CAF8B297CFF8F2F937E8E1E1F1031000"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/remit-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/remit-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
"12005F22000000002403EDEB4A2E00000001201B03EE5D3150116F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B68400000000000000C732102F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE65474473045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB701A04DEADBEEF81147990EC5D1D8DF69E070A968D4B186986FDF06ED0831449FF0C73CA6AF9733DA805F76CA2C37776B7C46B806314757C4A9ED08284D61F3D8807280795F858BAB61DE05C220000000150156F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B7504DEADBEEFE1F05CE05B6140000000000003E8E1E05B61D4838D7EA4C68000000000000000000000000000555344000000000006B80F0F1D98AEDA846ED981F741C398FB2C4FD1E1F100136320AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE"
 | 
			
		||||
							
								
								
									
										39
									
								
								packages/xahau-binary-codec/test/fixtures/remit-tx.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								packages/xahau-binary-codec/test/fixtures/remit-tx.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
{
 | 
			
		||||
  "TransactionType": "Remit",
 | 
			
		||||
  "Account": "rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo",
 | 
			
		||||
  "Destination": "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
 | 
			
		||||
  "DestinationTag": 1,
 | 
			
		||||
  "Fee": "12",
 | 
			
		||||
  "Flags": 0,
 | 
			
		||||
  "LastLedgerSequence": 65953073,
 | 
			
		||||
  "Sequence": 65923914,
 | 
			
		||||
  "SigningPubKey": "02F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE654",
 | 
			
		||||
  "TxnSignature": "3045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB",
 | 
			
		||||
  "Amounts": [
 | 
			
		||||
    {
 | 
			
		||||
      "AmountEntry": {
 | 
			
		||||
        "Amount": "1000"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      "AmountEntry": {
 | 
			
		||||
        "Amount": {
 | 
			
		||||
          "currency": "USD",
 | 
			
		||||
          "issuer": "rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX",
 | 
			
		||||
          "value": "1"
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "MintURIToken": {
 | 
			
		||||
    "URI": "DEADBEEF",
 | 
			
		||||
    "Digest": "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
 | 
			
		||||
    "Flags": 1
 | 
			
		||||
  },
 | 
			
		||||
  "URITokenIDs": [
 | 
			
		||||
    "AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE"
 | 
			
		||||
  ],
 | 
			
		||||
  "InvoiceID": "6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B",
 | 
			
		||||
  "Blob": "DEADBEEF",
 | 
			
		||||
  "Inform": "rB5Ux4Lv2nRx6eeoAAsZmtctnBQ2LiACnk"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
"120068240000000026006D2E00684000000000000000730081140000000000000000000000000000000000000000E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655E1"
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report-meta-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report-meta-binary.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
"201C00000000F8E51100525661E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DCE6F05FE05F7121ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A698114A53F8465478D79DC0C764F0FB2B67AE92465FD5EE1E05F7121ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A2281142BF2A77E25382EC1DEF521D81D24BC0FDD35BC9BE1E05F7121ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF51748114C45147960400DB6B763110CBCE8D641E9365F24EE1E05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1E05F7121ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD3678114A4EF485B50A7D91DF45450A680FAC31C53367B2DE1E05F7121EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB340281144D854497B48F1A41EF04E09DB656A11AAD01A703E1E05F7121EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E811446550CBD2B655081662AE3159B0488DE27EC0592E1F1E1E72200000000F05EE05E7121ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860811478339DD5880A994A5CB6E56CB7ED13FEEF201928E1F1F05FE05F7121ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655811408BCFB092DEE1BF0F2662AECE4DCC62C4AECCB8AE1F1E1E1F1031000"
 | 
			
		||||
							
								
								
									
										89
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								packages/xahau-binary-codec/test/fixtures/unl-report.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
			
		||||
{
 | 
			
		||||
  "Account": "",
 | 
			
		||||
  "ActiveValidator": {
 | 
			
		||||
    "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
 | 
			
		||||
  },
 | 
			
		||||
  "Fee": "0",
 | 
			
		||||
  "LedgerSequence": 7155200,
 | 
			
		||||
  "Sequence": 0,
 | 
			
		||||
  "SigningPubKey": "",
 | 
			
		||||
  "TransactionType": "UNLReport",
 | 
			
		||||
  "hash": "0878863F758F74A5CBD35691CDAB625A3BCD35B21B440E20545C4757DDB0CA43",
 | 
			
		||||
  "meta": {
 | 
			
		||||
    "AffectedNodes": [
 | 
			
		||||
      {
 | 
			
		||||
        "ModifiedNode": {
 | 
			
		||||
          "FinalFields": {
 | 
			
		||||
            "ActiveValidators": [
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
 | 
			
		||||
                  "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            ],
 | 
			
		||||
            "Flags": 0,
 | 
			
		||||
            "ImportVLKeys": [
 | 
			
		||||
              {
 | 
			
		||||
                "ImportVLKey": {
 | 
			
		||||
                  "Account": "rBxZvQBY551DJ21g9AC1Qc9ASQowqcskbF",
 | 
			
		||||
                  "PublicKey": "ED264807102805220DA0F312E71FC2C69E1552C9C5790F6C25E3729DEB573D5860"
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            ]
 | 
			
		||||
          },
 | 
			
		||||
          "LedgerEntryType": "UNLReport",
 | 
			
		||||
          "LedgerIndex": "61E32E7A24A238F1C619D5F9DDCC41A94B33B66C0163F7EFCC8A19C9FD6F28DC",
 | 
			
		||||
          "PreviousFields": {
 | 
			
		||||
            "ActiveValidators": [
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "rGhk2uLd8ShzX2Zrcgn8sQk1LWBG4jjEwf",
 | 
			
		||||
                  "PublicKey": "ED3ABC6740983BFB13FFD9728EBCC365A2877877D368FC28990819522300C92A69"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "rnr4kwS1VkJhvjVRuq2fbWZtEdN2HbpVVu",
 | 
			
		||||
                  "PublicKey": "ED49F82B2FFD537F224A1E0A10DEEFC3C25CE3882979E6B327C9F18603D21F0A22"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "rJupFrPPYgUNFBdoSqhMEJ22hiHKiZSHXQ",
 | 
			
		||||
                  "PublicKey": "ED79EB0F6A9F01A039235E536D19F812B55ACF540C9E22CF62C271E0D42BFF5174"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "roUo3ygV92bdhfE1v9LGpPETXvJv2kQv5",
 | 
			
		||||
                  "PublicKey": "ED93B2BE467CAD2F9F56FB3A82BDFF17F84B09E34232DDE8FAF2FC72382F142655"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "rGsa7f4arJ8JE9ok9LCht6jCu5xBKUKVMq",
 | 
			
		||||
                  "PublicKey": "ED96F581FED430E8CBE1F08B37408857001D4118D49FBB594B0BE007C2DBFFD367"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "r3htgPchiR2r8kMGzPK3Wfv3WTrpaRKjtU",
 | 
			
		||||
                  "PublicKey": "EDCF31B8F683345E1C49B4A1D85BF2731E55E7D6781F3D4BF45EE7ADF2D2FB3402"
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
              {
 | 
			
		||||
                "ActiveValidator": {
 | 
			
		||||
                  "Account": "rfQtB8m51sdbWgcmddRX2mMjMpSxzX1AGr",
 | 
			
		||||
                  "PublicKey": "EDDF197FC59A7FAA09EB1AD60A4638BA6201DD51497B5C08A1745115098E229E0E"
 | 
			
		||||
                }
 | 
			
		||||
              }
 | 
			
		||||
            ]
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    ],
 | 
			
		||||
    "TransactionIndex": 0,
 | 
			
		||||
    "TransactionResult": "tesSUCCESS"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -240,4 +240,25 @@ describe('Signing data', function () {
 | 
			
		||||
      ].join(''),
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it('can create claim blob iou', function () {
 | 
			
		||||
    const channel =
 | 
			
		||||
      '43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1'
 | 
			
		||||
    const amount = {
 | 
			
		||||
      currency: 'USD',
 | 
			
		||||
      issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
 | 
			
		||||
      value: '1000',
 | 
			
		||||
    }
 | 
			
		||||
    const json = { channel, amount }
 | 
			
		||||
    const actual = encodeForSigningClaim(json)
 | 
			
		||||
    expect(actual).toBe(
 | 
			
		||||
      [
 | 
			
		||||
        // hash prefix
 | 
			
		||||
        '434C4D00',
 | 
			
		||||
        // channel ID
 | 
			
		||||
        '43904CBFCDCEC530B4037871F86EE90BF799DF8D2E0EA564BC8A3F332E4F5FB1',
 | 
			
		||||
        // amount as a iou
 | 
			
		||||
        'D5438D7EA4C6800000000000000000000000000055534400000000005B812C9D57731E27A2DA8B1830195F88EF32A3B6',
 | 
			
		||||
      ].join(''),
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -656,7 +656,6 @@ class Client extends EventEmitter<EventTypes> {
 | 
			
		||||
   * @throws ValidationError If Amount and DeliverMax fields are not identical in a Payment Transaction
 | 
			
		||||
   */
 | 
			
		||||
 | 
			
		||||
  // eslint-disable-next-line complexity -- handling Payment transaction API v2 requires more logic
 | 
			
		||||
  public async autofill<T extends SubmittableTransaction>(
 | 
			
		||||
    transaction: T,
 | 
			
		||||
    signersCount?: number,
 | 
			
		||||
@@ -673,42 +672,17 @@ class Client extends EventEmitter<EventTypes> {
 | 
			
		||||
    if (tx.Sequence == null) {
 | 
			
		||||
      promises.push(setNextValidSequenceNumber(this, tx))
 | 
			
		||||
    }
 | 
			
		||||
    if (tx.Fee == null) {
 | 
			
		||||
      promises.push(calculateFeePerTransactionType(this, tx, signersCount))
 | 
			
		||||
    }
 | 
			
		||||
    if (tx.LastLedgerSequence == null) {
 | 
			
		||||
      promises.push(setLatestValidatedLedgerSequence(this, tx))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
 | 
			
		||||
    // @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
 | 
			
		||||
    if (tx.TransactionType === 'Payment' && tx.DeliverMax != null) {
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
 | 
			
		||||
      if (tx.Amount == null) {
 | 
			
		||||
        // If only DeliverMax is provided, use it to populate the Amount field
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
 | 
			
		||||
        // @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- DeliverMax is a known RPC-level property
 | 
			
		||||
        tx.Amount = tx.DeliverMax
 | 
			
		||||
      }
 | 
			
		||||
    await Promise.all(promises).then(() => tx)
 | 
			
		||||
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
 | 
			
		||||
      // @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- This is a valid null check for Amount
 | 
			
		||||
      if (tx.Amount != null && tx.Amount !== tx.DeliverMax) {
 | 
			
		||||
        return Promise.reject(
 | 
			
		||||
          new ValidationError(
 | 
			
		||||
            'PaymentTransaction: Amount and DeliverMax fields must be identical when both are provided',
 | 
			
		||||
          ),
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- ignore type-assertions on the DeliverMax property
 | 
			
		||||
      // @ts-expect-error -- DeliverMax property exists only at the RPC level, not at the protocol level
 | 
			
		||||
      delete tx.DeliverMax
 | 
			
		||||
    if (tx.Fee == null) {
 | 
			
		||||
      await calculateFeePerTransactionType(this, tx, signersCount)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return Promise.all(promises).then(() => tx)
 | 
			
		||||
    return tx
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,7 @@ function accountTxHasPartialPayment<
 | 
			
		||||
>(response: AccountTxVersionResponseMap<Version>): boolean {
 | 
			
		||||
  const { transactions } = response.result
 | 
			
		||||
  const foo = transactions.some((tx) => {
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- xahau does not support v2
 | 
			
		||||
    if (tx.tx_json != null) {
 | 
			
		||||
      const transaction = tx
 | 
			
		||||
      return isPartialPayment(transaction.tx_json, transaction.meta)
 | 
			
		||||
@@ -158,6 +159,7 @@ export function handleStreamPartialPayment(
 | 
			
		||||
  stream: TransactionStream | TransactionV1Stream,
 | 
			
		||||
  log: (id: string, message: string) => void,
 | 
			
		||||
): void {
 | 
			
		||||
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- xahau does not support v2
 | 
			
		||||
  if (isPartialPayment(stream.tx_json ?? stream.transaction, stream.meta)) {
 | 
			
		||||
    const warnings = stream.warnings ?? []
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										113
									
								
								packages/xahau/src/models/common/xahau.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								packages/xahau/src/models/common/xahau.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
import { Amount } from '.'
 | 
			
		||||
 | 
			
		||||
export interface AmountEntry {
 | 
			
		||||
  AmountEntry: { Amount: Amount }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The object that describes the grant in HookGrants.
 | 
			
		||||
 */
 | 
			
		||||
export interface HookGrant {
 | 
			
		||||
  /**
 | 
			
		||||
   * The object that describes the grant in HookGrants.
 | 
			
		||||
   */
 | 
			
		||||
  HookGrant: {
 | 
			
		||||
    /**
 | 
			
		||||
     * The hook hash of the grant.
 | 
			
		||||
     */
 | 
			
		||||
    HookHash: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The account authorized on the grant.
 | 
			
		||||
     */
 | 
			
		||||
    Authorize?: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The object that describes the parameter in HookParameters.
 | 
			
		||||
 */
 | 
			
		||||
export interface HookParameter {
 | 
			
		||||
  /**
 | 
			
		||||
   * The object that describes the parameter in HookParameters.
 | 
			
		||||
   */
 | 
			
		||||
  HookParameter: {
 | 
			
		||||
    /**
 | 
			
		||||
     * The name of the parameter.
 | 
			
		||||
     */
 | 
			
		||||
    HookParameterName: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The value of the parameter.
 | 
			
		||||
     */
 | 
			
		||||
    HookParameterValue?: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The object that describes the hook in Hooks.
 | 
			
		||||
 */
 | 
			
		||||
export interface Hook {
 | 
			
		||||
  /**
 | 
			
		||||
   * The object that describes the hook in Hooks.
 | 
			
		||||
   */
 | 
			
		||||
  Hook: {
 | 
			
		||||
    HookHash?: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The code that is executed when the hook is triggered.
 | 
			
		||||
     */
 | 
			
		||||
    CreateCode?: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The flags that are set on the hook.
 | 
			
		||||
     */
 | 
			
		||||
    Flags?: number
 | 
			
		||||
    /**
 | 
			
		||||
     * The transactions that triggers the hook. Represented as a 256Hash
 | 
			
		||||
     */
 | 
			
		||||
    HookOn?: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The namespace of the hook.
 | 
			
		||||
     */
 | 
			
		||||
    HookNamespace?: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The API version of the hook.
 | 
			
		||||
     */
 | 
			
		||||
    HookApiVersion?: number
 | 
			
		||||
    /**
 | 
			
		||||
     * The parameters of the hook.
 | 
			
		||||
     */
 | 
			
		||||
    HookParameters?: HookParameter[]
 | 
			
		||||
    /**
 | 
			
		||||
     * The grants of the hook.
 | 
			
		||||
     */
 | 
			
		||||
    HookGrants?: HookGrant[]
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * This information is added to emitted Transactions.
 | 
			
		||||
 */
 | 
			
		||||
export interface EmitDetails {
 | 
			
		||||
  EmitBurden: number
 | 
			
		||||
  EmitGeneration: number
 | 
			
		||||
  EmitHookHash: string
 | 
			
		||||
  EmitParentTxnID: string
 | 
			
		||||
  sfEmitNonce: string
 | 
			
		||||
  sfEmitCallback?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The object that describes the uritoken in MintURIToken.
 | 
			
		||||
 */
 | 
			
		||||
export interface MintURIToken {
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  URI: string
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  Digest?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The flags that are set on the uritoken.
 | 
			
		||||
   */
 | 
			
		||||
  Flags?: number
 | 
			
		||||
}
 | 
			
		||||
@@ -28,12 +28,6 @@ export default interface AccountRoot extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
   * `asfAccountTxnID` flag enabled.
 | 
			
		||||
   */
 | 
			
		||||
  AccountTxnID?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The ledger entry ID of the corresponding AMM ledger entry.
 | 
			
		||||
   * Set during account creation; cannot be modified.
 | 
			
		||||
   * If present, indicates that this is a special AMM AccountRoot; always omitted on non-AMM accounts.
 | 
			
		||||
   */
 | 
			
		||||
  AMMID?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * A domain associated with this account. In JSON, this is the hexadecimal
 | 
			
		||||
   * for the ASCII representation of the domain.
 | 
			
		||||
@@ -78,6 +72,17 @@ export default interface AccountRoot extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  MintedNFTokens?: number
 | 
			
		||||
  /** Another account that can mint NFTokens on behalf of this account. */
 | 
			
		||||
  NFTokenMinter?: string
 | 
			
		||||
  HookStateCount?: number
 | 
			
		||||
  HookNamespaces?: string[]
 | 
			
		||||
  RewardLgrFirst?: number
 | 
			
		||||
  RewardLgrLast?: number
 | 
			
		||||
  RewardTime?: number
 | 
			
		||||
  RewardAccumulator?: number
 | 
			
		||||
  FirstNFTokenSequence?: number
 | 
			
		||||
  ImportSequence?: string
 | 
			
		||||
  GovernanceFlags?: string
 | 
			
		||||
  GovernanceMarks?: string
 | 
			
		||||
  AccountIndex?: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -143,9 +148,9 @@ export interface AccountRootFlagsInterface {
 | 
			
		||||
   */
 | 
			
		||||
  lsfDisallowIncomingTrustline?: boolean
 | 
			
		||||
  /**
 | 
			
		||||
   * This address can claw back issued IOUs. Once enabled, cannot be disabled.
 | 
			
		||||
   * Disallow incoming Remit from other accounts.
 | 
			
		||||
   */
 | 
			
		||||
  lsfAllowTrustLineClawback?: boolean
 | 
			
		||||
  lsfDisallowIncomingRemit?: boolean
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export enum AccountRootFlags {
 | 
			
		||||
@@ -186,10 +191,6 @@ export enum AccountRootFlags {
 | 
			
		||||
   * (It has DepositAuth enabled.)
 | 
			
		||||
   */
 | 
			
		||||
  lsfDepositAuth = 0x01000000,
 | 
			
		||||
  /**
 | 
			
		||||
   * This account is an Automated Market Maker (AMM) instance.
 | 
			
		||||
   */
 | 
			
		||||
  lsfAMM = 0x02000000,
 | 
			
		||||
  /**
 | 
			
		||||
   * Disallow incoming NFTOffers from other accounts.
 | 
			
		||||
   */
 | 
			
		||||
@@ -207,7 +208,11 @@ export enum AccountRootFlags {
 | 
			
		||||
   */
 | 
			
		||||
  lsfDisallowIncomingTrustline = 0x20000000,
 | 
			
		||||
  /**
 | 
			
		||||
   * This address can claw back issued IOUs. Once enabled, cannot be disabled.
 | 
			
		||||
   * The account has issued a URIToken.
 | 
			
		||||
   */
 | 
			
		||||
  lsfAllowTrustLineClawback = 0x80000000,
 | 
			
		||||
  lsfURITokenIssuer = 0x40000000,
 | 
			
		||||
  /**
 | 
			
		||||
   * Disallow incoming Remits from other accounts.
 | 
			
		||||
   */
 | 
			
		||||
  lsfDisallowIncomingRemit = 0x80000000,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								packages/xahau/src/models/ledger/EmittedTxn.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								packages/xahau/src/models/ledger/EmittedTxn.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
import { Transaction } from '../transactions'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The EmittedTxn object type contains the
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface EmittedTxn extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'EmittedTxn'
 | 
			
		||||
 | 
			
		||||
  EmittedTxn: Transaction
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * A hint indicating which page of the sender's owner directory links to this
 | 
			
		||||
   * object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  OwnerNode: string
 | 
			
		||||
}
 | 
			
		||||
@@ -1,7 +1,9 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Escrow object type represents a held payment of XAH waiting to be
 | 
			
		||||
 * The Escrow object type represents a held payment waiting to be
 | 
			
		||||
 * executed or canceled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
@@ -10,17 +12,17 @@ export default interface Escrow extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'Escrow'
 | 
			
		||||
  /**
 | 
			
		||||
   * The address of the owner (sender) of this held payment. This is the
 | 
			
		||||
   * account that provided the XAH, and gets it back if the held payment is
 | 
			
		||||
   * account that provided the amounts, and gets it back if the held payment is
 | 
			
		||||
   * canceled.
 | 
			
		||||
   */
 | 
			
		||||
  Account: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The destination address where the XAH is paid if the held payment is
 | 
			
		||||
   * The destination address where the amounts are paid if the held payment is
 | 
			
		||||
   * successful.
 | 
			
		||||
   */
 | 
			
		||||
  Destination: string
 | 
			
		||||
  /** The amount of XAH, in drops, to be delivered by the held payment. */
 | 
			
		||||
  Amount: string
 | 
			
		||||
  /** The amount to be delivered by the held payment. */
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * A PREIMAGE-SHA-256 crypto-condition, as hexadecimal. If present, the
 | 
			
		||||
   * EscrowFinish transaction must contain a fulfillment that satisfies this
 | 
			
		||||
@@ -61,4 +63,9 @@ export default interface Escrow extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
   * this object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  DestinationNode?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The fee to charge when users finish an escrow, initially set on the
 | 
			
		||||
   * creation of an escrow contract, and updated on subsequent finish transactions
 | 
			
		||||
   */
 | 
			
		||||
  TransferRate?: number
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,8 @@ export interface FeeSettingsBase
 | 
			
		||||
   * A bit-map of boolean flags for this object. No flags are defined for this type.
 | 
			
		||||
   */
 | 
			
		||||
  Flags: 0
 | 
			
		||||
  XahauActivationLgrSeq?: number
 | 
			
		||||
  AccountCount?: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								packages/xahau/src/models/ledger/Hook.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								packages/xahau/src/models/ledger/Hook.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
import { Hook as HookWrapper } from '../common/xahau'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The Hook object type contains the
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface Hook extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'Hook'
 | 
			
		||||
 | 
			
		||||
  /** The identifying (classic) address of this account. */
 | 
			
		||||
  Account: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * A hint indicating which page of the sender's owner directory links to this
 | 
			
		||||
   * object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  OwnerNode: string
 | 
			
		||||
 | 
			
		||||
  PreviousTxnID: string
 | 
			
		||||
 | 
			
		||||
  PreviousTxnLgrSeq: number
 | 
			
		||||
 | 
			
		||||
  Hooks: HookWrapper[]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										69
									
								
								packages/xahau/src/models/ledger/HookDefinition.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								packages/xahau/src/models/ledger/HookDefinition.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
import { HookParameter } from '../common/xahau'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The HookDefintion object type contains the
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface HookDefintion
 | 
			
		||||
  extends BaseLedgerEntry,
 | 
			
		||||
    HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'HookDefintion'
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The flags that are set on the hook.
 | 
			
		||||
   */
 | 
			
		||||
  Flags: number
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * This field contains a string that is used to uniquely identify the hook.
 | 
			
		||||
   */
 | 
			
		||||
  HookHash: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The transactions that triggers the hook. Represented as a 256Hash
 | 
			
		||||
   */
 | 
			
		||||
  HookOn?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The namespace of the hook.
 | 
			
		||||
   */
 | 
			
		||||
  HookNamespace?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The API version of the hook.
 | 
			
		||||
   */
 | 
			
		||||
  HookApiVersion?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The parameters of the hook.
 | 
			
		||||
   */
 | 
			
		||||
  HookParameters?: HookParameter[]
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The code that is executed when the hook is triggered.
 | 
			
		||||
   */
 | 
			
		||||
  CreateCode?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * This is an optional field that contains the transaction ID of the hook set.
 | 
			
		||||
   */
 | 
			
		||||
  HookSetTxnID?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * This is an optional field that contains the number of references to this hook.
 | 
			
		||||
   */
 | 
			
		||||
  ReferenceCount?: number
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * This is an optional field that contains the fee associated with the hook.
 | 
			
		||||
   */
 | 
			
		||||
  Fee?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * This is an optional field that contains the callback fee associated with the hook.
 | 
			
		||||
   */
 | 
			
		||||
  HookCallbackFee?: number
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								packages/xahau/src/models/ledger/HookState.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								packages/xahau/src/models/ledger/HookState.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The HookState object type contains the
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface HookState extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'HookState'
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * A hint indicating which page of the sender's owner directory links to this
 | 
			
		||||
   * object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  OwnerNode: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The HookStateKey property contains the key associated with this hook state,
 | 
			
		||||
   * and the HookStateData property contains the data associated with this hook state.
 | 
			
		||||
   */
 | 
			
		||||
  HookStateKey: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The `HookStateData` property contains the data associated with this hook state.
 | 
			
		||||
   * It is typically a string containing the data associated with this hook state,
 | 
			
		||||
   * such as an identifier or other information.
 | 
			
		||||
   */
 | 
			
		||||
  HookStateData: string
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								packages/xahau/src/models/ledger/ImportVLSequence.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								packages/xahau/src/models/ledger/ImportVLSequence.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface ImportVLSequence
 | 
			
		||||
  extends BaseLedgerEntry,
 | 
			
		||||
    HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'ImportVLSequence'
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  PublicKey: string
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  ImportSequence: string
 | 
			
		||||
}
 | 
			
		||||
@@ -3,8 +3,13 @@ import Amendments from './Amendments'
 | 
			
		||||
import Check from './Check'
 | 
			
		||||
import DepositPreauth from './DepositPreauth'
 | 
			
		||||
import DirectoryNode from './DirectoryNode'
 | 
			
		||||
import EmittedTxn from './EmittedTxn'
 | 
			
		||||
import Escrow from './Escrow'
 | 
			
		||||
import FeeSettings from './FeeSettings'
 | 
			
		||||
import Hook from './Hook'
 | 
			
		||||
import HookDefinition from './HookDefinition'
 | 
			
		||||
import HookState from './HookState'
 | 
			
		||||
import ImportVLSequence from './ImportVLSequence'
 | 
			
		||||
import LedgerHashes from './LedgerHashes'
 | 
			
		||||
import NegativeUNL from './NegativeUNL'
 | 
			
		||||
import Offer from './Offer'
 | 
			
		||||
@@ -12,6 +17,8 @@ import PayChannel from './PayChannel'
 | 
			
		||||
import RippleState from './RippleState'
 | 
			
		||||
import SignerList from './SignerList'
 | 
			
		||||
import Ticket from './Ticket'
 | 
			
		||||
import UNLReport from './UNLReport'
 | 
			
		||||
import URIToken from './URIToken'
 | 
			
		||||
 | 
			
		||||
type LedgerEntry =
 | 
			
		||||
  | AccountRoot
 | 
			
		||||
@@ -19,8 +26,13 @@ type LedgerEntry =
 | 
			
		||||
  | Check
 | 
			
		||||
  | DepositPreauth
 | 
			
		||||
  | DirectoryNode
 | 
			
		||||
  | EmittedTxn
 | 
			
		||||
  | Escrow
 | 
			
		||||
  | FeeSettings
 | 
			
		||||
  | Hook
 | 
			
		||||
  | HookDefinition
 | 
			
		||||
  | HookState
 | 
			
		||||
  | ImportVLSequence
 | 
			
		||||
  | LedgerHashes
 | 
			
		||||
  | NegativeUNL
 | 
			
		||||
  | Offer
 | 
			
		||||
@@ -28,6 +40,8 @@ type LedgerEntry =
 | 
			
		||||
  | RippleState
 | 
			
		||||
  | SignerList
 | 
			
		||||
  | Ticket
 | 
			
		||||
  | UNLReport
 | 
			
		||||
  | URIToken
 | 
			
		||||
 | 
			
		||||
type LedgerEntryFilter =
 | 
			
		||||
  | 'account'
 | 
			
		||||
@@ -37,11 +51,17 @@ type LedgerEntryFilter =
 | 
			
		||||
  | 'directory'
 | 
			
		||||
  | 'escrow'
 | 
			
		||||
  | 'fee'
 | 
			
		||||
  | 'hook'
 | 
			
		||||
  | 'hook_state'
 | 
			
		||||
  | 'hook_definition'
 | 
			
		||||
  | 'import_vl_sequence'
 | 
			
		||||
  | 'hashes'
 | 
			
		||||
  | 'offer'
 | 
			
		||||
  | 'payment_channel'
 | 
			
		||||
  | 'signer_list'
 | 
			
		||||
  | 'state'
 | 
			
		||||
  | 'ticket'
 | 
			
		||||
  | 'unl_report'
 | 
			
		||||
  | 'uri_token'
 | 
			
		||||
 | 
			
		||||
export { LedgerEntry, LedgerEntryFilter }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
export interface NFTokenOffer extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'NFTokenOffer'
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  Destination?: string
 | 
			
		||||
  Expiration: number
 | 
			
		||||
  Flags: number
 | 
			
		||||
  NFTokenOfferNode?: string
 | 
			
		||||
  Owner: string
 | 
			
		||||
  OwnerNode?: string
 | 
			
		||||
}
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
export interface NFToken {
 | 
			
		||||
  NFToken: {
 | 
			
		||||
    Flags: number
 | 
			
		||||
    Issuer: string
 | 
			
		||||
    NFTokenID: string
 | 
			
		||||
    NFTokenTaxon: number
 | 
			
		||||
    URI?: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface NFTokenPage extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'NFTokenPage'
 | 
			
		||||
  NextPageMin?: string
 | 
			
		||||
  NFTokens: NFToken[]
 | 
			
		||||
  PreviousPageMin?: string
 | 
			
		||||
}
 | 
			
		||||
@@ -1,9 +1,11 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The PayChannel object type represents a payment channel. Payment channels
 | 
			
		||||
 * enable small, rapid off-ledger payments of XAH that can be later reconciled
 | 
			
		||||
 * with the consensus ledger. A payment channel holds a balance of XAH that can
 | 
			
		||||
 * enable small, rapid off-ledger payments that can be later reconciled
 | 
			
		||||
 * with the consensus ledger. A payment channel holds a balance that can
 | 
			
		||||
 * only be paid out to a specific destination address until the channel is
 | 
			
		||||
 * closed.
 | 
			
		||||
 *
 | 
			
		||||
@@ -18,37 +20,37 @@ export default interface PayChannel extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  Account: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The destination address for this payment channel. While the payment
 | 
			
		||||
   * channel is open, this address is the only one that can receive XAH from the
 | 
			
		||||
   * channel is open, this address is the only one that can receive amounts from the
 | 
			
		||||
   * channel. This comes from the Destination field of the transaction that
 | 
			
		||||
   * created the channel.
 | 
			
		||||
   */
 | 
			
		||||
  Destination: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Total XAH, in drops, that has been allocated to this channel. This
 | 
			
		||||
   * includes XAH that has been paid to the destination address. This is
 | 
			
		||||
   * initially set by the transaction that created the channel and can be
 | 
			
		||||
   * increased if the source address sends a PaymentChannelFund transaction.
 | 
			
		||||
   * Total amount that has been allocated to this channel. This includes amounts
 | 
			
		||||
   * that have been paid to the destination address. This is initially set by the
 | 
			
		||||
   * transaction that created the channel and can be increased if the source
 | 
			
		||||
   * address sends a PaymentChannelFund transaction.
 | 
			
		||||
   */
 | 
			
		||||
  Amount: string
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * Total XAH, in drops, already paid out by the channel. The difference
 | 
			
		||||
   * between this value and the Amount field is how much XAH can still be paid
 | 
			
		||||
   * to the destination address with PaymentChannelClaim transactions. If the
 | 
			
		||||
   * channel closes, the remaining difference is returned to the source address.
 | 
			
		||||
   * Total amount already paid out by the channel. The difference between this value
 | 
			
		||||
   * and the Amount field is how much can still be paid to the destination address
 | 
			
		||||
   * with PaymentChannelClaim transactions. If the channel closes, the remaining
 | 
			
		||||
   * difference is returned to the source address.
 | 
			
		||||
   */
 | 
			
		||||
  Balance: string
 | 
			
		||||
  Balance: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * Public key, in hexadecimal, of the key pair that can be used to sign
 | 
			
		||||
   * claims against this channel. This can be any valid secp256k1 or Ed25519
 | 
			
		||||
   * public key. This is set by the transaction that created the channel and
 | 
			
		||||
   * must match the public key used in claims against the channel. The channel
 | 
			
		||||
   * source address can also send XAH from this channel to the destination
 | 
			
		||||
   * source address can also send amounts from this channel to the destination
 | 
			
		||||
   * without signed claims.
 | 
			
		||||
   */
 | 
			
		||||
  PublicKey: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Number of seconds the source address must wait to close the channel if
 | 
			
		||||
   * it still has any XAH in it. Smaller values mean that the destination
 | 
			
		||||
   * it still has any amount in it. Smaller values mean that the destination
 | 
			
		||||
   * address has less time to redeem any outstanding claims after the source
 | 
			
		||||
   * address requests to close the channel. Can be any value that fits in a
 | 
			
		||||
   * 32-bit unsigned integer (0 to 2^32-1). This is set by the transaction that
 | 
			
		||||
@@ -94,4 +96,10 @@ export default interface PayChannel extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
   * this object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  DestinationNode?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The fee to charge when users make claims on a payment channel, initially
 | 
			
		||||
   * set on the creation of a payment channel and updated on subsequent funding
 | 
			
		||||
   * or claim transactions.
 | 
			
		||||
   */
 | 
			
		||||
  TransferRate?: number
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								packages/xahau/src/models/ledger/UNLReport.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								packages/xahau/src/models/ledger/UNLReport.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
interface ImportVLKey {
 | 
			
		||||
  ImportVLKey: {
 | 
			
		||||
    PublicKey: string
 | 
			
		||||
    Account?: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
interface ActiveValidator {
 | 
			
		||||
  ActiveValidator: {
 | 
			
		||||
    PublicKey: string
 | 
			
		||||
    Account?: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface UNLReport extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'UNLReport'
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  ImportVLKeys?: ImportVLKey[]
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  ActiveValidators?: ActiveValidator[]
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										42
									
								
								packages/xahau/src/models/ledger/URIToken.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								packages/xahau/src/models/ledger/URIToken.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,42 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseLedgerEntry, HasPreviousTxnID } from './BaseLedgerEntry'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The URIToken object type contains the
 | 
			
		||||
 *
 | 
			
		||||
 * @category Ledger Entries
 | 
			
		||||
 */
 | 
			
		||||
export default interface URIToken extends BaseLedgerEntry, HasPreviousTxnID {
 | 
			
		||||
  LedgerEntryType: 'URIToken'
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  Owner: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * A hint indicating which page of the sender's owner directory links to this
 | 
			
		||||
   * object, in case the directory consists of multiple pages.
 | 
			
		||||
   */
 | 
			
		||||
  OwnerNode: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  Issuer: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  URI: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  Digest: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  Destination: string
 | 
			
		||||
}
 | 
			
		||||
@@ -6,23 +6,28 @@ import Amendments, { Majority, AMENDMENTS_ID } from './Amendments'
 | 
			
		||||
import Check from './Check'
 | 
			
		||||
import DepositPreauth from './DepositPreauth'
 | 
			
		||||
import DirectoryNode from './DirectoryNode'
 | 
			
		||||
import EmittedTxn from './EmittedTxn'
 | 
			
		||||
import Escrow from './Escrow'
 | 
			
		||||
import FeeSettings, {
 | 
			
		||||
  FeeSettingsPreAmendmentFields,
 | 
			
		||||
  FeeSettingsPostAmendmentFields,
 | 
			
		||||
  FEE_SETTINGS_ID,
 | 
			
		||||
} from './FeeSettings'
 | 
			
		||||
import Hook from './Hook'
 | 
			
		||||
import HookDefinition from './HookDefinition'
 | 
			
		||||
import HookState from './HookState'
 | 
			
		||||
import ImportVLSequence from './ImportVLSequence'
 | 
			
		||||
import { Ledger, LedgerV1 } from './Ledger'
 | 
			
		||||
import { LedgerEntry, LedgerEntryFilter } from './LedgerEntry'
 | 
			
		||||
import LedgerHashes from './LedgerHashes'
 | 
			
		||||
import NegativeUNL, { NEGATIVE_UNL_ID } from './NegativeUNL'
 | 
			
		||||
import { NFTokenOffer } from './NFTokenOffer'
 | 
			
		||||
import { NFToken, NFTokenPage } from './NFTokenPage'
 | 
			
		||||
import Offer, { OfferFlags } from './Offer'
 | 
			
		||||
import PayChannel from './PayChannel'
 | 
			
		||||
import RippleState, { RippleStateFlags } from './RippleState'
 | 
			
		||||
import SignerList, { SignerListFlags } from './SignerList'
 | 
			
		||||
import Ticket from './Ticket'
 | 
			
		||||
import UNLReport from './UNLReport'
 | 
			
		||||
import URIToken from './URIToken'
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
  AccountRoot,
 | 
			
		||||
@@ -33,11 +38,16 @@ export {
 | 
			
		||||
  Check,
 | 
			
		||||
  DepositPreauth,
 | 
			
		||||
  DirectoryNode,
 | 
			
		||||
  EmittedTxn,
 | 
			
		||||
  Escrow,
 | 
			
		||||
  FEE_SETTINGS_ID,
 | 
			
		||||
  FeeSettings,
 | 
			
		||||
  FeeSettingsPreAmendmentFields,
 | 
			
		||||
  FeeSettingsPostAmendmentFields,
 | 
			
		||||
  Hook,
 | 
			
		||||
  HookDefinition,
 | 
			
		||||
  HookState,
 | 
			
		||||
  ImportVLSequence,
 | 
			
		||||
  Ledger,
 | 
			
		||||
  LedgerV1,
 | 
			
		||||
  LedgerEntryFilter,
 | 
			
		||||
@@ -46,9 +56,6 @@ export {
 | 
			
		||||
  Majority,
 | 
			
		||||
  NEGATIVE_UNL_ID,
 | 
			
		||||
  NegativeUNL,
 | 
			
		||||
  NFTokenOffer,
 | 
			
		||||
  NFTokenPage,
 | 
			
		||||
  NFToken,
 | 
			
		||||
  Offer,
 | 
			
		||||
  OfferFlags,
 | 
			
		||||
  PayChannel,
 | 
			
		||||
@@ -57,4 +64,6 @@ export {
 | 
			
		||||
  SignerList,
 | 
			
		||||
  SignerListFlags,
 | 
			
		||||
  Ticket,
 | 
			
		||||
  UNLReport,
 | 
			
		||||
  URIToken,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -8,7 +10,7 @@ export interface Channel {
 | 
			
		||||
  account: string
 | 
			
		||||
 | 
			
		||||
  /** The total amount of XAH, in drops allocated to this channel. */
 | 
			
		||||
  amount: string
 | 
			
		||||
  amount: Amount
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The total amount of XAH, in drops, paid out from this channel,
 | 
			
		||||
@@ -76,6 +78,8 @@ export interface Channel {
 | 
			
		||||
   * or other purpose at the destination account.
 | 
			
		||||
   */
 | 
			
		||||
  destination_tag?: number
 | 
			
		||||
 | 
			
		||||
  transfer_rate?: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
 | 
			
		||||
 | 
			
		||||
export interface AccountLinesTrustline {
 | 
			
		||||
@@ -62,6 +64,14 @@ export interface AccountLinesTrustline {
 | 
			
		||||
   * false.
 | 
			
		||||
   */
 | 
			
		||||
  freeze_peer?: boolean
 | 
			
		||||
  /**
 | 
			
		||||
   * The total amount of IOU, in drops/Amount locked in payment channels or escrow.
 | 
			
		||||
   */
 | 
			
		||||
  locked_balance?: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * The total number of lock balances on a RippleState ledger object.
 | 
			
		||||
   */
 | 
			
		||||
  lock_count?: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										48
									
								
								packages/xahau/src/models/methods/accountNamespace.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								packages/xahau/src/models/methods/accountNamespace.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
import { HookState } from '../ledger'
 | 
			
		||||
 | 
			
		||||
import { BaseRequest, BaseResponse } from './baseMethod'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The `account_namespace` command retrieves the account namespace. All information retrieved is relative to a
 | 
			
		||||
 * particular version of the ledger. Returns an {@link AccountNamespaceResponse}.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Requests
 | 
			
		||||
 */
 | 
			
		||||
export interface AccountNamespaceRequest extends BaseRequest {
 | 
			
		||||
  command: 'account_namespace'
 | 
			
		||||
  /** A unique identifier for the account, most commonly the account's address. */
 | 
			
		||||
  account: string
 | 
			
		||||
  /** The hex namespace. */
 | 
			
		||||
  namespace_id?: string
 | 
			
		||||
  /** The limit that was used in this request, if any. */
 | 
			
		||||
  limit?: number
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Response expected from an {@link AccountNamespaceRequest}.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Responses
 | 
			
		||||
 */
 | 
			
		||||
export interface AccountNamespaceResponse extends BaseResponse {
 | 
			
		||||
  result: {
 | 
			
		||||
    /**
 | 
			
		||||
     * The account requested.
 | 
			
		||||
     */
 | 
			
		||||
    account: string
 | 
			
		||||
    /**
 | 
			
		||||
     * The namespace_id requested.
 | 
			
		||||
     */
 | 
			
		||||
    namespace_id: string
 | 
			
		||||
    /**
 | 
			
		||||
     * A list of HookStates for the specified account namespace_id.
 | 
			
		||||
     */
 | 
			
		||||
    namespace_entries: HookState[]
 | 
			
		||||
    /**
 | 
			
		||||
     * The ledger index of the current open ledger, which was used when
 | 
			
		||||
     * retrieving this information.
 | 
			
		||||
     */
 | 
			
		||||
    ledger_current_index: number
 | 
			
		||||
    /** If true, this data comes from a validated ledger. */
 | 
			
		||||
    validated: boolean
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,11 +1,25 @@
 | 
			
		||||
import { Amendments, FeeSettings, LedgerHashes } from '../ledger'
 | 
			
		||||
import {
 | 
			
		||||
  Amendments,
 | 
			
		||||
  FeeSettings,
 | 
			
		||||
  HookDefinition,
 | 
			
		||||
  HookState,
 | 
			
		||||
  ImportVLSequence,
 | 
			
		||||
  LedgerHashes,
 | 
			
		||||
  UNLReport,
 | 
			
		||||
} from '../ledger'
 | 
			
		||||
import { LedgerEntry, LedgerEntryFilter } from '../ledger/LedgerEntry'
 | 
			
		||||
 | 
			
		||||
import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
 | 
			
		||||
 | 
			
		||||
export type AccountObjectType = Exclude<
 | 
			
		||||
  LedgerEntryFilter,
 | 
			
		||||
  'amendments' | 'fee' | 'hashes'
 | 
			
		||||
  | 'amendments'
 | 
			
		||||
  | 'fee'
 | 
			
		||||
  | 'hashes'
 | 
			
		||||
  | 'hook_definition'
 | 
			
		||||
  | 'hook_state'
 | 
			
		||||
  | 'import_vl_sequence'
 | 
			
		||||
  | 'unl_report'
 | 
			
		||||
>
 | 
			
		||||
/**
 | 
			
		||||
 * The account_objects command returns the raw ledger format for all objects
 | 
			
		||||
@@ -48,7 +62,13 @@ export interface AccountObjectsRequest
 | 
			
		||||
 */
 | 
			
		||||
export type AccountObject = Exclude<
 | 
			
		||||
  LedgerEntry,
 | 
			
		||||
  Amendments | FeeSettings | LedgerHashes
 | 
			
		||||
  | Amendments
 | 
			
		||||
  | FeeSettings
 | 
			
		||||
  | LedgerHashes
 | 
			
		||||
  | HookDefinition
 | 
			
		||||
  | HookState
 | 
			
		||||
  | ImportVLSequence
 | 
			
		||||
  | UNLReport
 | 
			
		||||
>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -2,17 +2,17 @@ import { BaseRequest, BaseResponse } from './baseMethod'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * The `channel_verify` method checks the validity of a signature that can be
 | 
			
		||||
 * used to redeem a specific amount of XAH from a payment channel. Expects a
 | 
			
		||||
 * used to redeem a specific amount from a payment channel. Expects a
 | 
			
		||||
 * response in the form of a {@link ChannelVerifyResponse}.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Requests
 | 
			
		||||
 */
 | 
			
		||||
export interface ChannelVerifyRequest extends BaseRequest {
 | 
			
		||||
  command: 'channel_verify'
 | 
			
		||||
  /** The amount of XAH, in drops, the provided signature authorizes. */
 | 
			
		||||
  /** The amount the provided signature authorizes. */
 | 
			
		||||
  amount: string
 | 
			
		||||
  /**
 | 
			
		||||
   * The Channel ID of the channel that provides the XAH. This is a
 | 
			
		||||
   * The Channel ID of the channel that provides the amount. This is a
 | 
			
		||||
   * 64-character hexadecimal string.
 | 
			
		||||
   */
 | 
			
		||||
  channel_id: string
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ import { BaseRequest, BaseResponse } from './baseMethod'
 | 
			
		||||
 */
 | 
			
		||||
export interface FeeRequest extends BaseRequest {
 | 
			
		||||
  command: 'fee'
 | 
			
		||||
  tx_blob?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -35,6 +36,11 @@ export interface FeeResponse extends BaseResponse {
 | 
			
		||||
       * included in a ledger under minimum load, represented in drops of XAH.
 | 
			
		||||
       */
 | 
			
		||||
      base_fee: string
 | 
			
		||||
      /**
 | 
			
		||||
       * The transaction cost required for a reference transaction to be
 | 
			
		||||
       * included in a ledger under minimum load, represented in drops of XAH.
 | 
			
		||||
       */
 | 
			
		||||
      base_fee_no_hooks: string
 | 
			
		||||
      /**
 | 
			
		||||
       * An approximation of the median transaction cost among transactions.
 | 
			
		||||
       * Included in the previous validated ledger, represented in drops of XAH.
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,10 @@ import {
 | 
			
		||||
  AccountLinesResponse,
 | 
			
		||||
  AccountLinesTrustline,
 | 
			
		||||
} from './accountLines'
 | 
			
		||||
import {
 | 
			
		||||
  AccountNamespaceRequest,
 | 
			
		||||
  AccountNamespaceResponse,
 | 
			
		||||
} from './accountNamespace'
 | 
			
		||||
import {
 | 
			
		||||
  AccountObject,
 | 
			
		||||
  AccountObjectsRequest,
 | 
			
		||||
@@ -171,6 +175,7 @@ type Request =
 | 
			
		||||
  | AccountCurrenciesRequest
 | 
			
		||||
  | AccountInfoRequest
 | 
			
		||||
  | AccountLinesRequest
 | 
			
		||||
  | AccountNamespaceRequest
 | 
			
		||||
  | AccountObjectsRequest
 | 
			
		||||
  | AccountOffersRequest
 | 
			
		||||
  | AccountTxRequest
 | 
			
		||||
@@ -217,6 +222,7 @@ type Response<Version extends APIVersion = typeof DEFAULT_API_VERSION> =
 | 
			
		||||
  | AccountCurrenciesResponse
 | 
			
		||||
  | AccountInfoVersionResponseMap<Version>
 | 
			
		||||
  | AccountLinesResponse
 | 
			
		||||
  | AccountNamespaceResponse
 | 
			
		||||
  | AccountObjectsResponse
 | 
			
		||||
  | AccountOffersResponse
 | 
			
		||||
  | AccountTxVersionResponseMap<Version>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,3 @@
 | 
			
		||||
import { Currency, XChainBridge } from '../common'
 | 
			
		||||
import { LedgerEntry } from '../ledger'
 | 
			
		||||
 | 
			
		||||
import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
 | 
			
		||||
@@ -21,20 +20,6 @@ import { BaseRequest, BaseResponse, LookupByLedgerRequest } from './baseMethod'
 | 
			
		||||
 */
 | 
			
		||||
export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
 | 
			
		||||
  command: 'ledger_entry'
 | 
			
		||||
  /**
 | 
			
		||||
   * Retrieve an Automated Market Maker (AMM) object from the ledger.
 | 
			
		||||
   * This is similar to amm_info method, but the ledger_entry version returns only the ledger entry as stored.
 | 
			
		||||
   */
 | 
			
		||||
  amm?: {
 | 
			
		||||
    asset: {
 | 
			
		||||
      currency: string
 | 
			
		||||
      issuer?: string
 | 
			
		||||
    }
 | 
			
		||||
    asset2: {
 | 
			
		||||
      currency: string
 | 
			
		||||
      issuer?: string
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /**
 | 
			
		||||
   * (Optional) If set to true and the queried object has been deleted,
 | 
			
		||||
   * return its complete data prior to its deletion.
 | 
			
		||||
@@ -81,12 +66,6 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Specify a DID object to retrieve. If a string, must be the
 | 
			
		||||
   * object ID of the DID object, as hexadecimal, or the account ID.
 | 
			
		||||
   */
 | 
			
		||||
  did?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The DirectoryNode to retrieve. If a string, must be the object ID of the
 | 
			
		||||
   * directory, as hexadecimal. If an object, requires either `dir_root` o
 | 
			
		||||
@@ -103,6 +82,11 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The object ID of a transaction emitted by the ledger entry.
 | 
			
		||||
   */
 | 
			
		||||
  emitted_txn?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The Escrow object to retrieve. If a string, must be the object ID of the
 | 
			
		||||
   * escrow, as hexadecimal. If an object, requires owner and seq sub-fields.
 | 
			
		||||
@@ -116,6 +100,47 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The hash of the Hook object to retrieve.
 | 
			
		||||
   */
 | 
			
		||||
  hook_definition?: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The Hook object to retrieve. If a string, must be the object ID of the Hook.
 | 
			
		||||
   * If an object, requires `account` sub-field.
 | 
			
		||||
   */
 | 
			
		||||
  hook?:
 | 
			
		||||
    | {
 | 
			
		||||
        /** The account of the Hook object. */
 | 
			
		||||
        account: string
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Object specifying the HookState object to retrieve. Requires the sub-fields
 | 
			
		||||
   * `account`, `key`, and `namespace_id` to uniquely specify the HookState entry
 | 
			
		||||
   * to retrieve.
 | 
			
		||||
   */
 | 
			
		||||
  hook_state?: {
 | 
			
		||||
    /** The account of the Hook object. */
 | 
			
		||||
    account: string
 | 
			
		||||
    /** The key of the state. */
 | 
			
		||||
    key: string
 | 
			
		||||
    /** The namespace of the state. */
 | 
			
		||||
    namespace_id: string
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The Import VL Sequence object to retrieve. If a string, must be the object ID of the VLSequence.
 | 
			
		||||
   * If an object, requires `public_key` sub-field.
 | 
			
		||||
   */
 | 
			
		||||
  import_vlseq?:
 | 
			
		||||
    | {
 | 
			
		||||
        /** The public_key of the Import VL Sequence object. */
 | 
			
		||||
        public_key: string
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * The Offer object to retrieve. If a string, interpret as the unique object
 | 
			
		||||
   * ID to the Offer. If an object, requires the sub-fields `account` and `seq`
 | 
			
		||||
@@ -163,31 +188,16 @@ export interface LedgerEntryRequest extends BaseRequest, LookupByLedgerRequest {
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Must be the object ID of the NFToken page, as hexadecimal
 | 
			
		||||
   * The URIToken object to retrieve. If a string, must be the object ID of the
 | 
			
		||||
   * URIToken, as hexadecimal. If an object, the `issuer` and `uri`
 | 
			
		||||
   * sub-fields are required to uniquely specify the URIToken entry.
 | 
			
		||||
   */
 | 
			
		||||
  nft_page?: string
 | 
			
		||||
 | 
			
		||||
  bridge_account?: string
 | 
			
		||||
 | 
			
		||||
  bridge?: XChainBridge
 | 
			
		||||
 | 
			
		||||
  xchain_owned_claim_id?:
 | 
			
		||||
  uri_token?:
 | 
			
		||||
    | {
 | 
			
		||||
        locking_chain_door: string
 | 
			
		||||
        locking_chain_issue: Currency
 | 
			
		||||
        issuing_chain_door: string
 | 
			
		||||
        issuing_chain_issue: Currency
 | 
			
		||||
        xchain_owned_claim_id: string | number
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
 | 
			
		||||
  xchain_owned_create_account_claim_id?:
 | 
			
		||||
    | {
 | 
			
		||||
        locking_chain_door: string
 | 
			
		||||
        locking_chain_issue: Currency
 | 
			
		||||
        issuing_chain_door: string
 | 
			
		||||
        issuing_chain_issue: Currency
 | 
			
		||||
        xchain_owned_create_account_claim_id: string | number
 | 
			
		||||
        /** The issuer of the URIToken object. */
 | 
			
		||||
        issuer: string
 | 
			
		||||
        /** The URIToken uri string (ascii). */
 | 
			
		||||
        uri: string
 | 
			
		||||
      }
 | 
			
		||||
    | string
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,7 @@ export enum AccountSetAsfFlags {
 | 
			
		||||
   */
 | 
			
		||||
  asfAuthorizedNFTokenMinter = 10,
 | 
			
		||||
  /** asf 11 is reserved for Hooks amendment */
 | 
			
		||||
  asfTshCollect = 11,
 | 
			
		||||
  /** Disallow other accounts from creating incoming NFTOffers */
 | 
			
		||||
  asfDisallowIncomingNFTokenOffer = 12,
 | 
			
		||||
  /** Disallow other accounts from creating incoming Checks */
 | 
			
		||||
@@ -58,8 +59,8 @@ export enum AccountSetAsfFlags {
 | 
			
		||||
  asfDisallowIncomingPayChan = 14,
 | 
			
		||||
  /** Disallow other accounts from creating incoming Trustlines */
 | 
			
		||||
  asfDisallowIncomingTrustline = 15,
 | 
			
		||||
  /** Permanently gain the ability to claw back issued IOUs */
 | 
			
		||||
  asfAllowTrustLineClawback = 16,
 | 
			
		||||
  /** Disallow other accounts from sending incoming Remits */
 | 
			
		||||
  asfDisallowIncomingRemit = 16,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										46
									
								
								packages/xahau/src/models/transactions/claimReward.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								packages/xahau/src/models/transactions/claimReward.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
/**
 | 
			
		||||
 * Transaction Flags for an ClaimReward Transaction.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 */
 | 
			
		||||
export enum ClaimRewardFlags {
 | 
			
		||||
  /**
 | 
			
		||||
   * If set, indicates that the user would like to opt out of rewards.
 | 
			
		||||
   */
 | 
			
		||||
  tfOptOut = 0x00000001,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClaimReward is a transaction model that allows an account to claim rewards.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface ClaimReward extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'ClaimReward'
 | 
			
		||||
  Flags?: number | ClaimRewardFlags
 | 
			
		||||
  /** The unique address of the issuer where the reward.c hook is installed. */
 | 
			
		||||
  Issuer?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an ClaimReward at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An ClaimReward Transaction.
 | 
			
		||||
 * @throws When the ClaimReward is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateClaimReward(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Issuer !== undefined && typeof tx.Issuer !== 'string') {
 | 
			
		||||
    throw new ValidationError('ClaimReward: Issuer must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Account === tx.Issuer) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'ClaimReward: Account and Issuer cannot be the same',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,14 +2,8 @@ import { isValidClassicAddress, isValidXAddress } from 'xahau-address-codec'
 | 
			
		||||
import { TRANSACTION_TYPES } from 'xahau-binary-codec'
 | 
			
		||||
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import {
 | 
			
		||||
  Amount,
 | 
			
		||||
  Currency,
 | 
			
		||||
  IssuedCurrencyAmount,
 | 
			
		||||
  Memo,
 | 
			
		||||
  Signer,
 | 
			
		||||
  XChainBridge,
 | 
			
		||||
} from '../common'
 | 
			
		||||
import { Amount, Currency, IssuedCurrencyAmount, Memo, Signer } from '../common'
 | 
			
		||||
import { EmitDetails, HookParameter } from '../common/xahau'
 | 
			
		||||
import { onlyHasFields } from '../utils'
 | 
			
		||||
 | 
			
		||||
const MEMO_SIZE = 3
 | 
			
		||||
@@ -58,7 +52,6 @@ function isSigner(obj: unknown): boolean {
 | 
			
		||||
const XAH_CURRENCY_SIZE = 1
 | 
			
		||||
const ISSUE_SIZE = 2
 | 
			
		||||
const ISSUED_CURRENCY_SIZE = 3
 | 
			
		||||
const XCHAIN_BRIDGE_SIZE = 4
 | 
			
		||||
 | 
			
		||||
function isRecord(value: unknown): value is Record<string, unknown> {
 | 
			
		||||
  return value !== null && typeof value === 'object'
 | 
			
		||||
@@ -147,23 +140,6 @@ export function isAmount(amount: unknown): amount is Amount {
 | 
			
		||||
  return typeof amount === 'string' || isIssuedCurrency(amount)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an XChainBridge at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param input - The input to check the form and type of.
 | 
			
		||||
 * @returns Whether the XChainBridge is properly formed.
 | 
			
		||||
 */
 | 
			
		||||
export function isXChainBridge(input: unknown): input is XChainBridge {
 | 
			
		||||
  return (
 | 
			
		||||
    isRecord(input) &&
 | 
			
		||||
    Object.keys(input).length === XCHAIN_BRIDGE_SIZE &&
 | 
			
		||||
    typeof input.LockingChainDoor === 'string' &&
 | 
			
		||||
    isCurrency(input.LockingChainIssue) &&
 | 
			
		||||
    typeof input.IssuingChainDoor === 'string' &&
 | 
			
		||||
    isCurrency(input.IssuingChainIssue)
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* eslint-disable @typescript-eslint/restrict-template-expressions -- tx.TransactionType is checked before any calls */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -291,6 +267,18 @@ export interface BaseTransaction {
 | 
			
		||||
   * The network id of the transaction.
 | 
			
		||||
   */
 | 
			
		||||
  NetworkID?: number
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  FirstLedgerSequence?: number
 | 
			
		||||
  /**
 | 
			
		||||
   * The hook parameters of the transaction.
 | 
			
		||||
   */
 | 
			
		||||
  HookParameters?: HookParameter[]
 | 
			
		||||
  /**
 | 
			
		||||
   * The hook parameters of the transaction.
 | 
			
		||||
   */
 | 
			
		||||
  EmitDetails?: EmitDetails
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ import {
 | 
			
		||||
} from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Return escrowed XAH to the sender.
 | 
			
		||||
 * Return escrowed amount to the sender.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
@@ -22,6 +22,11 @@ export interface EscrowCancel extends BaseTransaction {
 | 
			
		||||
   * created the escrow to cancel.
 | 
			
		||||
   */
 | 
			
		||||
  OfferSequence: number | string
 | 
			
		||||
  /**
 | 
			
		||||
   * The ID of the Escrow ledger object to cancel as a 64-character hexadecimal
 | 
			
		||||
   * string.
 | 
			
		||||
   */
 | 
			
		||||
  EscrowID?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -35,15 +40,17 @@ export function validateEscrowCancel(tx: Record<string, unknown>): void {
 | 
			
		||||
 | 
			
		||||
  validateRequiredField(tx, 'Owner', isAccount)
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferSequence == null) {
 | 
			
		||||
    throw new ValidationError('EscrowCancel: missing OfferSequence')
 | 
			
		||||
  if (tx.OfferSequence === undefined && tx.EscrowID === undefined) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'EscrowCancel: must include OfferSequence or EscrowID',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (
 | 
			
		||||
    (typeof tx.OfferSequence !== 'number' &&
 | 
			
		||||
      typeof tx.OfferSequence !== 'string') ||
 | 
			
		||||
    Number.isNaN(Number(tx.OfferSequence))
 | 
			
		||||
  ) {
 | 
			
		||||
  if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
 | 
			
		||||
    throw new ValidationError('EscrowCancel: OfferSequence must be a number')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.EscrowID !== undefined && typeof tx.EscrowID !== 'string') {
 | 
			
		||||
    throw new ValidationError('EscrowCancel: EscrowID must be a string')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,11 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  Account,
 | 
			
		||||
  BaseTransaction,
 | 
			
		||||
  isAccount,
 | 
			
		||||
  isAmount,
 | 
			
		||||
  isNumber,
 | 
			
		||||
  validateBaseTransaction,
 | 
			
		||||
  validateOptionalField,
 | 
			
		||||
@@ -11,19 +13,19 @@ import {
 | 
			
		||||
} from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Sequester XAH until the escrow process either finishes or is canceled.
 | 
			
		||||
 * Sequester amount until the escrow process either finishes or is canceled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface EscrowCreate extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'EscrowCreate'
 | 
			
		||||
  /**
 | 
			
		||||
   * Amount of XAH, in drops, to deduct from the sender's balance and escrow.
 | 
			
		||||
   * Once escrowed, the XAH can either go to the Destination address (after the.
 | 
			
		||||
   * FinishAfter time) or returned to the sender (after the CancelAfter time).
 | 
			
		||||
   * Amount to deduct from the sender's balance and escrow. Once escrowed, the
 | 
			
		||||
   * amount can either go to the Destination address (after the FinishAfter time)
 | 
			
		||||
   * or returned to the sender (after the CancelAfter time).
 | 
			
		||||
   */
 | 
			
		||||
  Amount: string
 | 
			
		||||
  /** Address to receive escrowed XAH. */
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /** Address to receive escrowed amount. */
 | 
			
		||||
  Destination: Account
 | 
			
		||||
  /**
 | 
			
		||||
   * The time, in seconds since the Ripple Epoch, when this escrow expires.
 | 
			
		||||
@@ -32,7 +34,7 @@ export interface EscrowCreate extends BaseTransaction {
 | 
			
		||||
   */
 | 
			
		||||
  CancelAfter?: number
 | 
			
		||||
  /**
 | 
			
		||||
   * The time, in seconds since the Ripple Epoch, when the escrowed XAH can be
 | 
			
		||||
   * The time, in seconds since the Ripple Epoch, when the escrowed amount can be
 | 
			
		||||
   * released to the recipient. This value is immutable; the funds cannot move.
 | 
			
		||||
   * until this time is reached.
 | 
			
		||||
   */
 | 
			
		||||
@@ -62,8 +64,8 @@ export function validateEscrowCreate(tx: Record<string, unknown>): void {
 | 
			
		||||
    throw new ValidationError('EscrowCreate: missing field Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.Amount !== 'string') {
 | 
			
		||||
    throw new ValidationError('EscrowCreate: Amount must be a string')
 | 
			
		||||
  if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('EscrowCreate: Amount must be an Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  validateRequiredField(tx, 'Destination', isAccount)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@ import {
 | 
			
		||||
} from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Deliver XAH from a held payment to the recipient.
 | 
			
		||||
 * Deliver amount from a held payment to the recipient.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
@@ -22,6 +22,11 @@ export interface EscrowFinish extends BaseTransaction {
 | 
			
		||||
   * payment to finish.
 | 
			
		||||
   */
 | 
			
		||||
  OfferSequence: number | string
 | 
			
		||||
  /**
 | 
			
		||||
   * The ID of the Escrow ledger object to cancel as a 64-character hexadecimal
 | 
			
		||||
   * string.
 | 
			
		||||
   */
 | 
			
		||||
  EscrowID?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Hex value matching the previously-supplied PREIMAGE-SHA-256.
 | 
			
		||||
   * crypto-condition of the held payment.
 | 
			
		||||
@@ -45,18 +50,20 @@ export function validateEscrowFinish(tx: Record<string, unknown>): void {
 | 
			
		||||
 | 
			
		||||
  validateRequiredField(tx, 'Owner', isAccount)
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferSequence == null) {
 | 
			
		||||
    throw new ValidationError('EscrowFinish: missing field OfferSequence')
 | 
			
		||||
  if (tx.OfferSequence === undefined && tx.EscrowID === undefined) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'EscrowFinish: must include OfferSequence or EscrowID',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (
 | 
			
		||||
    (typeof tx.OfferSequence !== 'number' &&
 | 
			
		||||
      typeof tx.OfferSequence !== 'string') ||
 | 
			
		||||
    Number.isNaN(Number(tx.OfferSequence))
 | 
			
		||||
  ) {
 | 
			
		||||
  if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
 | 
			
		||||
    throw new ValidationError('EscrowFinish: OfferSequence must be a number')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.EscrowID !== undefined && typeof tx.EscrowID !== 'string') {
 | 
			
		||||
    throw new ValidationError('EscrowFinish: EscrowID must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Condition !== undefined && typeof tx.Condition !== 'string') {
 | 
			
		||||
    throw new ValidationError('EscrowFinish: Condition must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										55
									
								
								packages/xahau/src/models/transactions/import.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								packages/xahau/src/models/transactions/import.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { isHex } from '../utils'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
const MAX_BLOB_LENGTH = 512
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface Import extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'Import'
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  Issuer?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Hex value representing a VL Blob.
 | 
			
		||||
   */
 | 
			
		||||
  Blob?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an Import at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An Import Transaction.
 | 
			
		||||
 * @throws When the Import is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateImport(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Issuer !== undefined && typeof tx.Issuer !== 'string') {
 | 
			
		||||
    throw new ValidationError('Import: Issuer must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Account === tx.Issuer) {
 | 
			
		||||
    throw new ValidationError('Import: Issuer and Account must not be equal')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.Blob !== 'string') {
 | 
			
		||||
    throw new ValidationError('Import: Blob must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.Blob === 'string' && !isHex(tx.Blob)) {
 | 
			
		||||
    throw new ValidationError('Import: Blob must be in hex format')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Blob.length > MAX_BLOB_LENGTH) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      `Import: Blob must be less than ${MAX_BLOB_LENGTH} characters`,
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -16,10 +16,13 @@ export {
 | 
			
		||||
export { CheckCancel } from './checkCancel'
 | 
			
		||||
export { CheckCash } from './checkCash'
 | 
			
		||||
export { CheckCreate } from './checkCreate'
 | 
			
		||||
export { ClaimReward, ClaimRewardFlags } from './claimReward'
 | 
			
		||||
export { DepositPreauth } from './depositPreauth'
 | 
			
		||||
export { EscrowCancel } from './escrowCancel'
 | 
			
		||||
export { EscrowCreate } from './escrowCreate'
 | 
			
		||||
export { EscrowFinish } from './escrowFinish'
 | 
			
		||||
export { Import } from './import'
 | 
			
		||||
export { Invoke } from './invoke'
 | 
			
		||||
export { EnableAmendment, EnableAmendmentFlags } from './enableAmendment'
 | 
			
		||||
export { OfferCancel } from './offerCancel'
 | 
			
		||||
export {
 | 
			
		||||
@@ -35,9 +38,20 @@ export {
 | 
			
		||||
} from './paymentChannelClaim'
 | 
			
		||||
export { PaymentChannelCreate } from './paymentChannelCreate'
 | 
			
		||||
export { PaymentChannelFund } from './paymentChannelFund'
 | 
			
		||||
export { Remit } from './remit'
 | 
			
		||||
export { SetHookFlagsInterface, SetHookFlags, SetHook } from './setHook'
 | 
			
		||||
export { SetFee, SetFeePreAmendment, SetFeePostAmendment } from './setFee'
 | 
			
		||||
export { SetRegularKey } from './setRegularKey'
 | 
			
		||||
export { SignerListSet } from './signerListSet'
 | 
			
		||||
export { TicketCreate } from './ticketCreate'
 | 
			
		||||
export { TrustSetFlagsInterface, TrustSetFlags, TrustSet } from './trustSet'
 | 
			
		||||
export {
 | 
			
		||||
  URITokenMintFlagsInterface,
 | 
			
		||||
  URITokenMintFlags,
 | 
			
		||||
  URITokenMint,
 | 
			
		||||
} from './uriTokenMint'
 | 
			
		||||
export { URITokenBurn } from './uriTokenBurn'
 | 
			
		||||
export { URITokenCreateSellOffer } from './uriTokenCreateSellOffer'
 | 
			
		||||
export { URITokenBuy } from './uriTokenBuy'
 | 
			
		||||
export { URITokenCancelSellOffer } from './uriTokenCancelSellOffer'
 | 
			
		||||
export { UNLModify } from './UNLModify'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								packages/xahau/src/models/transactions/invoke.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								packages/xahau/src/models/transactions/invoke.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface Invoke extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'Invoke'
 | 
			
		||||
  /**
 | 
			
		||||
   * If present, invokes the Hook on the Destination account.
 | 
			
		||||
   */
 | 
			
		||||
  Destination?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Hex value representing a VL Blob.
 | 
			
		||||
   */
 | 
			
		||||
  Blob?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an Invoke at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An Invoke Transaction.
 | 
			
		||||
 * @throws When the Invoke is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateInvoke(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Account === tx.Destination) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'Invoke: Destination and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -4,6 +4,30 @@ import { BaseTransaction } from './common'
 | 
			
		||||
import { Payment, PaymentMetadata } from './payment'
 | 
			
		||||
import type { Transaction } from './transaction'
 | 
			
		||||
 | 
			
		||||
export interface HookExecution {
 | 
			
		||||
  HookExecution: {
 | 
			
		||||
    HookAccount: string
 | 
			
		||||
    HookEmitCount: number
 | 
			
		||||
    HookExecutionIndex: number
 | 
			
		||||
    HookHash: string
 | 
			
		||||
    HookInstructionCount: string
 | 
			
		||||
    HookResult: number
 | 
			
		||||
    HookReturnCode: string
 | 
			
		||||
    HookReturnString: string
 | 
			
		||||
    HookStateChangeCount: number
 | 
			
		||||
    Flags: number
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface HookEmission {
 | 
			
		||||
  HookEmission: {
 | 
			
		||||
    EmittedTxnID: string
 | 
			
		||||
    HookAccount: string
 | 
			
		||||
    HookHash: string
 | 
			
		||||
    EmitNonce: string
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface CreatedNode {
 | 
			
		||||
  CreatedNode: {
 | 
			
		||||
    LedgerEntryType: string
 | 
			
		||||
@@ -65,6 +89,8 @@ export function isDeletedNode(node: Node): node is DeletedNode {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface TransactionMetadataBase {
 | 
			
		||||
  HookExecutions?: HookExecution[]
 | 
			
		||||
  HookEmissions?: HookEmission[]
 | 
			
		||||
  AffectedNodes: Node[]
 | 
			
		||||
  DeliveredAmount?: Amount
 | 
			
		||||
  // "unavailable" possible for transactions before 2014-01-20
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,11 @@ export interface OfferCancel extends BaseTransaction {
 | 
			
		||||
   * specified does not exist.
 | 
			
		||||
   */
 | 
			
		||||
  OfferSequence: number
 | 
			
		||||
  /**
 | 
			
		||||
   * The ID of the Escrow ledger object to cancel as a 64-character hexadecimal
 | 
			
		||||
   * string.
 | 
			
		||||
   */
 | 
			
		||||
  OfferID?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -27,11 +32,17 @@ export interface OfferCancel extends BaseTransaction {
 | 
			
		||||
export function validateOfferCancel(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferSequence === undefined) {
 | 
			
		||||
    throw new ValidationError('OfferCancel: missing field OfferSequence')
 | 
			
		||||
  if (tx.OfferSequence === undefined && tx.OfferID === undefined) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'OfferCancel: must include OfferSequence or OfferID',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.OfferSequence !== 'number') {
 | 
			
		||||
  if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
 | 
			
		||||
    throw new ValidationError('OfferCancel: OfferSequence must be a number')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferID !== undefined && typeof tx.OfferID !== 'string') {
 | 
			
		||||
    throw new ValidationError('OfferCancel: OfferID must be a string')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -102,6 +102,11 @@ export interface OfferCreate extends BaseTransaction {
 | 
			
		||||
  Expiration?: number
 | 
			
		||||
  /** An offer to delete first, specified in the same way as OfferCancel. */
 | 
			
		||||
  OfferSequence?: number
 | 
			
		||||
  /**
 | 
			
		||||
   * The ID of the Offer ledger object to cancel as a 64-character hexadecimal
 | 
			
		||||
   * string.
 | 
			
		||||
   */
 | 
			
		||||
  OfferID?: string
 | 
			
		||||
  /** The amount and type of currency being provided by the offer creator. */
 | 
			
		||||
  TakerGets: Amount
 | 
			
		||||
  /** The amount and type of currency being requested by the offer creator. */
 | 
			
		||||
@@ -138,6 +143,10 @@ export function validateOfferCreate(tx: Record<string, unknown>): void {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
 | 
			
		||||
    throw new ValidationError('OfferCreate: invalid OfferSequence')
 | 
			
		||||
    throw new ValidationError('OfferCreate: OfferSequence must be a number')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.OfferID !== undefined && typeof tx.OfferID !== 'string') {
 | 
			
		||||
    throw new ValidationError('OfferCreate: OfferID must be a string')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,12 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
 | 
			
		||||
import {
 | 
			
		||||
  BaseTransaction,
 | 
			
		||||
  GlobalFlags,
 | 
			
		||||
  isAmount,
 | 
			
		||||
  validateBaseTransaction,
 | 
			
		||||
} from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enum representing values for PaymentChannelClaim transaction flags.
 | 
			
		||||
@@ -17,15 +23,15 @@ export enum PaymentChannelClaimFlags {
 | 
			
		||||
  /**
 | 
			
		||||
   * Request to close the channel. Only the channel source and destination
 | 
			
		||||
   * addresses can use this flag. This flag closes the channel immediately if it
 | 
			
		||||
   * has no more XAH allocated to it after processing the current claim, or if
 | 
			
		||||
   * has no more funds allocated to it after processing the current claim, or if
 | 
			
		||||
   * the destination address uses it. If the source address uses this flag when
 | 
			
		||||
   * the channel still holds XAH, this schedules the channel to close after
 | 
			
		||||
   * the channel still holds an amount, this schedules the channel to close after
 | 
			
		||||
   * SettleDelay seconds have passed. (Specifically, this sets the Expiration of
 | 
			
		||||
   * the channel to the close time of the previous ledger plus the channel's
 | 
			
		||||
   * SettleDelay time, unless the channel already has an earlier Expiration
 | 
			
		||||
   * time.) If the destination address uses this flag when the channel still
 | 
			
		||||
   * holds XAH, any XAH that remains after processing the claim is returned to
 | 
			
		||||
   * the source address.
 | 
			
		||||
   * holds an amount, any amount that remains after processing the claim is
 | 
			
		||||
   * returned to the source address.
 | 
			
		||||
   */
 | 
			
		||||
  tfClose = 0x00020000,
 | 
			
		||||
}
 | 
			
		||||
@@ -77,21 +83,21 @@ export interface PaymentChannelClaimFlagsInterface extends GlobalFlags {
 | 
			
		||||
  /**
 | 
			
		||||
   * Request to close the channel. Only the channel source and destination
 | 
			
		||||
   * addresses can use this flag. This flag closes the channel immediately if it
 | 
			
		||||
   * has no more XAH allocated to it after processing the current claim, or if
 | 
			
		||||
   * has no more funds allocated to it after processing the current claim, or if
 | 
			
		||||
   * the destination address uses it. If the source address uses this flag when
 | 
			
		||||
   * the channel still holds XAH, this schedules the channel to close after
 | 
			
		||||
   * the channel still holds an amount, this schedules the channel to close after
 | 
			
		||||
   * SettleDelay seconds have passed. (Specifically, this sets the Expiration of
 | 
			
		||||
   * the channel to the close time of the previous ledger plus the channel's
 | 
			
		||||
   * SettleDelay time, unless the channel already has an earlier Expiration
 | 
			
		||||
   * time.) If the destination address uses this flag when the channel still
 | 
			
		||||
   * holds XAH, any XAH that remains after processing the claim is returned to
 | 
			
		||||
   * the source address.
 | 
			
		||||
   * holds an amount, any amount that remains after processing the claim is
 | 
			
		||||
   * returned to the source address.
 | 
			
		||||
   */
 | 
			
		||||
  tfClose?: boolean
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Claim XAH from a payment channel, adjust the payment channel's expiration,
 | 
			
		||||
 * Claim amount from a payment channel, adjust the payment channel's expiration,
 | 
			
		||||
 * or both.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
@@ -102,18 +108,18 @@ export interface PaymentChannelClaim extends BaseTransaction {
 | 
			
		||||
  /** The unique ID of the channel as a 64-character hexadecimal string. */
 | 
			
		||||
  Channel: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Total amount of XAH, in drops, delivered by this channel after processing
 | 
			
		||||
   * this claim. Required to deliver XAH. Must be more than the total amount
 | 
			
		||||
   * delivered by the channel so far, but not greater than the Amount of the
 | 
			
		||||
   * signed claim. Must be provided except when closing the channel.
 | 
			
		||||
   * Total amount delivered by this channel after processing this claim. Required
 | 
			
		||||
   * to deliver amount. Must be more than the total amount delivered by the channel
 | 
			
		||||
   * so far, but not greater than the Amount of the signed claim. Must be provided
 | 
			
		||||
   * except when closing the channel.
 | 
			
		||||
   */
 | 
			
		||||
  Balance?: string
 | 
			
		||||
  Balance?: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * The amount of XAH, in drops, authorized by the Signature. This must match
 | 
			
		||||
   * the amount in the signed message. This is the cumulative amount of XAH that
 | 
			
		||||
   * can be dispensed by the channel, including XAH previously redeemed.
 | 
			
		||||
   * The amount authorized by the Signature. This must match the amount in the
 | 
			
		||||
   * signed message. This is the cumulative amount that can be dispensed by the
 | 
			
		||||
   * channel, including amounts previously redeemed. Required unless closing the channel.
 | 
			
		||||
   */
 | 
			
		||||
  Amount?: string
 | 
			
		||||
  Amount?: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * The signature of this claim, as hexadecimal. The signed message contains
 | 
			
		||||
   * the channel ID and the amount of the claim. Required unless the sender of
 | 
			
		||||
@@ -146,12 +152,12 @@ export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
 | 
			
		||||
    throw new ValidationError('PaymentChannelClaim: Channel must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Balance !== undefined && typeof tx.Balance !== 'string') {
 | 
			
		||||
    throw new ValidationError('PaymentChannelClaim: Balance must be a string')
 | 
			
		||||
  if (tx.Balance !== undefined && !isAmount(tx.Balance)) {
 | 
			
		||||
    throw new ValidationError('PaymentChannelClaim: Balance must be an Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Amount !== undefined && typeof tx.Amount !== 'string') {
 | 
			
		||||
    throw new ValidationError('PaymentChannelClaim: Amount must be a string')
 | 
			
		||||
  if (tx.Amount !== undefined && !isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('PaymentChannelClaim: Amount must be an Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Signature !== undefined && typeof tx.Signature !== 'string') {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,11 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import {
 | 
			
		||||
  Account,
 | 
			
		||||
  BaseTransaction,
 | 
			
		||||
  isAccount,
 | 
			
		||||
  isAmount,
 | 
			
		||||
  isNumber,
 | 
			
		||||
  validateBaseTransaction,
 | 
			
		||||
  validateOptionalField,
 | 
			
		||||
@@ -11,7 +13,7 @@ import {
 | 
			
		||||
} from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Create a unidirectional channel and fund it with XAH. The address sending
 | 
			
		||||
 * Create a unidirectional channel and fund it. The address sending
 | 
			
		||||
 * this transaction becomes the "source address" of the payment channel.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
@@ -19,20 +21,20 @@ import {
 | 
			
		||||
export interface PaymentChannelCreate extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'PaymentChannelCreate'
 | 
			
		||||
  /**
 | 
			
		||||
   * Amount of XAH, in drops, to deduct from the sender's balance and set aside
 | 
			
		||||
   * in this channel. While the channel is open, the XAH can only go to the
 | 
			
		||||
   * Destination address. When the channel closes, any unclaimed XAH is returned
 | 
			
		||||
   * to the source address's balance.
 | 
			
		||||
   * Amount to deduct from the sender's balance and set aside in this channel.
 | 
			
		||||
   * While the channel is open, the amount can only go to the Destination
 | 
			
		||||
   * address. When the channel closes, any unclaimed amount is returned to
 | 
			
		||||
   * the source address's balance.
 | 
			
		||||
   */
 | 
			
		||||
  Amount: string
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * Address to receive XAH claims against this channel. This is also known as
 | 
			
		||||
   * Address to receive claims against this channel. This is also known as
 | 
			
		||||
   * the "destination address" for the channel.
 | 
			
		||||
   */
 | 
			
		||||
  Destination: Account
 | 
			
		||||
  /**
 | 
			
		||||
   * Amount of time the source address must wait before closing the channel if
 | 
			
		||||
   * it has unclaimed XAH.
 | 
			
		||||
   * it has unclaimed.
 | 
			
		||||
   */
 | 
			
		||||
  SettleDelay: number
 | 
			
		||||
  /**
 | 
			
		||||
@@ -71,8 +73,8 @@ export function validatePaymentChannelCreate(
 | 
			
		||||
    throw new ValidationError('PaymentChannelCreate: missing Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.Amount !== 'string') {
 | 
			
		||||
    throw new ValidationError('PaymentChannelCreate: Amount must be a string')
 | 
			
		||||
  if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('PaymentChannelCreate: Amount must be an Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  validateRequiredField(tx, 'Destination', isAccount)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Add additional XAH to an open payment channel, and optionally update the
 | 
			
		||||
 * Add additional amount to an open payment channel, and optionally update the
 | 
			
		||||
 * expiration time of the channel. Only the source address of the channel can
 | 
			
		||||
 * use this transaction.
 | 
			
		||||
 *
 | 
			
		||||
@@ -17,16 +18,15 @@ export interface PaymentChannelFund extends BaseTransaction {
 | 
			
		||||
   */
 | 
			
		||||
  Channel: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Amount of XAH in drops to add to the channel. Must be a positive amount
 | 
			
		||||
   * of XAH.
 | 
			
		||||
   * Amount to add to the channel. Must be a positive amount
 | 
			
		||||
   */
 | 
			
		||||
  Amount: string
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * New Expiration time to set for the channel in seconds since the Ripple
 | 
			
		||||
   * Epoch. This must be later than either the current time plus the SettleDelay
 | 
			
		||||
   * of the channel, or the existing Expiration of the channel. After the
 | 
			
		||||
   * Expiration time, any transaction that would access the channel closes the
 | 
			
		||||
   * channel without taking its normal action. Any unspent XAH is returned to
 | 
			
		||||
   * channel without taking its normal action. Any unspent amount is returned to
 | 
			
		||||
   * the source address when the channel closes. (Expiration is separate from
 | 
			
		||||
   * the channel's immutable CancelAfter time.) For more information, see the
 | 
			
		||||
   * PayChannel ledger object type.
 | 
			
		||||
@@ -55,8 +55,8 @@ export function validatePaymentChannelFund(tx: Record<string, unknown>): void {
 | 
			
		||||
    throw new ValidationError('PaymentChannelFund: missing Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.Amount !== 'string') {
 | 
			
		||||
    throw new ValidationError('PaymentChannelFund: Amount must be a string')
 | 
			
		||||
  if (typeof tx.Amount !== 'string' && !isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('PaymentChannelFund: Amount must be an Amount')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										202
									
								
								packages/xahau/src/models/transactions/remit.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								packages/xahau/src/models/transactions/remit.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,202 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { AmountEntry, MintURIToken } from '../common/xahau'
 | 
			
		||||
import { isHex } from '../utils'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
const MAX_URI_LENGTH = 512
 | 
			
		||||
const DIGEST_LENGTH = 64
 | 
			
		||||
const MAX_ARRAY_LENGTH = 32
 | 
			
		||||
const MAX_BLOB_LENGTH = 1024
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A Remit transaction represents a transfer of value from one account to
 | 
			
		||||
 * another.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface Remit extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'Remit'
 | 
			
		||||
  /** The unique address of the account receiving the payment. */
 | 
			
		||||
  Destination: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Arbitrary tag that identifies the reason for the payment to the
 | 
			
		||||
   * destination, or a hosted recipient to pay.
 | 
			
		||||
   */
 | 
			
		||||
  DestinationTag?: number
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  Amounts?: AmountEntry[]
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  MintURIToken?: MintURIToken
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  URITokenIDs?: string[]
 | 
			
		||||
  /**
 | 
			
		||||
   * Arbitrary 256-bit hash representing a specific reason or identifier for
 | 
			
		||||
   * this payment.
 | 
			
		||||
   */
 | 
			
		||||
  InvoiceID?: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Hex value representing a VL Blob.
 | 
			
		||||
   */
 | 
			
		||||
  Blob?: string
 | 
			
		||||
  /** The unique address of the account to inform */
 | 
			
		||||
  Inform?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of a Remit at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - A Remit Transaction.
 | 
			
		||||
 * @throws When the Remit is malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateRemit(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Amounts !== undefined) {
 | 
			
		||||
    checkAmounts(tx)
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.URITokenIDs !== undefined) {
 | 
			
		||||
    checkURITokenIDs(tx)
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.Destination === tx.Account) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'Remit: Destination must not be equal to the account',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.DestinationTag != null && typeof tx.DestinationTag !== 'number') {
 | 
			
		||||
    throw new ValidationError('Remit: DestinationTag must be a number')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.Inform === tx.Account || tx.Inform === tx.Destination) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'Remit: Inform must not be equal to the account or destination',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.MintURIToken !== undefined) {
 | 
			
		||||
    checkMintURIToken(tx)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Blob !== undefined && typeof tx.Blob !== 'string') {
 | 
			
		||||
    throw new ValidationError('Remit: Blob must be a string')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Blob !== undefined && typeof tx.Blob === 'string') {
 | 
			
		||||
    if (!isHex(tx.Blob)) {
 | 
			
		||||
      throw new ValidationError('Remit: Blob must be a hex string')
 | 
			
		||||
    }
 | 
			
		||||
    if (tx.Blob.length > MAX_BLOB_LENGTH) {
 | 
			
		||||
      throw new ValidationError('Remit: max size Blob')
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function checkAmounts(tx: Record<string, unknown>): void {
 | 
			
		||||
  if (!Array.isArray(tx.Amounts)) {
 | 
			
		||||
    throw new ValidationError('Remit: Amounts must be an array')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.Amounts.length < 1) {
 | 
			
		||||
    throw new ValidationError('Remit: empty field Amounts')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.Amounts.length > MAX_ARRAY_LENGTH) {
 | 
			
		||||
    throw new ValidationError('Remit: max field Amounts')
 | 
			
		||||
  }
 | 
			
		||||
  const seen = new Set<string>()
 | 
			
		||||
  let seenXrp = false
 | 
			
		||||
  for (const amount of tx.Amounts) {
 | 
			
		||||
    if (
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ignore
 | 
			
		||||
      amount.AmountEntry === undefined ||
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ignore
 | 
			
		||||
      typeof amount.AmountEntry !== 'object'
 | 
			
		||||
    ) {
 | 
			
		||||
      throw new ValidationError('Remit: invalid Amounts.AmountEntry')
 | 
			
		||||
    }
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ignore
 | 
			
		||||
    if (typeof amount.AmountEntry.Amount === 'string') {
 | 
			
		||||
      // eslint-disable-next-line max-depth -- ignore
 | 
			
		||||
      if (seenXrp) {
 | 
			
		||||
        throw new ValidationError(
 | 
			
		||||
          'Remit: Duplicate Native amounts are not allowed',
 | 
			
		||||
        )
 | 
			
		||||
      }
 | 
			
		||||
      seenXrp = true
 | 
			
		||||
    } else {
 | 
			
		||||
      // eslint-disable-next-line max-len -- ignore
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access -- ignore
 | 
			
		||||
      const amountKey = `${amount.AmountEntry.Amount.currency}:${amount.AmountEntry.Amount.issuer}`
 | 
			
		||||
      // eslint-disable-next-line max-depth -- ingore
 | 
			
		||||
      if (seen.has(amountKey)) {
 | 
			
		||||
        throw new ValidationError('Remit: Duplicate amounts are not allowed')
 | 
			
		||||
      }
 | 
			
		||||
      seen.add(amountKey)
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function checkURITokenIDs(tx: Record<string, unknown>): void {
 | 
			
		||||
  if (!Array.isArray(tx.URITokenIDs)) {
 | 
			
		||||
    throw new ValidationError('Remit: invalid field URITokenIDs')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.URITokenIDs.length < 1) {
 | 
			
		||||
    throw new ValidationError('Remit: empty field URITokenIDs')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.URITokenIDs.length > MAX_ARRAY_LENGTH) {
 | 
			
		||||
    throw new ValidationError('Remit: max field URITokenIDs')
 | 
			
		||||
  }
 | 
			
		||||
  const seen = new Set<string>()
 | 
			
		||||
  for (const token of tx.URITokenIDs) {
 | 
			
		||||
    if (typeof token !== 'string' || !isHex(token)) {
 | 
			
		||||
      throw new ValidationError('Remit: URITokenID must be a hex string')
 | 
			
		||||
    }
 | 
			
		||||
    if (token.length !== DIGEST_LENGTH) {
 | 
			
		||||
      throw new ValidationError(
 | 
			
		||||
        `Remit: URITokenID must be exactly ${DIGEST_LENGTH} characters`,
 | 
			
		||||
      )
 | 
			
		||||
    }
 | 
			
		||||
    if (seen.has(token)) {
 | 
			
		||||
      throw new ValidationError('Remit: Duplicate URITokens are not allowed')
 | 
			
		||||
    }
 | 
			
		||||
    seen.add(token)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function checkMintURIToken(tx: Record<string, unknown>): void {
 | 
			
		||||
  function isRecord(value: unknown): value is Record<string, unknown> {
 | 
			
		||||
    return value !== null && typeof value === 'object'
 | 
			
		||||
  }
 | 
			
		||||
  if (!isRecord(tx.MintURIToken)) {
 | 
			
		||||
    throw new ValidationError('Remit: invalid MintURIToken')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.MintURIToken.URI === undefined) {
 | 
			
		||||
    throw new ValidationError('Remit: missing field MintURIToken.URI')
 | 
			
		||||
  }
 | 
			
		||||
  if (typeof tx.MintURIToken.URI !== 'string' || !isHex(tx.MintURIToken.URI)) {
 | 
			
		||||
    throw new ValidationError('Remit: MintURIToken.URI must be a hex string')
 | 
			
		||||
  }
 | 
			
		||||
  if (tx.MintURIToken.URI.length > MAX_URI_LENGTH) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      `Remit: URI must be less than ${MAX_URI_LENGTH} characters`,
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
  if (
 | 
			
		||||
    tx.MintURIToken.Digest !== undefined &&
 | 
			
		||||
    typeof tx.MintURIToken.Digest !== 'string'
 | 
			
		||||
  ) {
 | 
			
		||||
    throw new ValidationError(`Remit: MintURIToken.Digest must be a string`)
 | 
			
		||||
  }
 | 
			
		||||
  if (
 | 
			
		||||
    tx.MintURIToken.Digest !== undefined &&
 | 
			
		||||
    !isHex(tx.MintURIToken.Digest) &&
 | 
			
		||||
    tx.MintURIToken.Digest.length !== DIGEST_LENGTH
 | 
			
		||||
  ) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      `Remit: Digest must be exactly ${DIGEST_LENGTH} characters`,
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										81
									
								
								packages/xahau/src/models/transactions/setHook.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								packages/xahau/src/models/transactions/setHook.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Hook } from '../common/xahau'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Enum representing values for Set Hook Transaction Flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 */
 | 
			
		||||
export enum SetHookFlags {
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  hsfOverride = 0x00000001,
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  hsfNSDelete = 0x0000002,
 | 
			
		||||
  /**
 | 
			
		||||
   */
 | 
			
		||||
  hsfCollect = 0x00000004,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface SetHookFlagsInterface extends GlobalFlags {
 | 
			
		||||
  hsfOverride?: boolean
 | 
			
		||||
  hsfNSDelete?: boolean
 | 
			
		||||
  hsfCollect?: boolean
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 *
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface SetHook extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'SetHook'
 | 
			
		||||
  /**
 | 
			
		||||
   *
 | 
			
		||||
   */
 | 
			
		||||
  Hooks: Hook[]
 | 
			
		||||
 | 
			
		||||
  Flags?: number | SetHookFlagsInterface
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const MAX_HOOKS = 10
 | 
			
		||||
const HEX_REGEX = /^[0-9A-Fa-f]{64}$/u
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an SetHook at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An SetHook Transaction.
 | 
			
		||||
 * @throws When the SetHook is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateSetHook(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (!Array.isArray(tx.Hooks)) {
 | 
			
		||||
    throw new ValidationError('SetHook: invalid Hooks')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.Hooks.length > MAX_HOOKS) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      `SetHook: maximum of ${MAX_HOOKS} hooks allowed in Hooks`,
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (const hook of tx.Hooks) {
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- Should be a Hook
 | 
			
		||||
    const hookObject = hook as Hook
 | 
			
		||||
    const { HookOn, HookNamespace } = hookObject.Hook
 | 
			
		||||
    if (HookOn !== undefined && !HEX_REGEX.test(HookOn)) {
 | 
			
		||||
      throw new ValidationError(
 | 
			
		||||
        `SetHook: HookOn in Hook must be a 256-bit (32-byte) hexadecimal value`,
 | 
			
		||||
      )
 | 
			
		||||
    }
 | 
			
		||||
    if (HookNamespace !== undefined && !HEX_REGEX.test(HookNamespace)) {
 | 
			
		||||
      throw new ValidationError(
 | 
			
		||||
        `SetHook: HookNamespace in Hook must be a 256-bit (32-byte) hexadecimal value`,
 | 
			
		||||
      )
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -9,12 +9,15 @@ import { AccountSet, validateAccountSet } from './accountSet'
 | 
			
		||||
import { CheckCancel, validateCheckCancel } from './checkCancel'
 | 
			
		||||
import { CheckCash, validateCheckCash } from './checkCash'
 | 
			
		||||
import { CheckCreate, validateCheckCreate } from './checkCreate'
 | 
			
		||||
import { ClaimReward, validateClaimReward } from './claimReward'
 | 
			
		||||
import { BaseTransaction, isIssuedCurrency } from './common'
 | 
			
		||||
import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
 | 
			
		||||
import { EnableAmendment } from './enableAmendment'
 | 
			
		||||
import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
 | 
			
		||||
import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
 | 
			
		||||
import { EscrowFinish, validateEscrowFinish } from './escrowFinish'
 | 
			
		||||
import { Import, validateImport } from './import'
 | 
			
		||||
import { Invoke, validateInvoke } from './invoke'
 | 
			
		||||
import { TransactionMetadata } from './metadata'
 | 
			
		||||
import { OfferCancel, validateOfferCancel } from './offerCancel'
 | 
			
		||||
import { OfferCreate, validateOfferCreate } from './offerCreate'
 | 
			
		||||
@@ -31,12 +34,25 @@ import {
 | 
			
		||||
  PaymentChannelFund,
 | 
			
		||||
  validatePaymentChannelFund,
 | 
			
		||||
} from './paymentChannelFund'
 | 
			
		||||
import { Remit, validateRemit } from './remit'
 | 
			
		||||
import { SetFee } from './setFee'
 | 
			
		||||
import { SetHook, validateSetHook } from './setHook'
 | 
			
		||||
import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
 | 
			
		||||
import { SignerListSet, validateSignerListSet } from './signerListSet'
 | 
			
		||||
import { TicketCreate, validateTicketCreate } from './ticketCreate'
 | 
			
		||||
import { TrustSet, validateTrustSet } from './trustSet'
 | 
			
		||||
import { UNLModify } from './UNLModify'
 | 
			
		||||
import { URITokenBurn, validateURITokenBurn } from './uriTokenBurn'
 | 
			
		||||
import { URITokenBuy, validateURITokenBuy } from './uriTokenBuy'
 | 
			
		||||
import {
 | 
			
		||||
  URITokenCancelSellOffer,
 | 
			
		||||
  validateURITokenCancelSellOffer,
 | 
			
		||||
} from './uriTokenCancelSellOffer'
 | 
			
		||||
import {
 | 
			
		||||
  URITokenCreateSellOffer,
 | 
			
		||||
  validateURITokenCreateSellOffer,
 | 
			
		||||
} from './uriTokenCreateSellOffer'
 | 
			
		||||
import { URITokenMint, validateURITokenMint } from './uriTokenMint'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Transactions that can be submitted by clients
 | 
			
		||||
@@ -48,20 +64,30 @@ export type SubmittableTransaction =
 | 
			
		||||
  | CheckCancel
 | 
			
		||||
  | CheckCash
 | 
			
		||||
  | CheckCreate
 | 
			
		||||
  | ClaimReward
 | 
			
		||||
  | DepositPreauth
 | 
			
		||||
  | EscrowCancel
 | 
			
		||||
  | EscrowCreate
 | 
			
		||||
  | EscrowFinish
 | 
			
		||||
  | Import
 | 
			
		||||
  | Invoke
 | 
			
		||||
  | OfferCancel
 | 
			
		||||
  | OfferCreate
 | 
			
		||||
  | Payment
 | 
			
		||||
  | PaymentChannelClaim
 | 
			
		||||
  | PaymentChannelCreate
 | 
			
		||||
  | PaymentChannelFund
 | 
			
		||||
  | Remit
 | 
			
		||||
  | SetHook
 | 
			
		||||
  | SetRegularKey
 | 
			
		||||
  | SignerListSet
 | 
			
		||||
  | TicketCreate
 | 
			
		||||
  | TrustSet
 | 
			
		||||
  | URITokenBurn
 | 
			
		||||
  | URITokenBuy
 | 
			
		||||
  | URITokenCancelSellOffer
 | 
			
		||||
  | URITokenMint
 | 
			
		||||
  | URITokenCreateSellOffer
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Transactions that can only be created by validators.
 | 
			
		||||
@@ -172,6 +198,10 @@ export function validate(transaction: Record<string, unknown>): void {
 | 
			
		||||
      validateCheckCreate(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'ClaimReward':
 | 
			
		||||
      validateClaimReward(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'DepositPreauth':
 | 
			
		||||
      validateDepositPreauth(tx)
 | 
			
		||||
      break
 | 
			
		||||
@@ -188,6 +218,14 @@ export function validate(transaction: Record<string, unknown>): void {
 | 
			
		||||
      validateEscrowFinish(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'Import':
 | 
			
		||||
      validateImport(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'Invoke':
 | 
			
		||||
      validateInvoke(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'OfferCancel':
 | 
			
		||||
      validateOfferCancel(tx)
 | 
			
		||||
      break
 | 
			
		||||
@@ -212,6 +250,14 @@ export function validate(transaction: Record<string, unknown>): void {
 | 
			
		||||
      validatePaymentChannelFund(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'Remit':
 | 
			
		||||
      validateRemit(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'SetHook':
 | 
			
		||||
      validateSetHook(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'SetRegularKey':
 | 
			
		||||
      validateSetRegularKey(tx)
 | 
			
		||||
      break
 | 
			
		||||
@@ -228,6 +274,26 @@ export function validate(transaction: Record<string, unknown>): void {
 | 
			
		||||
      validateTrustSet(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'URITokenMint':
 | 
			
		||||
      validateURITokenMint(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'URITokenBurn':
 | 
			
		||||
      validateURITokenBurn(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'URITokenCreateSellOffer':
 | 
			
		||||
      validateURITokenCreateSellOffer(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'URITokenBuy':
 | 
			
		||||
      validateURITokenBuy(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    case 'URITokenCancelSellOffer':
 | 
			
		||||
      validateURITokenCancelSellOffer(tx)
 | 
			
		||||
      break
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      throw new ValidationError(
 | 
			
		||||
        `Invalid field TransactionType: ${tx.TransactionType}`,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										60
									
								
								packages/xahau/src/models/transactions/uriTokenBurn.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								packages/xahau/src/models/transactions/uriTokenBurn.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Map of flags to boolean values representing {@link URITokenBurn} transaction
 | 
			
		||||
 * flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 *
 | 
			
		||||
 * @example
 | 
			
		||||
 * ```typescript
 | 
			
		||||
 * const tx: URITokenBurn = {
 | 
			
		||||
 * Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * TransactionType: 'URITokenBurn',
 | 
			
		||||
 * }
 | 
			
		||||
 *
 | 
			
		||||
 * // Autofill the tx to see how flags actually look compared to the interface usage.
 | 
			
		||||
 * const autofilledTx = await client.autofill(tx)
 | 
			
		||||
 * console.log(autofilledTx)
 | 
			
		||||
 * // {
 | 
			
		||||
 * // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * // TransactionType: 'URITokenBurn',
 | 
			
		||||
 * // Sequence: 21970384,
 | 
			
		||||
 * // Fee: '12',
 | 
			
		||||
 * // LastLedgerSequence: 21970404
 | 
			
		||||
 * // }
 | 
			
		||||
 * ```
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An URITokenBurn transaction is effectively a limit order . It defines an
 | 
			
		||||
 * intent to exchange currencies, and creates an Offer object if not completely.
 | 
			
		||||
 * Fulfilled when placed. Offers can be partially fulfilled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenBurn extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'URITokenBurn'
 | 
			
		||||
  /**
 | 
			
		||||
   * Identifies the URIToken object to be removed by the transaction.
 | 
			
		||||
   */
 | 
			
		||||
  URITokenID: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an URITokenBurn at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An URITokenBurn Transaction.
 | 
			
		||||
 * @throws When the URITokenBurn is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateURITokenBurn(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.URITokenID == null) {
 | 
			
		||||
    throw new ValidationError('NFTokenBurn: missing field URITokenID')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										83
									
								
								packages/xahau/src/models/transactions/uriTokenBuy.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								packages/xahau/src/models/transactions/uriTokenBuy.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Map of flags to boolean values representing {@link URITokenBuy} transaction
 | 
			
		||||
 * flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 *
 | 
			
		||||
 * @example
 | 
			
		||||
 * ```typescript
 | 
			
		||||
 * const tx: URITokenBuy = {
 | 
			
		||||
 * Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * Amount: '1000000',
 | 
			
		||||
 * TransactionType: 'URITokenBuy',
 | 
			
		||||
 * }
 | 
			
		||||
 *
 | 
			
		||||
 * // Autofill the tx to see how flags actually look compared to the interface usage.
 | 
			
		||||
 * const autofilledTx = await client.autofill(tx)
 | 
			
		||||
 * console.log(autofilledTx)
 | 
			
		||||
 * // {
 | 
			
		||||
 * // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * // Amount: '1000000',
 | 
			
		||||
 * // TransactionType: 'URITokenBuy',
 | 
			
		||||
 * // Sequence: 21970384,
 | 
			
		||||
 * // Fee: '12',
 | 
			
		||||
 * // LastLedgerSequence: 21970404
 | 
			
		||||
 * // }
 | 
			
		||||
 * ```
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An URITokenBuy transaction is effectively a limit order . It defines an
 | 
			
		||||
 * intent to exchange currencies, and creates an Offer object if not completely.
 | 
			
		||||
 * Fulfilled when placed. Offers can be partially fulfilled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenBuy extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'URITokenBuy'
 | 
			
		||||
  /**
 | 
			
		||||
   * Identifies the URITokenID of the NFToken object that the
 | 
			
		||||
   * offer references.
 | 
			
		||||
   */
 | 
			
		||||
  URITokenID: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Indicates the amount expected or offered for the Token.
 | 
			
		||||
   *
 | 
			
		||||
   * The amount must be non-zero, except when this is a sell
 | 
			
		||||
   * offer and the asset is XRP. This would indicate that the current
 | 
			
		||||
   * owner of the token is giving it away free, either to anyone at all,
 | 
			
		||||
   * or to the account identified by the Destination field.
 | 
			
		||||
   */
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an URITokenBuy at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An URITokenBuy Transaction.
 | 
			
		||||
 * @throws When the URITokenBuy is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateURITokenBuy(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Account === tx.Destination) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'URITokenBuy: Destination and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.URITokenID == null) {
 | 
			
		||||
    throw new ValidationError('URITokenBuy: missing field URITokenID')
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('URITokenBuy: invalid Amount')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,65 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Map of flags to boolean values representing {@link URITokenCancelSellOffer} transaction
 | 
			
		||||
 * flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 *
 | 
			
		||||
 * @example
 | 
			
		||||
 * ```typescript
 | 
			
		||||
 * const tx: URITokenCancelSellOffer = {
 | 
			
		||||
 * Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * TransactionType: 'URITokenCancelSellOffer',
 | 
			
		||||
 * }
 | 
			
		||||
 *
 | 
			
		||||
 * // Autofill the tx to see how flags actually look compared to the interface usage.
 | 
			
		||||
 * const autofilledTx = await client.autofill(tx)
 | 
			
		||||
 * console.log(autofilledTx)
 | 
			
		||||
 * // {
 | 
			
		||||
 * // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * // TransactionType: 'URITokenCancelSellOffer',
 | 
			
		||||
 * // Sequence: 21970384,
 | 
			
		||||
 * // Fee: '12',
 | 
			
		||||
 * // LastLedgerSequence: 21970404
 | 
			
		||||
 * // }
 | 
			
		||||
 * ```
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An URITokenCancelSellOffer transaction is effectively a limit order . It defines an
 | 
			
		||||
 * intent to exchange currencies, and creates an Offer object if not completely.
 | 
			
		||||
 * Fulfilled when placed. Offers can be partially fulfilled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenCancelSellOffer extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'URITokenCancelSellOffer'
 | 
			
		||||
  /**
 | 
			
		||||
   * Identifies the URITokenID of the NFToken object that the
 | 
			
		||||
   * offer references.
 | 
			
		||||
   */
 | 
			
		||||
  URITokenID: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an URITokenCancelSellOffer at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An URITokenCancelSellOffer Transaction.
 | 
			
		||||
 * @throws When the URITokenCancelSellOffer is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateURITokenCancelSellOffer(
 | 
			
		||||
  tx: Record<string, unknown>,
 | 
			
		||||
): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.URITokenID == null) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'URITokenCancelSellOffer: missing field URITokenID',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,93 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Map of flags to boolean values representing {@link URITokenCreateSellOffer} transaction
 | 
			
		||||
 * flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 *
 | 
			
		||||
 * @example
 | 
			
		||||
 * ```typescript
 | 
			
		||||
 * const tx: URITokenCreateSellOffer = {
 | 
			
		||||
 * Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * Amount: '1000000',
 | 
			
		||||
 * TransactionType: 'URITokenCreateSellOffer',
 | 
			
		||||
 * }
 | 
			
		||||
 *
 | 
			
		||||
 * // Autofill the tx to see how flags actually look compared to the interface usage.
 | 
			
		||||
 * const autofilledTx = await client.autofill(tx)
 | 
			
		||||
 * console.log(autofilledTx)
 | 
			
		||||
 * // {
 | 
			
		||||
 * // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * // URITokenID: '7AFCE32EBA8BD310CC2D00BE10B76E2183337EA20444D4580E4DBDB396C101FB',
 | 
			
		||||
 * // Amount: '1000000',
 | 
			
		||||
 * // TransactionType: 'URITokenCreateSellOffer',
 | 
			
		||||
 * // Sequence: 21970384,
 | 
			
		||||
 * // Fee: '12',
 | 
			
		||||
 * // LastLedgerSequence: 21970404
 | 
			
		||||
 * // }
 | 
			
		||||
 * ```
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An URITokenCreateSellOffer transaction is effectively a limit order . It defines an
 | 
			
		||||
 * intent to exchange currencies, and creates an Offer object if not completely.
 | 
			
		||||
 * Fulfilled when placed. Offers can be partially fulfilled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenCreateSellOffer extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'URITokenCreateSellOffer'
 | 
			
		||||
  /**
 | 
			
		||||
   * Identifies the URITokenID of the NFToken object that the
 | 
			
		||||
   * offer references.
 | 
			
		||||
   */
 | 
			
		||||
  URITokenID: string
 | 
			
		||||
  /**
 | 
			
		||||
   * Indicates the amount expected or offered for the Token.
 | 
			
		||||
   *
 | 
			
		||||
   * The amount must be non-zero, except when this is a sell
 | 
			
		||||
   * offer and the asset is XRP. This would indicate that the current
 | 
			
		||||
   * owner of the token is giving it away free, either to anyone at all,
 | 
			
		||||
   * or to the account identified by the Destination field.
 | 
			
		||||
   */
 | 
			
		||||
  Amount: Amount
 | 
			
		||||
  /**
 | 
			
		||||
   * If present, indicates that this offer may only be
 | 
			
		||||
   * accepted by the specified account. Attempts by other
 | 
			
		||||
   * accounts to accept this offer MUST fail.
 | 
			
		||||
   */
 | 
			
		||||
  Destination?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an URITokenCreateSellOffer at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An URITokenCreateSellOffer Transaction.
 | 
			
		||||
 * @throws When the URITokenCreateSellOffer is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateURITokenCreateSellOffer(
 | 
			
		||||
  tx: Record<string, unknown>,
 | 
			
		||||
): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (tx.Account === tx.Destination) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'URITokenCreateSellOffer: Destination and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.URITokenID == null) {
 | 
			
		||||
    throw new ValidationError(
 | 
			
		||||
      'URITokenCreateSellOffer: missing field URITokenID',
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!isAmount(tx.Amount)) {
 | 
			
		||||
    throw new ValidationError('URITokenCreateSellOffer: invalid Amount')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										110
									
								
								packages/xahau/src/models/transactions/uriTokenMint.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								packages/xahau/src/models/transactions/uriTokenMint.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Amount } from '../common'
 | 
			
		||||
import { isHex } from '../utils'
 | 
			
		||||
 | 
			
		||||
import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Transaction Flags for an URITokenMint Transaction.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 */
 | 
			
		||||
export enum URITokenMintFlags {
 | 
			
		||||
  /**
 | 
			
		||||
   * If set, indicates that the minted token may be burned by the issuer even
 | 
			
		||||
   * if the issuer does not currently hold the token. The current holder of
 | 
			
		||||
   * the token may always burn it.
 | 
			
		||||
   */
 | 
			
		||||
  tfBurnable = 0x00000001,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Map of flags to boolean values representing {@link URITokenMint} transaction
 | 
			
		||||
 * flags.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Flags
 | 
			
		||||
 *
 | 
			
		||||
 * @example
 | 
			
		||||
 * ```typescript
 | 
			
		||||
 * const tx: URITokenMint = {
 | 
			
		||||
 * Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * URI: '697066733A2F2F434944',
 | 
			
		||||
 * TransactionType: 'URITokenMint',
 | 
			
		||||
 * Flags: {
 | 
			
		||||
 *   tfBurnable: true,
 | 
			
		||||
 *  },
 | 
			
		||||
 * }
 | 
			
		||||
 *
 | 
			
		||||
 * // Autofill the tx to see how flags actually look compared to the interface usage.
 | 
			
		||||
 * const autofilledTx = await client.autofill(tx)
 | 
			
		||||
 * console.log(autofilledTx)
 | 
			
		||||
 * // {
 | 
			
		||||
 * // Account: 'rhFcpWDHLqpBmX4ezWiA5VLSS4e1BHqhHd',
 | 
			
		||||
 * // URI: '697066733A2F2F434944',
 | 
			
		||||
 * // TransactionType: 'URITokenMint',
 | 
			
		||||
 * // Flags: 0,
 | 
			
		||||
 * // Sequence: 21970384,
 | 
			
		||||
 * // Fee: '12',
 | 
			
		||||
 * // LastLedgerSequence: 21970404
 | 
			
		||||
 * // }
 | 
			
		||||
 * ```
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenMintFlagsInterface extends GlobalFlags {
 | 
			
		||||
  tfBurnable?: boolean
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * An URITokenMint transaction is effectively a limit order . It defines an
 | 
			
		||||
 * intent to exchange currencies, and creates an Offer object if not completely.
 | 
			
		||||
 * Fulfilled when placed. Offers can be partially fulfilled.
 | 
			
		||||
 *
 | 
			
		||||
 * @category Transaction Models
 | 
			
		||||
 */
 | 
			
		||||
export interface URITokenMint extends BaseTransaction {
 | 
			
		||||
  TransactionType: 'URITokenMint'
 | 
			
		||||
  Flags?: number | URITokenMintFlagsInterface
 | 
			
		||||
  /**
 | 
			
		||||
   * URI that points to the data and/or metadata associated with the NFT.
 | 
			
		||||
   * This field need not be an HTTP or HTTPS URL; it could be an IPFS URI, a
 | 
			
		||||
   * magnet link, immediate data encoded as an RFC2379 "data" URL, or even an
 | 
			
		||||
   * opaque issuer-specific encoding. The URI is NOT checked for validity, but
 | 
			
		||||
   * the field is limited to a maximum length of 256 bytes.
 | 
			
		||||
   *
 | 
			
		||||
   * This field must be hex-encoded. You can use `convertStringToHex` to
 | 
			
		||||
   * convert this field to the proper encoding.
 | 
			
		||||
   */
 | 
			
		||||
  URI: string
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * Indicates the amount expected or offered for the Token.
 | 
			
		||||
   *
 | 
			
		||||
   * The amount must be non-zero, except when this is a sell
 | 
			
		||||
   * offer and the asset is XRP. This would indicate that the current
 | 
			
		||||
   * owner of the token is giving it away free, either to anyone at all,
 | 
			
		||||
   * or to the account identified by the Destination field.
 | 
			
		||||
   */
 | 
			
		||||
  Amount?: Amount
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * If present, indicates that this offer may only be
 | 
			
		||||
   * accepted by the specified account. Attempts by other
 | 
			
		||||
   * accounts to accept this offer MUST fail.
 | 
			
		||||
   */
 | 
			
		||||
  Destination?: string
 | 
			
		||||
 | 
			
		||||
  Digest?: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Verify the form and type of an URITokenMint at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @param tx - An URITokenMint Transaction.
 | 
			
		||||
 * @throws When the URITokenMint is Malformed.
 | 
			
		||||
 */
 | 
			
		||||
export function validateURITokenMint(tx: Record<string, unknown>): void {
 | 
			
		||||
  validateBaseTransaction(tx)
 | 
			
		||||
 | 
			
		||||
  if (typeof tx.URI === 'string' && !isHex(tx.URI)) {
 | 
			
		||||
    throw new ValidationError('URITokenMint: URI must be in hex format')
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
/* eslint-disable no-param-reassign -- param reassign is safe */
 | 
			
		||||
/* eslint-disable no-bitwise -- flags require bitwise operations */
 | 
			
		||||
import { ValidationError } from '../../errors'
 | 
			
		||||
import { Hook } from '../common/xahau'
 | 
			
		||||
import {
 | 
			
		||||
  AccountRootFlagsInterface,
 | 
			
		||||
  AccountRootFlags,
 | 
			
		||||
@@ -10,6 +11,7 @@ import { GlobalFlags } from '../transactions/common'
 | 
			
		||||
import { OfferCreateFlags } from '../transactions/offerCreate'
 | 
			
		||||
import { PaymentFlags } from '../transactions/payment'
 | 
			
		||||
import { PaymentChannelClaimFlags } from '../transactions/paymentChannelClaim'
 | 
			
		||||
import { SetHookFlagsInterface, SetHookFlags } from '../transactions/setHook'
 | 
			
		||||
import type { Transaction } from '../transactions/transaction'
 | 
			
		||||
import { TrustSetFlags } from '../transactions/trustSet'
 | 
			
		||||
 | 
			
		||||
@@ -61,6 +63,17 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
 | 
			
		||||
    return
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (tx.TransactionType === 'SetHook') {
 | 
			
		||||
    tx.Flags = convertFlagsToNumber(tx.Flags, SetHookFlags)
 | 
			
		||||
    tx.Hooks.forEach((hook: Hook) => {
 | 
			
		||||
      hook.Hook.Flags = convertFlagsToNumber(
 | 
			
		||||
        // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- idk
 | 
			
		||||
        hook.Hook.Flags as SetHookFlagsInterface,
 | 
			
		||||
        SetHookFlags,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  tx.Flags = txToFlag[tx.TransactionType]
 | 
			
		||||
    ? convertFlagsToNumber(tx.Flags, txToFlag[tx.TransactionType])
 | 
			
		||||
    : 0
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,12 @@
 | 
			
		||||
import BigNumber from 'bignumber.js'
 | 
			
		||||
import { xAddressToClassicAddress, isValidXAddress } from 'xahau-address-codec'
 | 
			
		||||
import { encode } from 'xahau-binary-codec'
 | 
			
		||||
 | 
			
		||||
import { type Client } from '..'
 | 
			
		||||
import { ValidationError } from '../errors'
 | 
			
		||||
import { AccountInfoRequest } from '../models/methods'
 | 
			
		||||
import { Transaction } from '../models/transactions'
 | 
			
		||||
import { xahToDrops } from '../utils'
 | 
			
		||||
 | 
			
		||||
import getFeeXrp from './getFeeXah'
 | 
			
		||||
import { getFeeEstimateXrp } from './getFeeXah'
 | 
			
		||||
 | 
			
		||||
// Expire unconfirmed transactions after 20 ledger versions, approximately 1 minute, by default
 | 
			
		||||
const LEDGER_OFFSET = 20
 | 
			
		||||
@@ -16,73 +15,6 @@ const LEDGER_OFFSET = 20
 | 
			
		||||
// in every transaction to that chain to prevent replay attacks.
 | 
			
		||||
// Mainnet and testnet are exceptions. More context: https://github.com/XRPLF/xahaud/pull/4370
 | 
			
		||||
const RESTRICTED_NETWORKS = 1024
 | 
			
		||||
const REQUIRED_NETWORKID_VERSION = '1.11.0'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Determines whether the source xahaud version is not later than the target xahaud version.
 | 
			
		||||
 * Example usage: isNotLaterRippledVersion('1.10.0', '1.11.0') returns true.
 | 
			
		||||
 *                isNotLaterRippledVersion('1.10.0', '1.10.0-b1') returns false.
 | 
			
		||||
 *
 | 
			
		||||
 * @param source -- The source xahaud version.
 | 
			
		||||
 * @param target -- The target xahaud version.
 | 
			
		||||
 * @returns True if source is earlier than target, false otherwise.
 | 
			
		||||
 */
 | 
			
		||||
// eslint-disable-next-line max-lines-per-function, max-statements -- Disable for this helper functions.
 | 
			
		||||
function isNotLaterRippledVersion(source: string, target: string): boolean {
 | 
			
		||||
  if (source === target) {
 | 
			
		||||
    return true
 | 
			
		||||
  }
 | 
			
		||||
  const sourceDecomp = source.split('.')
 | 
			
		||||
  const targetDecomp = target.split('.')
 | 
			
		||||
  const sourceMajor = parseInt(sourceDecomp[0], 10)
 | 
			
		||||
  const sourceMinor = parseInt(sourceDecomp[1], 10)
 | 
			
		||||
  const targetMajor = parseInt(targetDecomp[0], 10)
 | 
			
		||||
  const targetMinor = parseInt(targetDecomp[1], 10)
 | 
			
		||||
  // Compare major version
 | 
			
		||||
  if (sourceMajor !== targetMajor) {
 | 
			
		||||
    return sourceMajor < targetMajor
 | 
			
		||||
  }
 | 
			
		||||
  // Compare minor version
 | 
			
		||||
  if (sourceMinor !== targetMinor) {
 | 
			
		||||
    return sourceMinor < targetMinor
 | 
			
		||||
  }
 | 
			
		||||
  const sourcePatch = sourceDecomp[2].split('-')
 | 
			
		||||
  const targetPatch = targetDecomp[2].split('-')
 | 
			
		||||
 | 
			
		||||
  const sourcePatchVersion = parseInt(sourcePatch[0], 10)
 | 
			
		||||
  const targetPatchVersion = parseInt(targetPatch[0], 10)
 | 
			
		||||
 | 
			
		||||
  // Compare patch version
 | 
			
		||||
  if (sourcePatchVersion !== targetPatchVersion) {
 | 
			
		||||
    return sourcePatchVersion < targetPatchVersion
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Compare release version
 | 
			
		||||
  if (sourcePatch.length !== targetPatch.length) {
 | 
			
		||||
    return sourcePatch.length > targetPatch.length
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (sourcePatch.length === 2) {
 | 
			
		||||
    // Compare different release types
 | 
			
		||||
    if (!sourcePatch[1][0].startsWith(targetPatch[1][0])) {
 | 
			
		||||
      return sourcePatch[1] < targetPatch[1]
 | 
			
		||||
    }
 | 
			
		||||
    // Compare beta version
 | 
			
		||||
    if (sourcePatch[1].startsWith('b')) {
 | 
			
		||||
      return (
 | 
			
		||||
        parseInt(sourcePatch[1].slice(1), 10) <
 | 
			
		||||
        parseInt(targetPatch[1].slice(1), 10)
 | 
			
		||||
      )
 | 
			
		||||
    }
 | 
			
		||||
    // Compare rc version
 | 
			
		||||
    return (
 | 
			
		||||
      parseInt(sourcePatch[1].slice(2), 10) <
 | 
			
		||||
      parseInt(targetPatch[1].slice(2), 10)
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Determine if the transaction required a networkID to be valid.
 | 
			
		||||
@@ -96,12 +28,7 @@ export function txNeedsNetworkID(client: Client): boolean {
 | 
			
		||||
    client.networkID !== undefined &&
 | 
			
		||||
    client.networkID > RESTRICTED_NETWORKS
 | 
			
		||||
  ) {
 | 
			
		||||
    if (
 | 
			
		||||
      client.buildVersion &&
 | 
			
		||||
      isNotLaterRippledVersion(REQUIRED_NETWORKID_VERSION, client.buildVersion)
 | 
			
		||||
    ) {
 | 
			
		||||
      return true
 | 
			
		||||
    }
 | 
			
		||||
    return true
 | 
			
		||||
  }
 | 
			
		||||
  return false
 | 
			
		||||
}
 | 
			
		||||
@@ -242,47 +169,12 @@ export async function calculateFeePerTransactionType(
 | 
			
		||||
  tx: Transaction,
 | 
			
		||||
  signersCount = 0,
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
  // netFee is usually 0.00001 XAH (10 drops)
 | 
			
		||||
  const netFeeXAH = await getFeeXrp(client)
 | 
			
		||||
  const netFeeDrops = xahToDrops(netFeeXAH)
 | 
			
		||||
  let baseFee = new BigNumber(netFeeDrops)
 | 
			
		||||
 | 
			
		||||
  // EscrowFinish Transaction with Fulfillment
 | 
			
		||||
  if (tx.TransactionType === 'EscrowFinish' && tx.Fulfillment != null) {
 | 
			
		||||
    const fulfillmentBytesSize: number = Math.ceil(tx.Fulfillment.length / 2)
 | 
			
		||||
    // 10 drops × (33 + (Fulfillment size in bytes / 16))
 | 
			
		||||
    const product = new BigNumber(
 | 
			
		||||
      // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- expected use of magic numbers
 | 
			
		||||
      scaleValue(netFeeDrops, 33 + fulfillmentBytesSize / 16),
 | 
			
		||||
    )
 | 
			
		||||
    baseFee = product.dp(0, BigNumber.ROUND_CEIL)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * Multi-signed Transaction
 | 
			
		||||
   * 10 drops × (1 + Number of Signatures Provided)
 | 
			
		||||
   */
 | 
			
		||||
  if (signersCount > 0) {
 | 
			
		||||
    baseFee = BigNumber.sum(baseFee, scaleValue(netFeeDrops, 1 + signersCount))
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const maxFeeDrops = xahToDrops(client.maxFeeXAH)
 | 
			
		||||
  const totalFee = BigNumber.min(baseFee, maxFeeDrops)
 | 
			
		||||
 | 
			
		||||
  // Round up baseFee and return it as a string
 | 
			
		||||
  // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-magic-numbers -- param reassign is safe, base 10 magic num
 | 
			
		||||
  tx.Fee = totalFee.dp(0, BigNumber.ROUND_CEIL).toString(10)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Scales the given value by multiplying it with the provided multiplier.
 | 
			
		||||
 *
 | 
			
		||||
 * @param value - The value to be scaled.
 | 
			
		||||
 * @param multiplier - The multiplier to scale the value.
 | 
			
		||||
 * @returns The scaled value as a string.
 | 
			
		||||
 */
 | 
			
		||||
function scaleValue(value, multiplier): string {
 | 
			
		||||
  return new BigNumber(value).times(multiplier).toString()
 | 
			
		||||
  const copyTx = { ...tx }
 | 
			
		||||
  copyTx.SigningPubKey = ``
 | 
			
		||||
  copyTx.Fee = `0`
 | 
			
		||||
  const tx_blob = encode(copyTx)
 | 
			
		||||
  // eslint-disable-next-line require-atomic-updates, no-param-reassign -- ignore
 | 
			
		||||
  tx.Fee = await getFeeEstimateXrp(client, tx_blob, signersCount)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -46,3 +46,37 @@ export default async function getFeeXrp(
 | 
			
		||||
  // Round fee to 6 decimal places
 | 
			
		||||
  return new BigNumber(fee.toFixed(NUM_DECIMAL_PLACES)).toString(BASE_10)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculates the estimated transaction fee.
 | 
			
		||||
 * Note: This is a public API that can be called directly.
 | 
			
		||||
 *
 | 
			
		||||
 * @param client - The Client used to connect to the ledger.
 | 
			
		||||
 * @param txBlob - The encoded transaction to estimate the fee for.
 | 
			
		||||
 * @param signersCount - The number of multisigners.
 | 
			
		||||
 * @returns The transaction fee.
 | 
			
		||||
 */
 | 
			
		||||
export async function getFeeEstimateXrp(
 | 
			
		||||
  client: Client,
 | 
			
		||||
  txBlob: string,
 | 
			
		||||
  signersCount = 0,
 | 
			
		||||
): Promise<string> {
 | 
			
		||||
  const response = await client.request({
 | 
			
		||||
    command: 'fee',
 | 
			
		||||
    tx_blob: txBlob,
 | 
			
		||||
  })
 | 
			
		||||
  const openLedgerFee = response.result.drops.open_ledger_fee
 | 
			
		||||
  const noHookFee = response.result.drops.base_fee_no_hooks
 | 
			
		||||
  let baseFee = new BigNumber(response.result.drops.base_fee)
 | 
			
		||||
  if (signersCount > 0) {
 | 
			
		||||
    baseFee = BigNumber.sum(
 | 
			
		||||
      openLedgerFee,
 | 
			
		||||
      scaleValue(noHookFee, 1 + signersCount),
 | 
			
		||||
    )
 | 
			
		||||
  }
 | 
			
		||||
  return new BigNumber(baseFee.toFixed(NUM_DECIMAL_PLACES)).toString(BASE_10)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function scaleValue(value, multiplier): string {
 | 
			
		||||
  return new BigNumber(value).times(multiplier).toString()
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -82,6 +82,7 @@ export function hashSignedTx(tx: Transaction | string): string {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (
 | 
			
		||||
    !txObject.EmitDetails &&
 | 
			
		||||
    txObject.TxnSignature === undefined &&
 | 
			
		||||
    txObject.Signers === undefined &&
 | 
			
		||||
    txObject.SigningPubKey === undefined
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
/* eslint-disable no-bitwise  -- this file mimics behavior in xahaud. It uses
 | 
			
		||||
   bitwise operators for and-ing numbers with a mask and bit shifting. */
 | 
			
		||||
 | 
			
		||||
import { bytesToHex } from '@xrplf/isomorphic/utils'
 | 
			
		||||
import { bytesToHex, stringToHex } from '@xrplf/isomorphic/utils'
 | 
			
		||||
import BigNumber from 'bignumber.js'
 | 
			
		||||
import { decodeAccountID } from 'xahau-address-codec'
 | 
			
		||||
 | 
			
		||||
@@ -185,4 +185,18 @@ export function hashPaymentChannel(
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Compute the Hash of an URIToken LedgerEntry.
 | 
			
		||||
 *
 | 
			
		||||
 * @param issuer - Address of the issuer of the URIToken.
 | 
			
		||||
 * @param uri - string uri of the URIToken (not the hex).
 | 
			
		||||
 * @returns The hash of the URIToken LedgerEntry.
 | 
			
		||||
 * @category Utilities
 | 
			
		||||
 */
 | 
			
		||||
export function hashURIToken(issuer: string, uri: string): string {
 | 
			
		||||
  return sha512Half(
 | 
			
		||||
    ledgerSpaceHex('uriToken') + addressToHex(issuer) + stringToHex(uri),
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@ const ledgerSpaces = {
 | 
			
		||||
  paychan: 'x',
 | 
			
		||||
  check: 'C',
 | 
			
		||||
  depositPreauth: 'p',
 | 
			
		||||
  uriToken: 'U',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default ledgerSpaces
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										94
									
								
								packages/xahau/src/utils/hooks.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								packages/xahau/src/utils/hooks.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,94 @@
 | 
			
		||||
/**
 | 
			
		||||
 * @module tts
 | 
			
		||||
 * @description
 | 
			
		||||
 * This module contains the transaction types and the function to calculate the hook on
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { TRANSACTION_TYPES, TRANSACTION_TYPE_MAP } from 'xahau-binary-codec'
 | 
			
		||||
// import createHash = require('create-hash')
 | 
			
		||||
 | 
			
		||||
import { XahlError } from '../errors'
 | 
			
		||||
import { HookParameter } from '../models/common/xahau'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @constant tts
 | 
			
		||||
 * @description
 | 
			
		||||
 * Transaction types
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @typedef TTS
 | 
			
		||||
 * @description
 | 
			
		||||
 * Transaction types
 | 
			
		||||
 */
 | 
			
		||||
export type TTS = typeof TRANSACTION_TYPE_MAP
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculate the hook on
 | 
			
		||||
 *
 | 
			
		||||
 * @param arr - array of transaction types
 | 
			
		||||
 * @returns the hook on
 | 
			
		||||
 */
 | 
			
		||||
export function calculateHookOn(arr: Array<keyof TTS>): string {
 | 
			
		||||
  let hash =
 | 
			
		||||
    '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff'
 | 
			
		||||
  arr.forEach((nth) => {
 | 
			
		||||
    if (typeof nth !== 'string') {
 | 
			
		||||
      throw new XahlError(`HookOn transaction type must be string`)
 | 
			
		||||
    }
 | 
			
		||||
    if (!TRANSACTION_TYPES.includes(String(nth))) {
 | 
			
		||||
      throw new XahlError(
 | 
			
		||||
        `invalid transaction type '${String(nth)}' in HookOn array`,
 | 
			
		||||
      )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const tts: Record<string, number> = TRANSACTION_TYPE_MAP
 | 
			
		||||
    let value = BigInt(hash)
 | 
			
		||||
    // eslint-disable-next-line no-bitwise -- Required
 | 
			
		||||
    value ^= BigInt(1) << BigInt(tts[nth])
 | 
			
		||||
    // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Required
 | 
			
		||||
    hash = `0x${value.toString(16)}`
 | 
			
		||||
  })
 | 
			
		||||
  hash = hash.replace('0x', '')
 | 
			
		||||
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Required
 | 
			
		||||
  hash = hash.padStart(64, '0')
 | 
			
		||||
  return hash.toUpperCase()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function isHex(value: string): boolean {
 | 
			
		||||
  return /^[0-9A-F]+$/iu.test(value)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function hexValue(value: string): string {
 | 
			
		||||
  return Buffer.from(value, 'utf8').toString('hex').toUpperCase()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Calculate the hex of the hook parameters
 | 
			
		||||
 *
 | 
			
		||||
 * @param data - the hook parameters
 | 
			
		||||
 * @returns the hex of the hook parameters
 | 
			
		||||
 */
 | 
			
		||||
export function hexHookParameters(data: HookParameter[]): HookParameter[] {
 | 
			
		||||
  const hookParameters: HookParameter[] = []
 | 
			
		||||
  for (const parameter of data) {
 | 
			
		||||
    let hookPName = parameter.HookParameter.HookParameterName
 | 
			
		||||
    let hookPValue = parameter.HookParameter.HookParameterValue
 | 
			
		||||
 | 
			
		||||
    if (!isHex(hookPName)) {
 | 
			
		||||
      hookPName = hexValue(hookPName)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (hookPValue && !isHex(hookPValue)) {
 | 
			
		||||
      hookPValue = hexValue(hookPValue)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    hookParameters.push({
 | 
			
		||||
      HookParameter: {
 | 
			
		||||
        HookParameterName: hookPName,
 | 
			
		||||
        HookParameterValue: hookPValue,
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
  return hookParameters
 | 
			
		||||
}
 | 
			
		||||
@@ -44,7 +44,9 @@ import {
 | 
			
		||||
  hashLedgerHeader,
 | 
			
		||||
  hashEscrow,
 | 
			
		||||
  hashPaymentChannel,
 | 
			
		||||
  hashURIToken,
 | 
			
		||||
} from './hashes'
 | 
			
		||||
import { calculateHookOn, hexHookParameters, TTS } from './hooks'
 | 
			
		||||
import {
 | 
			
		||||
  percentToTransferRate,
 | 
			
		||||
  decimalToTransferRate,
 | 
			
		||||
@@ -176,6 +178,7 @@ const hashes = {
 | 
			
		||||
  hashLedgerHeader,
 | 
			
		||||
  hashEscrow,
 | 
			
		||||
  hashPaymentChannel,
 | 
			
		||||
  hashURIToken,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
@@ -223,4 +226,7 @@ export {
 | 
			
		||||
  encodeForMultiSigning,
 | 
			
		||||
  encodeForSigning,
 | 
			
		||||
  encodeForSigningClaim,
 | 
			
		||||
  calculateHookOn,
 | 
			
		||||
  hexHookParameters,
 | 
			
		||||
  TTS,
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,14 +1,12 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { EscrowFinish, Payment, Transaction } from '../../src'
 | 
			
		||||
import { ValidationError } from '../../src/errors'
 | 
			
		||||
import xahaud from '../fixtures/xahaud'
 | 
			
		||||
import {
 | 
			
		||||
  setupClient,
 | 
			
		||||
  teardownClient,
 | 
			
		||||
  type XrplTestContext,
 | 
			
		||||
} from '../setupClient'
 | 
			
		||||
import { assertRejects } from '../testUtils'
 | 
			
		||||
 | 
			
		||||
const NetworkID = 1025
 | 
			
		||||
const Fee = '10'
 | 
			
		||||
@@ -17,8 +15,6 @@ const LastLedgerSequence = 2908734
 | 
			
		||||
 | 
			
		||||
describe('client.autofill', function () {
 | 
			
		||||
  let testContext: XrplTestContext
 | 
			
		||||
  const AMOUNT = '1234'
 | 
			
		||||
  let paymentTx: Payment
 | 
			
		||||
 | 
			
		||||
  async function setupMockRippledVersionAndID(
 | 
			
		||||
    buildVersion: string,
 | 
			
		||||
@@ -42,64 +38,6 @@ describe('client.autofill', function () {
 | 
			
		||||
  })
 | 
			
		||||
  afterAll(async () => teardownClient(testContext))
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    paymentTx = {
 | 
			
		||||
      TransactionType: 'Payment',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Amount: AMOUNT,
 | 
			
		||||
      Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
 | 
			
		||||
      DestinationTag: 1,
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
      Flags: 2147483648,
 | 
			
		||||
      LastLedgerSequence: 65953073,
 | 
			
		||||
      Sequence: 65923914,
 | 
			
		||||
      SigningPubKey:
 | 
			
		||||
        '02F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE654',
 | 
			
		||||
      TxnSignature:
 | 
			
		||||
        '3045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB',
 | 
			
		||||
      InvoiceID:
 | 
			
		||||
        '6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
 | 
			
		||||
      Paths: [
 | 
			
		||||
        [{ currency: 'BTC', issuer: 'r9vbV3EHvXWjSkeQ6CAcYVPGeq7TuiXY2X' }],
 | 
			
		||||
      ],
 | 
			
		||||
      SendMax: '100000000',
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('Validate Payment transaction API v2: Payment Transaction: Specify Only Amount field', async function () {
 | 
			
		||||
    const txResult = await testContext.client.autofill(paymentTx)
 | 
			
		||||
 | 
			
		||||
    assert.strictEqual(txResult.Amount, AMOUNT)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('Validate Payment transaction API v2: Payment Transaction: Specify Only DeliverMax field', async function () {
 | 
			
		||||
    // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
    paymentTx.DeliverMax = paymentTx.Amount
 | 
			
		||||
    // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
    delete paymentTx.Amount
 | 
			
		||||
    const txResult = await testContext.client.autofill(paymentTx)
 | 
			
		||||
 | 
			
		||||
    assert.strictEqual(txResult.Amount, AMOUNT)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('Validate Payment transaction API v2: Payment Transaction: identical DeliverMax and Amount fields', async function () {
 | 
			
		||||
    // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
    paymentTx.DeliverMax = paymentTx.Amount
 | 
			
		||||
 | 
			
		||||
    const txResult = await testContext.client.autofill(paymentTx)
 | 
			
		||||
 | 
			
		||||
    assert.strictEqual(txResult.Amount, AMOUNT)
 | 
			
		||||
    assert.strictEqual('DeliverMax' in txResult, false)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('Validate Payment transaction API v2: Payment Transaction: differing DeliverMax and Amount fields', async function () {
 | 
			
		||||
    // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
    paymentTx.DeliverMax = '6789'
 | 
			
		||||
    paymentTx.Amount = '1234'
 | 
			
		||||
 | 
			
		||||
    await assertRejects(testContext.client.autofill(paymentTx), ValidationError)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it('should not autofill if fields are present', async function () {
 | 
			
		||||
    const tx: Transaction = {
 | 
			
		||||
      TransactionType: 'DepositPreauth',
 | 
			
		||||
@@ -155,26 +93,6 @@ describe('client.autofill', function () {
 | 
			
		||||
    assert.strictEqual(txResult.NetworkID, 1025)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // NetworkID is only required in transaction for version 1.11.0 or later.
 | 
			
		||||
  // More context: https://github.com/XRPLF/xahaud/pull/4370
 | 
			
		||||
  it('ignores network ID if > 1024 but version is earlier than 1.11.0', async function () {
 | 
			
		||||
    await setupMockRippledVersionAndID('1.10.0', 1025)
 | 
			
		||||
    const tx: Payment = {
 | 
			
		||||
      TransactionType: 'Payment',
 | 
			
		||||
      Account: 'XVLhHMPHU98es4dbozjVtdWzVrDjtV18pX8yuPT7y4xaEHi',
 | 
			
		||||
      Amount: '1234',
 | 
			
		||||
      Destination: 'X7AcgcsBL6XDcUb289X4mJ8djcdyKaB5hJDWMArnXr61cqZ',
 | 
			
		||||
      Fee,
 | 
			
		||||
      Sequence,
 | 
			
		||||
      LastLedgerSequence,
 | 
			
		||||
    }
 | 
			
		||||
    testContext.mockRippled!.addResponse('ledger', xahaud.ledger.normal)
 | 
			
		||||
 | 
			
		||||
    const txResult = await testContext.client.autofill(tx)
 | 
			
		||||
 | 
			
		||||
    assert.strictEqual(txResult.NetworkID, undefined)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // NetworkID <= 1024 does not require a newtorkID in transaction.
 | 
			
		||||
  // More context: https://github.com/XRPLF/xahaud/pull/4370
 | 
			
		||||
  it('ignores network ID if <= 1024', async function () {
 | 
			
		||||
@@ -206,10 +124,7 @@ describe('client.autofill', function () {
 | 
			
		||||
      'account_info',
 | 
			
		||||
      xahaud.account_info.normal,
 | 
			
		||||
    )
 | 
			
		||||
    testContext.mockRippled!.addResponse(
 | 
			
		||||
      'server_info',
 | 
			
		||||
      xahaud.server_info.normal,
 | 
			
		||||
    )
 | 
			
		||||
    testContext.mockRippled!.addResponse('fee', xahaud.fee.feeBase)
 | 
			
		||||
    testContext.mockRippled!.addResponse('ledger', xahaud.ledger.normal)
 | 
			
		||||
 | 
			
		||||
    const txResult = await testContext.client.autofill(tx)
 | 
			
		||||
@@ -252,13 +167,10 @@ describe('client.autofill', function () {
 | 
			
		||||
        Sequence,
 | 
			
		||||
        LastLedgerSequence,
 | 
			
		||||
      }
 | 
			
		||||
      testContext.mockRippled!.addResponse(
 | 
			
		||||
        'server_info',
 | 
			
		||||
        xahaud.server_info.normal,
 | 
			
		||||
      )
 | 
			
		||||
      testContext.mockRippled!.addResponse('fee', xahaud.fee.feeBase)
 | 
			
		||||
      const txResult = await testContext.client.autofill(tx)
 | 
			
		||||
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '12')
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '10')
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it('should autofill Fee of an EscrowFinish transaction', async function () {
 | 
			
		||||
@@ -276,13 +188,10 @@ describe('client.autofill', function () {
 | 
			
		||||
        xahaud.account_info.normal,
 | 
			
		||||
      )
 | 
			
		||||
      testContext.mockRippled!.addResponse('ledger', xahaud.ledger.normal)
 | 
			
		||||
      testContext.mockRippled!.addResponse(
 | 
			
		||||
        'server_info',
 | 
			
		||||
        xahaud.server_info.normal,
 | 
			
		||||
      )
 | 
			
		||||
      testContext.mockRippled!.addResponse('fee', xahaud.fee.feeFinish)
 | 
			
		||||
 | 
			
		||||
      const txResult = await testContext.client.autofill(tx)
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '399')
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '330')
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it('should autofill Fee of an EscrowFinish transaction with signersCount', async function () {
 | 
			
		||||
@@ -294,19 +203,18 @@ describe('client.autofill', function () {
 | 
			
		||||
        Condition:
 | 
			
		||||
          'A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100',
 | 
			
		||||
        Fulfillment: 'A0028000',
 | 
			
		||||
        Sequence,
 | 
			
		||||
        LastLedgerSequence,
 | 
			
		||||
      }
 | 
			
		||||
      testContext.mockRippled!.addResponse(
 | 
			
		||||
        'account_info',
 | 
			
		||||
        xahaud.account_info.normal,
 | 
			
		||||
      )
 | 
			
		||||
      testContext.mockRippled!.addResponse('ledger', xahaud.ledger.normal)
 | 
			
		||||
      testContext.mockRippled!.addResponse(
 | 
			
		||||
        'server_info',
 | 
			
		||||
        xahaud.server_info.normal,
 | 
			
		||||
      )
 | 
			
		||||
      testContext.mockRippled!.addResponse('fee', xahaud.fee.feeFinish)
 | 
			
		||||
      const txResult = await testContext.client.autofill(tx, 4)
 | 
			
		||||
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '459')
 | 
			
		||||
      assert.strictEqual(txResult.Fee, '380')
 | 
			
		||||
    })
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
@@ -351,19 +259,9 @@ describe('client.autofill', function () {
 | 
			
		||||
        ledger_index: 9038214,
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
    testContext.mockRippled!.addResponse('server_info', {
 | 
			
		||||
      status: 'success',
 | 
			
		||||
      type: 'response',
 | 
			
		||||
      result: {
 | 
			
		||||
        info: {
 | 
			
		||||
          validated_ledger: {
 | 
			
		||||
            base_fee_xrp: 0.00001,
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    })
 | 
			
		||||
    testContext.mockRippled!.addResponse('fee', xahaud.fee.feeBase)
 | 
			
		||||
    const txResult = await testContext.client.autofill(tx)
 | 
			
		||||
    assert.strictEqual(txResult.Fee, '12')
 | 
			
		||||
    assert.strictEqual(txResult.Fee, '10')
 | 
			
		||||
    assert.strictEqual(txResult.Sequence, 23)
 | 
			
		||||
    assert.strictEqual(txResult.LastLedgerSequence, 9038234)
 | 
			
		||||
  })
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								packages/xahau/test/fixtures/xahaud/feeBase.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/xahau/test/fixtures/xahaud/feeBase.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
{
 | 
			
		||||
  "id": 0,
 | 
			
		||||
  "status": "success",
 | 
			
		||||
  "type": "response",
 | 
			
		||||
  "result": {
 | 
			
		||||
    "current_ledger_size": "0",
 | 
			
		||||
    "current_queue_size": "0",
 | 
			
		||||
    "drops": {
 | 
			
		||||
      "base_fee": "10",
 | 
			
		||||
      "base_fee_no_hooks": "10",
 | 
			
		||||
      "median_fee": "5000",
 | 
			
		||||
      "minimum_fee": "10",
 | 
			
		||||
      "open_ledger_fee": "10"
 | 
			
		||||
    },
 | 
			
		||||
    "expected_ledger_size": "32",
 | 
			
		||||
    "fee_hooks_feeunits": "10",
 | 
			
		||||
    "ledger_current_index": 22215818,
 | 
			
		||||
    "levels": {
 | 
			
		||||
      "median_level": "128000",
 | 
			
		||||
      "minimum_level": "256",
 | 
			
		||||
      "open_ledger_level": "256",
 | 
			
		||||
      "reference_level": "256"
 | 
			
		||||
    },
 | 
			
		||||
    "max_queue_size": "2000"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								packages/xahau/test/fixtures/xahaud/feeFinish.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/xahau/test/fixtures/xahaud/feeFinish.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
{
 | 
			
		||||
  "id": 0,
 | 
			
		||||
  "status": "success",
 | 
			
		||||
  "type": "response",
 | 
			
		||||
  "result": {
 | 
			
		||||
    "current_ledger_size": "0",
 | 
			
		||||
    "current_queue_size": "0",
 | 
			
		||||
    "drops": {
 | 
			
		||||
      "base_fee": "330",
 | 
			
		||||
      "base_fee_no_hooks": "10",
 | 
			
		||||
      "median_fee": "165000",
 | 
			
		||||
      "minimum_fee": "330",
 | 
			
		||||
      "open_ledger_fee": "330"
 | 
			
		||||
    },
 | 
			
		||||
    "expected_ledger_size": "32",
 | 
			
		||||
    "fee_hooks_feeunits": "330",
 | 
			
		||||
    "ledger_current_index": 22215880,
 | 
			
		||||
    "levels": {
 | 
			
		||||
      "median_level": "128000",
 | 
			
		||||
      "minimum_level": "256",
 | 
			
		||||
      "open_ledger_level": "256",
 | 
			
		||||
      "reference_level": "256"
 | 
			
		||||
    },
 | 
			
		||||
    "max_queue_size": "2000"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								packages/xahau/test/fixtures/xahaud/index.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										8
									
								
								packages/xahau/test/fixtures/xahaud/index.ts
									
									
									
									
										vendored
									
									
								
							@@ -5,6 +5,8 @@ import normalAccountTx from './accountTx.json'
 | 
			
		||||
import fabric from './bookOffers'
 | 
			
		||||
import usd_xrp from './bookOffersUsdXrp.json'
 | 
			
		||||
import xrp_usd from './bookOffersXrpUsd.json'
 | 
			
		||||
import feeBase from './feeBase.json'
 | 
			
		||||
import feeFinish from './feeFinish.json'
 | 
			
		||||
import normalLedger from './ledger.json'
 | 
			
		||||
import firstPage from './ledgerDataFirstPage.json'
 | 
			
		||||
import firstPageEmpty from './ledgerDataFirstPageEmpty.json'
 | 
			
		||||
@@ -78,6 +80,11 @@ const book_offers = {
 | 
			
		||||
  xrp_usd,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const fee = {
 | 
			
		||||
  feeBase,
 | 
			
		||||
  feeFinish,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const ledger_data = {
 | 
			
		||||
  firstPage,
 | 
			
		||||
  firstPageEmpty,
 | 
			
		||||
@@ -100,6 +107,7 @@ const xahaud = {
 | 
			
		||||
  account_objects,
 | 
			
		||||
  account_tx,
 | 
			
		||||
  book_offers,
 | 
			
		||||
  fee,
 | 
			
		||||
  ledger,
 | 
			
		||||
  ledger_data,
 | 
			
		||||
  partial_payments,
 | 
			
		||||
 
 | 
			
		||||
@@ -72,7 +72,6 @@ describe('account_info', function () {
 | 
			
		||||
          'index',
 | 
			
		||||
        ]),
 | 
			
		||||
        omit(expected.result.account_data, [
 | 
			
		||||
          'AccountIndex',
 | 
			
		||||
          'PreviousTxnID',
 | 
			
		||||
          'PreviousTxnLgrSeq',
 | 
			
		||||
          'Sequence',
 | 
			
		||||
@@ -136,7 +135,6 @@ describe('account_info', function () {
 | 
			
		||||
          'index',
 | 
			
		||||
        ]),
 | 
			
		||||
        omit(expected.result.account_data, [
 | 
			
		||||
          'AccountIndex',
 | 
			
		||||
          'PreviousTxnID',
 | 
			
		||||
          'PreviousTxnLgrSeq',
 | 
			
		||||
          'Sequence',
 | 
			
		||||
 
 | 
			
		||||
@@ -1,16 +1,8 @@
 | 
			
		||||
import { Client, Currency, Wallet } from '../../src'
 | 
			
		||||
import { Client, Wallet } from '../../src'
 | 
			
		||||
 | 
			
		||||
import serverUrl from './serverUrl'
 | 
			
		||||
import { fundAccount } from './utils'
 | 
			
		||||
 | 
			
		||||
export interface TestAMMPool {
 | 
			
		||||
  issuerWallet: Wallet
 | 
			
		||||
  lpWallet: Wallet
 | 
			
		||||
  testWallet: Wallet
 | 
			
		||||
  asset: Currency
 | 
			
		||||
  asset2: Currency
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface XrplIntegrationTestContext {
 | 
			
		||||
  client: Client
 | 
			
		||||
  wallet: Wallet
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { ClaimReward, ClaimRewardFlags } from '../../../src'
 | 
			
		||||
import serverUrl from '../serverUrl'
 | 
			
		||||
import {
 | 
			
		||||
  setupClient,
 | 
			
		||||
  teardownClient,
 | 
			
		||||
  type XrplIntegrationTestContext,
 | 
			
		||||
} from '../setup'
 | 
			
		||||
import { testTransaction } from '../utils'
 | 
			
		||||
 | 
			
		||||
// how long before each test case times out
 | 
			
		||||
const TIMEOUT = 20000
 | 
			
		||||
 | 
			
		||||
describe('ClaimReward', function () {
 | 
			
		||||
  let testContext: XrplIntegrationTestContext
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    testContext = await setupClient(serverUrl)
 | 
			
		||||
  })
 | 
			
		||||
  afterEach(async () => teardownClient(testContext))
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'opt in',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const tx: ClaimReward = {
 | 
			
		||||
        TransactionType: 'ClaimReward',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Issuer: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
 | 
			
		||||
      const accountInfoResponse = await testContext.client.request({
 | 
			
		||||
        command: 'account_info',
 | 
			
		||||
        account: testContext.wallet.classicAddress,
 | 
			
		||||
      })
 | 
			
		||||
      assert.exists(accountInfoResponse.result.account_data.RewardAccumulator)
 | 
			
		||||
      assert.exists(accountInfoResponse.result.account_data.RewardLgrFirst)
 | 
			
		||||
      assert.exists(accountInfoResponse.result.account_data.RewardLgrLast)
 | 
			
		||||
      assert.exists(accountInfoResponse.result.account_data.RewardTime)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
  it(
 | 
			
		||||
    'opt out',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const tx: ClaimReward = {
 | 
			
		||||
        TransactionType: 'ClaimReward',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Flags: ClaimRewardFlags.tfOptOut,
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
 | 
			
		||||
      const accountInfoResponse = await testContext.client.request({
 | 
			
		||||
        command: 'account_info',
 | 
			
		||||
        account: testContext.wallet.classicAddress,
 | 
			
		||||
      })
 | 
			
		||||
      assert.notExists(
 | 
			
		||||
        accountInfoResponse.result.account_data.RewardAccumulator,
 | 
			
		||||
      )
 | 
			
		||||
      assert.notExists(accountInfoResponse.result.account_data.RewardLgrFirst)
 | 
			
		||||
      assert.notExists(accountInfoResponse.result.account_data.RewardLgrLast)
 | 
			
		||||
      assert.notExists(accountInfoResponse.result.account_data.RewardTime)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										36
									
								
								packages/xahau/test/integration/transactions/invoke.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								packages/xahau/test/integration/transactions/invoke.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
import { Invoke } from '../../../src'
 | 
			
		||||
import serverUrl from '../serverUrl'
 | 
			
		||||
import {
 | 
			
		||||
  setupClient,
 | 
			
		||||
  teardownClient,
 | 
			
		||||
  type XrplIntegrationTestContext,
 | 
			
		||||
} from '../setup'
 | 
			
		||||
import { generateFundedWallet, testTransaction } from '../utils'
 | 
			
		||||
 | 
			
		||||
// how long before each test case times out
 | 
			
		||||
const TIMEOUT = 20000
 | 
			
		||||
 | 
			
		||||
describe('Invoke', function () {
 | 
			
		||||
  let testContext: XrplIntegrationTestContext
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    testContext = await setupClient(serverUrl)
 | 
			
		||||
  })
 | 
			
		||||
  afterEach(async () => teardownClient(testContext))
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'base',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const wallet2 = await generateFundedWallet(testContext.client)
 | 
			
		||||
      const tx: Invoke = {
 | 
			
		||||
        TransactionType: 'Invoke',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Destination: wallet2.classicAddress,
 | 
			
		||||
        Blob: 'DEADBEEF',
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
})
 | 
			
		||||
@@ -1,5 +1,3 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { Payment, Wallet } from '../../../src'
 | 
			
		||||
import serverUrl from '../serverUrl'
 | 
			
		||||
import {
 | 
			
		||||
@@ -14,22 +12,9 @@ const TIMEOUT = 20000
 | 
			
		||||
 | 
			
		||||
describe('Payment', function () {
 | 
			
		||||
  let testContext: XrplIntegrationTestContext
 | 
			
		||||
  let paymentTx: Payment
 | 
			
		||||
  const AMOUNT = '10000000'
 | 
			
		||||
  // This wallet is used for DeliverMax related tests
 | 
			
		||||
  let senderWallet: Wallet
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    // this payment transaction JSON needs to be refreshed before every test.
 | 
			
		||||
    // Because, we tinker with Amount and DeliverMax fields in the API v2 tests
 | 
			
		||||
    paymentTx = {
 | 
			
		||||
      TransactionType: 'Payment',
 | 
			
		||||
      Account: senderWallet.classicAddress,
 | 
			
		||||
      Amount: AMOUNT,
 | 
			
		||||
      Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  beforeAll(async () => {
 | 
			
		||||
    testContext = await setupClient(serverUrl)
 | 
			
		||||
    senderWallet = await generateFundedWallet(testContext.client)
 | 
			
		||||
@@ -49,57 +34,4 @@ describe('Payment', function () {
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'Validate Payment transaction API v2: Payment Transaction: Specify Only Amount field',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const result = await testTransaction(
 | 
			
		||||
        testContext.client,
 | 
			
		||||
        paymentTx,
 | 
			
		||||
        senderWallet,
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      assert.equal(result.result.engine_result_code, 0)
 | 
			
		||||
      assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'Validate Payment transaction API v2: Payment Transaction: Specify Only DeliverMax field',
 | 
			
		||||
    async () => {
 | 
			
		||||
      // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
      paymentTx.DeliverMax = paymentTx.Amount
 | 
			
		||||
      // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
      delete paymentTx.Amount
 | 
			
		||||
 | 
			
		||||
      const result = await testTransaction(
 | 
			
		||||
        testContext.client,
 | 
			
		||||
        paymentTx,
 | 
			
		||||
        senderWallet,
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      assert.equal(result.result.engine_result_code, 0)
 | 
			
		||||
      assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'Validate Payment transaction API v2: Payment Transaction: identical DeliverMax and Amount fields',
 | 
			
		||||
    async () => {
 | 
			
		||||
      // @ts-expect-error -- DeliverMax is a non-protocol, RPC level field in Payment transactions
 | 
			
		||||
      paymentTx.DeliverMax = paymentTx.Amount
 | 
			
		||||
 | 
			
		||||
      const result = await testTransaction(
 | 
			
		||||
        testContext.client,
 | 
			
		||||
        paymentTx,
 | 
			
		||||
        senderWallet,
 | 
			
		||||
      )
 | 
			
		||||
 | 
			
		||||
      assert.equal(result.result.engine_result_code, 0)
 | 
			
		||||
      assert.equal((result.result.tx_json as Payment).Amount, AMOUNT)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										75
									
								
								packages/xahau/test/integration/transactions/remit.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								packages/xahau/test/integration/transactions/remit.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,75 @@
 | 
			
		||||
import { stringToHex } from '@xrplf/isomorphic/src/utils'
 | 
			
		||||
 | 
			
		||||
import { Remit } from '../../../src'
 | 
			
		||||
import serverUrl from '../serverUrl'
 | 
			
		||||
import {
 | 
			
		||||
  setupClient,
 | 
			
		||||
  teardownClient,
 | 
			
		||||
  type XrplIntegrationTestContext,
 | 
			
		||||
} from '../setup'
 | 
			
		||||
import { generateFundedWallet, testTransaction } from '../utils'
 | 
			
		||||
 | 
			
		||||
// how long before each test case times out
 | 
			
		||||
const TIMEOUT = 20000
 | 
			
		||||
 | 
			
		||||
describe('Remit', function () {
 | 
			
		||||
  let testContext: XrplIntegrationTestContext
 | 
			
		||||
 | 
			
		||||
  beforeEach(async () => {
 | 
			
		||||
    testContext = await setupClient(serverUrl)
 | 
			
		||||
  })
 | 
			
		||||
  afterEach(async () => teardownClient(testContext))
 | 
			
		||||
 | 
			
		||||
  it(
 | 
			
		||||
    'base',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const wallet2 = await generateFundedWallet(testContext.client)
 | 
			
		||||
      const tx: Remit = {
 | 
			
		||||
        TransactionType: 'Remit',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Destination: wallet2.classicAddress,
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
  it(
 | 
			
		||||
    'amt',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const wallet2 = await generateFundedWallet(testContext.client)
 | 
			
		||||
      const tx: Remit = {
 | 
			
		||||
        TransactionType: 'Remit',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Destination: wallet2.classicAddress,
 | 
			
		||||
        Amounts: [
 | 
			
		||||
          {
 | 
			
		||||
            AmountEntry: {
 | 
			
		||||
              Amount: '1000000',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        ],
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
  it(
 | 
			
		||||
    'mint',
 | 
			
		||||
    async () => {
 | 
			
		||||
      const wallet2 = await generateFundedWallet(testContext.client)
 | 
			
		||||
      const tx: Remit = {
 | 
			
		||||
        TransactionType: 'Remit',
 | 
			
		||||
        Account: testContext.wallet.classicAddress,
 | 
			
		||||
        Destination: wallet2.classicAddress,
 | 
			
		||||
        MintURIToken: {
 | 
			
		||||
          URI: stringToHex('https://example.com'),
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      await testTransaction(testContext.client, tx, testContext.wallet)
 | 
			
		||||
    },
 | 
			
		||||
    TIMEOUT,
 | 
			
		||||
  )
 | 
			
		||||
})
 | 
			
		||||
@@ -25,8 +25,7 @@ describe('mock xahaud tests', function () {
 | 
			
		||||
    await assertRejects(
 | 
			
		||||
      testContext.client.request({
 | 
			
		||||
        command: 'account_info',
 | 
			
		||||
        account:
 | 
			
		||||
          xahaudFixtures.account_info.normal.result.account_data.Account,
 | 
			
		||||
        account: xahaudFixtures.account_info.normal.result.account_data.Account,
 | 
			
		||||
      }),
 | 
			
		||||
      XahaudError,
 | 
			
		||||
    )
 | 
			
		||||
@@ -51,8 +50,7 @@ describe('mock xahaud tests', function () {
 | 
			
		||||
    await assertRejects(
 | 
			
		||||
      testContext.client.request({
 | 
			
		||||
        command: 'account_info',
 | 
			
		||||
        account:
 | 
			
		||||
          xahaudFixtures.account_info.normal.result.account_data.Account,
 | 
			
		||||
        account: xahaudFixtures.account_info.normal.result.account_data.Account,
 | 
			
		||||
      }),
 | 
			
		||||
      XahaudError,
 | 
			
		||||
    )
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										62
									
								
								packages/xahau/test/models/claimReward.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								packages/xahau/test/models/claimReward.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { validate, ValidationError } from '../../src'
 | 
			
		||||
import { validateClaimReward } from '../../src/models/transactions/claimReward'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * ClaimReward Transaction Verification Testing.
 | 
			
		||||
 *
 | 
			
		||||
 * Providing runtime verification testing for each specific transaction type.
 | 
			
		||||
 */
 | 
			
		||||
describe('ClaimReward', function () {
 | 
			
		||||
  it(`verifies valid ClaimReward`, function () {
 | 
			
		||||
    const validClaim = {
 | 
			
		||||
      TransactionType: 'ClaimReward',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.doesNotThrow(() => validateClaimReward(validClaim))
 | 
			
		||||
    assert.doesNotThrow(() => validate(validClaim))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid Issuer`, function () {
 | 
			
		||||
    const invalidIssuer = {
 | 
			
		||||
      TransactionType: 'ClaimReward',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 1,
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateClaimReward(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'ClaimReward: Issuer must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'ClaimReward: Issuer must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ redundant Issuer`, function () {
 | 
			
		||||
    const invalidIssuer = {
 | 
			
		||||
      TransactionType: 'ClaimReward',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateClaimReward(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'ClaimReward: Account and Issuer cannot be the same',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'ClaimReward: Account and Issuer cannot be the same',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
@@ -25,8 +25,8 @@ describe('EscrowCancel', function () {
 | 
			
		||||
    assert.doesNotThrow(() => validate(cancel))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`Valid EscrowCancel with string OfferSequence`, function () {
 | 
			
		||||
    cancel.OfferSequence = '7'
 | 
			
		||||
  it(`Valid EscrowCancel with string EscrowID`, function () {
 | 
			
		||||
    cancel.EscrowID = '7'
 | 
			
		||||
 | 
			
		||||
    assert.doesNotThrow(() => validateEscrowCancel(cancel))
 | 
			
		||||
    assert.doesNotThrow(() => validate(cancel))
 | 
			
		||||
@@ -53,12 +53,12 @@ describe('EscrowCancel', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateEscrowCancel(cancel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCancel: missing OfferSequence',
 | 
			
		||||
      'EscrowCancel: must include OfferSequence or EscrowID',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(cancel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCancel: missing OfferSequence',
 | 
			
		||||
      'EscrowCancel: must include OfferSequence or EscrowID',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
@@ -91,4 +91,18 @@ describe('EscrowCancel', function () {
 | 
			
		||||
      'EscrowCancel: OfferSequence must be a number',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`Invalid EscrowID`, function () {
 | 
			
		||||
    cancel.EscrowID = 1
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateEscrowCancel(cancel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCancel: EscrowID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(cancel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCancel: EscrowID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -82,12 +82,12 @@ describe('EscrowCreate', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateEscrowCreate(escrow),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCreate: Amount must be a string',
 | 
			
		||||
      'EscrowCreate: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(escrow),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowCreate: Amount must be a string',
 | 
			
		||||
      'EscrowCreate: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -35,8 +35,8 @@ describe('EscrowFinish', function () {
 | 
			
		||||
    assert.doesNotThrow(() => validate(escrow))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`verifies valid EscrowFinish w/string OfferSequence`, function () {
 | 
			
		||||
    escrow.OfferSequence = '7'
 | 
			
		||||
  it(`verifies valid EscrowFinish w/string EscrowID`, function () {
 | 
			
		||||
    escrow.EscrowID = '7'
 | 
			
		||||
 | 
			
		||||
    assert.doesNotThrow(() => validateEscrowFinish(escrow))
 | 
			
		||||
    assert.doesNotThrow(() => validate(escrow))
 | 
			
		||||
@@ -72,6 +72,21 @@ describe('EscrowFinish', function () {
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid EscrowID`, function () {
 | 
			
		||||
    escrow.EscrowID = 1
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateEscrowFinish(escrow),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowFinish: EscrowID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(escrow),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'EscrowFinish: EscrowID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid Condition`, function () {
 | 
			
		||||
    escrow.Condition = 10
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										104
									
								
								packages/xahau/test/models/import.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								packages/xahau/test/models/import.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { validate, ValidationError } from '../../src'
 | 
			
		||||
import { validateImport } from '../../src/models/transactions/import'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Import Transaction Verification Testing.
 | 
			
		||||
 *
 | 
			
		||||
 * Providing runtime verification testing for each specific transaction type.
 | 
			
		||||
 */
 | 
			
		||||
describe('Import', function () {
 | 
			
		||||
  it(`verifies valid Import`, function () {
 | 
			
		||||
    const validImport = {
 | 
			
		||||
      TransactionType: 'Import',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Blob: 'DEADBEEF',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.doesNotThrow(() => validateImport(validImport))
 | 
			
		||||
    assert.doesNotThrow(() => validate(validImport))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ bad Issuer`, function () {
 | 
			
		||||
    const invalidIssuer = {
 | 
			
		||||
      TransactionType: 'Import',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 1,
 | 
			
		||||
      Blob: 'DEADBEEF',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateImport(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Issuer must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Issuer must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ redundant Issuer`, function () {
 | 
			
		||||
    const invalidIssuer = {
 | 
			
		||||
      TransactionType: 'Import',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Blob: 'DEADBEEF',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateImport(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Issuer and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Issuer and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ bad Blob`, function () {
 | 
			
		||||
    const invalidBlob = {
 | 
			
		||||
      TransactionType: 'Import',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
 | 
			
		||||
      Blob: 1,
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateImport(invalidBlob),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Blob must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidBlob),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Blob must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ bad Blob Hex`, function () {
 | 
			
		||||
    const invalidBlob = {
 | 
			
		||||
      TransactionType: 'Import',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Issuer: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
 | 
			
		||||
      Blob: 'ZZ11',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateImport(invalidBlob),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Blob must be in hex format',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidBlob),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Import: Blob must be in hex format',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										43
									
								
								packages/xahau/test/models/invoke.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								packages/xahau/test/models/invoke.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,43 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { validate, ValidationError } from '../../src'
 | 
			
		||||
import { validateInvoke } from '../../src/models/transactions/invoke'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Invoke Transaction Verification Testing.
 | 
			
		||||
 *
 | 
			
		||||
 * Providing runtime verification testing for each specific transaction type.
 | 
			
		||||
 */
 | 
			
		||||
describe('Invoke', function () {
 | 
			
		||||
  it(`verifies valid Invoke`, function () {
 | 
			
		||||
    const validInvoke = {
 | 
			
		||||
      TransactionType: 'Invoke',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Destination: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.doesNotThrow(() => validateInvoke(validInvoke))
 | 
			
		||||
    assert.doesNotThrow(() => validate(validInvoke))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ redundant Issuer`, function () {
 | 
			
		||||
    const invalidIssuer = {
 | 
			
		||||
      TransactionType: 'Invoke',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Destination: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateInvoke(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Invoke: Destination and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(invalidIssuer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Invoke: Destination and Account must not be equal',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
@@ -52,17 +52,31 @@ describe('OfferCancel', function () {
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ missing OfferSequence`, function () {
 | 
			
		||||
    delete offer.OfferSequence
 | 
			
		||||
  it(`throws w/ OfferID must be a string`, function () {
 | 
			
		||||
    offer.OfferID = 99
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateOfferCancel(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCancel: missing field OfferSequence',
 | 
			
		||||
      'OfferCancel: OfferID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCancel: missing field OfferSequence',
 | 
			
		||||
      'OfferCancel: OfferID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ missing OfferSequence and OfferID`, function () {
 | 
			
		||||
    delete offer.OfferSequence
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateOfferCancel(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCancel: must include OfferSequence or OfferID',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCancel: must include OfferSequence or OfferID',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 
 | 
			
		||||
@@ -140,12 +140,45 @@ describe('OfferCreate', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateOfferCreate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCreate: invalid OfferSequence',
 | 
			
		||||
      'OfferCreate: OfferSequence must be a number',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCreate: invalid OfferSequence',
 | 
			
		||||
      'OfferCreate: OfferSequence must be a number',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid OfferID`, function () {
 | 
			
		||||
    const offer = {
 | 
			
		||||
      Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
 | 
			
		||||
      Fee: '10',
 | 
			
		||||
      Flags: 0,
 | 
			
		||||
      LastLedgerSequence: 65453019,
 | 
			
		||||
      Sequence: 40949322,
 | 
			
		||||
      SigningPubKey:
 | 
			
		||||
        '03C48299E57F5AE7C2BE1391B581D313F1967EA2301628C07AC412092FDC15BA22',
 | 
			
		||||
      OfferID: 11,
 | 
			
		||||
      TakerGets: '12928290425',
 | 
			
		||||
      TakerPays: {
 | 
			
		||||
        currency: 'DSH',
 | 
			
		||||
        issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
 | 
			
		||||
        value: '43.11584856965009',
 | 
			
		||||
      },
 | 
			
		||||
      TransactionType: 'OfferCreate',
 | 
			
		||||
      TxnSignature:
 | 
			
		||||
        '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
 | 
			
		||||
    } as any
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateOfferCreate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCreate: OfferID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(offer),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'OfferCreate: OfferID must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -77,12 +77,12 @@ describe('PaymentChannelClaim', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validatePaymentChannelClaim(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelClaim: Balance must be a string',
 | 
			
		||||
      'PaymentChannelClaim: Balance must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelClaim: Balance must be a string',
 | 
			
		||||
      'PaymentChannelClaim: Balance must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
@@ -92,12 +92,12 @@ describe('PaymentChannelClaim', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validatePaymentChannelClaim(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelClaim: Amount must be a string',
 | 
			
		||||
      'PaymentChannelClaim: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelClaim: Amount must be a string',
 | 
			
		||||
      'PaymentChannelClaim: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -106,12 +106,12 @@ describe('PaymentChannelCreate', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validatePaymentChannelCreate(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelCreate: Amount must be a string',
 | 
			
		||||
      'PaymentChannelCreate: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelCreate: Amount must be a string',
 | 
			
		||||
      'PaymentChannelCreate: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -70,12 +70,12 @@ describe('PaymentChannelFund', function () {
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validatePaymentChannelFund(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelFund: Amount must be a string',
 | 
			
		||||
      'PaymentChannelFund: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(channel),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'PaymentChannelFund: Amount must be a string',
 | 
			
		||||
      'PaymentChannelFund: Amount must be an Amount',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										361
									
								
								packages/xahau/test/models/remit.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										361
									
								
								packages/xahau/test/models/remit.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,361 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { validate, ValidationError } from '../../src'
 | 
			
		||||
import { validateRemit } from '../../src/models/transactions/remit'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Remit Verification Testing.
 | 
			
		||||
 *
 | 
			
		||||
 * Providing runtime verification testing for each specific transaction type.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// eslint-disable-next-line max-statements -- ignore
 | 
			
		||||
describe('Remit', function () {
 | 
			
		||||
  let remit
 | 
			
		||||
 | 
			
		||||
  beforeEach(function () {
 | 
			
		||||
    remit = {
 | 
			
		||||
      TransactionType: 'Remit',
 | 
			
		||||
      Account: 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo',
 | 
			
		||||
      Destination: 'rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy',
 | 
			
		||||
      DestinationTag: 1,
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
      Flags: 0,
 | 
			
		||||
      LastLedgerSequence: 65953073,
 | 
			
		||||
      Sequence: 65923914,
 | 
			
		||||
      SigningPubKey:
 | 
			
		||||
        '02F9E33F16DF9507705EC954E3F94EB5F10D1FC4A354606DBE6297DBB1096FE654',
 | 
			
		||||
      TxnSignature:
 | 
			
		||||
        '3045022100E3FAE0EDEC3D6A8FF6D81BC9CF8288A61B7EEDE8071E90FF9314CB4621058D10022043545CF631706D700CEE65A1DB83EFDD185413808292D9D90F14D87D3DC2D8CB',
 | 
			
		||||
      Amounts: [
 | 
			
		||||
        { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
        {
 | 
			
		||||
          AmountEntry: {
 | 
			
		||||
            Amount: {
 | 
			
		||||
              currency: 'USD',
 | 
			
		||||
              issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
 | 
			
		||||
              value: '1',
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      ],
 | 
			
		||||
      MintURIToken: {
 | 
			
		||||
        URI: 'DEADBEEF',
 | 
			
		||||
        Digest:
 | 
			
		||||
          '6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
 | 
			
		||||
        Flags: 1,
 | 
			
		||||
      },
 | 
			
		||||
      URITokenIDs: [
 | 
			
		||||
        'AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE',
 | 
			
		||||
      ],
 | 
			
		||||
      InvoiceID:
 | 
			
		||||
        '6F1DFD1D0FE8A32E40E1F2C05CF1C15545BAB56B617F9C6C2D63A6B704BEF59B',
 | 
			
		||||
      Blob: 'DEADBEEF',
 | 
			
		||||
      Inform: 'rB5Ux4Lv2nRx6eeoAAsZmtctnBQ2LiACnk',
 | 
			
		||||
    } as any
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`verifies valid Remit`, function () {
 | 
			
		||||
    assert.doesNotThrow(() => validateRemit(remit))
 | 
			
		||||
    assert.doesNotThrow(() => validate(remit))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ Bad Amounts`, function () {
 | 
			
		||||
    remit.Amounts = {}
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Amounts must be an array',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Empty Amounts`, function () {
 | 
			
		||||
    remit.Amounts = []
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: empty field Amounts',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Max Amounts`, function () {
 | 
			
		||||
    remit.Amounts = [
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
    ]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: max field Amounts',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Duplicate native amounts`, function () {
 | 
			
		||||
    remit.Amounts = [
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
      { AmountEntry: { Amount: '1000' } },
 | 
			
		||||
    ]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Duplicate Native amounts are not allowed',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Duplicate amounts`, function () {
 | 
			
		||||
    remit.Amounts = [
 | 
			
		||||
      {
 | 
			
		||||
        AmountEntry: {
 | 
			
		||||
          Amount: {
 | 
			
		||||
            currency: 'USD',
 | 
			
		||||
            issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
 | 
			
		||||
            value: '1',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        AmountEntry: {
 | 
			
		||||
          Amount: {
 | 
			
		||||
            currency: 'USD',
 | 
			
		||||
            issuer: 'rcXY84C4g14iFp6taFXjjQGVeHqSCh9RX',
 | 
			
		||||
            value: '1',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    ]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Duplicate amounts are not allowed',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad URITokenIDs`, function () {
 | 
			
		||||
    remit.URITokenIDs = {}
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: invalid field URITokenIDs',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Empty URITokenIDs`, function () {
 | 
			
		||||
    remit.URITokenIDs = []
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: empty field URITokenIDs',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Empty URITokenIDs`, function () {
 | 
			
		||||
    remit.URITokenIDs = [
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
      'DEADBEEF',
 | 
			
		||||
    ]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: max field URITokenIDs',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Invalid URITokenID`, function () {
 | 
			
		||||
    remit.URITokenIDs = [1]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: URITokenID must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Invalid URITokenID`, function () {
 | 
			
		||||
    remit.URITokenIDs = ['ZZ11']
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: URITokenID must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Duplicate URITokenIDs`, function () {
 | 
			
		||||
    remit.URITokenIDs = ['DEADBEEF']
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: URITokenID must be exactly 64 characters',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Duplicate URITokenIDs`, function () {
 | 
			
		||||
    remit.URITokenIDs = [
 | 
			
		||||
      'AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE',
 | 
			
		||||
      'AED08CC1F50DD5F23A1948AF86153A3F3B7593E5EC77D65A02BB1B29E05AB6AE',
 | 
			
		||||
    ]
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Duplicate URITokens are not allowed',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  // it(`throws w/ Bad MintURIToken`, function () {
 | 
			
		||||
  //   remit.MintURIToken = []
 | 
			
		||||
  //   assert.throws(
 | 
			
		||||
  //     () => validateRemit(remit),
 | 
			
		||||
  //     ValidationError,
 | 
			
		||||
  //     'Remit: invalid MintURIToken',
 | 
			
		||||
  //   )
 | 
			
		||||
  // })
 | 
			
		||||
  it(`throws w/ Missing MintURIToken.URI`, function () {
 | 
			
		||||
    remit.MintURIToken = {}
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: missing field MintURIToken.URI',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad MintURIToken.URI`, function () {
 | 
			
		||||
    remit.MintURIToken = {
 | 
			
		||||
      URI: 1,
 | 
			
		||||
    }
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: MintURIToken.URI must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad MintURIToken.URI`, function () {
 | 
			
		||||
    remit.MintURIToken = {
 | 
			
		||||
      URI: 'ZZ11',
 | 
			
		||||
    }
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: MintURIToken.URI must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad MintURIToken Less than 1`, function () {
 | 
			
		||||
    remit.MintURIToken = {
 | 
			
		||||
      URI: '',
 | 
			
		||||
    }
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: MintURIToken.URI must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad MintURIToken.Digest`, function () {
 | 
			
		||||
    remit.MintURIToken = {
 | 
			
		||||
      URI: 'DEADBEEF',
 | 
			
		||||
      Digest: 1,
 | 
			
		||||
    }
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: MintURIToken.Digest must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad MintURIToken.Digest`, function () {
 | 
			
		||||
    remit.MintURIToken = {
 | 
			
		||||
      URI: 'DEADBEEF',
 | 
			
		||||
      Digest: 'ZZ11',
 | 
			
		||||
    }
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Digest must be exactly 64 characters',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad Destination`, function () {
 | 
			
		||||
    remit.Destination = 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Destination must not be equal to the account',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad Destination Tag`, function () {
 | 
			
		||||
    remit.DestinationTag = '1'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: DestinationTag must be a number',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad Inform`, function () {
 | 
			
		||||
    remit.Inform = 'rUn84CUYbNjRoTQ6mSW7BVJPSVJNLb1QLo'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Inform must not be equal to the account or destination',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad Blob Type`, function () {
 | 
			
		||||
    remit.Blob = 1
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Blob must be a string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
  it(`throws w/ Bad Blob Not Hex`, function () {
 | 
			
		||||
    remit.Blob = 'ZZ11'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateRemit(remit),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'Remit: Blob must be a hex string',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										141
									
								
								packages/xahau/test/models/setHook.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										141
									
								
								packages/xahau/test/models/setHook.test.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,141 @@
 | 
			
		||||
import { assert } from 'chai'
 | 
			
		||||
 | 
			
		||||
import { validate, ValidationError } from '../../src'
 | 
			
		||||
import { validateSetHook } from '../../src/models/transactions/setHook'
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SetHook Transaction Verification Testing.
 | 
			
		||||
 *
 | 
			
		||||
 * Providing runtime verification testing for each specific transaction type.
 | 
			
		||||
 */
 | 
			
		||||
describe('SetHook', function () {
 | 
			
		||||
  let setHookTx
 | 
			
		||||
 | 
			
		||||
  beforeEach(function () {
 | 
			
		||||
    setHookTx = {
 | 
			
		||||
      Flags: 0,
 | 
			
		||||
      TransactionType: 'SetHook',
 | 
			
		||||
      Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
 | 
			
		||||
      Fee: '12',
 | 
			
		||||
      Hooks: [
 | 
			
		||||
        {
 | 
			
		||||
          Hook: {
 | 
			
		||||
            CreateCode:
 | 
			
		||||
              '0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141B088040B7F004180080B7F0041A6080B7F004180080B7F0041B088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C41920841134180084112410010001A410022002000420010011A41012200200010021A200141106A240042000B0B2C01004180080B254163636570742E633A2043616C6C65642E00224163636570742E633A2043616C6C65642E22',
 | 
			
		||||
            HookOn:
 | 
			
		||||
              'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFF7',
 | 
			
		||||
            Flags: 1,
 | 
			
		||||
            HookApiVersion: 0,
 | 
			
		||||
            HookNamespace:
 | 
			
		||||
              '4FF9961269BF7630D32E15276569C94470174A5DA79FA567C0F62251AA9A36B9',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      ],
 | 
			
		||||
    } as any
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`verifies valid SetHook`, function () {
 | 
			
		||||
    assert.doesNotThrow(() => validateSetHook(setHookTx))
 | 
			
		||||
    assert.doesNotThrow(() => validate(setHookTx))
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid Hooks`, function () {
 | 
			
		||||
    setHookTx.Hooks = 'khgfgyhujk'
 | 
			
		||||
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateSetHook(setHookTx),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'SetHook: invalid Hooks',
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validate(setHookTx),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      'SetHook: invalid Hooks',
 | 
			
		||||
    )
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ maximum of 10 members allowed in Hooks`, function () {
 | 
			
		||||
    setHookTx.Hooks = []
 | 
			
		||||
    const hook = {
 | 
			
		||||
      Hook: {
 | 
			
		||||
        CreateCode:
 | 
			
		||||
          '0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141B088040B7F004180080B7F0041A6080B7F004180080B7F0041B088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C41920841134180084112410010001A410022002000420010011A41012200200010021A200141106A240042000B0B2C01004180080B254163636570742E633A2043616C6C65642E00224163636570742E633A2043616C6C65642E22',
 | 
			
		||||
        HookOn:
 | 
			
		||||
          'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFF7',
 | 
			
		||||
        Flags: 1,
 | 
			
		||||
        HookApiVersion: 0,
 | 
			
		||||
        HookNamespace:
 | 
			
		||||
          '4FF9961269BF7630D32E15276569C94470174A5DA79FA567C0F62251AA9A36B9',
 | 
			
		||||
      },
 | 
			
		||||
    }
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
    setHookTx.Hooks.push(hook)
 | 
			
		||||
 | 
			
		||||
    const errorMessage = 'SetHook: maximum of 10 hooks allowed in Hooks'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateSetHook(setHookTx),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      errorMessage,
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(() => validate(setHookTx), ValidationError, errorMessage)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid HookOn in Hooks`, function () {
 | 
			
		||||
    setHookTx.SignerQuorum = 2
 | 
			
		||||
    setHookTx.Hooks = [
 | 
			
		||||
      {
 | 
			
		||||
        Hook: {
 | 
			
		||||
          CreateCode:
 | 
			
		||||
            '0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141B088040B7F004180080B7F0041A6080B7F004180080B7F0041B088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C41920841134180084112410010001A410022002000420010011A41012200200010021A200141106A240042000B0B2C01004180080B254163636570742E633A2043616C6C65642E00224163636570742E633A2043616C6C65642E22',
 | 
			
		||||
          HookOn: '',
 | 
			
		||||
          Flags: 1,
 | 
			
		||||
          HookApiVersion: 0,
 | 
			
		||||
          HookNamespace:
 | 
			
		||||
            '4FF9961269BF7630D32E15276569C94470174A5DA79FA567C0F62251AA9A36B9',
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    ]
 | 
			
		||||
    const errorMessage =
 | 
			
		||||
      'SetHook: HookOn in Hook must be a 256-bit (32-byte) hexadecimal value'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateSetHook(setHookTx),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      errorMessage,
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(() => validate(setHookTx), ValidationError, errorMessage)
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  it(`throws w/ invalid HookNamespace in Hooks`, function () {
 | 
			
		||||
    setHookTx.SignerQuorum = 2
 | 
			
		||||
    setHookTx.Hooks = [
 | 
			
		||||
      {
 | 
			
		||||
        Hook: {
 | 
			
		||||
          CreateCode:
 | 
			
		||||
            '0061736D01000000011C0460057F7F7F7F7F017E60037F7F7E017E60027F7F017F60017F017E02230303656E76057472616365000003656E7606616363657074000103656E76025F670002030201030503010002062B077F0141B088040B7F004180080B7F0041A6080B7F004180080B7F0041B088040B7F0041000B7F0041010B07080104686F6F6B00030AC4800001C0800001017F230041106B220124002001200036020C41920841134180084112410010001A410022002000420010011A41012200200010021A200141106A240042000B0B2C01004180080B254163636570742E633A2043616C6C65642E00224163636570742E633A2043616C6C65642E22',
 | 
			
		||||
          HookOn:
 | 
			
		||||
            'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFF7',
 | 
			
		||||
          Flags: 1,
 | 
			
		||||
          HookApiVersion: 0,
 | 
			
		||||
          HookNamespace: '',
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    ]
 | 
			
		||||
    const errorMessage =
 | 
			
		||||
      'SetHook: HookNamespace in Hook must be a 256-bit (32-byte) hexadecimal value'
 | 
			
		||||
    assert.throws(
 | 
			
		||||
      () => validateSetHook(setHookTx),
 | 
			
		||||
      ValidationError,
 | 
			
		||||
      errorMessage,
 | 
			
		||||
    )
 | 
			
		||||
    assert.throws(() => validate(setHookTx), ValidationError, errorMessage)
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
@@ -168,7 +168,7 @@ describe('Models Utils', function () {
 | 
			
		||||
        AccountRootFlags.lsfDisallowIncomingCheck |
 | 
			
		||||
        AccountRootFlags.lsfDisallowIncomingPayChan |
 | 
			
		||||
        AccountRootFlags.lsfDisallowIncomingTrustline |
 | 
			
		||||
        AccountRootFlags.lsfAllowTrustLineClawback
 | 
			
		||||
        AccountRootFlags.lsfDisallowIncomingRemit
 | 
			
		||||
 | 
			
		||||
      const parsed = parseAccountRootFlags(accountRootFlags)
 | 
			
		||||
 | 
			
		||||
@@ -186,7 +186,7 @@ describe('Models Utils', function () {
 | 
			
		||||
          parsed.lsfDisallowIncomingCheck &&
 | 
			
		||||
          parsed.lsfDisallowIncomingPayChan &&
 | 
			
		||||
          parsed.lsfDisallowIncomingTrustline &&
 | 
			
		||||
          parsed.lsfAllowTrustLineClawback,
 | 
			
		||||
          parsed.lsfDisallowIncomingRemit,
 | 
			
		||||
      )
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
@@ -206,7 +206,7 @@ describe('Models Utils', function () {
 | 
			
		||||
      assert.isUndefined(parsed.lsfDisallowIncomingCheck)
 | 
			
		||||
      assert.isUndefined(parsed.lsfDisallowIncomingPayChan)
 | 
			
		||||
      assert.isUndefined(parsed.lsfDisallowIncomingTrustline)
 | 
			
		||||
      assert.isUndefined(parsed.lsfAllowTrustLineClawback)
 | 
			
		||||
      assert.isUndefined(parsed.lsfDisallowIncomingRemit)
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    it('parseTransactionFlags all enabled', function () {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user