-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Srecko Smodis
committed
Jun 10, 2021
1 parent
12bcfd3
commit 9c20171
Showing
22 changed files
with
11,155 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.6.9 <0.8.0; | ||
|
||
import "protocol-contracts/transfer-proxy/contracts/roles/OperatorRole.sol"; | ||
import "@rarible/exchange-interfaces/contracts/IERC20TransferProxy.sol"; | ||
|
||
contract ERC20TransferProxy is IERC20TransferProxy, Initializable, OperatorRole { | ||
|
||
function __ERC20TransferProxy_init() external initializer { | ||
__Ownable_init(); | ||
} | ||
|
||
function erc20safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) override external onlyOperator { | ||
require(token.transferFrom(from, to, value), "failure while transferring"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.6.9 <0.8.0; | ||
|
||
import "protocol-contracts/transfer-proxy/contracts/roles/OperatorRole.sol"; | ||
import "@rarible/exchange-interfaces/contracts/INftTransferProxy.sol"; | ||
|
||
contract NftTransferProxy is INftTransferProxy, Initializable, OperatorRole { | ||
|
||
function __NftTransferProxy_init() external initializer { | ||
__Ownable_init(); | ||
} | ||
|
||
function erc721safeTransferFrom(IERC721Upgradeable token, address from, address to, uint256 tokenId) override external onlyOperator { | ||
token.safeTransferFrom(from, to, tokenId); | ||
} | ||
|
||
function erc1155safeTransferFrom(IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data) override external onlyOperator { | ||
token.safeTransferFrom(from, to, id, value, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.6.2 <0.8.0; | ||
|
||
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; | ||
|
||
contract ERC1155Image { | ||
using StringsUpgradeable for uint; | ||
|
||
// Optional mapping for token URIs | ||
mapping (uint256 => string) private _tokenImages; | ||
|
||
event Image(string value, uint256 indexed id); | ||
|
||
function image(uint id) external view virtual returns (string memory) { | ||
return _tokenImage(id); | ||
} | ||
|
||
function _tokenImage(uint256 tokenId) internal view virtual returns (string memory) { | ||
string memory _tokenImage = _tokenImages[tokenId]; | ||
return _tokenImage; | ||
} | ||
|
||
/** | ||
* @dev Sets `_tokenImage` as the tokenImage of `tokenId`. | ||
* | ||
* Requirements: | ||
* | ||
* - `tokenId` must exist. | ||
*/ | ||
function _setTokenImage(uint256 tokenId, string memory _image) internal virtual { | ||
_tokenImages[tokenId] = _image; | ||
emit Image(_tokenImage(tokenId), tokenId); | ||
} | ||
|
||
function _clearTokenImages(uint256 tokenId) internal { | ||
if (bytes(_tokenImages[tokenId]).length != 0) { | ||
delete _tokenImages[tokenId]; | ||
} | ||
} | ||
uint256[50] private __gap; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const {deployments, ethers} = hre; | ||
const {deploy} = deployments; | ||
|
||
const [deployer] = await ethers.getSigners(); | ||
const from = await deployer.getAddress(); | ||
|
||
const erc20_p = await deploy('ERC20TransferProxy', { | ||
from, | ||
gasLimit: 9500000, | ||
args: [], | ||
log: true | ||
}); | ||
|
||
const nft_p = await deploy('NftTransferProxy', { | ||
from, | ||
gasLimit: 9500000, | ||
args: [], | ||
log: true | ||
}); | ||
|
||
const erc20ProxyContract = new ethers.Contract(erc20_p.address, erc20_p.abi); | ||
await erc20ProxyContract.connect(deployer).__ERC20TransferProxy_init(); | ||
|
||
const nftProxyContract = new ethers.Contract(nft_p.address, nft_p.abi); | ||
await nftProxyContract.connect(deployer).__NftTransferProxy_init(); | ||
}; | ||
export default func; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { DeployFunction } from 'hardhat-deploy/types'; | ||
import { HardhatRuntimeEnvironment } from 'hardhat/types'; | ||
|
||
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { | ||
const {deployments, ethers} = hre; | ||
const {deploy} = deployments; | ||
|
||
const [deployer] = await ethers.getSigners(); | ||
const from = await deployer.getAddress(); | ||
|
||
const contract = await deploy('EcoFiExchangeV2', { | ||
from, | ||
gasLimit: 9500000, | ||
args: [], | ||
log: true | ||
}); | ||
|
||
const deps = await deployments.all(); | ||
const erc20_p = deps['ERC20TransferProxy']; | ||
const nft_p = deps['NftTransferProxy']; | ||
|
||
const exchangeContract = new ethers.Contract(contract.address, contract.abi); | ||
await exchangeContract.connect(deployer).__EcoExchangeV2_init( | ||
nft_p.address, | ||
erc20_p.address, | ||
'10000', | ||
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', | ||
deps['EcoFiERC1155'].address); | ||
|
||
const erc20ProxyContract = new ethers.Contract(erc20_p.address, erc20_p.abi); | ||
await erc20ProxyContract.connect(deployer).addOperator(contract.address); | ||
|
||
const nftProxyContract = new ethers.Contract(nft_p.address, nft_p.abi); | ||
await nftProxyContract.connect(deployer).addOperator(contract.address); | ||
}; | ||
export default func; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.