Skip to content

Commit

Permalink
Refactoring Wrapped NFT
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetson committed Nov 30, 2023
1 parent 154a099 commit 01913f1
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions packages/hardhat/contracts/WrappedNft.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,9 @@ contract WrappedNft is ERC721URIStorage, IERC721Receiver {

source = ERC721(_source);

// Over-write the name
try source.name() returns (string memory sourceName) {
_name = string.concat("Bridged ", sourceName);
} catch Error(string memory reason) {
revert(reason);
} catch {
revert();
}

// Over-write the symbol
try source.symbol() returns (string memory sourceSymbol) {
_symbol = string.concat("b", sourceSymbol);
} catch Error(string memory reason) {
revert(reason);
} catch {
revert();
}
// Over-write the name and symbol
_name = string.concat("Bridged ", originalName());
_symbol = string.concat("b", originalSymbol());

registrar = msg.sender;
}
Expand Down Expand Up @@ -107,6 +93,28 @@ contract WrappedNft is ERC721URIStorage, IERC721Receiver {
return _symbol;
}

function originalName() public view returns (string memory) {
// Over-write the name
try source.name() returns (string memory sourceName) {
return sourceName;
} catch Error(string memory reason) {
revert(reason);
} catch {
revert();
}
}

function originalSymbol() public view returns (string memory) {
// Over-write the name
try source.symbol() returns (string memory sourceSymbol) {
return sourceSymbol;
} catch Error(string memory reason) {
revert(reason);
} catch {
revert();
}
}

////////////////////////////////////////////////////////////////////////////
//
// It's a locked nft.
Expand Down

0 comments on commit 01913f1

Please sign in to comment.