Skip to content

Instantly share code, notes, and snippets.

@koras
Created October 16, 2018 19:13
Show Gist options
  • Save koras/c3d5c3b04008ab9a0bbb0d3085464123 to your computer and use it in GitHub Desktop.
Save koras/c3d5c3b04008ab9a0bbb0d3085464123 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.23;
/// @title Interface new rabbits address
contract FromInterface {
function getBunny(uint32 _bunny) public view returns(
uint32 mother,
uint32 sire,
uint birthblock,
uint birthCount,
uint birthLastTime,
uint role,
uint genome,
bool interbreed,
uint leftTime,
uint lastTime,
uint price,
uint motherSumm
);
function getRabbitDNK(uint32 bunnyid) public view returns(uint);
function ownerOf(uint32 _tokenId) public view returns (address owner);
}
/// @title Interface new rabbits address
contract ToInterface {
function relocateToken(
uint32 id,
uint32 mother,
uint32 sire,
uint birthblock,
uint birthCount,
uint birthLastTime,
uint genome,
address _owner,
uint DNK)
external;
function setRabbitMother(uint32 children, uint32[5] _m) external;
}
contract Relocate44 {
address public fromAddress = 0x35Ea9df0B7E2E450B1D129a6F81276103b84F3dC;
address public toAddress = 0x2Ed020b084F7a58Ce7AC5d86496dC4ef48413a24;
address ownerCEO;
FromInterface fromContract;
ToInterface toContract;
constructor() public {
ownerCEO = msg.sender;
setFrom(fromAddress);
setTo(toAddress);
}
modifier onlyOwner() {
require(msg.sender == ownerCEO);
_;
}
function setFrom(address _from) {
fromContract = FromInterface(_from);
}
function setTo(address _to) public {
toContract = ToInterface(_to);
}
function sendBunny(uint32 bunnyID) public {
// for (bunnyID ; bunnyID < (bunnyID+limit); bunnyID++) {
// uint birthblock;
uint genome;
uint32 motherStart;
uint32 sire;
uint32 motherlocal;
// bool mothersave;
address own;
uint dnk;
uint32[5] memory mother;
uint256 m=0;
own = fromContract.ownerOf(bunnyID);
dnk = fromContract.getRabbitDNK(bunnyID);
(motherStart,sire,, ,,,genome,,,,,) = fromContract.getBunny(bunnyID);
toContract.relocateToken( bunnyID, motherStart, sire, 0, 0 , 0, genome, own, dnk);
if(motherStart!=0)
{
mother[0] = motherStart;
mother[1] = 0;
mother[2] = 0;
mother[3] = 0;
mother[4] = 0;
for (m = 1; m < 5; m++)
{
(motherlocal ,,,,,,,,,,,) = fromContract.getBunny(motherStart);
if(motherlocal!=0)
{
mother[m] = motherlocal;
motherStart = motherlocal;
}
}
toContract.setRabbitMother(bunnyID, mother);
}
//2
bunnyID = bunnyID+1;
own = fromContract.ownerOf(bunnyID);
dnk = fromContract.getRabbitDNK(bunnyID);
(motherStart,sire,, ,,,genome,,,,,) = fromContract.getBunny(bunnyID);
toContract.relocateToken( bunnyID, motherStart, sire, 0, 0 , 0, genome, own, dnk);
if(motherStart!=0)
{
mother[0] = motherStart;
mother[1] = 0;
mother[2] = 0;
mother[3] = 0;
mother[4] = 0;
for (m = 1; m < 5; m++)
{
(motherlocal ,,,,,,,,,,,) = fromContract.getBunny(motherStart);
if(motherlocal!=0)
{
mother[m] = motherlocal;
motherStart = motherlocal;
}
}
toContract.setRabbitMother(bunnyID, mother);
}
//3
bunnyID = bunnyID+1;
own = fromContract.ownerOf(bunnyID);
dnk = fromContract.getRabbitDNK(bunnyID);
(motherStart,sire,, ,,,genome,,,,,) = fromContract.getBunny(bunnyID);
toContract.relocateToken( bunnyID, motherStart, sire, 0, 0 , 0, genome, own, dnk);
if(motherStart!=0)
{
mother[0] = motherStart;
mother[1] = 0;
mother[2] = 0;
mother[3] = 0;
mother[4] = 0;
for (m = 1; m < 5; m++)
{
(motherlocal ,,,,,,,,,,,) = fromContract.getBunny(motherStart);
if(motherlocal!=0)
{
mother[m] = motherlocal;
motherStart = motherlocal;
}
}
toContract.setRabbitMother(bunnyID, mother);
}
//4
bunnyID = bunnyID+1;
own = fromContract.ownerOf(bunnyID);
dnk = fromContract.getRabbitDNK(bunnyID);
(motherStart,sire,, ,,,genome,,,,,) = fromContract.getBunny(bunnyID);
toContract.relocateToken( bunnyID, motherStart, sire, 0, 0 , 0, genome, own, dnk);
if(motherStart!=0)
{
mother[0] = motherStart;
mother[1] = 0;
mother[2] = 0;
mother[3] = 0;
mother[4] = 0;
for (m = 1; m < 5; m++)
{
(motherlocal ,,,,,,,,,,,) = fromContract.getBunny(motherStart);
if(motherlocal!=0)
{
mother[m] = motherlocal;
motherStart = motherlocal;
}
}
toContract.setRabbitMother(bunnyID, mother);
}
//5
bunnyID = bunnyID+1;
own = fromContract.ownerOf(bunnyID);
dnk = fromContract.getRabbitDNK(bunnyID);
(motherStart,sire,, ,,,genome,,,,,) = fromContract.getBunny(bunnyID);
toContract.relocateToken( bunnyID, motherStart, sire, 0, 0 , 0, genome, own, dnk);
if(motherStart!=0)
{
mother[0] = motherStart;
mother[1] = 0;
mother[2] = 0;
mother[3] = 0;
mother[4] = 0;
for (m = 1; m < 5; m++)
{
(motherlocal ,,,,,,,,,,,) = fromContract.getBunny(motherStart);
if(motherlocal!=0)
{
mother[m] = motherlocal;
motherStart = motherlocal;
}
}
toContract.setRabbitMother(bunnyID, mother);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment