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

add tokenDecimals option to deploy-test-token.js #1025

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/ethereum-contracts/scripts/deploy-test-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
* @param {Address} options.from Address to deploy contracts from
* @param {boolean} options.resetToken Reset the token deployment
*
* Usage: npx truffle exec scripts/deploy-test-token.js : {TOKEN_SYMBOL}
* Usage: npx truffle exec scripts/deploy-test-token.js : {TOKEN_DECIMALS} {TOKEN_SYMBOL}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appending the arg and making it optional (keep default value) would have avoided breaking the interface

*/
module.exports = eval(`(${S.toString()})()`)(async function (
args,
Expand All @@ -25,11 +25,15 @@ module.exports = eval(`(${S.toString()})()`)(async function (
console.log("======== Deploying test token ========");
let {resetToken} = options;

if (args.length !== 1) {
// > 2 because decimals is an optional field
// symbol should be required though
if (args.length > 2 || args.length < 1) {
throw new Error("Wrong number of arguments");
}
const tokenSymbol = args.pop();
console.log("Token symbol", tokenSymbol);
const tokenDecimals = args.pop() || 18;
console.log("Token decimals", tokenDecimals);

resetToken = resetToken || !!process.env.RESET_TOKEN;
console.log("reset token: ", resetToken);
Expand Down Expand Up @@ -62,7 +66,7 @@ module.exports = eval(`(${S.toString()})()`)(async function (
const testToken = await web3tx(TestToken.new, "TestToken.new")(
tokenSymbol + " Fake Token",
tokenSymbol,
18
tokenDecimals
);
testTokenAddress = testToken.address;
await web3tx(resolver.set, `Resolver set ${name}`)(
Expand Down
13 changes: 13 additions & 0 deletions packages/ethereum-contracts/test/scripts/deployment.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const deployTestToken = require("../../scripts/deploy-test-token");
const deploySuperToken = require("../../scripts/deploy-super-token");
const deployTestEnvironment = require("../../scripts/deploy-test-environment");
const Resolver = artifacts.require("Resolver");
const TestToken = artifacts.require("TestToken");
const UUPSProxiable = artifacts.require("UUPSProxiable");
const Superfluid = artifacts.require("Superfluid");
const ISuperTokenFactory = artifacts.require("ISuperTokenFactory");
Expand Down Expand Up @@ -375,6 +376,8 @@ contract("Embeded deployment scripts", (accounts) => {
);
const address1 = await resolver.get("tokens.TEST7262");
assert.notEqual(address1, ZERO_ADDRESS);
const testToken7262 = await TestToken.at(address1);
assert.equal(18, await testToken7262.decimals());

// second deployment
await deployTestToken(
Expand All @@ -397,6 +400,16 @@ contract("Embeded deployment scripts", (accounts) => {
);
const address3 = await resolver.get("tokens.TEST7262");
assert.equal(address3, address2);

// deploy test token with 6 decimals
await deployTestToken(
errorHandler,
[":", 6, "TEST6420"],
deploymentOptions
);
const address4 = await resolver.get("tokens.TEST6420");
const testToken6420 = await TestToken.at(address4);
assert.equal(6, await testToken6420.decimals());
});

it("scripts/deploy-super-token.js", async () => {
Expand Down