Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

Commit

Permalink
feat: bulk check if tokens have been wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
kengoldfarb committed Nov 17, 2021
1 parent 4d3cfb3 commit c94200e
Show file tree
Hide file tree
Showing 18 changed files with 863 additions and 660 deletions.
2 changes: 1 addition & 1 deletion .diamond/4.json

Large diffs are not rendered by default.

441 changes: 0 additions & 441 deletions abi/contracts/Meem/facets/MeemBaseFacet.sol/MeemBaseFacet.json

Large diffs are not rendered by default.

481 changes: 461 additions & 20 deletions abi/contracts/Meem/facets/MeemQueryFacet.sol/MeemQueryFacet.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -169,38 +169,6 @@
"name": "PropertiesSet",
"type": "event"
},
{
"inputs": [],
"name": "childDepth",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "childrenOf",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -553,48 +521,5 @@
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "numChildrenOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "ownedChildrenOf",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
]
161 changes: 161 additions & 0 deletions abi/contracts/Meem/interfaces/MeemStandard.sol/IMeemQueryStandard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
[
{
"inputs": [],
"name": "childDepth",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "childrenOf",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "enum Chain",
"name": "chain",
"type": "uint8"
},
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "isNFTWrapped",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "numChildrenOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "ownedChildrenOf",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_owner",
"type": "address"
}
],
"name": "tokenIdsOfOwner",
"outputs": [
{
"internalType": "uint256[]",
"name": "tokenIds_",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "enum Chain",
"name": "chain",
"type": "uint8"
},
{
"internalType": "address",
"name": "contractAddress",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"internalType": "struct WrappedItem[]",
"name": "items",
"type": "tuple[]"
}
],
"name": "wrappedTokens",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
}
]
39 changes: 0 additions & 39 deletions contracts/Meem/facets/MeemBaseFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,4 @@ contract MeemBaseFacet is IMeemBaseStandard {
permissionType
);
}

function childrenOf(uint256 tokenId)
public
view
override
returns (uint256[] memory)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.children[tokenId];
}

function ownedChildrenOf(uint256 tokenId, address owner)
public
view
override
returns (uint256[] memory)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.childrenOwnerTokens[tokenId][owner];
}

function numChildrenOf(uint256 tokenId)
public
view
override
returns (uint256)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.children[tokenId].length;
}

function getMeem(uint256 tokenId) public view returns (Meem memory) {
return LibMeem.getMeem(tokenId);
}

function childDepth() public view override returns (uint256) {
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.childDepth;
}
}
49 changes: 45 additions & 4 deletions contracts/Meem/facets/MeemQueryFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,54 @@ import {LibERC721} from '../libraries/LibERC721.sol';
import {LibAppStorage} from '../storage/LibAppStorage.sol';
import {LibMeem, WrappedItem} from '../libraries/LibMeem.sol';
import {LibAccessControl} from '../libraries/LibAccessControl.sol';
import {Meem, Chain, MeemProperties, PropertyType, PermissionType, MeemPermission, Split, IMeemBaseStandard} from '../interfaces/MeemStandard.sol';
import {Meem, Chain, MeemProperties, PropertyType, PermissionType, MeemPermission, Split, IMeemQueryStandard} from '../interfaces/MeemStandard.sol';
import {IRoyaltiesProvider} from '../../royalties/IRoyaltiesProvider.sol';
import {LibPart} from '../../royalties/LibPart.sol';

contract MeemQueryFacet {
contract MeemQueryFacet is IMeemQueryStandard {
function childrenOf(uint256 tokenId)
public
view
override
returns (uint256[] memory)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.children[tokenId];
}

function ownedChildrenOf(uint256 tokenId, address owner)
public
view
override
returns (uint256[] memory)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.childrenOwnerTokens[tokenId][owner];
}

function numChildrenOf(uint256 tokenId)
public
view
override
returns (uint256)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.children[tokenId].length;
}

function getMeem(uint256 tokenId) public view returns (Meem memory) {
return LibMeem.getMeem(tokenId);
}

function childDepth() public view override returns (uint256) {
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
return s.childDepth;
}

function tokenIdsOfOwner(address _owner)
public
view
override
returns (uint256[] memory tokenIds_)
{
LibAppStorage.AppStorage storage s = LibAppStorage.diamondStorage();
Expand All @@ -24,13 +64,14 @@ contract MeemQueryFacet {
Chain chain,
address contractAddress,
uint256 tokenId
) public view returns (bool) {
) public view override returns (bool) {
return LibMeem.isNFTWrapped(chain, contractAddress, tokenId);
}

function isWrapped(WrappedItem[] memory items)
function wrappedTokens(WrappedItem[] memory items)
public
view
override
returns (uint256[] memory)
{
return LibMeem.wrappedTokens(items);
Expand Down
Loading

0 comments on commit c94200e

Please sign in to comment.