Skip to content

Commit 1e5d0cc

Browse files
author
Yash Agrawal
committed
feat: minor fix
1 parent 6753e5b commit 1e5d0cc

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

contracts/SBTToken.sol

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,30 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
125125

126126
function _tokenURI(uint256 tokenId) private view returns (string memory) {
127127
SBTData memory sbtData = _sbtdata[tokenId];
128-
(bool stringDataPresent, StringAttribute[] memory stringAttributes) = sbtData.stringAttributesEncoded.length > 0
129-
? (true, abi.decode(sbtData.stringAttributesEncoded, (StringAttribute[])))
130-
: (false, new StringAttribute[](0));
131-
(bool numberDataPresent, NumberAttribute[] memory numberAttributes) = sbtData.numberAttributesEncoded.length > 0
132-
? (true, abi.decode(sbtData.numberAttributesEncoded, (NumberAttribute[])))
133-
: (false, new NumberAttribute[](0));
128+
(
129+
bool stringDataPresent,
130+
StringAttribute[] memory stringAttributes
131+
) = sbtData.stringAttributesEncoded.length > 0
132+
? (
133+
true,
134+
abi.decode(
135+
sbtData.stringAttributesEncoded,
136+
(StringAttribute[])
137+
)
138+
)
139+
: (false, new StringAttribute[](0));
140+
(
141+
bool numberDataPresent,
142+
NumberAttribute[] memory numberAttributes
143+
) = sbtData.numberAttributesEncoded.length > 0
144+
? (
145+
true,
146+
abi.decode(
147+
sbtData.numberAttributesEncoded,
148+
(NumberAttribute[])
149+
)
150+
)
151+
: (false, new NumberAttribute[](0));
134152

135153
string memory sbtAttributes = "";
136154

@@ -151,11 +169,7 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
151169
sbtAttributes = attributeInString;
152170
} else {
153171
sbtAttributes = string(
154-
abi.encodePacked(
155-
sbtAttributes,
156-
",",
157-
attributeInString
158-
)
172+
abi.encodePacked(sbtAttributes, ",", attributeInString)
159173
);
160174
}
161175
}
@@ -180,33 +194,20 @@ contract SBTToken is ISBTToken, ERC721EnumerableUpgradeable {
180194
if (i == 0) {
181195
if (stringDataPresent) {
182196
sbtAttributes = string(
183-
abi.encodePacked(
184-
",",
185-
attributeInString
186-
)
197+
abi.encodePacked(",", attributeInString)
187198
);
188199
} else {
189200
sbtAttributes = attributeInString;
190201
}
191202
} else {
192203
sbtAttributes = string(
193-
abi.encodePacked(
194-
sbtAttributes,
195-
",",
196-
attributeInString
197-
)
204+
abi.encodePacked(sbtAttributes, ",", attributeInString)
198205
);
199206
}
200207
}
201208
}
202209

203-
sbtAttributes = string(
204-
abi.encodePacked(
205-
"[",
206-
sbtAttributes,
207-
"]"
208-
)
209-
);
210+
sbtAttributes = string(abi.encodePacked("[", sbtAttributes, "]"));
210211

211212
return
212213
string(

0 commit comments

Comments
 (0)