Skip to content

Commit 459b4f7

Browse files
committed
fix regressions
1 parent 1e21449 commit 459b4f7

20 files changed

Lines changed: 164 additions & 149 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### [0.12.1](https://github.com/xdevguild/buildo.dev/releases/tag/v0.12.1) (2024-01-02)
2+
- important bugfix - the ticker is not always the same (API) as token/collection id
3+
- important bugfix - fix property name
4+
15
### [0.12.0](https://github.com/xdevguild/buildo.dev/releases/tag/v0.12.0) (2024-01-01)
26
- improve roles and properties selectors to make them less confusing
37
- use tokenId selectors for fungible ids and collections

components/operations/common/add-burn-sft-meta-quantity.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,29 @@ export const AddBurnQuantity = ({
6767
}: z.infer<typeof formSchema>) => {
6868
try {
6969
// TODO: replace with useElven useApiCall when ready to handle such cases
70-
const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>(
71-
`${apiAddress}/nfts/${tokenId.trim()}`,
72-
{
73-
headers: {
74-
'Content-Type': 'application/json',
75-
Accept: 'application/json',
76-
},
77-
}
78-
);
70+
const tokenOnNetwork = await axios.get<{
71+
nonce: number;
72+
collection: string;
73+
}>(`${apiAddress}/nfts/${tokenId.trim()}`, {
74+
headers: {
75+
'Content-Type': 'application/json',
76+
Accept: 'application/json',
77+
},
78+
});
7979

8080
const nonce = tokenOnNetwork?.data?.nonce;
81-
const collectionTicker = tokenOnNetwork?.data?.ticker;
81+
const collectionId = tokenOnNetwork?.data?.collection;
8282

8383
// TODO: show the error in the transaction status modal
84-
if (!nonce || !collectionTicker) {
84+
if (!nonce || !collectionId) {
8585
console.error(
86-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!"
86+
"Can't read the nonce or/and collection id of the token, using MultiversX API!"
8787
);
8888
return;
8989
}
9090

9191
const args: TypedValue[] = [
92-
BytesValue.fromUTF8(collectionTicker.trim()),
92+
BytesValue.fromUTF8(collectionId.trim()),
9393
new BigUIntValue(new BigNumber(nonce)),
9494
new BigUIntValue(new BigNumber(quantity.trim())),
9595
];
@@ -115,7 +115,7 @@ export const AddBurnQuantity = ({
115115
close();
116116
} catch (e) {
117117
console.error(
118-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!",
118+
"Can't read the nonce or/and collection id of the token, using MultiversX API!",
119119
e
120120
);
121121
}

components/operations/common/change-properties.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ const formSchema = z.object({
3535
});
3636

3737
type CreatorTokens = {
38-
ticker: string;
38+
identifier: string;
39+
collection: string;
3940
};
4041

4142
const propertiesMap: Record<
@@ -103,11 +104,17 @@ export const ChangeProperties = ({
103104
};
104105

105106
useEffect(() => {
106-
const tokenData = tokens?.find((token) => token.ticker === watchTokenId);
107+
const tokenData = tokens?.find(
108+
(token) => (token.identifier || token.collection) === watchTokenId
109+
);
107110
if (tokenData) {
108111
const properties = propertiesMap[tokenType].filter((property) => {
109-
const key = property.name as keyof typeof tokenData;
110-
return tokenData[key];
112+
const key = property.name;
113+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
114+
// @ts-expect-error
115+
return tokenData[
116+
key === 'canTransferNFTCreateRole' ? 'canTransferNftCreateRole' : key
117+
];
111118
});
112119
form.setValue(
113120
'properties',
@@ -142,8 +149,8 @@ export const ChangeProperties = ({
142149
options={
143150
tokens
144151
? tokens?.map((token) => ({
145-
value: token.ticker,
146-
label: token.ticker,
152+
value: token.identifier || token.collection,
153+
label: token.identifier || token.collection,
147154
}))
148155
: []
149156
}

components/operations/common/freeze-unfreeze-single.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,29 @@ export const FreezeUnfreezeSingle = ({
6666
}: z.infer<typeof formSchema>) => {
6767
try {
6868
// TODO: replace with useElven useApiCall when ready to handle such cases
69-
const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>(
70-
`${apiAddress}/nfts/${tokenId.trim()}`,
71-
{
72-
headers: {
73-
'Content-Type': 'application/json',
74-
Accept: 'application/json',
75-
},
76-
}
77-
);
69+
const tokenOnNetwork = await axios.get<{
70+
nonce: number;
71+
collection: string;
72+
}>(`${apiAddress}/nfts/${tokenId.trim()}`, {
73+
headers: {
74+
'Content-Type': 'application/json',
75+
Accept: 'application/json',
76+
},
77+
});
7878

7979
const nonce = tokenOnNetwork?.data?.nonce;
80-
const collectionTicker = tokenOnNetwork?.data?.ticker;
80+
const collectionId = tokenOnNetwork?.data?.collection;
8181

8282
// TODO: show the error in the transaction status modal
83-
if (!nonce || !collectionTicker) {
83+
if (!nonce || !collectionId) {
8484
console.error(
85-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!"
85+
"Can't read the nonce or/and collection id of the token, using MultiversX API!"
8686
);
8787
return;
8888
}
8989

9090
const args: TypedValue[] = [
91-
BytesValue.fromUTF8(collectionTicker.trim()),
91+
BytesValue.fromUTF8(collectionId.trim()),
9292
new BigUIntValue(new BigNumber(nonce)),
9393
new AddressValue(new Address(accountAddressToFreeze.trim())),
9494
];
@@ -114,7 +114,7 @@ export const FreezeUnfreezeSingle = ({
114114
close();
115115
} catch (e) {
116116
console.error(
117-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!",
117+
"Can't read the nonce or/and collection id of the token, using MultiversX API!",
118118
e
119119
);
120120
}

components/operations/common/issue-nft-sft.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const IssueNftSft = ({
116116
<DialogHeader className="p-8 pb-0">
117117
<DialogTitle>Issue a {tokenType} ESDT (Collection)</DialogTitle>
118118
<DialogDescription>
119-
Every token is assigned a unique identification code(ticker) and
119+
Every token is assigned a unique identification code (ticker) and
120120
metadata that distinguishes it from every other token.
121121
</DialogDescription>
122122
</DialogHeader>

components/operations/common/wipe-single.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,29 @@ export const WipeSingle = ({
5757
const onSubmit = async ({ tokenId, account }: z.infer<typeof formSchema>) => {
5858
try {
5959
// TODO: replace with useElven useApiCall when ready to handle such cases
60-
const tokenOnNetwork = await axios.get<{ nonce: number; ticker: string }>(
61-
`${apiAddress}/nfts/${tokenId.trim()}`,
62-
{
63-
headers: {
64-
'Content-Type': 'application/json',
65-
Accept: 'application/json',
66-
},
67-
}
68-
);
60+
const tokenOnNetwork = await axios.get<{
61+
nonce: number;
62+
collection: string;
63+
}>(`${apiAddress}/nfts/${tokenId.trim()}`, {
64+
headers: {
65+
'Content-Type': 'application/json',
66+
Accept: 'application/json',
67+
},
68+
});
6969

7070
const nonce = tokenOnNetwork?.data?.nonce;
71-
const collectionTicker = tokenOnNetwork?.data?.ticker;
71+
const collectionId = tokenOnNetwork?.data?.collection;
7272

7373
// TODO: show the error in the transaction status modal
74-
if (!nonce || !collectionTicker) {
74+
if (!nonce || !collectionId) {
7575
console.error(
76-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!"
76+
"Can't read the nonce or/and collection id of the token, using MultiversX API!"
7777
);
7878
return;
7979
}
8080

8181
const args: TypedValue[] = [
82-
BytesValue.fromUTF8(collectionTicker.trim()),
82+
BytesValue.fromUTF8(collectionId.trim()),
8383
new BigUIntValue(new BigNumber(nonce)),
8484
new AddressValue(new Address(account.trim())),
8585
];
@@ -101,7 +101,7 @@ export const WipeSingle = ({
101101
close();
102102
} catch (e) {
103103
console.error(
104-
"Can't read the nonce or/and collection ticker of the token, using MultiversX API!",
104+
"Can't read the nonce or/and collection id of the token, using MultiversX API!",
105105
e
106106
);
107107
}

components/operations/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const esdtTokenProperties: TokenPropertyOrRole[] = [
5858
export const sftNftTokenProperties: TokenPropertyOrRole[] = [
5959
...esdtTokenProperties,
6060
{
61-
name: 'canTransferNftCreateRole',
61+
name: 'canTransferNFTCreateRole',
6262
description: 'The token manager can transfer NFT/SFT/Meta creation role',
6363
},
6464
];

components/operations/fungible-tokens/pause-unpause.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export const PauseUnpause = ({ triggerTx, close }: OperationContentProps) => {
4040
);
4141

4242
const { tokens } = useCreatorTokensAmount<{
43-
ticker: string;
43+
identifier: string;
44+
collection: string;
4445
isPaused: boolean;
4546
}>({
4647
tokenType: 'fungible',
@@ -116,8 +117,8 @@ export const PauseUnpause = ({ triggerTx, close }: OperationContentProps) => {
116117
options={
117118
getTokens
118119
? getTokens?.map((token) => ({
119-
value: token.ticker,
120-
label: token.ticker,
120+
value: token.identifier || token.collection,
121+
label: token.identifier || token.collection,
121122
}))
122123
: []
123124
}

components/operations/meta-tokens/create.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { useAccount } from '@useelven/core';
2626
import { OperationsTokenIdInput } from '@/components/operations/operations-tokenid-input';
2727

2828
const formSchema = z.object({
29-
collectionTokenId: z.string().min(1, 'The field is required'),
29+
tokenId: z.string().min(1, 'The field is required'),
3030
name: z.string().min(1, 'The field is required'),
3131
initialQuantity: z
3232
.string()
@@ -47,21 +47,21 @@ export const Create = ({ triggerTx, close }: OperationContentProps) => {
4747
const form = useForm<z.infer<typeof formSchema>>({
4848
resolver: zodResolver(formSchema),
4949
defaultValues: {
50-
collectionTokenId: '',
50+
tokenId: '',
5151
name: '',
5252
initialQuantity: '',
5353
attributes: '',
5454
},
5555
});
5656

5757
const onSubmit = ({
58-
collectionTokenId,
58+
tokenId,
5959
name,
6060
initialQuantity,
6161
attributes,
6262
}: z.infer<typeof formSchema>) => {
6363
const args: TypedValue[] = [
64-
BytesValue.fromUTF8(collectionTokenId.trim()),
64+
BytesValue.fromUTF8(tokenId.trim()),
6565
new BigUIntValue(new Bignumber(initialQuantity)),
6666
BytesValue.fromUTF8(name.trim()),
6767
BytesValue.fromUTF8(''),

components/operations/meta-tokens/send.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => {
5555
const metaEsdtOnNetwork = await axios.get<{
5656
decimals: number;
5757
nonce: number;
58-
ticker: string;
58+
collection: string;
5959
}>(`${apiAddress}/nfts/${tokenId.trim()}`, {
6060
headers: {
6161
'Content-Type': 'application/json',
@@ -65,19 +65,19 @@ export const Send = ({ transfer, close }: OperationContentProps) => {
6565

6666
const decimals = metaEsdtOnNetwork?.data?.decimals;
6767
const nonce = metaEsdtOnNetwork?.data?.nonce;
68-
const collectionTicker = metaEsdtOnNetwork?.data?.ticker;
68+
const collectionId = metaEsdtOnNetwork?.data?.collection;
6969

7070
// TODO: show the error in the transaction status modal
71-
if (!nonce || !collectionTicker || !decimals) {
71+
if (!nonce || !collectionId || !decimals) {
7272
console.error(
73-
"Can't read the nonce, collection ticker and number of decimals of the token, using MultiversX API!"
73+
"Can't read the nonce, collection id and number of decimals of the token, using MultiversX API!"
7474
);
7575
return;
7676
}
7777

7878
transfer?.({
7979
type: ScTokenTransferType.ESDTNFTTransfer,
80-
tokenId: collectionTicker,
80+
tokenId: collectionId,
8181
address: address.trim(),
8282
amount: TokenTransfer.metaEsdtFromAmount(
8383
tokenId.trim(),
@@ -94,7 +94,7 @@ export const Send = ({ transfer, close }: OperationContentProps) => {
9494
close();
9595
} catch (e) {
9696
console.error(
97-
"Can't read the nonce, collection ticker and number of decimals of the token, using MultiversX API!",
97+
"Can't read the nonce, collection id and number of decimals of the token, using MultiversX API!",
9898
e
9999
);
100100
}

0 commit comments

Comments
 (0)