Skip to content

Commit 3e49f8f

Browse files
committed
fix code formatting
1 parent 447f500 commit 3e49f8f

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
We are thrilled to have you join us in building unique discoveries with [Scroll Canvas](https://scroll.io/canvas), a new product designed for ecosystem projects to interact with users in a more tailored way.
88

9-
Try Canvas at https://scroll.io/canvas
9+
Try Canvas at [scroll.io/canvas](https://scroll.io/canvas)
1010

1111
## Overview
1212

docs/badge-examples.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ See the address in [Deployments](./deployments.md).
4444
string public staticTokenURI;
4545
4646
constructor(address resolver_, string memory tokenURI_) ScrollBadge(resolver_) {
47-
staticTokenURI = tokenURI_;
47+
staticTokenURI = tokenURI_;
4848
}
4949
5050
function badgeTokenURI(bytes32 /*uid*/ ) public pure override returns (string memory) {
@@ -62,17 +62,17 @@ Second, we check whether the user is minting for themselves or not.
6262
function onIssueBadge(Attestation calldata attestation) internal virtual override returns (bool) {
6363
if (!super.onIssueBadge(attestation)) {
6464
return false;
65-
}
65+
}
6666
6767
// singleton
6868
if (hasBadge(attestation.recipient)) {
6969
revert SingletonBadge();
70-
}
70+
}
7171
7272
// self-attest
7373
if (attestation.recipient != attestation.attester) {
7474
revert Unauthorized();
75-
}
75+
}
7676
7777
return true;
7878
}
@@ -119,33 +119,33 @@ contract ScrollBadgePermissionless is ScrollBadgeSelfAttest, ScrollBadgeEligibil
119119
string public staticTokenURI;
120120
121121
constructor(address resolver_, string memory tokenURI_) ScrollBadge(resolver_) {
122-
staticTokenURI = tokenURI_;
123-
}
122+
staticTokenURI = tokenURI_;
123+
}
124124
125125
/// @inheritdoc ScrollBadge
126126
function onIssueBadge(Attestation calldata attestation)
127127
internal
128128
virtual
129129
override (ScrollBadge, ScrollBadgeSelfAttest, ScrollBadgeSingleton)
130130
returns (bool)
131-
{
131+
{
132132
return super.onIssueBadge(attestation);
133-
}
133+
}
134134
135135
/// @inheritdoc ScrollBadge
136136
function onRevokeBadge(Attestation calldata attestation)
137137
internal
138138
virtual
139139
override (ScrollBadge, ScrollBadgeSelfAttest, ScrollBadgeSingleton)
140140
returns (bool)
141-
{
141+
{
142142
return super.onRevokeBadge(attestation);
143-
}
143+
}
144144
145145
/// @inheritdoc ScrollBadge
146146
function badgeTokenURI(bytes32 /*uid*/ ) public pure override returns (string memory) {
147147
return staticTokenURI;
148-
}
148+
}
149149
}
150150
```
151151

@@ -182,14 +182,14 @@ contract ScrollBadgeLevels is ScrollBadgeCustomPayload {
182182
/// @inheritdoc ScrollBadgeCustomPayload
183183
function getSchema() public pure override returns (string memory) {
184184
return BADGE_LEVELS_SCHEMA;
185-
}
185+
}
186186
187187
function getCurrentLevel(bytes32 uid) public view returns (uint8) {
188-
Attestation memory badge = getAndValidateBadge(uid);
188+
Attestation memory badge = getAndValidateBadge(uid);
189189
bytes memory payload = getPayload(badge);
190-
(uint8 level) = decodePayloadData(payload);
190+
(uint8 level) = decodePayloadData(payload);
191191
return level;
192-
}
192+
}
193193
}
194194
```
195195

@@ -200,11 +200,11 @@ function onIssueBadge(Attestation calldata attestation) internal override return
200200
if (!super.onIssueBadge(attestation)) return false;
201201
202202
bytes memory payload = getPayload(attestation);
203-
(uint8 level) = decodePayloadData(payload);
203+
(uint8 level) = decodePayloadData(payload);
204204
205205
if (level > 10) {
206206
revert InvalidLevel();
207-
}
207+
}
208208
209209
return true;
210210
}
@@ -214,20 +214,21 @@ You can also use the custom payload when constructing the token URI (in `badgeTo
214214
This is particularly useful for badges that generate different token URIs based on each badge using [Data URLs](https://developer.mozilla.org/en-US/docs/Web/URI/Schemes/data):
215215

216216
```solidity
217-
218217
/// @inheritdoc ScrollBadge
219-
function badgeTokenURI(bytes32 uid) public pure override returns (string memory) {
220-
uint8 level = getCurrentLevel(uid);
221-
string memory name = string(abi.encode("Level #", Strings.toString(level)));
222-
string memory description = "Level Badge";
223-
string memory image = ""; // IPFS, HTTP, or data URL
224-
string memory issuerName = "Scroll";
225-
"issuerName": "Scroll"
226-
string memory tokenUriJson = Base64.encode(
227-
abi.encodePacked('{"name":"', name, '", "description":"', description, ', "image": "', image, ', "issuerName": "', issuerName, '"}')
228-
);
229-
return string(abi.encodePacked("data:application/json;base64,", tokenUriJson));
230-
}
218+
function badgeTokenURI(bytes32 uid) public pure override returns (string memory) {
219+
uint8 level = getCurrentLevel(uid);
220+
221+
string memory name = string(abi.encode("Level #", Strings.toString(level)));
222+
string memory description = "Level Badge";
223+
string memory image = ""; // IPFS, HTTP, or data URL
224+
string memory issuerName = "Scroll";
225+
226+
string memory tokenUriJson = Base64.encode(
227+
abi.encodePacked('{"name":"', name, '", "description":"', description, ', "image": "', image, ', "issuerName": "', issuerName, '"}')
228+
);
229+
230+
return string(abi.encodePacked("data:application/json;base64,", tokenUriJson));
231+
}
231232
```
232233

233234
You can see the full example in [`ScrollBadgeLevels`](../src/badge/examples/ScrollBadgeLevels.sol).
@@ -258,31 +259,31 @@ contract ScrollBadgeSimple is ScrollBadgeAccessControl, ScrollBadgeSingleton {
258259
string public sharedTokenURI;
259260
260261
constructor(address resolver_, string memory tokenUri_) ScrollBadge(resolver_) {
261-
sharedTokenURI = tokenUri_;
262-
}
262+
sharedTokenURI = tokenUri_;
263+
}
263264
264265
/// @inheritdoc ScrollBadge
265266
function onIssueBadge(Attestation calldata attestation)
266267
internal
267268
override (ScrollBadgeAccessControl, ScrollBadgeSingleton)
268269
returns (bool)
269-
{
270+
{
270271
return super.onIssueBadge(attestation);
271-
}
272+
}
272273
273274
/// @inheritdoc ScrollBadge
274275
function onRevokeBadge(Attestation calldata attestation)
275276
internal
276277
override (ScrollBadgeAccessControl, ScrollBadgeSingleton)
277278
returns (bool)
278-
{
279+
{
279280
return super.onRevokeBadge(attestation);
280-
}
281+
}
281282
282283
/// @inheritdoc ScrollBadge
283284
function badgeTokenURI(bytes32 /*uid*/ ) public view override returns (string memory) {
284285
return sharedTokenURI;
285-
}
286+
}
286287
}
287288
```
288289

0 commit comments

Comments
 (0)