aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src/abi_encoder/calldata.ts
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-16 06:33:40 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:10 +0800
commit8a8b904a292063d1adb3df0a84023610a3985f7f (patch)
treecfb0772901ec1965e2a68fd728b639ff592edf75 /packages/utils/src/abi_encoder/calldata.ts
parentebd4dbc6c6ebdf776ba1582367d3eda32717ba65 (diff)
downloaddexon-sol-tools-8a8b904a292063d1adb3df0a84023610a3985f7f.tar.gz
dexon-sol-tools-8a8b904a292063d1adb3df0a84023610a3985f7f.tar.zst
dexon-sol-tools-8a8b904a292063d1adb3df0a84023610a3985f7f.zip
Use new ABI Encoder for contracts
Diffstat (limited to 'packages/utils/src/abi_encoder/calldata.ts')
-rw-r--r--packages/utils/src/abi_encoder/calldata.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/packages/utils/src/abi_encoder/calldata.ts b/packages/utils/src/abi_encoder/calldata.ts
index 32278e5c5..078767c22 100644
--- a/packages/utils/src/abi_encoder/calldata.ts
+++ b/packages/utils/src/abi_encoder/calldata.ts
@@ -456,13 +456,19 @@ export class RawCalldata {
private selector: string;
private scopes: Queue<number>;
- constructor(value: string | Buffer) {
+ constructor(value: string | Buffer, hasSelectorPrefix: boolean = true) {
if (typeof value === 'string' && !value.startsWith('0x')) {
throw new Error(`Expected raw calldata to start with '0x'`);
}
const valueBuf = ethUtil.toBuffer(value);
- this.selector = ethUtil.bufferToHex(valueBuf.slice(0, 4));
- this.value = valueBuf.slice(4); // disregard selector
+ if (hasSelectorPrefix) {
+ this.selector = ethUtil.bufferToHex(valueBuf.slice(0, 4));
+ this.value = valueBuf.slice(4); // disregard selector
+ } else {
+ this.selector = '0x';
+ this.value = valueBuf;
+ }
+
this.offset = 0;
this.scopes = new Queue<number>();
this.scopes.push(0);