mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
firestore configs
This commit is contained in:
parent
8a3bedd324
commit
72a489ded8
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
.*
|
.*
|
||||||
node_modules
|
node_modules
|
||||||
|
build/
|
||||||
|
docs/
|
100
contracts/ERC721Tradable.sol
Normal file
100
contracts/ERC721Tradable.sol
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||||
|
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
|
||||||
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
||||||
|
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
||||||
|
import "@openzeppelin/contracts/utils/Strings.sol";
|
||||||
|
|
||||||
|
import "./common/meta-transactions/ContentMixin.sol";
|
||||||
|
import "./common/meta-transactions/NativeMetaTransaction.sol";
|
||||||
|
|
||||||
|
contract OwnableDelegateProxy {}
|
||||||
|
|
||||||
|
contract ProxyRegistry {
|
||||||
|
mapping(address => OwnableDelegateProxy) public proxies;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title ERC721Tradable
|
||||||
|
* ERC721Tradable - ERC721 contract that whitelists a trading address, and has minting functionality.
|
||||||
|
* @dev I added the _getCurrentTokenId manually, the rest of the contract is verbatim from https://github.com/ProjectOpenSea/opensea-creatures/blob/master/contracts/ERC721Tradable.sol
|
||||||
|
*/
|
||||||
|
abstract contract ERC721Tradable is ContextMixin, ERC721Enumerable, NativeMetaTransaction, Ownable {
|
||||||
|
using SafeMath for uint256;
|
||||||
|
|
||||||
|
address proxyRegistryAddress;
|
||||||
|
uint256 private _currentTokenId = 0;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
string memory _name,
|
||||||
|
string memory _symbol,
|
||||||
|
address _proxyRegistryAddress
|
||||||
|
) ERC721(_name, _symbol) {
|
||||||
|
proxyRegistryAddress = _proxyRegistryAddress;
|
||||||
|
_initializeEIP712(_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Mints a token to an address with a tokenURI.
|
||||||
|
* @param _to address of the future owner of the token
|
||||||
|
*/
|
||||||
|
function mintTo(address _to) internal {
|
||||||
|
uint256 newTokenId = _getNextTokenId();
|
||||||
|
_mint(_to, newTokenId);
|
||||||
|
_incrementTokenId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev calculates the next token ID based on value of _currentTokenId
|
||||||
|
* @return uint256 for the next token ID
|
||||||
|
*/
|
||||||
|
function _getNextTokenId() internal view returns (uint256) {
|
||||||
|
return _currentTokenId.add(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev increments the value of _currentTokenId
|
||||||
|
*/
|
||||||
|
function _incrementTokenId() private {
|
||||||
|
_currentTokenId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
function baseTokenURI() virtual public pure returns (string memory);
|
||||||
|
|
||||||
|
function tokenURI(uint256 _tokenId) override public pure returns (string memory) {
|
||||||
|
return string(abi.encodePacked(baseTokenURI(), Strings.toString(_tokenId)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
|
||||||
|
*/
|
||||||
|
function isApprovedForAll(address owner, address operator)
|
||||||
|
override
|
||||||
|
public
|
||||||
|
view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
// Whitelist OpenSea proxy contract for easy trading.
|
||||||
|
ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
|
||||||
|
if (address(proxyRegistry.proxies(owner)) == operator) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.isApprovedForAll(owner, operator);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea.
|
||||||
|
*/
|
||||||
|
function _msgSender()
|
||||||
|
internal
|
||||||
|
override
|
||||||
|
view
|
||||||
|
returns (address sender)
|
||||||
|
{
|
||||||
|
return ContextMixin.msgSender();
|
||||||
|
}
|
||||||
|
}
|
19
contracts/Migrations.sol
Normal file
19
contracts/Migrations.sol
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity >=0.4.22 <0.9.0;
|
||||||
|
|
||||||
|
contract Migrations {
|
||||||
|
address public owner = msg.sender;
|
||||||
|
uint public last_completed_migration;
|
||||||
|
|
||||||
|
modifier restricted() {
|
||||||
|
require(
|
||||||
|
msg.sender == owner,
|
||||||
|
"This function is restricted to the contract's owner"
|
||||||
|
);
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCompleted(uint completed) public restricted {
|
||||||
|
last_completed_migration = completed;
|
||||||
|
}
|
||||||
|
}
|
61
contracts/Rocketeer.sol
Normal file
61
contracts/Rocketeer.sol
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import "./ERC721Tradable.sol";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Rocketeer
|
||||||
|
* Rocketeer - a contract for my non-fungible rocketeers
|
||||||
|
*/
|
||||||
|
contract Rocketeer is ERC721Tradable {
|
||||||
|
|
||||||
|
// ///////////////////////////////
|
||||||
|
// Globals
|
||||||
|
// ///////////////////////////////
|
||||||
|
uint256 private ROCKETEER_MAX_SUPPLY = 5;
|
||||||
|
|
||||||
|
// Construct as Opensea tradable item
|
||||||
|
constructor(address _proxyRegistryAddress)
|
||||||
|
ERC721Tradable("Rocketeer", "RCT", _proxyRegistryAddress)
|
||||||
|
{
|
||||||
|
// Birth the genesis Rocketeer
|
||||||
|
spawnRocketeer( owner() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////
|
||||||
|
// Oracles
|
||||||
|
// ///////////////////////////////
|
||||||
|
|
||||||
|
// TODO: add Api data
|
||||||
|
// https://docs.opensea.io/docs/metadata-standards
|
||||||
|
function baseTokenURI() override public pure returns (string memory) {
|
||||||
|
return "https://us-central1-rocketeer-nft.cloudfunctions.net/testnetMetadata/rocketeer/";
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: add API link
|
||||||
|
// https://docs.opensea.io/docs/contract-level-metadata
|
||||||
|
function contractURI() public pure returns (string memory) {
|
||||||
|
return "https://us-central1-rocketeer-nft.cloudfunctions.net/collection";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////
|
||||||
|
// Minting
|
||||||
|
// ///////////////////////////////
|
||||||
|
|
||||||
|
function spawnRocketeer( address _to ) public onlyOwner {
|
||||||
|
|
||||||
|
uint256 nextTokenId = _getNextTokenId();
|
||||||
|
|
||||||
|
// No more than max supply
|
||||||
|
require( nextTokenId <= ROCKETEER_MAX_SUPPLY, "Maximum Rocketeer supply reached" );
|
||||||
|
|
||||||
|
// Every 42nd unit becomes a special edition, gas fees paid for but not owned by the minter
|
||||||
|
if( nextTokenId % 42 == 0 ) {
|
||||||
|
mintTo( owner() );
|
||||||
|
}
|
||||||
|
|
||||||
|
mintTo( _to );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
contracts/common/meta-transactions/ContentMixin.sol
Normal file
26
contracts/common/meta-transactions/ContentMixin.sol
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
abstract contract ContextMixin {
|
||||||
|
function msgSender()
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (address payable sender)
|
||||||
|
{
|
||||||
|
if (msg.sender == address(this)) {
|
||||||
|
bytes memory array = msg.data;
|
||||||
|
uint256 index = msg.data.length;
|
||||||
|
assembly {
|
||||||
|
// Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
|
||||||
|
sender := and(
|
||||||
|
mload(add(array, index)),
|
||||||
|
0xffffffffffffffffffffffffffffffffffffffff
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sender = payable(msg.sender);
|
||||||
|
}
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
}
|
77
contracts/common/meta-transactions/EIP712Base.sol
Normal file
77
contracts/common/meta-transactions/EIP712Base.sol
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import {Initializable} from "./Initializable.sol";
|
||||||
|
|
||||||
|
contract EIP712Base is Initializable {
|
||||||
|
struct EIP712Domain {
|
||||||
|
string name;
|
||||||
|
string version;
|
||||||
|
address verifyingContract;
|
||||||
|
bytes32 salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
string constant public ERC712_VERSION = "1";
|
||||||
|
|
||||||
|
bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256(
|
||||||
|
bytes(
|
||||||
|
"EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
bytes32 internal domainSeperator;
|
||||||
|
|
||||||
|
// supposed to be called once while initializing.
|
||||||
|
// one of the contracts that inherits this contract follows proxy pattern
|
||||||
|
// so it is not possible to do this in a constructor
|
||||||
|
function _initializeEIP712(
|
||||||
|
string memory name
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
initializer
|
||||||
|
{
|
||||||
|
_setDomainSeperator(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setDomainSeperator(string memory name) internal {
|
||||||
|
domainSeperator = keccak256(
|
||||||
|
abi.encode(
|
||||||
|
EIP712_DOMAIN_TYPEHASH,
|
||||||
|
keccak256(bytes(name)),
|
||||||
|
keccak256(bytes(ERC712_VERSION)),
|
||||||
|
address(this),
|
||||||
|
bytes32(getChainId())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDomainSeperator() public view returns (bytes32) {
|
||||||
|
return domainSeperator;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getChainId() public view returns (uint256) {
|
||||||
|
uint256 id;
|
||||||
|
assembly {
|
||||||
|
id := chainid()
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accept message hash and returns hash message in EIP712 compatible form
|
||||||
|
* So that it can be used to recover signer from signature signed using EIP712 formatted data
|
||||||
|
* https://eips.ethereum.org/EIPS/eip-712
|
||||||
|
* "\\x19" makes the encoding deterministic
|
||||||
|
* "\\x01" is the version byte to make it compatible to EIP-191
|
||||||
|
*/
|
||||||
|
function toTypedMessageHash(bytes32 messageHash)
|
||||||
|
internal
|
||||||
|
view
|
||||||
|
returns (bytes32)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
keccak256(
|
||||||
|
abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
13
contracts/common/meta-transactions/Initializable.sol
Normal file
13
contracts/common/meta-transactions/Initializable.sol
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
contract Initializable {
|
||||||
|
bool inited = false;
|
||||||
|
|
||||||
|
modifier initializer() {
|
||||||
|
require(!inited, "already inited");
|
||||||
|
_;
|
||||||
|
inited = true;
|
||||||
|
}
|
||||||
|
}
|
106
contracts/common/meta-transactions/NativeMetaTransaction.sol
Normal file
106
contracts/common/meta-transactions/NativeMetaTransaction.sol
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol";
|
||||||
|
import {EIP712Base} from "./EIP712Base.sol";
|
||||||
|
|
||||||
|
contract NativeMetaTransaction is EIP712Base {
|
||||||
|
using SafeMath for uint256;
|
||||||
|
bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256(
|
||||||
|
bytes(
|
||||||
|
"MetaTransaction(uint256 nonce,address from,bytes functionSignature)"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
event MetaTransactionExecuted(
|
||||||
|
address userAddress,
|
||||||
|
address payable relayerAddress,
|
||||||
|
bytes functionSignature
|
||||||
|
);
|
||||||
|
mapping(address => uint256) nonces;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Meta transaction structure.
|
||||||
|
* No point of including value field here as if user is doing value transfer then he has the funds to pay for gas
|
||||||
|
* He should call the desired function directly in that case.
|
||||||
|
*/
|
||||||
|
struct MetaTransaction {
|
||||||
|
uint256 nonce;
|
||||||
|
address from;
|
||||||
|
bytes functionSignature;
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeMetaTransaction(
|
||||||
|
address userAddress,
|
||||||
|
bytes memory functionSignature,
|
||||||
|
bytes32 sigR,
|
||||||
|
bytes32 sigS,
|
||||||
|
uint8 sigV
|
||||||
|
) public payable returns (bytes memory) {
|
||||||
|
MetaTransaction memory metaTx = MetaTransaction({
|
||||||
|
nonce: nonces[userAddress],
|
||||||
|
from: userAddress,
|
||||||
|
functionSignature: functionSignature
|
||||||
|
});
|
||||||
|
|
||||||
|
require(
|
||||||
|
verify(userAddress, metaTx, sigR, sigS, sigV),
|
||||||
|
"Signer and signature do not match"
|
||||||
|
);
|
||||||
|
|
||||||
|
// increase nonce for user (to avoid re-use)
|
||||||
|
nonces[userAddress] = nonces[userAddress].add(1);
|
||||||
|
|
||||||
|
emit MetaTransactionExecuted(
|
||||||
|
userAddress,
|
||||||
|
payable(msg.sender),
|
||||||
|
functionSignature
|
||||||
|
);
|
||||||
|
|
||||||
|
// Append userAddress and relayer address at the end to extract it from calling context
|
||||||
|
(bool success, bytes memory returnData) = address(this).call(
|
||||||
|
abi.encodePacked(functionSignature, userAddress)
|
||||||
|
);
|
||||||
|
require(success, "Function call not successful");
|
||||||
|
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hashMetaTransaction(MetaTransaction memory metaTx)
|
||||||
|
internal
|
||||||
|
pure
|
||||||
|
returns (bytes32)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
keccak256(
|
||||||
|
abi.encode(
|
||||||
|
META_TRANSACTION_TYPEHASH,
|
||||||
|
metaTx.nonce,
|
||||||
|
metaTx.from,
|
||||||
|
keccak256(metaTx.functionSignature)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNonce(address user) public view returns (uint256 nonce) {
|
||||||
|
nonce = nonces[user];
|
||||||
|
}
|
||||||
|
|
||||||
|
function verify(
|
||||||
|
address signer,
|
||||||
|
MetaTransaction memory metaTx,
|
||||||
|
bytes32 sigR,
|
||||||
|
bytes32 sigS,
|
||||||
|
uint8 sigV
|
||||||
|
) internal view returns (bool) {
|
||||||
|
require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER");
|
||||||
|
return
|
||||||
|
signer ==
|
||||||
|
ecrecover(
|
||||||
|
toTypedMessageHash(hashMetaTransaction(metaTx)),
|
||||||
|
sigV,
|
||||||
|
sigR,
|
||||||
|
sigS
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
22
firebase.json
Normal file
22
firebase.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"firestore": {
|
||||||
|
"rules": "firestore.rules",
|
||||||
|
"indexes": "firestore.indexes.json"
|
||||||
|
},
|
||||||
|
"functions": {
|
||||||
|
"predeploy": [
|
||||||
|
"npm --prefix \"$RESOURCE_DIR\" run lint"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hosting": {
|
||||||
|
"public": "docs",
|
||||||
|
"ignore": [
|
||||||
|
"firebase.json",
|
||||||
|
"**/.*",
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"storage": {
|
||||||
|
"rules": "storage.rules"
|
||||||
|
}
|
||||||
|
}
|
4
firestore.indexes.json
Normal file
4
firestore.indexes.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"indexes": [],
|
||||||
|
"fieldOverrides": []
|
||||||
|
}
|
8
firestore.rules
Normal file
8
firestore.rules
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
rules_version = '2';
|
||||||
|
service cloud.firestore {
|
||||||
|
match /databases/{database}/documents {
|
||||||
|
match /{document=**} {
|
||||||
|
allow read, write: if false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
migrations/1_initial_migration.js
Normal file
5
migrations/1_initial_migration.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
const Migrations = artifacts.require("Migrations");
|
||||||
|
|
||||||
|
module.exports = function (deployer) {
|
||||||
|
deployer.deploy(Migrations);
|
||||||
|
};
|
17
migrations/2_contract_migrations.js
Normal file
17
migrations/2_contract_migrations.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const Rocketeer = artifacts.require("./Rocketeer.sol");
|
||||||
|
|
||||||
|
module.exports = async (deployer, network, addresses) => {
|
||||||
|
|
||||||
|
// OpenSea proxy registry addresses for rinkeby and mainnet.
|
||||||
|
// Source: https://github.com/ProjectOpenSea/opensea-creatures
|
||||||
|
let proxyRegistryAddress = ""
|
||||||
|
if (network === 'rinkeby') {
|
||||||
|
proxyRegistryAddress = "0xf57b2c51ded3a29e6891aba85459d600256cf317"
|
||||||
|
} else {
|
||||||
|
proxyRegistryAddress = "0xa5409ec958c83c3f309868babaca7c86dcb077c1"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deploy rocketeer contract
|
||||||
|
await deployer.deploy(Rocketeer, proxyRegistryAddress, {gas: 5000000})
|
||||||
|
|
||||||
|
}
|
2309
package-lock.json
generated
Normal file
2309
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "rocketeer-nft",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"main": "truffle-config.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "Mentor Palokaj <mentor@palokaj.co> (http://github.com/actuallymentor)",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@openzeppelin/contracts": "^4.3.2",
|
||||||
|
"@truffle/hdwallet-provider": "^1.5.1",
|
||||||
|
"dotenv": "^10.0.0"
|
||||||
|
}
|
||||||
|
}
|
8
storage.rules
Normal file
8
storage.rules
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
rules_version = '2';
|
||||||
|
service firebase.storage {
|
||||||
|
match /b/{bucket}/o {
|
||||||
|
match /{allPaths=**} {
|
||||||
|
allow read, write: if request.auth!=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
127
truffle-config.js
Normal file
127
truffle-config.js
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* Use this file to configure your truffle project. It's seeded with some
|
||||||
|
* common settings for different networks and features like migrations,
|
||||||
|
* compilation and testing. Uncomment the ones you need or modify
|
||||||
|
* them to suit your project as necessary.
|
||||||
|
*
|
||||||
|
* More information about configuration can be found at:
|
||||||
|
*
|
||||||
|
* trufflesuite.com/docs/advanced/configuration
|
||||||
|
*
|
||||||
|
* To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider)
|
||||||
|
* to sign your transactions before they're sent to a remote public node. Infura accounts
|
||||||
|
* are available for free at: infura.io/register.
|
||||||
|
*
|
||||||
|
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
|
||||||
|
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
|
||||||
|
* phrase from a file you've .gitignored so it doesn't accidentally become public.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require('dotenv').config()
|
||||||
|
|
||||||
|
const HDWalletProvider = require('@truffle/hdwallet-provider');
|
||||||
|
|
||||||
|
// Copied from https://github.com/ProjectOpenSea/opensea-creatures
|
||||||
|
const MNEMONIC = process.env.MNEMONIC;
|
||||||
|
const NODE_API_KEY = process.env.INFURA_KEY || process.env.ALCHEMY_KEY;
|
||||||
|
const isInfura = !!process.env.INFURA_KEY;
|
||||||
|
|
||||||
|
const needsNodeAPI =
|
||||||
|
process.env.npm_config_argv &&
|
||||||
|
(process.env.npm_config_argv.includes("rinkeby") ||
|
||||||
|
process.env.npm_config_argv.includes("live"));
|
||||||
|
|
||||||
|
if ((!MNEMONIC || !NODE_API_KEY) && needsNodeAPI) {
|
||||||
|
console.error("Please set a mnemonic and ALCHEMY_KEY or INFURA_KEY.");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const rinkebyNodeUrl = isInfura
|
||||||
|
? "https://rinkeby.infura.io/v3/" + NODE_API_KEY
|
||||||
|
: "https://eth-rinkeby.alchemyapi.io/v2/" + NODE_API_KEY;
|
||||||
|
|
||||||
|
const mainnetNodeUrl = isInfura
|
||||||
|
? "https://mainnet.infura.io/v3/" + NODE_API_KEY
|
||||||
|
: "https://eth-mainnet.alchemyapi.io/v2/" + NODE_API_KEY;
|
||||||
|
|
||||||
|
|
||||||
|
// const fs = require('fs');
|
||||||
|
// const mnemonic = fs.readFileSync(".secret").toString().trim();
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* Networks define how you connect to your ethereum client and let you set the
|
||||||
|
* defaults web3 uses to send transactions. If you don't specify one truffle
|
||||||
|
* will spin up a development blockchain for you on port 9545 when you
|
||||||
|
* run `develop` or `test`. You can ask a truffle command to use a specific
|
||||||
|
* network from the command line, e.g
|
||||||
|
*
|
||||||
|
* $ truffle test --network <network-name>
|
||||||
|
*/
|
||||||
|
|
||||||
|
networks: {
|
||||||
|
development: {
|
||||||
|
host: "localhost",
|
||||||
|
port: 7545,
|
||||||
|
gas: 5000000,
|
||||||
|
network_id: "*", // Match any network id
|
||||||
|
},
|
||||||
|
rinkeby: {
|
||||||
|
provider: function () {
|
||||||
|
return new HDWalletProvider(MNEMONIC, rinkebyNodeUrl);
|
||||||
|
},
|
||||||
|
gas: 5000000,
|
||||||
|
network_id: 4,
|
||||||
|
},
|
||||||
|
live: {
|
||||||
|
network_id: 1,
|
||||||
|
provider: function () {
|
||||||
|
return new HDWalletProvider(MNEMONIC, mainnetNodeUrl);
|
||||||
|
},
|
||||||
|
gas: 5000000,
|
||||||
|
gasPrice: 5000000000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
// Set default mocha options here, use special reporters etc.
|
||||||
|
mocha: {
|
||||||
|
// timeout: 100000
|
||||||
|
},
|
||||||
|
|
||||||
|
// Configure your compilers
|
||||||
|
compilers: {
|
||||||
|
solc: {
|
||||||
|
version: "0.8.0", // Fetch exact version from solc-bin (default: truffle's version)
|
||||||
|
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
|
||||||
|
// settings: { // See the solidity docs for advice about optimization and evmVersion
|
||||||
|
// optimizer: {
|
||||||
|
// enabled: false,
|
||||||
|
// runs: 200
|
||||||
|
// },
|
||||||
|
// evmVersion: "byzantium"
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Truffle DB is currently disabled by default; to enable it, change enabled:
|
||||||
|
// false to enabled: true. The default storage location can also be
|
||||||
|
// overridden by specifying the adapter settings, as shown in the commented code below.
|
||||||
|
//
|
||||||
|
// NOTE: It is not possible to migrate your contracts to truffle DB and you should
|
||||||
|
// make a backup of your artifacts to a safe location before enabling this feature.
|
||||||
|
//
|
||||||
|
// After you backed up your artifacts you can utilize db by running migrate as follows:
|
||||||
|
// $ truffle migrate --reset --compile-all
|
||||||
|
//
|
||||||
|
// db: {
|
||||||
|
// enabled: false,
|
||||||
|
// host: "127.0.0.1",
|
||||||
|
// adapter: {
|
||||||
|
// name: "sqlite",
|
||||||
|
// settings: {
|
||||||
|
// directory: ".db"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user