Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add scripts/deploy.ts #1227

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/contracts-por/contracts/mocks/MockTrueCurrency.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ contract MockTrueCurrency is TrueCurrencyWithProofOfReserve {
}

function name() public pure override returns (string memory) {
return "TrueCurrency";
return "TrueUSD";
}

function symbol() public pure override returns (string memory) {
return "TCUR";
return "TUSD";
}
}
18 changes: 9 additions & 9 deletions packages/contracts-por/contracts/test/Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.6.10;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {IRegistryClone as RegistryClone} from "./IRegistryClone.sol";
import {IRegistryClone} from "./IRegistryClone.sol";

contract Registry {
struct AttributeData {
Expand All @@ -28,13 +28,13 @@ contract Registry {
// The logic governing who is allowed to set what attributes is abstracted as
// this accessManager, so that it may be replaced by the owner as needed
bytes32 constant WRITE_PERMISSION = keccak256("canWriteTo-");
mapping(bytes32 => RegistryClone[]) subscribers;
mapping(bytes32 => IRegistryClone[]) subscribers;

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event SetAttribute(address indexed who, bytes32 attribute, uint256 value, bytes32 notes, address indexed adminAddr);
event SetManager(address indexed oldManager, address indexed newManager);
event StartSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber);
event StopSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber);
event StartSubscription(bytes32 indexed attribute, IRegistryClone indexed subscriber);
event StopSubscription(bytes32 indexed attribute, IRegistryClone indexed subscriber);

// Allows a write if either a) the writer is that Registry's owner, or
// b) the writer is writing to attribute foo and that writer already has
Expand All @@ -54,14 +54,14 @@ contract Registry {
attributes[_who][_attribute] = AttributeData(_value, _notes, msg.sender, block.timestamp);
emit SetAttribute(_who, _attribute, _value, _notes, msg.sender);

RegistryClone[] storage targets = subscribers[_attribute];
IRegistryClone[] storage targets = subscribers[_attribute];
uint256 index = targets.length;
while (index-- > 0) {
targets[index].syncAttributeValue(_who, _attribute, _value);
}
}

function subscribe(bytes32 _attribute, RegistryClone _syncer) external onlyOwner {
function subscribe(bytes32 _attribute, IRegistryClone _syncer) external onlyOwner {
subscribers[_attribute].push(_syncer);
emit StartSubscription(_attribute, _syncer);
}
Expand All @@ -86,7 +86,7 @@ contract Registry {
require(confirmWrite(_attribute, msg.sender));
attributes[_who][_attribute] = AttributeData(_value, "", msg.sender, block.timestamp);
emit SetAttribute(_who, _attribute, _value, "", msg.sender);
RegistryClone[] storage targets = subscribers[_attribute];
IRegistryClone[] storage targets = subscribers[_attribute];
uint256 index = targets.length;
while (index-- > 0) {
targets[index].syncAttributeValue(_who, _attribute, _value);
Expand Down Expand Up @@ -130,10 +130,10 @@ contract Registry {
uint256 _startIndex,
address[] calldata _addresses
) external {
RegistryClone[] storage targets = subscribers[_attribute];
IRegistryClone[] storage targets = subscribers[_attribute];
uint256 index = targets.length;
while (index-- > _startIndex) {
RegistryClone target = targets[index];
IRegistryClone target = targets[index];
for (uint256 i = _addresses.length; i-- > 0; ) {
address who = _addresses[i];
target.syncAttributeValue(who, _attribute, attributes[who][_attribute].value);
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts-por/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"preflatten": "rm -rf custom_flatten",
"flatten": "waffle flatten .waffle.json",
"test": "mocha 'test/**/*.test.ts'",
"checks": "yarn lint && yarn test"
"checks": "yarn lint && yarn test",
"deploy": "ts-node scripts/deploy.ts"
},
"dependencies": {
"ethereum-mars": "0.2.5",
Expand All @@ -36,6 +37,7 @@
"@types/node": "^17.0.34",
"chai": "^4.3.6",
"ethers": "^5.7.0",
"ethereum-waffle": "^3.4.0",
"hardhat": "~2.10.2",
"mocha": "^10.0.0",
"ts-node": "^10.7.0",
Expand Down
22 changes: 22 additions & 0 deletions packages/contracts-por/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { deployContract, MockProvider } from 'ethereum-waffle'
import { BigNumber, getDefaultProvider, Wallet } from 'ethers'
import { OwnedUpgradeabilityProxy__factory } from '../build/types/factories/OwnedUpgradeabilityProxy__factory'
import { providers } from 'ethers'
//import { InfuraProvider } from 'ethers/providers'

export async function deploy() {
/*
what we need to configure:
1. private key of wallet that we want to use for contract deployment
2. infura key
3. contract factory - factory of contract that we want to deploy
*/
const goerliChainId = 5
const provider = new providers.InfuraProvider(goerliChainId, process.env.INFURA_KEY)
// const provider = getDefaultProvider(5)
const wallet = new Wallet(process.env.PRIVATE_KEY, provider)
const result = await deployContract(wallet, OwnedUpgradeabilityProxy__factory, [BigNumber.from(1000)] as any, { gasLimit: 2_000_000 })

}

deploy()