Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Note: Keep safe your mnemonic.
MNEMONIC_KEY="blossom spatial metal assault riot bullet truck update forward brave slide way"

DEPLOYER_PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE

# Alchemy key used to deploy smart contracts (includes archive nodes)
# Key should be the full URL
ALCHEMY_MAINNET_KEY=add-your-alchemy-key-here
Expand All @@ -25,6 +27,9 @@ INFURA_KEY=add-your-infura-key-here
# Etherscan API key. This is used to verify smart contract in the Ethereum networks.
ETHERSCAN_API_KEY=add-your-etherscan-api-key-here

# Safe Global API key for proposing transactions to Gnosis Safe
SAFE_GLOBAL_API_KEY=add-your-safe-global-api-key-here

# CoinMarketCap API key used for gas reporting
CMC_KEY=add-your-coinmarketcap-key-here

Expand Down
67 changes: 67 additions & 0 deletions contracts/nft/distributor/entry/roles.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import { LibDiamond } from "../../../shared/libraries/LibDiamond.sol";
import { AccessControlEvents } from "../../../contexts/access-control/data.sol";
import "../../../contexts/access-control/storage/roles.sol";

contract ent_roles_NFTDistributor_v1 is sto_AccessControl_Roles {
/**
* @notice Checks if an account has a specific role.
* @param role Encoding of the role to check.
* @param account Address to check the {role} for.
*/
function hasRole(bytes32 role, address account)
external
view
returns (bool)
{
return accessControlRolesStore().roles[role].members[account];
}

/**
* @notice Grants an account a new role.
* @param role Encoding of the role to give.
* @param account Address to give the {role} to.
*
* Requirements:
* - Sender must be diamond owner.
*/
function grantRole(bytes32 role, address account) external {
LibDiamond.enforceIsContractOwner();
_grantRole(role, account);
}

/**
* @notice Removes a role from an account.
* @param role Encoding of the role to remove.
* @param account Address to remove the {role} from.
*
* Requirements:
* - Sender must be diamond owner.
*/
function revokeRole(bytes32 role, address account) external {
LibDiamond.enforceIsContractOwner();
_revokeRole(role, account);
}

/**
* @notice Removes a role from the sender.
* @param role Encoding of the role to remove.
*/
function renounceRole(bytes32 role) external {
_revokeRole(role, msg.sender);
}

function _grantRole(bytes32 role, address account) internal {
if (accessControlRolesStore().roles[role].members[account]) return;
accessControlRolesStore().roles[role].members[account] = true;
emit AccessControlEvents.RoleGranted(role, account, msg.sender);
}

function _revokeRole(bytes32 role, address account) internal {
if (!accessControlRolesStore().roles[role].members[account]) return;
accessControlRolesStore().roles[role].members[account] = false;
emit AccessControlEvents.RoleRevoked(role, account, msg.sender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,17 @@ contract NFTMainnetBridgingToPolygonFacet {
EnumerableSet.UintSet storage stakedNFTs = NFTLib.s().stakedNFTs[
msg.sender
];



// we are creating a new array so that we can overrwrite each element
// with a newTokenId.
if (EnumerableSet.contains(stakedNFTs, tokenId)) {
NFTLib.unstake(tokenId, msg.sender);
} else if (TELLER_NFT_V1.ownerOf(tokenId) == msg.sender) {
} else {

require(TELLER_NFT_V1.ownerOf(tokenId) == msg.sender);

TELLER_NFT_V1.transferFrom(msg.sender, address(this), tokenId);
}

Expand Down
30 changes: 30 additions & 0 deletions contracts/nft/polygon/PolyTellerNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,36 @@ contract PolyTellerNFT is TellerNFT_V2 {
_mintBatch(user, ids, amounts, data);
}

/**
* @notice Admin function to mint a token to an address.
* @param to Address to mint to.
* @param id Token ID to mint.
* @param amount Amount to mint.
*/
function adminMint(address to, uint256 id, uint256 amount) external onlyRole(ADMIN) {
_mint(to, id, amount, "");
}

/**
* @notice Admin function to burn a token from an address.
* @param from Address to burn from.
* @param id Token ID to burn.
* @param amount Amount to burn.
*/
function adminBurn(address from, uint256 id, uint256 amount) external onlyRole(ADMIN) {
_burn(from, id, amount);
}

/**
* @notice Admin function to batch burn tokens from an address.
* @param from Address to burn from.
* @param ids Token IDs to burn.
* @param amounts Amounts to burn.
*/
function adminBurnBatch(address from, uint256[] calldata ids, uint256[] calldata amounts) external onlyRole(ADMIN) {
_burnBatch(from, ids, amounts);
}

/**
* @notice called when user wants to withdraw single token back to root chain
* @dev Should burn user's tokens. This transaction will be verified when exiting on root chain
Expand Down
8 changes: 4 additions & 4 deletions deploy/markets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import colors from 'colors'
import { ContractTransaction } from 'ethers'
import { ContractTransactionResponse } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import { DeployFunction } from 'hardhat-deploy/types'

Expand Down Expand Up @@ -66,11 +66,11 @@ const initializeMarkets: DeployFunction = async (hre) => {
)
const collateralTokensToAdd = new Set(
market.collateralTokens.map((sym) =>
ethers.utils.getAddress(tokenAddresses.all[sym])
ethers.getAddress(tokenAddresses.all[sym])
)
)
for (const token of existingCollateralTokens) {
const tokenAddress = ethers.utils.getAddress(token)
const tokenAddress = ethers.getAddress(token)
if (collateralTokensToAdd.has(tokenAddress))
collateralTokensToAdd.delete(tokenAddress)
}
Expand Down Expand Up @@ -150,7 +150,7 @@ const initializeMarkets: DeployFunction = async (hre) => {

const waitAndLog = async (
msg: string,
tx: Promise<ContractTransaction>,
tx: Promise<ContractTransactionResponse>,
hre: HardhatRuntimeEnvironment
): Promise<void> => {
const receipt = await tx.then(({ wait }) => wait())
Expand Down
4 changes: 2 additions & 2 deletions deploy/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const deployNFT: DeployFunction = async (hre) => {
methodName: 'initialize',
args: [
// Initial minters
ethers.utils.defaultAbiCoder.encode(
ethers.AbiCoder.defaultAbiCoder().encode(
['address[]'],
[minterAddresses]
),
Expand All @@ -71,7 +71,7 @@ const deployNFT: DeployFunction = async (hre) => {
})

// Add the distributor as a minter if not already
const minterRole = ethers.utils.id('MINTER')
const minterRole = ethers.id('MINTER')
const distributorIsDictAdmin = await nft.hasRole(
minterRole,
nftDistributor.address
Expand Down
2 changes: 1 addition & 1 deletion deploy/platform-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const createPlatformSettings: DeployFunction = async (hre) => {
const { max, min, processOnDeployment, value } = setting

if (processOnDeployment) {
const keccak = ethers.utils.id(settingName)
const keccak = ethers.id(settingName)
log(`${settingName}: `, { indent: 2, star: true, nl: false })

// Check if the platform setting has already been created
Expand Down
16 changes: 8 additions & 8 deletions deploy/price-agg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const registerPriceAggregators: DeployFunction = async (hre) => {

const definedPricer = await priceAgg.chainlinkPricer()
if (
ethers.utils.getAddress(definedPricer) !=
ethers.utils.getAddress(chainlinkPricer.address)
ethers.getAddress(definedPricer) !=
ethers.getAddress(chainlinkPricer.address)
) {
await priceAgg.setChainlinkPricer(chainlinkPricer.address)
}
Expand Down Expand Up @@ -120,12 +120,12 @@ export const deployChainlinkENS = async (
})

const tld = 'eth'
const tldLabel = hre.ethers.utils.id(tld)
const tldNode = hre.ethers.utils.namehash(tld)
const tldLabel = hre.ethers.id(tld)
const tldNode = hre.ethers.namehash(tld)

const mainDomain = 'data'
const dataLabel = hre.ethers.utils.id(mainDomain)
const dataNode = hre.ethers.utils.namehash(`${mainDomain}.${tld}`)
const dataLabel = hre.ethers.id(mainDomain)
const dataNode = hre.ethers.namehash(`${mainDomain}.${tld}`)

if (ensRegistry.deployResult.newlyDeployed) {
await ensRegistry
Expand Down Expand Up @@ -161,8 +161,8 @@ export const deployChainlinkENS = async (
for (const config of Object.values(chainlink)) {
const chainlinkAggSubdomain = `${config.baseTokenName.toLowerCase()}-${config.quoteTokenName.toLowerCase()}`
const chainlinkAggDomain = `${chainlinkAggSubdomain}.${mainDomain}.${tld}`
const chainlinkAggLabel = hre.ethers.utils.id(chainlinkAggSubdomain)
const chainlinkAggNode = hre.ethers.utils.namehash(chainlinkAggDomain)
const chainlinkAggLabel = hre.ethers.id(chainlinkAggSubdomain)
const chainlinkAggNode = hre.ethers.namehash(chainlinkAggDomain)
const address = await resolver['addr(bytes32)'](chainlinkAggNode)

hre.log(`${colors.underline(chainlinkAggSubdomain)}: ${config.address}`, {
Expand Down
22 changes: 8 additions & 14 deletions deploy/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ const deployProtocol: DeployFunction = async (hre) => {
// Try to get deployment of TellerDiamond
await contracts.get('TellerDiamond')

// If deployment exists execute upgrade function
const executeMethod = 'init2'
const upgradeExecute = {
methodName: executeMethod,
args: [wrappedNativeToken, priceAggregator.address],
}

execute = upgradeExecute
// If deployment exists, skip execute (init2 already called)
execute = undefined
} catch {
// Else execute initialize function
const executeMethod = 'init'
Expand Down Expand Up @@ -274,8 +268,8 @@ const deployLoansEscrowBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(loansEscrowLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(loansEscrowLogic.address)
) {
log(`Upgrading Loans Escrow logic: ${loansEscrowLogic.address}`, {
indent: 5,
Expand Down Expand Up @@ -328,8 +322,8 @@ const deployCollateralEscrowBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(collateralEscrowLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(collateralEscrowLogic.address)
) {
log(`Upgrading Collateral Escrow logic: ${collateralEscrowLogic.address}`, {
indent: 5,
Expand Down Expand Up @@ -382,8 +376,8 @@ const deployTTokenBeacon = async (
// Check to see if we need to upgrade
const currentImpl = await beacon.implementation()
if (
ethers.utils.getAddress(currentImpl) !==
ethers.utils.getAddress(tTokenLogic.address)
ethers.getAddress(currentImpl) !==
ethers.getAddress(tTokenLogic.address)
) {
log(`Upgrading Teller Token logic: ${tTokenLogic.address}`, {
indent: 5,
Expand Down
Loading
Loading