This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function bet(uint stake, uint spinUnder)external notOwner returns (uint spinUnderInput, uint stakeInput, uint prize, uint payout, uint previousBalance){ | |
| require(stake >= minBet && maxBet >= stake , 'stake is outside allowed limits'); | |
| require(spinUnder >= MIN_ROLL_UNDER && spinUnder <= MAX_ROLL_UNDER, 'spinUnder must be between or equal to 11 and 91'); | |
| require(balances[msg.sender] >= stake, 'insufficient balance to cover stake'); | |
| (payout, prize) = getPrizeAndPayout(stake, spinUnder); | |
| require(balances[owner] >= (prize.sub(stake)), 'insufficient contract balance to cover the prize'); | |
| previousBalance = balances[msg.sender]; | |
| subtractAmountFromUser(stake); | |
| uint QUERY_EXECUTION_DELAY = 0; | |
| uint GAS_FOR_CALLBACK = 200000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function __callback( bytes32 _queryId, string memory _result, bytes memory _proof ) public { | |
| require(msg.sender == provable_cbAddress()); | |
| require(ongoingBets[_queryId].sender != address(0x0) , 'query does not exist'); | |
| if(provable_randomDS_proofVerify__returnCode( _queryId, _result, _proof) != 0){ | |
| revert(); | |
| } else { | |
| uint ceiling = (MAX_INT_FROM_BYTE ** NUM_RANDOM_BYTES_REQUESTED) - 1; | |
| uint randomNumber = uint(keccak256(abi.encodePacked(_result))) % ceiling; | |
| uint spin = (randomNumber % 100) + 1; | |
| Bet memory bet = ongoingBets[_queryId]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function memoize(func) { | |
| var memo = {}; | |
| var slice = Array.prototype.slice; | |
| return function () { | |
| var args = slice.call(arguments); | |
| if (args in memo) return memo[args]; | |
| else return (memo[args] = func.apply(this, args)); | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function deleteFbComments() { | |
| let postDeleted = 0; | |
| const CLICK_DELAY = 50; | |
| function randomIntFromInterval(min, max) { | |
| return Math.floor(Math.random() * (max - min + 1) + min); | |
| } | |
| function sleep(ms = 200) { | |
| return new Promise((resolve) => setTimeout(resolve, ms)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isPrime(num) { | |
| for (let i = 2, s = Math.sqrt(num); i <= s; i++) | |
| if (num % i === 0) return false; | |
| return num > 1; | |
| } | |
| function getMapOfPrimeNumbersUpTo(n) { | |
| const result = new Map(); | |
| for (let i = 0; i < n; i++) { | |
| if (isPrime(i)) result.set(i, true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // How to clone a javascript object without just referencing the prototype | |
| const assert = require('node:assert') | |
| const input = { a: 1 } | |
| // every prototype is an object with normal property descriptors | |
| const prototypeDescriptors = Object.getOwnPropertyDescriptors( | |
| Object.getPrototypeOf(input) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Method name | string | number | boolean | undefined | null | Symbol | BigInt | |
|---|---|---|---|---|---|---|---|---|
| cloneJSON | β | β | β | β | β | β | β | |
| structuredClone | β | β | β | β | β | β | β | |
| underscoreContribClone | β | β | β | β | β | β | β | |
| cloneNemisj | β | β | β | β | β | β | β | |
| cloneTrincot | β | β | β | β | β | β | β | |
| cloneKoolDandy | β | β | β | β | β | β | β | |
| cloneRfdc | β | β | β | β | β | β | β | |
| justClone | β | β | β | β | β | β | β | |
| cloneDeep | β | β | β | β | β | β | β |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Method name | shallow object | non shallow object | circular references | typeof | constructor | |
|---|---|---|---|---|---|---|
| cloneJSON | β | β | β | β | β | |
| structuredClone | β | β | β | β | β | |
| underscoreContribClone | β | β | β | β | β | |
| cloneNemisj | β | β | β | β | β | |
| cloneTrincot | β | β | β | β | β | |
| cloneKoolDandy | β | β | β | β | β | |
| cloneRfdc | β | β | β | β | β | |
| justClone | β | β | β | β | β | |
| cloneDeep | β | β | β | β | β |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Method name | getter | setter | enumerable | non enumerable | enumerable and writable | non enumerable non writable and configurable | non enumerable writable and non configurable | non enumerable non writable and non configurable | own symbol | |
|---|---|---|---|---|---|---|---|---|---|---|
| cloneJSON | β | β | β | β | β | β | β | β | β | |
| structuredClone | β | β | β | β | β | β | β | β | β | |
| underscoreContribClone | β | β | β | β | β | β | β | β | β | |
| cloneNemisj | β | β | β | β | β | β | β | β | β | |
| cloneTrincot | β | β | β | β | β | β | β | β | β | |
| cloneKoolDandy | β | β | β | β | β | β | β | β | β | |
| cloneRfdc | β | β | β | β | β | β | β | β | β | |
| justClone | β | β | β | β | β | β | β | β | β | |
| cloneDeep | β | β | β | β | β | β | β | β | β |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Method name | frozen | sealed | non extensible | |
|---|---|---|---|---|
| cloneJSON | β | β | β | |
| structuredClone | β | β | β | |
| underscoreContribClone | β | β | β | |
| cloneNemisj | β | β | β | |
| cloneTrincot | β | β | β | |
| cloneKoolDandy | β | β | β | |
| cloneRfdc | β | β | β | |
| justClone | β | β | β | |
| cloneDeep | β | β | β |