From 06658df9782fef5e2b187d508b2e2d2203659a92 Mon Sep 17 00:00:00 2001 From: Christoph Michel Date: Wed, 5 Sep 2018 12:11:34 +0200 Subject: [PATCH] :art: Improve frontend by fixing negative Timers, displaying how many rounds are left --- .development.public.env | 1 - contract/actions/transfer.js | 4 +- contract/contract/KingOfEOS.cpp | 9 ++ contract/contract/KingOfEOS.hpp | 167 ++++++++++---------- contract/contract/KingOfEOS.wasm | Bin 18750 -> 18886 bytes contract/contract/KingOfEOS.wast | 246 +++++++++++++++++------------- pages/index.js | 31 +++- src/components/CurrentKingdom.jsx | 50 +++++- src/components/Timer.jsx | 9 +- src/store/actions.js | 3 +- src/store/reducer.js | 2 +- src/store/selectors.js | 5 + src/utils/constants.js | 1 + 13 files changed, 322 insertions(+), 206 deletions(-) diff --git a/.development.public.env b/.development.public.env index 430c3c1..fd800db 100644 --- a/.development.public.env +++ b/.development.public.env @@ -1,5 +1,4 @@ EOS_NETWORK_PROTOCOL=http EOS_NETWORK_HOST=127.0.0.1 EOS_NETWORK_PORT=8888 -EOS_NETWORK_CHAINID=cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f EOS_CONTRACT_NAME=kingofeos \ No newline at end of file diff --git a/contract/actions/transfer.js b/contract/actions/transfer.js index 510d627..57981e3 100644 --- a/contract/actions/transfer.js +++ b/contract/actions/transfer.js @@ -7,8 +7,8 @@ async function action() { await eos.transfer({ from: `test2`, to: process.env.CONTRACT_ACCOUNT, - quantity: `1.3500 SYS`, - memo: `displayname;10ba038e-48da-487b-96e8-8d3b99b6d18a;${now}`, + quantity: `2.4603 EOS`, + memo: `displayname;;${now}`, }) console.log(`SUCCESS`) } catch (error) { diff --git a/contract/contract/KingOfEOS.cpp b/contract/contract/KingOfEOS.cpp index c8d4093..ebb440a 100644 --- a/contract/contract/KingOfEOS.cpp +++ b/contract/contract/KingOfEOS.cpp @@ -47,6 +47,11 @@ inline void splitMemo(std::vector &results, std::string memo) results.emplace_back(start, end); } +void assertNotGameOver(const kingofeos::claim_record& latestClaim) { + uint64_t lastKingdomOrder = indexToKingdomOrder(latestClaim.kingdomKingIndex); + eosio_assert(lastKingdomOrder < MAX_NUMBER_OF_KINGS, "King of EOS is over"); +} + void kingofeos::onTransfer(const currency::transfer &transfer) { if (transfer.to != _self) @@ -64,6 +69,8 @@ void kingofeos::onTransfer(const currency::transfer &transfer) uint64_t lastKingdomOrder = indexToKingdomOrder(latestClaimRecord.kingdomKingIndex); uint8_t lastKingOrder = indexToKingOrder(latestClaimRecord.kingdomKingIndex); + assertNotGameOver(latestClaimRecord); + uint64_t claimPrice = kingOrderToClaimPrice(lastKingOrder + 1); eosio_assert(transfer.quantity.amount == claimPrice, "wrong claim price "); @@ -104,6 +111,8 @@ void kingofeos::end() --itr; // itr now points to last element eosio_assert(itr != claims.end(), "no previous claim exists"); + assertNotGameOver(*itr); + time lastClaimTime = itr->claimTime; eosio_assert(now() > lastClaimTime + MAX_CORONATION_TIME, "max coronation time not reached yet"); diff --git a/contract/contract/KingOfEOS.hpp b/contract/contract/KingOfEOS.hpp index 768adae..b9c538e 100644 --- a/contract/contract/KingOfEOS.hpp +++ b/contract/contract/KingOfEOS.hpp @@ -1,83 +1,84 @@ -#include - -#include -#include - - -// the time after which a new round begins when no -// new king was crowned -// 1 week -#define MAX_CORONATION_TIME 60 * 60 * 24 * 7 -#define CLAIM_MULTIPLIER 1.35 -#define COMMISSION_PERCENTAGE_POINTS 0.05 - -class kingofeos : public eosio::contract -{ - public: - kingofeos(account_name self) - : contract(self), - claims(self, self) - { - } - - struct claim - { - claim(){}; - claim(account_name name) : name(name){}; - claim(account_name name, std::string displayName, std::string image) - : name(name), displayName(displayName), image(image){}; - - account_name name; - std::string displayName; - std::string image; - EOSLIB_SERIALIZE(claim, (name)(displayName)(image)) - }; - - //@abi table claims i64 - struct claim_record - { - claim_record(){}; - claim_record(uint64_t kingdomKingIndex, time claimTime, claim claim) - : kingdomKingIndex(kingdomKingIndex), claimTime(claimTime), claim(claim){}; - // upper 56 bits contain kingdom order, lower 8 bits contain kingOrder - uint64_t kingdomKingIndex; // this also acts as key of the table - time claimTime; - claim claim; - - uint64_t primary_key() const { return kingdomKingIndex; } - // need to serialize this, otherwise saving it in the data base does not work - // Runtime Error Processing WASM - EOSLIB_SERIALIZE(claim_record, (kingdomKingIndex)(claimTime)(claim)) - }; - - //@abi action init - struct init - { - init(){}; - // action must have a field as of now - account_name name; - EOSLIB_SERIALIZE(init, (name)) - }; - - //@abi action end - struct end - { - end(){}; - // action must have a field as of now - account_name name; - EOSLIB_SERIALIZE(end, (name)) - }; - - // the first argument of multi_index must be the name of the table - // in the ABI! - typedef eosio::multi_index claims_db; - - void onTransfer(const eosio::currency::transfer& transfer); - void end (); - void init(account_name name); - void apply( account_name contract, account_name act ); - - private: - claims_db claims; -}; - +#include + +#include +#include + + +// the time after which a new round begins when no +// new king was crowned +// 1 week +#define MAX_CORONATION_TIME 60 * 60 * 24 * 7 +#define MAX_NUMBER_OF_KINGS 10 +#define CLAIM_MULTIPLIER 1.35 +#define COMMISSION_PERCENTAGE_POINTS 0.05 + +class kingofeos : public eosio::contract +{ + public: + kingofeos(account_name self) + : contract(self), + claims(self, self) + { + } + + struct claim + { + claim(){}; + claim(account_name name) : name(name){}; + claim(account_name name, std::string displayName, std::string image) + : name(name), displayName(displayName), image(image){}; + + account_name name; + std::string displayName; + std::string image; + EOSLIB_SERIALIZE(claim, (name)(displayName)(image)) + }; + + //@abi table claims i64 + struct claim_record + { + claim_record(){}; + claim_record(uint64_t kingdomKingIndex, time claimTime, claim claim) + : kingdomKingIndex(kingdomKingIndex), claimTime(claimTime), claim(claim){}; + // upper 56 bits contain kingdom order, lower 8 bits contain kingOrder + uint64_t kingdomKingIndex; // this also acts as key of the table + time claimTime; + claim claim; + + uint64_t primary_key() const { return kingdomKingIndex; } + // need to serialize this, otherwise saving it in the data base does not work + // Runtime Error Processing WASM + EOSLIB_SERIALIZE(claim_record, (kingdomKingIndex)(claimTime)(claim)) + }; + + //@abi action init + struct init + { + init(){}; + // action must have a field as of now + account_name name; + EOSLIB_SERIALIZE(init, (name)) + }; + + //@abi action end + struct end + { + end(){}; + // action must have a field as of now + account_name name; + EOSLIB_SERIALIZE(end, (name)) + }; + + // the first argument of multi_index must be the name of the table + // in the ABI! + typedef eosio::multi_index claims_db; + + void onTransfer(const eosio::currency::transfer& transfer); + void end (); + void init(account_name name); + void apply( account_name contract, account_name act ); + + private: + claims_db claims; +}; + diff --git a/contract/contract/KingOfEOS.wasm b/contract/contract/KingOfEOS.wasm index 6587edb32576c44838674d84a3e18d04c1d3f960..74b7206471ec7e9fb73d0164df04b82c8e60441e 100644 GIT binary patch delta 2684 zcmaJ@eQaA-6~Fhr=Vv?DPF@l>A9g;j?R+@jpSIJasdJM$Nte;AYzQedR9@n&cI-H{ zy)-FEHB*6Z6cKtWt?O2iK~Xa(EW>}W!GK7W2303DY!&p6g2L24DuG7OMipsH7ax$%$u?dpeYd;g_(X?4luCt@ z=_85sNGKj2UkE3^ICfgb$`g(C6e$?#MnIUPhL{HoM*rnLC@#2%%t z@Z5B80eNhnlXgeuBI)1~YApGj*c+Okk1Yk4mQb@nAEFL59*V^hQ>as!NruD7E6*oR zp@T~5WHOBc%1r3#6dF)dQ=!fx7?w`fo z1W`mWquOAQ>>XSGC+DxoRfPpGZIIDm#`YA`G&8x!e=Q%dwQFYBTNV{7XJ7cuWy4Xn z#feg#UumbBNBS5uG{Tk@-lMRheh{&B9A!08Dnq07^Y1A3GnDMwJaqXb@%=kMwHEYC z%s}-seDY20pwmQggRD{0Atb(YHwJ$AhRb@CttoK4#*j~1!+;<8PWI_&gFt9X`K;tY?08*PRQPpo0#Ab95lCH4S; zDWR0Je0O)sEV;8N@ym;#m(h;|?VR3ueG1y(aiMA}@sk{o6OVArYkuCR_Tx>yq`I+> zUs0X7jQ>tOjmvqju><>g%xG5usSJwejl+0_zi(VD*^~gD2#Zr41c-xu&ODZpdB}84 zT9$d9`5Nf`!u)}`TOk$qI}d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|Rmdvr)-MNM3m@`a;zRsyKyrl{rRAxaMHuGzp zhiKKU2}9x(uky?9;AJd#$2`9ba(5!yVGt*ghw&W~*oTvbH0H#HP;Qnzo+4rmdx2I; zujmA1{-npLE-Gzb&%ZZRCDY;j$2_Ezowd5L|7gnUEMDe1^pD4| zx}F;E#s3?Z$3^5m!u1Lm6Va)Hq`8vmG(nd?`=t%H9nI|9v7Q! zNps*gOES}%%go^y1>q~QX3u5g>7^ryEN)lfm5F|Q<<}El3BLnAoAA0<6|M3_Hj_Te zX6EC`1-6(?&LkM>UV_fae$ho2C%cB%En0OVo6TfdHW8o2k0X}MC9?5cMp!LaG>Z`9 za>Jr2M-w?*ZCNz+L>9Ghjm7!<$sk<^=Tt3v6qtH!bn80N^t-eb=TBp(c~4A;y7BJl VAOE>`2;KPc=h~+3uzcla>_6lUVC4V+ diff --git a/contract/contract/KingOfEOS.wast b/contract/contract/KingOfEOS.wast index 0a89550..01d31e3 100644 --- a/contract/contract/KingOfEOS.wast +++ b/contract/contract/KingOfEOS.wast @@ -32,38 +32,40 @@ (table 3 3 anyfunc) (elem (i32.const 0) $__wasm_nullptr $_ZN9kingofeos4initEy $_ZN9kingofeos3endEv) (memory $0 1) - (data (i32.const 4) "\90d\00\00") - (data (i32.const 16) "deployed contract may not take part in claiming the throne\00") - (data (i32.const 80) "transfer memo needs two arguments separated by \';\'\00") - (data (i32.const 144) "kingdom arguments failed the size requirements\00") - (data (i32.const 192) "cannot create objects in table of another contract\00") - (data (i32.const 256) "magnitude of asset amount must be less than 2^62\00") - (data (i32.const 320) "invalid symbol name\00") - (data (i32.const 352) "active\00") - (data (i32.const 368) "eosio.token\00") - (data (i32.const 384) "transfer\00") - (data (i32.const 400) "You were dethroned! Here\'s your profit. - King of EOS\00") - (data (i32.const 464) "must pay with EOS token\00") - (data (i32.const 496) "no previous claim exists\00") - (data (i32.const 528) "wrong claim price \00") - (data (i32.const 560) "cannot decrement end iterator when the table is empty\00") - (data (i32.const 624) "cannot decrement iterator at beginning of table\00") - (data (i32.const 672) "error reading iterator\00") - (data (i32.const 704) "read\00") - (data (i32.const 720) "get\00") - (data (i32.const 736) "write\00") - (data (i32.const 752) "max coronation time not reached yet\00") - (data (i32.const 800) "already initialized\00") - (data (i32.const 9216) "malloc_from_freed was designed to only be called after _heap was completely allocated\00") - (data (i32.const 9312) "\00\00\00\00\00\00\f0?\00\00\00\00\00\00\f8?") - (data (i32.const 9328) "\00\00\00\00\00\00\00\00\06\d0\cfC\eb\fdL>") - (data (i32.const 9344) "\00\00\00\00\00\00\00\00\00\00\00@\03\b8\e2?") + (data (i32.const 4) "\b0d\00\00") + (data (i32.const 16) "King of EOS is over\00") + (data (i32.const 48) "deployed contract may not take part in claiming the throne\00") + (data (i32.const 112) "transfer memo needs two arguments separated by \';\'\00") + (data (i32.const 176) "kingdom arguments failed the size requirements\00") + (data (i32.const 224) "cannot create objects in table of another contract\00") + (data (i32.const 288) "magnitude of asset amount must be less than 2^62\00") + (data (i32.const 352) "invalid symbol name\00") + (data (i32.const 384) "active\00") + (data (i32.const 400) "eosio.token\00") + (data (i32.const 416) "transfer\00") + (data (i32.const 432) "You were dethroned! Here\'s your profit. - King of EOS\00") + (data (i32.const 496) "must pay with EOS token\00") + (data (i32.const 528) "no previous claim exists\00") + (data (i32.const 560) "wrong claim price \00") + (data (i32.const 592) "cannot decrement end iterator when the table is empty\00") + (data (i32.const 656) "cannot decrement iterator at beginning of table\00") + (data (i32.const 704) "error reading iterator\00") + (data (i32.const 736) "read\00") + (data (i32.const 752) "get\00") + (data (i32.const 768) "write\00") + (data (i32.const 784) "max coronation time not reached yet\00") + (data (i32.const 832) "already initialized\00") + (data (i32.const 9248) "malloc_from_freed was designed to only be called after _heap was completely allocated\00") + (data (i32.const 9344) "\00\00\00\00\00\00\f0?\00\00\00\00\00\00\f8?") + (data (i32.const 9360) "\00\00\00\00\00\00\00\00\06\d0\cfC\eb\fdL>") + (data (i32.const 9376) "\00\00\00\00\00\00\00\00\00\00\00@\03\b8\e2?") (export "memory" (memory $0)) (export "_ZeqRK11checksum256S1_" (func $_ZeqRK11checksum256S1_)) (export "_ZeqRK11checksum160S1_" (func $_ZeqRK11checksum160S1_)) (export "_ZneRK11checksum160S1_" (func $_ZneRK11checksum160S1_)) (export "now" (func $now)) (export "_ZN5eosio12require_authERKNS_16permission_levelE" (func $_ZN5eosio12require_authERKNS_16permission_levelE)) + (export "_Z17assertNotGameOverRKN9kingofeos12claim_recordE" (func $_Z17assertNotGameOverRKN9kingofeos12claim_recordE)) (export "_ZN9kingofeos10onTransferERKN5eosio8currency8transferE" (func $_ZN9kingofeos10onTransferERKN5eosio8currency8transferE)) (export "_ZN9kingofeos3endEv" (func $_ZN9kingofeos3endEv)) (export "_ZN9kingofeos4initEy" (func $_ZN9kingofeos4initEy)) @@ -123,6 +125,17 @@ ) ) ) + (func $_Z17assertNotGameOverRKN9kingofeos12claim_recordE (param $0 i32) + (call $eosio_assert + (i64.lt_u + (i64.load + (get_local $0) + ) + (i64.const 2560) + ) + (i32.const 16) + ) + ) (func $_ZN9kingofeos10onTransferERKN5eosio8currency8transferE (param $0 i32) (param $1 i32) (local $2 i32) (local $3 i32) @@ -171,7 +184,7 @@ ) (get_local $11) ) - (i32.const 16) + (i32.const 48) ) (call $eosio_assert (i64.eq @@ -183,7 +196,7 @@ ) (i64.const 1397703940) ) - (i32.const 464) + (i32.const 496) ) (i32.store offset=244 (get_local $16) @@ -213,7 +226,7 @@ ) (i32.const 0) ) - (i32.const 496) + (i32.const 528) ) (i32.store (i32.add @@ -291,14 +304,21 @@ (get_local $16) (get_local $11) ) + (call $eosio_assert + (i64.lt_u + (get_local $11) + (i64.const 2560) + ) + (i32.const 16) + ) (set_local $8 (call $pow (f64.const 1.35) (f64.convert_u/i32 (i32.and (i32.add - (i32.wrap/i64 - (get_local $11) + (i32.load8_u offset=183 + (get_local $16) ) (i32.const 1) ) @@ -321,7 +341,7 @@ ) ) ) - (i32.const 528) + (i32.const 560) ) (i32.store offset=176 (get_local $16) @@ -385,7 +405,7 @@ ) (i32.const 1) ) - (i32.const 80) + (i32.const 112) ) (block $label$3 (block $label$4 @@ -497,7 +517,7 @@ ) (call $eosio_assert (get_local $3) - (i32.const 144) + (i32.const 176) ) (set_local $11 (i64.load @@ -631,7 +651,7 @@ ) (call $current_receiver) ) - (i32.const 192) + (i32.const 224) ) (i32.store (get_local $16) @@ -862,7 +882,7 @@ ) (i64.const 9223372036854775807) ) - (i32.const 256) + (i32.const 288) ) (set_local $11 (i64.shr_u @@ -956,7 +976,7 @@ ) (call $eosio_assert (get_local $3) - (i32.const 320) + (i32.const 352) ) (set_local $6 (i64.load @@ -970,7 +990,7 @@ (i64.const 59) ) (set_local $1 - (i32.const 352) + (i32.const 384) ) (set_local $12 (i64.const 0) @@ -1104,7 +1124,7 @@ (i64.const 59) ) (set_local $1 - (i32.const 368) + (i32.const 400) ) (set_local $14 (i64.const 0) @@ -1238,7 +1258,7 @@ (i64.const 59) ) (set_local $1 - (i32.const 384) + (i32.const 416) ) (set_local $15 (i64.const 0) @@ -1413,7 +1433,7 @@ (i32.ge_u (tee_local $1 (call $strlen - (i32.const 400) + (i32.const 432) ) ) (i32.const -16) @@ -1490,7 +1510,7 @@ (drop (call $memcpy (get_local $0) - (i32.const 400) + (i32.const 432) (get_local $1) ) ) @@ -2929,7 +2949,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -2961,7 +2981,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -2996,7 +3016,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -3031,7 +3051,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -3263,7 +3283,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -3285,7 +3305,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -3364,7 +3384,7 @@ ) (i32.const 1) ) - (i32.const 624) + (i32.const 656) ) (br $label$0) ) @@ -3387,7 +3407,7 @@ ) (i32.const -1) ) - (i32.const 560) + (i32.const 592) ) (call $eosio_assert (i32.xor @@ -3405,7 +3425,7 @@ ) (i32.const 1) ) - (i32.const 560) + (i32.const 592) ) ) (i32.store @@ -4498,7 +4518,7 @@ ) (i32.const 1) ) - (i32.const 672) + (i32.const 704) ) (block $label$4 (block $label$5 @@ -4770,7 +4790,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -4802,7 +4822,7 @@ ) (i32.const 3) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -4837,7 +4857,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -5231,7 +5251,7 @@ (get_local $2) ) ) - (i32.const 720) + (i32.const 752) ) (set_local $4 (i32.load8_u @@ -5375,7 +5395,7 @@ ) ) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -5485,7 +5505,7 @@ ) (i32.const 0) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5559,7 +5579,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5591,7 +5611,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5725,7 +5745,7 @@ ) (i32.const 0) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5781,7 +5801,7 @@ ) ) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5911,7 +5931,7 @@ ) (i32.const 0) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -5987,7 +6007,7 @@ ) (get_local $5) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -6043,7 +6063,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -6075,7 +6095,7 @@ ) (i32.const 3) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -6110,7 +6130,7 @@ ) (i32.const 7) ) - (i32.const 736) + (i32.const 768) ) (drop (call $memcpy @@ -6193,7 +6213,18 @@ ) (i32.const 0) ) - (i32.const 496) + (i32.const 528) + ) + (call $eosio_assert + (i64.lt_u + (i64.load + (i32.load offset=20 + (get_local $6) + ) + ) + (i64.const 2560) + ) + (i32.const 16) ) (set_local $1 (i32.load offset=8 @@ -6212,10 +6243,10 @@ ) (i32.add (get_local $1) - (i32.const 604800) + (i32.const 7) ) ) - (i32.const 752) + (i32.const 784) ) (i64.store offset=8 (get_local $6) @@ -6255,7 +6286,7 @@ ) (call $current_receiver) ) - (i32.const 192) + (i32.const 224) ) (i32.store offset=32 (get_local $6) @@ -6883,7 +6914,7 @@ ) (call $eosio_assert (get_local $4) - (i32.const 800) + (i32.const 832) ) (set_local $5 (i64.load @@ -6905,7 +6936,7 @@ ) (call $current_receiver) ) - (i32.const 192) + (i32.const 224) ) (i32.store offset=16 (get_local $7) @@ -7485,7 +7516,7 @@ (i64.const 59) ) (set_local $4 - (i32.const 368) + (i32.const 400) ) (set_local $7 (i64.const 0) @@ -7627,7 +7658,7 @@ (i64.const 59) ) (set_local $4 - (i32.const 384) + (i32.const 416) ) (set_local $7 (i64.const 0) @@ -7941,7 +7972,7 @@ ) (call $eosio_assert (i32.const 1) - (i32.const 256) + (i32.const 288) ) (set_local $3 (i64.const 5462355) @@ -8032,7 +8063,7 @@ ) (call $eosio_assert (get_local $5) - (i32.const 320) + (i32.const 352) ) (i32.store (i32.add @@ -8066,6 +8097,17 @@ (get_local $0) ) ) + (block $label$7 + (br_if $label$7 + (i32.lt_u + (get_local $1) + (i32.const 513) + ) + ) + (call $free + (get_local $2) + ) + ) (i32.store offset=4 (i32.const 0) (i32.add @@ -8165,7 +8207,7 @@ (get_local $1) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -8363,7 +8405,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -8395,7 +8437,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -8430,7 +8472,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -8465,7 +8507,7 @@ ) (i32.const 7) ) - (i32.const 704) + (i32.const 736) ) (drop (call $memcpy @@ -8557,7 +8599,7 @@ ) (func $malloc (param $0 i32) (result i32) (call $_ZN5eosio14memory_manager6mallocEm - (i32.const 820) + (i32.const 852) (get_local $0) ) ) @@ -8802,7 +8844,7 @@ ) ) ) - (i32.const 9216) + (i32.const 9248) ) (set_local $13 (i32.add @@ -9026,13 +9068,13 @@ (block $label$1 (br_if $label$1 (i32.eqz - (i32.load8_u offset=9302 + (i32.load8_u offset=9334 (i32.const 0) ) ) ) (set_local $7 - (i32.load offset=9304 + (i32.load offset=9336 (i32.const 0) ) ) @@ -9041,11 +9083,11 @@ (set_local $7 (current_memory) ) - (i32.store8 offset=9302 + (i32.store8 offset=9334 (i32.const 0) (i32.const 1) ) - (i32.store offset=9304 + (i32.store offset=9336 (i32.const 0) (tee_local $7 (i32.shl @@ -9096,7 +9138,7 @@ ) ) (set_local $3 - (i32.load offset=9304 + (i32.load offset=9336 (i32.const 0) ) ) @@ -9104,7 +9146,7 @@ (set_local $8 (i32.const 0) ) - (i32.store offset=9304 + (i32.store offset=9336 (i32.const 0) (get_local $3) ) @@ -9158,18 +9200,18 @@ ) (block $label$6 (br_if $label$6 - (i32.load8_u offset=9302 + (i32.load8_u offset=9334 (i32.const 0) ) ) (set_local $3 (current_memory) ) - (i32.store8 offset=9302 + (i32.store8 offset=9334 (i32.const 0) (i32.const 1) ) - (i32.store offset=9304 + (i32.store offset=9336 (i32.const 0) (tee_local $3 (i32.shl @@ -9237,12 +9279,12 @@ ) ) (set_local $6 - (i32.load offset=9304 + (i32.load offset=9336 (i32.const 0) ) ) ) - (i32.store offset=9304 + (i32.store offset=9336 (i32.const 0) (i32.add (get_local $6) @@ -9502,7 +9544,7 @@ (br_if $label$1 (i32.lt_s (tee_local $2 - (i32.load offset=9204 + (i32.load offset=9236 (i32.const 0) ) ) @@ -9510,7 +9552,7 @@ ) ) (set_local $3 - (i32.const 9012) + (i32.const 9044) ) (set_local $1 (i32.add @@ -9518,7 +9560,7 @@ (get_local $2) (i32.const 12) ) - (i32.const 9012) + (i32.const 9044) ) ) (loop $label$2 @@ -9610,7 +9652,7 @@ (br_if $label$0 (i32.eqz (tee_local $2 - (i32.load offset=9308 + (i32.load offset=9340 (i32.const 0) ) ) @@ -11164,7 +11206,7 @@ (i32.const 3) ) ) - (i32.const 9344) + (i32.const 9376) ) ) ) @@ -11208,7 +11250,7 @@ (f64.load (i32.add (get_local $6) - (i32.const 9312) + (i32.const 9344) ) ) ) @@ -11387,7 +11429,7 @@ (f64.load (i32.add (get_local $6) - (i32.const 9328) + (i32.const 9360) ) ) (f64.add diff --git a/pages/index.js b/pages/index.js index 5f33793..6ba9b03 100644 --- a/pages/index.js +++ b/pages/index.js @@ -14,6 +14,7 @@ import { import { checkServer } from '../src/utils' import withRedux from '../src/utils/withRedux' import { initStore } from '../src/store' +import { selectRoundsLeft, selectInitialLoadDone } from '../src/store/selectors' import { fetchRows, scatterLoaded } from '../src/store/actions' import '../theme/dist/semantic.min.css' import '../theme/dist/themes/default/assets/fonts/icons.eot' @@ -31,6 +32,8 @@ class Index extends React.Component { hallOfFameKings: PropTypes.array.isRequired, // eslint-disable-next-line react/forbid-prop-types canvasKings: PropTypes.array.isRequired, + roundsLeft: PropTypes.number.isRequired, + initialLoadDone: PropTypes.bool.isRequired, } componentDidMount() { @@ -56,16 +59,30 @@ class Index extends React.Component { currentKingdomOrder, hallOfFameKings, canvasKings, + roundsLeft, + initialLoadDone, } = this.props return (

- -
+ {initialLoadDone ? ( + + +
+ + ) : null}
- -
+ {initialLoadDone ? ( + + +
+ + ) : null}
@@ -109,7 +126,11 @@ class Index extends React.Component { } } -const mapStateToProps = state => state +const mapStateToProps = state => ({ + ...state, + roundsLeft: selectRoundsLeft(state), + initialLoadDone: selectInitialLoadDone(state), +}) const mapDispatchToProps = dispatch => ({ fetchRowsAction: bindActionCreators(fetchRows, dispatch), diff --git a/src/components/CurrentKingdom.jsx b/src/components/CurrentKingdom.jsx index afeb5e9..857e340 100644 --- a/src/components/CurrentKingdom.jsx +++ b/src/components/CurrentKingdom.jsx @@ -1,3 +1,4 @@ +import React from 'react' import PropTypes from 'prop-types' import { Header, Table, Label } from 'semantic-ui-react' import ImageLazy from './ImageLazy' @@ -18,6 +19,7 @@ export default class CurrentKingdom extends React.PureComponent { }), ).isRequired, kingdomOrder: PropTypes.number.isRequired, + roundsLeft: PropTypes.number.isRequired, } renderKingRow = (king, index) => ( @@ -46,15 +48,33 @@ export default class CurrentKingdom extends React.PureComponent { ) - render() { - const { kings, kingdomOrder } = this.props + + renderBody() { + const { kings, roundsLeft } = this.props + const roundsLeftStyles = ( + + ) + if (roundsLeft <= 0) { + return ( + +

+ King of EOS has ended. Check the Hall of Fame for all kings! +

+ {roundsLeftStyles} +
+ ) + } + return ( -
-
- - King Of EOS - {`Kingdom #${kingdomOrder}`} -
+ +

{`Only ${roundsLeft} Kingdom${ + roundsLeft > 1 ? `s` : `` + } left.`}

0 ? kings[0].claimTime : new Date()} /> @@ -78,6 +98,20 @@ export default class CurrentKingdom extends React.PureComponent { {kings.map(this.renderKingRow)}
+ {roundsLeftStyles} +
+ ) + } + render() { + const { kingdomOrder } = this.props + return ( +
+
+ + King Of EOS + {`Kingdom #${kingdomOrder}`} +
+ {this.renderBody()}