Skip to content

Commit

Permalink
Production Deploy (#13806)
Browse files Browse the repository at this point in the history
Manual deploy as of commit:d02077d8e9989b211800015ac37468b22c9851d9
  • Loading branch information
julien51 authored May 8, 2024
1 parent c341bc6 commit e4bc2a3
Show file tree
Hide file tree
Showing 210 changed files with 7,431 additions and 6,572 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ jobs:
BUILDKIT_PROGRESS: plain
steps:
- uses: actions/checkout@v4
# - name: Run Integration Tests
# run: scripts/integration-tests.sh
- name: Run Integration Tests
run: scripts/integration-tests.sh
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax = docker/dockerfile:experimental

ARG NODE_VERSION=20.10.0-bullseye
ARG NODE_VERSION=20.12.2-bullseye
# the graph cli binary does not work with bookworm which is the default for Node 20 images. Once the graph-cli binary has been updated to not use https://www.npmjs.com/package/binary-install-raw we can use bookworm.

###################################################################
Expand Down
2 changes: 1 addition & 1 deletion docker/development/eth-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:20.10.0-alpine as unlock-eth-node
FROM node:20.12.2-alpine as unlock-eth-node
LABEL Unlock <[email protected]>

USER root
Expand Down
2 changes: 1 addition & 1 deletion docker/development/eth-node/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HardhatUserConfig } from 'hardhat/config'
import '@nomiclabs/hardhat-ethers'
import '@nomicfoundation/hardhat-ethers'
import '@unlock-protocol/hardhat-plugin'

const config: HardhatUserConfig = {
Expand Down
4 changes: 1 addition & 3 deletions docker/development/eth-node/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ export const deployErc20 = async (): Promise<Contract> => {
)
const factory = await ethers.getContractFactory(abi, bytecode)
const erc20Contract = await factory.deploy({ gasLimit: 6000000 })
await erc20Contract.deployed()

return erc20Contract
}

export const outputSubgraphNetworkConf = async (
unlockAddress: string
): Promise<{}> => {
): Promise<object> => {
const networkConf = {
localhost: {
Unlock: {
Expand Down
10 changes: 5 additions & 5 deletions docker/development/eth-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"start": "hardhat node"
},
"dependencies": {
"@nomiclabs/hardhat-ethers": "2.2.3",
"@nomicfoundation/hardhat-ethers": "3.0.5",
"@unlock-protocol/contracts": "latest",
"@unlock-protocol/hardhat-plugin": "latest",
"eslint": "8.54.0",
"ethers": "5.7.2",
"hardhat": "2.20.1",
"eslint": "8.57.0",
"ethers": "6.10.0",
"hardhat": "2.22.3",
"hardhat-erc1820": "0.1.0",
"ts-node": "10.9.2",
"typescript": "5.4.3"
"typescript": "5.4.5"
}
}
41 changes: 20 additions & 21 deletions docker/development/eth-node/scripts/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import { ethers, unlock } from 'hardhat'
import { deployErc20, outputSubgraphNetworkConf } from '../lib'
import locksArgs from '../lib/locks'

const { AddressZero } = ethers.constants

const locksmithHost = process.env.LOCKSMITH_HOST || '127.0.0.1'
const locksmithPort = process.env.LOCKSMITH_PORT || 3000

const users = []
const users: string[] = []

if (process.env.LOCKSMITH_PURCHASER_ADDRESS) {
users.push(process.env.LOCKSMITH_PURCHASER_ADDRESS)
Expand All @@ -26,7 +24,7 @@ if (process.env.ETHEREUM_ADDRESS) {
users.push(process.env.ETHEREUM_ADDRESS)
}

const log = (message) => {
const log = (message: string) => {
console.log(`ETH NODE SETUP > ${message}`)
}

Expand All @@ -43,7 +41,7 @@ async function main() {
users.map((user) =>
deployer.sendTransaction({
to: user,
value: ethers.utils.parseEther('5.0'),
value: ethers.parseEther('5.0'),
})
)
)
Expand All @@ -52,17 +50,15 @@ async function main() {

// Deploy an ERC20
const erc20 = await deployErc20()
log(`ERC20 CONTRACT DEPLOYED AT ${erc20.address}`)
const erc20Address = await erc20.getAddress()
log(`ERC20 CONTRACT DEPLOYED AT ${erc20Address}`)
const decimals = await erc20.decimals()

// We then transfer some ERC20 tokens to some users
await Promise.all(
users.map(async (user) => {
const mintTx = await erc20.mint(
user,
ethers.utils.parseUnits('500', decimals)
)
log(`TRANSFERED 500 ERC20 (${erc20.address}) to ${user}`)
const mintTx = await erc20.mint(user, ethers.parseUnits('500', decimals))
log(`TRANSFERED 500 ERC20 (${erc20Address}) to ${user}`)
return await mintTx.wait()
})
)
Expand All @@ -71,7 +67,7 @@ async function main() {
* 2. Deploy UDT
*/
const udt = await deployErc20()
log(`UDT DEPLOYED AT ${udt.address}`)
log(`UDT DEPLOYED AT ${await udt.getAddress()}`)

// mint some tokens
await udt.mint(holder.address, 200)
Expand All @@ -83,14 +79,14 @@ async function main() {
log('UNLOCK PROTOCOL DEPLOYED')

// grant Unlock minting permissions
await udt.addMinter(unlockContract.address)
await udt.addMinter(await unlockContract.getAddress())

// TODO: deploy Wrapped Eth for unlock!

// Configure Unlock
await unlockContract.configUnlock(
udt.address,
AddressZero, // wrappedEth
await udt.getAddress(),
ethers.ZeroAddress, // wrappedEth
16000,
'DEVKEY',
`http://${locksmithHost}:${locksmithPort}/api/key/`,
Expand All @@ -103,10 +99,12 @@ async function main() {
*/
// Finally, deploy locks and for each of them, if it's an ERC20, approve it for locksmith purchases
await Promise.all(
locksArgs(erc20.address).map(async (lockParams) => {
locksArgs(erc20Address).map(async (lockParams) => {
const { lock } = await unlock.createLock(lockParams)

log(`LOCK "${await lockParams.name}" DEPLOYED TO ${lock.address}`)
log(
`LOCK "${await lockParams.name}" DEPLOYED TO ${await lock.getAddress()}`
)

if (
lockParams.currencyContractAddress &&
Expand All @@ -115,17 +113,18 @@ async function main() {
const purchaser = await ethers.getSigner(
process.env.LOCKSMITH_PURCHASER_ADDRESS
)
const approveTx = await erc20
.connect(purchaser)
.approve(lock.address, ethers.utils.parseUnits('500', decimals))
const approveTx = await erc20.connect(purchaser).getFunction('approve')(
await lock.getAddress(),
ethers.utils.parseUnits('500', decimals)
)
await approveTx.wait()
}
return lock
})
)

// replace subraph conf
await outputSubgraphNetworkConf(unlockContract.address)
await outputSubgraphNetworkConf(await unlockContract.getAddress())

// Mark the node as ready by sending 1 WEI to the address 0xa3056617a6f63478ca68a890c0d28b42f4135ae4 which is KECCAK256(UNLOCKREADY)
// This way, any test or application which requires the node to be completely set can just wait for the balance of 0xa3056617a6f63478ca68a890c0d28b42f4135ae4 to be >0.
Expand Down
Loading

0 comments on commit e4bc2a3

Please sign in to comment.