Skip to content

Commit

Permalink
fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
juliancwirko committed Jan 2, 2024
1 parent 1e21449 commit 459b4f7
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 149 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 14 additions & 14 deletions components/operations/common/add-burn-sft-meta-quantity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,29 @@ export const AddBurnQuantity = ({
}: z.infer<typeof formSchema>) => {
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())),
];
Expand All @@ -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
);
}
Expand Down
19 changes: 13 additions & 6 deletions components/operations/common/change-properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const formSchema = z.object({
});

type CreatorTokens = {
ticker: string;
identifier: string;
collection: string;
};

const propertiesMap: Record<
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
}))
: []
}
Expand Down
28 changes: 14 additions & 14 deletions components/operations/common/freeze-unfreeze-single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,29 +66,29 @@ export const FreezeUnfreezeSingle = ({
}: z.infer<typeof formSchema>) => {
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())),
];
Expand All @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/operations/common/issue-nft-sft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const IssueNftSft = ({
<DialogHeader className="p-8 pb-0">
<DialogTitle>Issue a {tokenType} ESDT (Collection)</DialogTitle>
<DialogDescription>
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.
</DialogDescription>
</DialogHeader>
Expand Down
28 changes: 14 additions & 14 deletions components/operations/common/wipe-single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,29 @@ export const WipeSingle = ({
const onSubmit = async ({ tokenId, account }: z.infer<typeof formSchema>) => {
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())),
];
Expand All @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion components/operations/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
];
Expand Down
7 changes: 4 additions & 3 deletions components/operations/fungible-tokens/pause-unpause.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const PauseUnpause = ({ triggerTx, close }: OperationContentProps) => {
);

const { tokens } = useCreatorTokensAmount<{
ticker: string;
identifier: string;
collection: string;
isPaused: boolean;
}>({
tokenType: 'fungible',
Expand Down Expand Up @@ -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,
}))
: []
}
Expand Down
8 changes: 4 additions & 4 deletions components/operations/meta-tokens/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -47,21 +47,21 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
collectionTokenId: '',
tokenId: '',
name: '',
initialQuantity: '',
attributes: '',
},
});

const onSubmit = ({
collectionTokenId,
tokenId,
name,
initialQuantity,
attributes,
}: z.infer<typeof formSchema>) => {
const args: TypedValue[] = [
BytesValue.fromUTF8(collectionTokenId.trim()),
BytesValue.fromUTF8(tokenId.trim()),
new BigUIntValue(new Bignumber(initialQuantity)),
BytesValue.fromUTF8(name.trim()),
BytesValue.fromUTF8(''),
Expand Down
12 changes: 6 additions & 6 deletions components/operations/meta-tokens/send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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(),
Expand All @@ -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
);
}
Expand Down
28 changes: 14 additions & 14 deletions components/operations/non-fungible-tokens/add-nft-uris.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,29 @@ export const AddNftUris = ({ triggerTx, close }: OperationContentProps) => {
const onSubmit = async ({ tokenId, uris }: z.infer<typeof formSchema>) => {
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)),
];

Expand All @@ -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
);
}
Expand Down
Loading

0 comments on commit 459b4f7

Please sign in to comment.