Skip to content
Closed
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
8 changes: 4 additions & 4 deletions packages/ethereum-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,20 @@ DISABLE_NATIVE_TRUFFLE=true truffle --network ganache exec "node_modules/@superf
If you want to deploy to a public network:

```sh
NEW_TEST_RESOLVER=1 DISABLE_NATIVE_TRUFFLE=true truffle --network goerli exec "node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-test-environment.js"
NEW_RESOLVER=1 DISABLE_NATIVE_TRUFFLE=true truffle --network goerli exec "node_modules/@superfluid-finance/ethereum-contracts/scripts/deploy-test-environment.js"
```

Note `NEW_TEST_RESOLVER=1`, it is to avoid using the official resolver address. Doing so
Note `NEW_RESOLVER=1`, it is to avoid using the official resolver address. Doing so
after the command finishes, you should see:

```
...
======== Super token deployed ========
=============== TEST ENVIRONMENT RESOLVER ======================
export TEST_RESOLVER_ADDRESS=0x43098b8d85Fe90eCE6B055e135759B558d2c0224
export RESOLVER_ADDRESS=0x43098b8d85Fe90eCE6B055e135759B558d2c0224
```

Run the export command to save TEST_RESOLVER_ADDRESS to your local environment.
Run the export command to save RESOLVER_ADDRESS to your local environment.
Whenever you run additional tests/scripts this will be the address used to find the SF Framework contracts.

### Examples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ interface IResolver {
*/
function get(string calldata name) external view returns (address);

event Set(string indexed name, address target);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
pragma solidity 0.7.6;

import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { IResolver } from "../interfaces/misc/IResolver.sol";
import { IResolver } from "../interfaces/ux/IResolver.sol";


