From 12468bf51f8c757827c7f8451b4ae4e4801e6c84 Mon Sep 17 00:00:00 2001 From: themandalore Date: Mon, 31 May 2021 10:38:19 -0400 Subject: [PATCH 1/2] update --- ...(n).mul(ethers.BigNumber.from(10).pow(18)) | 236 +++++++++ contracts/Extension.sol | 1 - contracts/TellorTransfer.sol | 6 +- "onateAccount\"," | 472 ++++++++++++++++++ "t { expect } = require(\"chai\");" | 13 + t({ | 13 + 6 files changed, 739 insertions(+), 2 deletions(-) create mode 100644 .BigNumber.from(n).mul(ethers.BigNumber.from(10).pow(18)) create mode 100644 "onateAccount\"," create mode 100644 "t { expect } = require(\"chai\");" create mode 100644 t({ diff --git a/.BigNumber.from(n).mul(ethers.BigNumber.from(10).pow(18)) b/.BigNumber.from(n).mul(ethers.BigNumber.from(10).pow(18)) new file mode 100644 index 0000000..255dc7e --- /dev/null +++ b/.BigNumber.from(n).mul(ethers.BigNumber.from(10).pow(18)) @@ -0,0 +1,236 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ESC-u Undo (toggle) search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines + --------------------------------------------------- + A search pattern may be preceded by one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_> + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current position with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D [_x_n_._n] . --color=_x_n_._n + Set screen colors. (MS-DOS only) + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] + Use a lesskey file. + -K --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n -N .... --line-numbers --LINE-NUMBERS + Don't use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t [_t_a_g] .. --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Horizontal scroll amount (0 = one half screen width) + ........ --no-keypad + Don't send termcap keypad init/deinit strings. + ........ --follow-name + The F command changes files if the input file is renamed. + ........ --use-backslash + Subsequent options use backslash as escape char. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. + + diff --git a/contracts/Extension.sol b/contracts/Extension.sol index a1f6b89..02cdcbf 100644 --- a/contracts/Extension.sol +++ b/contracts/Extension.sol @@ -4,7 +4,6 @@ pragma solidity 0.7.4; import "./SafeMath.sol"; import "./TellorGetters.sol"; import "./TellorVariables.sol"; -import "hardhat/console.sol"; import "./Utilities.sol"; /** diff --git a/contracts/TellorTransfer.sol b/contracts/TellorTransfer.sol index f3acee8..7c3cd42 100755 --- a/contracts/TellorTransfer.sol +++ b/contracts/TellorTransfer.sol @@ -54,7 +54,7 @@ contract TellorTransfer is TellorStorage, TellorVariables { stakerDetails[_user].currentStatus < 5 ) { //Subtracts the stakeAmount from balance if the _user is staked - if (balanceOf(_user) - uints[_STAKE_AMOUNT] >= _amount) { + if (balanceOf(_user).sub(uints[_STAKE_AMOUNT]) >= _amount) { return true; } return false; @@ -217,6 +217,10 @@ contract TellorTransfer is TellorStorage, TellorVariables { */ function _doBurn(address _from, uint256 _amount) internal { if (_amount == 0) return; + require( + allowedToTrade(_from, _amount), + "Should have sufficient balance to trade" + ); uint128 previousBalance = uint128(balanceOf(_from)); uint128 _sizedAmount = uint128(_amount); require( diff --git "a/onateAccount\"," "b/onateAccount\"," new file mode 100644 index 0000000..b71f92d --- /dev/null +++ "b/onateAccount\"," @@ -0,0 +1,472 @@ + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ESC-u Undo (toggle) search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines + --------------------------------------------------- + A search pattern may be preceded by one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_> + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current position with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D [_x_n_._n] . --color=_x_n_._n + Set screen colors. (MS-DOS only) + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] + Use a lesskey file. + -K --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n -N .... --line-numbers --LINE-NUMBERS + Don't use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t [_t_a_g] .. --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Horizontal scroll amount (0 = one half screen width) + ........ --no-keypad + Don't send termcap keypad init/deinit strings. + ........ --follow-name + The F command changes files if the input file is renamed. + ........ --use-backslash + Subsequent options use backslash as escape char. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. + + + + SSUUMMMMAARRYY OOFF LLEESSSS CCOOMMMMAANNDDSS + + Commands marked with * may be preceded by a number, _N. + Notes in parentheses indicate the behavior if _N is given. + A key preceded by a caret indicates the Ctrl key; thus ^K is ctrl-K. + + h H Display this help. + q :q Q :Q ZZ Exit. + --------------------------------------------------------------------------- + + MMOOVVIINNGG + + e ^E j ^N CR * Forward one line (or _N lines). + y ^Y k ^K ^P * Backward one line (or _N lines). + f ^F ^V SPACE * Forward one window (or _N lines). + b ^B ESC-v * Backward one window (or _N lines). + z * Forward one window (and set window to _N). + w * Backward one window (and set window to _N). + ESC-SPACE * Forward one window, but don't stop at end-of-file. + d ^D * Forward one half-window (and set half-window to _N). + u ^U * Backward one half-window (and set half-window to _N). + ESC-) RightArrow * Right one half screen width (or _N positions). + ESC-( LeftArrow * Left one half screen width (or _N positions). + ESC-} ^RightArrow Right to last column displayed. + ESC-{ ^LeftArrow Left to first column. + F Forward forever; like "tail -f". + ESC-F Like F but stop when search pattern is found. + r ^R ^L Repaint screen. + R Repaint screen, discarding buffered input. + --------------------------------------------------- + Default "window" is the screen height. + Default "half-window" is half of the screen height. + --------------------------------------------------------------------------- + + SSEEAARRCCHHIINNGG + + /_p_a_t_t_e_r_n * Search forward for (_N-th) matching line. + ?_p_a_t_t_e_r_n * Search backward for (_N-th) matching line. + n * Repeat previous search (for _N-th occurrence). + N * Repeat previous search in reverse direction. + ESC-n * Repeat previous search, spanning files. + ESC-N * Repeat previous search, reverse dir. & spanning files. + ESC-u Undo (toggle) search highlighting. + &_p_a_t_t_e_r_n * Display only matching lines + --------------------------------------------------- + A search pattern may be preceded by one or more of: + ^N or ! Search for NON-matching lines. + ^E or * Search multiple files (pass thru END OF FILE). + ^F or @ Start search at FIRST file (for /) or last file (for ?). + ^K Highlight matches, but don't move (KEEP position). + ^R Don't use REGULAR EXPRESSIONS. + --------------------------------------------------------------------------- + + JJUUMMPPIINNGG + + g < ESC-< * Go to first line in file (or line _N). + G > ESC-> * Go to last line in file (or line _N). + p % * Go to beginning of file (or _N percent into file). + t * Go to the (_N-th) next tag. + T * Go to the (_N-th) previous tag. + { ( [ * Find close bracket } ) ]. + } ) ] * Find open bracket { ( [. + ESC-^F _<_c_1_> _<_c_2_> * Find close bracket _<_c_2_>. + ESC-^B _<_c_1_> _<_c_2_> * Find open bracket _<_c_1_> + --------------------------------------------------- + Each "find close bracket" command goes forward to the close bracket + matching the (_N-th) open bracket in the top line. + Each "find open bracket" command goes backward to the open bracket + matching the (_N-th) close bracket in the bottom line. + + m_<_l_e_t_t_e_r_> Mark the current position with . + '_<_l_e_t_t_e_r_> Go to a previously marked position. + '' Go to the previous position. + ^X^X Same as '. + --------------------------------------------------- + A mark is any upper-case or lower-case letter. + Certain marks are predefined: + ^ means beginning of the file + $ means end of the file + --------------------------------------------------------------------------- + + CCHHAANNGGIINNGG FFIILLEESS + + :e [_f_i_l_e] Examine a new file. + ^X^V Same as :e. + :n * Examine the (_N-th) next file from the command line. + :p * Examine the (_N-th) previous file from the command line. + :x * Examine the first (or _N-th) file from the command line. + :d Delete the current file from the command line list. + = ^G :f Print current file name. + --------------------------------------------------------------------------- + + MMIISSCCEELLLLAANNEEOOUUSS CCOOMMMMAANNDDSS + + -_<_f_l_a_g_> Toggle a command line option [see OPTIONS below]. + --_<_n_a_m_e_> Toggle a command line option, by name. + __<_f_l_a_g_> Display the setting of a command line option. + ___<_n_a_m_e_> Display the setting of an option, by name. + +_c_m_d Execute the less cmd each time a new file is examined. + + !_c_o_m_m_a_n_d Execute the shell command with $SHELL. + |XX_c_o_m_m_a_n_d Pipe file between current pos & mark XX to shell command. + s _f_i_l_e Save input to a file. + v Edit the current file with $VISUAL or $EDITOR. + V Print version number of "less". + --------------------------------------------------------------------------- + + OOPPTTIIOONNSS + + Most options may be changed either on the command line, + or from within less by using the - or -- command. + Options may be given in one of two forms: either a single + character preceded by a -, or a name preceded by --. + + -? ........ --help + Display help (from command line). + -a ........ --search-skip-screen + Search skips current screen. + -A ........ --SEARCH-SKIP-SCREEN + Search starts just after target line. + -b [_N] .... --buffers=[_N] + Number of buffers. + -B ........ --auto-buffers + Don't automatically allocate buffers for pipes. + -c ........ --clear-screen + Repaint by clearing rather than scrolling. + -d ........ --dumb + Dumb terminal. + -D [_x_n_._n] . --color=_x_n_._n + Set screen colors. (MS-DOS only) + -e -E .... --quit-at-eof --QUIT-AT-EOF + Quit at end of file. + -f ........ --force + Force open non-regular files. + -F ........ --quit-if-one-screen + Quit if entire file fits on first screen. + -g ........ --hilite-search + Highlight only last match for searches. + -G ........ --HILITE-SEARCH + Don't highlight any matches for searches. + -h [_N] .... --max-back-scroll=[_N] + Backward scroll limit. + -i ........ --ignore-case + Ignore case in searches that do not contain uppercase. + -I ........ --IGNORE-CASE + Ignore case in all searches. + -j [_N] .... --jump-target=[_N] + Screen position of target lines. + -J ........ --status-column + Display a status column at left edge of screen. + -k [_f_i_l_e] . --lesskey-file=[_f_i_l_e] + Use a lesskey file. + -K --quit-on-intr + Exit less in response to ctrl-C. + -L ........ --no-lessopen + Ignore the LESSOPEN environment variable. + -m -M .... --long-prompt --LONG-PROMPT + Set prompt style. + -n -N .... --line-numbers --LINE-NUMBERS + Don't use line numbers. + -o [_f_i_l_e] . --log-file=[_f_i_l_e] + Copy to log file (standard input only). + -O [_f_i_l_e] . --LOG-FILE=[_f_i_l_e] + Copy to log file (unconditionally overwrite). + -p [_p_a_t_t_e_r_n] --pattern=[_p_a_t_t_e_r_n] + Start at pattern (from command line). + -P [_p_r_o_m_p_t] --prompt=[_p_r_o_m_p_t] + Define new prompt. + -q -Q .... --quiet --QUIET --silent --SILENT + Quiet the terminal bell. + -r -R .... --raw-control-chars --RAW-CONTROL-CHARS + Output "raw" control characters. + -s ........ --squeeze-blank-lines + Squeeze multiple blank lines. + -S ........ --chop-long-lines + Chop (truncate) long lines rather than wrapping. + -t [_t_a_g] .. --tag=[_t_a_g] + Find a tag. + -T [_t_a_g_s_f_i_l_e] --tag-file=[_t_a_g_s_f_i_l_e] + Use an alternate tags file. + -u -U .... --underline-special --UNDERLINE-SPECIAL + Change handling of backspaces. + -V ........ --version + Display the version number of "less". + -w ........ --hilite-unread + Highlight first new line after forward-screen. + -W ........ --HILITE-UNREAD + Highlight first new line after any forward movement. + -x [_N[,...]] --tabs=[_N[,...]] + Set tab stops. + -X ........ --no-init + Don't use termcap init/deinit strings. + -y [_N] .... --max-forw-scroll=[_N] + Forward scroll limit. + -z [_N] .... --window=[_N] + Set size of window. + -" [_c[_c]] . --quotes=[_c[_c]] + Set shell quote characters. + -~ ........ --tilde + Don't display tildes after end of file. + -# [_N] .... --shift=[_N] + Horizontal scroll amount (0 = one half screen width) + ........ --no-keypad + Don't send termcap keypad init/deinit strings. + ........ --follow-name + The F command changes files if the input file is renamed. + ........ --use-backslash + Subsequent options use backslash as escape char. + + + --------------------------------------------------------------------------- + + LLIINNEE EEDDIITTIINNGG + + These keys can be used to edit text being entered + on the "command line" at the bottom of the screen. + + RightArrow ..................... ESC-l ... Move cursor right one character. + LeftArrow ...................... ESC-h ... Move cursor left one character. + ctrl-RightArrow ESC-RightArrow ESC-w ... Move cursor right one word. + ctrl-LeftArrow ESC-LeftArrow ESC-b ... Move cursor left one word. + HOME ........................... ESC-0 ... Move cursor to start of line. + END ............................ ESC-$ ... Move cursor to end of line. + BACKSPACE ................................ Delete char to left of cursor. + DELETE ......................... ESC-x ... Delete char under cursor. + ctrl-BACKSPACE ESC-BACKSPACE ........... Delete word to left of cursor. + ctrl-DELETE .... ESC-DELETE .... ESC-X ... Delete word under cursor. + ctrl-U ......... ESC (MS-DOS only) ....... Delete entire line. + UpArrow ........................ ESC-k ... Retrieve previous command line. + DownArrow ...................... ESC-j ... Retrieve next command line. + TAB ...................................... Complete filename & cycle. + SHIFT-TAB ...................... ESC-TAB Complete filename & reverse cycle. + ctrl-L ................................... Complete filename, list all. + + diff --git "a/t { expect } = require(\"chai\");" "b/t { expect } = require(\"chai\");" new file mode 100644 index 0000000..8c54363 --- /dev/null +++ "b/t { expect } = require(\"chai\");" @@ -0,0 +1,13 @@ + coreFixes + formattingChanges + getters +* master + migrator + nickAudit + nickAudit2 + nickTests + nickTests2 + nickTests3 + nickTests4 + nickUpgrade + upgrade diff --git a/t({ b/t({ new file mode 100644 index 0000000..8c54363 --- /dev/null +++ b/t({ @@ -0,0 +1,13 @@ + coreFixes + formattingChanges + getters +* master + migrator + nickAudit + nickAudit2 + nickTests + nickTests2 + nickTests3 + nickTests4 + nickUpgrade + upgrade From 2019dc0f922a8821421de580e108709a8de1b9ed Mon Sep 17 00:00:00 2001 From: themandalore Date: Mon, 7 Jun 2021 10:27:35 -0400 Subject: [PATCH 2/2] nick tests addition --- contracts/TellorStake.sol | 6 +- test/attack.js | 62 ++++++++++++++++++++ test/didMineTest.js | 0 test/difficulty.js | 0 test/disputes.js | 109 +++++++++++++++++++++++++++++++++++ test/e2eTests.js | 0 test/fullMiningTests.js | 0 test/furtherTests.js | 0 test/helpers/constants.js | 0 test/helpers/testLib.js | 0 test/helpers/test_helpers.js | 0 test/mainnetTests.js | 0 test/migrator.js | 0 test/moreDisputes.js | 0 test/moreForking.js | 0 test/request.js | 0 test/rewards.js | 0 test/stake.js | 0 test/testOracle.js | 0 test/token.js | 0 test/trbMigration.js | 0 test/utilitiesTest.js | 0 test/voting.js | 0 23 files changed, 176 insertions(+), 1 deletion(-) create mode 100755 test/attack.js mode change 100644 => 100755 test/didMineTest.js mode change 100644 => 100755 test/difficulty.js mode change 100644 => 100755 test/disputes.js mode change 100644 => 100755 test/e2eTests.js mode change 100644 => 100755 test/fullMiningTests.js mode change 100644 => 100755 test/furtherTests.js mode change 100644 => 100755 test/helpers/constants.js mode change 100644 => 100755 test/helpers/testLib.js mode change 100644 => 100755 test/helpers/test_helpers.js mode change 100644 => 100755 test/mainnetTests.js mode change 100644 => 100755 test/migrator.js mode change 100644 => 100755 test/moreDisputes.js mode change 100644 => 100755 test/moreForking.js mode change 100644 => 100755 test/request.js mode change 100644 => 100755 test/rewards.js mode change 100644 => 100755 test/stake.js mode change 100644 => 100755 test/testOracle.js mode change 100644 => 100755 test/token.js mode change 100644 => 100755 test/trbMigration.js mode change 100644 => 100755 test/utilitiesTest.js mode change 100644 => 100755 test/voting.js diff --git a/contracts/TellorStake.sol b/contracts/TellorStake.sol index 308909d..5499fcd 100755 --- a/contracts/TellorStake.sol +++ b/contracts/TellorStake.sol @@ -55,6 +55,7 @@ contract TellorStake is TellorTransfer { //_miner is the miner being disputed. For every mined value 5 miners are saved in an array and the _minerIndex //provided by the party initiating the dispute address _miner = _request.minersByValue[_timestamp][_minerIndex]; + uints[keccak256(abi.encodePacked(_miner,"DisputeCount"))]++; bytes32 _hash = keccak256(abi.encodePacked(_miner, _requestId, _timestamp)); //Increase the dispute count by 1 @@ -219,7 +220,9 @@ contract TellorStake is TellorTransfer { ); } } else { - stakes.currentStatus = 1; + if(uints[keccak256(abi.encodePacked(last.reportedMiner,"DisputeCount"))] == 1){ + stakes.currentStatus = 1; + } TellorStorage.Request storage _request = requestDetails[disp.disputeUintVars[_REQUEST_ID]]; if (disp.disputeUintVars[_MINER_SLOT] == 2) { @@ -244,6 +247,7 @@ contract TellorStake is TellorTransfer { ); } } + uints[keccak256(abi.encodePacked(last.reportedMiner,"DisputeCount"))]--; if (disp.disputeUintVars[_MINER_SLOT] == 2) { requestDetails[disp.disputeUintVars[_REQUEST_ID]].apiUintVars[ _DISPUTE_COUNT diff --git a/test/attack.js b/test/attack.js new file mode 100755 index 0000000..0ed082f --- /dev/null +++ b/test/attack.js @@ -0,0 +1,62 @@ +// const { AbiCoder } = require("@ethersproject/abi"); +// const { expect } = require("chai"); +// const { ethers } = require("hardhat"); + +// function expandTo18Decimals(n) { +// return ethers.BigNumber.from(n).mul(ethers.BigNumber.from(10).pow(18)) +// } + +// describe("Tellor", function() { + +// const tellorMaster = "0x88dF592F8eb5D7Bd38bFeF7dEb0fBc02cf3778a0" +// const DEV_WALLET = "0x39E419bA25196794B595B2a595Ea8E527ddC9856" + +// it("should mint Tellor", async function() { + +// const accounts = await ethers.getSigners(); +// const attacker = accounts[1]; +// const user2 = accounts[2]; + +// // Take over an account just to give 500 tokens to the attacker +// await hre.network.provider.request({ +// method: "hardhat_impersonateAccount", +// params: [DEV_WALLET]} +// ) +// oldTellorInstance = await ethers.getContractAt("contracts/ITellor.sol:ITellor", tellorMaster) +// getters = await ethers.getContractAt("contracts/TellorGetters.sol:TellorGetters", tellorMaster) +// let fact = await ethers.getContractFactory("contracts/Mocks/TellorTest.sol:TellorTest"); +// let ext = await ethers.getContractFactory("contracts/Extension.sol:Extension"); +// newExt = await ext.deploy(); +// await newExt.deployed(); +// newTellor = await fact.deploy(newExt.address); +// await newTellor.deployed(); +// await hre.network.provider.request({ +// method: "hardhat_impersonateAccount", +// params: [DEV_WALLET] +// }) +// await accounts[0].sendTransaction({to:DEV_WALLET,value:ethers.utils.parseEther("1.0")}); +// const devWallet = await ethers.provider.getSigner(DEV_WALLET); +// master = await oldTellorInstance.connect(devWallet) +// await master.changeTellorContract(newTellor.address); + +// const tellor = await ethers.getContractAt("ITellor",tellorMaster, devWallet); +// await tellor.deployed(); +// // Make sure that impersonated address has some tokens +// expect(await tellor.balanceOf(await devWallet.getAddress())).not.equal(expandTo18Decimals(0)); +// // Check iniitial zero balance +// expect(await tellor.balanceOf(attacker.address)).equal("0"); +// // Transfer 501 tokens to the attacker +// await tellor.transfer(attacker.address, expandTo18Decimals(501), {from: devWallet.address}); +// expect(await tellor.balanceOf(attacker.address)).equal(expandTo18Decimals(501)); +// // Become a staker (changes currentStatus to 1) +// const userTellor = tellor.connect(attacker); +// await userTellor.depositStake(); +// // Tip any requestId with 2 tokens to make the balance lower than 500 +// expect(userTellor.addTip(1,expandTo18Decimals(2))).to.be.reverted; +// expect(await tellor.balanceOf(attacker.address)).equal(expandTo18Decimals(501)); +// // Transfer more than 500 tokens to underflow the balance +// expect(await tellor.balanceOf(user2.address)).equal("0"); +// expect(userTellor.transfer (user2.address, expandTo18Decimals(1000))).to.be.reverted; +// expect(await tellor.balanceOf(user2.address)).equal(expandTo18Decimals(0)); +// }); +// }); \ No newline at end of file diff --git a/test/didMineTest.js b/test/didMineTest.js old mode 100644 new mode 100755 diff --git a/test/difficulty.js b/test/difficulty.js old mode 100644 new mode 100755 diff --git a/test/disputes.js b/test/disputes.js old mode 100644 new mode 100755 index 14a3d62..3577ae4 --- a/test/disputes.js +++ b/test/disputes.js @@ -325,4 +325,113 @@ contract("Dispute Tests", function(accounts) { "disputing party's balance should change correctly" ); }); + + + it("Test multiple dispute to the same miner different ID's", async function() { + let times = []; + let blocks = []; + const reportingMiner = accounts[5]; + const reportingMiner2 = accounts[6] + const reportedMiner = accounts[1]; + const reportedIndex = 1; + const requestId = 1; + for (j = 0; j < 4; j++) { + await master.addTip(1, 1000); + await master.addTip(2, 1000); + await takeFifteen(); + await TestLib.mineBlock(env); + await takeFifteen(); + let block = await TestLib.mineBlock(env); + let count = await master.getNewValueCountbyRequestId(requestId); + let timestamp = await master.getTimestampbyRequestIDandIndex( + requestId, + count.toNumber() - 1 + ); + blocks.push(block); + times.push(timestamp); + } + let balance1 = await master.balanceOf(reportingMiner); + let balance21 = await master.balanceOf(reportingMiner2); + let dispBal1 = await master.balanceOf(reportedMiner); + let orig_dispBal4 = await master.balanceOf(accounts[4]); + await master.beginDispute(requestId, times[0], reportedIndex, { + from: reportingMiner, + }); + await master.beginDispute(2, times[1], reportedIndex, { + from: reportingMiner2, + }); + let hashID = await master.getDisputeIdByDisputeHash(web3.utils.soliditySha3(reportedMiner,requestId,times[0])) + assert(hashID == 1, "hash ID should be correct") + //dispute votes and tally + await master.vote(1, false, { from: accounts[3] }); + await master.vote(2, true, { from: accounts[3] }); + await helper.advanceTime(86400 * 22); + await master.tallyVotes(1); + s = await master.getStakerInfo(accounts[1]); + assert(s != 1, " Not staked"); + let balance2 = await master.balanceOf(reportingMiner); + let balance22 = await master.balanceOf(reportingMiner2); + let dispBal2 = await master.balanceOf(reportedMiner); + assert( + balance1.sub(balance2).eq(dispInfo[7][8]), + "reporting miner's balance should change correctly1" + ); + assert( + dispBal1.eq(dispBal2), + "reported party's balance should change correctly" + ); + assert( + balance21.sub(balance22).eq(dispInfo[7][8]), + "reporting miner's balance should change correctly" + ); + await master.tallyVotes(2); + await helper.advanceTime(86400 * 2); + await master.unlockDisputeFee(1, { from: accounts[0] }); + balance2 = await master.balanceOf(reportingMiner); + balance22 = await master.balanceOf(reportingMiner2); + dispBal2 = await master.balanceOf(reportedMiner); + assert( + balance1.sub(balance2).eq(dispInfo[7][8]), + "reporting miner's balance should change correctly" + ); + assert( + dispBal2.sub(dispBal1).eq(dispInfo[7][8]), + "reported party's balance should change correctly" + ); + assert( + balance21.sub(balance22).eq(dispInfo[7][8]), + "reporting miner's balance should change correctly" + ); + s = await master.getStakerInfo(accounts[1]); + assert(s != 1, " Not staked"); + await master.unlockDisputeFee(2, { from: accounts[0] }); + dispInfo = await master.getAllDisputeVars(1); + assert(dispInfo[7][0] == requestId); + assert(dispInfo[7][2] == blocks[0].values[reportedIndex][0]); + assert(dispInfo[2] == false, "Dispute Vote passed"); + //checks balances after dispute 1 + balance2 = await master.balanceOf(reportingMiner); + balance22 = await master.balanceOf(reportingMiner2); + dispBal2 = await master.balanceOf(reportedMiner); + assert( + balance1.sub(balance2).eq(dispInfo[7][8]), + "reporting miner's balance should change correctly" + ); + console.log(dispBal1.add(dispInfo[7][8]).sub(dispBal2)*1 - (web3.utils.toWei("500", "ether"))*1) + assert( + (dispBal1.add(dispInfo[7][8]).sub(dispBal2))*1 - (web3.utils.toWei("500", "ether")*1) == 0, + "reported party's balance should change correctly" + ); + assert( + balance21* 1 + 1*(web3.utils.toWei("500", "ether")) == 1*balance22, + "reporting miner's balance should change correctly" + ); + s = await master.getStakerInfo(accounts[1]); + assert(s != 1, " Not staked"); + let dispBal4 = await master.balanceOf(accounts[4]); + assert(dispBal4 - orig_dispBal4 == 0, "a4 shouldn't change'"); + }); + + + }); diff --git a/test/e2eTests.js b/test/e2eTests.js old mode 100644 new mode 100755 diff --git a/test/fullMiningTests.js b/test/fullMiningTests.js old mode 100644 new mode 100755 diff --git a/test/furtherTests.js b/test/furtherTests.js old mode 100644 new mode 100755 diff --git a/test/helpers/constants.js b/test/helpers/constants.js old mode 100644 new mode 100755 diff --git a/test/helpers/testLib.js b/test/helpers/testLib.js old mode 100644 new mode 100755 diff --git a/test/helpers/test_helpers.js b/test/helpers/test_helpers.js old mode 100644 new mode 100755 diff --git a/test/mainnetTests.js b/test/mainnetTests.js old mode 100644 new mode 100755 diff --git a/test/migrator.js b/test/migrator.js old mode 100644 new mode 100755 diff --git a/test/moreDisputes.js b/test/moreDisputes.js old mode 100644 new mode 100755 diff --git a/test/moreForking.js b/test/moreForking.js old mode 100644 new mode 100755 diff --git a/test/request.js b/test/request.js old mode 100644 new mode 100755 diff --git a/test/rewards.js b/test/rewards.js old mode 100644 new mode 100755 diff --git a/test/stake.js b/test/stake.js old mode 100644 new mode 100755 diff --git a/test/testOracle.js b/test/testOracle.js old mode 100644 new mode 100755 diff --git a/test/token.js b/test/token.js old mode 100644 new mode 100755 diff --git a/test/trbMigration.js b/test/trbMigration.js old mode 100644 new mode 100755 diff --git a/test/utilitiesTest.js b/test/utilitiesTest.js old mode 100644 new mode 100755 diff --git a/test/voting.js b/test/voting.js old mode 100644 new mode 100755