Compare commits

..

15 Commits

Author SHA1 Message Date
Richard Moore
4478896ca5 Fixed testcases for PhantomJS syntax. 2020-01-03 19:43:27 -05:00
Richard Moore
f996ec0c32 Updated dist files. 2020-01-03 19:01:29 -05:00
Richard Moore
c76e01e61f Properly handle errors in the IpcProvider (#695). 2020-01-03 18:56:07 -05:00
Richard Moore
f8087ae39c Added utility function to compute CREATE2 addresses (#697). 2020-01-03 18:20:15 -05:00
Richard Moore
7250cdcd31 Updated dist files. 2019-12-21 01:09:18 -05:00
Richard Moore
20f34f1ba9 Added proper support for v0.6 Solidity JSON type (#688). 2019-12-21 01:03:05 -05:00
Richard Moore
4ac08432b8 Fixed PhantomJS test cases for new elliptic library. 2019-11-24 20:56:28 +09:00
Richard Moore
3e3048df81 Merge branch 'master' of github.com:ethers-io/ethers.js 2019-11-24 20:06:38 +09:00
Richard Moore
c6199bf52a Updated dist files. 2019-11-24 20:06:10 +09:00
Richard Moore
20409c083c Update elliptic package to protect from Minerva timing attack (#666). 2019-11-24 19:55:10 +09:00
Richard Moore
7a90f18145 Do not poll if disabled during the previous event loop. 2019-11-24 19:34:17 +09:00
Richard Moore
df1ae611ba Moved node types to devDependencies (#663). 2019-11-24 19:33:02 +09:00
Richard Moore
6009a26c89 Added provider property to Web3Provider (#641). 2019-11-24 19:31:02 +09:00
Richard Moore
30984b6f00 Merge pull request #628 from evertonfraga/patch-1
Fix typo in tests/readme.md.
2019-11-20 21:01:58 +09:00
Ev
5af16a6090 Update README.md 2019-10-14 01:25:55 +09:00
32 changed files with 655 additions and 329 deletions

View File

@@ -1,6 +1,25 @@
CHANGELOG
=========
ethers/v4.0.42 (2020-01-03 18:35)
---------------------------------
- Properly handle errors in the IpcProvider ([#695](https://github.com/ethers-io/ethers.js/issues/695); [c76e01e](https://github.com/ethers-io/ethers.js/commit/c76e01e61fd52692f58c516842f7ed3b252b0f83))
- Added utility function to compute CREATE2 addresses ([#697](https://github.com/ethers-io/ethers.js/issues/697); [f8087ae](https://github.com/ethers-io/ethers.js/commit/f8087ae39ce7631425b6b4763347a4f9618f9730))
ethers/v4.0.41 (2019-12-21 01:05)
---------------------------------
- Added proper support for v0.6 Solidity JSON type ([#688](https://github.com/ethers-io/ethers.js/issues/688); [20f34f1](https://github.com/ethers-io/ethers.js/commit/20f34f1ba9c698d1731cb12c5de1822ad462fd7f)).
ethers/v4.0.40 (2019-11-24 19:58)
---------------------------------
- Update elliptic package to protect from Minerva timing attack ([#666](https://github.com/ethers-io/ethers.js/issues/666); [20409c0](https://github.com/ethers-io/ethers.js/commit/20409c083cd428c46cba09488ee609cc14ff1d2b)).
- Do not poll if disabled during the previous event loop. ([7a90f18](https://github.com/ethers-io/ethers.js/commit/7a90f18145931e7ff790cd9e1fd549929fbb9023)).
- Moved node types to devDependencies ([#663](https://github.com/ethers-io/ethers.js/issues/663); [df1ae61](https://github.com/ethers-io/ethers.js/commit/df1ae611bab0955005b0da6604191b60b34f198f)).
- Added provider property to Web3Provider ([#641](https://github.com/ethers-io/ethers.js/issues/641); [6009a26](https://github.com/ethers-io/ethers.js/commit/6009a26c89c359ae44ef4b6e8a664ed57db24f67)).
ethers/v4.0.39 (2019-10-30 19:15)
---------------------------------

2
_version.d.ts vendored
View File

@@ -1 +1 @@
export declare const version = "4.0.39";
export declare const version = "4.0.42";

View File

@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "4.0.39";
exports.version = "4.0.42";

646
dist/ethers.js vendored

File diff suppressed because it is too large Load Diff

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13
dist/ethers.types.txt vendored
View File

@@ -211,7 +211,7 @@ declare module 'ethers/providers' {
declare module 'ethers/utils' {
import { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType } from 'ethers/utils/abi-coder';
import { getAddress, getContractAddress, getIcapAddress } from 'ethers/utils/address';
import { getAddress, getContractAddress, getCreate2Address, getIcapAddress } from 'ethers/utils/address';
import * as base64 from 'ethers/utils/base64';
import { BigNumber, bigNumberify } from 'ethers/utils/bignumber';
import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexZeroPad, isHexString, joinSignature, padZeros, splitSignature, stripZeros } from 'ethers/utils/bytes';
@@ -244,7 +244,7 @@ declare module 'ethers/utils' {
import { ConnectionInfo, OnceBlockable, PollOptions } from 'ethers/utils/web';
import { EncryptOptions, ProgressCallback } from 'ethers/utils/secret-storage';
import { Wordlist } from 'ethers/utils/wordlist';
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
}
declare module 'ethers/wordlists' {
@@ -266,7 +266,7 @@ declare module 'ethers/utils/shims' {
}
declare module 'ethers/_version' {
export const version = "4.0.39";
export const version = "4.0.42";
}
declare module 'ethers/utils/bignumber' {
@@ -898,6 +898,13 @@ declare module 'ethers/utils/address' {
from: string;
nonce: Arrayish | BigNumber | number;
}): string;
export type Create2Options = {
from: string;
salt: Arrayish;
initCode?: Arrayish;
initCodeHash?: Arrayish;
};
export function getCreate2Address(options: Create2Options): string;
}
declare module 'ethers/utils/base64' {

2
dist/shims.js vendored

File diff suppressed because one or more lines are too long

20
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "ethers",
"version": "4.0.37",
"version": "4.0.40",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -92,7 +92,8 @@
"@types/node": {
"version": "10.14.12",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.12.tgz",
"integrity": "sha512-QcAKpaO6nhHLlxWBvpc4WeLrTvPqlHOvaj0s5GriKkA1zq+bsFBPpfYCvQhLqLgYlIko8A9YrPdaMHCo5mBcpg=="
"integrity": "sha512-QcAKpaO6nhHLlxWBvpc4WeLrTvPqlHOvaj0s5GriKkA1zq+bsFBPpfYCvQhLqLgYlIko8A9YrPdaMHCo5mBcpg==",
"dev": true
},
"JSONStream": {
"version": "1.3.5",
@@ -1827,14 +1828,17 @@
"dev": true
},
"elliptic": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz",
"integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.2.tgz",
"integrity": "sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw==",
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"hash.js": "^1.0.0",
"inherits": "^2.0.1"
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
}
},
"emoji-regex": {
@@ -3661,7 +3665,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
"dev": true,
"requires": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
@@ -4589,8 +4592,7 @@
"minimalistic-crypto-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=",
"dev": true
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
},
"minimatch": {
"version": "3.0.4",

View File

@@ -1,6 +1,6 @@
{
"name": "ethers",
"version": "4.0.39",
"version": "4.0.42",
"description": "Ethereum wallet library.",
"main": "./index.js",
"types": "./index.d.ts",
@@ -19,10 +19,9 @@
"version": "npm dist"
},
"dependencies": {
"@types/node": "^10.3.2",
"aes-js": "3.0.0",
"bn.js": "^4.4.0",
"elliptic": "6.3.3",
"elliptic": "6.5.2",
"hash.js": "1.1.3",
"js-sha3": "0.5.7",
"scrypt-js": "2.0.4",
@@ -31,6 +30,7 @@
"xmlhttprequest": "1.8.0"
},
"devDependencies": {
"@types/node": "^10.3.2",
"browserify": "^16.2.3",
"browserify-zlib": "^0.2.0",
"dts-bundle": "^0.7.3",

View File

@@ -452,6 +452,9 @@ var BaseProvider = /** @class */ (function (_super) {
BaseProvider.prototype._doPoll = function () {
var _this = this;
this.getBlockNumber().then(function (blockNumber) {
if (!_this.polling) {
return;
}
_this._setFastBlockNumber(blockNumber);
// If the block hasn't changed, meh.
if (blockNumber === _this._lastBlockNumber) {

View File

@@ -59,8 +59,16 @@ var IpcProvider = /** @class */ (function (_super) {
});
stream.on("end", function () {
try {
resolve(JSON.parse(response.toString('utf8')).result);
// @TODO: Better pull apart the error
var payload_1 = JSON.parse(response.toString('utf8'));
if (payload_1.error) {
var error = new Error(payload_1.error.message);
error.code = payload_1.error.code;
error.data = payload_1.error.data;
reject(error);
}
else {
resolve(payload_1.result);
}
stream.destroy();
}
catch (error) {

View File

@@ -47,6 +47,8 @@ var Web3Provider = /** @class */ (function (_super) {
errors.throwError('invalid web3Provider', errors.INVALID_ARGUMENT, { arg: 'web3Provider', value: web3Provider });
}
properties_1.defineReadOnly(_this, '_web3Provider', web3Provider);
// @TODO: In v5 remove the above definition; only this one is needed
properties_1.defineReadOnly(_this, 'provider', web3Provider);
return _this;
}
Web3Provider.prototype.send = function (method, params) {

View File

@@ -1 +1 @@
export const version = "4.0.39";
export const version = "4.0.42";

View File

@@ -573,6 +573,8 @@ export class BaseProvider extends Provider {
private _doPoll(): void {
this.getBlockNumber().then((blockNumber) => {
if (!this.polling) { return; }
this._setFastBlockNumber(blockNumber);
// If the block hasn't changed, meh.

View File

@@ -54,8 +54,15 @@ export class IpcProvider extends JsonRpcProvider {
stream.on("end", () => {
try {
resolve(JSON.parse(response.toString('utf8')).result);
// @TODO: Better pull apart the error
const payload = JSON.parse(response.toString('utf8'));
if (payload.error) {
const error: any = new Error(payload.error.message);
error.code = payload.error.code;
error.data = payload.error.data;
reject(error);
} else {
resolve(payload.result);
}
stream.destroy();
} catch (error) {
reject(error);

View File

@@ -55,6 +55,9 @@ export class Web3Provider extends JsonRpcProvider {
}
defineReadOnly(this, '_web3Provider', web3Provider);
// @TODO: In v5 remove the above definition; only this one is needed
defineReadOnly(this, 'provider', web3Provider);
}
send(method: string, params: any): Promise<any> {

View File

@@ -3,7 +3,7 @@
// We use this for base 36 maths
import BN from 'bn.js';
import { arrayify, stripZeros, hexlify } from './bytes';
import { arrayify, concat, stripZeros, hexlify } from './bytes';
import { BigNumber } from './bignumber';
import { keccak256 } from './keccak256';
import { encode } from './rlp';
@@ -140,3 +140,47 @@ export function getContractAddress(transaction: { from: string, nonce: Arrayish
])).substring(26));
}
export type Create2Options = {
from: string,
salt: Arrayish,
initCode?: Arrayish,
initCodeHash?: Arrayish,
};
// See: https://eips.ethereum.org/EIPS/eip-1014
export function getCreate2Address(options: Create2Options): string {
let initCodeHash = options.initCodeHash;
if (options.initCode) {
if (initCodeHash) {
if (keccak256(options.initCode) !== initCodeHash) {
errors.throwError("initCode/initCodeHash mismatch", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
} else {
initCodeHash = keccak256(options.initCode);
}
}
if (!initCodeHash) {
errors.throwError("missing initCode or initCodeHash", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
const from = getAddress(options.from);
const salt = arrayify(options.salt);
if (salt.length !== 32) {
errors.throwError("invalid salt", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
return getAddress("0x" + keccak256(concat([
"0xff",
from,
salt,
initCodeHash
])).substring(26));
}

View File

@@ -1,7 +1,7 @@
'use strict';
import { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType } from './abi-coder';
import { getAddress, getContractAddress, getIcapAddress } from './address';
import { getAddress, getContractAddress, getCreate2Address, getIcapAddress } from './address';
import * as base64 from './base64';
import { BigNumber, bigNumberify } from './bignumber';
import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexZeroPad, isHexString, joinSignature, padZeros, splitSignature, stripZeros } from './bytes';
@@ -103,6 +103,7 @@ export {
getAddress,
getIcapAddress,
getContractAddress,
getCreate2Address,
formatEther,
parseEther,

View File

@@ -311,6 +311,13 @@ function addMethod(method: any): void {
let signature = formatSignature(method).replace(/tuple/g, '');
let sighash = id(signature).substring(0, 10);
let isConst = false;
if (method.constant != null) {
isConst = method.constant;
} else if (method.stateMutability != null) {
isConst = (method.stateMutability == "view" || method.stateMutability == "pure");
}
let description = new _FunctionDescription({
inputs: method.inputs,
outputs: method.outputs,
@@ -318,7 +325,7 @@ function addMethod(method: any): void {
gas: method.gas,
payable: (method.payable == null || !!method.payable),
type: ((method.constant) ? 'call': 'transaction'),
type: (isConst ? 'call': 'transaction'),
name: method.name,
signature: signature,

View File

@@ -63,7 +63,7 @@ Building Testcases
------------------
Each suite of testcases is produced from a variety of sources. Many include a
specific set of test vecotrs as well as procedurally generated tests using known
specific set of test vectors as well as procedurally generated tests using known
correct implementations.
The `contract-interface` test cases are created by selecting a (deterministically) random

View File

@@ -110,4 +110,8 @@ function Reporter(runner) {
});
}
try {
window.ethersReporter = Reporter;
} catch (error) { }
module.exports = Reporter;

View File

@@ -59,6 +59,13 @@ if (!ArrayBuffer.isView) {
}
}
if (Array.prototype.fill == null) {
shims.push("Array.fill");
Array.prototype.fill = function(value) {
for (var i = 0; i < this.length; i++) { this[i] = value; }
}
}
// Shim nextTick
if (!global.nextTick) {
shims.push("nextTick");

View File

@@ -36,3 +36,64 @@ describe('Checksum and ICAP address generation', function() {
});
});
});
describe("Create2 Address Generation", function() {
var tests = [
{
name: "Example 0",
from: "0x0000000000000000000000000000000000000000",
salt: "0x0000000000000000000000000000000000000000000000000000000000000000",
initCode: "0x00",
expected: "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"
},
{
name: "Example 1",
from: "0xdeadbeef00000000000000000000000000000000",
salt: "0x0000000000000000000000000000000000000000000000000000000000000000",
initCode: "0x00",
expected: "0xB928f69Bb1D91Cd65274e3c79d8986362984fDA3"
},
{
name: "Example 2",
from: "0xdeadbeef00000000000000000000000000000000",
salt: "0x000000000000000000000000feed000000000000000000000000000000000000",
initCode: "0x00",
expected: "0xD04116cDd17beBE565EB2422F2497E06cC1C9833"
},
{
name: "Example 3",
from: "0x0000000000000000000000000000000000000000",
salt: "0x0000000000000000000000000000000000000000000000000000000000000000",
initCode: "0xdeadbeef",
expected: "0x70f2b2914A2a4b783FaEFb75f459A580616Fcb5e"
},
{
name: "Example 4",
from: "0x00000000000000000000000000000000deadbeef",
salt: "0x00000000000000000000000000000000000000000000000000000000cafebabe",
initCode: "0xdeadbeef",
expected: "0x60f3f640a8508fC6a86d45DF051962668E1e8AC7"
},
{
name: "Example 5",
from: "0x00000000000000000000000000000000deadbeef",
salt: "0x00000000000000000000000000000000000000000000000000000000cafebabe",
initCode: "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
expected: "0x1d8bfDC5D46DC4f61D6b6115972536eBE6A8854C"
},
{
name: "Example 6",
from: "0x0000000000000000000000000000000000000000",
salt: "0x0000000000000000000000000000000000000000000000000000000000000000",
initCode: "0x",
expected: "0xE33C0C7F7df4809055C3ebA6c09CFe4BaF1BD9e0"
},
];
tests.forEach(function(test) {
it("correctly computes the Create2 address - " + test.name, function() {
var address = ethers.utils.getCreate2Address(test);
assert.equal(address, test.expected, "correctly computes Create2 address");
});
});
});

View File

@@ -540,3 +540,46 @@ describe('Test Filters', function() {
doTest(test);
});
});
describe('Test Solidity v0.6 ABI', function() {
var tests = [
{
inputs: [ ],
outputs: [ ],
stateMutability: "view",
type: "function",
name: "testView_call"
},
{
inputs: [ ],
outputs: [ ],
stateMutability: "pure",
type: "function",
name: "testPure_call"
},
{
inputs: [ ],
outputs: [ ],
stateMutability: "payable",
type: "function",
name: "testPayable_transaction"
},
{
inputs: [ ],
outputs: [ ],
stateMutability: "nonpayable",
type: "function",
name: "testNonpayable_transaction"
},
];
tests.forEach(function(test, index) {
var type = test.name.split("_")[1];
it(('generates fragment from ABI - ' + test.name.split("_")[0]), function() {
var iface = new ethers.utils.Interface(JSON.stringify([ test ]));
var func = iface.functions[test.name];
assert.equal(func.type, type, "matches type");
});
});
});

View File

@@ -38,7 +38,7 @@
<!-- Run the test cases! -->
<script type="text/javascript">
mocha.reporter(tests.reporter);
mocha.reporter(ethersReporter);
// Use this to focus on specific test cases
//mocha.grep(new RegExp('easyseed')).run();

View File

@@ -1,7 +1,7 @@
var assert = require('assert');
function getEthers(filename) {
let ethers = require('../index');
var ethers = require('../index');
console.log('Loaded local ethers: ' + filename);
assert.equal(ethers.platform, 'node', 'platform: ' + ethers.platform + ' != "node"');
return ethers;

7
utils/address.d.ts vendored
View File

@@ -6,3 +6,10 @@ export declare function getContractAddress(transaction: {
from: string;
nonce: Arrayish | BigNumber | number;
}): string;
export declare type Create2Options = {
from: string;
salt: Arrayish;
initCode?: Arrayish;
initCodeHash?: Arrayish;
};
export declare function getCreate2Address(options: Create2Options): string;

View File

@@ -123,3 +123,38 @@ function getContractAddress(transaction) {
])).substring(26));
}
exports.getContractAddress = getContractAddress;
// See: https://eips.ethereum.org/EIPS/eip-1014
function getCreate2Address(options) {
var initCodeHash = options.initCodeHash;
if (options.initCode) {
if (initCodeHash) {
if (keccak256_1.keccak256(options.initCode) !== initCodeHash) {
errors.throwError("initCode/initCodeHash mismatch", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
}
else {
initCodeHash = keccak256_1.keccak256(options.initCode);
}
}
if (!initCodeHash) {
errors.throwError("missing initCode or initCodeHash", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
var from = getAddress(options.from);
var salt = bytes_1.arrayify(options.salt);
if (salt.length !== 32) {
errors.throwError("invalid salt", errors.INVALID_ARGUMENT, {
arg: "options", value: options
});
}
return getAddress("0x" + keccak256_1.keccak256(bytes_1.concat([
"0xff",
from,
salt,
initCodeHash
])).substring(26));
}
exports.getCreate2Address = getCreate2Address;

4
utils/index.d.ts vendored
View File

@@ -1,5 +1,5 @@
import { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType } from './abi-coder';
import { getAddress, getContractAddress, getIcapAddress } from './address';
import { getAddress, getContractAddress, getCreate2Address, getIcapAddress } from './address';
import * as base64 from './base64';
import { BigNumber, bigNumberify } from './bignumber';
import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexZeroPad, isHexString, joinSignature, padZeros, splitSignature, stripZeros } from './bytes';
@@ -32,4 +32,4 @@ import { Transaction, UnsignedTransaction } from './transaction';
import { ConnectionInfo, OnceBlockable, PollOptions } from './web';
import { EncryptOptions, ProgressCallback } from './secret-storage';
import { Wordlist } from './wordlist';
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };
export { AbiCoder, defaultAbiCoder, formatSignature, formatParamType, parseSignature, parseParamType, RLP, fetchJson, getNetwork, checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy, arrayify, concat, padZeros, stripZeros, HDNode, SigningKey, Interface, base64, BigNumber, bigNumberify, hexlify, isHexString, hexStripZeros, hexZeroPad, hexDataLength, hexDataSlice, toUtf8Bytes, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, id, getAddress, getIcapAddress, getContractAddress, getCreate2Address, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, populateTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, computePublicKey, recoverAddress, recoverPublicKey, verifyMessage, poll, SupportedAlgorithms, UnicodeNormalizationForm, CoerceFunc, EventFragment, FunctionFragment, ParamType, BigNumberish, Arrayish, Hexable, Signature, Indexed, DeployDescription, EventDescription, FunctionDescription, LogDescription, TransactionDescription, Network, Networkish, Transaction, UnsignedTransaction, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback, Wordlist, };

View File

@@ -17,6 +17,7 @@ exports.parseParamType = abi_coder_1.parseParamType;
var address_1 = require("./address");
exports.getAddress = address_1.getAddress;
exports.getContractAddress = address_1.getContractAddress;
exports.getCreate2Address = address_1.getCreate2Address;
exports.getIcapAddress = address_1.getIcapAddress;
var base64 = __importStar(require("./base64"));
exports.base64 = base64;

View File

@@ -243,12 +243,19 @@ function addMethod(method) {
case 'function': {
var signature = abi_coder_1.formatSignature(method).replace(/tuple/g, '');
var sighash = hash_1.id(signature).substring(0, 10);
var isConst = false;
if (method.constant != null) {
isConst = method.constant;
}
else if (method.stateMutability != null) {
isConst = (method.stateMutability == "view" || method.stateMutability == "pure");
}
var description = new _FunctionDescription({
inputs: method.inputs,
outputs: method.outputs,
gas: method.gas,
payable: (method.payable == null || !!method.payable),
type: ((method.constant) ? 'call' : 'transaction'),
type: (isConst ? 'call' : 'transaction'),
name: method.name,
signature: signature,
sighash: sighash,