Skip to content

Commit

Permalink
put mint functions on MasaSBTSelfSovereign
Browse files Browse the repository at this point in the history
  • Loading branch information
miquelcabot committed Nov 4, 2023
1 parent 67a90a5 commit 640890e
Show file tree
Hide file tree
Showing 7 changed files with 355 additions and 334 deletions.
91 changes: 0 additions & 91 deletions contracts/SoulboundCreditScore.sol
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import "./libraries/Errors.sol";
import "./tokens/MasaSBTSelfSovereign.sol";

/// @title Soulbound Credit Score
Expand Down Expand Up @@ -47,101 +46,11 @@ contract SoulboundCreditScore is MasaSBTSelfSovereign {

/* ========== MUTATIVE FUNCTIONS ======================================== */

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param identityId TokenId of the identity to mint the NFT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The NFT ID of the newly minted SBT
function mint(
address paymentMethod,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable returns (uint256) {
address to = soulboundIdentity.ownerOf(identityId);

uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(identityId, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit SoulboundCreditScoreMintedToIdentity(
tokenId,
identityId,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param to The address to mint the SBT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The SBT ID of the newly minted SBT
function mint(
address paymentMethod,
address to,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable returns (uint256) {
uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(to, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit SoulboundCreditScoreMintedToAddress(
tokenId,
to,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/* ========== VIEWS ===================================================== */

/* ========== PRIVATE FUNCTIONS ========================================= */

/* ========== MODIFIERS ================================================= */

/* ========== EVENTS ==================================================== */

event SoulboundCreditScoreMintedToIdentity(
uint256 tokenId,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);

event SoulboundCreditScoreMintedToAddress(
uint256 tokenId,
address to,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);
}
91 changes: 0 additions & 91 deletions contracts/SoulboundGreen.sol
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;

import "./libraries/Errors.sol";
import "./tokens/MasaSBTSelfSovereign.sol";

/// @title Soulbound Two-factor authentication (Green - 2FA)
Expand Down Expand Up @@ -47,101 +46,11 @@ contract SoulboundGreen is MasaSBTSelfSovereign {

/* ========== MUTATIVE FUNCTIONS ======================================== */

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param identityId TokenId of the identity to mint the NFT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The NFT ID of the newly minted SBT
function mint(
address paymentMethod,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable returns (uint256) {
address to = soulboundIdentity.ownerOf(identityId);

uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(identityId, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit SoulboundGreenMintedToIdentity(
tokenId,
identityId,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param to The address to mint the SBT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The SBT ID of the newly minted SBT
function mint(
address paymentMethod,
address to,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable returns (uint256) {
uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(to, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit SoulboundGreenMintedToAddress(
tokenId,
to,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/* ========== VIEWS ===================================================== */

/* ========== PRIVATE FUNCTIONS ========================================= */

/* ========== MODIFIERS ================================================= */

/* ========== EVENTS ==================================================== */

event SoulboundGreenMintedToIdentity(
uint256 tokenId,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);

event SoulboundGreenMintedToAddress(
uint256 tokenId,
address to,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);
}
90 changes: 0 additions & 90 deletions contracts/reference/ReferenceSBTSelfSovereign.sol
Expand Up @@ -46,78 +46,6 @@ contract ReferenceSBTSelfSovereign is MasaSBTSelfSovereign {

/* ========== MUTATIVE FUNCTIONS ======================================== */

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param identityId TokenId of the identity to mint the NFT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The SBT ID of the newly minted SBT
function mint(
address paymentMethod,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable virtual returns (uint256) {
address to = soulboundIdentity.ownerOf(identityId);

uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(identityId, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit MintedToIdentity(
tokenId,
identityId,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/// @notice Mints a new SBT
/// @dev The caller must have the MINTER role
/// @param paymentMethod Address of token that user want to pay
/// @param to The address to mint the SBT to
/// @param authorityAddress Address of the authority that signed the message
/// @param signatureDate Date of the signature
/// @param signature Signature of the message
/// @return The SBT ID of the newly minted SBT
function mint(
address paymentMethod,
address to,
address authorityAddress,
uint256 signatureDate,
bytes calldata signature
) external payable virtual returns (uint256) {
uint256 tokenId = _mintWithCounter(
paymentMethod,
to,
_hash(to, authorityAddress, signatureDate),
authorityAddress,
signature
);

emit MintedToAddress(
tokenId,
to,
authorityAddress,
signatureDate,
paymentMethod,
mintPrice
);

return tokenId;
}

/* ========== VIEWS ===================================================== */

function tokenURI(
Expand All @@ -133,22 +61,4 @@ contract ReferenceSBTSelfSovereign is MasaSBTSelfSovereign {
/* ========== MODIFIERS ================================================= */

/* ========== EVENTS ==================================================== */

event MintedToIdentity(
uint256 tokenId,
uint256 identityId,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);

event MintedToAddress(
uint256 tokenId,
address to,
address authorityAddress,
uint256 signatureDate,
address paymentMethod,
uint256 mintPrice
);
}

0 comments on commit 640890e

Please sign in to comment.