Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const overloadedTransferAbi = {
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" },
{ "name": "_data", "type": "bytes" }
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
const transferMethodTransactionDataA = web3Abi
.encodeFunctionCall( overloadedTransferAbi, [ fluorideAddrA,intAmountA, tradeId ]);
const transferMethodTransactionDataB = web3Abi
.encodeFunctionCall( overloadedTransferAbi, [ fluorideAddrB,intAmountB, tradeId ]);
const receiptPayA = await web3.eth
.sendTransaction({from: addrA, to: tokenA.address, data: transferMethodTransactionDataA, value: 0});
const receiptPayB = await web3.eth
.sendTransaction({from: addrB, to: tokenB.address, data: transferMethodTransactionDataB, value: 0});
const tokenABalA1 = await tokenA.balanceOf(addrA)
const tokenABalB1 = await tokenA.balanceOf(addrB)
const tokenBBalA1 = await tokenB.balanceOf(addrA)
const tokenBBalB1 = await tokenB.balanceOf(addrB)
// UPDATE SODIUM (this should be done by event relay/lithium)
const expectEventA = joinHex([fluorideAddrB/*, topic*/,tradeId])
const expectEventB = joinHex([fluorideAddrA/*, topic*/,tradeId])
const testDataA = [expectEventA,"2","3","4","5","6","7"]
it('should transfer half the balance in composable "3" to bob', async () => {
//const success = await composable.safeTransferFTP.call(bob, 3, sampleERC20.address, 250, bytes1);
//assert(success, 'did not transfer ERC20 from composable');
//const tx = await composable.safeTransferFTP(bob, 3, sampleERC20.address, 250, bytes1);
const transfer = ComposableTopDown.abi.filter(f => f.name === 'transferERC20' && f.inputs.length === 4)[0];
const transferMethodTransactionData = web3Abi.encodeFunctionCall(
transfer, [3, bob, sampleERC20.address, 250]
);
const tx = await web3.eth.sendTransaction({
from: alice, to: composable.address, data: transferMethodTransactionData, value: 0, gas: 500000
});
assert(tx, 'did not transfer');
});
it('should return the correct number of totalChildTokens and totalChildTokens after NFT contracts are added', async () => {
const aliceComposableTokenId = 2;
const numNFTs = 5;
const mintedPerNFT = 3;
const [nfts, erc20s] = await setupTestTokens(numNFTs, 0);
for (var i = 0; i < nfts.length; i++) {
const mintedTokens = [];
const safeTransferFrom = nfts[i].abi.filter(f => f.name === 'safeTransferFrom' && f.inputs.length === 4)[0];
for (var j = 0; j < mintedPerNFT; j++) {
await nfts[i].mint721(alice);
const mintedTokenId = j + 1;
mintedTokens.push(mintedTokenId);
const transferMethodTransactionData = web3Abi.encodeFunctionCall(
safeTransferFrom, [alice, composable.address, mintedTokenId, bytes2]
);
const tx = await web3.eth.sendTransaction({
from: alice, to: nfts[i].address, data: transferMethodTransactionData, value: 0, gas: 500000
});
}
const numNFTChildren = await composable.totalChildTokens(aliceComposableTokenId, nfts[i].address);
assert(
numNFTChildren.equals(mintedTokens.length),
`Expected number of totalChildTokens to be ${mintedTokens.length} but got ${numNFTChildren}`
);
}
const totalContracts = await composable.totalChildContracts(aliceComposableTokenId)
assert(
totalContracts.equals(numNFTs),
`Expected totalChildContracts to be ${numNFTs} but got ${totalContracts}`
"name": "value",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
}
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
};
const transferMethodTransactionData = web3Abi.encodeFunctionCall(
overloadedTransferAbi,
[
to,
value,
data
]
);
return await web3.eth.sendTransaction({from: params.from, to: contract.address, data: transferMethodTransactionData, value: params.value || 0});
}
//const receiptTransfer1 = await token.transfer(ionLock.address,value)
const overloadedTransferAbi = {
"constant": false,
"inputs": [
{ "name": "_to", "type": "address" },
{ "name": "_value", "type": "uint256" },
{ "name": "_data", "type": "bytes" }
],
"name": "transfer",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
const transferMethodTransactionData = web3Abi.encodeFunctionCall(
overloadedTransferAbi,
[
ionLock.address,
value,
Web3Utils.toHex(rawRef)
]
);
const receiptTransfer1 = await web3.eth.sendTransaction(
{
from: owner,
to: token.address,
data: transferMethodTransactionData,
value: 0
}
);
export default async function(ledger: AssetLedger) {
const attrs = {
to: ledger.id,
data: encodeFunctionCall(abi, []),
};
const res = await ledger.provider.send({
method: 'eth_call',
params: [attrs, 'latest'],
});
return decodeParameters(abi.outputs, res.result)[0];
}
async transfer(context, params) {
const transferMethod = EIP20.abi.find(method => {
return method.name === 'transfer'
})
const transferMethodTransactionData = web3Abi.encodeFunctionCall(
transferMethod,
[params.to, web3.utils.toBN(params.value)]
)
const estimateGas = await web3.eth.estimateGas({
from: account,
to: tokenAddress,
data: transferMethodTransactionData
})
const receipt = await web3.eth.sendTransaction({
from: account,
to: tokenAddress,
data: transferMethodTransactionData,
value: 0,
gas: estimateGas
onPressDepositAndWhitelist = () => {
const { whitelistAddress } = this.state
if (web3Utils.isAddress(whitelistAddress)) {
this.setState({
showWhitelistError: false,
})
const encodedWhitelistCall = abi.encodeFunctionCall(
{
name: 'stake',
type: 'function',
inputs: [
{
name: 'whitelistAddress',
type: 'address',
},
],
},
[whitelistAddress],
)
const url = `https://legacy.mycrypto.com/?to=${
this.state.stakeAddress
}&value=0&gaslimit=150000&data=${encodedWhitelistCall}#send-transaction`
shell.openExternal(url)
onPressApprove = () => {
const { stakeAddress, requiredStake } = this.state
const encodedApproveCall = abi.encodeFunctionCall(
{
name: 'approve',
type: 'function',
inputs: [
{
type: 'address',
name: '_spender',
},
{
type: 'uint256',
name: '_value',
},
],
},
[stakeAddress, requiredStake],
)
enc: (params: any[]) => {
return web3EthABI.encodeFunctionCall(v, [
'0x' + params[0],
]) as string;
},
dec: (raw: ArrayBuffer | string) => {