Skip to content

Commit

Permalink
refactor: add constants for different types of LSP8 tokenIds
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Sep 18, 2023
1 parent 5e521f0 commit 36150f5
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 11 deletions.
15 changes: 15 additions & 0 deletions constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,21 @@ export const LSP1_TYPE_IDS = {
'0xe32c7debcb817925ba4883fdbfc52797187f28f73f860641dab1a68d9b32902c',
};

// LSP8
// ----------

/**
* @dev list of LSP8 Token ID types that can be used to create different types of NFTs.
* @see for details see: https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-8-IdentifiableDigitalAsset.md#lsp8tokenidtype
*/
export const LSP8_TOKENID_TYPES = {
NUMBER: 0,
STRING: 1,
UNIQUE_ID: 2,
HASH: 3,
ADDRESS: 4,
};

// LSP25
// ----------

Expand Down
8 changes: 8 additions & 0 deletions contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0x0b084a55ebf70fd3c06fd755269dac

// keccak256('LSP8Tokens_OperatorNotification')
bytes32 constant _TYPEID_LSP8_TOKENOPERATOR = 0x8a1c15a8799f71b547e08e2bcb2e85257e81b0a07eee2ce6712549eef1f00970;

// --- Types of token IDs

uint256 constant _LSP8_TOKENIDTYPE_NUMBER = 0;
uint256 constant _LSP8_TOKENIDTYPE_STRING = 1;
uint256 constant _LSP8_TOKENIDTYPE_UNIQUE_ID = 2;
uint256 constant _LSP8_TOKENIDTYPE_HASH = 3;
uint256 constant _LSP8_TOKENIDTYPE_ADDRESS = 4;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LSP8BurnableInitTester, LSP8BurnableInitTester__factory } from '../../.
import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour';

import { deployProxy } from '../../utils/fixtures';
import { LSP8_TOKENID_TYPES } from '../../../constants';

