Skip to content

Commit

Permalink
add tokenDecimals option to deploy-test-token.js (#1025)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdavinchee committed Aug 9, 2022
1 parent 09a9bfc commit b9b1fe8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
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}
*/
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

0 comments on commit b9b1fe8

Please sign in to comment.