How to use the ethereumjs-util.toChecksumAddress function in ethereumjs-util

To help you get started, we’ve selected a few ethereumjs-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github merklejerk / flex-contract / src / coder.js View on Github external
function normalizeDecodedValue(type, value) {
	if (_.isArray(value))
		return _.map(value, v => normalizeDecodedValue(type, v));
	const elementType = /^[a-z0-9]+/i.exec(type)[0];
	assert(elementType);
	// Convert addresses to checksummed addresses.
	if (elementType == 'address')
		return ethjs.toChecksumAddress(value);
	// Convert integers to strings.
	if (/^u?int/.test(elementType) && _.isObject(value))
		return value.toString(10);
	// Resize bytes values.
	const m = /^bytes(\d+)?$/.exec(elementType);
	if (m && m[1]) {
		const size = parseInt(m[1]);
		return ethjs.bufferToHex(ethjs.setLengthRight(value, size));
	}
	return value;
}
github MetaMask / metamask-mobile / app / components / Views / SendFlow / index.js View on Github external
onToSelectedAddressChange = async toSelectedAddress => {
		const { addressBook, network, identities } = this.props;
		const networkAddressBook = addressBook[network] || {};
		let [addToAddressToAddressBook, toSelectedAddressReady, toAddressName, toEnsName] = [
			false,
			false,
			undefined,
			undefined
		];
		if (isValidAddress(toSelectedAddress)) {
			const checksummedToSelectedAddress = toChecksumAddress(toSelectedAddress);
			toSelectedAddressReady = true;
			const ens = await doENSReverseLookup(toSelectedAddress);
			if (ens) {
				toAddressName = ens;
			} else if (networkAddressBook[checksummedToSelectedAddress] || identities[checksummedToSelectedAddress]) {
				toAddressName =
					(networkAddressBook[checksummedToSelectedAddress] &&
						networkAddressBook[checksummedToSelectedAddress].name) ||
					(identities[checksummedToSelectedAddress] && identities[checksummedToSelectedAddress].name);
			} else {
				// If not in address book nor user accounts
				addToAddressToAddressBook = true;
			}
		} else if (isENS(toSelectedAddress)) {
			toEnsName = toSelectedAddress;
			const resolvedAddress = await doENSLookup(toSelectedAddress, network);
github ethers-io / ethers.js / tests / test-icap-address.js View on Github external
function testAddress(address) {
        var officialIban = (iban.fromAddress(address))._iban;

        var address = ethersAddress.getAddress(officialIban);
        var officialAddress = ethereumUtil.toChecksumAddress(address)

        var ethersIban = ethersAddress.getAddress(address, true);

        test.equal(address, officialAddress, 'wrong address');
        test.equal(ethersIban, officialIban, 'wrong ICAP address');
    }
github MyCryptoHQ / MyCrypto / common / v2 / features / CreateWallet / Keystore / Keystore.tsx View on Github external
createAccountWithID,
      updateSettingsAccounts,
      createAssetWithID,
      displayNotification
    } = this.props;
    const { keystore, network, accountType } = this.state;

    const accountNetwork: Network | undefined = getNetworkByName(network);
    if (!keystore || !accountNetwork) {
      return;
    }
    const newAsset: Asset = getNewDefaultAssetTemplateByNetwork(accountNetwork);
    const newAssetID: string = generateUUID();
    const newUUID = generateUUID();
    const account: Account = {
      address: toChecksumAddress(addHexPrefix(keystore.address)),
      networkId: network as NetworkId,
      wallet: accountType,
      dPath: '',
      assets: [{ uuid: newAssetID, balance: '0', mtime: Date.now() }],
      transactions: [],
      favorite: false,
      mtime: 0
    };
    createAccountWithID(account, newUUID);
    updateSettingsAccounts([...settings.dashboardAccounts, newUUID]);
    createAssetWithID(newAsset, newAssetID);

    displayNotification(NotificationTemplates.walletCreated, {
      address: account.address
    });
    history.replace(ROUTE_PATHS.DASHBOARD.path);
github brave / ethereum-remote-client / app / scripts / metamask-controller.js View on Github external
      hd: hdAccounts.filter((item, pos) => (hdAccounts.indexOf(item) === pos)).map(address => ethUtil.toChecksumAddress(address)),
      simpleKeyPair: [],
github go-faast / faast-web / src / utilities / convert.ts View on Github external
export function toChecksumAddress(address: string): string {
  return EthereumjsUtil.toChecksumAddress(address)
}
github MyEtherWallet / MyEtherWallet / src / wallets / software / basicWallet.js View on Github external
getAddressString() {
    const rawAddress = '0x' + this.getAddress().toString('hex');
    return ethUtil.toChecksumAddress(rawAddress);
  }
github invisible-college / democracy / packages / keys / src / wallet.js View on Github external
wallet.lockEncryptedAccountSync = ({ address }) => {
  const checksumAddress = toChecksumAddress(address)
  const { id, relockFunc } = wallet.relockMap[checksumAddress]
  if (id) {
    clearTimeout(id)
    relockFunc()
    delete wallet.relockMap[checksumAddress]
    LOGGER.debug(`Relocked ${address}`)
  }
}
github merklejerk / flex-contract / src / index.js View on Github external
receipt => {
				this._address = ethjs.toChecksumAddress(receipt.contractAddress);
			});
		return r;
github airgap-it / airgap-coin-lib / lib / protocols / GenericERC20.ts View on Github external
getTransactionDetails(unsignedTx: UnsignedTransaction): IAirGapTransaction {
    const unsignedEthereumTx = unsignedTx as UnsignedEthereumTransaction
    const ethTx = super.getTransactionDetails(unsignedEthereumTx)

    const tokenTransferDetails = abiDecoder.decodeMethod(unsignedEthereumTx.transaction.data)

    ethTx.to = [ethUtil.toChecksumAddress(tokenTransferDetails.params[0].value)]
    ethTx.amount = new BigNumber(tokenTransferDetails.params[1].value)

    return ethTx
  }
}