Skip to content

Commit

Permalink
feat: adding new updates to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
wellitongervickas committed Nov 27, 2023
1 parent 661c32e commit 86813f3
Show file tree
Hide file tree
Showing 14 changed files with 246 additions and 73 deletions.
8 changes: 5 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# accounts
ACCOUNTS_PRIVATE_KEY_1=""
ACCOUNTS_PRIVATE_KEY_2=""
ACCOUNTS_PRIVATE_KEY_1=""


# networks
MUMBAI_API_KEY=""
PUBLIC_NETWORK_43113_HTTP_RPC=""
ETHERSCAN_API_KEY=""
AVALANCHE_FUJI_API_KEY=""
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# 0xdevhub - Crosschain NFT contracts

[![Run Tests](https://github.com/0xdevhub/crosschain-nft-contracts/actions/workflows/tests.yml/badge.svg)](https://github.com/0xdevhub/crosschain-nft-contracts/actions/workflows/tests.yml)

## Networks

- Avalanche Fuji (43113)
- Arbitrum Rinkeby (soon)

## Contracts

- Avalanche Fuji: (soon)
- Arbitrum Rinkeby: (soon)

#### Deploying contracts

not available

#### Verifing contracts

```shell
pnpm verify --contract contracts/[ContractName].sol:[Contract] --network [networkid] [contractAddress] ["ARGUMENTS"]
```

#### Adding new adapter

ToDo

## Getting Started

```shell
pnpm compile
pnpm typechain
pnpm node
pnpm deploy:localhost
pnpm deploy:mumbai
```

## Available scrips by `dlx hardhat`

```shell
dlx hardhat help
REPORT_GAS=true dlx hardhat test
```

## Testing

```bash
pnpm test
pnpm test:watch
pnpm test:coverage
```
3 changes: 3 additions & 0 deletions config/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const evmAccounts = [
String(process.env.ACCOUNTS_PRIVATE_KEY_1) // owner
]
32 changes: 32 additions & 0 deletions config/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { evmAccounts } from './accounts'
import { Chain } from './types'

export const avalancheFuji: Chain = {
id: 43_113,
name: 'Avalanche Fuji',
network: 'avalanche-fuji',
nativeCurrency: {
decimals: 18,
name: 'Avalanche Fuji',
symbol: 'AVAX'
},
accounts: evmAccounts,
rpcUrls: {
protocol: {
http: [process.env.PUBLIC_NETWORK_43113_HTTP_RPC!]
},
default: { http: ['https://api.avax-test.network/ext/bc/C/rpc'] },
public: { http: ['https://api.avax-test.network/ext/bc/C/rpc'] }
},
blockExplorers: {
etherscan: { name: 'SnowTrace', url: 'https://testnet.snowtrace.io' },
default: { name: 'SnowTrace', url: 'https://testnet.snowtrace.io' }
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 7096959
}
},
testnet: true
}
15 changes: 15 additions & 0 deletions config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { reduce } from 'lodash'
import { avalancheFuji } from './chains'
import { Chain } from './types'

export const allowedChains = [avalancheFuji]

export const allowedChainsConfig = reduce(
allowedChains,
(acc, chain: Chain) => {
acc[chain.id] = chain

return acc
},
{} as { [key: number]: Chain }
)
16 changes: 0 additions & 16 deletions config/networks.ts

This file was deleted.

40 changes: 40 additions & 0 deletions config/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface NativeCurrency {
decimals: number
name: string
symbol: string
}

export interface RpcUrls {
http: string[]
}

export interface BlockExplorer {
name: string
url: string
}

export interface Contracts {
multicall3: {
address: string
blockCreated: number
}
}

export interface Chain {
id: number
name: string
network: string
accounts: string[]
nativeCurrency: NativeCurrency
rpcUrls: {
[key: string]: RpcUrls
default: RpcUrls
public: RpcUrls
}
blockExplorers: {
etherscan: BlockExplorer
default: BlockExplorer
}
contracts: Contracts
testnet: boolean
}
29 changes: 27 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@ import dotenv from 'dotenv'
dotenv.config()

import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-verify'
import '@nomicfoundation/hardhat-toolbox'
import '@nomiclabs/hardhat-solhint'
import 'tsconfig-paths/register'
import { networks as networksConfig } from '@/config/networks'
import './tasks'

import { allowedChainsConfig } from '@/config/config'
import { avalancheFuji } from '@/config/chains'

const config: HardhatUserConfig = {
networks: networksConfig,
networks:
process.env.NODE_ENV !== 'development'
? {
[avalancheFuji.id]: {
url: allowedChainsConfig[avalancheFuji.id].rpcUrls.default.http[0],
accounts: allowedChainsConfig[avalancheFuji.id].accounts
}
}
: {
localhost: {
url: 'http://127.0.0.1:8545'
},
hardhat: {
// See its defaults
}
},
solidity: {
version: '0.8.21',
settings: {
Expand All @@ -21,6 +40,12 @@ const config: HardhatUserConfig = {
typechain: {
outDir: 'typechain',
target: 'ethers-v6'
},
etherscan: {
apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY!,
avalancheFujiTestnet: process.env.AVALANCHE_FUJI_API_KEY!
}
}
}

Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
},
"scripts": {
"node": "NODE_ENV=development hardhat node",
"deploy:localhost": "NODE_ENV=development hardhat run --network localhost scripts/deploy.ts",
"deploy:mumbai": "hardhat run --network mumbai scripts/deploy.ts",
"verify": "hardhat verify",
"compile": "hardhat compile",
"test": "NODE_ENV=development hardhat test",
"typechain": "hardhat typechain",
Expand All @@ -23,7 +22,7 @@
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.0",
"@nomicfoundation/hardhat-verify": "^1.1.1",
"@nomiclabs/hardhat-solhint": "^3.0.1",
"@typechain/ethers-v6": "^0.4.3",
"@typechain/hardhat": "^8.0.3",
Expand All @@ -43,11 +42,14 @@
"ts-node": ">=8.0.0",
"tsconfig-paths": "^4.2.0",
"typechain": "^8.3.2",
"typescript": ">=4.5.0"
"typescript": ">=4.5.0",
"@types/lodash": "^4.14.202",
"dotenv": "^16.3.1"
},
"dependencies": {
"@chainlink/contracts-ccip": "^0.7.6",
"@openzeppelin/contracts": "^5.0.0",
"dotenv": "^16.3.1"
"cli-spinners": "^2.9.2",
"lodash": "^4.17.21"
}
}
21 changes: 19 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 18 additions & 44 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
import {
deployContract,
getContractAddress,
getContractAt,
getNetwork,
getSigners
} from './utils'
import { Spinner } from './spinner'
import cliSpinner from 'cli-spinners'

import { DEVELOPER_ROLE, DEVELOPER_ROLE_DELAY } from './constants'
const spinner: Spinner = new Spinner(cliSpinner.triangle)

async function main() {
const { chainId } = await getNetwork()
console.log('chainId ' + chainId)
const deploy = async () => {
// deploy hub contract
console.log(`ℹ️ Deploying...`)

const [owner, developer] = await getSigners()
console.log('owner:' + owner.address)

// deploy access management contract
const accessManagement = await deployContract(
'AccessManagement',
owner.address
)
const accessManagementAddress = await getContractAddress(accessManagement)
console.log('accessManagementAddress:' + accessManagementAddress)

// grant role to developer
const accessManagementContract = await getContractAt(
'AccessManagement',
accessManagementAddress
)

await accessManagementContract.grantRole(
DEVELOPER_ROLE,
developer.address,
DEVELOPER_ROLE_DELAY
)

console.log(
'developer role granted: ',
developer.address,
DEVELOPER_ROLE,
DEVELOPER_ROLE_DELAY
)
console.log(`✅ deployed`)
}

main().catch((error) => {
console.error(error)
process.exitCode = 1
})
;(async () => {
try {
spinner.start()
await deploy()
spinner.stop()
} catch (error) {
console.error(error)
process.exitCode = 1
spinner.stop()
}
})()
Loading

0 comments on commit 86813f3

Please sign in to comment.