Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
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 } });
}
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);
}
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);
}