aboutsummaryrefslogtreecommitdiffstats
path: root/packages/utils/src
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-11-28 05:31:44 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-11-29 08:38:11 +0800
commit1f693ea12142bc761f4067871d92e7d2662cf256 (patch)
tree58d352925dbdb4ad157c4a229eab7a7a3e0828b9 /packages/utils/src
parent3f545da9f86856b54cd226c29174ac1ae085e35b (diff)
downloaddexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar.gz
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar.bz2
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar.lz
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar.xz
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.tar.zst
dexon-sol-tools-1f693ea12142bc761f4067871d92e7d2662cf256.zip
Changed from <string>.startsWith to _.startsWith
Diffstat (limited to 'packages/utils/src')
-rw-r--r--packages/utils/src/abi_encoder/abstract_data_types/data_type.ts2
-rw-r--r--packages/utils/src/abi_encoder/calldata/calldata.ts2
-rw-r--r--packages/utils/src/abi_encoder/calldata/raw_calldata.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/address.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts2
-rw-r--r--packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts2
-rw-r--r--packages/utils/src/abi_encoder/utils/math.ts2
7 files changed, 7 insertions, 7 deletions
diff --git a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts
index 61d3ac3a9..4cef60172 100644
--- a/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts
+++ b/packages/utils/src/abi_encoder/abstract_data_types/data_type.ts
@@ -37,7 +37,7 @@ export abstract class DataType {
}
public decode(calldata: string, rules?: DecodingRules, selector?: string): any {
- if (!_.isUndefined(selector) && !calldata.startsWith(selector)) {
+ if (!_.isUndefined(selector) && !_.startsWith(calldata, selector)) {
throw new Error(
`Tried to decode calldata, but it was missing the function selector. Expected prefix '${selector}'. Got '${calldata}'.`,
);
diff --git a/packages/utils/src/abi_encoder/calldata/calldata.ts b/packages/utils/src/abi_encoder/calldata/calldata.ts
index e93d63803..c57ff08c2 100644
--- a/packages/utils/src/abi_encoder/calldata/calldata.ts
+++ b/packages/utils/src/abi_encoder/calldata/calldata.ts
@@ -29,7 +29,7 @@ export class Calldata {
* If the root block was created by a Method then a selector will likely be set.
*/
public setSelector(selector: string): void {
- if (!selector.startsWith('0x')) {
+ if (!_.startsWith(selector, '0x')) {
throw new Error(`Expected selector to be hex. Missing prefix '0x'`);
} else if (selector.length !== Constants.HEX_SELECTOR_LENGTH_IN_CHARS) {
throw new Error(`Invalid selector '${selector}'`);
diff --git a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts
index dfd4cfa72..fbe592fc7 100644
--- a/packages/utils/src/abi_encoder/calldata/raw_calldata.ts
+++ b/packages/utils/src/abi_encoder/calldata/raw_calldata.ts
@@ -13,7 +13,7 @@ export class RawCalldata {
public constructor(value: string | Buffer, hasSelector: boolean = true) {
// Sanity check
- if (typeof value === 'string' && !value.startsWith('0x')) {
+ if (typeof value === 'string' && !_.startsWith(value, '0x')) {
throw new Error(`Expected raw calldata to start with '0x'`);
}
// Construct initial values
diff --git a/packages/utils/src/abi_encoder/evm_data_types/address.ts b/packages/utils/src/abi_encoder/evm_data_types/address.ts
index 71aa293b5..52fc8e7b9 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/address.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/address.ts
@@ -31,7 +31,7 @@ export class Address extends AbstractDataTypes.Blob {
}
public encodeValue(value: string): Buffer {
- if (!value.startsWith('0x')) {
+ if (!_.startsWith(value, '0x')) {
throw new Error(Address.ERROR_MESSAGE_ADDRESS_MUST_START_WITH_0X);
}
const valueBuf = ethUtil.toBuffer(value);
diff --git a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts
index 01d83d11a..98d90b7e4 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/dynamic_bytes.ts
@@ -60,7 +60,7 @@ export class DynamicBytes extends AbstractDataTypes.Blob {
if (typeof value !== 'string') {
return;
}
- if (!value.startsWith('0x')) {
+ if (!_.startsWith(value, '0x')) {
throw new Error(`Tried to encode non-hex value. Value must inlcude '0x' prefix.`);
} else if (value.length % 2 !== 0) {
throw new Error(`Tried to assign ${value}, which is contains a half-byte. Use full bytes only.`);
diff --git a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts
index 3a2ad410f..68f212f79 100644
--- a/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts
+++ b/packages/utils/src/abi_encoder/evm_data_types/static_bytes.ts
@@ -59,7 +59,7 @@ export class StaticBytes extends AbstractDataTypes.Blob {
private _sanityCheckValue(value: string | Buffer): void {
if (typeof value === 'string') {
- if (!value.startsWith('0x')) {
+ if (!_.startsWith(value, '0x')) {
throw new Error(`Tried to encode non-hex value. Value must inlcude '0x' prefix.`);
} else if (value.length % 2 !== 0) {
throw new Error(`Tried to assign ${value}, which is contains a half-byte. Use full bytes only.`);
diff --git a/packages/utils/src/abi_encoder/utils/math.ts b/packages/utils/src/abi_encoder/utils/math.ts
index c5fa10e73..bc344c695 100644
--- a/packages/utils/src/abi_encoder/utils/math.ts
+++ b/packages/utils/src/abi_encoder/utils/math.ts
@@ -79,7 +79,7 @@ export function decodeNumericValue(encodedValue: Buffer, minValue: BigNumber): B
}
// Case 2/3: value is non-negative because there is no leading 1 (encoded as two's-complement)
const valueBin = value.toString(Constants.BIN_BASE);
- const valueIsNegative = valueBin.length === Constants.EVM_WORD_WIDTH_IN_BITS && valueBin[0].startsWith('1');
+ const valueIsNegative = valueBin.length === Constants.EVM_WORD_WIDTH_IN_BITS && _.startsWith(valueBin[0], '1');
if (!valueIsNegative) {
return value;
}