From 1e21449b9c4796306b0739955caca92f601b293d Mon Sep 17 00:00:00 2001 From: Nicolas Vergez - PhyloFane Date: Mon, 1 Jan 2024 17:55:54 +0100 Subject: [PATCH 1/2] Update token identifier in OperationsTokenIdInput --- components/operations/operations-tokenid-input.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/operations/operations-tokenid-input.tsx b/components/operations/operations-tokenid-input.tsx index 48a12ae..5efef4a 100644 --- a/components/operations/operations-tokenid-input.tsx +++ b/components/operations/operations-tokenid-input.tsx @@ -13,7 +13,11 @@ export const OperationsTokenIdInput = ({ tokenType: CommonOpertationContentProps['tokenType']; description?: string; }) => { - const { tokens } = useCreatorTokens<{ ticker: string; isPaused: boolean }>({ + const { tokens } = useCreatorTokens<{ + ticker: string; + identifier: string; + isPaused: boolean; + }>({ tokenType, }); @@ -25,7 +29,7 @@ export const OperationsTokenIdInput = ({ options={ tokens ? tokens?.map((token) => ({ - value: token.ticker, + value: token.identifier, label: token.ticker, })) : [] From 459b4f7ad483fec951faeb28957d0a938c78f08f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20=C4=86wirko?= Date: Tue, 2 Jan 2024 12:03:00 +0100 Subject: [PATCH 2/2] fix regressions --- CHANGELOG.md | 4 +++ .../common/add-burn-sft-meta-quantity.tsx | 28 +++++++++---------- .../operations/common/change-properties.tsx | 19 +++++++++---- .../common/freeze-unfreeze-single.tsx | 28 +++++++++---------- .../operations/common/issue-nft-sft.tsx | 2 +- components/operations/common/wipe-single.tsx | 28 +++++++++---------- components/operations/constants.ts | 2 +- .../fungible-tokens/pause-unpause.tsx | 7 +++-- components/operations/meta-tokens/create.tsx | 8 +++--- components/operations/meta-tokens/send.tsx | 12 ++++---- .../non-fungible-tokens/add-nft-uris.tsx | 28 +++++++++---------- .../operations/non-fungible-tokens/burn.tsx | 28 +++++++++---------- .../non-fungible-tokens/change-attributes.tsx | 28 +++++++++---------- .../operations/non-fungible-tokens/create.tsx | 8 +++--- .../operations/non-fungible-tokens/send.tsx | 28 +++++++++---------- .../operations-tokenid-amount-input.tsx | 7 +++-- .../operations/operations-tokenid-input.tsx | 10 ++++--- .../semi-fungible-tokens/create.tsx | 8 +++--- .../operations/semi-fungible-tokens/send.tsx | 28 +++++++++---------- package.json | 2 +- 20 files changed, 164 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f989879..2906d38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### [0.12.1](https://github.com/xdevguild/buildo.dev/releases/tag/v0.12.1) (2024-01-02) +- important bugfix - the ticker is not always the same (API) as token/collection id +- important bugfix - fix property name + ### [0.12.0](https://github.com/xdevguild/buildo.dev/releases/tag/v0.12.0) (2024-01-01) - improve roles and properties selectors to make them less confusing - use tokenId selectors for fungible ids and collections diff --git a/components/operations/common/add-burn-sft-meta-quantity.tsx b/components/operations/common/add-burn-sft-meta-quantity.tsx index 7b081a5..e975f97 100644 --- a/components/operations/common/add-burn-sft-meta-quantity.tsx +++ b/components/operations/common/add-burn-sft-meta-quantity.tsx @@ -67,29 +67,29 @@ export const AddBurnQuantity = ({ }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new BigNumber(nonce)), new BigUIntValue(new BigNumber(quantity.trim())), ]; @@ -115,7 +115,7 @@ export const AddBurnQuantity = ({ close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/common/change-properties.tsx b/components/operations/common/change-properties.tsx index 1d09a62..4331316 100644 --- a/components/operations/common/change-properties.tsx +++ b/components/operations/common/change-properties.tsx @@ -35,7 +35,8 @@ const formSchema = z.object({ }); type CreatorTokens = { - ticker: string; + identifier: string; + collection: string; }; const propertiesMap: Record< @@ -103,11 +104,17 @@ export const ChangeProperties = ({ }; useEffect(() => { - const tokenData = tokens?.find((token) => token.ticker === watchTokenId); + const tokenData = tokens?.find( + (token) => (token.identifier || token.collection) === watchTokenId + ); if (tokenData) { const properties = propertiesMap[tokenType].filter((property) => { - const key = property.name as keyof typeof tokenData; - return tokenData[key]; + const key = property.name; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error + return tokenData[ + key === 'canTransferNFTCreateRole' ? 'canTransferNftCreateRole' : key + ]; }); form.setValue( 'properties', @@ -142,8 +149,8 @@ export const ChangeProperties = ({ options={ tokens ? tokens?.map((token) => ({ - value: token.ticker, - label: token.ticker, + value: token.identifier || token.collection, + label: token.identifier || token.collection, })) : [] } diff --git a/components/operations/common/freeze-unfreeze-single.tsx b/components/operations/common/freeze-unfreeze-single.tsx index 2995ca8..ae9fb36 100644 --- a/components/operations/common/freeze-unfreeze-single.tsx +++ b/components/operations/common/freeze-unfreeze-single.tsx @@ -66,29 +66,29 @@ export const FreezeUnfreezeSingle = ({ }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new BigNumber(nonce)), new AddressValue(new Address(accountAddressToFreeze.trim())), ]; @@ -114,7 +114,7 @@ export const FreezeUnfreezeSingle = ({ close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/common/issue-nft-sft.tsx b/components/operations/common/issue-nft-sft.tsx index 812d7c5..f2be8d4 100644 --- a/components/operations/common/issue-nft-sft.tsx +++ b/components/operations/common/issue-nft-sft.tsx @@ -116,7 +116,7 @@ export const IssueNftSft = ({ Issue a {tokenType} ESDT (Collection) - Every token is assigned a unique identification code(ticker) and + Every token is assigned a unique identification code (ticker) and metadata that distinguishes it from every other token. diff --git a/components/operations/common/wipe-single.tsx b/components/operations/common/wipe-single.tsx index 90ed5f7..0adcd65 100644 --- a/components/operations/common/wipe-single.tsx +++ b/components/operations/common/wipe-single.tsx @@ -57,29 +57,29 @@ export const WipeSingle = ({ const onSubmit = async ({ tokenId, account }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new BigNumber(nonce)), new AddressValue(new Address(account.trim())), ]; @@ -101,7 +101,7 @@ export const WipeSingle = ({ close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/constants.ts b/components/operations/constants.ts index 67aff28..b258ac3 100644 --- a/components/operations/constants.ts +++ b/components/operations/constants.ts @@ -58,7 +58,7 @@ export const esdtTokenProperties: TokenPropertyOrRole[] = [ export const sftNftTokenProperties: TokenPropertyOrRole[] = [ ...esdtTokenProperties, { - name: 'canTransferNftCreateRole', + name: 'canTransferNFTCreateRole', description: 'The token manager can transfer NFT/SFT/Meta creation role', }, ]; diff --git a/components/operations/fungible-tokens/pause-unpause.tsx b/components/operations/fungible-tokens/pause-unpause.tsx index 19fa2f0..d87e908 100644 --- a/components/operations/fungible-tokens/pause-unpause.tsx +++ b/components/operations/fungible-tokens/pause-unpause.tsx @@ -40,7 +40,8 @@ export const PauseUnpause = ({ triggerTx, close }: OperationContentProps) => { ); const { tokens } = useCreatorTokensAmount<{ - ticker: string; + identifier: string; + collection: string; isPaused: boolean; }>({ tokenType: 'fungible', @@ -116,8 +117,8 @@ export const PauseUnpause = ({ triggerTx, close }: OperationContentProps) => { options={ getTokens ? getTokens?.map((token) => ({ - value: token.ticker, - label: token.ticker, + value: token.identifier || token.collection, + label: token.identifier || token.collection, })) : [] } diff --git a/components/operations/meta-tokens/create.tsx b/components/operations/meta-tokens/create.tsx index 078bf42..0d2070a 100644 --- a/components/operations/meta-tokens/create.tsx +++ b/components/operations/meta-tokens/create.tsx @@ -26,7 +26,7 @@ import { useAccount } from '@useelven/core'; import { OperationsTokenIdInput } from '@/components/operations/operations-tokenid-input'; const formSchema = z.object({ - collectionTokenId: z.string().min(1, 'The field is required'), + tokenId: z.string().min(1, 'The field is required'), name: z.string().min(1, 'The field is required'), initialQuantity: z .string() @@ -47,7 +47,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { - collectionTokenId: '', + tokenId: '', name: '', initialQuantity: '', attributes: '', @@ -55,13 +55,13 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { }); const onSubmit = ({ - collectionTokenId, + tokenId, name, initialQuantity, attributes, }: z.infer) => { const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTokenId.trim()), + BytesValue.fromUTF8(tokenId.trim()), new BigUIntValue(new Bignumber(initialQuantity)), BytesValue.fromUTF8(name.trim()), BytesValue.fromUTF8(''), diff --git a/components/operations/meta-tokens/send.tsx b/components/operations/meta-tokens/send.tsx index 4833ace..14beca8 100644 --- a/components/operations/meta-tokens/send.tsx +++ b/components/operations/meta-tokens/send.tsx @@ -55,7 +55,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => { const metaEsdtOnNetwork = await axios.get<{ decimals: number; nonce: number; - ticker: string; + collection: string; }>(`${apiAddress}/nfts/${tokenId.trim()}`, { headers: { 'Content-Type': 'application/json', @@ -65,19 +65,19 @@ export const Send = ({ transfer, close }: OperationContentProps) => { const decimals = metaEsdtOnNetwork?.data?.decimals; const nonce = metaEsdtOnNetwork?.data?.nonce; - const collectionTicker = metaEsdtOnNetwork?.data?.ticker; + const collectionId = metaEsdtOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker || !decimals) { + if (!nonce || !collectionId || !decimals) { console.error( - "Can't read the nonce, collection ticker and number of decimals of the token, using MultiversX API!" + "Can't read the nonce, collection id and number of decimals of the token, using MultiversX API!" ); return; } transfer?.({ type: ScTokenTransferType.ESDTNFTTransfer, - tokenId: collectionTicker, + tokenId: collectionId, address: address.trim(), amount: TokenTransfer.metaEsdtFromAmount( tokenId.trim(), @@ -94,7 +94,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => { close(); } catch (e) { console.error( - "Can't read the nonce, collection ticker and number of decimals of the token, using MultiversX API!", + "Can't read the nonce, collection id and number of decimals of the token, using MultiversX API!", e ); } diff --git a/components/operations/non-fungible-tokens/add-nft-uris.tsx b/components/operations/non-fungible-tokens/add-nft-uris.tsx index b816c16..f8a8a3b 100644 --- a/components/operations/non-fungible-tokens/add-nft-uris.tsx +++ b/components/operations/non-fungible-tokens/add-nft-uris.tsx @@ -48,29 +48,29 @@ export const AddNftUris = ({ triggerTx, close }: OperationContentProps) => { const onSubmit = async ({ tokenId, uris }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new Bignumber(nonce)), ]; @@ -95,7 +95,7 @@ export const AddNftUris = ({ triggerTx, close }: OperationContentProps) => { close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/non-fungible-tokens/burn.tsx b/components/operations/non-fungible-tokens/burn.tsx index 0eeccb1..86bc70b 100644 --- a/components/operations/non-fungible-tokens/burn.tsx +++ b/components/operations/non-fungible-tokens/burn.tsx @@ -47,29 +47,29 @@ export const BurnNft = ({ triggerTx, close }: OperationContentProps) => { const onSubmit = async ({ tokenId }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new BigNumber(nonce)), new BigUIntValue(new BigNumber(1)), ]; @@ -91,7 +91,7 @@ export const BurnNft = ({ triggerTx, close }: OperationContentProps) => { close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/non-fungible-tokens/change-attributes.tsx b/components/operations/non-fungible-tokens/change-attributes.tsx index b5b5c52..b0536a1 100644 --- a/components/operations/non-fungible-tokens/change-attributes.tsx +++ b/components/operations/non-fungible-tokens/change-attributes.tsx @@ -60,29 +60,29 @@ export const ChangeAttributes = ({ }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const tokenOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = tokenOnNetwork?.data?.nonce; - const collectionTicker = tokenOnNetwork?.data?.ticker; + const collectionId = tokenOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTicker.trim()), + BytesValue.fromUTF8(collectionId.trim()), new BigUIntValue(new Bignumber(nonce)), BytesValue.fromUTF8(attributes.trim()), ]; @@ -107,7 +107,7 @@ export const ChangeAttributes = ({ close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/non-fungible-tokens/create.tsx b/components/operations/non-fungible-tokens/create.tsx index 23ecf4b..20598e3 100644 --- a/components/operations/non-fungible-tokens/create.tsx +++ b/components/operations/non-fungible-tokens/create.tsx @@ -26,7 +26,7 @@ import { useAccount } from '@useelven/core'; import { OperationsTokenIdInput } from '@/components/operations/operations-tokenid-input'; const formSchema = z.object({ - collectionTokenId: z.string().min(1, 'The field is required'), + tokenId: z.string().min(1, 'The field is required'), name: z.string().min(1, 'The field is required'), royalties: z .string() @@ -54,7 +54,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { - collectionTokenId: '', + tokenId: '', name: '', royalties: '', uris: '', @@ -64,7 +64,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { }); const onSubmit = ({ - collectionTokenId, + tokenId, name, royalties, uris, @@ -72,7 +72,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { hash, }: z.infer) => { const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTokenId.trim()), + BytesValue.fromUTF8(tokenId.trim()), new BigUIntValue(new Bignumber(1)), BytesValue.fromUTF8(name.trim()), new BigUIntValue(new Bignumber(Number(royalties) * 100 || 0)), diff --git a/components/operations/non-fungible-tokens/send.tsx b/components/operations/non-fungible-tokens/send.tsx index abc30a4..f4824c4 100644 --- a/components/operations/non-fungible-tokens/send.tsx +++ b/components/operations/non-fungible-tokens/send.tsx @@ -39,30 +39,30 @@ export const Send = ({ transfer, close }: OperationContentProps) => { const onSubmit = async ({ tokenId, address }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const nftOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const nftOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = nftOnNetwork?.data?.nonce; - const collectionTicker = nftOnNetwork?.data?.ticker; + const collectionId = nftOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } transfer?.({ type: ScTokenTransferType.ESDTNFTTransfer, - tokenId: collectionTicker, + tokenId: collectionId, address: address.trim(), amount: '1', gasLimit: transfersOperationsGasLimit, @@ -74,7 +74,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => { close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/components/operations/operations-tokenid-amount-input.tsx b/components/operations/operations-tokenid-amount-input.tsx index 6cb4ab4..328f023 100644 --- a/components/operations/operations-tokenid-amount-input.tsx +++ b/components/operations/operations-tokenid-amount-input.tsx @@ -14,7 +14,8 @@ export const OperationsTokenIdAmountInput = ({ onlyOwner?: boolean; }) => { const { tokens } = useCreatorTokensAmount<{ - ticker: string; + identifier: string; + collection: string; isPaused: boolean; }>({ tokenType, @@ -29,8 +30,8 @@ export const OperationsTokenIdAmountInput = ({ options={ tokens ? tokens?.map((token) => ({ - value: token.ticker, - label: token.ticker, + value: token.identifier || token.collection, + label: token.identifier || token.collection, })) : [] } diff --git a/components/operations/operations-tokenid-input.tsx b/components/operations/operations-tokenid-input.tsx index 5efef4a..9e4859f 100644 --- a/components/operations/operations-tokenid-input.tsx +++ b/components/operations/operations-tokenid-input.tsx @@ -9,13 +9,15 @@ import { useCreatorTokens } from '@/hooks/use-creator-tokens'; export const OperationsTokenIdInput = ({ tokenType, description = 'Please provide your token id', + name = 'tokenId', }: { tokenType: CommonOpertationContentProps['tokenType']; description?: string; + name?: string; }) => { const { tokens } = useCreatorTokens<{ - ticker: string; identifier: string; + collection: string; isPaused: boolean; }>({ tokenType, @@ -23,14 +25,14 @@ export const OperationsTokenIdInput = ({ return ( ({ - value: token.identifier, - label: token.ticker, + value: token.identifier || token.collection, + label: token.identifier || token.collection, })) : [] } diff --git a/components/operations/semi-fungible-tokens/create.tsx b/components/operations/semi-fungible-tokens/create.tsx index 0dc1e90..9e9a4e3 100644 --- a/components/operations/semi-fungible-tokens/create.tsx +++ b/components/operations/semi-fungible-tokens/create.tsx @@ -26,7 +26,7 @@ import { useAccount } from '@useelven/core'; import { OperationsTokenIdInput } from '@/components/operations/operations-tokenid-input'; const formSchema = z.object({ - collectionTokenId: z.string().min(1, 'The field is required'), + tokenId: z.string().min(1, 'The field is required'), name: z.string().min(1, 'The field is required'), initialQuantity: z .string() @@ -60,7 +60,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { const form = useForm>({ resolver: zodResolver(formSchema), defaultValues: { - collectionTokenId: '', + tokenId: '', name: '', initialQuantity: '', royalties: '', @@ -71,7 +71,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { }); const onSubmit = ({ - collectionTokenId, + tokenId, name, initialQuantity, royalties, @@ -80,7 +80,7 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => { hash, }: z.infer) => { const args: TypedValue[] = [ - BytesValue.fromUTF8(collectionTokenId.trim()), + BytesValue.fromUTF8(tokenId.trim()), new BigUIntValue(new Bignumber(initialQuantity.trim())), BytesValue.fromUTF8(name.trim()), new BigUIntValue(new Bignumber(Number(royalties) * 100 || 0)), diff --git a/components/operations/semi-fungible-tokens/send.tsx b/components/operations/semi-fungible-tokens/send.tsx index f4ff4a8..657239e 100644 --- a/components/operations/semi-fungible-tokens/send.tsx +++ b/components/operations/semi-fungible-tokens/send.tsx @@ -51,30 +51,30 @@ export const Send = ({ transfer, close }: OperationContentProps) => { }: z.infer) => { try { // TODO: replace with useElven useApiCall when ready to handle such cases - const sftOnNetwork = await axios.get<{ nonce: number; ticker: string }>( - `${apiAddress}/nfts/${tokenId.trim()}`, - { - headers: { - 'Content-Type': 'application/json', - Accept: 'application/json', - }, - } - ); + const sftOnNetwork = await axios.get<{ + nonce: number; + collection: string; + }>(`${apiAddress}/nfts/${tokenId.trim()}`, { + headers: { + 'Content-Type': 'application/json', + Accept: 'application/json', + }, + }); const nonce = sftOnNetwork?.data?.nonce; - const collectionTicker = sftOnNetwork?.data?.ticker; + const collectionId = sftOnNetwork?.data?.collection; // TODO: show the error in the transaction status modal - if (!nonce || !collectionTicker) { + if (!nonce || !collectionId) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!" + "Can't read the nonce or/and collection id of the token, using MultiversX API!" ); return; } transfer?.({ type: ScTokenTransferType.ESDTNFTTransfer, - tokenId: collectionTicker, + tokenId: collectionId, address: address.trim(), amount, gasLimit: transfersOperationsGasLimit, @@ -86,7 +86,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => { close(); } catch (e) { console.error( - "Can't read the nonce or/and collection ticker of the token, using MultiversX API!", + "Can't read the nonce or/and collection id of the token, using MultiversX API!", e ); } diff --git a/package.json b/package.json index 2e9e101..f4a1411 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "buildo.dev", - "version": "0.12.0", + "version": "0.12.1", "author": "Julian Ćwirko ", "license": "MIT", "homepage": "https://www.buildo.dev",