2018-05-11 22:11:05 +00:00
|
|
|
module.exports = {
|
2018-05-11 22:22:32 +00:00
|
|
|
default: {
|
|
|
|
dappConnection: [
|
2019-08-30 20:50:20 +00:00
|
|
|
"$EMBARK",
|
2018-02-08 00:39:11 +00:00
|
|
|
"ws://localhost:8546",
|
2018-10-23 15:23:42 +00:00
|
|
|
"$WEB3"
|
2017-07-05 12:35:51 +00:00
|
|
|
],
|
2018-05-11 22:22:32 +00:00
|
|
|
gas: "auto",
|
2019-08-30 20:50:20 +00:00
|
|
|
beforeDeploy: async () => {
|
|
|
|
console.log("==========================");
|
|
|
|
console.log("before deploying contracts");
|
|
|
|
console.log("==========================");
|
|
|
|
},
|
2020-01-07 13:41:35 +00:00
|
|
|
interfaces: ['Ownable'],
|
2019-08-30 20:50:20 +00:00
|
|
|
deploy: {
|
2019-11-05 13:17:51 +00:00
|
|
|
Token: {
|
|
|
|
deploy: false,
|
|
|
|
args: [1000]
|
|
|
|
},
|
2018-05-11 22:22:32 +00:00
|
|
|
SimpleStorage: {
|
|
|
|
fromIndex: 0,
|
2018-07-25 20:01:42 +00:00
|
|
|
args: [100],
|
2019-11-12 21:06:52 +00:00
|
|
|
onDeploy: ["SimpleStorage.methods.setRegistar('embark.eth').send()"]
|
2018-04-18 19:36:54 +00:00
|
|
|
},
|
2018-05-11 22:22:32 +00:00
|
|
|
SimpleStorageTest: {
|
2019-08-30 20:50:20 +00:00
|
|
|
//file: "./some_folder/test_contract.sol",
|
|
|
|
args: [1000, 'embark.eth']
|
2018-04-20 15:39:17 +00:00
|
|
|
},
|
2019-10-22 13:27:22 +00:00
|
|
|
StandardToken: {
|
|
|
|
file: "https://github.com/status-im/contracts/blob/151-embark31/contracts/token/StandardToken.sol",
|
|
|
|
deploy: false
|
|
|
|
},
|
2019-08-30 20:50:20 +00:00
|
|
|
AnotherStorage: {
|
|
|
|
args: ["$SimpleStorage"]
|
|
|
|
//args: ["0x0000000000000000000000000000000000000000"]
|
2019-10-30 20:02:17 +00:00
|
|
|
},
|
2019-11-05 13:17:51 +00:00
|
|
|
BigFreakingContract: {
|
|
|
|
args: [100]
|
|
|
|
},
|
|
|
|
ContractArgs: {
|
fix(@embark/ens): don't change shape of Smart Contract args in action hooks
This commit fixes the issue that it wasn't possible anymore to use named constructor arguments
in Smart Contract configurations.
For example, the following Smart Contract expects two constructor arguments:
```solidity
contract SomeContract {
constructor(address[] _addresses, int initialValue) public {}
}
```
The first being a list of addresses, the second one a number. This can be configured as:
```js
SomeContract: {
args: [
["$MyToken2", "$SimpleStorage"],
123
]
}
```
Notice how the order of arguments matters here. `_addresses` come first in the constructor,
so they have to be defined first in the configuration as well.
Another way to configure this is using named arguments, which is what's broken prior to this commit:
```js
SomeContract: {
args: {
initialValue: 123,
_addresses: ["$MyToken2", "$SimpleStorage"]
}
}
```
Using a notation like this ^ the order no longer matters as Embark will figure out the right
values for the constructor arguments by their names.
The reason this is broken is because there are several modules in Embark that register and
run a `deployment:contract:beforeDeploy` action, which are allowed to mutate this configuration
object. One of those modules is the `ens` module, which searches for ENS names in the arguments
and figure out whether it has to replace it with a resolved address.
One thing that particular module didn't take into account is that `args` could be either and
array, or an object and will always return an array, changing the shape of `args` in case it was
an object.
This is a problem because another module, `ethereum-blockchain-client`, another action is registered
that takes this mutated object in `determineArguments()` and ensure that, if `args` is actually an
object, the values are put in the correct position matching the constructor of the Smart Contract in
question.
One way to solve this was to use the newly introduced [priority](https://github.com/embark-framework/embark/pull/2031) and ensure
that `ens` action is executed after `ethereum-blockchain-client`'s.
However, the actual bug here is that the ENS module changes the shape of `args` in the first place,
so this commit ensures that it preserves it.
2019-11-08 10:58:32 +00:00
|
|
|
args: {
|
|
|
|
initialValue: 123,
|
|
|
|
_addresses: ["$MyToken2", "$SimpleStorage"]
|
|
|
|
}
|
2019-11-05 13:17:51 +00:00
|
|
|
},
|
|
|
|
SomeContract: {
|
|
|
|
deployIf: 'await MyToken.methods.isAvailable().call()',
|
|
|
|
deps: ['MyToken'],
|
|
|
|
args: [
|
|
|
|
["$MyToken2", "$SimpleStorage"],
|
|
|
|
100
|
|
|
|
]
|
|
|
|
},
|
|
|
|
Expiration: {
|
|
|
|
args: [1000]
|
|
|
|
},
|
|
|
|
SimpleStorageWithHttpImport: {
|
|
|
|
fromIndex: 0,
|
2019-10-30 20:02:17 +00:00
|
|
|
args: [100]
|
2019-11-05 13:17:51 +00:00
|
|
|
},
|
|
|
|
MyToken: {
|
|
|
|
instanceOf: "Token"
|
|
|
|
},
|
|
|
|
MyToken2: {
|
|
|
|
instanceOf: "Token",
|
|
|
|
args: [200]
|
|
|
|
},
|
2017-12-21 16:21:36 +00:00
|
|
|
},
|
2019-08-30 20:50:20 +00:00
|
|
|
afterDeploy: async (dependencies) => {
|
|
|
|
console.log("==========================");
|
|
|
|
console.log("after deploying contracts");
|
|
|
|
console.log("==========================");
|
|
|
|
// console.dir(dependencies);
|
|
|
|
// console.dir(dependencies.contracts.SimpleStorage.methods);
|
|
|
|
// try {
|
|
|
|
// let value = await dependencies.contracts.SimpleStorage.methods.get().call();
|
|
|
|
// console.dir(value)
|
|
|
|
// } catch(err) {
|
|
|
|
// console.dir(err);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
//afterDeploy: [
|
|
|
|
//"Test.methods.changeAddress('$MyToken')",
|
|
|
|
//"web3.eth.getAccounts((err, accounts) => Test.methods.changeAddress(accounts[0]))"
|
|
|
|
//]
|
2017-02-10 02:41:45 +00:00
|
|
|
},
|
2018-05-11 22:22:32 +00:00
|
|
|
development: {
|
2019-08-30 20:50:20 +00:00
|
|
|
deploy: {
|
|
|
|
// MyToken2: {
|
|
|
|
// instanceOf: "Token",
|
|
|
|
// args: [2000]
|
|
|
|
// }
|
2017-02-10 02:41:45 +00:00
|
|
|
}
|
2017-02-10 00:38:02 +00:00
|
|
|
}
|
2018-05-11 22:11:05 +00:00
|
|
|
};
|