type LSP8BurnableInitTestContext = {
accounts: SignerWithAddress[];
Expand All @@ -26,7 +27,7 @@ describe('LSP8BurnableInit with proxy', () => {
name: 'LSP8 Burnable - deployed with constructor',
symbol: 'BRN',
newOwner: accounts[0].address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const lsp8BurnableImplementation = await new LSP8BurnableInitTester__factory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../LSP8CappedSupply.behaviour';

import { deployProxy } from '../../utils/fixtures';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8CappedSupplyInit with proxy', () => {
const buildTestContext = async () => {
Expand All @@ -18,7 +19,7 @@ describe('LSP8CappedSupplyInit with proxy', () => {
name: 'LSP8 capped supply - deployed with proxy',
symbol: 'CAP',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
tokenSupplyCap: ethers.BigNumber.from('2'),
};
const lsp8CappedSupplyInit = await new LSP8CappedSupplyInitTester__factory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../LSP8CompatibleERC721.behaviour';

import { deployProxy } from '../../utils/fixtures';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8CompatibleERC721Init with proxy', () => {
const buildTestContext = async (): Promise<LSP8CompatibleERC721TestContext> => {
Expand All @@ -31,7 +32,7 @@ describe('LSP8CompatibleERC721Init with proxy', () => {
name: 'LSP8 - deployed with constructor',
symbol: 'NFT',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
lsp4MetadataValue,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '../LSP8Enumerable.behaviour';

import { deployProxy } from '../../utils/fixtures';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8EnumerableInit with proxy', () => {
const buildTestContext = async () => {
Expand All @@ -17,7 +18,7 @@ describe('LSP8EnumerableInit with proxy', () => {
name: 'LSP8 Enumerable - deployed with proxy',
symbol: 'LSP8 NMRBL',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const LSP8EnumerableInit: LSP8EnumerableInitTester =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../LSP8Mintable.behaviour';

import { deployProxy } from '../../utils/fixtures';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8MintableInit with proxy', () => {
const buildTestContext = async () => {
Expand All @@ -18,7 +19,7 @@ describe('LSP8MintableInit with proxy', () => {
name: 'LSP8 Mintable - deployed with proxy',
symbol: 'MNTBL',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const LSP8MintableInit: LSP8MintableInit = await new LSP8MintableInit__factory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
import { LSP8BurnableTester, LSP8BurnableTester__factory } from '../../../types';

import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour';
import { LSP8_TOKENID_TYPES } from '../../../constants';

type LSP8BurnableTestContext = {
accounts: SignerWithAddress[];
Expand All @@ -23,7 +24,7 @@ describe('LSP8Burnable with constructor', () => {
name: 'LSP8 Burnable - deployed with constructor',
symbol: 'BRN',
newOwner: accounts[0].address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const lsp8Burnable = await new LSP8BurnableTester__factory(accounts[0]).deploy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LSP8CappedSupplyTestContext,
getNamedAccounts,
} from '../LSP8CappedSupply.behaviour';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8CappedSupply with constructor', () => {
const buildTestContext = async () => {
Expand All @@ -16,7 +17,7 @@ describe('LSP8CappedSupply with constructor', () => {
name: 'LSP8 capped supply - deployed with constructor',
symbol: 'CAP',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
tokenSupplyCap: ethers.BigNumber.from('2'),
};
const lsp8CappedSupply = await new LSP8CappedSupplyTester__factory(accounts.owner).deploy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
shouldInitializeLikeLSP8CompatibleERC721,
LSP8CompatibleERC721TestContext,
} from '../LSP8CompatibleERC721.behaviour';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8CompatibleERC721 with constructor', () => {
const buildTestContext = async (): Promise<LSP8CompatibleERC721TestContext> => {
Expand All @@ -25,7 +26,7 @@ describe('LSP8CompatibleERC721 with constructor', () => {
name: 'Compat for ERC721',
symbol: 'NFT',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
lsp4MetadataValue,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
LSP8EnumerableTestContext,
getNamedAccounts,
} from '../LSP8Enumerable.behaviour';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8Enumerable with constructor', () => {
const buildTestContext = async () => {
Expand All @@ -15,7 +16,7 @@ describe('LSP8Enumerable with constructor', () => {
name: 'LSP8 Enumerable - deployed with constructor',
symbol: 'LSP8 NMRBL',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const lsp8Enumerable: LSP8EnumerableTester = await new LSP8EnumerableTester__factory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
LS4DigitalAssetMetadataTestContext,
shouldBehaveLikeLSP4DigitalAssetMetadata,
} from '../../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.behaviour';
import { LSP8_TOKENID_TYPES } from '../../../constants';

describe('LSP8IdentifiableDigitalAsset with constructor', () => {
const buildTestContext = async (nftType: number): Promise<LSP8TestContext> => {
Expand Down Expand Up @@ -62,7 +63,7 @@ describe('LSP8IdentifiableDigitalAsset with constructor', () => {
name: 'LSP8 - deployed with constructor',
symbol: 'NFT',
owner: accounts[0],
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};
const contract = await new LSP8Tester__factory(accounts[0]).deploy(
deployParams.name,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LSP8_TOKENID_TYPES } from '../../../constants';
import { LSP8Mintable, LSP8Mintable__factory } from '../../../types';

import { shouldInitializeLikeLSP8 } from '../LSP8IdentifiableDigitalAsset.behaviour';
Expand All @@ -15,7 +16,7 @@ describe('LSP8Mintable with constructor', () => {
name: 'LSP8 Mintable - deployed with constructor',
symbol: 'LSP8 MNTBL',
newOwner: accounts.owner.address,
tokenIdType: 0,
tokenIdType: LSP8_TOKENID_TYPES.NUMBER,
};

const lsp8Mintable: LSP8Mintable = await new LSP8Mintable__factory(accounts.owner).deploy(
Expand Down

0 comments on commit 36150f5

Please sign in to comment.