Skip to content

Commit

Permalink
Added type to TransactionResponse and TrnsactionReceipt (#1687).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 24, 2021
1 parent 91951dc commit d001901
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/abstract-provider/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface TransactionReceipt {
confirmations: number,
cumulativeGasUsed: BigNumber,
byzantium: boolean,
type: number;
status?: number
};

Expand Down
11 changes: 9 additions & 2 deletions packages/providers/src.ts/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ export class Formatter {
const hash = this.hash.bind(this);
const hex = this.hex.bind(this);
const number = this.number.bind(this);
const type = this.type.bind(this);

const strictData = (v: any) => { return this.data(v, true); };

formats.transaction = {
hash: hash,

type: Formatter.allowNull(number, null),
type: type,
accessList: Formatter.allowNull(this.accessList.bind(this), null),

blockHash: Formatter.allowNull(hash, null),
Expand Down Expand Up @@ -116,7 +117,8 @@ export class Formatter {
blockNumber: number,
confirmations: Formatter.allowNull(number, null),
cumulativeGasUsed: bigNumber,
status: Formatter.allowNull(number)
status: Formatter.allowNull(number),
type: type
};

formats.block = {
Expand Down Expand Up @@ -178,6 +180,11 @@ export class Formatter {
return BigNumber.from(number).toNumber();
}

type(number: any): number {
if (number === "0x" || number == null) { return 0; }
return BigNumber.from(number).toNumber();
}

// Strict! Used on input.
bigNumber(value: any): BigNumber {
return BigNumber.from(value);
Expand Down
2 changes: 1 addition & 1 deletion packages/transactions/src.ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function _serialize(transaction: UnsignedTransaction, signature?: SignatureLike)

export function serialize(transaction: UnsignedTransaction, signature?: SignatureLike): string {
// Legacy and EIP-155 Transactions
if (transaction.type == null) {
if (transaction.type == null || transaction.type === 0) {
if (transaction.accessList != null) {
logger.throwArgumentError("untyped transactions do not support accessList; include type: 1", "transaction", transaction);
}
Expand Down

0 comments on commit d001901

Please sign in to comment.