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

Remove web3 dependency #206

Merged
merged 1 commit into from
Aug 20, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"path": "^0.12.7",
"q": "^1.5.1",
"truffle-hdwallet-provider": "^0.0.6",
"web3": "^0.20.6",
"zos-lib": "1.3.0"
},
"devDependencies": {
Expand Down
16 changes: 14 additions & 2 deletions scripts/dataEncodingTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ describe('transaction data encoding and decoding tests', function() {
// disable timeouts
this.timeout(0);

var initV2Data = "0xd76c43c60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aca94ef8bd5ffee41947b4585a84bda5a3d3da6e000000000000000000000000000000000000000000000000000000000000000c";
var configureMinterData = "0x4e44d9560000000000000000000000009c08210cc65b5c9f1961cdbd9ea9bf017522464d000000000000000000000000000000000000000000000000000000003b9aca00"
var initV2Data = "d76c43c60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aca94ef8bd5ffee41947b4585a84bda5a3d3da6e000000000000000000000000000000000000000000000000000000000000000c";
var upgradeToAndCallData = "4f1ef286000000000000000000000000023fe1585d8361f0584aaa78c152f94cdcff7b3000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064d76c43c60000000000000000000000000000000000000000000000000000000000000001000000000000000000000000aca94ef8bd5ffee41947b4585a84bda5a3d3da6e000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000"
var configureMinterData = "4e44d9560000000000000000000000009c08210cc65b5c9f1961cdbd9ea9bf017522464d000000000000000000000000000000000000000000000000000000003b9aca00"

it('td001 should return correct data using encodeTxData with --compile flag', async function () {
const { stdout, stderr } = await exec('truffle exec --compile ./scripts/encodeTxData.js FiatTokenV2NewFieldsTest initV2 true 0xaca94ef8bd5ffee41947b4585a84bda5a3d3da6e 12');
Expand Down Expand Up @@ -54,4 +55,15 @@ describe('transaction data encoding and decoding tests', function() {
assert.equal(decodedData.inputs[0], "9c08210cc65b5c9f1961cdbd9ea9bf017522464d")
assert.equal(decodedData.inputs[1], "1000000000")
})

it('td007 should decode a data string for FiatTokenProxy and its byte array input to a hex string', async function () {
await exec ("truffle exec scripts/decodeTxData.js --contract FiatTokenProxy --data " + upgradeToAndCallData + " --filename initV2Test")
var decodedDataJson = fs.readFileSync('decoded_data/initV2Test.json');
var decodedData = JSON.parse(decodedDataJson);
assert.equal(decodedData.name, "upgradeToAndCall")
assert.equal(decodedData.types[0], "address")
assert.equal(decodedData.types[1], "bytes")
assert.equal(decodedData.inputs[0], "023fe1585d8361f0584aaa78c152f94cdcff7b30")
assert.equal(decodedData.inputs[1], initV2Data)
})
})
16 changes: 9 additions & 7 deletions scripts/decodeTxData.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ const InputDataDecoder = require('ethereum-input-data-decoder')
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var web3 = require('web3')

var args = process.argv;

var dataFlagIndex = args.indexOf("--data");
Expand All @@ -24,10 +22,16 @@ var contractNameFlagIndex = args.indexOf("--contract")
var contractName = args[contractNameFlagIndex + 1]
var fileNameFlagIndex = args.indexOf("--filename")

var FiatTokenVX = artifacts.require(contractName)
var abi = FiatTokenVX.abi
var contract = artifacts.require(contractName)
var abi = contract.abi
var decoder = new InputDataDecoder(abi)

function toHexString(byteArray) {
return Array.from(byteArray, function(byte) {
return ('0' + (byte & 0xFF).toString(16)).slice(-2);
}).join('')
}

function decode() {
result = decoder.decodeData(data)
for (i = 0; i < result.inputs.length; i++) {
Expand All @@ -36,11 +40,9 @@ function decode() {
result.inputs[i] = result.inputs[i].toString()
}
if (result.types[i] == "bytes") {
result.inputs[i] = web3.utils.bytesToHex(result.inputs[i])
result.inputs[i] = toHexString(result.inputs[i])
}

}

var decodedDataJson = JSON.stringify(result)

if (fileNameFlagIndex != -1) {
Expand Down
20 changes: 0 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1775,10 +1775,6 @@ cookie@0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"

cookiejar@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c"

copy-concurrently@^1.0.0:
version "1.0.5"
resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0"
Expand Down Expand Up @@ -7663,16 +7659,6 @@ web3@^0.18.2, web3@^0.18.4:
xhr2 "*"
xmlhttprequest "*"

web3@^0.20.6:
version "0.20.7"
resolved "https://registry.yarnpkg.com/web3/-/web3-0.20.7.tgz#1605e6d81399ed6f85a471a4f3da0c8be57df2f7"
dependencies:
bignumber.js "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
crypto-js "^3.1.4"
utf8 "^2.1.1"
xhr2-cookies "^1.1.0"
xmlhttprequest "*"

webpack-addons@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/webpack-addons/-/webpack-addons-1.1.5.tgz#2b178dfe873fb6e75e40a819fa5c26e4a9bc837a"
Expand Down Expand Up @@ -7811,12 +7797,6 @@ xdg-basedir@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"

xhr2-cookies@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/xhr2-cookies/-/xhr2-cookies-1.1.0.tgz#7d77449d0999197f155cb73b23df72505ed89d48"
dependencies:
cookiejar "^2.1.1"

xhr2@*:
version "0.1.4"
resolved "https://registry.yarnpkg.com/xhr2/-/xhr2-0.1.4.tgz#7f87658847716db5026323812f818cadab387a5f"
Expand Down