Skip to content

@gala-chain/testAPI


API > nft

Variable: nft

nft: object

Test data factory object containing all NFT-related test utilities. Provides both plain objects (for DTOs) and class instances (for chaincode testing).

Each property comes in two forms: - *Plain functions return plain JavaScript objects - Regular properties return class instances

Example

// Get plain object for DTO creation
const plainTokenClass = nft.tokenClassPlain();

// Get class instance for chaincode testing
const tokenClassInstance = nft.tokenClass();

Type declaration

tokenAllowance

tokenAllowance: CreateInstanceFn\<TokenAllowance>

tokenAllowancePlain

tokenAllowancePlain: (txUnixTime) => object

Creates a plain NFT token allowance object for testing. Grants transfer allowance from testUser2 to testUser1.

Parameters

txUnixTime: number

Unix timestamp for the allowance creation time

Returns

Plain object representing an NFT transfer allowance

additionalKey

additionalKey: string = "Elixir"

allowanceType

allowanceType: number = 1

category

category: string = "Item"

collection

collection: string = "TEST"

created

created: number = txUnixTime

expires

expires: number = 0

grantedBy

grantedBy: UserAlias = users.testUser2.identityKey

grantedTo

grantedTo: UserAlias = users.testUser1.identityKey

instance

instance: BigNumber

quantity

quantity: BigNumber

quantitySpent

quantitySpent: BigNumber

type

type: string = "Potion"

uses

uses: BigNumber

usesSpent

usesSpent: BigNumber

tokenBalance

tokenBalance: CreateInstanceFn\<TokenBalance>

tokenBalancePlain

tokenBalancePlain: () => object

Creates a factory function that returns a copy of the provided object.

Returns

Factory function that returns the object

additionalKey

additionalKey: string = "Elixir"

category

category: string = "Item"

collection

collection: string = "TEST"

inUseHolds

inUseHolds: never[] = []

instanceIds

instanceIds: BigNumber[]

lockedHolds

lockedHolds: never[] = []

owner

owner: UserAlias = users.testUser1.identityKey

quantity

quantity: BigNumber

type

type: string = "Potion"

Example

const factory = createPlainFn({ name: "test", value: 123 });
const obj = factory(); // { name: "test", value: 123 }

tokenBurn

tokenBurn: CreateInstanceFn\<TokenBurn>

tokenBurnCounterPlain

tokenBurnCounterPlain: (txUnixTime, timeKey, epoch, totalKnownBurnsCount) => object

Creates a plain NFT token burn counter object for testing. Extends burn record with additional metadata for tracking.

Parameters

txUnixTime: number

Unix timestamp for the burn transaction

timeKey: string

Time-based key for the burn counter

epoch: string

Epoch identifier for the burn

totalKnownBurnsCount: BigNumber

Total count of known burns

Returns

Plain object representing an NFT burn counter

additionalKey

additionalKey: string = "Elixir"

burnedBy

burnedBy: UserAlias = users.testUser1.identityKey

category

category: string = "Item"

collection

collection: string = "TEST"

created

created: number = txUnixTime

epoch

epoch: string

instance

instance: BigNumber

quantity

quantity: BigNumber

timeKey

timeKey: string

totalKnownBurnsCount

totalKnownBurnsCount: BigNumber

type

type: string = "Potion"

tokenBurnPlain

tokenBurnPlain: (txUnixTime) => object

Creates a plain NFT token burn record object for testing.

Parameters

txUnixTime: number

Unix timestamp for the burn transaction

Returns

Plain object representing an NFT burn

additionalKey

additionalKey: string = "Elixir"

burnedBy

burnedBy: UserAlias = users.testUser1.identityKey

category

category: string = "Item"

collection

collection: string = "TEST"

created

created: number = txUnixTime

instance

instance: BigNumber

quantity

quantity: BigNumber

type

type: string = "Potion"

tokenClass

tokenClass: CreateInstanceFn\<TokenClass>

tokenClassKey

tokenClassKey: CreateInstanceFn\<TokenClassKey>

tokenClassKeyPlain

tokenClassKeyPlain: () => object

Creates a factory function that returns a copy of the provided object.

Returns

Factory function that returns the object

additionalKey

additionalKey: string = "Elixir"

category

category: string = "Item"

collection

collection: string = "TEST"

type

type: string = "Potion"

Example

const factory = createPlainFn({ name: "test", value: 123 });
const obj = factory(); // { name: "test", value: 123 }

tokenClassPlain

tokenClassPlain: () => object

Creates a factory function that returns a copy of the provided object.

Returns

Factory function that returns the object

additionalKey

additionalKey: string = "Elixir"

authorities

authorities: UserAlias[]

category

category: string = "Item"

collection

collection: string = "TEST"

decimals

decimals: number = 0

description

description: string = "Generated via automated test suite."

image

image: string = "https://app.gala.games/test-image-placeholder-url.png"

isNonFungible

isNonFungible: boolean = true

maxCapacity

maxCapacity: BigNumber

maxSupply

maxSupply: BigNumber

name

name: string = "TestElixirNft"

network

network: string = GC_NETWORK_ID

symbol

symbol: string = "GALAXR"

totalBurned

totalBurned: BigNumber

totalMintAllowance

totalMintAllowance: BigNumber

totalSupply

totalSupply: BigNumber

type

type: string = "Potion"

Example

const factory = createPlainFn({ name: "test", value: 123 });
const obj = factory(); // { name: "test", value: 123 }

tokenInstance1

tokenInstance1: CreateInstanceFn\<TokenInstance>

tokenInstance1Key

tokenInstance1Key: CreateInstanceFn\<TokenInstanceKey>

tokenInstance1KeyPlain

tokenInstance1KeyPlain: () => object

Creates a factory function that returns a copy of the provided object.

Returns

Factory function that returns the object

additionalKey

additionalKey: string = "Elixir"

category

category: string = "Item"

collection

collection: string = "TEST"

instance

instance: BigNumber

type

type: string = "Potion"

Example

const factory = createPlainFn({ name: "test", value: 123 });
const obj = factory(); // { name: "test", value: 123 }

tokenInstance1Plain

tokenInstance1Plain: () => object

Creates a factory function that returns a copy of the provided object.

Returns

Factory function that returns the object

additionalKey

additionalKey: string = "Elixir"

category

category: string = "Item"

collection

collection: string = "TEST"

instance

instance: BigNumber

isNonFungible

isNonFungible: boolean = true

owner

owner: UserAlias = users.testUser1.identityKey

type

type: string = "Potion"

Example

const factory = createPlainFn({ name: "test", value: 123 });
const obj = factory(); // { name: "test", value: 123 }

tokenMintAllowance

tokenMintAllowance: CreateInstanceFn\<TokenAllowance>

tokenMintAllowancePlain

tokenMintAllowancePlain: (txUnixTime) => object

Creates a plain NFT mint allowance object for testing. Grants mint permission to admin user.

Parameters

txUnixTime: number

Unix timestamp for the allowance creation time

Returns

Plain object representing an NFT mint allowance

additionalKey

additionalKey: string = "Elixir"

allowanceType

allowanceType: number = 4

category

category: string = "Item"

collection

collection: string = "TEST"

created

created: number = txUnixTime

expires

expires: number = 0

grantedBy

grantedBy: UserAlias = users.admin.identityKey

grantedTo

grantedTo: UserAlias = users.admin.identityKey

instance

instance: BigNumber

quantity

quantity: BigNumber

quantitySpent

quantitySpent: BigNumber

type

type: string = "Potion"

uses

uses: BigNumber

usesSpent

usesSpent: BigNumber

Source

chain-test/src/data/nft.ts:212