Skip to content

Commit

Permalink
Add factory registration (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngmachado authored Mar 1, 2022
1 parent 1aeedfc commit 93ad0cc
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const SuperfluidSDK = require("@superfluid-finance/js-sdk");
const {
getScriptRunnerFactory: S,
extractWeb3Options,
builtTruffleContractLoader,
sendGovernanceAction,
} = require("./libs/common");

/**
* @dev Create a new super app factory registration.
* @param {Array} argv Overriding command line arguments
* @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.protocolReleaseVersion Specify the protocol release version to be used
*
* Usage: npx truffle exec scripts/create-new-factory-registration.js : {FACTORY_ADDRESS}
*/
module.exports = eval(`(${S.toString()})({
doNotPrintColonArgs: true
})`)(async function (args, options = {}) {
console.log("======== Creating new factory registration ========");
let {protocolReleaseVersion} = options;

if (args.length !== 1) {
throw new Error("Wrong number of arguments");
}
const factoryAddress = args.pop();

console.log("protocol release version:", protocolReleaseVersion);

const sf = new SuperfluidSDK.Framework({
...extractWeb3Options(options),
version: protocolReleaseVersion,
additionalContracts: [
"Ownable",
"IMultiSigWallet",
"SuperfluidGovernanceBase",
],
contractLoader: builtTruffleContractLoader,
});
await sf.initialize();

console.log("Factory Address:", factoryAddress);

await sendGovernanceAction(sf, (gov) =>
gov.authorizeAppFactory(sf.host.address, factoryAddress)
);
});
3 changes: 1 addition & 2 deletions packages/ethereum-contracts/scripts/libs/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ async function codeChanged(
new RegExp(r, "g"),
"0".repeat(r.length)
);
if (codeTrimed === codeTrimed2)
throw new Error("Code replacement not found");

codeTrimed = codeTrimed2;
});

Expand Down

0 comments on commit 93ad0cc

Please sign in to comment.