Closed dabana closed 6 years ago
an opcode error?
I get:
Warning: Cannot update during an existing state transition (such as within render
or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount
.
Oui ça c'est un warning parce qu'on change le state du React component dans le render(). Ça cause pas de problème, mais après il est supposé y avoir une autre erreur VM invalid op code
Uncaught (in promise) Error: Returned error: VM Exception while processing transaction: invalid opcode
Je pense que je sais c'est quoi le problème. C'Est que le remet pas les boolean de mon mapping a false dans ClaimBet().
Mais ça regle pas les calls multiples à SendWinner() mais c'est peut-être pas grave
Ah ah! c'est le require qui envoie l'erreur. Bien sur!
If you look up either of those opcodes in the yellow paper, you won’t find them. This is why you see the invalid opcode error, because there’s no specification for how a client should handle them.
Okai je n'ai plus l'erreur quand je commente la ligne require(isPlayer[msg.sender]); ET la ligne delete playerAddresses; dans le contract.
Mais tout ça viens du call multiple a SendWinner() je crois
An event is created in the contract to log to the blockchain: 1) Winner address 2) Loser address 3) a game index 4) the bet ammount
An array containing the players address, playerAddresses, has been created for this purpose. But the React app seams to be calling its SendWinner() multiple times in a row. This creates an opcode error in the VM because the extra calls to the contract function ClaimBet() cause an indexing of an empty array (playerAddresses is empty when the game is finished and the bet is claimed by the winner).
It is a React related issues I have problems solving.