diff --git a/src/components/endpoints/Mint.vue b/src/components/endpoints/Mint.vue index 10310c4d..256a1bd8 100644 --- a/src/components/endpoints/Mint.vue +++ b/src/components/endpoints/Mint.vue @@ -19,7 +19,9 @@ import LSPSelect from '@/components/shared/LSPSelect.vue' import { TokenInfo, LSPType, padTokenId } from '@/helpers/tokenUtils' import useWeb3Connection from '@/compositions/useWeb3Connection' import useErc725 from '@/compositions/useErc725' -import LSP8IdentifiableDigitalAsset from '@erc725/erc725.js/schemas/LSP8IdentifiableDigitalAsset.json' +// TODO for now we use local schema before erc725 is fixed +// import LSP8IdentifiableDigitalAsset from '@erc725/erc725.js/schemas/LSP8IdentifiableDigitalAsset.json' +import LSP8IdentifiableDigitalAsset from '@/schema/LSP8IdentifiableDigitalAsset.json' import { isHex } from 'web3-utils' import { isAddress } from 'ethers/lib/utils' import { LSP8_TOKEN_ID_TYPES } from '@lukso/lsp-smart-contracts' @@ -108,6 +110,10 @@ const handleChangeTokenId = (event: Event) => { } break case LSP8_TOKEN_ID_TYPES.UNIQUE_ID: + if (!isHex(value)) { + return (tokenIdTypeError.value = 'Must be a byte string') + } + break case LSP8_TOKEN_ID_TYPES.HASH: if (value.length !== 66 || !isHex(value)) { return (tokenIdTypeError.value = 'Must be a 32byte hash') @@ -158,6 +164,7 @@ const mint = async () => { return } + // mint asset myToken.value = contract(LSP8Mintable.abi as any, mintToken.value) const tokenIdPadded = padTokenId(tokenIdType.value, tokenId.value) await myToken.value.methods @@ -170,6 +177,7 @@ const mint = async () => { console.log(JSON.stringify(payload, null, 2)) }) + // set asset metadata const tokenIdTypeData = LSP8TokenIdTypesData[tokenIdType.value] const metadataKey = ERC725.encodeKeyName( `LSP8MetadataTokenURI:<${tokenIdTypeData}>`, diff --git a/src/enums.ts b/src/enums.ts index b1e65758..1cb91f08 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -17,7 +17,7 @@ export const LSP8TokenIdTypes = [ export const LSP8TokenIdTypesData = [ 'uint256', 'string', - 'bytes32', + 'bytes', 'bytes32', 'address', ] diff --git a/src/helpers/tokenUtils.ts b/src/helpers/tokenUtils.ts index d38f4e2a..728686fa 100644 --- a/src/helpers/tokenUtils.ts +++ b/src/helpers/tokenUtils.ts @@ -331,8 +331,9 @@ export const padTokenId = (tokenIdType: number, tokenId: string) => { case LSP8_TOKEN_ID_TYPES.STRING: return rightPad(fromUtf8(tokenId), 64) case LSP8_TOKEN_ID_TYPES.UNIQUE_ID: - case LSP8_TOKEN_ID_TYPES.HASH: return rightPad(tokenId, 64) + case LSP8_TOKEN_ID_TYPES.HASH: + return tokenId // it's 32 bytes already case LSP8_TOKEN_ID_TYPES.ADDRESS: return leftPad(tokenId, 64) default: diff --git a/src/schema/LSP8IdentifiableDigitalAsset.json b/src/schema/LSP8IdentifiableDigitalAsset.json new file mode 100644 index 00000000..df2ab0b8 --- /dev/null +++ b/src/schema/LSP8IdentifiableDigitalAsset.json @@ -0,0 +1,51 @@ +[ + { + "name": "LSP8TokenIdType", + "key": "0x715f248956de7ce65e94d9d836bfead479f7e70d69b718d47bfe7b00e05b4fe4", + "keyType": "Singleton", + "valueType": "uint256", + "valueContent": "Number" + }, + { + "name": "LSP8MetadataTokenURI:
", + "key": "0x1339e76a390b7b9ec9010000
", + "keyType": "Mapping", + "valueType": "(bytes4,string)", + "valueContent": "(Bytes4,URI)" + }, + { + "name": "LSP8MetadataTokenURI:", + "key": "0x1339e76a390b7b9ec9010000", + "keyType": "Mapping", + "valueType": "(bytes4,string)", + "valueContent": "(Bytes4,URI)" + }, + { + "name": "LSP8MetadataTokenURI:", + "key": "0x1339e76a390b7b9ec9010000", + "keyType": "Mapping", + "valueType": "(bytes4,string)", + "valueContent": "(Bytes4,URI)" + }, + { + "name": "LSP8MetadataTokenURI:", + "key": "0x1339e76a390b7b9ec9010000", + "keyType": "Mapping", + "valueType": "(bytes4,string)", + "valueContent": "(Bytes4,URI)" + }, + { + "name": "LSP8TokenMetadataBaseURI", + "key": "0x1a7628600c3bac7101f53697f48df381ddc36b9015e7d7c9c5633d1252aa2843", + "keyType": "Singleton", + "valueType": "(bytes4,string)", + "valueContent": "(Bytes4,URI)" + }, + { + "name": "LSP8ReferenceContract", + "key": "0x708e7b881795f2e6b6c2752108c177ec89248458de3bf69d0d43480b3e5034e6", + "keyType": "Singleton", + "valueType": "(address,bytes32)", + "valueContent": "(Address,bytes32)" + } +]