Skip to content

Commit

Permalink
feat: fix compatibility with latest change
Browse files Browse the repository at this point in the history
  • Loading branch information
zimpha committed Oct 15, 2024
1 parent ec2fd2e commit 4383f6a
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions src/badge/examples/ScrollEmployeeBadge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,34 @@ import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {ScrollBadge} from "../ScrollBadge.sol";
import {ScrollBadgeAccessControl} from "../extensions/ScrollBadgeAccessControl.sol";
import {ScrollBadgeCustomPayload} from "../extensions/ScrollBadgeCustomPayload.sol";
import {ScrollBadgeDefaultURI} from "../extensions/ScrollBadgeDefaultURI.sol";
import {ScrollBadgeNoExpiry} from "../extensions/ScrollBadgeNoExpiry.sol";
import {ScrollBadgeNonRevocable} from "../extensions/ScrollBadgeNonRevocable.sol";
import {ScrollBadgeSingleton} from "../extensions/ScrollBadgeSingleton.sol";

string constant SCROLL_EMPLOYEE_BADGE_SCHEMA = "uint256 employeeId,uint256 year";
string constant SCROLL_EMPLOYEE_BADGE_SCHEMA = "uint256 year";

function decodePayloadData(bytes memory data) pure returns (uint256,uint256) {
return abi.decode(data, (uint256,uint256));
function decodePayloadData(bytes memory data) pure returns (uint256) {
return abi.decode(data, (uint256));
}

/// @title ScrollEmployeeBadge
contract ScrollEmployeeBadge is
ScrollBadgeAccessControl,
ScrollBadgeCustomPayload,
ScrollBadgeDefaultURI,
ScrollBadgeNoExpiry,
ScrollBadgeNonRevocable,
ScrollBadgeSingleton
{
/// @notice The base token URI.
string public baseTokenURI;

constructor(address resolver_, string memory baseTokenURI_) ScrollBadge(resolver_) {
constructor(
address resolver_,
string memory baseTokenURI_,
string memory defaultBadgeURI_
) ScrollBadge(resolver_) ScrollBadgeDefaultURI(defaultBadgeURI_) {
baseTokenURI = baseTokenURI_;
}

Expand All @@ -41,9 +47,12 @@ contract ScrollEmployeeBadge is
}

/// @inheritdoc ScrollBadge
function onIssueBadge(Attestation calldata attestation)
function onIssueBadge(
Attestation calldata attestation
)
internal
override (
override(
ScrollBadge,
ScrollBadgeAccessControl,
ScrollBadgeCustomPayload,
ScrollBadgeNoExpiry,
Expand All @@ -56,22 +65,27 @@ contract ScrollEmployeeBadge is
}

/// @inheritdoc ScrollBadge
function onRevokeBadge(Attestation calldata attestation)
function onRevokeBadge(
Attestation calldata attestation
)
internal
override (
ScrollBadge, ScrollBadgeAccessControl, ScrollBadgeCustomPayload, ScrollBadgeNoExpiry, ScrollBadgeSingleton
override(
ScrollBadge,
ScrollBadgeAccessControl,
ScrollBadgeCustomPayload,
ScrollBadgeNoExpiry,
ScrollBadgeSingleton
)
returns (bool)
{
return super.onRevokeBadge(attestation);
}

/// @inheritdoc ScrollBadge
/// @dev This function is TBD
function badgeTokenURI(bytes32 uid) public view override returns (string memory) {
/// @inheritdoc ScrollBadgeDefaultURI
function getBadgeTokenURI(bytes32 uid) internal view override returns (string memory) {
Attestation memory attestation = getAndValidateBadge(uid);
bytes memory payload = getPayload(attestation);
(,uint256 year) = decodePayloadData(payload);
uint256 year = decodePayloadData(payload);

return string(abi.encodePacked(baseTokenURI, Strings.toString(year), ".json"));
}
Expand Down

0 comments on commit 4383f6a

Please sign in to comment.