@ethersphere/bee-js
Advanced tools
Comparing version 7.0.4 to 7.1.0
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.makeEthereumWalletSigner = exports.ethToSwarmAddress = exports.fromLittleEndian = exports.toLittleEndian = exports.isHexEthAddress = exports.makeHexEthAddress = exports.makeEthAddress = void 0; | ||
exports.makeEthereumWalletSigner = exports.ethToSwarmAddress = exports.fromLittleEndian = exports.toLittleEndian = exports.isHexEthAddress = exports.makeHexEthAddress = exports.makeEthAddress = exports.capitalizeAddressERC55 = void 0; | ||
// For ESM compatibility | ||
@@ -15,2 +15,19 @@ const js_sha3_1 = __importDefault(require("js-sha3")); | ||
const ETH_ADDR_HEX_LENGTH = 40; | ||
function capitalizeAddressERC55(address) { | ||
if (address.startsWith('0x')) { | ||
address = address.slice(2); | ||
} | ||
const addressHash = keccak256(address.toLowerCase()); | ||
let result = '0x'; | ||
for (let i = 0; i < address.length; i++) { | ||
if (parseInt(addressHash[i], 16) > 7) { | ||
result += address[i].toUpperCase(); | ||
} | ||
else { | ||
result += address[i].toLowerCase(); | ||
} | ||
} | ||
return result; | ||
} | ||
exports.capitalizeAddressERC55 = capitalizeAddressERC55; | ||
function makeEthAddress(address) { | ||
@@ -17,0 +34,0 @@ if (typeof address === 'string') { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.getStampUsage = exports.getStampTtlSeconds = exports.getStampMaximumCapacityBytes = exports.getStampEffectiveBytes = exports.getStampCostInPlur = exports.getStampCostInBzz = exports.getDepthForCapacity = exports.getAmountForTtl = exports.makeMaxTarget = exports.keccak256Hash = exports.toLittleEndian = exports.makeHexEthAddress = exports.makeEthereumWalletSigner = exports.makeEthAddress = exports.isHexEthAddress = exports.fromLittleEndian = exports.ethToSwarmAddress = exports.makeHexString = exports.isHexString = exports.intToHex = exports.hexToBytes = exports.bytesToHex = exports.assertPrefixedHexString = exports.assertHexString = exports.isFlexBytes = exports.isBytes = exports.flexBytesAtOffset = exports.bytesEqual = exports.bytesAtOffset = exports.assertFlexBytes = exports.assertBytes = exports.getFolderSize = exports.getCollectionSize = void 0; | ||
exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.getStampUsage = exports.getStampTtlSeconds = exports.getStampMaximumCapacityBytes = exports.getStampEffectiveBytes = exports.getStampCostInPlur = exports.getStampCostInBzz = exports.getDepthForCapacity = exports.getAmountForTtl = exports.makeMaxTarget = exports.keccak256Hash = exports.toLittleEndian = exports.makeHexEthAddress = exports.makeEthereumWalletSigner = exports.makeEthAddress = exports.isHexEthAddress = exports.fromLittleEndian = exports.ethToSwarmAddress = exports.capitalizeAddressERC55 = exports.makeHexString = exports.isHexString = exports.intToHex = exports.hexToBytes = exports.bytesToHex = exports.assertPrefixedHexString = exports.assertHexString = exports.isFlexBytes = exports.isBytes = exports.flexBytesAtOffset = exports.bytesEqual = exports.bytesAtOffset = exports.assertFlexBytes = exports.assertBytes = exports.getFolderSize = exports.getCollectionSize = void 0; | ||
var collection_1 = require("./collection"); | ||
@@ -25,2 +25,3 @@ Object.defineProperty(exports, "getCollectionSize", { enumerable: true, get: function () { return collection_1.getCollectionSize; } }); | ||
var eth_1 = require("./eth"); | ||
Object.defineProperty(exports, "capitalizeAddressERC55", { enumerable: true, get: function () { return eth_1.capitalizeAddressERC55; } }); | ||
Object.defineProperty(exports, "ethToSwarmAddress", { enumerable: true, get: function () { return eth_1.ethToSwarmAddress; } }); | ||
@@ -27,0 +28,0 @@ Object.defineProperty(exports, "fromLittleEndian", { enumerable: true, get: function () { return eth_1.fromLittleEndian; } }); |
@@ -11,2 +11,17 @@ // For ESM compatibility | ||
const ETH_ADDR_HEX_LENGTH = 40; | ||
export function capitalizeAddressERC55(address) { | ||
if (address.startsWith('0x')) { | ||
address = address.slice(2); | ||
} | ||
const addressHash = keccak256(address.toLowerCase()); | ||
let result = '0x'; | ||
for (let i = 0; i < address.length; i++) { | ||
if (parseInt(addressHash[i], 16) > 7) { | ||
result += address[i].toUpperCase(); | ||
} else { | ||
result += address[i].toLowerCase(); | ||
} | ||
} | ||
return result; | ||
} | ||
export function makeEthAddress(address) { | ||
@@ -13,0 +28,0 @@ if (typeof address === 'string') { |
@@ -5,3 +5,3 @@ export { getCollectionSize } from "./collection.js"; | ||
export { assertHexString, assertPrefixedHexString, bytesToHex, hexToBytes, intToHex, isHexString, makeHexString } from "./hex.js"; | ||
export { ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian } from "./eth.js"; | ||
export { capitalizeAddressERC55, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian } from "./eth.js"; | ||
export { keccak256Hash } from "./hash.js"; | ||
@@ -8,0 +8,0 @@ export { makeMaxTarget } from "./pss.js"; |
@@ -7,2 +7,3 @@ import { BrandedString, Signer } from '../types'; | ||
export type HexEthAddress = HexString<40>; | ||
export declare function capitalizeAddressERC55(address: string): string; | ||
export declare function makeEthAddress(address: EthAddress | Uint8Array | string | unknown): EthAddress; | ||
@@ -9,0 +10,0 @@ export declare function makeHexEthAddress(address: EthAddress | Uint8Array | string | unknown): HexEthAddress; |
@@ -5,3 +5,3 @@ export { getCollectionSize } from './collection'; | ||
export { HexString, PrefixedHexString, assertHexString, assertPrefixedHexString, bytesToHex, hexToBytes, intToHex, isHexString, makeHexString, } from './hex'; | ||
export { EthAddress, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian, } from './eth'; | ||
export { EthAddress, capitalizeAddressERC55, ethToSwarmAddress, fromLittleEndian, isHexEthAddress, makeEthAddress, makeEthereumWalletSigner, makeHexEthAddress, toLittleEndian, } from './eth'; | ||
export { keccak256Hash } from './hash'; | ||
@@ -8,0 +8,0 @@ export { makeMaxTarget } from './pss'; |
{ | ||
"name": "@ethersphere/bee-js", | ||
"version": "7.0.4", | ||
"version": "7.1.0", | ||
"description": "Javascript client for Bee", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1888551
14147