mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 13:05:49 +00:00
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { Client } from '@transia/xrpl'
|
|
import { assert } from 'chai'
|
|
import _ from 'lodash'
|
|
|
|
import {
|
|
convertStringToHex,
|
|
getNFTokenID,
|
|
NFTokenMint,
|
|
TransactionMetadata,
|
|
} from '../../../src'
|
|
|
|
// how long before each test case times out
|
|
const TIMEOUT = 20000
|
|
|
|
describe('NFTokenMint', function () {
|
|
// TODO: Once we update our integration tests to handle NFTs, replace this client with XrplIntegrationTestContext
|
|
it(
|
|
'get NFTokenID',
|
|
async function () {
|
|
const client = new Client('wss://s.altnet.rippletest.net:51233/')
|
|
await client.connect()
|
|
|
|
const { wallet, balance: _balance } = await client.fundWallet()
|
|
|
|
const tx: NFTokenMint = {
|
|
TransactionType: 'NFTokenMint',
|
|
Account: wallet.address,
|
|
URI: convertStringToHex('https://www.google.com'),
|
|
NFTokenTaxon: 0,
|
|
}
|
|
try {
|
|
const response = await client.submitAndWait(tx, {
|
|
wallet,
|
|
})
|
|
assert.equal(response.type, 'response')
|
|
assert.equal(
|
|
(response.result.meta as TransactionMetadata).TransactionResult,
|
|
'tesSUCCESS',
|
|
)
|
|
|
|
const accountNFTs = await client.request({
|
|
command: 'account_nfts',
|
|
account: wallet.address,
|
|
})
|
|
|
|
const nftokenID =
|
|
getNFTokenID(response.result.meta as TransactionMetadata) ??
|
|
'undefined'
|
|
const accountHasNFT = accountNFTs.result.account_nfts.some(
|
|
(value) => value.NFTokenID === nftokenID,
|
|
)
|
|
|
|
assert.isTrue(
|
|
accountHasNFT,
|
|
`Expected to find an NFT with NFTokenID ${nftokenID} in account ${
|
|
wallet.address
|
|
} but did not find it.
|
|
\n\nHere's what was returned from 'account_nfts' for ${
|
|
wallet.address
|
|
}: ${JSON.stringify(accountNFTs)}`,
|
|
)
|
|
} finally {
|
|
await client.disconnect()
|
|
}
|
|
},
|
|
TIMEOUT,
|
|
)
|
|
})
|