@abacus-network/utils
Advanced tools
Comparing version 0.3.1 to 0.4.0-beta0
@@ -0,1 +1,2 @@ | ||
import { ethers } from 'ethers'; | ||
/********* BASIC TYPES *********/ | ||
@@ -10,7 +11,7 @@ export declare type Domain = number; | ||
index: number; | ||
signature: string; | ||
signature: ethers.utils.BytesLike; | ||
}; | ||
export declare type CallData = { | ||
to: Address; | ||
data: string; | ||
data: ethers.utils.BytesLike; | ||
}; | ||
@@ -17,0 +18,0 @@ export declare enum AbacusState { |
@@ -5,2 +5,4 @@ import { ethers } from 'ethers'; | ||
export declare function deepEquals(v1: any, v2: any): boolean; | ||
export declare const ensure0x: (hexstr: string) => string; | ||
export declare const strip0x: (hexstr: string) => string; | ||
export declare function getHexStringByteLength(hexStr: string): number; | ||
@@ -7,0 +9,0 @@ export declare const stringToBytes32: (s: string) => string; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.retryAsync = exports.sleep = exports.domainHash = exports.destinationAndNonce = exports.messageHash = exports.parseMessage = exports.formatMessage = exports.formatCallData = exports.bytes32ToAddress = exports.addressToBytes32 = exports.stringToBytes32 = exports.getHexStringByteLength = exports.deepEquals = exports.assert = void 0; | ||
exports.retryAsync = exports.sleep = exports.domainHash = exports.destinationAndNonce = exports.messageHash = exports.parseMessage = exports.formatMessage = exports.formatCallData = exports.bytes32ToAddress = exports.addressToBytes32 = exports.stringToBytes32 = exports.getHexStringByteLength = exports.strip0x = exports.ensure0x = exports.deepEquals = exports.assert = void 0; | ||
const ethers_1 = require("ethers"); | ||
@@ -25,2 +25,6 @@ function assert(predicate, errorMessage) { | ||
exports.deepEquals = deepEquals; | ||
const ensure0x = (hexstr) => hexstr.startsWith('0x') ? hexstr : `0x${hexstr}`; | ||
exports.ensure0x = ensure0x; | ||
const strip0x = (hexstr) => hexstr.startsWith('0x') ? hexstr.slice(2) : hexstr; | ||
exports.strip0x = strip0x; | ||
/* | ||
@@ -33,7 +37,3 @@ * Gets the byte length of a hex string | ||
function getHexStringByteLength(hexStr) { | ||
let len = hexStr.length; | ||
// check for prefix, remove if necessary | ||
if (hexStr.slice(0, 2) == '0x') { | ||
len -= 2; | ||
} | ||
const len = (0, exports.strip0x)(hexStr).length; | ||
// divide by 2 to get the byte length | ||
@@ -47,3 +47,3 @@ return len / 2; | ||
str.copy(result); | ||
return '0x' + result.toString('hex'); | ||
return (0, exports.ensure0x)(result.toString('hex')); | ||
}; | ||
@@ -50,0 +50,0 @@ exports.stringToBytes32 = stringToBytes32; |
{ | ||
"name": "@abacus-network/utils", | ||
"description": "General utilities for the Abacus network", | ||
"version": "0.3.1", | ||
"version": "0.4.0-beta0", | ||
"dependencies": { | ||
@@ -32,3 +32,4 @@ "ethers": "^5.6.8" | ||
"/dist" | ||
] | ||
], | ||
"stableVersion": "0.3.1" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24507
323