contract TestResolver is IResolver, AccessControl {
contract Resolver is IResolver, AccessControl {

mapping(string => address) private _registry;

Expand All @@ -16,6 +16,7 @@ contract TestResolver is IResolver, AccessControl {
function set(string calldata name, address target) external {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not an admin");
_registry[name] = target;
emit Set(name, target);
}

function get(string calldata name) external view override returns (address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma abicoder v2;
pragma solidity 0.7.6;

import { IResolver } from "../interfaces/misc/IResolver.sol";
import { IResolver } from "../interfaces/ux/IResolver.sol";
import {
ISuperfluid,
ISuperTokenFactory,
Expand Down
42 changes: 21 additions & 21 deletions packages/ethereum-contracts/scripts/deploy-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
} = require("./utils");

let resetSuperfluidFramework;
let testResolver;
let resolver;

async function deployAndRegisterContractIf(
Contract,
Expand All @@ -25,13 +25,13 @@ async function deployAndRegisterContractIf(
) {
let contractDeployed;
const contractName = Contract.contractName;
const contractAddress = await testResolver.get(resolverKey);
const contractAddress = await resolver.get(resolverKey);
console.log(`${resolverKey} address`, contractAddress);
if (resetSuperfluidFramework || (await cond(contractAddress))) {
console.log(`${contractName} needs new deployment.`);
contractDeployed = await deployFunc();
console.log(`${resolverKey} deployed to`, contractDeployed.address);
await web3tx(testResolver.set, `Resolver set ${resolverKey}`)(
await web3tx(resolver.set, `Resolver set ${resolverKey}`)(
resolverKey,
contractDeployed.address
);
Expand Down Expand Up @@ -76,14 +76,14 @@ async function deployContractIfCodeChanged(
* @param {boolean} options.isTruffle Whether the script is used within native truffle framework
* @param {Web3} options.web3 Injected web3 instance
* @param {Address} options.from Address to deploy contracts from
* @param {boolean} options.newTestResolver Force to create a new resolver (overridng env: NEW_TEST_RESOLVER)
* @param {boolean} options.useMocks Use mock contracts instead (overridng env: USE_MOCKS)
* @param {boolean} options.newResolver Force to create a new resolver (overriding env: NEW_RESOLVER)
* @param {boolean} options.useMocks Use mock contracts instead (overriding env: USE_MOCKS)
* @param {boolean} options.nonUpgradable Deploy contracts configured to be non-upgradable
* (overridng env: NON_UPGRADABLE)
* (overriding env: NON_UPGRADABLE)
* @param {boolean} options.appWhiteListing Deploy contracts configured to require app white listing
* (overridng env: ENABLE_APP_WHITELISTING)
* (overriding env: ENABLE_APP_WHITELISTING)
* @param {boolean} options.resetSuperfluidFramework Reset the superfluid framework deployment
* (overridng env: RESET_SUPERFLUID_FRAMEWORK)
* (overriding env: RESET_SUPERFLUID_FRAMEWORK)
* @param {boolean} options.protocolReleaseVersion Specify the protocol release version to be used
* (overriding env: RELEASE_VERSION)
*
Expand All @@ -95,7 +95,7 @@ module.exports = async function (callback, options = {}) {

await eval(`(${detectTruffleAndConfigure.toString()})(options)`);
let {
newTestResolver,
newResolver,
useMocks,
nonUpgradable,
appWhiteListing,
Expand All @@ -121,14 +121,14 @@ module.exports = async function (callback, options = {}) {
"org.superfluid-finance.agreements.InstantDistributionAgreement.v1"
);

newTestResolver = newTestResolver || !!process.env.NEW_TEST_RESOLVER;
newResolver = newResolver || !!process.env.NEW_RESOLVER;
useMocks = useMocks || !!process.env.USE_MOCKS;
nonUpgradable = nonUpgradable || !!process.env.NON_UPGRADABLE;
appWhiteListing =
appWhiteListing ||
config.gov_enableAppWhiteListing ||
!!process.env.ENABLE_APP_WHITELISTING;
if (newTestResolver) {
if (newResolver) {
console.log("**** !ATTN! CREATING NEW RESOLVER ****");
}
if (useMocks) {
Expand All @@ -152,7 +152,7 @@ module.exports = async function (callback, options = {}) {
"Ownable",
"IMultiSigWallet",
"SuperfluidGovernanceBase",
"TestResolver",
"Resolver",
"SuperfluidLoader",
"Superfluid",
"SuperTokenFactory",
Expand All @@ -176,7 +176,7 @@ module.exports = async function (callback, options = {}) {
Ownable,
IMultiSigWallet,
SuperfluidGovernanceBase,
TestResolver,
Resolver,
SuperfluidLoader,
Superfluid,
SuperfluidMock,
Expand All @@ -202,14 +202,14 @@ module.exports = async function (callback, options = {}) {
networkId,
});

if (!newTestResolver && config.resolverAddress) {
testResolver = await TestResolver.at(config.resolverAddress);
if (!newResolver && config.resolverAddress) {
resolver = await Resolver.at(config.resolverAddress);
} else {
testResolver = await web3tx(TestResolver.new, "TestResolver.new")();
resolver = await web3tx(Resolver.new, "Resolver.new")();
// make it available for the sdk for testing purpose
process.env.TEST_RESOLVER_ADDRESS = testResolver.address;
process.env.RESOLVER_ADDRESS = resolver.address;
}
console.log("Resolver address", testResolver.address);
console.log("Resolver address", resolver.address);

// deploy new governance contract
let governanceInitializationRequired = false;
Expand Down Expand Up @@ -239,7 +239,7 @@ module.exports = async function (callback, options = {}) {
return await web3tx(
SuperfluidLoader.new,
"SuperfluidLoader.new"
)(testResolver.address);
)(resolver.address);
}
);

Expand Down Expand Up @@ -549,12 +549,12 @@ module.exports = async function (callback, options = {}) {

console.log("======== Superfluid framework deployed ========");

if (process.env.TEST_RESOLVER_ADDRESS) {
if (process.env.RESOLVER_ADDRESS) {
console.log(
"=============== TEST ENVIRONMENT RESOLVER ======================"
);
console.log(
`export TEST_RESOLVER_ADDRESS=${process.env.TEST_RESOLVER_ADDRESS}`
`export RESOLVER_ADDRESS=${process.env.RESOLVER_ADDRESS}`
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ethereum-contracts/scripts/deploy-super-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = async function (callback, argv, options = {}) {
"Ownable",
"IMultiSigWallet",
"SuperfluidGovernanceBase",
"TestResolver",
"Resolver",
"UUPSProxiable",
"SETHProxy",
],
Expand All @@ -65,7 +65,7 @@ module.exports = async function (callback, argv, options = {}) {
await sf.initialize();

const {
TestResolver,
Resolver,
UUPSProxiable,
ERC20WithTokenInfo,
ISuperToken,
Expand Down Expand Up @@ -202,8 +202,8 @@ module.exports = async function (callback, argv, options = {}) {
const superToken = await deploymentFn();
console.log("Wrapper created at", superToken.address);
console.log("Resolver setting new address...");
const testResolver = await TestResolver.at(sf.resolver.address);
await testResolver.set(superTokenKey, superToken.address);
const resolver = await Resolver.at(sf.resolver.address);
await resolver.set(superTokenKey, superToken.address);
console.log("Resolver set done.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ module.exports = async function (callback, options = {}) {
options
);

if (process.env.TEST_RESOLVER_ADDRESS) {
if (process.env.RESOLVER_ADDRESS) {
console.log(
"=============== TEST ENVIRONMENT RESOLVER ======================"
);
console.log(
`export TEST_RESOLVER_ADDRESS=${process.env.TEST_RESOLVER_ADDRESS}`
`export RESOLVER_ADDRESS=${process.env.RESOLVER_ADDRESS}`
);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/ethereum-contracts/scripts/deploy-test-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ module.exports = async function (callback, argv, options = {}) {
console.log("reset token: ", resetToken);
console.log("chain ID: ", chainId);

const { TestResolver, TestToken } = await SuperfluidSDK.loadContracts({
const { Resolver, TestToken } = await SuperfluidSDK.loadContracts({
...extractWeb3Options(options),
additionalContracts: ["TestResolver", "TestToken"],
additionalContracts: ["Resolver", "TestToken"],
contractLoader: builtTruffleContractLoader,
});

const testResolver = await TestResolver.at(config.resolverAddress);
console.log("Resolver address", testResolver.address);
const resolver = await Resolver.at(config.resolverAddress);
console.log("Resolver address", resolver.address);

// deploy test token and its super token
const name = `tokens.${tokenName}`;
let testTokenAddress = await testResolver.get(name);
let testTokenAddress = await resolver.get(name);
if (
resetToken ||
testTokenAddress === "0x0000000000000000000000000000000000000000"
Expand All @@ -61,7 +61,7 @@ module.exports = async function (callback, argv, options = {}) {
18
);
testTokenAddress = testToken.address;
await web3tx(testResolver.set, `TestResolver set ${name}`)(
await web3tx(resolver.set, `Resolver set ${name}`)(
name,
testTokenAddress
);
Expand Down
6 changes: 2 additions & 4 deletions packages/ethereum-contracts/scripts/list-super-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = async function (callback, argv, options = {}) {
"IMultiSigWallet",
"SuperfluidGovernanceBase",
"SuperToken",
"TestResolver",
"Resolver",
],
contractLoader: builtTruffleContractLoader,
});
Expand All @@ -64,9 +64,7 @@ module.exports = async function (callback, argv, options = {}) {
const superTokenKey = `supertokens.${protocolReleaseVersion}.${tokenSymbol}`;
console.log("Super token key", superTokenKey);

const resolver = await sf.contracts.TestResolver.at(
sf.resolver.address
);
const resolver = await sf.contracts.Resolver.at(sf.resolver.address);
if (
(await resolver.get.call(superTokenKey)) !== ZERO_ADDRESS &&
!resetToken
Expand Down
12 changes: 6 additions & 6 deletions packages/ethereum-contracts/scripts/register-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ module.exports = async function (callback, argv, options = {}) {
console.log("reset token: ", resetToken);
console.log("chain ID: ", chainId);

const { TestResolver } = await SuperfluidSDK.loadContracts({
const { Resolver } = await SuperfluidSDK.loadContracts({
...extractWeb3Options(options),
additionalContracts: ["TestResolver"],
additionalContracts: ["Resolver"],
contractLoader: builtTruffleContractLoader,
});

const testResolver = await TestResolver.at(config.resolverAddress);
console.log("Resolver address", testResolver.address);
const resolver = await Resolver.at(config.resolverAddress);
console.log("Resolver address", resolver.address);

const name = `tokens.${tokenName}`;
let testTokenAddress = await testResolver.get(name);
let testTokenAddress = await resolver.get(name);

if (
resetToken ||
testTokenAddress === "0x0000000000000000000000000000000000000000"
) {
await web3tx(testResolver.set, `TestResolver set ${name}`)(
await web3tx(resolver.set, `Resolver set ${name}`)(
name,
tokenAddress
);
Expand Down
16 changes: 8 additions & 8 deletions packages/ethereum-contracts/scripts/reset-deployment.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { web3tx } = require("@decentral.ee/web3-helpers");
const { setWeb3Provider } = require("@decentral.ee/web3-helpers/src/config");
const TestResolver = artifacts.require("TestResolver");
const Resolver = artifacts.require("Resolver");
const getConfig = require("./getConfig");

const { parseColonArgs, rl } = require("./utils");
Expand Down Expand Up @@ -31,21 +31,21 @@ module.exports = async function (callback, argv) {

const config = getConfig(networkId);

let testResolver;
let resolver;
if (config.resolverAddress) {
testResolver = await TestResolver.at(config.resolverAddress);
resolver = await Resolver.at(config.resolverAddress);
} else {
testResolver = await web3tx(TestResolver.new, "TestResolver.new")();
resolver = await web3tx(Resolver.new, "Resolver.new")();
// make it available for the sdk for testing purpose
process.env.TEST_RESOLVER_ADDRESS = testResolver.address;
process.env.RESOLVER_ADDRESS = resolver.address;
}
console.log("Resolver address", testResolver.address);
console.log("Resolver address", resolver.address);

await web3tx(testResolver.set, "Clear Superfluid deployment")(
await web3tx(resolver.set, "Clear Superfluid deployment")(
`Superfluid.${version}`,
"0x" + "0".repeat(40)
);
await web3tx(testResolver.set, "Clear TestGovernance deployment")(
await web3tx(resolver.set, "Clear TestGovernance deployment")(
`TestGovernance.${version}`,
"0x" + "0".repeat(40)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = async function (callback, argv, options = {}) {
"Ownable",
"IMultiSigWallet",
"SuperfluidGovernanceBase",
"TestResolver",
"Resolver",
"UUPSProxiable",
"SETHProxy",
],
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-contracts/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function builtTruffleContractLoader(name) {

async function setResolver(sf, key, value) {
console.log(`Setting resolver ${key} -> ${value} ...`);
const resolver = await sf.contracts.TestResolver.at(sf.resolver.address);
const resolver = await sf.contracts.Resolver.at(sf.resolver.address);
switch (process.env.RESOLVER_ADMIN_TYPE) {
case "MULTISIG": {
console.log("Resolver Admin type: MultiSig");
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum-contracts/test/TestEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = class TestEnvironment {

// deploy framework
await deployFramework(this.errorHandler, {
newTestResolver: true,
newResolver: true,
useMocks: this.useMocks,
isTruffle: this.isTruffle,
...deployOpts,
Expand Down
Loading