Similar to https://github.com/trufflesuite/truffle/issues/1607
I am trying to use the external compile step to build artifacts for a contract external to my truffle project that is written in vyper (https://github.com/Uniswap/contracts-vyper). The contract bytecode and abi were compiled and checked into the external repo for me, so I don't think I need to run vyper myself.
truffle-config.js that looks something like this:
module.exports = {
...
compilers: {
...
external: {
command: "true",
targets: [
{
properties: {
contractName: "UniswapExchange",
},
fileProperties: {
abi: "external/uniswap-contracts-vyper/abi/uniswap_exchange.json",
bytecode: "external/uniswap-contracts-vyper/bytecode/exchange.txt",
},
},
{
properties: {
contractName: "UniswapFactory",
},
fileProperties: {
abi: "external/uniswap-contracts-vyper/abi/uniswap_factory.json",
bytecode: "external/uniswap-contracts-vyper/bytecode/factory.txt",
},
},
],
},
},
Running truffle compile should create a json file with the abi and bytecode included.
Error: Schema validation failed. Errors:
should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
schemaPath: '#/additionalProperties',
params: { additionalProperty: 'outputs' },
data:
{ name: 'setup',
outputs: [],
inputs: [ { type: 'address', name: 'token_addr' } ],
constant: false,
payable: false,
type: 'function',
gas: 175875 },
parentSchema:
{ type: 'object',
properties:
{ type: { type: 'string', enum: [ 'event' ] },
name: { '$ref': '#/definitions/Name' },
inputs:
{ type: 'array',
items: { '$ref': '#/definitions/EventParameter' } },
anonymous: { type: 'boolean' } },
required: [ 'type', 'name', 'inputs', 'anonymous' ],
additionalProperties: false } }
should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
schemaPath: '#/additionalProperties',
params: { additionalProperty: 'name' },
data:
{ name: 'setup',
outputs: [],
inputs: [ { type: 'address', name: 'token_addr' } ],
constant: false,
payable: false,
type: 'function',
gas: 175875 },
parentSchema:
{ type: 'object',
properties:
{ type: { type: 'string', enum: [ 'constructor' ] },
inputs:
{ type: 'array', items: { '$ref': '#/definitions/Parameter' } },
stateMutability: { '$ref': '#/definitions/StateMutability' },
constant: { type: 'boolean' },
payable: { type: 'boolean', default: false } },
required: [ 'type', 'inputs', 'stateMutability' ],
additionalProperties: false } }
should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
schemaPath: '#/additionalProperties',
params: { additionalProperty: 'name' },
data:
{ name: 'setup',
outputs: [],
inputs: [ { type: 'address', name: 'token_addr' } ],
constant: false,
payable: false,
type: 'function',
gas: 175875 },
parentSchema:
{ type: 'object',
properties:
{ type: { type: 'string', enum: [ 'fallback' ] },
stateMutability: { '$ref': '#/definitions/StateMutability' },
constant: { type: 'boolean' },
payable: { type: 'boolean', default: false } },
required: [ 'type', 'stateMutability' ],
additionalProperties: false } }
should NOT have additional properties (additionalProperties):
{ dataPath: '.abi[6]',
schemaPath: '#/additionalProperties',
params: { additionalProperty: 'gas' },
data:
{ name: 'setup',
outputs: [],
inputs: [ { type: 'address', name: 'token_addr' } ],
constant: false,
payable: false,
type: 'function',
gas: 175875 },
parentSchema:
{ type: 'object',
properties:
{ type:
{ type: 'string', enum: [ 'function' ], default: 'function' },
name: { '$ref': '#/definitions/Name' },
inputs:
{ type: 'array', items: { '$ref': '#/definitions/Parameter' } },
outputs:
{ type: 'array',
items: { '$ref': '#/definitions/Parameter' },
default: [] },
stateMutability: { '$ref': '#/definitions/StateMutability' },
constant: { type: 'boolean' },
payable: { type: 'boolean', default: false } },
required: [ 'name', 'inputs', 'stateMutability' ],
additionalProperties: false } }
should match exactly one schema in oneOf (oneOf):
{ dataPath: '.abi[6]',
schemaPath: '#/items/oneOf',
params: {},
data:
{ name: 'setup',
outputs: [],
inputs: [ { type: 'address', name: 'token_addr' } ],
constant: false,
payable: false,
type: 'function',
gas: 175875 },
parentSchema:
{ oneOf:
[ { '$ref': '#/definitions/Event' },
{ '$ref': '#/definitions/ConstructorFunction' },
{ '$ref': '#/definitions/FallbackFunction' },
{ '$ref': '#/definitions/NormalFunction' } ] } }
at Object.validate (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-contract-schema/index.js:197:1)
at processTargets (/usr/src/app/node_modules/truffle/build/webpack:/packages/truffle-external-compile/index.js:154:1)
Truffle v5.0.1 (core: 5.0.1)
Node v10.14.2
error Command failed with exit code 1.
I'm guessing truffle is expecting output from solc and not vyper. Any suggestions for how to deploy this contract to my test blockchain during truffle migrate?
truffle version): v5.0.1node --version): v10.14.2npm --version): 6.4.1@WyseNynja You know, at this point I believe that Truffle will compile vyper files for you without having to use the external setup if you have them in your contracts directory.
Let me know how it goes for you.
AFAICT, that would work if I were building the entire project with Vyper. My project is written in solidity. I need Vyper for setting up my test environment with outside contracts.
On Jan 14, 2019, at 7:34 AM, tyler feickert notifications@github.com wrote:
@WyseNynja You know, at this point I believe that Truffle will compile vyper files for you without having to use the external setup if you have them in your contracts directory.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I was told to use the external compile step in #1607. Was that incorrect?
It is possible to use the external property to do this...BUT Truffle will compile Vyper contracts as well as Solidity contracts "side-by-side".
In the issue you linked to, @gnidan is referring to the current limitation of only being able to use one single version of the Solidity compiler. However, you can have a project that includes both Solidity and Vyper files and Truffle will deal with them.
@WyseNynja Did you successfully get your vyper contracts compiling?
I’ve been working on my own solidity contract interacting with 0x and haven’t done any more work with Uniswap yet.
I think dropping the Vyper contracts into the main contracts directory will work for me though. Hopefully I won’t need multiple versions of the Vyper compiler if I add another project.
Ok, let me know if you have any more questions on the way. Closing this for now.
I copied uniswap's contracts into my contracts directory, but it fails with this error:
$ truffle compile
Compiling ./contracts/external/uniswap/uniswap_exchange.vy...
Compiling ./contracts/external/uniswap/uniswap_factory.vy...
/root/.local/venvs/vyper/lib/python3.6/site-packages/vyper/types/types.py:347: DeprecationWarning: Mapping definitions using subscript have deprecated (see VIP564). Use map(type1, type2) instead.
DeprecationWarning
vyper.exceptions.InvalidTypeException: line 8: Unknown list type.
token_to_exchange: address[address]
-------------------^
Compilation of /usr/src/app/contracts/external/uniswap/uniswap_factory.vy failed. See above.
Truffle v5.0.4 (core: 5.0.4)
Node v11.9.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm guessing this is because uniswap expects vyper==0.1.0b4, but truffle is using a newer version. I don't want to modify the contracts at all since I am trying to interact with them the same way they are deployed on mainnet.
How can I tell truffle to use an old version of vyper? Or is the error something else?
If I create a truffle artifact myself with the bytecode that is included in the git checkout and an empty list for abi, I am able to truffle migrate, but I really need the abi in order to do my testing.
EDIT: Got around not having the abi by making an interface in solidity and using that.
@WyseNynja Concerning the Vyper compiler...I'll have to look into adding functionality in the config for specifying the version.
@eggplantzzz any progress on this? Or should I create a separate issue? I'm having the same issue @WyseNynja mentioned trying to add Uniswap's contracts: https://github.com/trufflesuite/truffle/issues/1623#issuecomment-464887970
I am writing vyper contracts in my Truffle project. Running vyper --version yields 0.1.0b10 - is this what Truffle is using? Or how can I see which version Truffle uses? Is there a way to specify the vyper version in Truffle?
Ideally, I could use the latest version for my own contracts (0.1.0b10) & the older version (0.1.0b4) on the Uniswap contracts.
Thanks!
This is a problem for me as well. Is there a way to tell truffle which compiler to use?
Is this issue resolved?
Most helpful comment
@WyseNynja Concerning the Vyper compiler...I'll have to look into adding functionality in the config for specifying the version.