Skip to content

Commit

Permalink
onramp working
Browse files Browse the repository at this point in the history
  • Loading branch information
maceip committed Feb 6, 2024
1 parent 5eb51dd commit 20a6e46
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 47 deletions.
14 changes: 7 additions & 7 deletions deploy/001_deploy_simple_erc20.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import {parseEther} from 'ethers';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';
import { parseEther } from 'ethers';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const {deployments, getNamedAccounts} = hre;
const {deploy} = deployments;
const { deployments, getNamedAccounts } = hre;
const { deploy } = deployments;

const {deployer, simpleERC20Beneficiary} = await getNamedAccounts();
const { deployer, simpleERC20Beneficiary, simpleOffchainVerifier } = await getNamedAccounts();

await deploy('SimpleERC20', {
from: deployer,
args: [simpleERC20Beneficiary, parseEther('1000000000')],
args: [simpleOffchainVerifier, parseEther('1000000000')],
log: true,
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
});
Expand Down
6 changes: 3 additions & 3 deletions deploy/002_deploy_deramp_vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { ethers } from 'hardhat';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer, simpleERC20Beneficiary } = await hre.getNamedAccounts();
const { deployer, simpleOffchainVerifier } = await hre.getNamedAccounts();
const asset = await (await hre.ethers.getContract('SimpleERC20', deployer)).getAddress();
console.log('vault asset: ', asset);
const { deploy } = hre.deployments;
Expand All @@ -23,12 +23,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
execute: {
init: {
methodName: 'initialize',
args: [asset, 'DeRamp Token', 'RAMP', max, min, fee, simpleERC20Beneficiary],
args: [asset, 'DeRamp Token', 'RAMP', max, min, fee, simpleOffchainVerifier],
},

onUpgrade: {
methodName: 'postUpgrade',
args: [asset, 'DeRamp Token', 'RAMP', max, min, fee, simpleERC20Beneficiary],
args: [asset, 'DeRamp Token', 'RAMP', max, min, fee, simpleOffchainVerifier],
},
},
},
Expand Down
35 changes: 26 additions & 9 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import 'dotenv/config';
import {HardhatUserConfig} from 'hardhat/types';
import { HardhatUserConfig } from 'hardhat/types';

import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-ethers';
import '@typechain/hardhat';
import 'hardhat-gas-reporter';
import 'solidity-coverage';
import '@nomicfoundation/hardhat-verify';

import 'hardhat-deploy';
import 'hardhat-deploy-ethers';
import 'hardhat-deploy-tenderly';

import {node_url, accounts, addForkConfiguration} from './utils/network';
import { node_url, accounts, addForkConfiguration } from './utils/network';

const config: HardhatUserConfig = {
solidity: {
Expand All @@ -32,6 +33,12 @@ const config: HardhatUserConfig = {
simpleERC20Beneficiary: 1,
onRamper: 2,
offRamper: 3,
simpleOffchainVerifier: {
default: 4,
sepolia: '0x36e7Fda8CC503D5Ec7729A42eb86EF02Af315Bf9'
},


},
networks: addForkConfiguration({
hardhat: {
Expand Down Expand Up @@ -82,19 +89,29 @@ const config: HardhatUserConfig = {
},
external: process.env.HARDHAT_FORK
? {
deployments: {
// process.env.HARDHAT_FORK will specify the network that the fork is made from.
// these lines allow it to fetch the deployments from the network being forked from both for node and deploy task
hardhat: ['deployments/' + process.env.HARDHAT_FORK],
localhost: ['deployments/' + process.env.HARDHAT_FORK],
},
}
deployments: {
// process.env.HARDHAT_FORK will specify the network that the fork is made from.
// these lines allow it to fetch the deployments from the network being forked from both for node and deploy task
hardhat: ['deployments/' + process.env.HARDHAT_FORK],
localhost: ['deployments/' + process.env.HARDHAT_FORK],
},
}
: undefined,

tenderly: {
project: 'template-ethereum-contracts',
username: process.env.TENDERLY_USERNAME as string,
},
etherscan: {
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: 'MSFGJM485PQKZ27XDN74RP5PKXAJYUWXSH',
},
sourcify: {
// Disabled by default
// Doesn't need an API key
enabled: true,
},
};

export default config;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"solidity-coverage": "^0.8.6",
"solmate": "github:transmissions11/solmate",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"@nomicfoundation/hardhat-verify": "^2.0.4"
},
"scripts": {
"prepare": "node ./.setup.js && hardhat typechain",
Expand Down
95 changes: 95 additions & 0 deletions pnpm-lock.yaml

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

37 changes: 37 additions & 0 deletions scripts/directTransfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { deployments, getNamedAccounts, getUnnamedAccounts, ethers } from 'hardhat';

const { execute } = deployments;
// example script

const args = process.argv.slice(2);
const account = args[0];
const message = args[1];

async function main() {
const { owner, simpleOffchainVerifier, offRamper, onRamper } = await getNamedAccounts();
const simpleOffchainVerifierSigner = await ethers.getSigner(simpleOffchainVerifier);
const bob = await ethers.getSigner(offRamper);
const alice = await ethers.getSigner(onRamper);


console.log('simpleOffchainVerifier: ', simpleOffchainVerifier);
console.log('bob.address: ', bob.address);
console.log('DeRampVault.address: ', DeRampVault.address);


const erc20Deployment = await deployments.get('SimpleERC20');
const erc20ABI = await ethers.getContractFactory('SimpleERC20');
const deRampABI = await ethers.getContractFactory('DeRampVault');



const DeRampHandle = await deRampABI.connect(simpleOffchainVerifierSigner).attach(DeRampVault.address);
const tx = await DeRampHandle.transferFrom(DeRampVault.address, alice.address, 100);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Loading

0 comments on commit 20a6e46

Please sign in to comment.