CHANGE web3js to etherjs

pull/15/head
pubkey 6 years ago
parent 2e8b90110a
commit 826e9443f6
  1. 3
      package.json
  2. 20
      src/hash.js
  3. 16
      src/tx-data-by-compiled.js

@ -106,9 +106,8 @@
"eth-lib": "0.2.8",
"ethereumjs-tx": "1.3.6",
"ethereumjs-util": "5.2.0",
"ethers": "3.0.25",
"secp256k1": "3.5.0",
"web3-eth-contract": "1.0.0-beta.34",
"web3-utils": "1.0.0-beta.34",
"webpack": "4.15.1",
"webpack-bundle-analyzer": "2.13.1",
"webpack-cli": "3.0.8"

@ -1,15 +1,21 @@
import {
soliditySha3
} from 'web3-utils';
keccak256 as solidityKeccak256
} from 'ethers/utils/solidity.js';
export function keccak256(params) {
const types = [];
const values = [];
if (!Array.isArray(params)) {
params = [{
type: 'string',
value: params
}];
types.push('string');
values.push(params);
}else {
params.forEach(p => {
types.push(p.type);
values.push(p.value);
});
}
return soliditySha3(...params);
return solidityKeccak256(types, values);
}
export const SIGN_PREFIX = '\x19Ethereum Signed Message:\n32';

@ -1,24 +1,18 @@
import * as Web3EthContract from 'web3-eth-contract';
import Contract from 'ethers/contracts/contract.js';
export default function txDataByCompiled(
abi,
bytecode,
args
) {
// solc returns a string which is often passed instead of the json
if (typeof abi === 'string') abi = JSON.parse(abi);
const web3Contract = new Web3EthContract.default(
const deployTransaction = Contract.getDeployTransaction(
'0x' + bytecode,
abi,
null, {
data: '0x' + bytecode
}
...args
);
const createCode = web3Contract.deploy({
arguments: args
}).encodeABI();
return createCode;
return deployTransaction.data;
}

Loading…
Cancel
Save