-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-transaction-error
- Loading branch information
Showing
29 changed files
with
381 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/api/src/block/blockDetail.dto.ts → packages/api/src/block/blockDetails.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/api/src/common/transformers/hexToDecimalNumber.transformer.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { hexToDecimalNumberTransformer } from "./hexToDecimalNumber.transformer"; | ||
|
||
describe("hexToDecimalNumberTransformer", () => { | ||
describe("to", () => { | ||
it("returns null for null input", () => { | ||
const result = hexToDecimalNumberTransformer.to(null); | ||
expect(result).toBeNull(); | ||
}); | ||
|
||
it("returns hex representation of the decimal number string", () => { | ||
const result = hexToDecimalNumberTransformer.to("800"); | ||
expect(result).toBe("0x0320"); | ||
}); | ||
}); | ||
|
||
describe("from", () => { | ||
it("returns null for null input", () => { | ||
const result = hexToDecimalNumberTransformer.from(null); | ||
expect(result).toBeNull(); | ||
}); | ||
|
||
it("returns decimal representation of the hex number string", () => { | ||
const result = hexToDecimalNumberTransformer.from("0x320"); | ||
expect(result).toBe("800"); | ||
}); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/api/src/common/transformers/hexToDecimalNumber.transformer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BigNumber } from "ethers"; | ||
import { ValueTransformer } from "typeorm"; | ||
|
||
export const hexToDecimalNumberTransformer: ValueTransformer = { | ||
to(decimalNumberStr: string | null): string | null { | ||
if (!decimalNumberStr) { | ||
return null; | ||
} | ||
return BigNumber.from(decimalNumberStr).toHexString(); | ||
}, | ||
from(hexNumberStr: string | null): string | null { | ||
if (!hexNumberStr) { | ||
return null; | ||
} | ||
return BigNumber.from(hexNumberStr).toString(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/api/src/transaction/dtos/transactionDetails.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { TransactionDto } from "./transaction.dto"; | ||
|
||
export class TransactionDetailsDto extends TransactionDto { | ||
@ApiProperty({ | ||
type: String, | ||
description: "Gas used by the transaction", | ||
example: "50000000", | ||
}) | ||
public readonly gasUsed: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/api/src/transaction/entities/transactionDetails.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Entity } from "typeorm"; | ||
import { Transaction } from "./transaction.entity"; | ||
|
||
@Entity({ name: "transactions" }) | ||
export class TransactionDetails extends Transaction { | ||
public get gasUsed(): string { | ||
return this.transactionReceipt ? this.transactionReceipt.gasUsed : null; | ||
} | ||
|
||
toJSON(): any { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { transactionReceipt, ...restFields } = super.toJSON(); | ||
return { | ||
...restFields, | ||
gasUsed: this.gasUsed, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.