Skip to content

Commit

Permalink
Updated dist files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jan 8, 2020
1 parent 2d5492c commit a7e29d6
Show file tree
Hide file tree
Showing 78 changed files with 451 additions and 334 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog

This change log is managed by `scripts/cmds/update-versions` but may be manually updated.

ethers/v5.0.0-beta.164 (2020-01-07 19:57)
-----------------------------------------

- Use better Description typing. ([2d5492c](https://github.com/ethers-io/ethers.js/commit/2d5492cd2ee722c818c249244af7b5bea05d67b0))
- Better property access on ABI decoded results. ([#698](https://github.com/ethers-io/ethers.js/issues/698); [13f50ab](https://github.com/ethers-io/ethers.js/commit/13f50abd847f7ddcc7e54c102da54e2d23b86fae))
- Better typing support for Description. ([d0f4642](https://github.com/ethers-io/ethers.js/commit/d0f4642f6d2c9f5119f1910a0082894c60e81191))
- Fixed resolveName when name is an address with an invalid checksum. ([#694](https://github.com/ethers-io/ethers.js/issues/694); [1e72fc7](https://github.com/ethers-io/ethers.js/commit/1e72fc7d6f7c3be4410dbdcfbab9a0463ceb52bd))

ethers/v5.0.0-beta.163 (2020-01-06 18:57)
-----------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion packages/abi/lib.esm/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "abi/5.0.0-beta.143";
export declare const version = "abi/5.0.0-beta.144";
2 changes: 1 addition & 1 deletion packages/abi/lib.esm/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const version = "abi/5.0.0-beta.143";
export const version = "abi/5.0.0-beta.144";
4 changes: 2 additions & 2 deletions packages/abi/lib.esm/abi-coder.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BytesLike } from "@ethersproject/bytes";
import { Coder, Reader, Writer } from "./coders/abstract-coder";
import { Coder, Reader, Result, Writer } from "./coders/abstract-coder";
import { ParamType } from "./fragments";
export declare type CoerceFunc = (type: string, value: any) => any;
export declare class AbiCoder {
Expand All @@ -10,6 +10,6 @@ export declare class AbiCoder {
_getReader(data: Uint8Array): Reader;
_getWriter(): Writer;
encode(types: Array<string | ParamType>, values: Array<any>): string;
decode(types: Array<string | ParamType>, data: BytesLike): any;
decode(types: Array<string | ParamType>, data: BytesLike): Result;
}
export declare const defaultAbiCoder: AbiCoder;
10 changes: 5 additions & 5 deletions packages/abi/lib.esm/abi-coder.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ export class AbiCoder {
value: { types: types, values: values }
});
}
let coders = types.map((type) => this._getCoder(ParamType.from(type)));
let coder = (new TupleCoder(coders, "_"));
let writer = this._getWriter();
const coders = types.map((type) => this._getCoder(ParamType.from(type)));
const coder = (new TupleCoder(coders, "_"));
const writer = this._getWriter();
coder.encode(writer, values);
return writer.data;
}
decode(types, data) {
let coders = types.map((type) => this._getCoder(ParamType.from(type)));
let coder = new TupleCoder(coders, "_");
const coders = types.map((type) => this._getCoder(ParamType.from(type)));
const coder = new TupleCoder(coders, "_");
return coder.decode(this._getReader(arrayify(data)));
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/abi/lib.esm/coders/abstract-coder.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { BytesLike } from "@ethersproject/bytes";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
export interface Result extends Array<any> {
[key: string]: any;
}
export declare type CoerceFunc = (type: string, value: any) => any;
export declare abstract class Coder {
readonly name: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/abi/lib.esm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
import { Indexed, Interface } from "./interface";
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType };
import { Indexed, Interface, Result } from "./interface";
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result };
30 changes: 15 additions & 15 deletions packages/abi/lib.esm/interface.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,29 @@ import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
import { BytesLike } from "@ethersproject/bytes";
import { Description } from "@ethersproject/properties";
import { AbiCoder } from "./abi-coder";
import { Result } from "./coders/abstract-coder";
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments";
export declare class LogDescription extends Description {
export { Result };
export declare class LogDescription extends Description<LogDescription> {
readonly eventFragment: EventFragment;
readonly name: string;
readonly signature: string;
readonly topic: string;
readonly values: any;
readonly args: Result;
}
export declare class TransactionDescription extends Description {
export declare class TransactionDescription extends Description<TransactionDescription> {
readonly functionFragment: FunctionFragment;
readonly name: string;
readonly args: Array<any>;
readonly args: Result;
readonly signature: string;
readonly sighash: string;
readonly value: BigNumber;
}
export declare class Indexed extends Description {
export declare class Indexed extends Description<Indexed> {
readonly hash: string;
readonly _isIndexed: boolean;
static isIndexed(value: any): value is Indexed;
}
export declare class Result {
[key: string]: any;
[key: number]: any;
}
export declare class Interface {
readonly fragments: Array<Fragment>;
readonly errors: {
Expand All @@ -44,23 +43,24 @@ export declare class Interface {
readonly _abiCoder: AbiCoder;
static _isInterface: boolean;
constructor(fragments: string | Array<Fragment | JsonFragment | string>);
format(format?: string): string | Array<string>;
static getAbiCoder(): AbiCoder;
static getAddress(address: string): string;
_sighashify(functionFragment: FunctionFragment): string;
_topicify(eventFragment: EventFragment): string;
static getSighash(functionFragment: FunctionFragment): string;
static getTopic(eventFragment: EventFragment): string;
getFunction(nameOrSignatureOrSighash: string): FunctionFragment;
getEvent(nameOrSignatureOrTopic: string): EventFragment;
getSighash(functionFragment: FunctionFragment | string): string;
getEventTopic(eventFragment: EventFragment | string): string;
_decodeParams(params: Array<ParamType>, data: BytesLike): Array<any>;
_decodeParams(params: Array<ParamType>, data: BytesLike): Result;
_encodeParams(params: Array<ParamType>, values: Array<any>): string;
encodeDeploy(values?: Array<any>): string;
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Array<any>;
decodeFunctionData(functionFragment: FunctionFragment | string, data: BytesLike): Result;
encodeFunctionData(functionFragment: FunctionFragment | string, values?: Array<any>): string;
decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Array<any>;
decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Result;
encodeFunctionResult(functionFragment: FunctionFragment | string, values?: Array<any>): string;
encodeFilterTopics(eventFragment: EventFragment, values: Array<any>): Array<string | Array<string>>;
decodeEventLog(eventFragment: EventFragment | string, data: BytesLike, topics?: Array<string>): Array<any>;
decodeEventLog(eventFragment: EventFragment | string, data: BytesLike, topics?: Array<string>): Result;
parseTransaction(tx: {
data: string;
value?: BigNumberish;
Expand Down
65 changes: 41 additions & 24 deletions packages/abi/lib.esm/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { id } from "@ethersproject/hash";
import { keccak256 } from "@ethersproject/keccak256";
import { defineReadOnly, Description, getStatic } from "@ethersproject/properties";
import { defaultAbiCoder } from "./abi-coder";
import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType } from "./fragments";
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments";
import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
Expand All @@ -19,8 +19,6 @@ export class Indexed extends Description {
return !!(value && value._isIndexed);
}
}
export class Result {
}
export class Interface {
constructor(fragments) {
logger.checkNew(new.target, Interface);
Expand Down Expand Up @@ -66,38 +64,40 @@ export class Interface {
}
bucket[signature] = fragment;
});
// Add any fragments with a unique name by its name (sans signature parameters)
/*
[this.events, this.functions].forEach((bucket) => {
let count = getNameCount(bucket);
Object.keys(bucket).forEach((signature) => {
let fragment = bucket[signature];
if (count[fragment.name] !== 1) {
logger.warn("duplicate definition - " + fragment.name);
return;
}
bucket[fragment.name] = fragment;
});
});
*/
// If we do not have a constructor use the default "constructor() payable"
if (!this.deploy) {
defineReadOnly(this, "deploy", ConstructorFragment.from({ type: "constructor" }));
}
defineReadOnly(this, "_isInterface", true);
}
format(format) {
if (!format) {
format = FormatTypes.full;
}
if (format === FormatTypes.sighash) {
logger.throwArgumentError("interface does not support formating sighash", "format", format);
}
const abi = this.fragments.map((fragment) => fragment.format(format));
// We need to re-bundle the JSON fragments a bit
if (format === FormatTypes.json) {
return JSON.stringify(abi.map((j) => JSON.parse(j)));
}
return abi;
}
// Sub-classes can override these to handle other blockchains
static getAbiCoder() {
return defaultAbiCoder;
}
static getAddress(address) {
return getAddress(address);
}
_sighashify(functionFragment) {
static getSighash(functionFragment) {
return hexDataSlice(id(functionFragment.format()), 0, 4);
}
_topicify(eventFragment) {
static getTopic(eventFragment) {
return id(eventFragment.format());
}
// Find a function definition by any means necessary (unless it is ambiguous)
getFunction(nameOrSignatureOrSighash) {
if (isHexString(nameOrSignatureOrSighash)) {
for (const name in this.functions) {
Expand Down Expand Up @@ -126,6 +126,7 @@ export class Interface {
}
return result;
}
// Find an event definition by any means necessary (unless it is ambiguous)
getEvent(nameOrSignatureOrTopic) {
if (isHexString(nameOrSignatureOrTopic)) {
const topichash = nameOrSignatureOrTopic.toLowerCase();
Expand Down Expand Up @@ -155,17 +156,19 @@ export class Interface {
}
return result;
}
// Get the sighash (the bytes4 selector) used by Solidity to identify a function
getSighash(functionFragment) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
}
return this._sighashify(functionFragment);
return getStatic(this.constructor, "getSighash")(functionFragment);
}
// Get the topic (the bytes32 hash) used by Solidity to identify an event
getEventTopic(eventFragment) {
if (typeof (eventFragment) === "string") {
eventFragment = this.getEvent(eventFragment);
}
return this._topicify(eventFragment);
return getStatic(this.constructor, "getTopic")(eventFragment);
}
_decodeParams(params, data) {
return this._abiCoder.decode(params, data);
Expand All @@ -176,6 +179,7 @@ export class Interface {
encodeDeploy(values) {
return this._encodeParams(this.deploy.inputs, values || []);
}
// Decode the data for a function call (e.g. tx.data)
decodeFunctionData(functionFragment, data) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
Expand All @@ -186,6 +190,7 @@ export class Interface {
}
return this._decodeParams(functionFragment.inputs, bytes.slice(4));
}
// Encode the data for a function call (e.g. tx.data)
encodeFunctionData(functionFragment, values) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
Expand All @@ -195,6 +200,7 @@ export class Interface {
this._encodeParams(functionFragment.inputs, values || [])
]));
}
// Decode the result from a function call (e.g. from eth_call)
decodeFunctionResult(functionFragment, data) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
Expand All @@ -212,7 +218,7 @@ export class Interface {
case 4:
if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") {
errorSignature = "Error(string)";
reason = this._abiCoder.decode(["string"], bytes.slice(4));
reason = this._abiCoder.decode(["string"], bytes.slice(4))[0];
}
break;
}
Expand All @@ -223,12 +229,14 @@ export class Interface {
reason: reason
});
}
// Encode the result for a function call (e.g. for eth_call)
encodeFunctionResult(functionFragment, values) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
}
return hexlify(this._abiCoder.encode(functionFragment.outputs, values || []));
}
// Create the filter for the event with search criteria (e.g. for eth_filterLog)
encodeFilterTopics(eventFragment, values) {
if (typeof (eventFragment) === "string") {
eventFragment = this.getEvent(eventFragment);
Expand Down Expand Up @@ -277,6 +285,7 @@ export class Interface {
}
return topics;
}
// Decode a filter for the event and the search criteria
decodeEventLog(eventFragment, data, topics) {
if (typeof (eventFragment) === "string") {
eventFragment = this.getEvent(eventFragment);
Expand Down Expand Up @@ -326,10 +335,14 @@ export class Interface {
else {
result[index] = resultNonIndexed[nonIndexedIndex++];
}
//if (param.name && result[param.name] == null) { result[param.name] = result[index]; }
if (param.name && result[param.name] == null) {
result[param.name] = result[index];
}
});
return result;
}
// Given a transaction, find the matching function fragment (if any) and
// determine all its properties and call parameters
parseTransaction(tx) {
let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase());
if (!fragment) {
Expand All @@ -344,18 +357,22 @@ export class Interface {
value: BigNumber.from(tx.value || "0"),
});
}
// Given an event log, find the matching event fragment (if any) and
// determine all its properties and values
parseLog(log) {
let fragment = this.getEvent(log.topics[0]);
if (!fragment || fragment.anonymous) {
return null;
}
// @TODO: If anonymous, and the only method, and the input count matches, should we parse?
// Probably not, because just because it is the only event in the ABI does
// not mean we have the full ABI; maybe jsut a fragment?
return new LogDescription({
eventFragment: fragment,
name: fragment.name,
signature: fragment.format(),
topic: this.getEventTopic(fragment),
values: this.decodeEventLog(fragment, log.data, log.topics)
args: this.decodeEventLog(fragment, log.data, log.topics)
});
}
/*
Expand Down
2 changes: 1 addition & 1 deletion packages/abi/lib/_version.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export declare const version = "abi/5.0.0-beta.143";
export declare const version = "abi/5.0.0-beta.144";
2 changes: 1 addition & 1 deletion packages/abi/lib/_version.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "abi/5.0.0-beta.143";
exports.version = "abi/5.0.0-beta.144";
4 changes: 2 additions & 2 deletions packages/abi/lib/abi-coder.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BytesLike } from "@ethersproject/bytes";
import { Coder, Reader, Writer } from "./coders/abstract-coder";
import { Coder, Reader, Result, Writer } from "./coders/abstract-coder";
import { ParamType } from "./fragments";
export declare type CoerceFunc = (type: string, value: any) => any;
export declare class AbiCoder {
Expand All @@ -10,6 +10,6 @@ export declare class AbiCoder {
_getReader(data: Uint8Array): Reader;
_getWriter(): Writer;
encode(types: Array<string | ParamType>, values: Array<any>): string;
decode(types: Array<string | ParamType>, data: BytesLike): any;
decode(types: Array<string | ParamType>, data: BytesLike): Result;
}
export declare const defaultAbiCoder: AbiCoder;
3 changes: 3 additions & 0 deletions packages/abi/lib/coders/abstract-coder.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { BytesLike } from "@ethersproject/bytes";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
export interface Result extends Array<any> {
[key: string]: any;
}
export declare type CoerceFunc = (type: string, value: any) => any;
export declare abstract class Coder {
readonly name: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/abi/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments";
import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder";
import { Indexed, Interface } from "./interface";
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType };
import { Indexed, Interface, Result } from "./interface";
export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType, Result };
Loading

0 comments on commit a7e29d6

Please sign in to comment.