@hyperlane-xyz/utils 3.0.0-beta0 → 3.1.0-beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/src/addresses.d.ts +13 -4
- package/dist/src/addresses.d.ts.map +1 -1
- package/dist/src/addresses.js +110 -35
- package/dist/src/addresses.js.map +1 -1
- package/dist/src/types.d.ts +3 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { addressToByteHexString, addressToBytes, addressToBytes32, addressToBytesEvm, addressToBytesSol, bytes32ToAddress, bytesToProtocolAddress, capitalizeAddress, convertToProtocolAddress, ensure0x, eqAddress, eqAddressEvm, eqAddressSol, getAddressProtocolType, isAddressEvm, isAddressSealevel, isValidAddress, isValidAddressEvm, isValidAddressSealevel, isValidTransactionHash, isValidTransactionHashEvm, isValidTransactionHashSealevel, isZeroishAddress, normalizeAddress, normalizeAddressEvm, normalizeAddressSealevel, shortenAddress, strip0x, } from './src/addresses';
|
|
1
|
+
export { addressToByteHexString, addressToBytes, addressToBytes32, addressToBytesCosmos, addressToBytesEvm, addressToBytesSol, bytes32ToAddress, bytesToAddressCosmos, bytesToAddressEvm, bytesToAddressSol, bytesToProtocolAddress, capitalizeAddress, convertToProtocolAddress, ensure0x, eqAddress, eqAddressCosmos, eqAddressEvm, eqAddressSol, getAddressProtocolType, isAddressCosmos, isAddressEvm, isAddressSealevel, isValidAddress, isValidAddressCosmos, isValidAddressEvm, isValidAddressSealevel, isValidTransactionHash, isValidTransactionHashCosmos, isValidTransactionHashEvm, isValidTransactionHashSealevel, isZeroishAddress, normalizeAddress, normalizeAddressCosmos, normalizeAddressEvm, normalizeAddressSealevel, shortenAddress, strip0x, } from './src/addresses';
|
|
2
2
|
export { convertDecimals, convertDecimalsEthersBigNumber, eqAmountApproximate, fromWei, fromWeiRounded, toWei, tryParseAmount, } from './src/amount';
|
|
3
3
|
export { chunk, exclude } from './src/arrays';
|
|
4
4
|
export { pollAsync, retryAsync, runWithTimeout, sleep, timeout, } from './src/async';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,KAAK,EACL,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,EACL,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,cAAc,EACd,SAA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,EACjB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,8BAA8B,EAC9B,gBAAgB,EAChB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,cAAc,EACd,OAAO,GACR,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,KAAK,EACL,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,EACL,OAAO,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,YAAY,EACZ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C/B,aAAa,EACb,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.Validator = exports.BaseValidator = exports.assert = void 0;
|
|
3
|
+
exports.sleep = exports.runWithTimeout = exports.retryAsync = exports.pollAsync = exports.exclude = exports.chunk = exports.tryParseAmount = exports.toWei = exports.fromWeiRounded = exports.fromWei = exports.eqAmountApproximate = exports.convertDecimalsEthersBigNumber = exports.convertDecimals = exports.strip0x = exports.shortenAddress = exports.normalizeAddressSealevel = exports.normalizeAddressEvm = exports.normalizeAddressCosmos = exports.normalizeAddress = exports.isZeroishAddress = exports.isValidTransactionHashSealevel = exports.isValidTransactionHashEvm = exports.isValidTransactionHashCosmos = exports.isValidTransactionHash = exports.isValidAddressSealevel = exports.isValidAddressEvm = exports.isValidAddressCosmos = exports.isValidAddress = exports.isAddressSealevel = exports.isAddressEvm = exports.isAddressCosmos = exports.getAddressProtocolType = exports.eqAddressSol = exports.eqAddressEvm = exports.eqAddressCosmos = exports.eqAddress = exports.ensure0x = exports.convertToProtocolAddress = exports.capitalizeAddress = exports.bytesToProtocolAddress = exports.bytesToAddressSol = exports.bytesToAddressEvm = exports.bytesToAddressCosmos = exports.bytes32ToAddress = exports.addressToBytesSol = exports.addressToBytesEvm = exports.addressToBytesCosmos = exports.addressToBytes32 = exports.addressToBytes = exports.addressToByteHexString = void 0;
|
|
4
|
+
exports.sanitizeString = exports.errorToString = exports.symmetricDifference = exports.setEquality = exports.difference = exports.promiseObjAll = exports.pick = exports.objMerge = exports.objMapEntries = exports.objMap = exports.objFilter = exports.isObject = exports.invertKeysAndValues = exports.deepEquals = exports.arrayToObject = exports.parseLegacyMultisigIsmMetadata = exports.formatLegacyMultisigIsmMetadata = exports.parseMessage = exports.messageId = exports.formatMessage = exports.sum = exports.stdDev = exports.median = exports.mean = exports.warn = exports.trace = exports.log = exports.error = exports.debug = exports.evmId = exports.canonizeId = exports.safelyAccessEnvVar = exports.domainHash = exports.isS3CheckpointWithId = exports.isS3Checkpoint = exports.isCheckpoint = exports.formatCallData = exports.mulBigAndFixed = exports.isZeroish = exports.isBigNumberish = exports.fixedToBig = exports.bigToFixed = exports.BigNumberMin = exports.BigNumberMax = exports.toBase64 = exports.fromBase64 = exports.hexOrBase58ToHex = exports.bufferToBase58 = exports.base58ToBuffer = exports.timeout = void 0;
|
|
5
|
+
exports.Validator = exports.BaseValidator = exports.assert = exports.ProtocolType = exports.ProtocolSmallestUnit = exports.MessageStatus = exports.InterchainSecurityModuleType = exports.isNumeric = exports.isNullish = exports.trimToLength = exports.toTitleCase = exports.streamToString = void 0;
|
|
6
6
|
var addresses_1 = require("./src/addresses");
|
|
7
7
|
Object.defineProperty(exports, "addressToByteHexString", { enumerable: true, get: function () { return addresses_1.addressToByteHexString; } });
|
|
8
8
|
Object.defineProperty(exports, "addressToBytes", { enumerable: true, get: function () { return addresses_1.addressToBytes; } });
|
|
9
9
|
Object.defineProperty(exports, "addressToBytes32", { enumerable: true, get: function () { return addresses_1.addressToBytes32; } });
|
|
10
|
+
Object.defineProperty(exports, "addressToBytesCosmos", { enumerable: true, get: function () { return addresses_1.addressToBytesCosmos; } });
|
|
10
11
|
Object.defineProperty(exports, "addressToBytesEvm", { enumerable: true, get: function () { return addresses_1.addressToBytesEvm; } });
|
|
11
12
|
Object.defineProperty(exports, "addressToBytesSol", { enumerable: true, get: function () { return addresses_1.addressToBytesSol; } });
|
|
12
13
|
Object.defineProperty(exports, "bytes32ToAddress", { enumerable: true, get: function () { return addresses_1.bytes32ToAddress; } });
|
|
14
|
+
Object.defineProperty(exports, "bytesToAddressCosmos", { enumerable: true, get: function () { return addresses_1.bytesToAddressCosmos; } });
|
|
15
|
+
Object.defineProperty(exports, "bytesToAddressEvm", { enumerable: true, get: function () { return addresses_1.bytesToAddressEvm; } });
|
|
16
|
+
Object.defineProperty(exports, "bytesToAddressSol", { enumerable: true, get: function () { return addresses_1.bytesToAddressSol; } });
|
|
13
17
|
Object.defineProperty(exports, "bytesToProtocolAddress", { enumerable: true, get: function () { return addresses_1.bytesToProtocolAddress; } });
|
|
14
18
|
Object.defineProperty(exports, "capitalizeAddress", { enumerable: true, get: function () { return addresses_1.capitalizeAddress; } });
|
|
15
19
|
Object.defineProperty(exports, "convertToProtocolAddress", { enumerable: true, get: function () { return addresses_1.convertToProtocolAddress; } });
|
|
16
20
|
Object.defineProperty(exports, "ensure0x", { enumerable: true, get: function () { return addresses_1.ensure0x; } });
|
|
17
21
|
Object.defineProperty(exports, "eqAddress", { enumerable: true, get: function () { return addresses_1.eqAddress; } });
|
|
22
|
+
Object.defineProperty(exports, "eqAddressCosmos", { enumerable: true, get: function () { return addresses_1.eqAddressCosmos; } });
|
|
18
23
|
Object.defineProperty(exports, "eqAddressEvm", { enumerable: true, get: function () { return addresses_1.eqAddressEvm; } });
|
|
19
24
|
Object.defineProperty(exports, "eqAddressSol", { enumerable: true, get: function () { return addresses_1.eqAddressSol; } });
|
|
20
25
|
Object.defineProperty(exports, "getAddressProtocolType", { enumerable: true, get: function () { return addresses_1.getAddressProtocolType; } });
|
|
26
|
+
Object.defineProperty(exports, "isAddressCosmos", { enumerable: true, get: function () { return addresses_1.isAddressCosmos; } });
|
|
21
27
|
Object.defineProperty(exports, "isAddressEvm", { enumerable: true, get: function () { return addresses_1.isAddressEvm; } });
|
|
22
28
|
Object.defineProperty(exports, "isAddressSealevel", { enumerable: true, get: function () { return addresses_1.isAddressSealevel; } });
|
|
23
29
|
Object.defineProperty(exports, "isValidAddress", { enumerable: true, get: function () { return addresses_1.isValidAddress; } });
|
|
30
|
+
Object.defineProperty(exports, "isValidAddressCosmos", { enumerable: true, get: function () { return addresses_1.isValidAddressCosmos; } });
|
|
24
31
|
Object.defineProperty(exports, "isValidAddressEvm", { enumerable: true, get: function () { return addresses_1.isValidAddressEvm; } });
|
|
25
32
|
Object.defineProperty(exports, "isValidAddressSealevel", { enumerable: true, get: function () { return addresses_1.isValidAddressSealevel; } });
|
|
26
33
|
Object.defineProperty(exports, "isValidTransactionHash", { enumerable: true, get: function () { return addresses_1.isValidTransactionHash; } });
|
|
34
|
+
Object.defineProperty(exports, "isValidTransactionHashCosmos", { enumerable: true, get: function () { return addresses_1.isValidTransactionHashCosmos; } });
|
|
27
35
|
Object.defineProperty(exports, "isValidTransactionHashEvm", { enumerable: true, get: function () { return addresses_1.isValidTransactionHashEvm; } });
|
|
28
36
|
Object.defineProperty(exports, "isValidTransactionHashSealevel", { enumerable: true, get: function () { return addresses_1.isValidTransactionHashSealevel; } });
|
|
29
37
|
Object.defineProperty(exports, "isZeroishAddress", { enumerable: true, get: function () { return addresses_1.isZeroishAddress; } });
|
|
30
38
|
Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return addresses_1.normalizeAddress; } });
|
|
39
|
+
Object.defineProperty(exports, "normalizeAddressCosmos", { enumerable: true, get: function () { return addresses_1.normalizeAddressCosmos; } });
|
|
31
40
|
Object.defineProperty(exports, "normalizeAddressEvm", { enumerable: true, get: function () { return addresses_1.normalizeAddressEvm; } });
|
|
32
41
|
Object.defineProperty(exports, "normalizeAddressSealevel", { enumerable: true, get: function () { return addresses_1.normalizeAddressSealevel; } });
|
|
33
42
|
Object.defineProperty(exports, "shortenAddress", { enumerable: true, get: function () { return addresses_1.shortenAddress; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{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;AAFtB,2HAAA,+BAA+B,OAAA;AAC/B,0HAAA,8BAA8B,OAAA;AAEhC,yCAYuB;AAVrB,wGAAA,aAAa,OAAA;AACb,qGAAA,UAAU,OAAA;AACV,8GAAA,mBAAmB,OAAA;AACnB,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,iGAAA,MAAM,OAAA;AACN,wGAAA,aAAa,OAAA;AACb,mGAAA,QAAQ,OAAA;AACR,+FAAA,IAAI,OAAA;AACJ,wGAAA,aAAa,OAAA;AAEf,mCAA0E;AAAjE,kGAAA,UAAU,OAAA;AAAE,mGAAA,WAAW,OAAA;AAAE,2GAAA,mBAAmB,OAAA;AACrD,yCAMuB;AALrB,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AACd,yGAAA,cAAc,OAAA;AACd,sGAAA,WAAW,OAAA;AACX,uGAAA,YAAY,OAAA;AAEd,uCAAoD;AAA3C,mGAAA,SAAS,OAAA;AAAE,mGAAA,SAAS,OAAA;AAC7B,qCAoBqB;AAZnB,qHAAA,4BAA4B,OAAA;AAE5B,sGAAA,aAAa,OAAA;AAGb,6GAAA,oBAAoB,OAAA;AACpB,qGAAA,YAAY,OAAA;AAOd,+CAA0C;AAAjC,oGAAA,MAAM,OAAA;AACf,6CAA2D;AAAlD,0GAAA,aAAa,OAAA;AAAE,sGAAA,SAAS,OAAA"}
|
package/dist/src/addresses.d.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Address, HexString, ProtocolType } from './types';
|
|
2
|
+
export declare const IBC_DENOM_REGEX: RegExp;
|
|
3
3
|
export declare function isAddressEvm(address: Address): boolean;
|
|
4
4
|
export declare function isAddressSealevel(address: Address): boolean;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function isAddressCosmos(address: Address): boolean;
|
|
6
|
+
export declare function getAddressProtocolType(address: Address): ProtocolType.Ethereum | ProtocolType.Sealevel | ProtocolType.Cosmos | undefined;
|
|
6
7
|
export declare function isValidAddressEvm(address: Address): boolean;
|
|
7
8
|
export declare function isValidAddressSealevel(address: Address): boolean;
|
|
9
|
+
export declare function isValidAddressCosmos(address: Address): boolean;
|
|
8
10
|
export declare function isValidAddress(address: Address, protocol?: ProtocolType): boolean;
|
|
9
11
|
export declare function normalizeAddressEvm(address: Address): string;
|
|
10
12
|
export declare function normalizeAddressSealevel(address: Address): string;
|
|
13
|
+
export declare function normalizeAddressCosmos(address: Address): string;
|
|
11
14
|
export declare function normalizeAddress(address: Address, protocol?: ProtocolType): string;
|
|
12
15
|
export declare function eqAddressEvm(a1: Address, a2: Address): boolean;
|
|
13
16
|
export declare function eqAddressSol(a1: Address, a2: Address): boolean;
|
|
17
|
+
export declare function eqAddressCosmos(a1: Address, a2: Address): boolean;
|
|
14
18
|
export declare function eqAddress(a1: Address, a2: Address): boolean;
|
|
15
19
|
export declare function isValidTransactionHashEvm(input: string): boolean;
|
|
16
20
|
export declare function isValidTransactionHashSealevel(input: string): boolean;
|
|
21
|
+
export declare function isValidTransactionHashCosmos(input: string): boolean;
|
|
17
22
|
export declare function isValidTransactionHash(input: string, protocol: ProtocolType): boolean;
|
|
18
23
|
export declare function isZeroishAddress(address: Address): boolean;
|
|
19
24
|
export declare function shortenAddress(address: Address, capitalize?: boolean): string;
|
|
@@ -22,10 +27,14 @@ export declare function addressToBytes32(address: Address): string;
|
|
|
22
27
|
export declare function bytes32ToAddress(bytes32: HexString): Address;
|
|
23
28
|
export declare function addressToBytesEvm(address: Address): Uint8Array;
|
|
24
29
|
export declare function addressToBytesSol(address: Address): Uint8Array;
|
|
30
|
+
export declare function addressToBytesCosmos(address: Address): Uint8Array;
|
|
25
31
|
export declare function addressToBytes(address: Address, protocol?: ProtocolType): Uint8Array;
|
|
26
32
|
export declare function addressToByteHexString(address: string, protocol?: ProtocolType): string;
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
33
|
+
export declare function bytesToAddressEvm(bytes: Uint8Array): Address;
|
|
34
|
+
export declare function bytesToAddressSol(bytes: Uint8Array): Address;
|
|
35
|
+
export declare function bytesToAddressCosmos(bytes: Uint8Array, prefix: string): Address;
|
|
36
|
+
export declare function bytesToProtocolAddress(bytes: Uint8Array, toProtocol: ProtocolType, prefix?: string): string;
|
|
37
|
+
export declare function convertToProtocolAddress(address: string, protocol: ProtocolType, prefix?: string): string;
|
|
29
38
|
export declare function ensure0x(hexstr: string): string;
|
|
30
39
|
export declare function strip0x(hexstr: string): string;
|
|
31
40
|
//# sourceMappingURL=addresses.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAM3D,eAAO,MAAM,eAAe,QAA6B,CAAC;AAS1D,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,WAE5C;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,WAEjD;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,WAE/C;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,mFAWtD;AAeD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,WAQjD;AAGD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,WAOtD;AAGD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,WAQpD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,WAWvE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,UAOnD;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,UAOxD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAA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ED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,YAAY,UAKxB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAE5D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAE5D;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAGT;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,YAAY,EACxB,MAAM,CAAC,EAAE,MAAM,UAWhB;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,YAAY,EACtB,MAAM,CAAC,EAAE,MAAM,UAQhB;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,UAEtC;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,UAErC"}
|
package/dist/src/addresses.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.strip0x = exports.ensure0x = exports.convertToProtocolAddress = exports.bytesToProtocolAddress = exports.addressToByteHexString = exports.addressToBytes = exports.addressToBytesSol = exports.addressToBytesEvm = exports.bytes32ToAddress = exports.addressToBytes32 = exports.capitalizeAddress = exports.shortenAddress = exports.isZeroishAddress = exports.isValidTransactionHash = exports.isValidTransactionHashSealevel = exports.isValidTransactionHashEvm = exports.eqAddress = exports.eqAddressSol = exports.eqAddressEvm = exports.normalizeAddress = exports.normalizeAddressSealevel = exports.normalizeAddressEvm = exports.isValidAddress = exports.isValidAddressSealevel = exports.isValidAddressEvm = exports.getAddressProtocolType = exports.isAddressSealevel = exports.isAddressEvm = void 0;
|
|
3
|
+
exports.strip0x = exports.ensure0x = exports.convertToProtocolAddress = exports.bytesToProtocolAddress = exports.bytesToAddressCosmos = exports.bytesToAddressSol = exports.bytesToAddressEvm = exports.addressToByteHexString = exports.addressToBytes = exports.addressToBytesCosmos = exports.addressToBytesSol = exports.addressToBytesEvm = exports.bytes32ToAddress = exports.addressToBytes32 = exports.capitalizeAddress = exports.shortenAddress = exports.isZeroishAddress = exports.isValidTransactionHash = exports.isValidTransactionHashCosmos = exports.isValidTransactionHashSealevel = exports.isValidTransactionHashEvm = exports.eqAddress = exports.eqAddressCosmos = exports.eqAddressSol = exports.eqAddressEvm = exports.normalizeAddress = exports.normalizeAddressCosmos = exports.normalizeAddressSealevel = exports.normalizeAddressEvm = exports.isValidAddress = exports.isValidAddressCosmos = exports.isValidAddressSealevel = exports.isValidAddressEvm = exports.getAddressProtocolType = exports.isAddressCosmos = exports.isAddressSealevel = exports.isAddressEvm = exports.IBC_DENOM_REGEX = void 0;
|
|
4
|
+
const encoding_1 = require("@cosmjs/encoding");
|
|
4
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
6
|
const ethers_1 = require("ethers");
|
|
6
7
|
const types_1 = require("./types");
|
|
7
8
|
const EVM_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
|
|
8
9
|
const SEALEVEL_ADDRESS_REGEX = /^[a-zA-Z0-9]{36,44}$/;
|
|
10
|
+
const COSMOS_ADDRESS_REGEX = /^[a-z]{1,10}1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38,58}$/; // Bech32
|
|
11
|
+
exports.IBC_DENOM_REGEX = /^ibc\/([A-Fa-f0-9]{64})$/;
|
|
9
12
|
const EVM_TX_HASH_REGEX = /^0x([A-Fa-f0-9]{64})$/;
|
|
10
13
|
const SEALEVEL_TX_HASH_REGEX = /^[a-zA-Z1-9]{88}$/;
|
|
14
|
+
const COSMOS_TX_HASH_REGEX = /^(0x)?[A-Fa-f0-9]{64}$/;
|
|
11
15
|
const ZEROISH_ADDRESS_REGEX = /^(0x)?0*$/;
|
|
16
|
+
const COSMOS_ZEROISH_ADDRESS_REGEX = /^[a-z]{1,10}?1[0]{38}$/;
|
|
12
17
|
function isAddressEvm(address) {
|
|
13
18
|
return EVM_ADDRESS_REGEX.test(address);
|
|
14
19
|
}
|
|
@@ -17,12 +22,19 @@ function isAddressSealevel(address) {
|
|
|
17
22
|
return SEALEVEL_ADDRESS_REGEX.test(address);
|
|
18
23
|
}
|
|
19
24
|
exports.isAddressSealevel = isAddressSealevel;
|
|
25
|
+
function isAddressCosmos(address) {
|
|
26
|
+
return COSMOS_ADDRESS_REGEX.test(address) || exports.IBC_DENOM_REGEX.test(address);
|
|
27
|
+
}
|
|
28
|
+
exports.isAddressCosmos = isAddressCosmos;
|
|
20
29
|
function getAddressProtocolType(address) {
|
|
21
30
|
if (!address)
|
|
22
31
|
return undefined;
|
|
23
32
|
if (isAddressEvm(address)) {
|
|
24
33
|
return types_1.ProtocolType.Ethereum;
|
|
25
34
|
}
|
|
35
|
+
else if (isAddressCosmos(address)) {
|
|
36
|
+
return types_1.ProtocolType.Cosmos;
|
|
37
|
+
}
|
|
26
38
|
else if (isAddressSealevel(address)) {
|
|
27
39
|
return types_1.ProtocolType.Sealevel;
|
|
28
40
|
}
|
|
@@ -31,17 +43,14 @@ function getAddressProtocolType(address) {
|
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
exports.getAddressProtocolType = getAddressProtocolType;
|
|
34
|
-
function routeAddressUtil(
|
|
35
|
-
protocol
|
|
36
|
-
if (protocol
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
else if (protocol === types_1.ProtocolType.Sealevel) {
|
|
40
|
-
return sealevelFn(param);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
46
|
+
function routeAddressUtil(fns, param, fallback, protocol) {
|
|
47
|
+
protocol || (protocol = getAddressProtocolType(param));
|
|
48
|
+
if (protocol && fns[protocol])
|
|
49
|
+
return fns[protocol](param);
|
|
50
|
+
else if (fallback)
|
|
43
51
|
return fallback;
|
|
44
|
-
|
|
52
|
+
else
|
|
53
|
+
throw new Error(`Unsupported protocol ${protocol}`);
|
|
45
54
|
}
|
|
46
55
|
// Slower than isAddressEvm above but actually validates content and checksum
|
|
47
56
|
function isValidAddressEvm(address) {
|
|
@@ -66,8 +75,23 @@ function isValidAddressSealevel(address) {
|
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
exports.isValidAddressSealevel = isValidAddressSealevel;
|
|
78
|
+
// Slower than isAddressCosmos above but actually validates content and checksum
|
|
79
|
+
function isValidAddressCosmos(address) {
|
|
80
|
+
try {
|
|
81
|
+
const isValid = address && (exports.IBC_DENOM_REGEX.test(address) || (0, encoding_1.fromBech32)(address));
|
|
82
|
+
return !!isValid;
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.isValidAddressCosmos = isValidAddressCosmos;
|
|
69
89
|
function isValidAddress(address, protocol) {
|
|
70
|
-
return routeAddressUtil(
|
|
90
|
+
return routeAddressUtil({
|
|
91
|
+
[types_1.ProtocolType.Ethereum]: isValidAddressEvm,
|
|
92
|
+
[types_1.ProtocolType.Sealevel]: isValidAddressSealevel,
|
|
93
|
+
[types_1.ProtocolType.Cosmos]: isValidAddressCosmos,
|
|
94
|
+
}, address, false, protocol);
|
|
71
95
|
}
|
|
72
96
|
exports.isValidAddress = isValidAddress;
|
|
73
97
|
function normalizeAddressEvm(address) {
|
|
@@ -92,8 +116,23 @@ function normalizeAddressSealevel(address) {
|
|
|
92
116
|
}
|
|
93
117
|
}
|
|
94
118
|
exports.normalizeAddressSealevel = normalizeAddressSealevel;
|
|
119
|
+
function normalizeAddressCosmos(address) {
|
|
120
|
+
if (isZeroishAddress(address))
|
|
121
|
+
return address;
|
|
122
|
+
try {
|
|
123
|
+
return (0, encoding_1.normalizeBech32)(address);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return address;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.normalizeAddressCosmos = normalizeAddressCosmos;
|
|
95
130
|
function normalizeAddress(address, protocol) {
|
|
96
|
-
return routeAddressUtil(
|
|
131
|
+
return routeAddressUtil({
|
|
132
|
+
[types_1.ProtocolType.Ethereum]: normalizeAddressEvm,
|
|
133
|
+
[types_1.ProtocolType.Sealevel]: normalizeAddressSealevel,
|
|
134
|
+
[types_1.ProtocolType.Cosmos]: normalizeAddressCosmos,
|
|
135
|
+
}, address, address, protocol);
|
|
97
136
|
}
|
|
98
137
|
exports.normalizeAddress = normalizeAddress;
|
|
99
138
|
function eqAddressEvm(a1, a2) {
|
|
@@ -104,12 +143,20 @@ function eqAddressSol(a1, a2) {
|
|
|
104
143
|
return normalizeAddressSealevel(a1) === normalizeAddressSealevel(a2);
|
|
105
144
|
}
|
|
106
145
|
exports.eqAddressSol = eqAddressSol;
|
|
146
|
+
function eqAddressCosmos(a1, a2) {
|
|
147
|
+
return normalizeAddressCosmos(a1) === normalizeAddressCosmos(a2);
|
|
148
|
+
}
|
|
149
|
+
exports.eqAddressCosmos = eqAddressCosmos;
|
|
107
150
|
function eqAddress(a1, a2) {
|
|
108
151
|
const p1 = getAddressProtocolType(a1);
|
|
109
152
|
const p2 = getAddressProtocolType(a2);
|
|
110
153
|
if (p1 !== p2)
|
|
111
154
|
return false;
|
|
112
|
-
return routeAddressUtil(
|
|
155
|
+
return routeAddressUtil({
|
|
156
|
+
[types_1.ProtocolType.Ethereum]: (_a1) => eqAddressEvm(_a1, a2),
|
|
157
|
+
[types_1.ProtocolType.Sealevel]: (_a1) => eqAddressSol(_a1, a2),
|
|
158
|
+
[types_1.ProtocolType.Cosmos]: (_a1) => eqAddressCosmos(_a1, a2),
|
|
159
|
+
}, a1, false, p1);
|
|
113
160
|
}
|
|
114
161
|
exports.eqAddress = eqAddress;
|
|
115
162
|
function isValidTransactionHashEvm(input) {
|
|
@@ -120,6 +167,10 @@ function isValidTransactionHashSealevel(input) {
|
|
|
120
167
|
return SEALEVEL_TX_HASH_REGEX.test(input);
|
|
121
168
|
}
|
|
122
169
|
exports.isValidTransactionHashSealevel = isValidTransactionHashSealevel;
|
|
170
|
+
function isValidTransactionHashCosmos(input) {
|
|
171
|
+
return COSMOS_TX_HASH_REGEX.test(input);
|
|
172
|
+
}
|
|
173
|
+
exports.isValidTransactionHashCosmos = isValidTransactionHashCosmos;
|
|
123
174
|
function isValidTransactionHash(input, protocol) {
|
|
124
175
|
if (protocol === types_1.ProtocolType.Ethereum) {
|
|
125
176
|
return isValidTransactionHashEvm(input);
|
|
@@ -127,13 +178,17 @@ function isValidTransactionHash(input, protocol) {
|
|
|
127
178
|
else if (protocol === types_1.ProtocolType.Sealevel) {
|
|
128
179
|
return isValidTransactionHashSealevel(input);
|
|
129
180
|
}
|
|
181
|
+
else if (protocol === types_1.ProtocolType.Cosmos) {
|
|
182
|
+
return isValidTransactionHashCosmos(input);
|
|
183
|
+
}
|
|
130
184
|
else {
|
|
131
185
|
return false;
|
|
132
186
|
}
|
|
133
187
|
}
|
|
134
188
|
exports.isValidTransactionHash = isValidTransactionHash;
|
|
135
189
|
function isZeroishAddress(address) {
|
|
136
|
-
return ZEROISH_ADDRESS_REGEX.test(address)
|
|
190
|
+
return (ZEROISH_ADDRESS_REGEX.test(address) ||
|
|
191
|
+
COSMOS_ZEROISH_ADDRESS_REGEX.test(address));
|
|
137
192
|
}
|
|
138
193
|
exports.isZeroishAddress = isZeroishAddress;
|
|
139
194
|
function shortenAddress(address, capitalize) {
|
|
@@ -155,60 +210,80 @@ function capitalizeAddress(address) {
|
|
|
155
210
|
return address.toUpperCase();
|
|
156
211
|
}
|
|
157
212
|
exports.capitalizeAddress = capitalizeAddress;
|
|
213
|
+
// For EVM addresses only, kept for backwards compatibility and convenience
|
|
158
214
|
function addressToBytes32(address) {
|
|
159
215
|
return ethers_1.utils
|
|
160
216
|
.hexZeroPad(ethers_1.utils.hexStripZeros(address), 32)
|
|
161
217
|
.toLowerCase();
|
|
162
218
|
}
|
|
163
219
|
exports.addressToBytes32 = addressToBytes32;
|
|
220
|
+
// For EVM addresses only, kept for backwards compatibility and convenience
|
|
164
221
|
function bytes32ToAddress(bytes32) {
|
|
165
222
|
return ethers_1.utils.getAddress(bytes32.slice(-40));
|
|
166
223
|
}
|
|
167
224
|
exports.bytes32ToAddress = bytes32ToAddress;
|
|
168
225
|
function addressToBytesEvm(address) {
|
|
169
226
|
const addrBytes32 = addressToBytes32(address);
|
|
170
|
-
return Buffer.from(addrBytes32
|
|
227
|
+
return Buffer.from(strip0x(addrBytes32), 'hex');
|
|
171
228
|
}
|
|
172
229
|
exports.addressToBytesEvm = addressToBytesEvm;
|
|
173
230
|
function addressToBytesSol(address) {
|
|
174
231
|
return new web3_js_1.PublicKey(address).toBytes();
|
|
175
232
|
}
|
|
176
233
|
exports.addressToBytesSol = addressToBytesSol;
|
|
234
|
+
function addressToBytesCosmos(address) {
|
|
235
|
+
return (0, encoding_1.fromBech32)(address).data;
|
|
236
|
+
}
|
|
237
|
+
exports.addressToBytesCosmos = addressToBytesCosmos;
|
|
177
238
|
function addressToBytes(address, protocol) {
|
|
178
|
-
return routeAddressUtil(
|
|
239
|
+
return routeAddressUtil({
|
|
240
|
+
[types_1.ProtocolType.Ethereum]: addressToBytesEvm,
|
|
241
|
+
[types_1.ProtocolType.Sealevel]: addressToBytesSol,
|
|
242
|
+
[types_1.ProtocolType.Cosmos]: addressToBytesCosmos,
|
|
243
|
+
}, address, new Uint8Array(), protocol);
|
|
179
244
|
}
|
|
180
245
|
exports.addressToBytes = addressToBytes;
|
|
181
246
|
function addressToByteHexString(address, protocol) {
|
|
182
|
-
return
|
|
247
|
+
return ensure0x(Buffer.from(addressToBytes(address, protocol)).toString('hex'));
|
|
183
248
|
}
|
|
184
249
|
exports.addressToByteHexString = addressToByteHexString;
|
|
185
|
-
function
|
|
186
|
-
|
|
187
|
-
|
|
250
|
+
function bytesToAddressEvm(bytes) {
|
|
251
|
+
return bytes32ToAddress(Buffer.from(bytes).toString('hex'));
|
|
252
|
+
}
|
|
253
|
+
exports.bytesToAddressEvm = bytesToAddressEvm;
|
|
254
|
+
function bytesToAddressSol(bytes) {
|
|
255
|
+
return new web3_js_1.PublicKey(bytes).toBase58();
|
|
256
|
+
}
|
|
257
|
+
exports.bytesToAddressSol = bytesToAddressSol;
|
|
258
|
+
function bytesToAddressCosmos(bytes, prefix) {
|
|
259
|
+
if (!prefix)
|
|
260
|
+
throw new Error('Prefix required for Cosmos address');
|
|
261
|
+
return (0, encoding_1.toBech32)(prefix, bytes);
|
|
262
|
+
}
|
|
263
|
+
exports.bytesToAddressCosmos = bytesToAddressCosmos;
|
|
264
|
+
function bytesToProtocolAddress(bytes, toProtocol, prefix) {
|
|
265
|
+
if (toProtocol === types_1.ProtocolType.Ethereum) {
|
|
266
|
+
return bytesToAddressEvm(bytes);
|
|
267
|
+
}
|
|
268
|
+
else if (toProtocol === types_1.ProtocolType.Sealevel) {
|
|
269
|
+
return bytesToAddressSol(bytes);
|
|
188
270
|
}
|
|
189
|
-
else if (toProtocol === types_1.ProtocolType.
|
|
190
|
-
return
|
|
271
|
+
else if (toProtocol === types_1.ProtocolType.Cosmos) {
|
|
272
|
+
return bytesToAddressCosmos(bytes, prefix);
|
|
191
273
|
}
|
|
192
274
|
else {
|
|
193
275
|
throw new Error(`Unsupported protocol for address ${toProtocol}`);
|
|
194
276
|
}
|
|
195
277
|
}
|
|
196
278
|
exports.bytesToProtocolAddress = bytesToProtocolAddress;
|
|
197
|
-
function convertToProtocolAddress(address, protocol) {
|
|
279
|
+
function convertToProtocolAddress(address, protocol, prefix) {
|
|
198
280
|
const currentProtocol = getAddressProtocolType(address);
|
|
281
|
+
if (!currentProtocol)
|
|
282
|
+
throw new Error(`Unknown address protocol for ${address}`);
|
|
199
283
|
if (currentProtocol === protocol)
|
|
200
284
|
return address;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
return new web3_js_1.PublicKey(addressToBytes(address, types_1.ProtocolType.Ethereum)).toBase58();
|
|
204
|
-
}
|
|
205
|
-
else if (currentProtocol === types_1.ProtocolType.Sealevel &&
|
|
206
|
-
protocol === types_1.ProtocolType.Ethereum) {
|
|
207
|
-
return bytes32ToAddress(Buffer.from(addressToBytes(address, types_1.ProtocolType.Sealevel)).toString('hex'));
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
throw new Error(`Unsupported protocol combination ${currentProtocol} -> ${protocol}`);
|
|
211
|
-
}
|
|
285
|
+
const addressBytes = addressToBytes(address, currentProtocol);
|
|
286
|
+
return bytesToProtocolAddress(addressBytes, protocol, prefix);
|
|
212
287
|
}
|
|
213
288
|
exports.convertToProtocolAddress = convertToProtocolAddress;
|
|
214
289
|
function ensure0x(hexstr) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAC5C,mCAA8C;AAE9C,mCAA2D;AAE3D,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAChD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../src/addresses.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AACzE,6CAA4C;AAC5C,mCAA8C;AAE9C,mCAA2D;AAE3D,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AAChD,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AACtD,MAAM,oBAAoB,GACxB,yDAAyD,CAAC,CAAC,SAAS;AACzD,QAAA,eAAe,GAAG,0BAA0B,CAAC;AAE1D,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAClD,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAEtD,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAE9D,SAAgB,YAAY,CAAC,OAAgB;IAC3C,OAAO,iBAAiB,CAAC,IAAI,CAA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AG,cAAc,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC9D,OAAO,sBAAsB,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC;AAXD,4DAWC;AAED,SAAgB,QAAQ,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;AAC1D,CAAC;AAFD,4BAEC;AAED,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5D,CAAC;AAFD,0BAEC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -2,12 +2,14 @@ import type { ethers } from 'ethers';
|
|
|
2
2
|
export declare enum ProtocolType {
|
|
3
3
|
Ethereum = "ethereum",
|
|
4
4
|
Sealevel = "sealevel",
|
|
5
|
-
Fuel = "fuel"
|
|
5
|
+
Fuel = "fuel",
|
|
6
|
+
Cosmos = "cosmos"
|
|
6
7
|
}
|
|
7
8
|
export type ProtocolTypeValue = `${ProtocolType}`;
|
|
8
9
|
export declare const ProtocolSmallestUnit: {
|
|
9
10
|
ethereum: string;
|
|
10
11
|
sealevel: string;
|
|
12
|
+
cosmos: string;
|
|
11
13
|
};
|
|
12
14
|
/********* BASIC TYPES *********/
|
|
13
15
|
export type Domain = number;
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,IAAI,SAAS;
|
|
1
|
+
{"version":3,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ocolType["Fuel"] = "fuel";
|
|
9
|
+
ProtocolType["Cosmos"] = "cosmos";
|
|
9
10
|
})(ProtocolType || (exports.ProtocolType = ProtocolType = {}));
|
|
10
11
|
exports.ProtocolSmallestUnit = {
|
|
11
12
|
[ProtocolType.Ethereum]: 'wei',
|
|
12
13
|
[ProtocolType.Sealevel]: 'lamports',
|
|
14
|
+
[ProtocolType.Cosmos]: 'uATOM',
|
|
13
15
|
};
|
|
14
16
|
var MessageStatus;
|
|
15
17
|
(function (MessageStatus) {
|
package/dist/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAEA,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,qCAAqB,CAAA;IACrB,6BAAa,CAAA;IACb,iCAAiB,CAAA;AACnB,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAIY,QAAA,oBAAoB,GAAG;IAClC,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,KAAK;IAC9B,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,UAAU;IACnC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO;CAC/B,CAAC;AAwDF,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,iDAAQ,CAAA;IACR,2DAAS,CAAA;AACX,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAqBD,IAAY,4BAEX;AAFD,WAAY,4BAA4B;IACtC,uFAAY,CAAA;AACd,CAAC,EAFW,4BAA4B,4CAA5B,4BAA4B,QAEvC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperlane-xyz/utils",
|
|
3
3
|
"description": "General utilities and types for the Hyperlane network",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.1.0-beta1",
|
|
5
5
|
"dependencies": {
|
|
6
|
+
"@cosmjs/encoding": "^0.31.3",
|
|
6
7
|
"@solana/web3.js": "^1.78.0",
|
|
7
8
|
"bignumber.js": "^9.1.1",
|
|
8
9
|
"ethers": "^5.7.2"
|