Skip to content

Instantly share code, notes, and snippets.

@jdkanani
Created May 15, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdkanani/d2285249c8177644a60fe134fb22a635 to your computer and use it in GitHub Desktop.
Save jdkanani/d2285249c8177644a60fe134fb22a635 to your computer and use it in GitHub Desktop.
pragma solidity 0.5.9;
contract DepositTest {
event Deposit(
address rootToken,
address user,
uint256 amountOrTokenId,
uint256 depositCount
);
struct D {
address rootToken;
address user;
uint256 amountOrTokenId;
uint256 depositCount;
}
mapping(uint256 => D) public ds;
constructor() public payable {
}
event LogTransfer(
address indexed token,
address indexed f,
address indexed to,
uint256 amount,
uint256 input1,
uint256 input2,
uint256 output1,
uint256 output2
);
event LogFeeTransfer(
address indexed token,
address indexed f,
address indexed to,
uint256 amount,
uint256 input1,
uint256 input2,
uint256 output1,
uint256 output2
);
function e() public payable {
emit Deposit(0x48aA8D4AF32551892FCF08Ad63Be7dD206D46F65, 0x48aA8D4AF32551892FCF08Ad63Be7dD206D46F65, 10, 20);
}
function transferTo(address payable to) public payable {
to.transfer(msg.value);
}
// function e1() public {
// deposit1(9, hex"1234", 0x48aA8D4AF32551892FCF08Ad63Be7dD206D46F65, 10, hex"1232");
// }
// function c(bytes memory payload) public {
// address(this).call(payload);
// }
// function deposit(uint256 depositId, bytes memory uy, address to, uint256 amount, bytes memory ab) public {
// emit Deposit(depositId, uy, to, amount, ab);
// emit PackedDeposit(abi.encode(depositId, to, amount, ab));
// }
function onStateReceive(
uint256 stateId,
bytes memory payload
) public {
require(msg.sender == address(0x0000000000000000000000000000000000001001));
// address(this).call(abi.encodePacked(bytes4(keccak256("depositTokens(address,address,bytes,uint256,uint256)")), payload));
address rootToken;
address user;
uint256 amountOrTokenId;
uint256 depositCount;
(rootToken, user, amountOrTokenId, depositCount) = abi.decode(payload, (address,address,uint256,uint256));
depositTokens(rootToken,user, amountOrTokenId, depositCount);
}
function depositTokens(
address rootToken,
address user,
uint256 amountOrTokenId,
uint256 depositCount
) internal {
emit Deposit(rootToken, user, amountOrTokenId, depositCount);
ds[depositCount] = D({
rootToken: rootToken,
user: user,
amountOrTokenId: amountOrTokenId,
depositCount: depositCount
});
}
// counter
uint256 public counter = 0;
event StateSynced(uint256 indexed id, address indexed contractAddress, bytes data);
// sync state
function syncState(address receiver, bytes memory data) public /* onlyRegistered(receiver) */ {
counter = counter + 1;
emit StateSynced(counter, receiver, data);
}
// function deposit1(uint256 depositId, bytes memory uy, address to, uint256 amount, bytes memory ab) public {
// emit Deposit(depositId, uy, to, amount, ab);
// emit PackedDeposit1(msg.data);
// emit PackedDeposit(abi.encode(depositId, uy, to, amount, ab));
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment