aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/calldata.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-20 06:35:40 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commit67dd062a2f6a936cad18ff81afac398cd6a1ab97 (patch)
tree1f9a7402e662bc90c6cf493f571db137ce008b0b /packages/utils/src/abi_encoder/calldata.ts
parent0c0bcb44d3ef6d68c9c7c05be25641ef57a7287a (diff)
downloaddexon-0x-contracts-67dd062a2f6a936cad18ff81afac398cd6a1ab97.tar.gz
dexon-0x-contracts-67dd062a2f6a936cad18ff81afac398cd6a1ab97.tar.zst
dexon-0x-contracts-67dd062a2f6a936cad18ff81afac398cd6a1ab97.zip
Cleaning up optimizer tests
Diffstat (limited to 'packages/utils/src/abi_encoder/calldata.ts')
-rw-r--r--packages/utils/src/abi_encoder/calldata.ts37
1 files changed, 29 insertions, 8 deletions
diff --git a/packages/utils/src/abi_encoder/calldata.ts b/packages/utils/src/abi_encoder/calldata.ts
index 11288064e..e6ce58957 100644
--- a/packages/utils/src/abi_encoder/calldata.ts
+++ b/packages/utils/src/abi_encoder/calldata.ts
@@ -20,7 +20,14 @@ export abstract class CalldataBlock {
private relocatable: boolean;
private parentName: string;
- constructor(name: string, signature: string, parentName: string, /*offsetInBytes: number,*/ headerSizeInBytes: number, bodySizeInBytes: number, relocatable: boolean) {
+ constructor(
+ name: string,
+ signature: string,
+ parentName: string,
+ /*offsetInBytes: number,*/ headerSizeInBytes: number,
+ bodySizeInBytes: number,
+ relocatable: boolean,
+ ) {
this.name = name;
this.signature = signature;
this.parentName = parentName;
@@ -91,7 +98,13 @@ export abstract class CalldataBlock {
export class PayloadCalldataBlock extends CalldataBlock {
private payload: Buffer;
- constructor(name: string, signature: string, parentName: string, /*offsetInBytes: number,*/ relocatable: boolean, payload: Buffer) {
+ constructor(
+ name: string,
+ signature: string,
+ parentName: string,
+ /*offsetInBytes: number,*/ relocatable: boolean,
+ payload: Buffer,
+ ) {
const headerSizeInBytes = 0;
const bodySizeInBytes = payload.byteLength;
super(name, signature, parentName, headerSizeInBytes, bodySizeInBytes, relocatable);
@@ -115,7 +128,14 @@ export class DependentCalldataBlock extends CalldataBlock {
private dependency: CalldataBlock;
private aliasFor: CalldataBlock | undefined;
- constructor(name: string, signature: string, parentName: string, relocatable: boolean, dependency: CalldataBlock, parent: CalldataBlock) {
+ constructor(
+ name: string,
+ signature: string,
+ parentName: string,
+ relocatable: boolean,
+ dependency: CalldataBlock,
+ parent: CalldataBlock,
+ ) {
const headerSizeInBytes = 0;
const bodySizeInBytes = DependentCalldataBlock.DEPENDENT_PAYLOAD_SIZE_IN_BYTES;
super(name, signature, parentName, headerSizeInBytes, bodySizeInBytes, relocatable);
@@ -125,7 +145,8 @@ export class DependentCalldataBlock extends CalldataBlock {
}
public toBuffer(): Buffer {
- const destinationOffset = (this.aliasFor !== undefined) ? this.aliasFor.getOffsetInBytes() : this.dependency.getOffsetInBytes();
+ const destinationOffset =
+ this.aliasFor !== undefined ? this.aliasFor.getOffsetInBytes() : this.dependency.getOffsetInBytes();
const parentOffset = this.parent.getOffsetInBytes();
const parentHeaderSize = this.parent.getHeaderSizeInBytes();
const pointer: number = destinationOffset - (parentOffset + parentHeaderSize);
@@ -314,7 +335,7 @@ export class Calldata {
//const ancestrialNamesOffset = name.startsWith('ptr<') ? 4 : 0;
//const parentOffset = name.lastIndexOf(parentName);
- const prettyName = name.replace(`${parentName}.`, '').replace(`${functionName}.`, '');//.replace(`${parentName}[`, '[');
+ const prettyName = name.replace(`${parentName}.`, '').replace(`${functionName}.`, ''); //.replace(`${parentName}[`, '[');
const signature = block.getSignature();
// Current offset
@@ -383,7 +404,7 @@ export class Calldata {
const blocksByHash: { [key: string]: CalldataBlock } = {};
// 1. Create a queue of subtrees by hash
- // Note that they are ordered the same as
+ // Note that they are ordered the same as
const subtreeQueue = this.createQueue(this.root);
let block: CalldataBlock | undefined;
while ((block = subtreeQueue.popBack()) !== undefined) {
@@ -435,7 +456,7 @@ export class Calldata {
}
public toAnnotatedString(): string {
- return "";
+ return '';
}
public setRoot(block: CalldataBlock) {
@@ -532,4 +553,4 @@ export class RawCalldata {
public getSelector(): string {
return this.selector;
}
-} \ No newline at end of file
+}