-
I have been using the functions function checkUpkeep(bytes memory /* checkData */) public view override returns (//,bytes memory value
bool upkeepNeeded,
bytes memory num
){
bool sellTime;
bool Quant;
uint256 EthPrice;
// bytes memory Wallet;
// bytes memory num;
EthPrice = getPrice();
address[] memory id = new address[](s_Wallets.length);
for (uint i = 0; i < s_Wallets.length; i++) { //Search in loop which Stop should be triggered
id[i] = s_Wallets[i];
Dades memory Data = s_Registre[id[i]];
uint256 SL = Data.Stop;
uint256 Q = Data.QuantityETH;
sellTime = (SL <= EthPrice);
Quant = (Q > 0);
if (sellTime && Quant){
num = abi.encode(i);
// Wallet = abi.encode(id[i]);
//value = abi.encodePacked(Q);
upkeepNeeded = (sellTime && Quant);
break;
}
//upkeepNeeded = (sellTime && Quant); //All conditions must be True
}
//upkeepNeeded = true;
return (upkeepNeeded, num);//, value
}
function performUpkeep(bytes calldata num) external override {//, bytes calldata value
(bool upkeepNeeded, ) = checkUpkeep("");
// require(upkeepNeeded, "Upkeep not needed");
if (!upkeepNeeded) {
revert Order__UpkeepNotNeeded(
address(this).balance,
s_Wallets.length
);
}
//Byte conversion to uint
uint256 number;
number = abi.decode(num, (uint256));
// RESET DATA FROM WALLET
// Reseteja les dades
Dades storage dades = s_Registre[s_Wallets[number]];
dades.QuantityETH = 0;
dades.Stop = 0;
//Delets wallet from the list
s_Wallets = Remove(number);
} First function encode (i) and second function decodes it but the data is not properly transferret and I don't know why. All codes in internet work somehow like this using keepers.
Any advice? I'm quite stuck with this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Encode/decode is working now. What seems not be working is the priceFeed insite the |
Beta Was this translation helpful? Give feedback.
-
Push to GitHub please |
Beta Was this translation helpful? Give feedback.
Push to GitHub please