Skip to content

Commit 0177d56

Browse files
V-Vaaljoelamouche
authored andcommitted
fix(tests): align scripts and tests with bytes badge descriptions
1 parent 7079d03 commit 0177d56

5 files changed

Lines changed: 21 additions & 27 deletions

File tree

the-guild-smart-contracts/script/CreateBadgesFromJson.s.sol

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ contract CreateBadgesFromJson is Script {
1313

1414
struct BadgeData {
1515
bytes32 name;
16-
bytes32 description;
16+
string description;
1717
}
1818

1919
function run() public {
@@ -76,7 +76,7 @@ contract CreateBadgesFromJson is Script {
7676
": ",
7777
vm.toString(badges[i].name),
7878
" - ",
79-
vm.toString(badges[i].description)
79+
badges[i].description
8080
)
8181
)
8282
);
@@ -126,20 +126,14 @@ contract CreateBadgesFromJson is Script {
126126
name := mload(add(nameBytes, 32))
127127
}
128128

129-
// Parse description with proper bytes32 conversion
130-
string memory descriptionStr = abi.decode(
129+
// Parse description as string
130+
string memory description = abi.decode(
131131
vm.parseJson(
132132
jsonData,
133133
string(abi.encodePacked(basePath, ".description"))
134134
),
135135
(string)
136136
);
137-
bytes32 description;
138-
bytes memory descriptionBytes = bytes(descriptionStr);
139-
require(descriptionBytes.length <= 32, "description too long");
140-
assembly {
141-
description := mload(add(descriptionBytes, 32))
142-
}
143137

144138
tempBadges[count] = BadgeData({
145139
name: name,
@@ -215,7 +209,7 @@ contract CreateBadgesFromJson is Script {
215209
continue;
216210
}
217211

218-
try badgeRegistry.createBadge(badge.name, badge.description) {
212+
try badgeRegistry.createBadge(badge.name, bytes(badge.description)) {
219213
console.log(
220214
string(
221215
abi.encodePacked(
@@ -226,7 +220,7 @@ contract CreateBadgesFromJson is Script {
226220
": ",
227221
vm.toString(badge.name),
228222
" - ",
229-
vm.toString(badge.description)
223+
badge.description
230224
)
231225
)
232226
);

the-guild-smart-contracts/script/FullDeploymentScript.s.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ contract FullDeploymentScript is Script {
5656
// Create some badges
5757
badgeRegistry.createBadge(
5858
bytes32("Rust"),
59-
bytes32("Know how to code in Rust")
59+
bytes("Know how to code in Rust")
6060
);
6161
badgeRegistry.createBadge(
6262
bytes32("Solidity"),
63-
bytes32("Know how to code in Solidity")
63+
bytes("Know how to code in Solidity")
6464
);
6565
badgeRegistry.createBadge(
6666
bytes32("TypeScript"),
67-
bytes32("Know how to code in TypeScript")
67+
bytes("Know how to code in TypeScript")
6868
);
6969

7070
// Deploy or attach to existing badge ranking via CREATE2

the-guild-smart-contracts/script/TheGuildBadgeRegistry.s.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,31 @@ contract TheGuildBadgeRegistryScript is Script {
1515
}();
1616
registry.createBadge(
1717
bytes32("Rust"),
18-
bytes32("Know how to code in Rust")
18+
bytes("Know how to code in Rust")
1919
);
2020
registry.createBadge(
2121
bytes32("Solidity"),
22-
bytes32("Know how to code in Solidity")
22+
bytes("Know how to code in Solidity")
2323
);
2424
registry.createBadge(
2525
bytes32("Python"),
26-
bytes32("Know how to code in Python")
26+
bytes("Know how to code in Python")
2727
);
2828
registry.createBadge(
2929
bytes32("JavaScript"),
30-
bytes32("Know how to code in JavaScript")
30+
bytes("Know how to code in JavaScript")
3131
);
3232
registry.createBadge(
3333
bytes32("TypeScript"),
34-
bytes32("Know how to code in TypeScript")
34+
bytes("Know how to code in TypeScript")
3535
);
3636
registry.createBadge(
3737
bytes32("React"),
38-
bytes32("Know how to code in React")
38+
bytes("Know how to code in React")
3939
);
4040
registry.createBadge(
4141
bytes32("Next.js"),
42-
bytes32("Know how to code in Next.js")
42+
bytes("Know how to code in Next.js")
4343
);
4444
vm.stopBroadcast();
4545
}

the-guild-smart-contracts/test/TheGuildAttestationResolver.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ contract TheGuildAttestationResolverTest is Test {
5151
// Ensure badge exists
5252
badgeRegistry.createBadge(
5353
bytes32("Rust"),
54-
bytes32("Know how to code in Rust")
54+
bytes("Know how to code in Rust")
5555
);
5656

5757
// Build attestation request
@@ -142,7 +142,7 @@ contract TheGuildAttestationResolverTest is Test {
142142
bytes32 schemaId = _registerSchema();
143143
badgeRegistry.createBadge(
144144
bytes32("Rust"),
145-
bytes32("Know how to code in Rust")
145+
bytes("Know how to code in Rust")
146146
);
147147

148148
vm.prank(attester);
@@ -171,7 +171,7 @@ contract TheGuildAttestationResolverTest is Test {
171171
bytes32 schemaId = _registerSchema();
172172
badgeRegistry.createBadge(
173173
bytes32("Rust"),
174-
bytes32("Know how to code in Rust")
174+
bytes("Know how to code in Rust")
175175
);
176176

177177
vm.prank(attester);
@@ -204,7 +204,7 @@ contract TheGuildAttestationResolverTest is Test {
204204
// Ensure badge exists
205205
badgeRegistry.createBadge(
206206
bytes32("Rust"),
207-
bytes32("Know how to code in Rust")
207+
bytes("Know how to code in Rust")
208208
);
209209

210210
AttestationRequest memory request = AttestationRequest({

the-guild-smart-contracts/test/TheGuildBadgeRanking.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ contract TheGuildBadgeRankingTest is Test {
1818
ranking = new TheGuildBadgeRanking(registry);
1919

2020
// Create a badge for testing
21-
registry.createBadge(badgeName, bytes32("A test badge"));
21+
registry.createBadge(badgeName, bytes("A test badge"));
2222
}
2323

2424
function test_UpvoteBadge_SucceedsAndEmitsEvent() public {

0 commit comments

Comments
 (0)