Guest User

Untitled

a guest
Jun 6th, 2021
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. mapping(uint=>address) public theWork; //noita
  2. mapping(uint=>uint) workingTotem;
  3. mapping(uint=>string) public txt;
  4. mapping(uint=>bool) requestLocked;
  5. event OracleRequest(address buidlr, uint totemID, uint earningsToManifest, address _theWork, string text, uint ticketID);
  6. function oracleRequest(uint totemID, string memory _txt, address contract_optional) public payable returns(uint ticketID){
  7. address sender = msg.sender;
  8. require( staker[totemID] == sender && !totemManifest[totemID] && !requestLocked[totemID] );
  9. uint ID = ORACLE.fileRequestTicket{value: msg.value}(1, true);
  10. workingTotem[ID] = totemID;
  11. theWork[totemID] = contract_optional;
  12. txt[totemID] = _txt;
  13. requestLocked[totemID] = true;
  14. emit OracleRequest(sender, totemID, builder_dividendsOf(totemID)+builder_earnings[totemID], contract_optional, _txt, ID);
  15. return ID;
  16. }
  17.  
  18. event CommunityReward(address buidlr, uint totemID, uint reward, address contractBuilt, string text, uint ticketID);
  19. event RequestRejected(uint totemID, uint ticketID);
  20. function oracleIntFallback(uint ticketID, bool requestRejected, uint numberOfOptions, uint[] memory optionWeights, int[] memory intOptions) public{
  21. uint optWeight;
  22. uint positive;
  23. uint negative;
  24. uint totemID = workingTotem[ticketID];
  25. require( msg.sender == address(ORACLE) );
  26.  
  27. for(uint i; i < numberOfOptions; i+=1){
  28. optWeight = optionWeights[i];
  29. if(intOptions[i]>0){
  30. positive += optWeight;
  31. }else{
  32. negative += optWeight;
  33. }
  34. }
  35.  
  36. if(!requestRejected && positive>negative){
  37. //emit event and give reward
  38. if(!totemManifest[totemID]){
  39. totemManifest[totemID] = true;
  40. uint earned = builder_earnings[totemID];
  41. if(earned>0){
  42. if( staker[totemID]==address(0) ){
  43. storeUpCommunityRewards(earned);
  44. }else{
  45. earnings[MVTpool][staker[totemID]] += earned;
  46. }
  47. }
  48. emit CommunityReward(staker[totemID], totemID, earned, theWork[totemID], txt[totemID], ticketID );
  49. }
  50. }else{
  51. emit RequestRejected(totemID,ticketID);
  52. }
  53. requestLocked[totemID] = false;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment