How to use eth-url-parser - 4 common examples

To help you get started, we’ve selected a few eth-url-parser 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 MetaMask / metamask-mobile / app / components / Views / QRScanner / index.js View on Github external
data = { content };
			if (this.props.navigation.state.params.onStartScan) {
				this.props.navigation.state.params.onStartScan(data).then(() => {
					this.props.navigation.state.params.onScanSuccess(data);
				});
				this.mounted = false;
				this.props.navigation.goBack();
			} else {
				Alert.alert(strings('qr_scanner.error'), strings('qr_scanner.attempting_sync_from_wallet_error'));
				this.mounted = false;
				this.props.navigation.goBack();
			}
		} else {
			if (content.split('ethereum:').length > 1) {
				this.shouldReadBarCode = false;
				data = parse(content);
				let action = 'send-eth';
				if (data.function_name === 'transfer') {
					// Send erc20 token
					action = 'send-token';
				}
				data = { ...data, action };
			} else if (
				content.length === 64 ||
				(content.substring(0, 2).toLowerCase() === '0x' && content.length === 66)
			) {
				this.shouldReadBarCode = false;
				data = { private_key: content.length === 64 ? content : content.substr(2) };
			} else if (content.substring(0, 2).toLowerCase() === '0x') {
				this.shouldReadBarCode = false;
				data = { target_address: content, action: 'send-eth' };
			} else if (content.split('wc:').length > 1) {
github MetaMask / metamask-mobile / app / core / DeeplinkManager.js View on Github external
handleEthereumUrl(url) {
		let action;
		const ethUrl = parse(url);
		action = 'send-eth';
		if (ethUrl.function_name === 'transfer') {
			// Send erc20 token
			action = 'send-token';
		} else if (ethUrl.function_name) {
			// Other smart contract interaction
			// That involves txs
			action = 'smart-contract-interaction';
		}
		this.navigation.navigate('SendView', { txMeta: { ...ethUrl, action, source: url } });
	}
github MetaMask / metamask-mobile / app / util / payment-link-generator.js View on Github external
export function generateETHLink(receiverAddress, value, chainId) {
	const data = {
		chain_id: chainId,
		function_name: undefined,
		parameters: {
			value: value + 'e18'
		},
		scheme: 'ethereum',
		target_address: receiverAddress
	};
	return build(data);
}
github MetaMask / metamask-mobile / app / util / payment-link-generator.js View on Github external
export function generateERC20Link(receiverAddress, assetAddress, value, chainId) {
	const data = {
		chain_id: chainId,
		function_name: 'transfer',
		parameters: {
			address: receiverAddress,
			uint256: value
		},
		scheme: 'ethereum',
		target_address: assetAddress
	};
	return build(data);
}

eth-url-parser

Ethereum url parsing library

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular eth-url-parser functions