Skip to content

Commit

Permalink
Merge pull request #21 from RigoBlock/feature/ci
Browse files Browse the repository at this point in the history
Feature/ci
  • Loading branch information
gabririgo authored Jun 10, 2022
2 parents 2e76a55 + d43687a commit f2e9bc8
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/autolabeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
contracts: ['contracts']
@rgbk/v3-contracts: ['packages/v3-contracts']
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: v3-contracts
on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
solidity: [""]
settings: ['{"optimizer":{"enabled":true,"runs":200}}']
#include:
#- solidity: "0.8.14"
# settings: '{"optimizer":{"enabled":true,"runs":200}}'
#- solidity: "0.7.4"
# settings: '{"optimizer":{"enabled":true,"runs":200}}'
#- solidity: "0.6.6"
# settings: '{"optimizer":{"enabled":true,"runs":200}}'
#- solidity: "0.5.0"
# settings: '{"optimizer":{"enabled":true,"runs":200}}'
env:
SOLIDITY_VERSION: ${{ matrix.solidity }}
SOLIDITY_SETTINGS: ${{ matrix.settings }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.7.0
- uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile
- run: yarn build
52 changes: 52 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.7.0
- uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- run: yarn --frozen-lockfile
- run: yarn build
#- run: yarn test

publish-gpr:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- run: yarn --frozen-lockfile
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.PUBLISH_GITHUB_TOKEN}}

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: yarn --frozen-lockfile
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const AddressOne = "0x0000000000000000000000000000000000000001";
18 changes: 18 additions & 0 deletions src/utils/proxies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { ethers, Contract } from "ethers"

export const calculateProxyAddress = async (factory: Contract, singleton: string, inititalizer: string, nonce: number | string) => {
const deploymentCode = ethers.utils.solidityPack(["bytes", "uint256"], [await factory.proxyCreationCode(), singleton])
const salt = ethers.utils.solidityKeccak256(
["bytes32", "uint256"],
[ethers.utils.solidityKeccak256(["bytes"], [inititalizer]), nonce]
)
return ethers.utils.getCreate2Address(factory.address, salt, ethers.utils.keccak256(deploymentCode))
}

export const calculateProxyAddressWithCallback = async (factory: Contract, singleton: string, inititalizer: string, nonce: number | string, callback: string) => {
const saltNonceWithCallback = ethers.utils.solidityKeccak256(
["uint256", "address"],
[nonce, callback]
)
return calculateProxyAddress(factory, singleton, inititalizer, saltNonceWithCallback)
}

0 comments on commit f2e9bc8

Please sign in to comment.