diff --git a/Celestial/CelestialArchitecture.png b/Celestial/CelestialArchitecture.png new file mode 100644 index 00000000..91e6525a Binary files /dev/null and b/Celestial/CelestialArchitecture.png differ diff --git a/Celestial/Compiler/.gitignore b/Celestial/Compiler/.gitignore new file mode 100644 index 00000000..209d8f6a --- /dev/null +++ b/Celestial/Compiler/.gitignore @@ -0,0 +1,5 @@ +.vscode/* + +.antlr/* + +__pycache__/* \ No newline at end of file diff --git a/Celestial/Compiler/CelestialLexer.g4 b/Celestial/Compiler/CelestialLexer.g4 new file mode 100644 index 00000000..bfba6f14 --- /dev/null +++ b/Celestial/Compiler/CelestialLexer.g4 @@ -0,0 +1,168 @@ +lexer grammar CelestialLexer; + +options {language=Python3;} + +// Type names + +ADDR : 'address' ; +BOOL : 'bool' ; +ENUM : 'enum' ; +EVENT : 'event' ; +EVENTLOG : 'eventlog' ; +UINT : 'uint' ; +UINT8 : 'uint8' ; +INSTMAP : 'inst_map' ; +INT : 'int' ; +STRING : 'string' ; +CONTRACT : 'contract' ; +MAP : 'mapping' ; +BYTES : 'bytes' ; +BYTES20 : 'bytes20' ; +BYTES32 : 'bytes32' ; + +// Keywords + +ADD : 'add' ; +AS : 'as' ; +ASSERT : 'assert' ; +BALANCE : 'balance' ; +BCOINBASE : 'block.coinbase' ; +BDIFF : 'block.difficulty' ; +BGASLIMIT : 'block.gaslimit' ; +BNUMBER : 'block.number' ; +BTIMESTAMP: 'block.timestamp' ; +CALL : 'call' ; +CALLBOOL : 'call_bool' ; +CALLUINT : 'call_uint' ; +CONSTANT : 'constant' ; +CONSTR : 'constructor' ; +CONTAINS : 'contains' ; +CREDIT : 'credit' ; +DEBIT : 'debit' ; +DEFAULT : 'default' ; +DELETE : 'delete' ; +ELSE : 'else' ; +EMIT : 'emit' ; +ETRANSFER : 'eTransfer' ; +EXISTS : 'exists' ; +FALLBACK : 'fallback' ; +FOR : 'for' ; +FORALL : 'forall'; +FROM : 'from' ; +FUNCTION : 'function' ; +IF : 'if' ; +IMPORT : 'import' ; +IN : 'in' ; +INT_MIN : 'int_min' ; +INT_MAX : 'int_max' ; +ITE : 'ite' ; +INVARIANT : 'invariant' ; +KEYS : 'keys' ; +LEMMA : 'lemma' ; +LENGTH : 'length' ; +LOG : 'log' ; +MODIFIES : 'modifies' ; +MODIFIESA : 'modifies_addresses' ; +NEW : 'new' ; +PAYABLE : 'payable' ; +POP : 'pop' ; +POST : 'post' ; +PRAGMA : 'pragma' ; +PRE : 'pre' ; +PRINT : 'print' ; +PRIVATE : 'private' ; +PUBLIC : 'public' ; +PURE : 'pure' ; +PUSH : 'push' ; +RECEIVE : 'receive'; +RETURN : 'return' ; +RETURNS : 'returns' ; +REVERT : 'revert' ; +RREVERTS : 'r_reverts' ; +SAFEADD : 'safe_add' ; +SAFEDIV : 'safe_div' ; +SAFEMOD : 'safe_mod' ; +SAFEMUL : 'safe_mul' ; +SAFESUB : 'safe_sub' ; +SEND : 'send' ; +SENDER : 'sender' ; +SPEC : 'spec' ; +STRUCT : 'struct' ; +// SUMEQ : 'sumEquals' ; +THIS : 'this' ; +TRANSFER : 'transfer' ; +TXREVERTS : 'tx_reverts' ; +TXGASPRICE: 'tx.gasprice' ; +TXORIGIN : 'tx.origin' ; +UINT_MAX : 'uint_max' ; +USING : 'using' ; +VALUE : 'value' ; +VIEW : 'view' ; + +// Literals + +BoolLiteral : 'true' | 'false' ; + +IntLiteral : [0-9]+ ; + +NullLiteral : 'null'; + +StringLiteral : '"' StringCharacters? '"' ; +fragment StringCharacters : StringCharacter+ ; +fragment StringCharacter : ~["\\] | EscapeSequence ; +fragment EscapeSequence : '\\' . ; + +VersionLiteral : [0-9]+ '.' [0-9]+ ('.' [0-9]+)? ; + +// Symbols + +LNOT : '!' ; +LAND : '&&' ; +LOR : '||' ; +MAPUPD : '=>' ; +IMPL : '==>' ; +BIMPL : '<==>' ; + +EQ : '==' ; +NE : '!=' ; +LE : '<=' ; +GE : '>=' ; +LT : '<' ; +GT : '>' ; +RARROW : '->' ; + +ASSIGN : '=' ; +INSERT : '+=' ; +REMOVE : '-=' ; + +PLUS : '+' ; +SUB : '-' ; +MUL : '*' ; +DIV : '/' ; +MOD : '%' ; + +CARET : '^' ; +BNOT : '~' ; + +LBRACE : '{' ; +RBRACE : '}' ; +LBRACK : '[' ; +RBRACK : ']' ; +LPAREN : '(' ; +RPAREN : ')' ; +SEMI : ';' ; +COMMA : ',' ; +DOT : '.' ; +COLON : ':' ; + +// Identifiers + +Iden : PLetter PLetterOrDigit* ; +fragment PLetter : [a-zA-Z_] ; +fragment PLetterOrDigit : [a-zA-Z0-9_] ; + +// Non-code regions + +Whitespace : [ \t\r\n\f]+ -> skip ; +BlockComment : '/*' .*? '*/' -> channel(HIDDEN) ; +LineComment : '//' ~[\r\n]* -> channel(HIDDEN) ; diff --git a/Celestial/Compiler/CelestialLexer.interp b/Celestial/Compiler/CelestialLexer.interp new file mode 100644 index 00000000..6584f6aa --- /dev/null +++ b/Celestial/Compiler/CelestialLexer.interp @@ -0,0 +1,418 @@ +token literal names: +null +'address' +'bool' +'enum' +'event' +'eventlog' +'uint' +'uint8' +'inst_map' +'int' +'string' +'contract' +'mapping' +'bytes' +'bytes20' +'bytes32' +'add' +'as' +'assert' +'balance' +'block.coinbase' +'block.difficulty' +'block.gaslimit' +'block.number' +'block.timestamp' +'call' +'call_bool' +'call_uint' +'constant' +'constructor' +'contains' +'credit' +'debit' +'default' +'delete' +'else' +'emit' +'eTransfer' +'exists' +'fallback' +'for' +'forall' +'from' +'function' +'if' +'import' +'in' +'int_min' +'int_max' +'ite' +'invariant' +'keys' +'lemma' +'length' +'log' +'modifies' +'modifies_addresses' +'new' +'payable' +'pop' +'post' +'pragma' +'pre' +'print' +'private' +'public' +'pure' +'push' +'receive' +'return' +'returns' +'revert' +'r_reverts' +'safe_add' +'safe_div' +'safe_mod' +'safe_mul' +'safe_sub' +'send' +'sender' +'spec' +'struct' +'this' +'transfer' +'tx_reverts' +'tx.gasprice' +'tx.origin' +'uint_max' +'using' +'value' +'view' +null +null +'null' +null +null +'!' +'&&' +'||' +'=>' +'==>' +'<==>' +'==' +'!=' +'<=' +'>=' +'<' +'>' +'->' +'=' +'+=' +'-=' +'+' +'-' +'*' +'/' +'%' +'^' +'~' +'{' +'}' +'[' +']' +'(' +')' +';' +',' +'.' +':' +null +null +null +null + +token symbolic names: +null +ADDR +BOOL +ENUM +EVENT +EVENTLOG +UINT +UINT8 +INSTMAP +INT +STRING +CONTRACT +MAP +BYTES +BYTES20 +BYTES32 +ADD +AS +ASSERT +BALANCE +BCOINBASE +BDIFF +BGASLIMIT +BNUMBER +BTIMESTAMP +CALL +CALLBOOL +CALLUINT +CONSTANT +CONSTR +CONTAINS +CREDIT +DEBIT +DEFAULT +DELETE +ELSE +EMIT +ETRANSFER +EXISTS +FALLBACK +FOR +FORALL +FROM +FUNCTION +IF +IMPORT +IN +INT_MIN +INT_MAX +ITE +INVARIANT +KEYS +LEMMA +LENGTH +LOG +MODIFIES +MODIFIESA +NEW +PAYABLE +POP +POST +PRAGMA +PRE +PRINT +PRIVATE +PUBLIC +PURE +PUSH +RECEIVE +RETURN +RETURNS +REVERT +RREVERTS +SAFEADD +SAFEDIV +SAFEMOD +SAFEMUL +SAFESUB +SEND +SENDER +SPEC +STRUCT +THIS +TRANSFER +TXREVERTS +TXGASPRICE +TXORIGIN +UINT_MAX +USING +VALUE +VIEW +BoolLiteral +IntLiteral +NullLiteral +StringLiteral +VersionLiteral +LNOT +LAND +LOR +MAPUPD +IMPL +BIMPL +EQ +NE +LE +GE +LT +GT +RARROW +ASSIGN +INSERT +REMOVE +PLUS +SUB +MUL +DIV +MOD +CARET +BNOT +LBRACE +RBRACE +LBRACK +RBRACK +LPAREN +RPAREN +SEMI +COMMA +DOT +COLON +Iden +Whitespace +BlockComment +LineComment + +rule names: +ADDR +BOOL +ENUM +EVENT +EVENTLOG +UINT +UINT8 +INSTMAP +INT +STRING +CONTRACT +MAP +BYTES +BYTES20 +BYTES32 +ADD +AS +ASSERT +BALANCE +BCOINBASE +BDIFF +BGASLIMIT +BNUMBER +BTIMESTAMP +CALL +CALLBOOL +CALLUINT +CONSTANT +CONSTR +CONTAINS +CREDIT +DEBIT +DEFAULT +DELETE +ELSE +EMIT +ETRANSFER +EXISTS +FALLBACK +FOR +FORALL +FROM +FUNCTION +IF +IMPORT +IN +INT_MIN +INT_MAX +ITE +INVARIANT +KEYS +LEMMA +LENGTH +LOG +MODIFIES +MODIFIESA +NEW +PAYABLE +POP +POST +PRAGMA +PRE +PRINT +PRIVATE +PUBLIC +PURE +PUSH +RECEIVE +RETURN +RETURNS +REVERT +RREVERTS +SAFEADD +SAFEDIV +SAFEMOD +SAFEMUL +SAFESUB +SEND +SENDER +SPEC +STRUCT +THIS +TRANSFER +TXREVERTS +TXGASPRICE +TXORIGIN +UINT_MAX +USING +VALUE +VIEW +BoolLiteral +IntLiteral +NullLiteral +StringLiteral +StringCharacters +StringCharacter +EscapeSequence +VersionLiteral +LNOT +LAND +LOR +MAPUPD +IMPL +BIMPL +EQ +NE +LE +GE +LT +GT +RARROW +ASSIGN +INSERT +REMOVE +PLUS +SUB +MUL +DIV +MOD +CARET +BNOT +LBRACE +RBRACE +LBRACK +RBRACK +LPAREN +RPAREN +SEMI +COMMA +DOT +COLON +Iden +PLetter +PLetterOrDigit +Whitespace +BlockComment +LineComment + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 134, 1142, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 4, 81, 9, 81, 4, 82, 9, 82, 4, 83, 9, 83, 4, 84, 9, 84, 4, 85, 9, 85, 4, 86, 9, 86, 4, 87, 9, 87, 4, 88, 9, 88, 4, 89, 9, 89, 4, 90, 9, 90, 4, 91, 9, 91, 4, 92, 9, 92, 4, 93, 9, 93, 4, 94, 9, 94, 4, 95, 9, 95, 4, 96, 9, 96, 4, 97, 9, 97, 4, 98, 9, 98, 4, 99, 9, 99, 4, 100, 9, 100, 4, 101, 9, 101, 4, 102, 9, 102, 4, 103, 9, 103, 4, 104, 9, 104, 4, 105, 9, 105, 4, 106, 9, 106, 4, 107, 9, 107, 4, 108, 9, 108, 4, 109, 9, 109, 4, 110, 9, 110, 4, 111, 9, 111, 4, 112, 9, 112, 4, 113, 9, 113, 4, 114, 9, 114, 4, 115, 9, 115, 4, 116, 9, 116, 4, 117, 9, 117, 4, 118, 9, 118, 4, 119, 9, 119, 4, 120, 9, 120, 4, 121, 9, 121, 4, 122, 9, 122, 4, 123, 9, 123, 4, 124, 9, 124, 4, 125, 9, 125, 4, 126, 9, 126, 4, 127, 9, 127, 4, 128, 9, 128, 4, 129, 9, 129, 4, 130, 9, 130, 4, 131, 9, 131, 4, 132, 9, 132, 4, 133, 9, 133, 4, 134, 9, 134, 4, 135, 9, 135, 4, 136, 9, 136, 4, 137, 9, 137, 4, 138, 9, 138, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 64, 3, 64, 3, 64, 3, 64, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 65, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 3, 66, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 3, 68, 3, 68, 3, 68, 3, 68, 3, 68, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 3, 71, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 3, 72, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 73, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 74, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 75, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 76, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 77, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 78, 3, 79, 3, 79, 3, 79, 3, 79, 3, 79, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 80, 3, 81, 3, 81, 3, 81, 3, 81, 3, 81, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 82, 3, 83, 3, 83, 3, 83, 3, 83, 3, 83, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 84, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 85, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 86, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 87, 3, 88, 3, 88, 3, 88, 3, 88, 3, 88, 3, 88, 3, 88, 3, 88, 3, 88, 3, 89, 3, 89, 3, 89, 3, 89, 3, 89, 3, 89, 3, 90, 3, 90, 3, 90, 3, 90, 3, 90, 3, 90, 3, 91, 3, 91, 3, 91, 3, 91, 3, 91, 3, 92, 3, 92, 3, 92, 3, 92, 3, 92, 3, 92, 3, 92, 3, 92, 3, 92, 5, 92, 970, 10, 92, 3, 93, 6, 93, 973, 10, 93, 13, 93, 14, 93, 974, 3, 94, 3, 94, 3, 94, 3, 94, 3, 94, 3, 95, 3, 95, 5, 95, 984, 10, 95, 3, 95, 3, 95, 3, 96, 6, 96, 989, 10, 96, 13, 96, 14, 96, 990, 3, 97, 3, 97, 5, 97, 995, 10, 97, 3, 98, 3, 98, 3, 98, 3, 99, 6, 99, 1001, 10, 99, 13, 99, 14, 99, 1002, 3, 99, 3, 99, 6, 99, 1007, 10, 99, 13, 99, 14, 99, 1008, 3, 99, 3, 99, 6, 99, 1013, 10, 99, 13, 99, 14, 99, 1014, 5, 99, 1017, 10, 99, 3, 100, 3, 100, 3, 101, 3, 101, 3, 101, 3, 102, 3, 102, 3, 102, 3, 103, 3, 103, 3, 103, 3, 104, 3, 104, 3, 104, 3, 104, 3, 105, 3, 105, 3, 105, 3, 105, 3, 105, 3, 106, 3, 106, 3, 106, 3, 107, 3, 107, 3, 107, 3, 108, 3, 108, 3, 108, 3, 109, 3, 109, 3, 109, 3, 110, 3, 110, 3, 111, 3, 111, 3, 112, 3, 112, 3, 112, 3, 113, 3, 113, 3, 114, 3, 114, 3, 114, 3, 115, 3, 115, 3, 115, 3, 116, 3, 116, 3, 117, 3, 117, 3, 118, 3, 118, 3, 119, 3, 119, 3, 120, 3, 120, 3, 121, 3, 121, 3, 122, 3, 122, 3, 123, 3, 123, 3, 124, 3, 124, 3, 125, 3, 125, 3, 126, 3, 126, 3, 127, 3, 127, 3, 128, 3, 128, 3, 129, 3, 129, 3, 130, 3, 130, 3, 131, 3, 131, 3, 132, 3, 132, 3, 133, 3, 133, 7, 133, 1102, 10, 133, 12, 133, 14, 133, 1105, 11, 133, 3, 134, 3, 134, 3, 135, 3, 135, 3, 136, 6, 136, 1112, 10, 136, 13, 136, 14, 136, 1113, 3, 136, 3, 136, 3, 137, 3, 137, 3, 137, 3, 137, 7, 137, 1122, 10, 137, 12, 137, 14, 137, 1125, 11, 137, 3, 137, 3, 137, 3, 137, 3, 137, 3, 137, 3, 138, 3, 138, 3, 138, 3, 138, 7, 138, 1136, 10, 138, 12, 138, 14, 138, 1139, 11, 138, 3, 138, 3, 138, 3, 1123, 2, 139, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 55, 109, 56, 111, 57, 113, 58, 115, 59, 117, 60, 119, 61, 121, 62, 123, 63, 125, 64, 127, 65, 129, 66, 131, 67, 133, 68, 135, 69, 137, 70, 139, 71, 141, 72, 143, 73, 145, 74, 147, 75, 149, 76, 151, 77, 153, 78, 155, 79, 157, 80, 159, 81, 161, 82, 163, 83, 165, 84, 167, 85, 169, 86, 171, 87, 173, 88, 175, 89, 177, 90, 179, 91, 181, 92, 183, 93, 185, 94, 187, 95, 189, 96, 191, 2, 193, 2, 195, 2, 197, 97, 199, 98, 201, 99, 203, 100, 205, 101, 207, 102, 209, 103, 211, 104, 213, 105, 215, 106, 217, 107, 219, 108, 221, 109, 223, 110, 225, 111, 227, 112, 229, 113, 231, 114, 233, 115, 235, 116, 237, 117, 239, 118, 241, 119, 243, 120, 245, 121, 247, 122, 249, 123, 251, 124, 253, 125, 255, 126, 257, 127, 259, 128, 261, 129, 263, 130, 265, 131, 267, 2, 269, 2, 271, 132, 273, 133, 275, 134, 3, 2, 8, 3, 2, 50, 59, 4, 2, 36, 36, 94, 94, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 5, 2, 11, 12, 14, 15, 34, 34, 4, 2, 12, 12, 15, 15, 2, 1149, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 117, 3, 2, 2, 2, 2, 119, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 2, 133, 3, 2, 2, 2, 2, 135, 3, 2, 2, 2, 2, 137, 3, 2, 2, 2, 2, 139, 3, 2, 2, 2, 2, 141, 3, 2, 2, 2, 2, 143, 3, 2, 2, 2, 2, 145, 3, 2, 2, 2, 2, 147, 3, 2, 2, 2, 2, 149, 3, 2, 2, 2, 2, 151, 3, 2, 2, 2, 2, 153, 3, 2, 2, 2, 2, 155, 3, 2, 2, 2, 2, 157, 3, 2, 2, 2, 2, 159, 3, 2, 2, 2, 2, 161, 3, 2, 2, 2, 2, 163, 3, 2, 2, 2, 2, 165, 3, 2, 2, 2, 2, 167, 3, 2, 2, 2, 2, 169, 3, 2, 2, 2, 2, 171, 3, 2, 2, 2, 2, 173, 3, 2, 2, 2, 2, 175, 3, 2, 2, 2, 2, 177, 3, 2, 2, 2, 2, 179, 3, 2, 2, 2, 2, 181, 3, 2, 2, 2, 2, 183, 3, 2, 2, 2, 2, 185, 3, 2, 2, 2, 2, 187, 3, 2, 2, 2, 2, 189, 3, 2, 2, 2, 2, 197, 3, 2, 2, 2, 2, 199, 3, 2, 2, 2, 2, 201, 3, 2, 2, 2, 2, 203, 3, 2, 2, 2, 2, 205, 3, 2, 2, 2, 2, 207, 3, 2, 2, 2, 2, 209, 3, 2, 2, 2, 2, 211, 3, 2, 2, 2, 2, 213, 3, 2, 2, 2, 2, 215, 3, 2, 2, 2, 2, 217, 3, 2, 2, 2, 2, 219, 3, 2, 2, 2, 2, 221, 3, 2, 2, 2, 2, 223, 3, 2, 2, 2, 2, 225, 3, 2, 2, 2, 2, 227, 3, 2, 2, 2, 2, 229, 3, 2, 2, 2, 2, 231, 3, 2, 2, 2, 2, 233, 3, 2, 2, 2, 2, 235, 3, 2, 2, 2, 2, 237, 3, 2, 2, 2, 2, 239, 3, 2, 2, 2, 2, 241, 3, 2, 2, 2, 2, 243, 3, 2, 2, 2, 2, 245, 3, 2, 2, 2, 2, 247, 3, 2, 2, 2, 2, 249, 3, 2, 2, 2, 2, 251, 3, 2, 2, 2, 2, 253, 3, 2, 2, 2, 2, 255, 3, 2, 2, 2, 2, 257, 3, 2, 2, 2, 2, 259, 3, 2, 2, 2, 2, 261, 3, 2, 2, 2, 2, 263, 3, 2, 2, 2, 2, 265, 3, 2, 2, 2, 2, 271, 3, 2, 2, 2, 2, 273, 3, 2, 2, 2, 2, 275, 3, 2, 2, 2, 3, 277, 3, 2, 2, 2, 5, 285, 3, 2, 2, 2, 7, 290, 3, 2, 2, 2, 9, 295, 3, 2, 2, 2, 11, 301, 3, 2, 2, 2, 13, 310, 3, 2, 2, 2, 15, 315, 3, 2, 2, 2, 17, 321, 3, 2, 2, 2, 19, 330, 3, 2, 2, 2, 21, 334, 3, 2, 2, 2, 23, 341, 3, 2, 2, 2, 25, 350, 3, 2, 2, 2, 27, 358, 3, 2, 2, 2, 29, 364, 3, 2, 2, 2, 31, 372, 3, 2, 2, 2, 33, 380, 3, 2, 2, 2, 35, 384, 3, 2, 2, 2, 37, 387, 3, 2, 2, 2, 39, 394, 3, 2, 2, 2, 41, 402, 3, 2, 2, 2, 43, 417, 3, 2, 2, 2, 45, 434, 3, 2, 2, 2, 47, 449, 3, 2, 2, 2, 49, 462, 3, 2, 2, 2, 51, 478, 3, 2, 2, 2, 53, 483, 3, 2, 2, 2, 55, 493, 3, 2, 2, 2, 57, 503, 3, 2, 2, 2, 59, 512, 3, 2, 2, 2, 61, 524, 3, 2, 2, 2, 63, 533, 3, 2, 2, 2, 65, 540, 3, 2, 2, 2, 67, 546, 3, 2, 2, 2, 69, 554, 3, 2, 2, 2, 71, 561, 3, 2, 2, 2, 73, 566, 3, 2, 2, 2, 75, 571, 3, 2, 2, 2, 77, 581, 3, 2, 2, 2, 79, 588, 3, 2, 2, 2, 81, 597, 3, 2, 2, 2, 83, 601, 3, 2, 2, 2, 85, 608, 3, 2, 2, 2, 87, 613, 3, 2, 2, 2, 89, 622, 3, 2, 2, 2, 91, 625, 3, 2, 2, 2, 93, 632, 3, 2, 2, 2, 95, 635, 3, 2, 2, 2, 97, 643, 3, 2, 2, 2, 99, 651, 3, 2, 2, 2, 101, 655, 3, 2, 2, 2, 103, 665, 3, 2, 2, 2, 105, 670, 3, 2, 2, 2, 107, 676, 3, 2, 2, 2, 109, 683, 3, 2, 2, 2, 111, 687, 3, 2, 2, 2, 113, 696, 3, 2, 2, 2, 115, 715, 3, 2, 2, 2, 117, 719, 3, 2, 2, 2, 119, 727, 3, 2, 2, 2, 121, 731, 3, 2, 2, 2, 123, 736, 3, 2, 2, 2, 125, 743, 3, 2, 2, 2, 127, 747, 3, 2, 2, 2, 129, 753, 3, 2, 2, 2, 131, 761, 3, 2, 2, 2, 133, 768, 3, 2, 2, 2, 135, 773, 3, 2, 2, 2, 137, 778, 3, 2, 2, 2, 139, 786, 3, 2, 2, 2, 141, 793, 3, 2, 2, 2, 143, 801, 3, 2, 2, 2, 145, 808, 3, 2, 2, 2, 147, 818, 3, 2, 2, 2, 149, 827, 3, 2, 2, 2, 151, 836, 3, 2, 2, 2, 153, 845, 3, 2, 2, 2, 155, 854, 3, 2, 2, 2, 157, 863, 3, 2, 2, 2, 159, 868, 3, 2, 2, 2, 161, 875, 3, 2, 2, 2, 163, 880, 3, 2, 2, 2, 165, 887, 3, 2, 2, 2, 167, 892, 3, 2, 2, 2, 169, 901, 3, 2, 2, 2, 171, 912, 3, 2, 2, 2, 173, 924, 3, 2, 2, 2, 175, 934, 3, 2, 2, 2, 177, 943, 3, 2, 2, 2, 179, 949, 3, 2, 2, 2, 181, 955, 3, 2, 2, 2, 183, 969, 3, 2, 2, 2, 185, 972, 3, 2, 2, 2, 187, 976, 3, 2, 2, 2, 189, 981, 3, 2, 2, 2, 191, 988, 3, 2, 2, 2, 193, 994, 3, 2, 2, 2, 195, 996, 3, 2, 2, 2, 197, 1000, 3, 2, 2, 2, 199, 1018, 3, 2, 2, 2, 201, 1020, 3, 2, 2, 2, 203, 1023, 3, 2, 2, 2, 205, 1026, 3, 2, 2, 2, 207, 1029, 3, 2, 2, 2, 209, 1033, 3, 2, 2, 2, 211, 1038, 3, 2, 2, 2, 213, 1041, 3, 2, 2, 2, 215, 1044, 3, 2, 2, 2, 217, 1047, 3, 2, 2, 2, 219, 1050, 3, 2, 2, 2, 221, 1052, 3, 2, 2, 2, 223, 1054, 3, 2, 2, 2, 225, 1057, 3, 2, 2, 2, 227, 1059, 3, 2, 2, 2, 229, 1062, 3, 2, 2, 2, 231, 1065, 3, 2, 2, 2, 233, 1067, 3, 2, 2, 2, 235, 1069, 3, 2, 2, 2, 237, 1071, 3, 2, 2, 2, 239, 1073, 3, 2, 2, 2, 241, 1075, 3, 2, 2, 2, 243, 1077, 3, 2, 2, 2, 245, 1079, 3, 2, 2, 2, 247, 1081, 3, 2, 2, 2, 249, 1083, 3, 2, 2, 2, 251, 1085, 3, 2, 2, 2, 253, 1087, 3, 2, 2, 2, 255, 1089, 3, 2, 2, 2, 257, 1091, 3, 2, 2, 2, 259, 1093, 3, 2, 2, 2, 261, 1095, 3, 2, 2, 2, 263, 1097, 3, 2, 2, 2, 265, 1099, 3, 2, 2, 2, 267, 1106, 3, 2, 2, 2, 269, 1108, 3, 2, 2, 2, 271, 1111, 3, 2, 2, 2, 273, 1117, 3, 2, 2, 2, 275, 1131, 3, 2, 2, 2, 277, 278, 7, 99, 2, 2, 278, 279, 7, 102, 2, 2, 279, 280, 7, 102, 2, 2, 280, 281, 7, 116, 2, 2, 281, 282, 7, 103, 2, 2, 282, 283, 7, 117, 2, 2, 283, 284, 7, 117, 2, 2, 284, 4, 3, 2, 2, 2, 285, 286, 7, 100, 2, 2, 286, 287, 7, 113, 2, 2, 287, 288, 7, 113, 2, 2, 288, 289, 7, 110, 2, 2, 289, 6, 3, 2, 2, 2, 290, 291, 7, 103, 2, 2, 291, 292, 7, 112, 2, 2, 292, 293, 7, 119, 2, 2, 293, 294, 7, 111, 2, 2, 294, 8, 3, 2, 2, 2, 295, 296, 7, 103, 2, 2, 296, 297, 7, 120, 2, 2, 297, 298, 7, 103, 2, 2, 298, 299, 7, 112, 2, 2, 299, 300, 7, 118, 2, 2, 300, 10, 3, 2, 2, 2, 301, 302, 7, 103, 2, 2, 302, 303, 7, 120, 2, 2, 303, 304, 7, 103, 2, 2, 304, 305, 7, 112, 2, 2, 305, 306, 7, 118, 2, 2, 306, 307, 7, 110, 2, 2, 307, 308, 7, 113, 2, 2, 308, 309, 7, 105, 2, 2, 309, 12, 3, 2, 2, 2, 310, 311, 7, 119, 2, 2, 311, 312, 7, 107, 2, 2, 312, 313, 7, 112, 2, 2, 313, 314, 7, 118, 2, 2, 314, 14, 3, 2, 2, 2, 315, 316, 7, 119, 2, 2, 316, 317, 7, 107, 2, 2, 317, 318, 7, 112, 2, 2, 318, 319, 7, 118, 2, 2, 319, 320, 7, 58, 2, 2, 320, 16, 3, 2, 2, 2, 321, 322, 7, 107, 2, 2, 322, 323, 7, 112, 2, 2, 323, 324, 7, 117, 2, 2, 324, 325, 7, 118, 2, 2, 325, 326, 7, 97, 2, 2, 326, 327, 7, 111, 2, 2, 327, 328, 7, 99, 2, 2, 328, 329, 7, 114, 2, 2, 329, 18, 3, 2, 2, 2, 330, 331, 7, 107, 2, 2, 331, 332, 7, 112, 2, 2, 332, 333, 7, 118, 2, 2, 333, 20, 3, 2, 2, 2, 334, 335, 7, 117, 2, 2, 335, 336, 7, 118, 2, 2, 336, 337, 7, 116, 2, 2, 337, 338, 7, 107, 2, 2, 338, 339, 7, 112, 2, 2, 339, 340, 7, 105, 2, 2, 340, 22, 3, 2, 2, 2, 341, 342, 7, 101, 2, 2, 342, 343, 7, 113, 2, 2, 343, 344, 7, 112, 2, 2, 344, 345, 7, 118, 2, 2, 345, 346, 7, 116, 2, 2, 346, 347, 7, 99, 2, 2, 347, 348, 7, 101, 2, 2, 348, 349, 7, 118, 2, 2, 349, 24, 3, 2, 2, 2, 350, 351, 7, 111, 2, 2, 351, 352, 7, 99, 2, 2, 352, 353, 7, 114, 2, 2, 353, 354, 7, 114, 2, 2, 354, 355, 7, 107, 2, 2, 355, 356, 7, 112, 2, 2, 356, 357, 7, 105, 2, 2, 357, 26, 3, 2, 2, 2, 358, 359, 7, 100, 2, 2, 359, 360, 7, 123, 2, 2, 360, 361, 7, 118, 2, 2, 361, 362, 7, 103, 2, 2, 362, 363, 7, 117, 2, 2, 363, 28, 3, 2, 2, 2, 364, 365, 7, 100, 2, 2, 365, 366, 7, 123, 2, 2, 366, 367, 7, 118, 2, 2, 367, 368, 7, 103, 2, 2, 368, 369, 7, 117, 2, 2, 369, 370, 7, 52, 2, 2, 370, 371, 7, 50, 2, 2, 371, 30, 3, 2, 2, 2, 372, 373, 7, 100, 2, 2, 373, 374, 7, 123, 2, 2, 374, 375, 7, 118, 2, 2, 375, 376, 7, 103, 2, 2, 376, 377, 7, 117, 2, 2, 377, 378, 7, 53, 2, 2, 378, 379, 7, 52, 2, 2, 379, 32, 3, 2, 2, 2, 380, 381, 7, 99, 2, 2, 381, 382, 7, 102, 2, 2, 382, 383, 7, 102, 2, 2, 383, 34, 3, 2, 2, 2, 384, 385, 7, 99, 2, 2, 385, 386, 7, 117, 2, 2, 386, 36, 3, 2, 2, 2, 387, 388, 7, 99, 2, 2, 388, 389, 7, 117, 2, 2, 389, 390, 7, 117, 2, 2, 390, 391, 7, 103, 2, 2, 391, 392, 7, 116, 2, 2, 392, 393, 7, 118, 2, 2, 393, 38, 3, 2, 2, 2, 394, 395, 7, 100, 2, 2, 395, 396, 7, 99, 2, 2, 396, 397, 7, 110, 2, 2, 397, 398, 7, 99, 2, 2, 398, 399, 7, 112, 2, 2, 399, 400, 7, 101, 2, 2, 400, 401, 7, 103, 2, 2, 401, 40, 3, 2, 2, 2, 402, 403, 7, 100, 2, 2, 403, 404, 7, 110, 2, 2, 404, 405, 7, 113, 2, 2, 405, 406, 7, 101, 2, 2, 406, 407, 7, 109, 2, 2, 407, 408, 7, 48, 2, 2, 408, 409, 7, 101, 2, 2, 409, 410, 7, 113, 2, 2, 410, 411, 7, 107, 2, 2, 411, 412, 7, 112, 2, 2, 412, 413, 7, 100, 2, 2, 413, 414, 7, 99, 2, 2, 414, 415, 7, 117, 2, 2, 415, 416, 7, 103, 2, 2, 416, 42, 3, 2, 2, 2, 417, 418, 7, 100, 2, 2, 418, 419, 7, 110, 2, 2, 419, 420, 7, 113, 2, 2, 420, 421, 7, 101, 2, 2, 421, 422, 7, 109, 2, 2, 422, 423, 7, 48, 2, 2, 423, 424, 7, 102, 2, 2, 424, 425, 7, 107, 2, 2, 425, 426, 7, 104, 2, 2, 426, 427, 7, 104, 2, 2, 427, 428, 7, 107, 2, 2, 428, 429, 7, 101, 2, 2, 429, 430, 7, 119, 2, 2, 430, 431, 7, 110, 2, 2, 431, 432, 7, 118, 2, 2, 432, 433, 7, 123, 2, 2, 433, 44, 3, 2, 2, 2, 434, 435, 7, 100, 2, 2, 435, 436, 7, 110, 2, 2, 436, 437, 7, 113, 2, 2, 437, 438, 7, 101, 2, 2, 438, 439, 7, 109, 2, 2, 439, 440, 7, 48, 2, 2, 440, 441, 7, 105, 2, 2, 441, 442, 7, 99, 2, 2, 442, 443, 7, 117, 2, 2, 443, 444, 7, 110, 2, 2, 444, 445, 7, 107, 2, 2, 445, 446, 7, 111, 2, 2, 446, 447, 7, 107, 2, 2, 447, 448, 7, 118, 2, 2, 448, 46, 3, 2, 2, 2, 449, 450, 7, 100, 2, 2, 450, 451, 7, 110, 2, 2, 451, 452, 7, 113, 2, 2, 452, 453, 7, 101, 2, 2, 453, 454, 7, 109, 2, 2, 454, 455, 7, 48, 2, 2, 455, 456, 7, 112, 2, 2, 456, 457, 7, 119, 2, 2, 457, 458, 7, 111, 2, 2, 458, 459, 7, 100, 2, 2, 459, 460, 7, 103, 2, 2, 460, 461, 7, 116, 2, 2, 461, 48, 3, 2, 2, 2, 462, 463, 7, 100, 2, 2, 463, 464, 7, 110, 2, 2, 464, 465, 7, 113, 2, 2, 465, 466, 7, 101, 2, 2, 466, 467, 7, 109, 2, 2, 467, 468, 7, 48, 2, 2, 468, 469, 7, 118, 2, 2, 469, 470, 7, 107, 2, 2, 470, 471, 7, 111, 2, 2, 471, 472, 7, 103, 2, 2, 472, 473, 7, 117, 2, 2, 473, 474, 7, 118, 2, 2, 474, 475, 7, 99, 2, 2, 475, 476, 7, 111, 2, 2, 476, 477, 7, 114, 2, 2, 477, 50, 3, 2, 2, 2, 478, 479, 7, 101, 2, 2, 479, 480, 7, 99, 2, 2, 480, 481, 7, 110, 2, 2, 481, 482, 7, 110, 2, 2, 482, 52, 3, 2, 2, 2, 483, 484, 7, 101, 2, 2, 484, 485, 7, 99, 2, 2, 485, 486, 7, 110, 2, 2, 486, 487, 7, 110, 2, 2, 487, 488, 7, 97, 2, 2, 488, 489, 7, 100, 2, 2, 489, 490, 7, 113, 2, 2, 490, 491, 7, 113, 2, 2, 491, 492, 7, 110, 2, 2, 492, 54, 3, 2, 2, 2, 493, 494, 7, 101, 2, 2, 494, 495, 7, 99, 2, 2, 495, 496, 7, 110, 2, 2, 496, 497, 7, 110, 2, 2, 497, 498, 7, 97, 2, 2, 498, 499, 7, 119, 2, 2, 499, 500, 7, 107, 2, 2, 500, 501, 7, 112, 2, 2, 501, 502, 7, 118, 2, 2, 502, 56, 3, 2, 2, 2, 503, 504, 7, 101, 2, 2, 504, 505, 7, 113, 2, 2, 505, 506, 7, 112, 2, 2, 506, 507, 7, 117, 2, 2, 507, 508, 7, 118, 2, 2, 508, 509, 7, 99, 2, 2, 509, 510, 7, 112, 2, 2, 510, 511, 7, 118, 2, 2, 511, 58, 3, 2, 2, 2, 512, 513, 7, 101, 2, 2, 513, 514, 7, 113, 2, 2, 514, 515, 7, 112, 2, 2, 515, 516, 7, 117, 2, 2, 516, 517, 7, 118, 2, 2, 517, 518, 7, 116, 2, 2, 518, 519, 7, 119, 2, 2, 519, 520, 7, 101, 2, 2, 520, 521, 7, 118, 2, 2, 521, 522, 7, 113, 2, 2, 522, 523, 7, 116, 2, 2, 523, 60, 3, 2, 2, 2, 524, 525, 7, 101, 2, 2, 525, 526, 7, 113, 2, 2, 526, 527, 7, 112, 2, 2, 527, 528, 7, 118, 2, 2, 528, 529, 7, 99, 2, 2, 529, 530, 7, 107, 2, 2, 530, 531, 7, 112, 2, 2, 531, 532, 7, 117, 2, 2, 532, 62, 3, 2, 2, 2, 533, 534, 7, 101, 2, 2, 534, 535, 7, 116, 2, 2, 535, 536, 7, 103, 2, 2, 536, 537, 7, 102, 2, 2, 537, 538, 7, 107, 2, 2, 538, 539, 7, 118, 2, 2, 539, 64, 3, 2, 2, 2, 540, 541, 7, 102, 2, 2, 541, 542, 7, 103, 2, 2, 542, 543, 7, 100, 2, 2, 543, 544, 7, 107, 2, 2, 544, 545, 7, 118, 2, 2, 545, 66, 3, 2, 2, 2, 546, 547, 7, 102, 2, 2, 547, 548, 7, 103, 2, 2, 548, 549, 7, 104, 2, 2, 549, 550, 7, 99, 2, 2, 550, 551, 7, 119, 2, 2, 551, 552, 7, 110, 2, 2, 552, 553, 7, 118, 2, 2, 553, 68, 3, 2, 2, 2, 554, 555, 7, 102, 2, 2, 555, 556, 7, 103, 2, 2, 556, 557, 7, 110, 2, 2, 557, 558, 7, 103, 2, 2, 558, 559, 7, 118, 2, 2, 559, 560, 7, 103, 2, 2, 560, 70, 3, 2, 2, 2, 561, 562, 7, 103, 2, 2, 562, 563, 7, 110, 2, 2, 563, 564, 7, 117, 2, 2, 564, 565, 7, 103, 2, 2, 565, 72, 3, 2, 2, 2, 566, 567, 7, 103, 2, 2, 567, 568, 7, 111, 2, 2, 568, 569, 7, 107, 2, 2, 569, 570, 7, 118, 2, 2, 570, 74, 3, 2, 2, 2, 571, 572, 7, 103, 2, 2, 572, 573, 7, 86, 2, 2, 573, 574, 7, 116, 2, 2, 574, 575, 7, 99, 2, 2, 575, 576, 7, 112, 2, 2, 576, 577, 7, 117, 2, 2, 577, 578, 7, 104, 2, 2, 578, 579, 7, 103, 2, 2, 579, 580, 7, 116, 2, 2, 580, 76, 3, 2, 2, 2, 581, 582, 7, 103, 2, 2, 582, 583, 7, 122, 2, 2, 583, 584, 7, 107, 2, 2, 584, 585, 7, 117, 2, 2, 585, 586, 7, 118, 2, 2, 586, 587, 7, 117, 2, 2, 587, 78, 3, 2, 2, 2, 588, 589, 7, 104, 2, 2, 589, 590, 7, 99, 2, 2, 590, 591, 7, 110, 2, 2, 591, 592, 7, 110, 2, 2, 592, 593, 7, 100, 2, 2, 593, 594, 7, 99, 2, 2, 594, 595, 7, 101, 2, 2, 595, 596, 7, 109, 2, 2, 596, 80, 3, 2, 2, 2, 597, 598, 7, 104, 2, 2, 598, 599, 7, 113, 2, 2, 599, 600, 7, 116, 2, 2, 600, 82, 3, 2, 2, 2, 601, 602, 7, 104, 2, 2, 602, 603, 7, 113, 2, 2, 603, 604, 7, 116, 2, 2, 604, 605, 7, 99, 2, 2, 605, 606, 7, 110, 2, 2, 606, 607, 7, 110, 2, 2, 607, 84, 3, 2, 2, 2, 608, 609, 7, 104, 2, 2, 609, 610, 7, 116, 2, 2, 610, 611, 7, 113, 2, 2, 611, 612, 7, 111, 2, 2, 612, 86, 3, 2, 2, 2, 613, 614, 7, 104, 2, 2, 614, 615, 7, 119, 2, 2, 615, 616, 7, 112, 2, 2, 616, 617, 7, 101, 2, 2, 617, 618, 7, 118, 2, 2, 618, 619, 7, 107, 2, 2, 619, 620, 7, 113, 2, 2, 620, 621, 7, 112, 2, 2, 621, 88, 3, 2, 2, 2, 622, 623, 7, 107, 2, 2, 623, 624, 7, 104, 2, 2, 624, 90, 3, 2, 2, 2, 625, 626, 7, 107, 2, 2, 626, 627, 7, 111, 2, 2, 627, 628, 7, 114, 2, 2, 628, 629, 7, 113, 2, 2, 629, 630, 7, 116, 2, 2, 630, 631, 7, 118, 2, 2, 631, 92, 3, 2, 2, 2, 632, 633, 7, 107, 2, 2, 633, 634, 7, 112, 2, 2, 634, 94, 3, 2, 2, 2, 635, 636, 7, 107, 2, 2, 636, 637, 7, 112, 2, 2, 637, 638, 7, 118, 2, 2, 638, 639, 7, 97, 2, 2, 639, 640, 7, 111, 2, 2, 640, 641, 7, 107, 2, 2, 641, 642, 7, 112, 2, 2, 642, 96, 3, 2, 2, 2, 643, 644, 7, 107, 2, 2, 644, 645, 7, 112, 2, 2, 645, 646, 7, 118, 2, 2, 646, 647, 7, 97, 2, 2, 647, 648, 7, 111, 2, 2, 648, 649, 7, 99, 2, 2, 649, 650, 7, 122, 2, 2, 650, 98, 3, 2, 2, 2, 651, 652, 7, 107, 2, 2, 652, 653, 7, 118, 2, 2, 653, 654, 7, 103, 2, 2, 654, 100, 3, 2, 2, 2, 655, 656, 7, 107, 2, 2, 656, 657, 7, 112, 2, 2, 657, 658, 7, 120, 2, 2, 658, 659, 7, 99, 2, 2, 659, 660, 7, 116, 2, 2, 660, 661, 7, 107, 2, 2, 661, 662, 7, 99, 2, 2, 662, 663, 7, 112, 2, 2, 663, 664, 7, 118, 2, 2, 664, 102, 3, 2, 2, 2, 665, 666, 7, 109, 2, 2, 666, 667, 7, 103, 2, 2, 667, 668, 7, 123, 2, 2, 668, 669, 7, 117, 2, 2, 669, 104, 3, 2, 2, 2, 670, 671, 7, 110, 2, 2, 671, 672, 7, 103, 2, 2, 672, 673, 7, 111, 2, 2, 673, 674, 7, 111, 2, 2, 674, 675, 7, 99, 2, 2, 675, 106, 3, 2, 2, 2, 676, 677, 7, 110, 2, 2, 677, 678, 7, 103, 2, 2, 678, 679, 7, 112, 2, 2, 679, 680, 7, 105, 2, 2, 680, 681, 7, 118, 2, 2, 681, 682, 7, 106, 2, 2, 682, 108, 3, 2, 2, 2, 683, 684, 7, 110, 2, 2, 684, 685, 7, 113, 2, 2, 685, 686, 7, 105, 2, 2, 686, 110, 3, 2, 2, 2, 687, 688, 7, 111, 2, 2, 688, 689, 7, 113, 2, 2, 689, 690, 7, 102, 2, 2, 690, 691, 7, 107, 2, 2, 691, 692, 7, 104, 2, 2, 692, 693, 7, 107, 2, 2, 693, 694, 7, 103, 2, 2, 694, 695, 7, 117, 2, 2, 695, 112, 3, 2, 2, 2, 696, 697, 7, 111, 2, 2, 697, 698, 7, 113, 2, 2, 698, 699, 7, 102, 2, 2, 699, 700, 7, 107, 2, 2, 700, 701, 7, 104, 2, 2, 701, 702, 7, 107, 2, 2, 702, 703, 7, 103, 2, 2, 703, 704, 7, 117, 2, 2, 704, 705, 7, 97, 2, 2, 705, 706, 7, 99, 2, 2, 706, 707, 7, 102, 2, 2, 707, 708, 7, 102, 2, 2, 708, 709, 7, 116, 2, 2, 709, 710, 7, 103, 2, 2, 710, 711, 7, 117, 2, 2, 711, 712, 7, 117, 2, 2, 712, 713, 7, 103, 2, 2, 713, 714, 7, 117, 2, 2, 714, 114, 3, 2, 2, 2, 715, 716, 7, 112, 2, 2, 716, 717, 7, 103, 2, 2, 717, 718, 7, 121, 2, 2, 718, 116, 3, 2, 2, 2, 719, 720, 7, 114, 2, 2, 720, 721, 7, 99, 2, 2, 721, 722, 7, 123, 2, 2, 722, 723, 7, 99, 2, 2, 723, 724, 7, 100, 2, 2, 724, 725, 7, 110, 2, 2, 725, 726, 7, 103, 2, 2, 726, 118, 3, 2, 2, 2, 727, 728, 7, 114, 2, 2, 728, 729, 7, 113, 2, 2, 729, 730, 7, 114, 2, 2, 730, 120, 3, 2, 2, 2, 731, 732, 7, 114, 2, 2, 732, 733, 7, 113, 2, 2, 733, 734, 7, 117, 2, 2, 734, 735, 7, 118, 2, 2, 735, 122, 3, 2, 2, 2, 736, 737, 7, 114, 2, 2, 737, 738, 7, 116, 2, 2, 738, 739, 7, 99, 2, 2, 739, 740, 7, 105, 2, 2, 740, 741, 7, 111, 2, 2, 741, 742, 7, 99, 2, 2, 742, 124, 3, 2, 2, 2, 743, 744, 7, 114, 2, 2, 744, 745, 7, 116, 2, 2, 745, 746, 7, 103, 2, 2, 746, 126, 3, 2, 2, 2, 747, 748, 7, 114, 2, 2, 748, 749, 7, 116, 2, 2, 749, 750, 7, 107, 2, 2, 750, 751, 7, 112, 2, 2, 751, 752, 7, 118, 2, 2, 752, 128, 3, 2, 2, 2, 753, 754, 7, 114, 2, 2, 754, 755, 7, 116, 2, 2, 755, 756, 7, 107, 2, 2, 756, 757, 7, 120, 2, 2, 757, 758, 7, 99, 2, 2, 758, 759, 7, 118, 2, 2, 759, 760, 7, 103, 2, 2, 760, 130, 3, 2, 2, 2, 761, 762, 7, 114, 2, 2, 762, 763, 7, 119, 2, 2, 763, 764, 7, 100, 2, 2, 764, 765, 7, 110, 2, 2, 765, 766, 7, 107, 2, 2, 766, 767, 7, 101, 2, 2, 767, 132, 3, 2, 2, 2, 768, 769, 7, 114, 2, 2, 769, 770, 7, 119, 2, 2, 770, 771, 7, 116, 2, 2, 771, 772, 7, 103, 2, 2, 772, 134, 3, 2, 2, 2, 773, 774, 7, 114, 2, 2, 774, 775, 7, 119, 2, 2, 775, 776, 7, 117, 2, 2, 776, 777, 7, 106, 2, 2, 777, 136, 3, 2, 2, 2, 778, 779, 7, 116, 2, 2, 779, 780, 7, 103, 2, 2, 780, 781, 7, 101, 2, 2, 781, 782, 7, 103, 2, 2, 782, 783, 7, 107, 2, 2, 783, 784, 7, 120, 2, 2, 784, 785, 7, 103, 2, 2, 785, 138, 3, 2, 2, 2, 786, 787, 7, 116, 2, 2, 787, 788, 7, 103, 2, 2, 788, 789, 7, 118, 2, 2, 789, 790, 7, 119, 2, 2, 790, 791, 7, 116, 2, 2, 791, 792, 7, 112, 2, 2, 792, 140, 3, 2, 2, 2, 793, 794, 7, 116, 2, 2, 794, 795, 7, 103, 2, 2, 795, 796, 7, 118, 2, 2, 796, 797, 7, 119, 2, 2, 797, 798, 7, 116, 2, 2, 798, 799, 7, 112, 2, 2, 799, 800, 7, 117, 2, 2, 800, 142, 3, 2, 2, 2, 801, 802, 7, 116, 2, 2, 802, 803, 7, 103, 2, 2, 803, 804, 7, 120, 2, 2, 804, 805, 7, 103, 2, 2, 805, 806, 7, 116, 2, 2, 806, 807, 7, 118, 2, 2, 807, 144, 3, 2, 2, 2, 808, 809, 7, 116, 2, 2, 809, 810, 7, 97, 2, 2, 810, 811, 7, 116, 2, 2, 811, 812, 7, 103, 2, 2, 812, 813, 7, 120, 2, 2, 813, 814, 7, 103, 2, 2, 814, 815, 7, 116, 2, 2, 815, 816, 7, 118, 2, 2, 816, 817, 7, 117, 2, 2, 817, 146, 3, 2, 2, 2, 818, 819, 7, 117, 2, 2, 819, 820, 7, 99, 2, 2, 820, 821, 7, 104, 2, 2, 821, 822, 7, 103, 2, 2, 822, 823, 7, 97, 2, 2, 823, 824, 7, 99, 2, 2, 824, 825, 7, 102, 2, 2, 825, 826, 7, 102, 2, 2, 826, 148, 3, 2, 2, 2, 827, 828, 7, 117, 2, 2, 828, 829, 7, 99, 2, 2, 829, 830, 7, 104, 2, 2, 830, 831, 7, 103, 2, 2, 831, 832, 7, 97, 2, 2, 832, 833, 7, 102, 2, 2, 833, 834, 7, 107, 2, 2, 834, 835, 7, 120, 2, 2, 835, 150, 3, 2, 2, 2, 836, 837, 7, 117, 2, 2, 837, 838, 7, 99, 2, 2, 838, 839, 7, 104, 2, 2, 839, 840, 7, 103, 2, 2, 840, 841, 7, 97, 2, 2, 841, 842, 7, 111, 2, 2, 842, 843, 7, 113, 2, 2, 843, 844, 7, 102, 2, 2, 844, 152, 3, 2, 2, 2, 845, 846, 7, 117, 2, 2, 846, 847, 7, 99, 2, 2, 847, 848, 7, 104, 2, 2, 848, 849, 7, 103, 2, 2, 849, 850, 7, 97, 2, 2, 850, 851, 7, 111, 2, 2, 851, 852, 7, 119, 2, 2, 852, 853, 7, 110, 2, 2, 853, 154, 3, 2, 2, 2, 854, 855, 7, 117, 2, 2, 855, 856, 7, 99, 2, 2, 856, 857, 7, 104, 2, 2, 857, 858, 7, 103, 2, 2, 858, 859, 7, 97, 2, 2, 859, 860, 7, 117, 2, 2, 860, 861, 7, 119, 2, 2, 861, 862, 7, 100, 2, 2, 862, 156, 3, 2, 2, 2, 863, 864, 7, 117, 2, 2, 864, 865, 7, 103, 2, 2, 865, 866, 7, 112, 2, 2, 866, 867, 7, 102, 2, 2, 867, 158, 3, 2, 2, 2, 868, 869, 7, 117, 2, 2, 869, 870, 7, 103, 2, 2, 870, 871, 7, 112, 2, 2, 871, 872, 7, 102, 2, 2, 872, 873, 7, 103, 2, 2, 873, 874, 7, 116, 2, 2, 874, 160, 3, 2, 2, 2, 875, 876, 7, 117, 2, 2, 876, 877, 7, 114, 2, 2, 877, 878, 7, 103, 2, 2, 878, 879, 7, 101, 2, 2, 879, 162, 3, 2, 2, 2, 880, 881, 7, 117, 2, 2, 881, 882, 7, 118, 2, 2, 882, 883, 7, 116, 2, 2, 883, 884, 7, 119, 2, 2, 884, 885, 7, 101, 2, 2, 885, 886, 7, 118, 2, 2, 886, 164, 3, 2, 2, 2, 887, 888, 7, 118, 2, 2, 888, 889, 7, 106, 2, 2, 889, 890, 7, 107, 2, 2, 890, 891, 7, 117, 2, 2, 891, 166, 3, 2, 2, 2, 892, 893, 7, 118, 2, 2, 893, 894, 7, 116, 2, 2, 894, 895, 7, 99, 2, 2, 895, 896, 7, 112, 2, 2, 896, 897, 7, 117, 2, 2, 897, 898, 7, 104, 2, 2, 898, 899, 7, 103, 2, 2, 899, 900, 7, 116, 2, 2, 900, 168, 3, 2, 2, 2, 901, 902, 7, 118, 2, 2, 902, 903, 7, 122, 2, 2, 903, 904, 7, 97, 2, 2, 904, 905, 7, 116, 2, 2, 905, 906, 7, 103, 2, 2, 906, 907, 7, 120, 2, 2, 907, 908, 7, 103, 2, 2, 908, 909, 7, 116, 2, 2, 909, 910, 7, 118, 2, 2, 910, 911, 7, 117, 2, 2, 911, 170, 3, 2, 2, 2, 912, 913, 7, 118, 2, 2, 913, 914, 7, 122, 2, 2, 914, 915, 7, 48, 2, 2, 915, 916, 7, 105, 2, 2, 916, 917, 7, 99, 2, 2, 917, 918, 7, 117, 2, 2, 918, 919, 7, 114, 2, 2, 919, 920, 7, 116, 2, 2, 920, 921, 7, 107, 2, 2, 921, 922, 7, 101, 2, 2, 922, 923, 7, 103, 2, 2, 923, 172, 3, 2, 2, 2, 924, 925, 7, 118, 2, 2, 925, 926, 7, 122, 2, 2, 926, 927, 7, 48, 2, 2, 927, 928, 7, 113, 2, 2, 928, 929, 7, 116, 2, 2, 929, 930, 7, 107, 2, 2, 930, 931, 7, 105, 2, 2, 931, 932, 7, 107, 2, 2, 932, 933, 7, 112, 2, 2, 933, 174, 3, 2, 2, 2, 934, 935, 7, 119, 2, 2, 935, 936, 7, 107, 2, 2, 936, 937, 7, 112, 2, 2, 937, 938, 7, 118, 2, 2, 938, 939, 7, 97, 2, 2, 939, 940, 7, 111, 2, 2, 940, 941, 7, 99, 2, 2, 941, 942, 7, 122, 2, 2, 942, 176, 3, 2, 2, 2, 943, 944, 7, 119, 2, 2, 944, 945, 7, 117, 2, 2, 945, 946, 7, 107, 2, 2, 946, 947, 7, 112, 2, 2, 947, 948, 7, 105, 2, 2, 948, 178, 3, 2, 2, 2, 949, 950, 7, 120, 2, 2, 950, 951, 7, 99, 2, 2, 951, 952, 7, 110, 2, 2, 952, 953, 7, 119, 2, 2, 953, 954, 7, 103, 2, 2, 954, 180, 3, 2, 2, 2, 955, 956, 7, 120, 2, 2, 956, 957, 7, 107, 2, 2, 957, 958, 7, 103, 2, 2, 958, 959, 7, 121, 2, 2, 959, 182, 3, 2, 2, 2, 960, 961, 7, 118, 2, 2, 961, 962, 7, 116, 2, 2, 962, 963, 7, 119, 2, 2, 963, 970, 7, 103, 2, 2, 964, 965, 7, 104, 2, 2, 965, 966, 7, 99, 2, 2, 966, 967, 7, 110, 2, 2, 967, 968, 7, 117, 2, 2, 968, 970, 7, 103, 2, 2, 969, 960, 3, 2, 2, 2, 969, 964, 3, 2, 2, 2, 970, 184, 3, 2, 2, 2, 971, 973, 9, 2, 2, 2, 972, 971, 3, 2, 2, 2, 973, 974, 3, 2, 2, 2, 974, 972, 3, 2, 2, 2, 974, 975, 3, 2, 2, 2, 975, 186, 3, 2, 2, 2, 976, 977, 7, 112, 2, 2, 977, 978, 7, 119, 2, 2, 978, 979, 7, 110, 2, 2, 979, 980, 7, 110, 2, 2, 980, 188, 3, 2, 2, 2, 981, 983, 7, 36, 2, 2, 982, 984, 5, 191, 96, 2, 983, 982, 3, 2, 2, 2, 983, 984, 3, 2, 2, 2, 984, 985, 3, 2, 2, 2, 985, 986, 7, 36, 2, 2, 986, 190, 3, 2, 2, 2, 987, 989, 5, 193, 97, 2, 988, 987, 3, 2, 2, 2, 989, 990, 3, 2, 2, 2, 990, 988, 3, 2, 2, 2, 990, 991, 3, 2, 2, 2, 991, 192, 3, 2, 2, 2, 992, 995, 10, 3, 2, 2, 993, 995, 5, 195, 98, 2, 994, 992, 3, 2, 2, 2, 994, 993, 3, 2, 2, 2, 995, 194, 3, 2, 2, 2, 996, 997, 7, 94, 2, 2, 997, 998, 11, 2, 2, 2, 998, 196, 3, 2, 2, 2, 999, 1001, 9, 2, 2, 2, 1000, 999, 3, 2, 2, 2, 1001, 1002, 3, 2, 2, 2, 1002, 1000, 3, 2, 2, 2, 1002, 1003, 3, 2, 2, 2, 1003, 1004, 3, 2, 2, 2, 1004, 1006, 7, 48, 2, 2, 1005, 1007, 9, 2, 2, 2, 1006, 1005, 3, 2, 2, 2, 1007, 1008, 3, 2, 2, 2, 1008, 1006, 3, 2, 2, 2, 1008, 1009, 3, 2, 2, 2, 1009, 1016, 3, 2, 2, 2, 1010, 1012, 7, 48, 2, 2, 1011, 1013, 9, 2, 2, 2, 1012, 1011, 3, 2, 2, 2, 1013, 1014, 3, 2, 2, 2, 1014, 1012, 3, 2, 2, 2, 1014, 1015, 3, 2, 2, 2, 1015, 1017, 3, 2, 2, 2, 1016, 1010, 3, 2, 2, 2, 1016, 1017, 3, 2, 2, 2, 1017, 198, 3, 2, 2, 2, 1018, 1019, 7, 35, 2, 2, 1019, 200, 3, 2, 2, 2, 1020, 1021, 7, 40, 2, 2, 1021, 1022, 7, 40, 2, 2, 1022, 202, 3, 2, 2, 2, 1023, 1024, 7, 126, 2, 2, 1024, 1025, 7, 126, 2, 2, 1025, 204, 3, 2, 2, 2, 1026, 1027, 7, 63, 2, 2, 1027, 1028, 7, 64, 2, 2, 1028, 206, 3, 2, 2, 2, 1029, 1030, 7, 63, 2, 2, 1030, 1031, 7, 63, 2, 2, 1031, 1032, 7, 64, 2, 2, 1032, 208, 3, 2, 2, 2, 1033, 1034, 7, 62, 2, 2, 1034, 1035, 7, 63, 2, 2, 1035, 1036, 7, 63, 2, 2, 1036, 1037, 7, 64, 2, 2, 1037, 210, 3, 2, 2, 2, 1038, 1039, 7, 63, 2, 2, 1039, 1040, 7, 63, 2, 2, 1040, 212, 3, 2, 2, 2, 1041, 1042, 7, 35, 2, 2, 1042, 1043, 7, 63, 2, 2, 1043, 214, 3, 2, 2, 2, 1044, 1045, 7, 62, 2, 2, 1045, 1046, 7, 63, 2, 2, 1046, 216, 3, 2, 2, 2, 1047, 1048, 7, 64, 2, 2, 1048, 1049, 7, 63, 2, 2, 1049, 218, 3, 2, 2, 2, 1050, 1051, 7, 62, 2, 2, 1051, 220, 3, 2, 2, 2, 1052, 1053, 7, 64, 2, 2, 1053, 222, 3, 2, 2, 2, 1054, 1055, 7, 47, 2, 2, 1055, 1056, 7, 64, 2, 2, 1056, 224, 3, 2, 2, 2, 1057, 1058, 7, 63, 2, 2, 1058, 226, 3, 2, 2, 2, 1059, 1060, 7, 45, 2, 2, 1060, 1061, 7, 63, 2, 2, 1061, 228, 3, 2, 2, 2, 1062, 1063, 7, 47, 2, 2, 1063, 1064, 7, 63, 2, 2, 1064, 230, 3, 2, 2, 2, 1065, 1066, 7, 45, 2, 2, 1066, 232, 3, 2, 2, 2, 1067, 1068, 7, 47, 2, 2, 1068, 234, 3, 2, 2, 2, 1069, 1070, 7, 44, 2, 2, 1070, 236, 3, 2, 2, 2, 1071, 1072, 7, 49, 2, 2, 1072, 238, 3, 2, 2, 2, 1073, 1074, 7, 39, 2, 2, 1074, 240, 3, 2, 2, 2, 1075, 1076, 7, 96, 2, 2, 1076, 242, 3, 2, 2, 2, 1077, 1078, 7, 128, 2, 2, 1078, 244, 3, 2, 2, 2, 1079, 1080, 7, 125, 2, 2, 1080, 246, 3, 2, 2, 2, 1081, 1082, 7, 127, 2, 2, 1082, 248, 3, 2, 2, 2, 1083, 1084, 7, 93, 2, 2, 1084, 250, 3, 2, 2, 2, 1085, 1086, 7, 95, 2, 2, 1086, 252, 3, 2, 2, 2, 1087, 1088, 7, 42, 2, 2, 1088, 254, 3, 2, 2, 2, 1089, 1090, 7, 43, 2, 2, 1090, 256, 3, 2, 2, 2, 1091, 1092, 7, 61, 2, 2, 1092, 258, 3, 2, 2, 2, 1093, 1094, 7, 46, 2, 2, 1094, 260, 3, 2, 2, 2, 1095, 1096, 7, 48, 2, 2, 1096, 262, 3, 2, 2, 2, 1097, 1098, 7, 60, 2, 2, 1098, 264, 3, 2, 2, 2, 1099, 1103, 5, 267, 134, 2, 1100, 1102, 5, 269, 135, 2, 1101, 1100, 3, 2, 2, 2, 1102, 1105, 3, 2, 2, 2, 1103, 1101, 3, 2, 2, 2, 1103, 1104, 3, 2, 2, 2, 1104, 266, 3, 2, 2, 2, 1105, 1103, 3, 2, 2, 2, 1106, 1107, 9, 4, 2, 2, 1107, 268, 3, 2, 2, 2, 1108, 1109, 9, 5, 2, 2, 1109, 270, 3, 2, 2, 2, 1110, 1112, 9, 6, 2, 2, 1111, 1110, 3, 2, 2, 2, 1112, 1113, 3, 2, 2, 2, 1113, 1111, 3, 2, 2, 2, 1113, 1114, 3, 2, 2, 2, 1114, 1115, 3, 2, 2, 2, 1115, 1116, 8, 136, 2, 2, 1116, 272, 3, 2, 2, 2, 1117, 1118, 7, 49, 2, 2, 1118, 1119, 7, 44, 2, 2, 1119, 1123, 3, 2, 2, 2, 1120, 1122, 11, 2, 2, 2, 1121, 1120, 3, 2, 2, 2, 1122, 1125, 3, 2, 2, 2, 1123, 1124, 3, 2, 2, 2, 1123, 1121, 3, 2, 2, 2, 1124, 1126, 3, 2, 2, 2, 1125, 1123, 3, 2, 2, 2, 1126, 1127, 7, 44, 2, 2, 1127, 1128, 7, 49, 2, 2, 1128, 1129, 3, 2, 2, 2, 1129, 1130, 8, 137, 3, 2, 1130, 274, 3, 2, 2, 2, 1131, 1132, 7, 49, 2, 2, 1132, 1133, 7, 49, 2, 2, 1133, 1137, 3, 2, 2, 2, 1134, 1136, 10, 7, 2, 2, 1135, 1134, 3, 2, 2, 2, 1136, 1139, 3, 2, 2, 2, 1137, 1135, 3, 2, 2, 2, 1137, 1138, 3, 2, 2, 2, 1138, 1140, 3, 2, 2, 2, 1139, 1137, 3, 2, 2, 2, 1140, 1141, 8, 138, 3, 2, 1141, 276, 3, 2, 2, 2, 16, 2, 969, 974, 983, 990, 994, 1002, 1008, 1014, 1016, 1103, 1113, 1123, 1137, 4, 8, 2, 2, 2, 3, 2] \ No newline at end of file diff --git a/Celestial/Compiler/CelestialLexer.py b/Celestial/Compiler/CelestialLexer.py new file mode 100644 index 00000000..1127f0dd --- /dev/null +++ b/Celestial/Compiler/CelestialLexer.py @@ -0,0 +1,719 @@ +# Generated from CelestialLexer.g4 by ANTLR 4.7.1 +from antlr4 import * +from io import StringIO +from typing.io import TextIO +import sys + + +def serializedATN(): + with StringIO() as buf: + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2\u0086") + buf.write("\u0476\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7") + buf.write("\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r") + buf.write("\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23") + buf.write("\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30") + buf.write("\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36") + buf.write("\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%") + buf.write("\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.") + buf.write("\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64") + buf.write("\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:") + buf.write("\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\t") + buf.write("C\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I\tI\4J\tJ\4K\tK\4L\t") + buf.write("L\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT\4U\t") + buf.write("U\4V\tV\4W\tW\4X\tX\4Y\tY\4Z\tZ\4[\t[\4\\\t\\\4]\t]\4") + buf.write("^\t^\4_\t_\4`\t`\4a\ta\4b\tb\4c\tc\4d\td\4e\te\4f\tf\4") + buf.write("g\tg\4h\th\4i\ti\4j\tj\4k\tk\4l\tl\4m\tm\4n\tn\4o\to\4") + buf.write("p\tp\4q\tq\4r\tr\4s\ts\4t\tt\4u\tu\4v\tv\4w\tw\4x\tx\4") + buf.write("y\ty\4z\tz\4{\t{\4|\t|\4}\t}\4~\t~\4\177\t\177\4\u0080") + buf.write("\t\u0080\4\u0081\t\u0081\4\u0082\t\u0082\4\u0083\t\u0083") + buf.write("\4\u0084\t\u0084\4\u0085\t\u0085\4\u0086\t\u0086\4\u0087") + buf.write("\t\u0087\4\u0088\t\u0088\4\u0089\t\u0089\4\u008a\t\u008a") + buf.write("\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3") + buf.write("\4\3\4\3\4\3\4\3\4\3\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6") + buf.write("\3\6\3\6\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3") + buf.write("\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n") + buf.write("\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3") + buf.write("\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r") + buf.write("\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17") + buf.write("\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20") + buf.write("\3\20\3\20\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\23\3\23") + buf.write("\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24") + buf.write("\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25") + buf.write("\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26\3\26") + buf.write("\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26") + buf.write("\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27") + buf.write("\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30") + buf.write("\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31") + buf.write("\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31") + buf.write("\3\31\3\32\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33") + buf.write("\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34") + buf.write("\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35") + buf.write("\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36") + buf.write("\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37") + buf.write("\3\37\3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3\"\3\"\3") + buf.write("\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3$\3$\3$\3") + buf.write("$\3$\3%\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'") + buf.write("\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3") + buf.write(")\3)\3)\3)\3*\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3,\3,\3") + buf.write(",\3,\3,\3,\3,\3,\3,\3-\3-\3-\3.\3.\3.\3.\3.\3.\3.\3/\3") + buf.write("/\3/\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\61\3\61") + buf.write("\3\61\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\63") + buf.write("\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\64\3\64") + buf.write("\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65\3\65\3\66\3\66") + buf.write("\3\66\3\66\3\66\3\66\3\66\3\67\3\67\3\67\3\67\38\38\3") + buf.write("8\38\38\38\38\38\38\39\39\39\39\39\39\39\39\39\39\39\3") + buf.write("9\39\39\39\39\39\39\39\3:\3:\3:\3:\3;\3;\3;\3;\3;\3;\3") + buf.write(";\3;\3<\3<\3<\3<\3=\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3>\3") + buf.write("?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3A\3A\3A\3A\3A\3A\3A\3A\3") + buf.write("B\3B\3B\3B\3B\3B\3B\3C\3C\3C\3C\3C\3D\3D\3D\3D\3D\3E\3") + buf.write("E\3E\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3F\3F\3G\3G\3G\3G\3") + buf.write("G\3G\3G\3G\3H\3H\3H\3H\3H\3H\3H\3I\3I\3I\3I\3I\3I\3I\3") + buf.write("I\3I\3I\3J\3J\3J\3J\3J\3J\3J\3J\3J\3K\3K\3K\3K\3K\3K\3") + buf.write("K\3K\3K\3L\3L\3L\3L\3L\3L\3L\3L\3L\3M\3M\3M\3M\3M\3M\3") + buf.write("M\3M\3M\3N\3N\3N\3N\3N\3N\3N\3N\3N\3O\3O\3O\3O\3O\3P\3") + buf.write("P\3P\3P\3P\3P\3P\3Q\3Q\3Q\3Q\3Q\3R\3R\3R\3R\3R\3R\3R\3") + buf.write("S\3S\3S\3S\3S\3T\3T\3T\3T\3T\3T\3T\3T\3T\3U\3U\3U\3U\3") + buf.write("U\3U\3U\3U\3U\3U\3U\3V\3V\3V\3V\3V\3V\3V\3V\3V\3V\3V\3") + buf.write("V\3W\3W\3W\3W\3W\3W\3W\3W\3W\3W\3X\3X\3X\3X\3X\3X\3X\3") + buf.write("X\3X\3Y\3Y\3Y\3Y\3Y\3Y\3Z\3Z\3Z\3Z\3Z\3Z\3[\3[\3[\3[\3") + buf.write("[\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3\\\3\\\5\\\u03ca\n\\\3") + buf.write("]\6]\u03cd\n]\r]\16]\u03ce\3^\3^\3^\3^\3^\3_\3_\5_\u03d8") + buf.write("\n_\3_\3_\3`\6`\u03dd\n`\r`\16`\u03de\3a\3a\5a\u03e3\n") + buf.write("a\3b\3b\3b\3c\6c\u03e9\nc\rc\16c\u03ea\3c\3c\6c\u03ef") + buf.write("\nc\rc\16c\u03f0\3c\3c\6c\u03f5\nc\rc\16c\u03f6\5c\u03f9") + buf.write("\nc\3d\3d\3e\3e\3e\3f\3f\3f\3g\3g\3g\3h\3h\3h\3h\3i\3") + buf.write("i\3i\3i\3i\3j\3j\3j\3k\3k\3k\3l\3l\3l\3m\3m\3m\3n\3n\3") + buf.write("o\3o\3p\3p\3p\3q\3q\3r\3r\3r\3s\3s\3s\3t\3t\3u\3u\3v\3") + buf.write("v\3w\3w\3x\3x\3y\3y\3z\3z\3{\3{\3|\3|\3}\3}\3~\3~\3\177") + buf.write("\3\177\3\u0080\3\u0080\3\u0081\3\u0081\3\u0082\3\u0082") + buf.write("\3\u0083\3\u0083\3\u0084\3\u0084\3\u0085\3\u0085\7\u0085") + buf.write("\u044e\n\u0085\f\u0085\16\u0085\u0451\13\u0085\3\u0086") + buf.write("\3\u0086\3\u0087\3\u0087\3\u0088\6\u0088\u0458\n\u0088") + buf.write("\r\u0088\16\u0088\u0459\3\u0088\3\u0088\3\u0089\3\u0089") + buf.write("\3\u0089\3\u0089\7\u0089\u0462\n\u0089\f\u0089\16\u0089") + buf.write("\u0465\13\u0089\3\u0089\3\u0089\3\u0089\3\u0089\3\u0089") + buf.write("\3\u008a\3\u008a\3\u008a\3\u008a\7\u008a\u0470\n\u008a") + buf.write("\f\u008a\16\u008a\u0473\13\u008a\3\u008a\3\u008a\3\u0463") + buf.write("\2\u008b\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f") + buf.write("\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27") + buf.write("-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%") + buf.write("I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67") + buf.write("m8o9q:s;u{?}@\177A\u0081B\u0083C\u0085D\u0087E\u0089") + buf.write("F\u008bG\u008dH\u008fI\u0091J\u0093K\u0095L\u0097M\u0099") + buf.write("N\u009bO\u009dP\u009fQ\u00a1R\u00a3S\u00a5T\u00a7U\u00a9") + buf.write("V\u00abW\u00adX\u00afY\u00b1Z\u00b3[\u00b5\\\u00b7]\u00b9") + buf.write("^\u00bb_\u00bd`\u00bf\2\u00c1\2\u00c3\2\u00c5a\u00c7b") + buf.write("\u00c9c\u00cbd\u00cde\u00cff\u00d1g\u00d3h\u00d5i\u00d7") + buf.write("j\u00d9k\u00dbl\u00ddm\u00dfn\u00e1o\u00e3p\u00e5q\u00e7") + buf.write("r\u00e9s\u00ebt\u00edu\u00efv\u00f1w\u00f3x\u00f5y\u00f7") + buf.write("z\u00f9{\u00fb|\u00fd}\u00ff~\u0101\177\u0103\u0080\u0105") + buf.write("\u0081\u0107\u0082\u0109\u0083\u010b\2\u010d\2\u010f\u0084") + buf.write("\u0111\u0085\u0113\u0086\3\2\b\3\2\62;\4\2$$^^\5\2C\\") + buf.write("aac|\6\2\62;C\\aac|\5\2\13\f\16\17\"\"\4\2\f\f\17\17\2") + buf.write("\u047d\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2") + buf.write("\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2") + buf.write("\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33") + buf.write("\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2") + buf.write("\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2") + buf.write("\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2") + buf.write("\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2") + buf.write("\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3") + buf.write("\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S") + buf.write("\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2") + buf.write("]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2") + buf.write("\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2") + buf.write("\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2") + buf.write("\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2") + buf.write("\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3\2\2\2\2\u0089") + buf.write("\3\2\2\2\2\u008b\3\2\2\2\2\u008d\3\2\2\2\2\u008f\3\2\2") + buf.write("\2\2\u0091\3\2\2\2\2\u0093\3\2\2\2\2\u0095\3\2\2\2\2\u0097") + buf.write("\3\2\2\2\2\u0099\3\2\2\2\2\u009b\3\2\2\2\2\u009d\3\2\2") + buf.write("\2\2\u009f\3\2\2\2\2\u00a1\3\2\2\2\2\u00a3\3\2\2\2\2\u00a5") + buf.write("\3\2\2\2\2\u00a7\3\2\2\2\2\u00a9\3\2\2\2\2\u00ab\3\2\2") + buf.write("\2\2\u00ad\3\2\2\2\2\u00af\3\2\2\2\2\u00b1\3\2\2\2\2\u00b3") + buf.write("\3\2\2\2\2\u00b5\3\2\2\2\2\u00b7\3\2\2\2\2\u00b9\3\2\2") + buf.write("\2\2\u00bb\3\2\2\2\2\u00bd\3\2\2\2\2\u00c5\3\2\2\2\2\u00c7") + buf.write("\3\2\2\2\2\u00c9\3\2\2\2\2\u00cb\3\2\2\2\2\u00cd\3\2\2") + buf.write("\2\2\u00cf\3\2\2\2\2\u00d1\3\2\2\2\2\u00d3\3\2\2\2\2\u00d5") + buf.write("\3\2\2\2\2\u00d7\3\2\2\2\2\u00d9\3\2\2\2\2\u00db\3\2\2") + buf.write("\2\2\u00dd\3\2\2\2\2\u00df\3\2\2\2\2\u00e1\3\2\2\2\2\u00e3") + buf.write("\3\2\2\2\2\u00e5\3\2\2\2\2\u00e7\3\2\2\2\2\u00e9\3\2\2") + buf.write("\2\2\u00eb\3\2\2\2\2\u00ed\3\2\2\2\2\u00ef\3\2\2\2\2\u00f1") + buf.write("\3\2\2\2\2\u00f3\3\2\2\2\2\u00f5\3\2\2\2\2\u00f7\3\2\2") + buf.write("\2\2\u00f9\3\2\2\2\2\u00fb\3\2\2\2\2\u00fd\3\2\2\2\2\u00ff") + buf.write("\3\2\2\2\2\u0101\3\2\2\2\2\u0103\3\2\2\2\2\u0105\3\2\2") + buf.write("\2\2\u0107\3\2\2\2\2\u0109\3\2\2\2\2\u010f\3\2\2\2\2\u0111") + buf.write("\3\2\2\2\2\u0113\3\2\2\2\3\u0115\3\2\2\2\5\u011d\3\2\2") + buf.write("\2\7\u0122\3\2\2\2\t\u0127\3\2\2\2\13\u012d\3\2\2\2\r") + buf.write("\u0136\3\2\2\2\17\u013b\3\2\2\2\21\u0141\3\2\2\2\23\u014a") + buf.write("\3\2\2\2\25\u014e\3\2\2\2\27\u0155\3\2\2\2\31\u015e\3") + buf.write("\2\2\2\33\u0166\3\2\2\2\35\u016c\3\2\2\2\37\u0174\3\2") + buf.write("\2\2!\u017c\3\2\2\2#\u0180\3\2\2\2%\u0183\3\2\2\2\'\u018a") + buf.write("\3\2\2\2)\u0192\3\2\2\2+\u01a1\3\2\2\2-\u01b2\3\2\2\2") + buf.write("/\u01c1\3\2\2\2\61\u01ce\3\2\2\2\63\u01de\3\2\2\2\65\u01e3") + buf.write("\3\2\2\2\67\u01ed\3\2\2\29\u01f7\3\2\2\2;\u0200\3\2\2") + buf.write("\2=\u020c\3\2\2\2?\u0215\3\2\2\2A\u021c\3\2\2\2C\u0222") + buf.write("\3\2\2\2E\u022a\3\2\2\2G\u0231\3\2\2\2I\u0236\3\2\2\2") + buf.write("K\u023b\3\2\2\2M\u0245\3\2\2\2O\u024c\3\2\2\2Q\u0255\3") + buf.write("\2\2\2S\u0259\3\2\2\2U\u0260\3\2\2\2W\u0265\3\2\2\2Y\u026e") + buf.write("\3\2\2\2[\u0271\3\2\2\2]\u0278\3\2\2\2_\u027b\3\2\2\2") + buf.write("a\u0283\3\2\2\2c\u028b\3\2\2\2e\u028f\3\2\2\2g\u0299\3") + buf.write("\2\2\2i\u029e\3\2\2\2k\u02a4\3\2\2\2m\u02ab\3\2\2\2o\u02af") + buf.write("\3\2\2\2q\u02b8\3\2\2\2s\u02cb\3\2\2\2u\u02cf\3\2\2\2") + buf.write("w\u02d7\3\2\2\2y\u02db\3\2\2\2{\u02e0\3\2\2\2}\u02e7\3") + buf.write("\2\2\2\177\u02eb\3\2\2\2\u0081\u02f1\3\2\2\2\u0083\u02f9") + buf.write("\3\2\2\2\u0085\u0300\3\2\2\2\u0087\u0305\3\2\2\2\u0089") + buf.write("\u030a\3\2\2\2\u008b\u0312\3\2\2\2\u008d\u0319\3\2\2\2") + buf.write("\u008f\u0321\3\2\2\2\u0091\u0328\3\2\2\2\u0093\u0332\3") + buf.write("\2\2\2\u0095\u033b\3\2\2\2\u0097\u0344\3\2\2\2\u0099\u034d") + buf.write("\3\2\2\2\u009b\u0356\3\2\2\2\u009d\u035f\3\2\2\2\u009f") + buf.write("\u0364\3\2\2\2\u00a1\u036b\3\2\2\2\u00a3\u0370\3\2\2\2") + buf.write("\u00a5\u0377\3\2\2\2\u00a7\u037c\3\2\2\2\u00a9\u0385\3") + buf.write("\2\2\2\u00ab\u0390\3\2\2\2\u00ad\u039c\3\2\2\2\u00af\u03a6") + buf.write("\3\2\2\2\u00b1\u03af\3\2\2\2\u00b3\u03b5\3\2\2\2\u00b5") + buf.write("\u03bb\3\2\2\2\u00b7\u03c9\3\2\2\2\u00b9\u03cc\3\2\2\2") + buf.write("\u00bb\u03d0\3\2\2\2\u00bd\u03d5\3\2\2\2\u00bf\u03dc\3") + buf.write("\2\2\2\u00c1\u03e2\3\2\2\2\u00c3\u03e4\3\2\2\2\u00c5\u03e8") + buf.write("\3\2\2\2\u00c7\u03fa\3\2\2\2\u00c9\u03fc\3\2\2\2\u00cb") + buf.write("\u03ff\3\2\2\2\u00cd\u0402\3\2\2\2\u00cf\u0405\3\2\2\2") + buf.write("\u00d1\u0409\3\2\2\2\u00d3\u040e\3\2\2\2\u00d5\u0411\3") + buf.write("\2\2\2\u00d7\u0414\3\2\2\2\u00d9\u0417\3\2\2\2\u00db\u041a") + buf.write("\3\2\2\2\u00dd\u041c\3\2\2\2\u00df\u041e\3\2\2\2\u00e1") + buf.write("\u0421\3\2\2\2\u00e3\u0423\3\2\2\2\u00e5\u0426\3\2\2\2") + buf.write("\u00e7\u0429\3\2\2\2\u00e9\u042b\3\2\2\2\u00eb\u042d\3") + buf.write("\2\2\2\u00ed\u042f\3\2\2\2\u00ef\u0431\3\2\2\2\u00f1\u0433") + buf.write("\3\2\2\2\u00f3\u0435\3\2\2\2\u00f5\u0437\3\2\2\2\u00f7") + buf.write("\u0439\3\2\2\2\u00f9\u043b\3\2\2\2\u00fb\u043d\3\2\2\2") + buf.write("\u00fd\u043f\3\2\2\2\u00ff\u0441\3\2\2\2\u0101\u0443\3") + buf.write("\2\2\2\u0103\u0445\3\2\2\2\u0105\u0447\3\2\2\2\u0107\u0449") + buf.write("\3\2\2\2\u0109\u044b\3\2\2\2\u010b\u0452\3\2\2\2\u010d") + buf.write("\u0454\3\2\2\2\u010f\u0457\3\2\2\2\u0111\u045d\3\2\2\2") + buf.write("\u0113\u046b\3\2\2\2\u0115\u0116\7c\2\2\u0116\u0117\7") + buf.write("f\2\2\u0117\u0118\7f\2\2\u0118\u0119\7t\2\2\u0119\u011a") + buf.write("\7g\2\2\u011a\u011b\7u\2\2\u011b\u011c\7u\2\2\u011c\4") + buf.write("\3\2\2\2\u011d\u011e\7d\2\2\u011e\u011f\7q\2\2\u011f\u0120") + buf.write("\7q\2\2\u0120\u0121\7n\2\2\u0121\6\3\2\2\2\u0122\u0123") + buf.write("\7g\2\2\u0123\u0124\7p\2\2\u0124\u0125\7w\2\2\u0125\u0126") + buf.write("\7o\2\2\u0126\b\3\2\2\2\u0127\u0128\7g\2\2\u0128\u0129") + buf.write("\7x\2\2\u0129\u012a\7g\2\2\u012a\u012b\7p\2\2\u012b\u012c") + buf.write("\7v\2\2\u012c\n\3\2\2\2\u012d\u012e\7g\2\2\u012e\u012f") + buf.write("\7x\2\2\u012f\u0130\7g\2\2\u0130\u0131\7p\2\2\u0131\u0132") + buf.write("\7v\2\2\u0132\u0133\7n\2\2\u0133\u0134\7q\2\2\u0134\u0135") + buf.write("\7i\2\2\u0135\f\3\2\2\2\u0136\u0137\7w\2\2\u0137\u0138") + buf.write("\7k\2\2\u0138\u0139\7p\2\2\u0139\u013a\7v\2\2\u013a\16") + buf.write("\3\2\2\2\u013b\u013c\7w\2\2\u013c\u013d\7k\2\2\u013d\u013e") + buf.write("\7p\2\2\u013e\u013f\7v\2\2\u013f\u0140\7:\2\2\u0140\20") + buf.write("\3\2\2\2\u0141\u0142\7k\2\2\u0142\u0143\7p\2\2\u0143\u0144") + buf.write("\7u\2\2\u0144\u0145\7v\2\2\u0145\u0146\7a\2\2\u0146\u0147") + buf.write("\7o\2\2\u0147\u0148\7c\2\2\u0148\u0149\7r\2\2\u0149\22") + buf.write("\3\2\2\2\u014a\u014b\7k\2\2\u014b\u014c\7p\2\2\u014c\u014d") + buf.write("\7v\2\2\u014d\24\3\2\2\2\u014e\u014f\7u\2\2\u014f\u0150") + buf.write("\7v\2\2\u0150\u0151\7t\2\2\u0151\u0152\7k\2\2\u0152\u0153") + buf.write("\7p\2\2\u0153\u0154\7i\2\2\u0154\26\3\2\2\2\u0155\u0156") + buf.write("\7e\2\2\u0156\u0157\7q\2\2\u0157\u0158\7p\2\2\u0158\u0159") + buf.write("\7v\2\2\u0159\u015a\7t\2\2\u015a\u015b\7c\2\2\u015b\u015c") + buf.write("\7e\2\2\u015c\u015d\7v\2\2\u015d\30\3\2\2\2\u015e\u015f") + buf.write("\7o\2\2\u015f\u0160\7c\2\2\u0160\u0161\7r\2\2\u0161\u0162") + buf.write("\7r\2\2\u0162\u0163\7k\2\2\u0163\u0164\7p\2\2\u0164\u0165") + buf.write("\7i\2\2\u0165\32\3\2\2\2\u0166\u0167\7d\2\2\u0167\u0168") + buf.write("\7{\2\2\u0168\u0169\7v\2\2\u0169\u016a\7g\2\2\u016a\u016b") + buf.write("\7u\2\2\u016b\34\3\2\2\2\u016c\u016d\7d\2\2\u016d\u016e") + buf.write("\7{\2\2\u016e\u016f\7v\2\2\u016f\u0170\7g\2\2\u0170\u0171") + buf.write("\7u\2\2\u0171\u0172\7\64\2\2\u0172\u0173\7\62\2\2\u0173") + buf.write("\36\3\2\2\2\u0174\u0175\7d\2\2\u0175\u0176\7{\2\2\u0176") + buf.write("\u0177\7v\2\2\u0177\u0178\7g\2\2\u0178\u0179\7u\2\2\u0179") + buf.write("\u017a\7\65\2\2\u017a\u017b\7\64\2\2\u017b \3\2\2\2\u017c") + buf.write("\u017d\7c\2\2\u017d\u017e\7f\2\2\u017e\u017f\7f\2\2\u017f") + buf.write("\"\3\2\2\2\u0180\u0181\7c\2\2\u0181\u0182\7u\2\2\u0182") + buf.write("$\3\2\2\2\u0183\u0184\7c\2\2\u0184\u0185\7u\2\2\u0185") + buf.write("\u0186\7u\2\2\u0186\u0187\7g\2\2\u0187\u0188\7t\2\2\u0188") + buf.write("\u0189\7v\2\2\u0189&\3\2\2\2\u018a\u018b\7d\2\2\u018b") + buf.write("\u018c\7c\2\2\u018c\u018d\7n\2\2\u018d\u018e\7c\2\2\u018e") + buf.write("\u018f\7p\2\2\u018f\u0190\7e\2\2\u0190\u0191\7g\2\2\u0191") + buf.write("(\3\2\2\2\u0192\u0193\7d\2\2\u0193\u0194\7n\2\2\u0194") + buf.write("\u0195\7q\2\2\u0195\u0196\7e\2\2\u0196\u0197\7m\2\2\u0197") + buf.write("\u0198\7\60\2\2\u0198\u0199\7e\2\2\u0199\u019a\7q\2\2") + buf.write("\u019a\u019b\7k\2\2\u019b\u019c\7p\2\2\u019c\u019d\7d") + buf.write("\2\2\u019d\u019e\7c\2\2\u019e\u019f\7u\2\2\u019f\u01a0") + buf.write("\7g\2\2\u01a0*\3\2\2\2\u01a1\u01a2\7d\2\2\u01a2\u01a3") + buf.write("\7n\2\2\u01a3\u01a4\7q\2\2\u01a4\u01a5\7e\2\2\u01a5\u01a6") + buf.write("\7m\2\2\u01a6\u01a7\7\60\2\2\u01a7\u01a8\7f\2\2\u01a8") + buf.write("\u01a9\7k\2\2\u01a9\u01aa\7h\2\2\u01aa\u01ab\7h\2\2\u01ab") + buf.write("\u01ac\7k\2\2\u01ac\u01ad\7e\2\2\u01ad\u01ae\7w\2\2\u01ae") + buf.write("\u01af\7n\2\2\u01af\u01b0\7v\2\2\u01b0\u01b1\7{\2\2\u01b1") + buf.write(",\3\2\2\2\u01b2\u01b3\7d\2\2\u01b3\u01b4\7n\2\2\u01b4") + buf.write("\u01b5\7q\2\2\u01b5\u01b6\7e\2\2\u01b6\u01b7\7m\2\2\u01b7") + buf.write("\u01b8\7\60\2\2\u01b8\u01b9\7i\2\2\u01b9\u01ba\7c\2\2") + buf.write("\u01ba\u01bb\7u\2\2\u01bb\u01bc\7n\2\2\u01bc\u01bd\7k") + buf.write("\2\2\u01bd\u01be\7o\2\2\u01be\u01bf\7k\2\2\u01bf\u01c0") + buf.write("\7v\2\2\u01c0.\3\2\2\2\u01c1\u01c2\7d\2\2\u01c2\u01c3") + buf.write("\7n\2\2\u01c3\u01c4\7q\2\2\u01c4\u01c5\7e\2\2\u01c5\u01c6") + buf.write("\7m\2\2\u01c6\u01c7\7\60\2\2\u01c7\u01c8\7p\2\2\u01c8") + buf.write("\u01c9\7w\2\2\u01c9\u01ca\7o\2\2\u01ca\u01cb\7d\2\2\u01cb") + buf.write("\u01cc\7g\2\2\u01cc\u01cd\7t\2\2\u01cd\60\3\2\2\2\u01ce") + buf.write("\u01cf\7d\2\2\u01cf\u01d0\7n\2\2\u01d0\u01d1\7q\2\2\u01d1") + buf.write("\u01d2\7e\2\2\u01d2\u01d3\7m\2\2\u01d3\u01d4\7\60\2\2") + buf.write("\u01d4\u01d5\7v\2\2\u01d5\u01d6\7k\2\2\u01d6\u01d7\7o") + buf.write("\2\2\u01d7\u01d8\7g\2\2\u01d8\u01d9\7u\2\2\u01d9\u01da") + buf.write("\7v\2\2\u01da\u01db\7c\2\2\u01db\u01dc\7o\2\2\u01dc\u01dd") + buf.write("\7r\2\2\u01dd\62\3\2\2\2\u01de\u01df\7e\2\2\u01df\u01e0") + buf.write("\7c\2\2\u01e0\u01e1\7n\2\2\u01e1\u01e2\7n\2\2\u01e2\64") + buf.write("\3\2\2\2\u01e3\u01e4\7e\2\2\u01e4\u01e5\7c\2\2\u01e5\u01e6") + buf.write("\7n\2\2\u01e6\u01e7\7n\2\2\u01e7\u01e8\7a\2\2\u01e8\u01e9") + buf.write("\7d\2\2\u01e9\u01ea\7q\2\2\u01ea\u01eb\7q\2\2\u01eb\u01ec") + buf.write("\7n\2\2\u01ec\66\3\2\2\2\u01ed\u01ee\7e\2\2\u01ee\u01ef") + buf.write("\7c\2\2\u01ef\u01f0\7n\2\2\u01f0\u01f1\7n\2\2\u01f1\u01f2") + buf.write("\7a\2\2\u01f2\u01f3\7w\2\2\u01f3\u01f4\7k\2\2\u01f4\u01f5") + buf.write("\7p\2\2\u01f5\u01f6\7v\2\2\u01f68\3\2\2\2\u01f7\u01f8") + buf.write("\7e\2\2\u01f8\u01f9\7q\2\2\u01f9\u01fa\7p\2\2\u01fa\u01fb") + buf.write("\7u\2\2\u01fb\u01fc\7v\2\2\u01fc\u01fd\7c\2\2\u01fd\u01fe") + buf.write("\7p\2\2\u01fe\u01ff\7v\2\2\u01ff:\3\2\2\2\u0200\u0201") + buf.write("\7e\2\2\u0201\u0202\7q\2\2\u0202\u0203\7p\2\2\u0203\u0204") + buf.write("\7u\2\2\u0204\u0205\7v\2\2\u0205\u0206\7t\2\2\u0206\u0207") + buf.write("\7w\2\2\u0207\u0208\7e\2\2\u0208\u0209\7v\2\2\u0209\u020a") + buf.write("\7q\2\2\u020a\u020b\7t\2\2\u020b<\3\2\2\2\u020c\u020d") + buf.write("\7e\2\2\u020d\u020e\7q\2\2\u020e\u020f\7p\2\2\u020f\u0210") + buf.write("\7v\2\2\u0210\u0211\7c\2\2\u0211\u0212\7k\2\2\u0212\u0213") + buf.write("\7p\2\2\u0213\u0214\7u\2\2\u0214>\3\2\2\2\u0215\u0216") + buf.write("\7e\2\2\u0216\u0217\7t\2\2\u0217\u0218\7g\2\2\u0218\u0219") + buf.write("\7f\2\2\u0219\u021a\7k\2\2\u021a\u021b\7v\2\2\u021b@\3") + buf.write("\2\2\2\u021c\u021d\7f\2\2\u021d\u021e\7g\2\2\u021e\u021f") + buf.write("\7d\2\2\u021f\u0220\7k\2\2\u0220\u0221\7v\2\2\u0221B\3") + buf.write("\2\2\2\u0222\u0223\7f\2\2\u0223\u0224\7g\2\2\u0224\u0225") + buf.write("\7h\2\2\u0225\u0226\7c\2\2\u0226\u0227\7w\2\2\u0227\u0228") + buf.write("\7n\2\2\u0228\u0229\7v\2\2\u0229D\3\2\2\2\u022a\u022b") + buf.write("\7f\2\2\u022b\u022c\7g\2\2\u022c\u022d\7n\2\2\u022d\u022e") + buf.write("\7g\2\2\u022e\u022f\7v\2\2\u022f\u0230\7g\2\2\u0230F\3") + buf.write("\2\2\2\u0231\u0232\7g\2\2\u0232\u0233\7n\2\2\u0233\u0234") + buf.write("\7u\2\2\u0234\u0235\7g\2\2\u0235H\3\2\2\2\u0236\u0237") + buf.write("\7g\2\2\u0237\u0238\7o\2\2\u0238\u0239\7k\2\2\u0239\u023a") + buf.write("\7v\2\2\u023aJ\3\2\2\2\u023b\u023c\7g\2\2\u023c\u023d") + buf.write("\7V\2\2\u023d\u023e\7t\2\2\u023e\u023f\7c\2\2\u023f\u0240") + buf.write("\7p\2\2\u0240\u0241\7u\2\2\u0241\u0242\7h\2\2\u0242\u0243") + buf.write("\7g\2\2\u0243\u0244\7t\2\2\u0244L\3\2\2\2\u0245\u0246") + buf.write("\7g\2\2\u0246\u0247\7z\2\2\u0247\u0248\7k\2\2\u0248\u0249") + buf.write("\7u\2\2\u0249\u024a\7v\2\2\u024a\u024b\7u\2\2\u024bN\3") + buf.write("\2\2\2\u024c\u024d\7h\2\2\u024d\u024e\7c\2\2\u024e\u024f") + buf.write("\7n\2\2\u024f\u0250\7n\2\2\u0250\u0251\7d\2\2\u0251\u0252") + buf.write("\7c\2\2\u0252\u0253\7e\2\2\u0253\u0254\7m\2\2\u0254P\3") + buf.write("\2\2\2\u0255\u0256\7h\2\2\u0256\u0257\7q\2\2\u0257\u0258") + buf.write("\7t\2\2\u0258R\3\2\2\2\u0259\u025a\7h\2\2\u025a\u025b") + buf.write("\7q\2\2\u025b\u025c\7t\2\2\u025c\u025d\7c\2\2\u025d\u025e") + buf.write("\7n\2\2\u025e\u025f\7n\2\2\u025fT\3\2\2\2\u0260\u0261") + buf.write("\7h\2\2\u0261\u0262\7t\2\2\u0262\u0263\7q\2\2\u0263\u0264") + buf.write("\7o\2\2\u0264V\3\2\2\2\u0265\u0266\7h\2\2\u0266\u0267") + buf.write("\7w\2\2\u0267\u0268\7p\2\2\u0268\u0269\7e\2\2\u0269\u026a") + buf.write("\7v\2\2\u026a\u026b\7k\2\2\u026b\u026c\7q\2\2\u026c\u026d") + buf.write("\7p\2\2\u026dX\3\2\2\2\u026e\u026f\7k\2\2\u026f\u0270") + buf.write("\7h\2\2\u0270Z\3\2\2\2\u0271\u0272\7k\2\2\u0272\u0273") + buf.write("\7o\2\2\u0273\u0274\7r\2\2\u0274\u0275\7q\2\2\u0275\u0276") + buf.write("\7t\2\2\u0276\u0277\7v\2\2\u0277\\\3\2\2\2\u0278\u0279") + buf.write("\7k\2\2\u0279\u027a\7p\2\2\u027a^\3\2\2\2\u027b\u027c") + buf.write("\7k\2\2\u027c\u027d\7p\2\2\u027d\u027e\7v\2\2\u027e\u027f") + buf.write("\7a\2\2\u027f\u0280\7o\2\2\u0280\u0281\7k\2\2\u0281\u0282") + buf.write("\7p\2\2\u0282`\3\2\2\2\u0283\u0284\7k\2\2\u0284\u0285") + buf.write("\7p\2\2\u0285\u0286\7v\2\2\u0286\u0287\7a\2\2\u0287\u0288") + buf.write("\7o\2\2\u0288\u0289\7c\2\2\u0289\u028a\7z\2\2\u028ab\3") + buf.write("\2\2\2\u028b\u028c\7k\2\2\u028c\u028d\7v\2\2\u028d\u028e") + buf.write("\7g\2\2\u028ed\3\2\2\2\u028f\u0290\7k\2\2\u0290\u0291") + buf.write("\7p\2\2\u0291\u0292\7x\2\2\u0292\u0293\7c\2\2\u0293\u0294") + buf.write("\7t\2\2\u0294\u0295\7k\2\2\u0295\u0296\7c\2\2\u0296\u0297") + buf.write("\7p\2\2\u0297\u0298\7v\2\2\u0298f\3\2\2\2\u0299\u029a") + buf.write("\7m\2\2\u029a\u029b\7g\2\2\u029b\u029c\7{\2\2\u029c\u029d") + buf.write("\7u\2\2\u029dh\3\2\2\2\u029e\u029f\7n\2\2\u029f\u02a0") + buf.write("\7g\2\2\u02a0\u02a1\7o\2\2\u02a1\u02a2\7o\2\2\u02a2\u02a3") + buf.write("\7c\2\2\u02a3j\3\2\2\2\u02a4\u02a5\7n\2\2\u02a5\u02a6") + buf.write("\7g\2\2\u02a6\u02a7\7p\2\2\u02a7\u02a8\7i\2\2\u02a8\u02a9") + buf.write("\7v\2\2\u02a9\u02aa\7j\2\2\u02aal\3\2\2\2\u02ab\u02ac") + buf.write("\7n\2\2\u02ac\u02ad\7q\2\2\u02ad\u02ae\7i\2\2\u02aen\3") + buf.write("\2\2\2\u02af\u02b0\7o\2\2\u02b0\u02b1\7q\2\2\u02b1\u02b2") + buf.write("\7f\2\2\u02b2\u02b3\7k\2\2\u02b3\u02b4\7h\2\2\u02b4\u02b5") + buf.write("\7k\2\2\u02b5\u02b6\7g\2\2\u02b6\u02b7\7u\2\2\u02b7p\3") + buf.write("\2\2\2\u02b8\u02b9\7o\2\2\u02b9\u02ba\7q\2\2\u02ba\u02bb") + buf.write("\7f\2\2\u02bb\u02bc\7k\2\2\u02bc\u02bd\7h\2\2\u02bd\u02be") + buf.write("\7k\2\2\u02be\u02bf\7g\2\2\u02bf\u02c0\7u\2\2\u02c0\u02c1") + buf.write("\7a\2\2\u02c1\u02c2\7c\2\2\u02c2\u02c3\7f\2\2\u02c3\u02c4") + buf.write("\7f\2\2\u02c4\u02c5\7t\2\2\u02c5\u02c6\7g\2\2\u02c6\u02c7") + buf.write("\7u\2\2\u02c7\u02c8\7u\2\2\u02c8\u02c9\7g\2\2\u02c9\u02ca") + buf.write("\7u\2\2\u02car\3\2\2\2\u02cb\u02cc\7p\2\2\u02cc\u02cd") + buf.write("\7g\2\2\u02cd\u02ce\7y\2\2\u02cet\3\2\2\2\u02cf\u02d0") + buf.write("\7r\2\2\u02d0\u02d1\7c\2\2\u02d1\u02d2\7{\2\2\u02d2\u02d3") + buf.write("\7c\2\2\u02d3\u02d4\7d\2\2\u02d4\u02d5\7n\2\2\u02d5\u02d6") + buf.write("\7g\2\2\u02d6v\3\2\2\2\u02d7\u02d8\7r\2\2\u02d8\u02d9") + buf.write("\7q\2\2\u02d9\u02da\7r\2\2\u02dax\3\2\2\2\u02db\u02dc") + buf.write("\7r\2\2\u02dc\u02dd\7q\2\2\u02dd\u02de\7u\2\2\u02de\u02df") + buf.write("\7v\2\2\u02dfz\3\2\2\2\u02e0\u02e1\7r\2\2\u02e1\u02e2") + buf.write("\7t\2\2\u02e2\u02e3\7c\2\2\u02e3\u02e4\7i\2\2\u02e4\u02e5") + buf.write("\7o\2\2\u02e5\u02e6\7c\2\2\u02e6|\3\2\2\2\u02e7\u02e8") + buf.write("\7r\2\2\u02e8\u02e9\7t\2\2\u02e9\u02ea\7g\2\2\u02ea~\3") + buf.write("\2\2\2\u02eb\u02ec\7r\2\2\u02ec\u02ed\7t\2\2\u02ed\u02ee") + buf.write("\7k\2\2\u02ee\u02ef\7p\2\2\u02ef\u02f0\7v\2\2\u02f0\u0080") + buf.write("\3\2\2\2\u02f1\u02f2\7r\2\2\u02f2\u02f3\7t\2\2\u02f3\u02f4") + buf.write("\7k\2\2\u02f4\u02f5\7x\2\2\u02f5\u02f6\7c\2\2\u02f6\u02f7") + buf.write("\7v\2\2\u02f7\u02f8\7g\2\2\u02f8\u0082\3\2\2\2\u02f9\u02fa") + buf.write("\7r\2\2\u02fa\u02fb\7w\2\2\u02fb\u02fc\7d\2\2\u02fc\u02fd") + buf.write("\7n\2\2\u02fd\u02fe\7k\2\2\u02fe\u02ff\7e\2\2\u02ff\u0084") + buf.write("\3\2\2\2\u0300\u0301\7r\2\2\u0301\u0302\7w\2\2\u0302\u0303") + buf.write("\7t\2\2\u0303\u0304\7g\2\2\u0304\u0086\3\2\2\2\u0305\u0306") + buf.write("\7r\2\2\u0306\u0307\7w\2\2\u0307\u0308\7u\2\2\u0308\u0309") + buf.write("\7j\2\2\u0309\u0088\3\2\2\2\u030a\u030b\7t\2\2\u030b\u030c") + buf.write("\7g\2\2\u030c\u030d\7e\2\2\u030d\u030e\7g\2\2\u030e\u030f") + buf.write("\7k\2\2\u030f\u0310\7x\2\2\u0310\u0311\7g\2\2\u0311\u008a") + buf.write("\3\2\2\2\u0312\u0313\7t\2\2\u0313\u0314\7g\2\2\u0314\u0315") + buf.write("\7v\2\2\u0315\u0316\7w\2\2\u0316\u0317\7t\2\2\u0317\u0318") + buf.write("\7p\2\2\u0318\u008c\3\2\2\2\u0319\u031a\7t\2\2\u031a\u031b") + buf.write("\7g\2\2\u031b\u031c\7v\2\2\u031c\u031d\7w\2\2\u031d\u031e") + buf.write("\7t\2\2\u031e\u031f\7p\2\2\u031f\u0320\7u\2\2\u0320\u008e") + buf.write("\3\2\2\2\u0321\u0322\7t\2\2\u0322\u0323\7g\2\2\u0323\u0324") + buf.write("\7x\2\2\u0324\u0325\7g\2\2\u0325\u0326\7t\2\2\u0326\u0327") + buf.write("\7v\2\2\u0327\u0090\3\2\2\2\u0328\u0329\7t\2\2\u0329\u032a") + buf.write("\7a\2\2\u032a\u032b\7t\2\2\u032b\u032c\7g\2\2\u032c\u032d") + buf.write("\7x\2\2\u032d\u032e\7g\2\2\u032e\u032f\7t\2\2\u032f\u0330") + buf.write("\7v\2\2\u0330\u0331\7u\2\2\u0331\u0092\3\2\2\2\u0332\u0333") + buf.write("\7u\2\2\u0333\u0334\7c\2\2\u0334\u0335\7h\2\2\u0335\u0336") + buf.write("\7g\2\2\u0336\u0337\7a\2\2\u0337\u0338\7c\2\2\u0338\u0339") + buf.write("\7f\2\2\u0339\u033a\7f\2\2\u033a\u0094\3\2\2\2\u033b\u033c") + buf.write("\7u\2\2\u033c\u033d\7c\2\2\u033d\u033e\7h\2\2\u033e\u033f") + buf.write("\7g\2\2\u033f\u0340\7a\2\2\u0340\u0341\7f\2\2\u0341\u0342") + buf.write("\7k\2\2\u0342\u0343\7x\2\2\u0343\u0096\3\2\2\2\u0344\u0345") + buf.write("\7u\2\2\u0345\u0346\7c\2\2\u0346\u0347\7h\2\2\u0347\u0348") + buf.write("\7g\2\2\u0348\u0349\7a\2\2\u0349\u034a\7o\2\2\u034a\u034b") + buf.write("\7q\2\2\u034b\u034c\7f\2\2\u034c\u0098\3\2\2\2\u034d\u034e") + buf.write("\7u\2\2\u034e\u034f\7c\2\2\u034f\u0350\7h\2\2\u0350\u0351") + buf.write("\7g\2\2\u0351\u0352\7a\2\2\u0352\u0353\7o\2\2\u0353\u0354") + buf.write("\7w\2\2\u0354\u0355\7n\2\2\u0355\u009a\3\2\2\2\u0356\u0357") + buf.write("\7u\2\2\u0357\u0358\7c\2\2\u0358\u0359\7h\2\2\u0359\u035a") + buf.write("\7g\2\2\u035a\u035b\7a\2\2\u035b\u035c\7u\2\2\u035c\u035d") + buf.write("\7w\2\2\u035d\u035e\7d\2\2\u035e\u009c\3\2\2\2\u035f\u0360") + buf.write("\7u\2\2\u0360\u0361\7g\2\2\u0361\u0362\7p\2\2\u0362\u0363") + buf.write("\7f\2\2\u0363\u009e\3\2\2\2\u0364\u0365\7u\2\2\u0365\u0366") + buf.write("\7g\2\2\u0366\u0367\7p\2\2\u0367\u0368\7f\2\2\u0368\u0369") + buf.write("\7g\2\2\u0369\u036a\7t\2\2\u036a\u00a0\3\2\2\2\u036b\u036c") + buf.write("\7u\2\2\u036c\u036d\7r\2\2\u036d\u036e\7g\2\2\u036e\u036f") + buf.write("\7e\2\2\u036f\u00a2\3\2\2\2\u0370\u0371\7u\2\2\u0371\u0372") + buf.write("\7v\2\2\u0372\u0373\7t\2\2\u0373\u0374\7w\2\2\u0374\u0375") + buf.write("\7e\2\2\u0375\u0376\7v\2\2\u0376\u00a4\3\2\2\2\u0377\u0378") + buf.write("\7v\2\2\u0378\u0379\7j\2\2\u0379\u037a\7k\2\2\u037a\u037b") + buf.write("\7u\2\2\u037b\u00a6\3\2\2\2\u037c\u037d\7v\2\2\u037d\u037e") + buf.write("\7t\2\2\u037e\u037f\7c\2\2\u037f\u0380\7p\2\2\u0380\u0381") + buf.write("\7u\2\2\u0381\u0382\7h\2\2\u0382\u0383\7g\2\2\u0383\u0384") + buf.write("\7t\2\2\u0384\u00a8\3\2\2\2\u0385\u0386\7v\2\2\u0386\u0387") + buf.write("\7z\2\2\u0387\u0388\7a\2\2\u0388\u0389\7t\2\2\u0389\u038a") + buf.write("\7g\2\2\u038a\u038b\7x\2\2\u038b\u038c\7g\2\2\u038c\u038d") + buf.write("\7t\2\2\u038d\u038e\7v\2\2\u038e\u038f\7u\2\2\u038f\u00aa") + buf.write("\3\2\2\2\u0390\u0391\7v\2\2\u0391\u0392\7z\2\2\u0392\u0393") + buf.write("\7\60\2\2\u0393\u0394\7i\2\2\u0394\u0395\7c\2\2\u0395") + buf.write("\u0396\7u\2\2\u0396\u0397\7r\2\2\u0397\u0398\7t\2\2\u0398") + buf.write("\u0399\7k\2\2\u0399\u039a\7e\2\2\u039a\u039b\7g\2\2\u039b") + buf.write("\u00ac\3\2\2\2\u039c\u039d\7v\2\2\u039d\u039e\7z\2\2\u039e") + buf.write("\u039f\7\60\2\2\u039f\u03a0\7q\2\2\u03a0\u03a1\7t\2\2") + buf.write("\u03a1\u03a2\7k\2\2\u03a2\u03a3\7i\2\2\u03a3\u03a4\7k") + buf.write("\2\2\u03a4\u03a5\7p\2\2\u03a5\u00ae\3\2\2\2\u03a6\u03a7") + buf.write("\7w\2\2\u03a7\u03a8\7k\2\2\u03a8\u03a9\7p\2\2\u03a9\u03aa") + buf.write("\7v\2\2\u03aa\u03ab\7a\2\2\u03ab\u03ac\7o\2\2\u03ac\u03ad") + buf.write("\7c\2\2\u03ad\u03ae\7z\2\2\u03ae\u00b0\3\2\2\2\u03af\u03b0") + buf.write("\7w\2\2\u03b0\u03b1\7u\2\2\u03b1\u03b2\7k\2\2\u03b2\u03b3") + buf.write("\7p\2\2\u03b3\u03b4\7i\2\2\u03b4\u00b2\3\2\2\2\u03b5\u03b6") + buf.write("\7x\2\2\u03b6\u03b7\7c\2\2\u03b7\u03b8\7n\2\2\u03b8\u03b9") + buf.write("\7w\2\2\u03b9\u03ba\7g\2\2\u03ba\u00b4\3\2\2\2\u03bb\u03bc") + buf.write("\7x\2\2\u03bc\u03bd\7k\2\2\u03bd\u03be\7g\2\2\u03be\u03bf") + buf.write("\7y\2\2\u03bf\u00b6\3\2\2\2\u03c0\u03c1\7v\2\2\u03c1\u03c2") + buf.write("\7t\2\2\u03c2\u03c3\7w\2\2\u03c3\u03ca\7g\2\2\u03c4\u03c5") + buf.write("\7h\2\2\u03c5\u03c6\7c\2\2\u03c6\u03c7\7n\2\2\u03c7\u03c8") + buf.write("\7u\2\2\u03c8\u03ca\7g\2\2\u03c9\u03c0\3\2\2\2\u03c9\u03c4") + buf.write("\3\2\2\2\u03ca\u00b8\3\2\2\2\u03cb\u03cd\t\2\2\2\u03cc") + buf.write("\u03cb\3\2\2\2\u03cd\u03ce\3\2\2\2\u03ce\u03cc\3\2\2\2") + buf.write("\u03ce\u03cf\3\2\2\2\u03cf\u00ba\3\2\2\2\u03d0\u03d1\7") + buf.write("p\2\2\u03d1\u03d2\7w\2\2\u03d2\u03d3\7n\2\2\u03d3\u03d4") + buf.write("\7n\2\2\u03d4\u00bc\3\2\2\2\u03d5\u03d7\7$\2\2\u03d6\u03d8") + buf.write("\5\u00bf`\2\u03d7\u03d6\3\2\2\2\u03d7\u03d8\3\2\2\2\u03d8") + buf.write("\u03d9\3\2\2\2\u03d9\u03da\7$\2\2\u03da\u00be\3\2\2\2") + buf.write("\u03db\u03dd\5\u00c1a\2\u03dc\u03db\3\2\2\2\u03dd\u03de") + buf.write("\3\2\2\2\u03de\u03dc\3\2\2\2\u03de\u03df\3\2\2\2\u03df") + buf.write("\u00c0\3\2\2\2\u03e0\u03e3\n\3\2\2\u03e1\u03e3\5\u00c3") + buf.write("b\2\u03e2\u03e0\3\2\2\2\u03e2\u03e1\3\2\2\2\u03e3\u00c2") + buf.write("\3\2\2\2\u03e4\u03e5\7^\2\2\u03e5\u03e6\13\2\2\2\u03e6") + buf.write("\u00c4\3\2\2\2\u03e7\u03e9\t\2\2\2\u03e8\u03e7\3\2\2\2") + buf.write("\u03e9\u03ea\3\2\2\2\u03ea\u03e8\3\2\2\2\u03ea\u03eb\3") + buf.write("\2\2\2\u03eb\u03ec\3\2\2\2\u03ec\u03ee\7\60\2\2\u03ed") + buf.write("\u03ef\t\2\2\2\u03ee\u03ed\3\2\2\2\u03ef\u03f0\3\2\2\2") + buf.write("\u03f0\u03ee\3\2\2\2\u03f0\u03f1\3\2\2\2\u03f1\u03f8\3") + buf.write("\2\2\2\u03f2\u03f4\7\60\2\2\u03f3\u03f5\t\2\2\2\u03f4") + buf.write("\u03f3\3\2\2\2\u03f5\u03f6\3\2\2\2\u03f6\u03f4\3\2\2\2") + buf.write("\u03f6\u03f7\3\2\2\2\u03f7\u03f9\3\2\2\2\u03f8\u03f2\3") + buf.write("\2\2\2\u03f8\u03f9\3\2\2\2\u03f9\u00c6\3\2\2\2\u03fa\u03fb") + buf.write("\7#\2\2\u03fb\u00c8\3\2\2\2\u03fc\u03fd\7(\2\2\u03fd\u03fe") + buf.write("\7(\2\2\u03fe\u00ca\3\2\2\2\u03ff\u0400\7~\2\2\u0400\u0401") + buf.write("\7~\2\2\u0401\u00cc\3\2\2\2\u0402\u0403\7?\2\2\u0403\u0404") + buf.write("\7@\2\2\u0404\u00ce\3\2\2\2\u0405\u0406\7?\2\2\u0406\u0407") + buf.write("\7?\2\2\u0407\u0408\7@\2\2\u0408\u00d0\3\2\2\2\u0409\u040a") + buf.write("\7>\2\2\u040a\u040b\7?\2\2\u040b\u040c\7?\2\2\u040c\u040d") + buf.write("\7@\2\2\u040d\u00d2\3\2\2\2\u040e\u040f\7?\2\2\u040f\u0410") + buf.write("\7?\2\2\u0410\u00d4\3\2\2\2\u0411\u0412\7#\2\2\u0412\u0413") + buf.write("\7?\2\2\u0413\u00d6\3\2\2\2\u0414\u0415\7>\2\2\u0415\u0416") + buf.write("\7?\2\2\u0416\u00d8\3\2\2\2\u0417\u0418\7@\2\2\u0418\u0419") + buf.write("\7?\2\2\u0419\u00da\3\2\2\2\u041a\u041b\7>\2\2\u041b\u00dc") + buf.write("\3\2\2\2\u041c\u041d\7@\2\2\u041d\u00de\3\2\2\2\u041e") + buf.write("\u041f\7/\2\2\u041f\u0420\7@\2\2\u0420\u00e0\3\2\2\2\u0421") + buf.write("\u0422\7?\2\2\u0422\u00e2\3\2\2\2\u0423\u0424\7-\2\2\u0424") + buf.write("\u0425\7?\2\2\u0425\u00e4\3\2\2\2\u0426\u0427\7/\2\2\u0427") + buf.write("\u0428\7?\2\2\u0428\u00e6\3\2\2\2\u0429\u042a\7-\2\2\u042a") + buf.write("\u00e8\3\2\2\2\u042b\u042c\7/\2\2\u042c\u00ea\3\2\2\2") + buf.write("\u042d\u042e\7,\2\2\u042e\u00ec\3\2\2\2\u042f\u0430\7") + buf.write("\61\2\2\u0430\u00ee\3\2\2\2\u0431\u0432\7\'\2\2\u0432") + buf.write("\u00f0\3\2\2\2\u0433\u0434\7`\2\2\u0434\u00f2\3\2\2\2") + buf.write("\u0435\u0436\7\u0080\2\2\u0436\u00f4\3\2\2\2\u0437\u0438") + buf.write("\7}\2\2\u0438\u00f6\3\2\2\2\u0439\u043a\7\177\2\2\u043a") + buf.write("\u00f8\3\2\2\2\u043b\u043c\7]\2\2\u043c\u00fa\3\2\2\2") + buf.write("\u043d\u043e\7_\2\2\u043e\u00fc\3\2\2\2\u043f\u0440\7") + buf.write("*\2\2\u0440\u00fe\3\2\2\2\u0441\u0442\7+\2\2\u0442\u0100") + buf.write("\3\2\2\2\u0443\u0444\7=\2\2\u0444\u0102\3\2\2\2\u0445") + buf.write("\u0446\7.\2\2\u0446\u0104\3\2\2\2\u0447\u0448\7\60\2\2") + buf.write("\u0448\u0106\3\2\2\2\u0449\u044a\7<\2\2\u044a\u0108\3") + buf.write("\2\2\2\u044b\u044f\5\u010b\u0086\2\u044c\u044e\5\u010d") + buf.write("\u0087\2\u044d\u044c\3\2\2\2\u044e\u0451\3\2\2\2\u044f") + buf.write("\u044d\3\2\2\2\u044f\u0450\3\2\2\2\u0450\u010a\3\2\2\2") + buf.write("\u0451\u044f\3\2\2\2\u0452\u0453\t\4\2\2\u0453\u010c\3") + buf.write("\2\2\2\u0454\u0455\t\5\2\2\u0455\u010e\3\2\2\2\u0456\u0458") + buf.write("\t\6\2\2\u0457\u0456\3\2\2\2\u0458\u0459\3\2\2\2\u0459") + buf.write("\u0457\3\2\2\2\u0459\u045a\3\2\2\2\u045a\u045b\3\2\2\2") + buf.write("\u045b\u045c\b\u0088\2\2\u045c\u0110\3\2\2\2\u045d\u045e") + buf.write("\7\61\2\2\u045e\u045f\7,\2\2\u045f\u0463\3\2\2\2\u0460") + buf.write("\u0462\13\2\2\2\u0461\u0460\3\2\2\2\u0462\u0465\3\2\2") + buf.write("\2\u0463\u0464\3\2\2\2\u0463\u0461\3\2\2\2\u0464\u0466") + buf.write("\3\2\2\2\u0465\u0463\3\2\2\2\u0466\u0467\7,\2\2\u0467") + buf.write("\u0468\7\61\2\2\u0468\u0469\3\2\2\2\u0469\u046a\b\u0089") + buf.write("\3\2\u046a\u0112\3\2\2\2\u046b\u046c\7\61\2\2\u046c\u046d") + buf.write("\7\61\2\2\u046d\u0471\3\2\2\2\u046e\u0470\n\7\2\2\u046f") + buf.write("\u046e\3\2\2\2\u0470\u0473\3\2\2\2\u0471\u046f\3\2\2\2") + buf.write("\u0471\u0472\3\2\2\2\u0472\u0474\3\2\2\2\u0473\u0471\3") + buf.write("\2\2\2\u0474\u0475\b\u008a\3\2\u0475\u0114\3\2\2\2\20") + buf.write("\2\u03c9\u03ce\u03d7\u03de\u03e2\u03ea\u03f0\u03f6\u03f8") + buf.write("\u044f\u0459\u0463\u0471\4\b\2\2\2\3\2") + return buf.getvalue() + + +class CelestialLexer(Lexer): + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] + + ADDR = 1 + BOOL = 2 + ENUM = 3 + EVENT = 4 + EVENTLOG = 5 + UINT = 6 + UINT8 = 7 + INSTMAP = 8 + INT = 9 + STRING = 10 + CONTRACT = 11 + MAP = 12 + BYTES = 13 + BYTES20 = 14 + BYTES32 = 15 + ADD = 16 + AS = 17 + ASSERT = 18 + BALANCE = 19 + BCOINBASE = 20 + BDIFF = 21 + BGASLIMIT = 22 + BNUMBER = 23 + BTIMESTAMP = 24 + CALL = 25 + CALLBOOL = 26 + CALLUINT = 27 + CONSTANT = 28 + CONSTR = 29 + CONTAINS = 30 + CREDIT = 31 + DEBIT = 32 + DEFAULT = 33 + DELETE = 34 + ELSE = 35 + EMIT = 36 + ETRANSFER = 37 + EXISTS = 38 + FALLBACK = 39 + FOR = 40 + FORALL = 41 + FROM = 42 + FUNCTION = 43 + IF = 44 + IMPORT = 45 + IN = 46 + INT_MIN = 47 + INT_MAX = 48 + ITE = 49 + INVARIANT = 50 + KEYS = 51 + LEMMA = 52 + LENGTH = 53 + LOG = 54 + MODIFIES = 55 + MODIFIESA = 56 + NEW = 57 + PAYABLE = 58 + POP = 59 + POST = 60 + PRAGMA = 61 + PRE = 62 + PRINT = 63 + PRIVATE = 64 + PUBLIC = 65 + PURE = 66 + PUSH = 67 + RECEIVE = 68 + RETURN = 69 + RETURNS = 70 + REVERT = 71 + RREVERTS = 72 + SAFEADD = 73 + SAFEDIV = 74 + SAFEMOD = 75 + SAFEMUL = 76 + SAFESUB = 77 + SEND = 78 + SENDER = 79 + SPEC = 80 + STRUCT = 81 + THIS = 82 + TRANSFER = 83 + TXREVERTS = 84 + TXGASPRICE = 85 + TXORIGIN = 86 + UINT_MAX = 87 + USING = 88 + VALUE = 89 + VIEW = 90 + BoolLiteral = 91 + IntLiteral = 92 + NullLiteral = 93 + StringLiteral = 94 + VersionLiteral = 95 + LNOT = 96 + LAND = 97 + LOR = 98 + MAPUPD = 99 + IMPL = 100 + BIMPL = 101 + EQ = 102 + NE = 103 + LE = 104 + GE = 105 + LT = 106 + GT = 107 + RARROW = 108 + ASSIGN = 109 + INSERT = 110 + REMOVE = 111 + PLUS = 112 + SUB = 113 + MUL = 114 + DIV = 115 + MOD = 116 + CARET = 117 + BNOT = 118 + LBRACE = 119 + RBRACE = 120 + LBRACK = 121 + RBRACK = 122 + LPAREN = 123 + RPAREN = 124 + SEMI = 125 + COMMA = 126 + DOT = 127 + COLON = 128 + Iden = 129 + Whitespace = 130 + BlockComment = 131 + LineComment = 132 + + channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] + + modeNames = [ "DEFAULT_MODE" ] + + literalNames = [ "", + "'address'", "'bool'", "'enum'", "'event'", "'eventlog'", "'uint'", + "'uint8'", "'inst_map'", "'int'", "'string'", "'contract'", + "'mapping'", "'bytes'", "'bytes20'", "'bytes32'", "'add'", "'as'", + "'assert'", "'balance'", "'block.coinbase'", "'block.difficulty'", + "'block.gaslimit'", "'block.number'", "'block.timestamp'", "'call'", + "'call_bool'", "'call_uint'", "'constant'", "'constructor'", + "'contains'", "'credit'", "'debit'", "'default'", "'delete'", + "'else'", "'emit'", "'eTransfer'", "'exists'", "'fallback'", + "'for'", "'forall'", "'from'", "'function'", "'if'", "'import'", + "'in'", "'int_min'", "'int_max'", "'ite'", "'invariant'", "'keys'", + "'lemma'", "'length'", "'log'", "'modifies'", "'modifies_addresses'", + "'new'", "'payable'", "'pop'", "'post'", "'pragma'", "'pre'", + "'print'", "'private'", "'public'", "'pure'", "'push'", "'receive'", + "'return'", "'returns'", "'revert'", "'r_reverts'", "'safe_add'", + "'safe_div'", "'safe_mod'", "'safe_mul'", "'safe_sub'", "'send'", + "'sender'", "'spec'", "'struct'", "'this'", "'transfer'", "'tx_reverts'", + "'tx.gasprice'", "'tx.origin'", "'uint_max'", "'using'", "'value'", + "'view'", "'null'", "'!'", "'&&'", "'||'", "'=>'", "'==>'", + "'<==>'", "'=='", "'!='", "'<='", "'>='", "'<'", "'>'", "'->'", + "'='", "'+='", "'-='", "'+'", "'-'", "'*'", "'/'", "'%'", "'^'", + "'~'", "'{'", "'}'", "'['", "']'", "'('", "')'", "';'", "','", + "'.'", "':'" ] + + symbolicNames = [ "", + "ADDR", "BOOL", "ENUM", "EVENT", "EVENTLOG", "UINT", "UINT8", + "INSTMAP", "INT", "STRING", "CONTRACT", "MAP", "BYTES", "BYTES20", + "BYTES32", "ADD", "AS", "ASSERT", "BALANCE", "BCOINBASE", "BDIFF", + "BGASLIMIT", "BNUMBER", "BTIMESTAMP", "CALL", "CALLBOOL", "CALLUINT", + "CONSTANT", "CONSTR", "CONTAINS", "CREDIT", "DEBIT", "DEFAULT", + "DELETE", "ELSE", "EMIT", "ETRANSFER", "EXISTS", "FALLBACK", + "FOR", "FORALL", "FROM", "FUNCTION", "IF", "IMPORT", "IN", "INT_MIN", + "INT_MAX", "ITE", "INVARIANT", "KEYS", "LEMMA", "LENGTH", "LOG", + "MODIFIES", "MODIFIESA", "NEW", "PAYABLE", "POP", "POST", "PRAGMA", + "PRE", "PRINT", "PRIVATE", "PUBLIC", "PURE", "PUSH", "RECEIVE", + "RETURN", "RETURNS", "REVERT", "RREVERTS", "SAFEADD", "SAFEDIV", + "SAFEMOD", "SAFEMUL", "SAFESUB", "SEND", "SENDER", "SPEC", "STRUCT", + "THIS", "TRANSFER", "TXREVERTS", "TXGASPRICE", "TXORIGIN", "UINT_MAX", + "USING", "VALUE", "VIEW", "BoolLiteral", "IntLiteral", "NullLiteral", + "StringLiteral", "VersionLiteral", "LNOT", "LAND", "LOR", "MAPUPD", + "IMPL", "BIMPL", "EQ", "NE", "LE", "GE", "LT", "GT", "RARROW", + "ASSIGN", "INSERT", "REMOVE", "PLUS", "SUB", "MUL", "DIV", "MOD", + "CARET", "BNOT", "LBRACE", "RBRACE", "LBRACK", "RBRACK", "LPAREN", + "RPAREN", "SEMI", "COMMA", "DOT", "COLON", "Iden", "Whitespace", + "BlockComment", "LineComment" ] + + ruleNames = [ "ADDR", "BOOL", "ENUM", "EVENT", "EVENTLOG", "UINT", "UINT8", + "INSTMAP", "INT", "STRING", "CONTRACT", "MAP", "BYTES", + "BYTES20", "BYTES32", "ADD", "AS", "ASSERT", "BALANCE", + "BCOINBASE", "BDIFF", "BGASLIMIT", "BNUMBER", "BTIMESTAMP", + "CALL", "CALLBOOL", "CALLUINT", "CONSTANT", "CONSTR", + "CONTAINS", "CREDIT", "DEBIT", "DEFAULT", "DELETE", "ELSE", + "EMIT", "ETRANSFER", "EXISTS", "FALLBACK", "FOR", "FORALL", + "FROM", "FUNCTION", "IF", "IMPORT", "IN", "INT_MIN", "INT_MAX", + "ITE", "INVARIANT", "KEYS", "LEMMA", "LENGTH", "LOG", + "MODIFIES", "MODIFIESA", "NEW", "PAYABLE", "POP", "POST", + "PRAGMA", "PRE", "PRINT", "PRIVATE", "PUBLIC", "PURE", + "PUSH", "RECEIVE", "RETURN", "RETURNS", "REVERT", "RREVERTS", + "SAFEADD", "SAFEDIV", "SAFEMOD", "SAFEMUL", "SAFESUB", + "SEND", "SENDER", "SPEC", "STRUCT", "THIS", "TRANSFER", + "TXREVERTS", "TXGASPRICE", "TXORIGIN", "UINT_MAX", "USING", + "VALUE", "VIEW", "BoolLiteral", "IntLiteral", "NullLiteral", + "StringLiteral", "StringCharacters", "StringCharacter", + "EscapeSequence", "VersionLiteral", "LNOT", "LAND", "LOR", + "MAPUPD", "IMPL", "BIMPL", "EQ", "NE", "LE", "GE", "LT", + "GT", "RARROW", "ASSIGN", "INSERT", "REMOVE", "PLUS", + "SUB", "MUL", "DIV", "MOD", "CARET", "BNOT", "LBRACE", + "RBRACE", "LBRACK", "RBRACK", "LPAREN", "RPAREN", "SEMI", + "COMMA", "DOT", "COLON", "Iden", "PLetter", "PLetterOrDigit", + "Whitespace", "BlockComment", "LineComment" ] + + grammarFileName = "CelestialLexer.g4" + + def __init__(self, input=None, output:TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.7.1") + self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) + self._actions = None + self._predicates = None + + diff --git a/Celestial/Compiler/CelestialLexer.tokens b/Celestial/Compiler/CelestialLexer.tokens new file mode 100644 index 00000000..9a55d8a5 --- /dev/null +++ b/Celestial/Compiler/CelestialLexer.tokens @@ -0,0 +1,256 @@ +ADDR=1 +BOOL=2 +ENUM=3 +EVENT=4 +EVENTLOG=5 +UINT=6 +UINT8=7 +INSTMAP=8 +INT=9 +STRING=10 +CONTRACT=11 +MAP=12 +BYTES=13 +BYTES20=14 +BYTES32=15 +ADD=16 +AS=17 +ASSERT=18 +BALANCE=19 +BCOINBASE=20 +BDIFF=21 +BGASLIMIT=22 +BNUMBER=23 +BTIMESTAMP=24 +CALL=25 +CALLBOOL=26 +CALLUINT=27 +CONSTANT=28 +CONSTR=29 +CONTAINS=30 +CREDIT=31 +DEBIT=32 +DEFAULT=33 +DELETE=34 +ELSE=35 +EMIT=36 +ETRANSFER=37 +EXISTS=38 +FALLBACK=39 +FOR=40 +FORALL=41 +FROM=42 +FUNCTION=43 +IF=44 +IMPORT=45 +IN=46 +INT_MIN=47 +INT_MAX=48 +ITE=49 +INVARIANT=50 +KEYS=51 +LEMMA=52 +LENGTH=53 +LOG=54 +MODIFIES=55 +MODIFIESA=56 +NEW=57 +PAYABLE=58 +POP=59 +POST=60 +PRAGMA=61 +PRE=62 +PRINT=63 +PRIVATE=64 +PUBLIC=65 +PURE=66 +PUSH=67 +RECEIVE=68 +RETURN=69 +RETURNS=70 +REVERT=71 +RREVERTS=72 +SAFEADD=73 +SAFEDIV=74 +SAFEMOD=75 +SAFEMUL=76 +SAFESUB=77 +SEND=78 +SENDER=79 +SPEC=80 +STRUCT=81 +THIS=82 +TRANSFER=83 +TXREVERTS=84 +TXGASPRICE=85 +TXORIGIN=86 +UINT_MAX=87 +USING=88 +VALUE=89 +VIEW=90 +BoolLiteral=91 +IntLiteral=92 +NullLiteral=93 +StringLiteral=94 +VersionLiteral=95 +LNOT=96 +LAND=97 +LOR=98 +MAPUPD=99 +IMPL=100 +BIMPL=101 +EQ=102 +NE=103 +LE=104 +GE=105 +LT=106 +GT=107 +RARROW=108 +ASSIGN=109 +INSERT=110 +REMOVE=111 +PLUS=112 +SUB=113 +MUL=114 +DIV=115 +MOD=116 +CARET=117 +BNOT=118 +LBRACE=119 +RBRACE=120 +LBRACK=121 +RBRACK=122 +LPAREN=123 +RPAREN=124 +SEMI=125 +COMMA=126 +DOT=127 +COLON=128 +Iden=129 +Whitespace=130 +BlockComment=131 +LineComment=132 +'address'=1 +'bool'=2 +'enum'=3 +'event'=4 +'eventlog'=5 +'uint'=6 +'uint8'=7 +'inst_map'=8 +'int'=9 +'string'=10 +'contract'=11 +'mapping'=12 +'bytes'=13 +'bytes20'=14 +'bytes32'=15 +'add'=16 +'as'=17 +'assert'=18 +'balance'=19 +'block.coinbase'=20 +'block.difficulty'=21 +'block.gaslimit'=22 +'block.number'=23 +'block.timestamp'=24 +'call'=25 +'call_bool'=26 +'call_uint'=27 +'constant'=28 +'constructor'=29 +'contains'=30 +'credit'=31 +'debit'=32 +'default'=33 +'delete'=34 +'else'=35 +'emit'=36 +'eTransfer'=37 +'exists'=38 +'fallback'=39 +'for'=40 +'forall'=41 +'from'=42 +'function'=43 +'if'=44 +'import'=45 +'in'=46 +'int_min'=47 +'int_max'=48 +'ite'=49 +'invariant'=50 +'keys'=51 +'lemma'=52 +'length'=53 +'log'=54 +'modifies'=55 +'modifies_addresses'=56 +'new'=57 +'payable'=58 +'pop'=59 +'post'=60 +'pragma'=61 +'pre'=62 +'print'=63 +'private'=64 +'public'=65 +'pure'=66 +'push'=67 +'receive'=68 +'return'=69 +'returns'=70 +'revert'=71 +'r_reverts'=72 +'safe_add'=73 +'safe_div'=74 +'safe_mod'=75 +'safe_mul'=76 +'safe_sub'=77 +'send'=78 +'sender'=79 +'spec'=80 +'struct'=81 +'this'=82 +'transfer'=83 +'tx_reverts'=84 +'tx.gasprice'=85 +'tx.origin'=86 +'uint_max'=87 +'using'=88 +'value'=89 +'view'=90 +'null'=93 +'!'=96 +'&&'=97 +'||'=98 +'=>'=99 +'==>'=100 +'<==>'=101 +'=='=102 +'!='=103 +'<='=104 +'>='=105 +'<'=106 +'>'=107 +'->'=108 +'='=109 +'+='=110 +'-='=111 +'+'=112 +'-'=113 +'*'=114 +'/'=115 +'%'=116 +'^'=117 +'~'=118 +'{'=119 +'}'=120 +'['=121 +']'=122 +'('=123 +')'=124 +';'=125 +','=126 +'.'=127 +':'=128 diff --git a/Celestial/Compiler/CelestialParser.g4 b/Celestial/Compiler/CelestialParser.g4 new file mode 100644 index 00000000..b69de659 --- /dev/null +++ b/Celestial/Compiler/CelestialParser.g4 @@ -0,0 +1,262 @@ +parser grammar CelestialParser; + +options {tokenVocab = CelestialLexer; language=Python3;}// CelestialLexer; + +// A small overview of ANTLRs parser rules: +// +// Parser rules begin with a lower case letter, lexer rules begin +// with an Uppercase letter. To create a parser rule, write the name +// followed by a colon (:) and then a list of alternatives, separated +// by pipe (|) characters. You can use parenthesis for sub-expressions, +// alternatives within those sub-expressions, and kleene * or + on any +// element in a rule. +// +// Every production rule corresponds to a class that gets generated +// in the target language for the ANTLR generator. If we use alternative +// labels, as in `type`, then subclasses of the rule-class will be created +// for each label. If one alternative is labelled, then they all must be. +// The purpose of labels is to call different functions in the generated +// listeners and visitors for the results of these productions. +// +// Lastly, ANTLR's DSL contains a feature that allows us to name the matched +// tokens and productions in an alternative (name=part) or collect multiple +// tokens or productions of the same type into a list (list+=part). The `type` +// production below uses this feature, too. + +program : (contractDecl | pragmaDirective | importDirective)* EOF ; + +pragmaDirective + : PRAGMA pragmaName=iden pragmaValue SEMI ; + +pragmaValue + : version | expr ; + +version + : versionConstraint versionConstraint? ; + +versionConstraint + : versionOperator? VersionLiteral ; + +versionOperator + : CARET | BNOT | GE | GT | LT | LE | ASSIGN ; + +importDirective + : IMPORT StringLiteral+ (AS iden)? SEMI + | IMPORT (MUL | iden) (AS iden)? FROM StringLiteral+ SEMI + | IMPORT LBRACE importDeclaration ( COMMA importDeclaration )* RBRACE FROM StringLiteral+ SEMI ; + +importDeclaration : iden (AS iden)? ; + +iden : Iden ; +//int : IntLiteral ; + +datatype : arrayType=datatype LBRACK RBRACK + | MAP LPAREN keyType=datatype MAPUPD valueType=datatype RPAREN + | BOOL + | INT + | UINT + | UINT8 + | STRING + | ADDR (PAYABLE)? + | EVENTLOG + | EVENT + | name=iden + | INSTMAP LT iden GT + | BYTES + | BYTES20 + | BYTES32 + ; + +idenTypeList : idenType (COMMA idenType)* ; +idenType : name=iden COLON datatype ; + +contractDecl : CONTRACT name=iden contractBody ; + +contractBody : LBRACE contractContents+ RBRACE ; + +contractContents : varDecl + | enumDecl + | structDecl + | funDecl + | invariantDecl + | eventDecl + | constructorDecl + | methodDecl + | usingForDecl + ; + +enumDecl : ENUM name=iden LBRACE iden (COMMA iden)* RBRACE ; + +structDecl : STRUCT name=iden LBRACE datatype iden SEMI (datatype iden SEMI)* RBRACE ; + +funDecl : SPEC name=iden LPAREN funParamList? RPAREN functionBody # FDecl + ; + +funParamList : funParam (COMMA funParam)* ; +funParam : datatype name=iden ; +functionBody : LBRACE expr RBRACE ; + +invariantDecl : INVARIANT name=iden invariantBody ; +invariantBody : LBRACE expr RBRACE ; + +eventDecl : EVENT name=iden LPAREN (datatype (COMMA datatype)*)? RPAREN SEMI ; + +constructorDecl : CONSTR LPAREN methodParamList? RPAREN (PUBLIC|PRIVATE)? spec (MODIFIES LBRACK (modifies=rvalueList)? RBRACK)? (MODIFIESA LBRACK (modifies_addrs=rvalueList)? RBRACK)? methodBody ; + +spec : (PRE pre=expr)? (POST post=expr)? (CREDIT)? (DEBIT)? (TXREVERTS reverts=expr)? (RREVERTS rreverts=expr)? + | (CREDIT)? (DEBIT)? (PRE pre=expr)? (POST post=expr)? (TXREVERTS reverts=expr)? (RREVERTS rreverts=expr)? + | (PRE pre=expr)? (TXREVERTS reverts=expr)? (CREDIT)? (DEBIT)? (POST post=expr)? (RREVERTS rreverts=expr)? + | (PRE pre=expr)? (TXREVERTS reverts=expr)? (POST post=expr)? (CREDIT)? (DEBIT)? (RREVERTS rreverts=expr)?; +stateMutability : PURE | CONSTANT | VIEW ; +methodDecl : (RECEIVE | FALLBACK | FUNCTION name=iden) LPAREN methodParamList? RPAREN (PUBLIC|PRIVATE)? stateMutability? spec (MODIFIES LBRACK (modifies=rvalueList)? RBRACK)? (MODIFIESA LBRACK (modifies_addrs=rvalueList)? RBRACK)? (RETURNS LPAREN datatype (returnval=iden)? RPAREN)? methodBody # MDecl + ; +methodParamList : methodParam (COMMA methodParam)* ; +methodParam : datatype name=iden ; +methodBody : LBRACE (varDecl | statement)* returnStatement RBRACE ; +returnStatement : RETURN expr? SEMI ; + +varDecl : datatype iden (ASSIGN expr)? SEMI ; + +usingForDecl : USING iden FOR (datatype | MUL) SEMI ; + +loopVarDecl : datatype iden ASSIGN expr + | iden ASSIGN expr ; + +statement : //# CompoundStmt + LBRACE statement* RBRACE + + //# PushStmt + | arrayName=lvalue DOT PUSH LPAREN value=expr RPAREN SEMI + + //# PopStmt + | arrayName=lvalue DOT POP LPAREN RPAREN SEMI + + //# DeleteStmt + | DELETE LPAREN toDelete=lvalue (COMMA value=expr)? RPAREN SEMI + + //# AssertStmt + | ASSERT expr (COMMA StringLiteral)? SEMI + + //# CreateStmt + | assignTo=lvalue ASSIGN NEW iden LPAREN rvalueList? RPAREN SEMI + + // unknown call Statements + | expr DOT CALL LPAREN rvalueList RPAREN SEMI + | BOOL iden ASSIGN expr DOT CALL LPAREN rvalueList RPAREN SEMI + | lvalue ASSIGN expr DOT CALL LPAREN rvalueList RPAREN SEMI + + | expr DOT CALLUINT LPAREN rvalueList RPAREN SEMI + | UINT iden ASSIGN expr DOT CALLUINT LPAREN rvalueList RPAREN SEMI + + | expr DOT CALLBOOL LPAREN rvalueList RPAREN SEMI + | BOOL iden ASSIGN expr DOT CALLBOOL LPAREN rvalueList RPAREN SEMI + + //# ExternalContractMethodCallStmt + | otherContractInstance=lvalue DOT method=iden LPAREN rvalueList? RPAREN SEMI + + //# ExternalContractMethodCallAssignStmt + | assignTo=lvalue ASSIGN otherContractInstance=lvalue DOT method=iden LPAREN rvalueList? RPAREN SEMI + + //# AssignStmt + | assignTo=lvalue assignment=ASSIGN rvalue SEMI + + //# IfStmt + | IF LPAREN expr RPAREN thenBranch=statement elseStatement? + + //# ForStmt + | FOR LPAREN loopVarDecl (COMMA loopVarDecl)* SEMI expr SEMI expr SEMI RPAREN loopBody=statement + + //# MethodCallStmt + | method=iden LPAREN rvalueList? RPAREN SEMI + + //# eTransferSendStmt + | SEND LPAREN contract=expr COMMA ETRANSFER COMMA payload=expr RPAREN SEMI + + // Ether transfer statement + | to=expr DOT TRANSFER LPAREN amount=expr RPAREN SEMI + + //# SendStmt + // | SEND LPAREN contract=expr COMMA event=iden COMMA payload=expr (COMMA payload=expr)* RPAREN SEMI + | EMIT event=iden LPAREN payload=expr (COMMA payload=expr)* RPAREN SEMI + + //# RevertStmt + | REVERT LPAREN StringLiteral (COMMA rvalueList)? RPAREN SEMI + ; + +elseStatement : ELSE statement ; + +lvalue : name=iden //# VarLvalue + | lvalue DOT field=iden //# NamedTupleLvalue + | lvalue LBRACK expr RBRACK //# MapOrArrayLvalue + ; + +logcheck : LPAREN event=iden COMMA payload=expr (COMMA payload=expr)* RPAREN + | LPAREN to=expr COMMA ETRANSFER COMMA payload=expr RPAREN + ; + +expr : primitive //# PrimitiveExpr + | LPAREN expr RPAREN //# ParenExpr + | iden DOT method=iden LPAREN rvalueList? RPAREN + | expr DOT field=iden //# FieldAccessExpr + | array=expr LBRACK index=expr RBRACK //# ArrayMapAccessExpr + | array=expr DOT LENGTH LPAREN RPAREN //# ArrayLengthExpr + | method=iden LPAREN rvalueList? RPAREN //# MethodCallExpr + | FORALL LPAREN funParamList RPAREN LPAREN expr RPAREN + | EXISTS LPAREN funParamList RPAREN LPAREN expr RPAREN + | op=(SUB | LNOT) expr //# UnaryExpr + | lhs=expr op=(MUL | DIV | MOD) rhs=expr //# BinExpr + | SAFEMOD LPAREN lhs=expr COMMA rhs=expr RPAREN //# SafeMod + | SAFEDIV LPAREN lhs=expr COMMA rhs=expr RPAREN //# SafeDiv + | SAFEMUL LPAREN lhs=expr COMMA rhs=expr RPAREN //# SafeMul + | lhs=expr op=(PLUS | SUB) rhs=expr //# BinExpr + | SAFEADD LPAREN lhs=expr COMMA rhs=expr RPAREN //# SafeAdd + | SAFESUB LPAREN lhs=expr COMMA rhs=expr RPAREN //# SafeSub + | lhs=expr op=(LT | GT | GE | LE | IN) rhs=expr //# BinExpr + | lhs=expr op=(EQ | NE) rhs=expr //# BinExpr + | lhs=expr op=LAND rhs=expr //# BinExpr + | lhs=expr op=LOR rhs=expr //# BinExpr + | lhs=expr op=(IMPL | BIMPL) rhs=expr //# ImpliesExpr + | expr MAPUPD expr (COMMA expr MAPUPD expr)* //# MapUpdateExpr + | iden LPAREN expr RPAREN //# CastExpr + | NEW contractName=iden LPAREN rvalueList? RPAREN //# CreateExpr + | instmap=iden DOT ADD LPAREN NEW contractName=iden LPAREN rvalueList? RPAREN RPAREN //# InstMapAdd + | ITE LPAREN condition=expr COMMA + thenBranch=expr COMMA + elseBranch=expr RPAREN //# ite() + | DEFAULT LPAREN datatype RPAREN + | logcheck (COLON COLON logcheck)* COLON COLON logName=primitive + | PAYABLE LPAREN expr RPAREN +// | contractInstance=lvalue DOT method=iden LPAREN rvalueList? RPAREN // Contract Instance method call + ; + +primitive : iden //# IdenPrimitive + | VALUE + | BALANCE + | SENDER + | TXGASPRICE | TXORIGIN + | BCOINBASE | BDIFF | BGASLIMIT | BNUMBER | BTIMESTAMP + | LOG + | INT_MIN | INT_MAX | UINT_MAX + | NEW LPAREN iden RPAREN + | NEW LPAREN BALANCE RPAREN + | NEW LPAREN LOG RPAREN + | BoolLiteral //# BoolPrimitive + | IntLiteral //# IntPrimitive + | NullLiteral //# NullPrimitive + | StringLiteral + | THIS //# ThisPrimitive + | ADDR LPAREN THIS RPAREN + | ADDR LPAREN iden RPAREN + ; + +unnamedTupleBody : fields+=rvalue COMMA + | fields+=rvalue (COMMA fields+=rvalue)+ + ; + +namedTupleBody : names+=iden ASSIGN values+=rvalue COMMA + | names+=iden ASSIGN values+=rvalue (COMMA names+=iden ASSIGN values+=rvalue)+ + ; + +rvalueList : rvalue (COMMA rvalue)* ; +rvalue : expr + ; \ No newline at end of file diff --git a/Celestial/Compiler/CelestialParser.interp b/Celestial/Compiler/CelestialParser.interp new file mode 100644 index 00000000..1d0be4b9 --- /dev/null +++ b/Celestial/Compiler/CelestialParser.interp @@ -0,0 +1,320 @@ +token literal names: +null +'address' +'bool' +'enum' +'event' +'eventlog' +'uint' +'uint8' +'inst_map' +'int' +'string' +'contract' +'mapping' +'bytes' +'bytes20' +'bytes32' +'add' +'as' +'assert' +'balance' +'block.coinbase' +'block.difficulty' +'block.gaslimit' +'block.number' +'block.timestamp' +'call' +'call_bool' +'call_uint' +'constant' +'constructor' +'contains' +'credit' +'debit' +'default' +'delete' +'else' +'emit' +'eTransfer' +'exists' +'fallback' +'for' +'forall' +'from' +'function' +'if' +'import' +'in' +'int_min' +'int_max' +'ite' +'invariant' +'keys' +'lemma' +'length' +'log' +'modifies' +'modifies_addresses' +'new' +'payable' +'pop' +'post' +'pragma' +'pre' +'print' +'private' +'public' +'pure' +'push' +'receive' +'return' +'returns' +'revert' +'r_reverts' +'safe_add' +'safe_div' +'safe_mod' +'safe_mul' +'safe_sub' +'send' +'sender' +'spec' +'struct' +'this' +'transfer' +'tx_reverts' +'tx.gasprice' +'tx.origin' +'uint_max' +'using' +'value' +'view' +null +null +'null' +null +null +'!' +'&&' +'||' +'=>' +'==>' +'<==>' +'==' +'!=' +'<=' +'>=' +'<' +'>' +'->' +'=' +'+=' +'-=' +'+' +'-' +'*' +'/' +'%' +'^' +'~' +'{' +'}' +'[' +']' +'(' +')' +';' +',' +'.' +':' +null +null +null +null + +token symbolic names: +null +ADDR +BOOL +ENUM +EVENT +EVENTLOG +UINT +UINT8 +INSTMAP +INT +STRING +CONTRACT +MAP +BYTES +BYTES20 +BYTES32 +ADD +AS +ASSERT +BALANCE +BCOINBASE +BDIFF +BGASLIMIT +BNUMBER +BTIMESTAMP +CALL +CALLBOOL +CALLUINT +CONSTANT +CONSTR +CONTAINS +CREDIT +DEBIT +DEFAULT +DELETE +ELSE +EMIT +ETRANSFER +EXISTS +FALLBACK +FOR +FORALL +FROM +FUNCTION +IF +IMPORT +IN +INT_MIN +INT_MAX +ITE +INVARIANT +KEYS +LEMMA +LENGTH +LOG +MODIFIES +MODIFIESA +NEW +PAYABLE +POP +POST +PRAGMA +PRE +PRINT +PRIVATE +PUBLIC +PURE +PUSH +RECEIVE +RETURN +RETURNS +REVERT +RREVERTS +SAFEADD +SAFEDIV +SAFEMOD +SAFEMUL +SAFESUB +SEND +SENDER +SPEC +STRUCT +THIS +TRANSFER +TXREVERTS +TXGASPRICE +TXORIGIN +UINT_MAX +USING +VALUE +VIEW +BoolLiteral +IntLiteral +NullLiteral +StringLiteral +VersionLiteral +LNOT +LAND +LOR +MAPUPD +IMPL +BIMPL +EQ +NE +LE +GE +LT +GT +RARROW +ASSIGN +INSERT +REMOVE +PLUS +SUB +MUL +DIV +MOD +CARET +BNOT +LBRACE +RBRACE +LBRACK +RBRACK +LPAREN +RPAREN +SEMI +COMMA +DOT +COLON +Iden +Whitespace +BlockComment +LineComment + +rule names: +program +pragmaDirective +pragmaValue +version +versionConstraint +versionOperator +importDirective +importDeclaration +iden +datatype +idenTypeList +idenType +contractDecl +contractBody +contractContents +enumDecl +structDecl +funDecl +funParamList +funParam +functionBody +invariantDecl +invariantBody +eventDecl +constructorDecl +spec +stateMutability +methodDecl +methodParamList +methodParam +methodBody +returnStatement +varDecl +usingForDecl +loopVarDecl +statement +elseStatement +lvalue +logcheck +expr +primitive +unnamedTupleBody +namedTupleBody +rvalueList +rvalue + + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 134, 1088, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 3, 2, 3, 2, 3, 2, 7, 2, 96, 10, 2, 12, 2, 14, 2, 99, 11, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 5, 4, 110, 10, 4, 3, 5, 3, 5, 5, 5, 114, 10, 5, 3, 6, 5, 6, 117, 10, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 6, 8, 125, 10, 8, 13, 8, 14, 8, 126, 3, 8, 3, 8, 5, 8, 131, 10, 8, 3, 8, 3, 8, 3, 8, 3, 8, 5, 8, 137, 10, 8, 3, 8, 3, 8, 5, 8, 141, 10, 8, 3, 8, 3, 8, 6, 8, 145, 10, 8, 13, 8, 14, 8, 146, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 7, 8, 155, 10, 8, 12, 8, 14, 8, 158, 11, 8, 3, 8, 3, 8, 3, 8, 6, 8, 163, 10, 8, 13, 8, 14, 8, 164, 3, 8, 3, 8, 5, 8, 169, 10, 8, 3, 9, 3, 9, 3, 9, 5, 9, 174, 10, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 193, 10, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 206, 10, 11, 3, 11, 3, 11, 3, 11, 7, 11, 211, 10, 11, 12, 11, 14, 11, 214, 11, 11, 3, 12, 3, 12, 3, 12, 7, 12, 219, 10, 12, 12, 12, 14, 12, 222, 11, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 6, 15, 234, 10, 15, 13, 15, 14, 15, 235, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 5, 16, 249, 10, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 7, 17, 257, 10, 17, 12, 17, 14, 17, 260, 11, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 7, 18, 274, 10, 18, 12, 18, 14, 18, 277, 11, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 5, 19, 285, 10, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 7, 20, 293, 10, 20, 12, 20, 14, 20, 296, 11, 20, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 7, 25, 319, 10, 25, 12, 25, 14, 25, 322, 11, 25, 5, 25, 324, 10, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 5, 26, 332, 10, 26, 3, 26, 3, 26, 5, 26, 336, 10, 26, 3, 26, 3, 26, 3, 26, 3, 26, 5, 26, 342, 10, 26, 3, 26, 5, 26, 345, 10, 26, 3, 26, 3, 26, 3, 26, 5, 26, 350, 10, 26, 3, 26, 5, 26, 353, 10, 26, 3, 26, 3, 26, 3, 27, 3, 27, 5, 27, 359, 10, 27, 3, 27, 3, 27, 5, 27, 363, 10, 27, 3, 27, 5, 27, 366, 10, 27, 3, 27, 5, 27, 369, 10, 27, 3, 27, 3, 27, 5, 27, 373, 10, 27, 3, 27, 3, 27, 5, 27, 377, 10, 27, 3, 27, 5, 27, 380, 10, 27, 3, 27, 5, 27, 383, 10, 27, 3, 27, 3, 27, 5, 27, 387, 10, 27, 3, 27, 3, 27, 5, 27, 391, 10, 27, 3, 27, 3, 27, 5, 27, 395, 10, 27, 3, 27, 3, 27, 5, 27, 399, 10, 27, 3, 27, 3, 27, 5, 27, 403, 10, 27, 3, 27, 3, 27, 5, 27, 407, 10, 27, 3, 27, 5, 27, 410, 10, 27, 3, 27, 5, 27, 413, 10, 27, 3, 27, 3, 27, 5, 27, 417, 10, 27, 3, 27, 3, 27, 5, 27, 421, 10, 27, 3, 27, 3, 27, 5, 27, 425, 10, 27, 3, 27, 3, 27, 5, 27, 429, 10, 27, 3, 27, 3, 27, 5, 27, 433, 10, 27, 3, 27, 5, 27, 436, 10, 27, 3, 27, 5, 27, 439, 10, 27, 3, 27, 3, 27, 5, 27, 443, 10, 27, 5, 27, 445, 10, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 5, 29, 453, 10, 29, 3, 29, 3, 29, 5, 29, 457, 10, 29, 3, 29, 3, 29, 5, 29, 461, 10, 29, 3, 29, 5, 29, 464, 10, 29, 3, 29, 3, 29, 3, 29, 3, 29, 5, 29, 470, 10, 29, 3, 29, 5, 29, 473, 10, 29, 3, 29, 3, 29, 3, 29, 5, 29, 478, 10, 29, 3, 29, 5, 29, 481, 10, 29, 3, 29, 3, 29, 3, 29, 3, 29, 5, 29, 487, 10, 29, 3, 29, 3, 29, 5, 29, 491, 10, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 7, 30, 498, 10, 30, 12, 30, 14, 30, 501, 11, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 7, 32, 509, 10, 32, 12, 32, 14, 32, 512, 11, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 5, 33, 519, 10, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 5, 34, 527, 10, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 5, 35, 536, 10, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 5, 36, 549, 10, 36, 3, 37, 3, 37, 7, 37, 553, 10, 37, 12, 37, 14, 37, 556, 11, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 579, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 588, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 598, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 675, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 687, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 703, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 7, 37, 710, 10, 37, 12, 37, 14, 37, 713, 11, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 726, 10, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 7, 37, 755, 10, 37, 12, 37, 14, 37, 758, 11, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 5, 37, 768, 10, 37, 3, 37, 3, 37, 5, 37, 772, 10, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 3, 39, 7, 39, 788, 10, 39, 12, 39, 14, 39, 791, 11, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 7, 40, 799, 10, 40, 12, 40, 14, 40, 802, 11, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 5, 40, 814, 10, 40, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 827, 10, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 834, 10, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 900, 10, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 912, 10, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 7, 41, 935, 10, 41, 12, 41, 14, 41, 938, 11, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 5, 41, 949, 10, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 7, 41, 993, 10, 41, 12, 41, 14, 41, 996, 11, 41, 7, 41, 998, 10, 41, 12, 41, 14, 41, 1001, 11, 41, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 5, 42, 1045, 10, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 3, 43, 6, 43, 1053, 10, 43, 13, 43, 14, 43, 1054, 5, 43, 1057, 10, 43, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 6, 44, 1072, 10, 44, 13, 44, 14, 44, 1073, 5, 44, 1076, 10, 44, 3, 45, 3, 45, 3, 45, 7, 45, 1081, 10, 45, 12, 45, 14, 45, 1084, 11, 45, 3, 46, 3, 46, 3, 46, 2, 5, 20, 76, 80, 47, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 2, 11, 5, 2, 106, 109, 111, 111, 119, 120, 3, 2, 66, 67, 5, 2, 30, 30, 68, 68, 92, 92, 4, 2, 98, 98, 115, 115, 3, 2, 116, 118, 3, 2, 114, 115, 4, 2, 48, 48, 106, 109, 3, 2, 104, 105, 3, 2, 102, 103, 2, 1241, 2, 97, 3, 2, 2, 2, 4, 102, 3, 2, 2, 2, 6, 109, 3, 2, 2, 2, 8, 111, 3, 2, 2, 2, 10, 116, 3, 2, 2, 2, 12, 120, 3, 2, 2, 2, 14, 168, 3, 2, 2, 2, 16, 170, 3, 2, 2, 2, 18, 175, 3, 2, 2, 2, 20, 205, 3, 2, 2, 2, 22, 215, 3, 2, 2, 2, 24, 223, 3, 2, 2, 2, 26, 227, 3, 2, 2, 2, 28, 231, 3, 2, 2, 2, 30, 248, 3, 2, 2, 2, 32, 250, 3, 2, 2, 2, 34, 263, 3, 2, 2, 2, 36, 280, 3, 2, 2, 2, 38, 289, 3, 2, 2, 2, 40, 297, 3, 2, 2, 2, 42, 300, 3, 2, 2, 2, 44, 304, 3, 2, 2, 2, 46, 308, 3, 2, 2, 2, 48, 312, 3, 2, 2, 2, 50, 328, 3, 2, 2, 2, 52, 444, 3, 2, 2, 2, 54, 446, 3, 2, 2, 2, 56, 452, 3, 2, 2, 2, 58, 494, 3, 2, 2, 2, 60, 502, 3, 2, 2, 2, 62, 505, 3, 2, 2, 2, 64, 516, 3, 2, 2, 2, 66, 522, 3, 2, 2, 2, 68, 530, 3, 2, 2, 2, 70, 548, 3, 2, 2, 2, 72, 771, 3, 2, 2, 2, 74, 773, 3, 2, 2, 2, 76, 776, 3, 2, 2, 2, 78, 813, 3, 2, 2, 2, 80, 948, 3, 2, 2, 2, 82, 1044, 3, 2, 2, 2, 84, 1056, 3, 2, 2, 2, 86, 1075, 3, 2, 2, 2, 88, 1077, 3, 2, 2, 2, 90, 1085, 3, 2, 2, 2, 92, 96, 5, 26, 14, 2, 93, 96, 5, 4, 3, 2, 94, 96, 5, 14, 8, 2, 95, 92, 3, 2, 2, 2, 95, 93, 3, 2, 2, 2, 95, 94, 3, 2, 2, 2, 96, 99, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 97, 98, 3, 2, 2, 2, 98, 100, 3, 2, 2, 2, 99, 97, 3, 2, 2, 2, 100, 101, 7, 2, 2, 3, 101, 3, 3, 2, 2, 2, 102, 103, 7, 63, 2, 2, 103, 104, 5, 18, 10, 2, 104, 105, 5, 6, 4, 2, 105, 106, 7, 127, 2, 2, 106, 5, 3, 2, 2, 2, 107, 110, 5, 8, 5, 2, 108, 110, 5, 80, 41, 2, 109, 107, 3, 2, 2, 2, 109, 108, 3, 2, 2, 2, 110, 7, 3, 2, 2, 2, 111, 113, 5, 10, 6, 2, 112, 114, 5, 10, 6, 2, 113, 112, 3, 2, 2, 2, 113, 114, 3, 2, 2, 2, 114, 9, 3, 2, 2, 2, 115, 117, 5, 12, 7, 2, 116, 115, 3, 2, 2, 2, 116, 117, 3, 2, 2, 2, 117, 118, 3, 2, 2, 2, 118, 119, 7, 97, 2, 2, 119, 11, 3, 2, 2, 2, 120, 121, 9, 2, 2, 2, 121, 13, 3, 2, 2, 2, 122, 124, 7, 47, 2, 2, 123, 125, 7, 96, 2, 2, 124, 123, 3, 2, 2, 2, 125, 126, 3, 2, 2, 2, 126, 124, 3, 2, 2, 2, 126, 127, 3, 2, 2, 2, 127, 130, 3, 2, 2, 2, 128, 129, 7, 19, 2, 2, 129, 131, 5, 18, 10, 2, 130, 128, 3, 2, 2, 2, 130, 131, 3, 2, 2, 2, 131, 132, 3, 2, 2, 2, 132, 169, 7, 127, 2, 2, 133, 136, 7, 47, 2, 2, 134, 137, 7, 116, 2, 2, 135, 137, 5, 18, 10, 2, 136, 134, 3, 2, 2, 2, 136, 135, 3, 2, 2, 2, 137, 140, 3, 2, 2, 2, 138, 139, 7, 19, 2, 2, 139, 141, 5, 18, 10, 2, 140, 138, 3, 2, 2, 2, 140, 141, 3, 2, 2, 2, 141, 142, 3, 2, 2, 2, 142, 144, 7, 44, 2, 2, 143, 145, 7, 96, 2, 2, 144, 143, 3, 2, 2, 2, 145, 146, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 148, 3, 2, 2, 2, 148, 169, 7, 127, 2, 2, 149, 150, 7, 47, 2, 2, 150, 151, 7, 121, 2, 2, 151, 156, 5, 16, 9, 2, 152, 153, 7, 128, 2, 2, 153, 155, 5, 16, 9, 2, 154, 152, 3, 2, 2, 2, 155, 158, 3, 2, 2, 2, 156, 154, 3, 2, 2, 2, 156, 157, 3, 2, 2, 2, 157, 159, 3, 2, 2, 2, 158, 156, 3, 2, 2, 2, 159, 160, 7, 122, 2, 2, 160, 162, 7, 44, 2, 2, 161, 163, 7, 96, 2, 2, 162, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 3, 2, 2, 2, 166, 167, 7, 127, 2, 2, 167, 169, 3, 2, 2, 2, 168, 122, 3, 2, 2, 2, 168, 133, 3, 2, 2, 2, 168, 149, 3, 2, 2, 2, 169, 15, 3, 2, 2, 2, 170, 173, 5, 18, 10, 2, 171, 172, 7, 19, 2, 2, 172, 174, 5, 18, 10, 2, 173, 171, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 174, 17, 3, 2, 2, 2, 175, 176, 7, 131, 2, 2, 176, 19, 3, 2, 2, 2, 177, 178, 8, 11, 1, 2, 178, 179, 7, 14, 2, 2, 179, 180, 7, 125, 2, 2, 180, 181, 5, 20, 11, 2, 181, 182, 7, 101, 2, 2, 182, 183, 5, 20, 11, 2, 183, 184, 7, 126, 2, 2, 184, 206, 3, 2, 2, 2, 185, 206, 7, 4, 2, 2, 186, 206, 7, 11, 2, 2, 187, 206, 7, 8, 2, 2, 188, 206, 7, 9, 2, 2, 189, 206, 7, 12, 2, 2, 190, 192, 7, 3, 2, 2, 191, 193, 7, 60, 2, 2, 192, 191, 3, 2, 2, 2, 192, 193, 3, 2, 2, 2, 193, 206, 3, 2, 2, 2, 194, 206, 7, 7, 2, 2, 195, 206, 7, 6, 2, 2, 196, 206, 5, 18, 10, 2, 197, 198, 7, 10, 2, 2, 198, 199, 7, 108, 2, 2, 199, 200, 5, 18, 10, 2, 200, 201, 7, 109, 2, 2, 201, 206, 3, 2, 2, 2, 202, 206, 7, 15, 2, 2, 203, 206, 7, 16, 2, 2, 204, 206, 7, 17, 2, 2, 205, 177, 3, 2, 2, 2, 205, 185, 3, 2, 2, 2, 205, 186, 3, 2, 2, 2, 205, 187, 3, 2, 2, 2, 205, 188, 3, 2, 2, 2, 205, 189, 3, 2, 2, 2, 205, 190, 3, 2, 2, 2, 205, 194, 3, 2, 2, 2, 205, 195, 3, 2, 2, 2, 205, 196, 3, 2, 2, 2, 205, 197, 3, 2, 2, 2, 205, 202, 3, 2, 2, 2, 205, 203, 3, 2, 2, 2, 205, 204, 3, 2, 2, 2, 206, 212, 3, 2, 2, 2, 207, 208, 12, 17, 2, 2, 208, 209, 7, 123, 2, 2, 209, 211, 7, 124, 2, 2, 210, 207, 3, 2, 2, 2, 211, 214, 3, 2, 2, 2, 212, 210, 3, 2, 2, 2, 212, 213, 3, 2, 2, 2, 213, 21, 3, 2, 2, 2, 214, 212, 3, 2, 2, 2, 215, 220, 5, 24, 13, 2, 216, 217, 7, 128, 2, 2, 217, 219, 5, 24, 13, 2, 218, 216, 3, 2, 2, 2, 219, 222, 3, 2, 2, 2, 220, 218, 3, 2, 2, 2, 220, 221, 3, 2, 2, 2, 221, 23, 3, 2, 2, 2, 222, 220, 3, 2, 2, 2, 223, 224, 5, 18, 10, 2, 224, 225, 7, 130, 2, 2, 225, 226, 5, 20, 11, 2, 226, 25, 3, 2, 2, 2, 227, 228, 7, 13, 2, 2, 228, 229, 5, 18, 10, 2, 229, 230, 5, 28, 15, 2, 230, 27, 3, 2, 2, 2, 231, 233, 7, 121, 2, 2, 232, 234, 5, 30, 16, 2, 233, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 233, 3, 2, 2, 2, 235, 236, 3, 2, 2, 2, 236, 237, 3, 2, 2, 2, 237, 238, 7, 122, 2, 2, 238, 29, 3, 2, 2, 2, 239, 249, 5, 66, 34, 2, 240, 249, 5, 32, 17, 2, 241, 249, 5, 34, 18, 2, 242, 249, 5, 36, 19, 2, 243, 249, 5, 44, 23, 2, 244, 249, 5, 48, 25, 2, 245, 249, 5, 50, 26, 2, 246, 249, 5, 56, 29, 2, 247, 249, 5, 68, 35, 2, 248, 239, 3, 2, 2, 2, 248, 240, 3, 2, 2, 2, 248, 241, 3, 2, 2, 2, 248, 242, 3, 2, 2, 2, 248, 243, 3, 2, 2, 2, 248, 244, 3, 2, 2, 2, 248, 245, 3, 2, 2, 2, 248, 246, 3, 2, 2, 2, 248, 247, 3, 2, 2, 2, 249, 31, 3, 2, 2, 2, 250, 251, 7, 5, 2, 2, 251, 252, 5, 18, 10, 2, 252, 253, 7, 121, 2, 2, 253, 258, 5, 18, 10, 2, 254, 255, 7, 128, 2, 2, 255, 257, 5, 18, 10, 2, 256, 254, 3, 2, 2, 2, 257, 260, 3, 2, 2, 2, 258, 256, 3, 2, 2, 2, 258, 259, 3, 2, 2, 2, 259, 261, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 261, 262, 7, 122, 2, 2, 262, 33, 3, 2, 2, 2, 263, 264, 7, 83, 2, 2, 264, 265, 5, 18, 10, 2, 265, 266, 7, 121, 2, 2, 266, 267, 5, 20, 11, 2, 267, 268, 5, 18, 10, 2, 268, 275, 7, 127, 2, 2, 269, 270, 5, 20, 11, 2, 270, 271, 5, 18, 10, 2, 271, 272, 7, 127, 2, 2, 272, 274, 3, 2, 2, 2, 273, 269, 3, 2, 2, 2, 274, 277, 3, 2, 2, 2, 275, 273, 3, 2, 2, 2, 275, 276, 3, 2, 2, 2, 276, 278, 3, 2, 2, 2, 277, 275, 3, 2, 2, 2, 278, 279, 7, 122, 2, 2, 279, 35, 3, 2, 2, 2, 280, 281, 7, 82, 2, 2, 281, 282, 5, 18, 10, 2, 282, 284, 7, 125, 2, 2, 283, 285, 5, 38, 20, 2, 284, 283, 3, 2, 2, 2, 284, 285, 3, 2, 2, 2, 285, 286, 3, 2, 2, 2, 286, 287, 7, 126, 2, 2, 287, 288, 5, 42, 22, 2, 288, 37, 3, 2, 2, 2, 289, 294, 5, 40, 21, 2, 290, 291, 7, 128, 2, 2, 291, 293, 5, 40, 21, 2, 292, 290, 3, 2, 2, 2, 293, 296, 3, 2, 2, 2, 294, 292, 3, 2, 2, 2, 294, 295, 3, 2, 2, 2, 295, 39, 3, 2, 2, 2, 296, 294, 3, 2, 2, 2, 297, 298, 5, 20, 11, 2, 298, 299, 5, 18, 10, 2, 299, 41, 3, 2, 2, 2, 300, 301, 7, 121, 2, 2, 301, 302, 5, 80, 41, 2, 302, 303, 7, 122, 2, 2, 303, 43, 3, 2, 2, 2, 304, 305, 7, 52, 2, 2, 305, 306, 5, 18, 10, 2, 306, 307, 5, 46, 24, 2, 307, 45, 3, 2, 2, 2, 308, 309, 7, 121, 2, 2, 309, 310, 5, 80, 41, 2, 310, 311, 7, 122, 2, 2, 311, 47, 3, 2, 2, 2, 312, 313, 7, 6, 2, 2, 313, 314, 5, 18, 10, 2, 314, 323, 7, 125, 2, 2, 315, 320, 5, 20, 11, 2, 316, 317, 7, 128, 2, 2, 317, 319, 5, 20, 11, 2, 318, 316, 3, 2, 2, 2, 319, 322, 3, 2, 2, 2, 320, 318, 3, 2, 2, 2, 320, 321, 3, 2, 2, 2, 321, 324, 3, 2, 2, 2, 322, 320, 3, 2, 2, 2, 323, 315, 3, 2, 2, 2, 323, 324, 3, 2, 2, 2, 324, 325, 3, 2, 2, 2, 325, 326, 7, 126, 2, 2, 326, 327, 7, 127, 2, 2, 327, 49, 3, 2, 2, 2, 328, 329, 7, 31, 2, 2, 329, 331, 7, 125, 2, 2, 330, 332, 5, 58, 30, 2, 331, 330, 3, 2, 2, 2, 331, 332, 3, 2, 2, 2, 332, 333, 3, 2, 2, 2, 333, 335, 7, 126, 2, 2, 334, 336, 9, 3, 2, 2, 335, 334, 3, 2, 2, 2, 335, 336, 3, 2, 2, 2, 336, 337, 3, 2, 2, 2, 337, 344, 5, 52, 27, 2, 338, 339, 7, 57, 2, 2, 339, 341, 7, 123, 2, 2, 340, 342, 5, 88, 45, 2, 341, 340, 3, 2, 2, 2, 341, 342, 3, 2, 2, 2, 342, 343, 3, 2, 2, 2, 343, 345, 7, 124, 2, 2, 344, 338, 3, 2, 2, 2, 344, 345, 3, 2, 2, 2, 345, 352, 3, 2, 2, 2, 346, 347, 7, 58, 2, 2, 347, 349, 7, 123, 2, 2, 348, 350, 5, 88, 45, 2, 349, 348, 3, 2, 2, 2, 349, 350, 3, 2, 2, 2, 350, 351, 3, 2, 2, 2, 351, 353, 7, 124, 2, 2, 352, 346, 3, 2, 2, 2, 352, 353, 3, 2, 2, 2, 353, 354, 3, 2, 2, 2, 354, 355, 5, 62, 32, 2, 355, 51, 3, 2, 2, 2, 356, 357, 7, 64, 2, 2, 357, 359, 5, 80, 41, 2, 358, 356, 3, 2, 2, 2, 358, 359, 3, 2, 2, 2, 359, 362, 3, 2, 2, 2, 360, 361, 7, 62, 2, 2, 361, 363, 5, 80, 41, 2, 362, 360, 3, 2, 2, 2, 362, 363, 3, 2, 2, 2, 363, 365, 3, 2, 2, 2, 364, 366, 7, 33, 2, 2, 365, 364, 3, 2, 2, 2, 365, 366, 3, 2, 2, 2, 366, 368, 3, 2, 2, 2, 367, 369, 7, 34, 2, 2, 368, 367, 3, 2, 2, 2, 368, 369, 3, 2, 2, 2, 369, 372, 3, 2, 2, 2, 370, 371, 7, 86, 2, 2, 371, 373, 5, 80, 41, 2, 372, 370, 3, 2, 2, 2, 372, 373, 3, 2, 2, 2, 373, 376, 3, 2, 2, 2, 374, 375, 7, 74, 2, 2, 375, 377, 5, 80, 41, 2, 376, 374, 3, 2, 2, 2, 376, 377, 3, 2, 2, 2, 377, 445, 3, 2, 2, 2, 378, 380, 7, 33, 2, 2, 379, 378, 3, 2, 2, 2, 379, 380, 3, 2, 2, 2, 380, 382, 3, 2, 2, 2, 381, 383, 7, 34, 2, 2, 382, 381, 3, 2, 2, 2, 382, 383, 3, 2, 2, 2, 383, 386, 3, 2, 2, 2, 384, 385, 7, 64, 2, 2, 385, 387, 5, 80, 41, 2, 386, 384, 3, 2, 2, 2, 386, 387, 3, 2, 2, 2, 387, 390, 3, 2, 2, 2, 388, 389, 7, 62, 2, 2, 389, 391, 5, 80, 41, 2, 390, 388, 3, 2, 2, 2, 390, 391, 3, 2, 2, 2, 391, 394, 3, 2, 2, 2, 392, 393, 7, 86, 2, 2, 393, 395, 5, 80, 41, 2, 394, 392, 3, 2, 2, 2, 394, 395, 3, 2, 2, 2, 395, 398, 3, 2, 2, 2, 396, 397, 7, 74, 2, 2, 397, 399, 5, 80, 41, 2, 398, 396, 3, 2, 2, 2, 398, 399, 3, 2, 2, 2, 399, 445, 3, 2, 2, 2, 400, 401, 7, 64, 2, 2, 401, 403, 5, 80, 41, 2, 402, 400, 3, 2, 2, 2, 402, 403, 3, 2, 2, 2, 403, 406, 3, 2, 2, 2, 404, 405, 7, 86, 2, 2, 405, 407, 5, 80, 41, 2, 406, 404, 3, 2, 2, 2, 406, 407, 3, 2, 2, 2, 407, 409, 3, 2, 2, 2, 408, 410, 7, 33, 2, 2, 409, 408, 3, 2, 2, 2, 409, 410, 3, 2, 2, 2, 410, 412, 3, 2, 2, 2, 411, 413, 7, 34, 2, 2, 412, 411, 3, 2, 2, 2, 412, 413, 3, 2, 2, 2, 413, 416, 3, 2, 2, 2, 414, 415, 7, 62, 2, 2, 415, 417, 5, 80, 41, 2, 416, 414, 3, 2, 2, 2, 416, 417, 3, 2, 2, 2, 417, 420, 3, 2, 2, 2, 418, 419, 7, 74, 2, 2, 419, 421, 5, 80, 41, 2, 420, 418, 3, 2, 2, 2, 420, 421, 3, 2, 2, 2, 421, 445, 3, 2, 2, 2, 422, 423, 7, 64, 2, 2, 423, 425, 5, 80, 41, 2, 424, 422, 3, 2, 2, 2, 424, 425, 3, 2, 2, 2, 425, 428, 3, 2, 2, 2, 426, 427, 7, 86, 2, 2, 427, 429, 5, 80, 41, 2, 428, 426, 3, 2, 2, 2, 428, 429, 3, 2, 2, 2, 429, 432, 3, 2, 2, 2, 430, 431, 7, 62, 2, 2, 431, 433, 5, 80, 41, 2, 432, 430, 3, 2, 2, 2, 432, 433, 3, 2, 2, 2, 433, 435, 3, 2, 2, 2, 434, 436, 7, 33, 2, 2, 435, 434, 3, 2, 2, 2, 435, 436, 3, 2, 2, 2, 436, 438, 3, 2, 2, 2, 437, 439, 7, 34, 2, 2, 438, 437, 3, 2, 2, 2, 438, 439, 3, 2, 2, 2, 439, 442, 3, 2, 2, 2, 440, 441, 7, 74, 2, 2, 441, 443, 5, 80, 41, 2, 442, 440, 3, 2, 2, 2, 442, 443, 3, 2, 2, 2, 443, 445, 3, 2, 2, 2, 444, 358, 3, 2, 2, 2, 444, 379, 3, 2, 2, 2, 444, 402, 3, 2, 2, 2, 444, 424, 3, 2, 2, 2, 445, 53, 3, 2, 2, 2, 446, 447, 9, 4, 2, 2, 447, 55, 3, 2, 2, 2, 448, 453, 7, 70, 2, 2, 449, 453, 7, 41, 2, 2, 450, 451, 7, 45, 2, 2, 451, 453, 5, 18, 10, 2, 452, 448, 3, 2, 2, 2, 452, 449, 3, 2, 2, 2, 452, 450, 3, 2, 2, 2, 453, 454, 3, 2, 2, 2, 454, 456, 7, 125, 2, 2, 455, 457, 5, 58, 30, 2, 456, 455, 3, 2, 2, 2, 456, 457, 3, 2, 2, 2, 457, 458, 3, 2, 2, 2, 458, 460, 7, 126, 2, 2, 459, 461, 9, 3, 2, 2, 460, 459, 3, 2, 2, 2, 460, 461, 3, 2, 2, 2, 461, 463, 3, 2, 2, 2, 462, 464, 5, 54, 28, 2, 463, 462, 3, 2, 2, 2, 463, 464, 3, 2, 2, 2, 464, 465, 3, 2, 2, 2, 465, 472, 5, 52, 27, 2, 466, 467, 7, 57, 2, 2, 467, 469, 7, 123, 2, 2, 468, 470, 5, 88, 45, 2, 469, 468, 3, 2, 2, 2, 469, 470, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 473, 7, 124, 2, 2, 472, 466, 3, 2, 2, 2, 472, 473, 3, 2, 2, 2, 473, 480, 3, 2, 2, 2, 474, 475, 7, 58, 2, 2, 475, 477, 7, 123, 2, 2, 476, 478, 5, 88, 45, 2, 477, 476, 3, 2, 2, 2, 477, 478, 3, 2, 2, 2, 478, 479, 3, 2, 2, 2, 479, 481, 7, 124, 2, 2, 480, 474, 3, 2, 2, 2, 480, 481, 3, 2, 2, 2, 481, 490, 3, 2, 2, 2, 482, 483, 7, 72, 2, 2, 483, 484, 7, 125, 2, 2, 484, 486, 5, 20, 11, 2, 485, 487, 5, 18, 10, 2, 486, 485, 3, 2, 2, 2, 486, 487, 3, 2, 2, 2, 487, 488, 3, 2, 2, 2, 488, 489, 7, 126, 2, 2, 489, 491, 3, 2, 2, 2, 490, 482, 3, 2, 2, 2, 490, 491, 3, 2, 2, 2, 491, 492, 3, 2, 2, 2, 492, 493, 5, 62, 32, 2, 493, 57, 3, 2, 2, 2, 494, 499, 5, 60, 31, 2, 495, 496, 7, 128, 2, 2, 496, 498, 5, 60, 31, 2, 497, 495, 3, 2, 2, 2, 498, 501, 3, 2, 2, 2, 499, 497, 3, 2, 2, 2, 499, 500, 3, 2, 2, 2, 500, 59, 3, 2, 2, 2, 501, 499, 3, 2, 2, 2, 502, 503, 5, 20, 11, 2, 503, 504, 5, 18, 10, 2, 504, 61, 3, 2, 2, 2, 505, 510, 7, 121, 2, 2, 506, 509, 5, 66, 34, 2, 507, 509, 5, 72, 37, 2, 508, 506, 3, 2, 2, 2, 508, 507, 3, 2, 2, 2, 509, 512, 3, 2, 2, 2, 510, 508, 3, 2, 2, 2, 510, 511, 3, 2, 2, 2, 511, 513, 3, 2, 2, 2, 512, 510, 3, 2, 2, 2, 513, 514, 5, 64, 33, 2, 514, 515, 7, 122, 2, 2, 515, 63, 3, 2, 2, 2, 516, 518, 7, 71, 2, 2, 517, 519, 5, 80, 41, 2, 518, 517, 3, 2, 2, 2, 518, 519, 3, 2, 2, 2, 519, 520, 3, 2, 2, 2, 520, 521, 7, 127, 2, 2, 521, 65, 3, 2, 2, 2, 522, 523, 5, 20, 11, 2, 523, 526, 5, 18, 10, 2, 524, 525, 7, 111, 2, 2, 525, 527, 5, 80, 41, 2, 526, 524, 3, 2, 2, 2, 526, 527, 3, 2, 2, 2, 527, 528, 3, 2, 2, 2, 528, 529, 7, 127, 2, 2, 529, 67, 3, 2, 2, 2, 530, 531, 7, 90, 2, 2, 531, 532, 5, 18, 10, 2, 532, 535, 7, 42, 2, 2, 533, 536, 5, 20, 11, 2, 534, 536, 7, 116, 2, 2, 535, 533, 3, 2, 2, 2, 535, 534, 3, 2, 2, 2, 536, 537, 3, 2, 2, 2, 537, 538, 7, 127, 2, 2, 538, 69, 3, 2, 2, 2, 539, 540, 5, 20, 11, 2, 540, 541, 5, 18, 10, 2, 541, 542, 7, 111, 2, 2, 542, 543, 5, 80, 41, 2, 543, 549, 3, 2, 2, 2, 544, 545, 5, 18, 10, 2, 545, 546, 7, 111, 2, 2, 546, 547, 5, 80, 41, 2, 547, 549, 3, 2, 2, 2, 548, 539, 3, 2, 2, 2, 548, 544, 3, 2, 2, 2, 549, 71, 3, 2, 2, 2, 550, 554, 7, 121, 2, 2, 551, 553, 5, 72, 37, 2, 552, 551, 3, 2, 2, 2, 553, 556, 3, 2, 2, 2, 554, 552, 3, 2, 2, 2, 554, 555, 3, 2, 2, 2, 555, 557, 3, 2, 2, 2, 556, 554, 3, 2, 2, 2, 557, 772, 7, 122, 2, 2, 558, 559, 5, 76, 39, 2, 559, 560, 7, 129, 2, 2, 560, 561, 7, 69, 2, 2, 561, 562, 7, 125, 2, 2, 562, 563, 5, 80, 41, 2, 563, 564, 7, 126, 2, 2, 564, 565, 7, 127, 2, 2, 565, 772, 3, 2, 2, 2, 566, 567, 5, 76, 39, 2, 567, 568, 7, 129, 2, 2, 568, 569, 7, 61, 2, 2, 569, 570, 7, 125, 2, 2, 570, 571, 7, 126, 2, 2, 571, 572, 7, 127, 2, 2, 572, 772, 3, 2, 2, 2, 573, 574, 7, 36, 2, 2, 574, 575, 7, 125, 2, 2, 575, 578, 5, 76, 39, 2, 576, 577, 7, 128, 2, 2, 577, 579, 5, 80, 41, 2, 578, 576, 3, 2, 2, 2, 578, 579, 3, 2, 2, 2, 579, 580, 3, 2, 2, 2, 580, 581, 7, 126, 2, 2, 581, 582, 7, 127, 2, 2, 582, 772, 3, 2, 2, 2, 583, 584, 7, 20, 2, 2, 584, 587, 5, 80, 41, 2, 585, 586, 7, 128, 2, 2, 586, 588, 7, 96, 2, 2, 587, 585, 3, 2, 2, 2, 587, 588, 3, 2, 2, 2, 588, 589, 3, 2, 2, 2, 589, 590, 7, 127, 2, 2, 590, 772, 3, 2, 2, 2, 591, 592, 5, 76, 39, 2, 592, 593, 7, 111, 2, 2, 593, 594, 7, 59, 2, 2, 594, 595, 5, 18, 10, 2, 595, 597, 7, 125, 2, 2, 596, 598, 5, 88, 45, 2, 597, 596, 3, 2, 2, 2, 597, 598, 3, 2, 2, 2, 598, 599, 3, 2, 2, 2, 599, 600, 7, 126, 2, 2, 600, 601, 7, 127, 2, 2, 601, 772, 3, 2, 2, 2, 602, 603, 5, 80, 41, 2, 603, 604, 7, 129, 2, 2, 604, 605, 7, 27, 2, 2, 605, 606, 7, 125, 2, 2, 606, 607, 5, 88, 45, 2, 607, 608, 7, 126, 2, 2, 608, 609, 7, 127, 2, 2, 609, 772, 3, 2, 2, 2, 610, 611, 7, 4, 2, 2, 611, 612, 5, 18, 10, 2, 612, 613, 7, 111, 2, 2, 613, 614, 5, 80, 41, 2, 614, 615, 7, 129, 2, 2, 615, 616, 7, 27, 2, 2, 616, 617, 7, 125, 2, 2, 617, 618, 5, 88, 45, 2, 618, 619, 7, 126, 2, 2, 619, 620, 7, 127, 2, 2, 620, 772, 3, 2, 2, 2, 621, 622, 5, 76, 39, 2, 622, 623, 7, 111, 2, 2, 623, 624, 5, 80, 41, 2, 624, 625, 7, 129, 2, 2, 625, 626, 7, 27, 2, 2, 626, 627, 7, 125, 2, 2, 627, 628, 5, 88, 45, 2, 628, 629, 7, 126, 2, 2, 629, 630, 7, 127, 2, 2, 630, 772, 3, 2, 2, 2, 631, 632, 5, 80, 41, 2, 632, 633, 7, 129, 2, 2, 633, 634, 7, 29, 2, 2, 634, 635, 7, 125, 2, 2, 635, 636, 5, 88, 45, 2, 636, 637, 7, 126, 2, 2, 637, 638, 7, 127, 2, 2, 638, 772, 3, 2, 2, 2, 639, 640, 7, 8, 2, 2, 640, 641, 5, 18, 10, 2, 641, 642, 7, 111, 2, 2, 642, 643, 5, 80, 41, 2, 643, 644, 7, 129, 2, 2, 644, 645, 7, 29, 2, 2, 645, 646, 7, 125, 2, 2, 646, 647, 5, 88, 45, 2, 647, 648, 7, 126, 2, 2, 648, 649, 7, 127, 2, 2, 649, 772, 3, 2, 2, 2, 650, 651, 5, 80, 41, 2, 651, 652, 7, 129, 2, 2, 652, 653, 7, 28, 2, 2, 653, 654, 7, 125, 2, 2, 654, 655, 5, 88, 45, 2, 655, 656, 7, 126, 2, 2, 656, 657, 7, 127, 2, 2, 657, 772, 3, 2, 2, 2, 658, 659, 7, 4, 2, 2, 659, 660, 5, 18, 10, 2, 660, 661, 7, 111, 2, 2, 661, 662, 5, 80, 41, 2, 662, 663, 7, 129, 2, 2, 663, 664, 7, 28, 2, 2, 664, 665, 7, 125, 2, 2, 665, 666, 5, 88, 45, 2, 666, 667, 7, 126, 2, 2, 667, 668, 7, 127, 2, 2, 668, 772, 3, 2, 2, 2, 669, 670, 5, 76, 39, 2, 670, 671, 7, 129, 2, 2, 671, 672, 5, 18, 10, 2, 672, 674, 7, 125, 2, 2, 673, 675, 5, 88, 45, 2, 674, 673, 3, 2, 2, 2, 674, 675, 3, 2, 2, 2, 675, 676, 3, 2, 2, 2, 676, 677, 7, 126, 2, 2, 677, 678, 7, 127, 2, 2, 678, 772, 3, 2, 2, 2, 679, 680, 5, 76, 39, 2, 680, 681, 7, 111, 2, 2, 681, 682, 5, 76, 39, 2, 682, 683, 7, 129, 2, 2, 683, 684, 5, 18, 10, 2, 684, 686, 7, 125, 2, 2, 685, 687, 5, 88, 45, 2, 686, 685, 3, 2, 2, 2, 686, 687, 3, 2, 2, 2, 687, 688, 3, 2, 2, 2, 688, 689, 7, 126, 2, 2, 689, 690, 7, 127, 2, 2, 690, 772, 3, 2, 2, 2, 691, 692, 5, 76, 39, 2, 692, 693, 7, 111, 2, 2, 693, 694, 5, 90, 46, 2, 694, 695, 7, 127, 2, 2, 695, 772, 3, 2, 2, 2, 696, 697, 7, 46, 2, 2, 697, 698, 7, 125, 2, 2, 698, 699, 5, 80, 41, 2, 699, 700, 7, 126, 2, 2, 700, 702, 5, 72, 37, 2, 701, 703, 5, 74, 38, 2, 702, 701, 3, 2, 2, 2, 702, 703, 3, 2, 2, 2, 703, 772, 3, 2, 2, 2, 704, 705, 7, 42, 2, 2, 705, 706, 7, 125, 2, 2, 706, 711, 5, 70, 36, 2, 707, 708, 7, 128, 2, 2, 708, 710, 5, 70, 36, 2, 709, 707, 3, 2, 2, 2, 710, 713, 3, 2, 2, 2, 711, 709, 3, 2, 2, 2, 711, 712, 3, 2, 2, 2, 712, 714, 3, 2, 2, 2, 713, 711, 3, 2, 2, 2, 714, 715, 7, 127, 2, 2, 715, 716, 5, 80, 41, 2, 716, 717, 7, 127, 2, 2, 717, 718, 5, 80, 41, 2, 718, 719, 7, 127, 2, 2, 719, 720, 7, 126, 2, 2, 720, 721, 5, 72, 37, 2, 721, 772, 3, 2, 2, 2, 722, 723, 5, 18, 10, 2, 723, 725, 7, 125, 2, 2, 724, 726, 5, 88, 45, 2, 725, 724, 3, 2, 2, 2, 725, 726, 3, 2, 2, 2, 726, 727, 3, 2, 2, 2, 727, 728, 7, 126, 2, 2, 728, 729, 7, 127, 2, 2, 729, 772, 3, 2, 2, 2, 730, 731, 7, 80, 2, 2, 731, 732, 7, 125, 2, 2, 732, 733, 5, 80, 41, 2, 733, 734, 7, 128, 2, 2, 734, 735, 7, 39, 2, 2, 735, 736, 7, 128, 2, 2, 736, 737, 5, 80, 41, 2, 737, 738, 7, 126, 2, 2, 738, 739, 7, 127, 2, 2, 739, 772, 3, 2, 2, 2, 740, 741, 5, 80, 41, 2, 741, 742, 7, 129, 2, 2, 742, 743, 7, 85, 2, 2, 743, 744, 7, 125, 2, 2, 744, 745, 5, 80, 41, 2, 745, 746, 7, 126, 2, 2, 746, 747, 7, 127, 2, 2, 747, 772, 3, 2, 2, 2, 748, 749, 7, 38, 2, 2, 749, 750, 5, 18, 10, 2, 750, 751, 7, 125, 2, 2, 751, 756, 5, 80, 41, 2, 752, 753, 7, 128, 2, 2, 753, 755, 5, 80, 41, 2, 754, 752, 3, 2, 2, 2, 755, 758, 3, 2, 2, 2, 756, 754, 3, 2, 2, 2, 756, 757, 3, 2, 2, 2, 757, 759, 3, 2, 2, 2, 758, 756, 3, 2, 2, 2, 759, 760, 7, 126, 2, 2, 760, 761, 7, 127, 2, 2, 761, 772, 3, 2, 2, 2, 762, 763, 7, 73, 2, 2, 763, 764, 7, 125, 2, 2, 764, 767, 7, 96, 2, 2, 765, 766, 7, 128, 2, 2, 766, 768, 5, 88, 45, 2, 767, 765, 3, 2, 2, 2, 767, 768, 3, 2, 2, 2, 768, 769, 3, 2, 2, 2, 769, 770, 7, 126, 2, 2, 770, 772, 7, 127, 2, 2, 771, 550, 3, 2, 2, 2, 771, 558, 3, 2, 2, 2, 771, 566, 3, 2, 2, 2, 771, 573, 3, 2, 2, 2, 771, 583, 3, 2, 2, 2, 771, 591, 3, 2, 2, 2, 771, 602, 3, 2, 2, 2, 771, 610, 3, 2, 2, 2, 771, 621, 3, 2, 2, 2, 771, 631, 3, 2, 2, 2, 771, 639, 3, 2, 2, 2, 771, 650, 3, 2, 2, 2, 771, 658, 3, 2, 2, 2, 771, 669, 3, 2, 2, 2, 771, 679, 3, 2, 2, 2, 771, 691, 3, 2, 2, 2, 771, 696, 3, 2, 2, 2, 771, 704, 3, 2, 2, 2, 771, 722, 3, 2, 2, 2, 771, 730, 3, 2, 2, 2, 771, 740, 3, 2, 2, 2, 771, 748, 3, 2, 2, 2, 771, 762, 3, 2, 2, 2, 772, 73, 3, 2, 2, 2, 773, 774, 7, 37, 2, 2, 774, 775, 5, 72, 37, 2, 775, 75, 3, 2, 2, 2, 776, 777, 8, 39, 1, 2, 777, 778, 5, 18, 10, 2, 778, 789, 3, 2, 2, 2, 779, 780, 12, 4, 2, 2, 780, 781, 7, 129, 2, 2, 781, 788, 5, 18, 10, 2, 782, 783, 12, 3, 2, 2, 783, 784, 7, 123, 2, 2, 784, 785, 5, 80, 41, 2, 785, 786, 7, 124, 2, 2, 786, 788, 3, 2, 2, 2, 787, 779, 3, 2, 2, 2, 787, 782, 3, 2, 2, 2, 788, 791, 3, 2, 2, 2, 789, 787, 3, 2, 2, 2, 789, 790, 3, 2, 2, 2, 790, 77, 3, 2, 2, 2, 791, 789, 3, 2, 2, 2, 792, 793, 7, 125, 2, 2, 793, 794, 5, 18, 10, 2, 794, 795, 7, 128, 2, 2, 795, 800, 5, 80, 41, 2, 796, 797, 7, 128, 2, 2, 797, 799, 5, 80, 41, 2, 798, 796, 3, 2, 2, 2, 799, 802, 3, 2, 2, 2, 800, 798, 3, 2, 2, 2, 800, 801, 3, 2, 2, 2, 801, 803, 3, 2, 2, 2, 802, 800, 3, 2, 2, 2, 803, 804, 7, 126, 2, 2, 804, 814, 3, 2, 2, 2, 805, 806, 7, 125, 2, 2, 806, 807, 5, 80, 41, 2, 807, 808, 7, 128, 2, 2, 808, 809, 7, 39, 2, 2, 809, 810, 7, 128, 2, 2, 810, 811, 5, 80, 41, 2, 811, 812, 7, 126, 2, 2, 812, 814, 3, 2, 2, 2, 813, 792, 3, 2, 2, 2, 813, 805, 3, 2, 2, 2, 814, 79, 3, 2, 2, 2, 815, 816, 8, 41, 1, 2, 816, 949, 5, 82, 42, 2, 817, 818, 7, 125, 2, 2, 818, 819, 5, 80, 41, 2, 819, 820, 7, 126, 2, 2, 820, 949, 3, 2, 2, 2, 821, 822, 5, 18, 10, 2, 822, 823, 7, 129, 2, 2, 823, 824, 5, 18, 10, 2, 824, 826, 7, 125, 2, 2, 825, 827, 5, 88, 45, 2, 826, 825, 3, 2, 2, 2, 826, 827, 3, 2, 2, 2, 827, 828, 3, 2, 2, 2, 828, 829, 7, 126, 2, 2, 829, 949, 3, 2, 2, 2, 830, 831, 5, 18, 10, 2, 831, 833, 7, 125, 2, 2, 832, 834, 5, 88, 45, 2, 833, 832, 3, 2, 2, 2, 833, 834, 3, 2, 2, 2, 834, 835, 3, 2, 2, 2, 835, 836, 7, 126, 2, 2, 836, 949, 3, 2, 2, 2, 837, 838, 7, 43, 2, 2, 838, 839, 7, 125, 2, 2, 839, 840, 5, 38, 20, 2, 840, 841, 7, 126, 2, 2, 841, 842, 7, 125, 2, 2, 842, 843, 5, 80, 41, 2, 843, 844, 7, 126, 2, 2, 844, 949, 3, 2, 2, 2, 845, 846, 7, 40, 2, 2, 846, 847, 7, 125, 2, 2, 847, 848, 5, 38, 20, 2, 848, 849, 7, 126, 2, 2, 849, 850, 7, 125, 2, 2, 850, 851, 5, 80, 41, 2, 851, 852, 7, 126, 2, 2, 852, 949, 3, 2, 2, 2, 853, 854, 9, 5, 2, 2, 854, 949, 5, 80, 41, 23, 855, 856, 7, 77, 2, 2, 856, 857, 7, 125, 2, 2, 857, 858, 5, 80, 41, 2, 858, 859, 7, 128, 2, 2, 859, 860, 5, 80, 41, 2, 860, 861, 7, 126, 2, 2, 861, 949, 3, 2, 2, 2, 862, 863, 7, 76, 2, 2, 863, 864, 7, 125, 2, 2, 864, 865, 5, 80, 41, 2, 865, 866, 7, 128, 2, 2, 866, 867, 5, 80, 41, 2, 867, 868, 7, 126, 2, 2, 868, 949, 3, 2, 2, 2, 869, 870, 7, 78, 2, 2, 870, 871, 7, 125, 2, 2, 871, 872, 5, 80, 41, 2, 872, 873, 7, 128, 2, 2, 873, 874, 5, 80, 41, 2, 874, 875, 7, 126, 2, 2, 875, 949, 3, 2, 2, 2, 876, 877, 7, 75, 2, 2, 877, 878, 7, 125, 2, 2, 878, 879, 5, 80, 41, 2, 879, 880, 7, 128, 2, 2, 880, 881, 5, 80, 41, 2, 881, 882, 7, 126, 2, 2, 882, 949, 3, 2, 2, 2, 883, 884, 7, 79, 2, 2, 884, 885, 7, 125, 2, 2, 885, 886, 5, 80, 41, 2, 886, 887, 7, 128, 2, 2, 887, 888, 5, 80, 41, 2, 888, 889, 7, 126, 2, 2, 889, 949, 3, 2, 2, 2, 890, 891, 5, 18, 10, 2, 891, 892, 7, 125, 2, 2, 892, 893, 5, 80, 41, 2, 893, 894, 7, 126, 2, 2, 894, 949, 3, 2, 2, 2, 895, 896, 7, 59, 2, 2, 896, 897, 5, 18, 10, 2, 897, 899, 7, 125, 2, 2, 898, 900, 5, 88, 45, 2, 899, 898, 3, 2, 2, 2, 899, 900, 3, 2, 2, 2, 900, 901, 3, 2, 2, 2, 901, 902, 7, 126, 2, 2, 902, 949, 3, 2, 2, 2, 903, 904, 5, 18, 10, 2, 904, 905, 7, 129, 2, 2, 905, 906, 7, 18, 2, 2, 906, 907, 7, 125, 2, 2, 907, 908, 7, 59, 2, 2, 908, 909, 5, 18, 10, 2, 909, 911, 7, 125, 2, 2, 910, 912, 5, 88, 45, 2, 911, 910, 3, 2, 2, 2, 911, 912, 3, 2, 2, 2, 912, 913, 3, 2, 2, 2, 913, 914, 7, 126, 2, 2, 914, 915, 7, 126, 2, 2, 915, 949, 3, 2, 2, 2, 916, 917, 7, 51, 2, 2, 917, 918, 7, 125, 2, 2, 918, 919, 5, 80, 41, 2, 919, 920, 7, 128, 2, 2, 920, 921, 5, 80, 41, 2, 921, 922, 7, 128, 2, 2, 922, 923, 5, 80, 41, 2, 923, 924, 7, 126, 2, 2, 924, 949, 3, 2, 2, 2, 925, 926, 7, 35, 2, 2, 926, 927, 7, 125, 2, 2, 927, 928, 5, 20, 11, 2, 928, 929, 7, 126, 2, 2, 929, 949, 3, 2, 2, 2, 930, 936, 5, 78, 40, 2, 931, 932, 7, 130, 2, 2, 932, 933, 7, 130, 2, 2, 933, 935, 5, 78, 40, 2, 934, 931, 3, 2, 2, 2, 935, 938, 3, 2, 2, 2, 936, 934, 3, 2, 2, 2, 936, 937, 3, 2, 2, 2, 937, 939, 3, 2, 2, 2, 938, 936, 3, 2, 2, 2, 939, 940, 7, 130, 2, 2, 940, 941, 7, 130, 2, 2, 941, 942, 5, 82, 42, 2, 942, 949, 3, 2, 2, 2, 943, 944, 7, 60, 2, 2, 944, 945, 7, 125, 2, 2, 945, 946, 5, 80, 41, 2, 946, 947, 7, 126, 2, 2, 947, 949, 3, 2, 2, 2, 948, 815, 3, 2, 2, 2, 948, 817, 3, 2, 2, 2, 948, 821, 3, 2, 2, 2, 948, 830, 3, 2, 2, 2, 948, 837, 3, 2, 2, 2, 948, 845, 3, 2, 2, 2, 948, 853, 3, 2, 2, 2, 948, 855, 3, 2, 2, 2, 948, 862, 3, 2, 2, 2, 948, 869, 3, 2, 2, 2, 948, 876, 3, 2, 2, 2, 948, 883, 3, 2, 2, 2, 948, 890, 3, 2, 2, 2, 948, 895, 3, 2, 2, 2, 948, 903, 3, 2, 2, 2, 948, 916, 3, 2, 2, 2, 948, 925, 3, 2, 2, 2, 948, 930, 3, 2, 2, 2, 948, 943, 3, 2, 2, 2, 949, 999, 3, 2, 2, 2, 950, 951, 12, 22, 2, 2, 951, 952, 9, 6, 2, 2, 952, 998, 5, 80, 41, 23, 953, 954, 12, 18, 2, 2, 954, 955, 9, 7, 2, 2, 955, 998, 5, 80, 41, 19, 956, 957, 12, 15, 2, 2, 957, 958, 9, 8, 2, 2, 958, 998, 5, 80, 41, 16, 959, 960, 12, 14, 2, 2, 960, 961, 9, 9, 2, 2, 961, 998, 5, 80, 41, 15, 962, 963, 12, 13, 2, 2, 963, 964, 7, 99, 2, 2, 964, 998, 5, 80, 41, 14, 965, 966, 12, 12, 2, 2, 966, 967, 7, 100, 2, 2, 967, 998, 5, 80, 41, 13, 968, 969, 12, 11, 2, 2, 969, 970, 9, 10, 2, 2, 970, 998, 5, 80, 41, 12, 971, 972, 12, 29, 2, 2, 972, 973, 7, 129, 2, 2, 973, 998, 5, 18, 10, 2, 974, 975, 12, 28, 2, 2, 975, 976, 7, 123, 2, 2, 976, 977, 5, 80, 41, 2, 977, 978, 7, 124, 2, 2, 978, 998, 3, 2, 2, 2, 979, 980, 12, 27, 2, 2, 980, 981, 7, 129, 2, 2, 981, 982, 7, 55, 2, 2, 982, 983, 7, 125, 2, 2, 983, 998, 7, 126, 2, 2, 984, 985, 12, 10, 2, 2, 985, 986, 7, 101, 2, 2, 986, 994, 5, 80, 41, 2, 987, 988, 7, 128, 2, 2, 988, 989, 5, 80, 41, 2, 989, 990, 7, 101, 2, 2, 990, 991, 5, 80, 41, 2, 991, 993, 3, 2, 2, 2, 992, 987, 3, 2, 2, 2, 993, 996, 3, 2, 2, 2, 994, 992, 3, 2, 2, 2, 994, 995, 3, 2, 2, 2, 995, 998, 3, 2, 2, 2, 996, 994, 3, 2, 2, 2, 997, 950, 3, 2, 2, 2, 997, 953, 3, 2, 2, 2, 997, 956, 3, 2, 2, 2, 997, 959, 3, 2, 2, 2, 997, 962, 3, 2, 2, 2, 997, 965, 3, 2, 2, 2, 997, 968, 3, 2, 2, 2, 997, 971, 3, 2, 2, 2, 997, 974, 3, 2, 2, 2, 997, 979, 3, 2, 2, 2, 997, 984, 3, 2, 2, 2, 998, 1001, 3, 2, 2, 2, 999, 997, 3, 2, 2, 2, 999, 1000, 3, 2, 2, 2, 1000, 81, 3, 2, 2, 2, 1001, 999, 3, 2, 2, 2, 1002, 1045, 5, 18, 10, 2, 1003, 1045, 7, 91, 2, 2, 1004, 1045, 7, 21, 2, 2, 1005, 1045, 7, 81, 2, 2, 1006, 1045, 7, 87, 2, 2, 1007, 1045, 7, 88, 2, 2, 1008, 1045, 7, 22, 2, 2, 1009, 1045, 7, 23, 2, 2, 1010, 1045, 7, 24, 2, 2, 1011, 1045, 7, 25, 2, 2, 1012, 1045, 7, 26, 2, 2, 1013, 1045, 7, 56, 2, 2, 1014, 1045, 7, 49, 2, 2, 1015, 1045, 7, 50, 2, 2, 1016, 1045, 7, 89, 2, 2, 1017, 1018, 7, 59, 2, 2, 1018, 1019, 7, 125, 2, 2, 1019, 1020, 5, 18, 10, 2, 1020, 1021, 7, 126, 2, 2, 1021, 1045, 3, 2, 2, 2, 1022, 1023, 7, 59, 2, 2, 1023, 1024, 7, 125, 2, 2, 1024, 1025, 7, 21, 2, 2, 1025, 1045, 7, 126, 2, 2, 1026, 1027, 7, 59, 2, 2, 1027, 1028, 7, 125, 2, 2, 1028, 1029, 7, 56, 2, 2, 1029, 1045, 7, 126, 2, 2, 1030, 1045, 7, 93, 2, 2, 1031, 1045, 7, 94, 2, 2, 1032, 1045, 7, 95, 2, 2, 1033, 1045, 7, 96, 2, 2, 1034, 1045, 7, 84, 2, 2, 1035, 1036, 7, 3, 2, 2, 1036, 1037, 7, 125, 2, 2, 1037, 1038, 7, 84, 2, 2, 1038, 1045, 7, 126, 2, 2, 1039, 1040, 7, 3, 2, 2, 1040, 1041, 7, 125, 2, 2, 1041, 1042, 5, 18, 10, 2, 1042, 1043, 7, 126, 2, 2, 1043, 1045, 3, 2, 2, 2, 1044, 1002, 3, 2, 2, 2, 1044, 1003, 3, 2, 2, 2, 1044, 1004, 3, 2, 2, 2, 1044, 1005, 3, 2, 2, 2, 1044, 1006, 3, 2, 2, 2, 1044, 1007, 3, 2, 2, 2, 1044, 1008, 3, 2, 2, 2, 1044, 1009, 3, 2, 2, 2, 1044, 1010, 3, 2, 2, 2, 1044, 1011, 3, 2, 2, 2, 1044, 1012, 3, 2, 2, 2, 1044, 1013, 3, 2, 2, 2, 1044, 1014, 3, 2, 2, 2, 1044, 1015, 3, 2, 2, 2, 1044, 1016, 3, 2, 2, 2, 1044, 1017, 3, 2, 2, 2, 1044, 1022, 3, 2, 2, 2, 1044, 1026, 3, 2, 2, 2, 1044, 1030, 3, 2, 2, 2, 1044, 1031, 3, 2, 2, 2, 1044, 1032, 3, 2, 2, 2, 1044, 1033, 3, 2, 2, 2, 1044, 1034, 3, 2, 2, 2, 1044, 1035, 3, 2, 2, 2, 1044, 1039, 3, 2, 2, 2, 1045, 83, 3, 2, 2, 2, 1046, 1047, 5, 90, 46, 2, 1047, 1048, 7, 128, 2, 2, 1048, 1057, 3, 2, 2, 2, 1049, 1052, 5, 90, 46, 2, 1050, 1051, 7, 128, 2, 2, 1051, 1053, 5, 90, 46, 2, 1052, 1050, 3, 2, 2, 2, 1053, 1054, 3, 2, 2, 2, 1054, 1052, 3, 2, 2, 2, 1054, 1055, 3, 2, 2, 2, 1055, 1057, 3, 2, 2, 2, 1056, 1046, 3, 2, 2, 2, 1056, 1049, 3, 2, 2, 2, 1057, 85, 3, 2, 2, 2, 1058, 1059, 5, 18, 10, 2, 1059, 1060, 7, 111, 2, 2, 1060, 1061, 5, 90, 46, 2, 1061, 1062, 7, 128, 2, 2, 1062, 1076, 3, 2, 2, 2, 1063, 1064, 5, 18, 10, 2, 1064, 1065, 7, 111, 2, 2, 1065, 1071, 5, 90, 46, 2, 1066, 1067, 7, 128, 2, 2, 1067, 1068, 5, 18, 10, 2, 1068, 1069, 7, 111, 2, 2, 1069, 1070, 5, 90, 46, 2, 1070, 1072, 3, 2, 2, 2, 1071, 1066, 3, 2, 2, 2, 1072, 1073, 3, 2, 2, 2, 1073, 1071, 3, 2, 2, 2, 1073, 1074, 3, 2, 2, 2, 1074, 1076, 3, 2, 2, 2, 1075, 1058, 3, 2, 2, 2, 1075, 1063, 3, 2, 2, 2, 1076, 87, 3, 2, 2, 2, 1077, 1082, 5, 90, 46, 2, 1078, 1079, 7, 128, 2, 2, 1079, 1081, 5, 90, 46, 2, 1080, 1078, 3, 2, 2, 2, 1081, 1084, 3, 2, 2, 2, 1082, 1080, 3, 2, 2, 2, 1082, 1083, 3, 2, 2, 2, 1083, 89, 3, 2, 2, 2, 1084, 1082, 3, 2, 2, 2, 1085, 1086, 5, 80, 41, 2, 1086, 91, 3, 2, 2, 2, 107, 95, 97, 109, 113, 116, 126, 130, 136, 140, 146, 156, 164, 168, 173, 192, 205, 212, 220, 235, 248, 258, 275, 284, 294, 320, 323, 331, 335, 341, 344, 349, 352, 358, 362, 365, 368, 372, 376, 379, 382, 386, 390, 394, 398, 402, 406, 409, 412, 416, 420, 424, 428, 432, 435, 438, 442, 444, 452, 456, 460, 463, 469, 472, 477, 480, 486, 490, 499, 508, 510, 518, 526, 535, 548, 554, 578, 587, 597, 674, 686, 702, 711, 725, 756, 767, 771, 787, 789, 800, 813, 826, 833, 899, 911, 936, 948, 994, 997, 999, 1044, 1054, 1056, 1073, 1075, 1082] \ No newline at end of file diff --git a/Celestial/Compiler/CelestialParser.py b/Celestial/Compiler/CelestialParser.py new file mode 100644 index 00000000..1749ca29 --- /dev/null +++ b/Celestial/Compiler/CelestialParser.py @@ -0,0 +1,6255 @@ +# Generated from CelestialParser.g4 by ANTLR 4.7.1 +# encoding: utf-8 +from antlr4 import * +from io import StringIO +from typing.io import TextIO +import sys + +def serializedATN(): + with StringIO() as buf: + buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\u0086") + buf.write("\u0440\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7") + buf.write("\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16") + buf.write("\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23") + buf.write("\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31") + buf.write("\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36") + buf.write("\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t") + buf.write("&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.\t.\3") + buf.write("\2\3\2\3\2\7\2`\n\2\f\2\16\2c\13\2\3\2\3\2\3\3\3\3\3\3") + buf.write("\3\3\3\3\3\4\3\4\5\4n\n\4\3\5\3\5\5\5r\n\5\3\6\5\6u\n") + buf.write("\6\3\6\3\6\3\7\3\7\3\b\3\b\6\b}\n\b\r\b\16\b~\3\b\3\b") + buf.write("\5\b\u0083\n\b\3\b\3\b\3\b\3\b\5\b\u0089\n\b\3\b\3\b\5") + buf.write("\b\u008d\n\b\3\b\3\b\6\b\u0091\n\b\r\b\16\b\u0092\3\b") + buf.write("\3\b\3\b\3\b\3\b\3\b\7\b\u009b\n\b\f\b\16\b\u009e\13\b") + buf.write("\3\b\3\b\3\b\6\b\u00a3\n\b\r\b\16\b\u00a4\3\b\3\b\5\b") + buf.write("\u00a9\n\b\3\t\3\t\3\t\5\t\u00ae\n\t\3\n\3\n\3\13\3\13") + buf.write("\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13") + buf.write("\3\13\3\13\5\13\u00c1\n\13\3\13\3\13\3\13\3\13\3\13\3") + buf.write("\13\3\13\3\13\3\13\3\13\3\13\5\13\u00ce\n\13\3\13\3\13") + buf.write("\3\13\7\13\u00d3\n\13\f\13\16\13\u00d6\13\13\3\f\3\f\3") + buf.write("\f\7\f\u00db\n\f\f\f\16\f\u00de\13\f\3\r\3\r\3\r\3\r\3") + buf.write("\16\3\16\3\16\3\16\3\17\3\17\6\17\u00ea\n\17\r\17\16\17") + buf.write("\u00eb\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3") + buf.write("\20\3\20\5\20\u00f9\n\20\3\21\3\21\3\21\3\21\3\21\3\21") + buf.write("\7\21\u0101\n\21\f\21\16\21\u0104\13\21\3\21\3\21\3\22") + buf.write("\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\7\22\u0112") + buf.write("\n\22\f\22\16\22\u0115\13\22\3\22\3\22\3\23\3\23\3\23") + buf.write("\3\23\5\23\u011d\n\23\3\23\3\23\3\23\3\24\3\24\3\24\7") + buf.write("\24\u0125\n\24\f\24\16\24\u0128\13\24\3\25\3\25\3\25\3") + buf.write("\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\30\3\30\3\30") + buf.write("\3\30\3\31\3\31\3\31\3\31\3\31\3\31\7\31\u013f\n\31\f") + buf.write("\31\16\31\u0142\13\31\5\31\u0144\n\31\3\31\3\31\3\31\3") + buf.write("\32\3\32\3\32\5\32\u014c\n\32\3\32\3\32\5\32\u0150\n\32") + buf.write("\3\32\3\32\3\32\3\32\5\32\u0156\n\32\3\32\5\32\u0159\n") + buf.write("\32\3\32\3\32\3\32\5\32\u015e\n\32\3\32\5\32\u0161\n\32") + buf.write("\3\32\3\32\3\33\3\33\5\33\u0167\n\33\3\33\3\33\5\33\u016b") + buf.write("\n\33\3\33\5\33\u016e\n\33\3\33\5\33\u0171\n\33\3\33\3") + buf.write("\33\5\33\u0175\n\33\3\33\3\33\5\33\u0179\n\33\3\33\5\33") + buf.write("\u017c\n\33\3\33\5\33\u017f\n\33\3\33\3\33\5\33\u0183") + buf.write("\n\33\3\33\3\33\5\33\u0187\n\33\3\33\3\33\5\33\u018b\n") + buf.write("\33\3\33\3\33\5\33\u018f\n\33\3\33\3\33\5\33\u0193\n\33") + buf.write("\3\33\3\33\5\33\u0197\n\33\3\33\5\33\u019a\n\33\3\33\5") + buf.write("\33\u019d\n\33\3\33\3\33\5\33\u01a1\n\33\3\33\3\33\5\33") + buf.write("\u01a5\n\33\3\33\3\33\5\33\u01a9\n\33\3\33\3\33\5\33\u01ad") + buf.write("\n\33\3\33\3\33\5\33\u01b1\n\33\3\33\5\33\u01b4\n\33\3") + buf.write("\33\5\33\u01b7\n\33\3\33\3\33\5\33\u01bb\n\33\5\33\u01bd") + buf.write("\n\33\3\34\3\34\3\35\3\35\3\35\3\35\5\35\u01c5\n\35\3") + buf.write("\35\3\35\5\35\u01c9\n\35\3\35\3\35\5\35\u01cd\n\35\3\35") + buf.write("\5\35\u01d0\n\35\3\35\3\35\3\35\3\35\5\35\u01d6\n\35\3") + buf.write("\35\5\35\u01d9\n\35\3\35\3\35\3\35\5\35\u01de\n\35\3\35") + buf.write("\5\35\u01e1\n\35\3\35\3\35\3\35\3\35\5\35\u01e7\n\35\3") + buf.write("\35\3\35\5\35\u01eb\n\35\3\35\3\35\3\36\3\36\3\36\7\36") + buf.write("\u01f2\n\36\f\36\16\36\u01f5\13\36\3\37\3\37\3\37\3 \3") + buf.write(" \3 \7 \u01fd\n \f \16 \u0200\13 \3 \3 \3 \3!\3!\5!\u0207") + buf.write("\n!\3!\3!\3\"\3\"\3\"\3\"\5\"\u020f\n\"\3\"\3\"\3#\3#") + buf.write("\3#\3#\3#\5#\u0218\n#\3#\3#\3$\3$\3$\3$\3$\3$\3$\3$\3") + buf.write("$\5$\u0225\n$\3%\3%\7%\u0229\n%\f%\16%\u022c\13%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\5%\u0243\n%\3%\3%\3%\3%\3%\3%\3%\5%\u024c\n%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\5%\u0256\n%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\5%\u02a3\n%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\5%\u02af\n%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\5%\u02bf\n%\3%\3%\3%\3%\3") + buf.write("%\7%\u02c6\n%\f%\16%\u02c9\13%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\5%\u02d6\n%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3") + buf.write("%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\3%\7%\u02f3") + buf.write("\n%\f%\16%\u02f6\13%\3%\3%\3%\3%\3%\3%\3%\3%\5%\u0300") + buf.write("\n%\3%\3%\5%\u0304\n%\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'") + buf.write("\3\'\3\'\3\'\3\'\3\'\7\'\u0314\n\'\f\'\16\'\u0317\13\'") + buf.write("\3(\3(\3(\3(\3(\3(\7(\u031f\n(\f(\16(\u0322\13(\3(\3(") + buf.write("\3(\3(\3(\3(\3(\3(\3(\3(\5(\u032e\n(\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\5)\u033b\n)\3)\3)\3)\3)\3)\5)\u0342\n") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\5)\u0384\n)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\5)\u0390\n)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\7)\u03a7\n)\f") + buf.write(")\16)\u03aa\13)\3)\3)\3)\3)\3)\3)\3)\3)\3)\5)\u03b5\n") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3") + buf.write(")\3)\3)\3)\3)\3)\3)\7)\u03e1\n)\f)\16)\u03e4\13)\7)\u03e6") + buf.write("\n)\f)\16)\u03e9\13)\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*") + buf.write("\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3") + buf.write("*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\3*\5*\u0415\n*\3") + buf.write("+\3+\3+\3+\3+\3+\6+\u041d\n+\r+\16+\u041e\5+\u0421\n+") + buf.write("\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\6,\u0430\n,\r") + buf.write(",\16,\u0431\5,\u0434\n,\3-\3-\3-\7-\u0439\n-\f-\16-\u043c") + buf.write("\13-\3.\3.\3.\2\5\24LP/\2\4\6\b\n\f\16\20\22\24\26\30") + buf.write("\32\34\36 \"$&(*,.\60\62\64\668:<>@BDFHJLNPRTVXZ\2\13") + buf.write("\5\2jmoowx\3\2BC\5\2\36\36DD\\\\\4\2bbss\3\2tv\3\2rs\4") + buf.write("\2\60\60jm\3\2hi\3\2fg\2\u04d9\2a\3\2\2\2\4f\3\2\2\2\6") + buf.write("m\3\2\2\2\bo\3\2\2\2\nt\3\2\2\2\fx\3\2\2\2\16\u00a8\3") + buf.write("\2\2\2\20\u00aa\3\2\2\2\22\u00af\3\2\2\2\24\u00cd\3\2") + buf.write("\2\2\26\u00d7\3\2\2\2\30\u00df\3\2\2\2\32\u00e3\3\2\2") + buf.write("\2\34\u00e7\3\2\2\2\36\u00f8\3\2\2\2 \u00fa\3\2\2\2\"") + buf.write("\u0107\3\2\2\2$\u0118\3\2\2\2&\u0121\3\2\2\2(\u0129\3") + buf.write("\2\2\2*\u012c\3\2\2\2,\u0130\3\2\2\2.\u0134\3\2\2\2\60") + buf.write("\u0138\3\2\2\2\62\u0148\3\2\2\2\64\u01bc\3\2\2\2\66\u01be") + buf.write("\3\2\2\28\u01c4\3\2\2\2:\u01ee\3\2\2\2<\u01f6\3\2\2\2") + buf.write(">\u01f9\3\2\2\2@\u0204\3\2\2\2B\u020a\3\2\2\2D\u0212\3") + buf.write("\2\2\2F\u0224\3\2\2\2H\u0303\3\2\2\2J\u0305\3\2\2\2L\u0308") + buf.write("\3\2\2\2N\u032d\3\2\2\2P\u03b4\3\2\2\2R\u0414\3\2\2\2") + buf.write("T\u0420\3\2\2\2V\u0433\3\2\2\2X\u0435\3\2\2\2Z\u043d\3") + buf.write("\2\2\2\\`\5\32\16\2]`\5\4\3\2^`\5\16\b\2_\\\3\2\2\2_]") + buf.write("\3\2\2\2_^\3\2\2\2`c\3\2\2\2a_\3\2\2\2ab\3\2\2\2bd\3\2") + buf.write("\2\2ca\3\2\2\2de\7\2\2\3e\3\3\2\2\2fg\7?\2\2gh\5\22\n") + buf.write("\2hi\5\6\4\2ij\7\177\2\2j\5\3\2\2\2kn\5\b\5\2ln\5P)\2") + buf.write("mk\3\2\2\2ml\3\2\2\2n\7\3\2\2\2oq\5\n\6\2pr\5\n\6\2qp") + buf.write("\3\2\2\2qr\3\2\2\2r\t\3\2\2\2su\5\f\7\2ts\3\2\2\2tu\3") + buf.write("\2\2\2uv\3\2\2\2vw\7a\2\2w\13\3\2\2\2xy\t\2\2\2y\r\3\2") + buf.write("\2\2z|\7/\2\2{}\7`\2\2|{\3\2\2\2}~\3\2\2\2~|\3\2\2\2~") + buf.write("\177\3\2\2\2\177\u0082\3\2\2\2\u0080\u0081\7\23\2\2\u0081") + buf.write("\u0083\5\22\n\2\u0082\u0080\3\2\2\2\u0082\u0083\3\2\2") + buf.write("\2\u0083\u0084\3\2\2\2\u0084\u00a9\7\177\2\2\u0085\u0088") + buf.write("\7/\2\2\u0086\u0089\7t\2\2\u0087\u0089\5\22\n\2\u0088") + buf.write("\u0086\3\2\2\2\u0088\u0087\3\2\2\2\u0089\u008c\3\2\2\2") + buf.write("\u008a\u008b\7\23\2\2\u008b\u008d\5\22\n\2\u008c\u008a") + buf.write("\3\2\2\2\u008c\u008d\3\2\2\2\u008d\u008e\3\2\2\2\u008e") + buf.write("\u0090\7,\2\2\u008f\u0091\7`\2\2\u0090\u008f\3\2\2\2\u0091") + buf.write("\u0092\3\2\2\2\u0092\u0090\3\2\2\2\u0092\u0093\3\2\2\2") + buf.write("\u0093\u0094\3\2\2\2\u0094\u00a9\7\177\2\2\u0095\u0096") + buf.write("\7/\2\2\u0096\u0097\7y\2\2\u0097\u009c\5\20\t\2\u0098") + buf.write("\u0099\7\u0080\2\2\u0099\u009b\5\20\t\2\u009a\u0098\3") + buf.write("\2\2\2\u009b\u009e\3\2\2\2\u009c\u009a\3\2\2\2\u009c\u009d") + buf.write("\3\2\2\2\u009d\u009f\3\2\2\2\u009e\u009c\3\2\2\2\u009f") + buf.write("\u00a0\7z\2\2\u00a0\u00a2\7,\2\2\u00a1\u00a3\7`\2\2\u00a2") + buf.write("\u00a1\3\2\2\2\u00a3\u00a4\3\2\2\2\u00a4\u00a2\3\2\2\2") + buf.write("\u00a4\u00a5\3\2\2\2\u00a5\u00a6\3\2\2\2\u00a6\u00a7\7") + buf.write("\177\2\2\u00a7\u00a9\3\2\2\2\u00a8z\3\2\2\2\u00a8\u0085") + buf.write("\3\2\2\2\u00a8\u0095\3\2\2\2\u00a9\17\3\2\2\2\u00aa\u00ad") + buf.write("\5\22\n\2\u00ab\u00ac\7\23\2\2\u00ac\u00ae\5\22\n\2\u00ad") + buf.write("\u00ab\3\2\2\2\u00ad\u00ae\3\2\2\2\u00ae\21\3\2\2\2\u00af") + buf.write("\u00b0\7\u0083\2\2\u00b0\23\3\2\2\2\u00b1\u00b2\b\13\1") + buf.write("\2\u00b2\u00b3\7\16\2\2\u00b3\u00b4\7}\2\2\u00b4\u00b5") + buf.write("\5\24\13\2\u00b5\u00b6\7e\2\2\u00b6\u00b7\5\24\13\2\u00b7") + buf.write("\u00b8\7~\2\2\u00b8\u00ce\3\2\2\2\u00b9\u00ce\7\4\2\2") + buf.write("\u00ba\u00ce\7\13\2\2\u00bb\u00ce\7\b\2\2\u00bc\u00ce") + buf.write("\7\t\2\2\u00bd\u00ce\7\f\2\2\u00be\u00c0\7\3\2\2\u00bf") + buf.write("\u00c1\7<\2\2\u00c0\u00bf\3\2\2\2\u00c0\u00c1\3\2\2\2") + buf.write("\u00c1\u00ce\3\2\2\2\u00c2\u00ce\7\7\2\2\u00c3\u00ce\7") + buf.write("\6\2\2\u00c4\u00ce\5\22\n\2\u00c5\u00c6\7\n\2\2\u00c6") + buf.write("\u00c7\7l\2\2\u00c7\u00c8\5\22\n\2\u00c8\u00c9\7m\2\2") + buf.write("\u00c9\u00ce\3\2\2\2\u00ca\u00ce\7\17\2\2\u00cb\u00ce") + buf.write("\7\20\2\2\u00cc\u00ce\7\21\2\2\u00cd\u00b1\3\2\2\2\u00cd") + buf.write("\u00b9\3\2\2\2\u00cd\u00ba\3\2\2\2\u00cd\u00bb\3\2\2\2") + buf.write("\u00cd\u00bc\3\2\2\2\u00cd\u00bd\3\2\2\2\u00cd\u00be\3") + buf.write("\2\2\2\u00cd\u00c2\3\2\2\2\u00cd\u00c3\3\2\2\2\u00cd\u00c4") + buf.write("\3\2\2\2\u00cd\u00c5\3\2\2\2\u00cd\u00ca\3\2\2\2\u00cd") + buf.write("\u00cb\3\2\2\2\u00cd\u00cc\3\2\2\2\u00ce\u00d4\3\2\2\2") + buf.write("\u00cf\u00d0\f\21\2\2\u00d0\u00d1\7{\2\2\u00d1\u00d3\7") + buf.write("|\2\2\u00d2\u00cf\3\2\2\2\u00d3\u00d6\3\2\2\2\u00d4\u00d2") + buf.write("\3\2\2\2\u00d4\u00d5\3\2\2\2\u00d5\25\3\2\2\2\u00d6\u00d4") + buf.write("\3\2\2\2\u00d7\u00dc\5\30\r\2\u00d8\u00d9\7\u0080\2\2") + buf.write("\u00d9\u00db\5\30\r\2\u00da\u00d8\3\2\2\2\u00db\u00de") + buf.write("\3\2\2\2\u00dc\u00da\3\2\2\2\u00dc\u00dd\3\2\2\2\u00dd") + buf.write("\27\3\2\2\2\u00de\u00dc\3\2\2\2\u00df\u00e0\5\22\n\2\u00e0") + buf.write("\u00e1\7\u0082\2\2\u00e1\u00e2\5\24\13\2\u00e2\31\3\2") + buf.write("\2\2\u00e3\u00e4\7\r\2\2\u00e4\u00e5\5\22\n\2\u00e5\u00e6") + buf.write("\5\34\17\2\u00e6\33\3\2\2\2\u00e7\u00e9\7y\2\2\u00e8\u00ea") + buf.write("\5\36\20\2\u00e9\u00e8\3\2\2\2\u00ea\u00eb\3\2\2\2\u00eb") + buf.write("\u00e9\3\2\2\2\u00eb\u00ec\3\2\2\2\u00ec\u00ed\3\2\2\2") + buf.write("\u00ed\u00ee\7z\2\2\u00ee\35\3\2\2\2\u00ef\u00f9\5B\"") + buf.write("\2\u00f0\u00f9\5 \21\2\u00f1\u00f9\5\"\22\2\u00f2\u00f9") + buf.write("\5$\23\2\u00f3\u00f9\5,\27\2\u00f4\u00f9\5\60\31\2\u00f5") + buf.write("\u00f9\5\62\32\2\u00f6\u00f9\58\35\2\u00f7\u00f9\5D#\2") + buf.write("\u00f8\u00ef\3\2\2\2\u00f8\u00f0\3\2\2\2\u00f8\u00f1\3") + buf.write("\2\2\2\u00f8\u00f2\3\2\2\2\u00f8\u00f3\3\2\2\2\u00f8\u00f4") + buf.write("\3\2\2\2\u00f8\u00f5\3\2\2\2\u00f8\u00f6\3\2\2\2\u00f8") + buf.write("\u00f7\3\2\2\2\u00f9\37\3\2\2\2\u00fa\u00fb\7\5\2\2\u00fb") + buf.write("\u00fc\5\22\n\2\u00fc\u00fd\7y\2\2\u00fd\u0102\5\22\n") + buf.write("\2\u00fe\u00ff\7\u0080\2\2\u00ff\u0101\5\22\n\2\u0100") + buf.write("\u00fe\3\2\2\2\u0101\u0104\3\2\2\2\u0102\u0100\3\2\2\2") + buf.write("\u0102\u0103\3\2\2\2\u0103\u0105\3\2\2\2\u0104\u0102\3") + buf.write("\2\2\2\u0105\u0106\7z\2\2\u0106!\3\2\2\2\u0107\u0108\7") + buf.write("S\2\2\u0108\u0109\5\22\n\2\u0109\u010a\7y\2\2\u010a\u010b") + buf.write("\5\24\13\2\u010b\u010c\5\22\n\2\u010c\u0113\7\177\2\2") + buf.write("\u010d\u010e\5\24\13\2\u010e\u010f\5\22\n\2\u010f\u0110") + buf.write("\7\177\2\2\u0110\u0112\3\2\2\2\u0111\u010d\3\2\2\2\u0112") + buf.write("\u0115\3\2\2\2\u0113\u0111\3\2\2\2\u0113\u0114\3\2\2\2") + buf.write("\u0114\u0116\3\2\2\2\u0115\u0113\3\2\2\2\u0116\u0117\7") + buf.write("z\2\2\u0117#\3\2\2\2\u0118\u0119\7R\2\2\u0119\u011a\5") + buf.write("\22\n\2\u011a\u011c\7}\2\2\u011b\u011d\5&\24\2\u011c\u011b") + buf.write("\3\2\2\2\u011c\u011d\3\2\2\2\u011d\u011e\3\2\2\2\u011e") + buf.write("\u011f\7~\2\2\u011f\u0120\5*\26\2\u0120%\3\2\2\2\u0121") + buf.write("\u0126\5(\25\2\u0122\u0123\7\u0080\2\2\u0123\u0125\5(") + buf.write("\25\2\u0124\u0122\3\2\2\2\u0125\u0128\3\2\2\2\u0126\u0124") + buf.write("\3\2\2\2\u0126\u0127\3\2\2\2\u0127\'\3\2\2\2\u0128\u0126") + buf.write("\3\2\2\2\u0129\u012a\5\24\13\2\u012a\u012b\5\22\n\2\u012b") + buf.write(")\3\2\2\2\u012c\u012d\7y\2\2\u012d\u012e\5P)\2\u012e\u012f") + buf.write("\7z\2\2\u012f+\3\2\2\2\u0130\u0131\7\64\2\2\u0131\u0132") + buf.write("\5\22\n\2\u0132\u0133\5.\30\2\u0133-\3\2\2\2\u0134\u0135") + buf.write("\7y\2\2\u0135\u0136\5P)\2\u0136\u0137\7z\2\2\u0137/\3") + buf.write("\2\2\2\u0138\u0139\7\6\2\2\u0139\u013a\5\22\n\2\u013a") + buf.write("\u0143\7}\2\2\u013b\u0140\5\24\13\2\u013c\u013d\7\u0080") + buf.write("\2\2\u013d\u013f\5\24\13\2\u013e\u013c\3\2\2\2\u013f\u0142") + buf.write("\3\2\2\2\u0140\u013e\3\2\2\2\u0140\u0141\3\2\2\2\u0141") + buf.write("\u0144\3\2\2\2\u0142\u0140\3\2\2\2\u0143\u013b\3\2\2\2") + buf.write("\u0143\u0144\3\2\2\2\u0144\u0145\3\2\2\2\u0145\u0146\7") + buf.write("~\2\2\u0146\u0147\7\177\2\2\u0147\61\3\2\2\2\u0148\u0149") + buf.write("\7\37\2\2\u0149\u014b\7}\2\2\u014a\u014c\5:\36\2\u014b") + buf.write("\u014a\3\2\2\2\u014b\u014c\3\2\2\2\u014c\u014d\3\2\2\2") + buf.write("\u014d\u014f\7~\2\2\u014e\u0150\t\3\2\2\u014f\u014e\3") + buf.write("\2\2\2\u014f\u0150\3\2\2\2\u0150\u0151\3\2\2\2\u0151\u0158") + buf.write("\5\64\33\2\u0152\u0153\79\2\2\u0153\u0155\7{\2\2\u0154") + buf.write("\u0156\5X-\2\u0155\u0154\3\2\2\2\u0155\u0156\3\2\2\2\u0156") + buf.write("\u0157\3\2\2\2\u0157\u0159\7|\2\2\u0158\u0152\3\2\2\2") + buf.write("\u0158\u0159\3\2\2\2\u0159\u0160\3\2\2\2\u015a\u015b\7") + buf.write(":\2\2\u015b\u015d\7{\2\2\u015c\u015e\5X-\2\u015d\u015c") + buf.write("\3\2\2\2\u015d\u015e\3\2\2\2\u015e\u015f\3\2\2\2\u015f") + buf.write("\u0161\7|\2\2\u0160\u015a\3\2\2\2\u0160\u0161\3\2\2\2") + buf.write("\u0161\u0162\3\2\2\2\u0162\u0163\5> \2\u0163\63\3\2\2") + buf.write("\2\u0164\u0165\7@\2\2\u0165\u0167\5P)\2\u0166\u0164\3") + buf.write("\2\2\2\u0166\u0167\3\2\2\2\u0167\u016a\3\2\2\2\u0168\u0169") + buf.write("\7>\2\2\u0169\u016b\5P)\2\u016a\u0168\3\2\2\2\u016a\u016b") + buf.write("\3\2\2\2\u016b\u016d\3\2\2\2\u016c\u016e\7!\2\2\u016d") + buf.write("\u016c\3\2\2\2\u016d\u016e\3\2\2\2\u016e\u0170\3\2\2\2") + buf.write("\u016f\u0171\7\"\2\2\u0170\u016f\3\2\2\2\u0170\u0171\3") + buf.write("\2\2\2\u0171\u0174\3\2\2\2\u0172\u0173\7V\2\2\u0173\u0175") + buf.write("\5P)\2\u0174\u0172\3\2\2\2\u0174\u0175\3\2\2\2\u0175\u0178") + buf.write("\3\2\2\2\u0176\u0177\7J\2\2\u0177\u0179\5P)\2\u0178\u0176") + buf.write("\3\2\2\2\u0178\u0179\3\2\2\2\u0179\u01bd\3\2\2\2\u017a") + buf.write("\u017c\7!\2\2\u017b\u017a\3\2\2\2\u017b\u017c\3\2\2\2") + buf.write("\u017c\u017e\3\2\2\2\u017d\u017f\7\"\2\2\u017e\u017d\3") + buf.write("\2\2\2\u017e\u017f\3\2\2\2\u017f\u0182\3\2\2\2\u0180\u0181") + buf.write("\7@\2\2\u0181\u0183\5P)\2\u0182\u0180\3\2\2\2\u0182\u0183") + buf.write("\3\2\2\2\u0183\u0186\3\2\2\2\u0184\u0185\7>\2\2\u0185") + buf.write("\u0187\5P)\2\u0186\u0184\3\2\2\2\u0186\u0187\3\2\2\2\u0187") + buf.write("\u018a\3\2\2\2\u0188\u0189\7V\2\2\u0189\u018b\5P)\2\u018a") + buf.write("\u0188\3\2\2\2\u018a\u018b\3\2\2\2\u018b\u018e\3\2\2\2") + buf.write("\u018c\u018d\7J\2\2\u018d\u018f\5P)\2\u018e\u018c\3\2") + buf.write("\2\2\u018e\u018f\3\2\2\2\u018f\u01bd\3\2\2\2\u0190\u0191") + buf.write("\7@\2\2\u0191\u0193\5P)\2\u0192\u0190\3\2\2\2\u0192\u0193") + buf.write("\3\2\2\2\u0193\u0196\3\2\2\2\u0194\u0195\7V\2\2\u0195") + buf.write("\u0197\5P)\2\u0196\u0194\3\2\2\2\u0196\u0197\3\2\2\2\u0197") + buf.write("\u0199\3\2\2\2\u0198\u019a\7!\2\2\u0199\u0198\3\2\2\2") + buf.write("\u0199\u019a\3\2\2\2\u019a\u019c\3\2\2\2\u019b\u019d\7") + buf.write("\"\2\2\u019c\u019b\3\2\2\2\u019c\u019d\3\2\2\2\u019d\u01a0") + buf.write("\3\2\2\2\u019e\u019f\7>\2\2\u019f\u01a1\5P)\2\u01a0\u019e") + buf.write("\3\2\2\2\u01a0\u01a1\3\2\2\2\u01a1\u01a4\3\2\2\2\u01a2") + buf.write("\u01a3\7J\2\2\u01a3\u01a5\5P)\2\u01a4\u01a2\3\2\2\2\u01a4") + buf.write("\u01a5\3\2\2\2\u01a5\u01bd\3\2\2\2\u01a6\u01a7\7@\2\2") + buf.write("\u01a7\u01a9\5P)\2\u01a8\u01a6\3\2\2\2\u01a8\u01a9\3\2") + buf.write("\2\2\u01a9\u01ac\3\2\2\2\u01aa\u01ab\7V\2\2\u01ab\u01ad") + buf.write("\5P)\2\u01ac\u01aa\3\2\2\2\u01ac\u01ad\3\2\2\2\u01ad\u01b0") + buf.write("\3\2\2\2\u01ae\u01af\7>\2\2\u01af\u01b1\5P)\2\u01b0\u01ae") + buf.write("\3\2\2\2\u01b0\u01b1\3\2\2\2\u01b1\u01b3\3\2\2\2\u01b2") + buf.write("\u01b4\7!\2\2\u01b3\u01b2\3\2\2\2\u01b3\u01b4\3\2\2\2") + buf.write("\u01b4\u01b6\3\2\2\2\u01b5\u01b7\7\"\2\2\u01b6\u01b5\3") + buf.write("\2\2\2\u01b6\u01b7\3\2\2\2\u01b7\u01ba\3\2\2\2\u01b8\u01b9") + buf.write("\7J\2\2\u01b9\u01bb\5P)\2\u01ba\u01b8\3\2\2\2\u01ba\u01bb") + buf.write("\3\2\2\2\u01bb\u01bd\3\2\2\2\u01bc\u0166\3\2\2\2\u01bc") + buf.write("\u017b\3\2\2\2\u01bc\u0192\3\2\2\2\u01bc\u01a8\3\2\2\2") + buf.write("\u01bd\65\3\2\2\2\u01be\u01bf\t\4\2\2\u01bf\67\3\2\2\2") + buf.write("\u01c0\u01c5\7F\2\2\u01c1\u01c5\7)\2\2\u01c2\u01c3\7-") + buf.write("\2\2\u01c3\u01c5\5\22\n\2\u01c4\u01c0\3\2\2\2\u01c4\u01c1") + buf.write("\3\2\2\2\u01c4\u01c2\3\2\2\2\u01c5\u01c6\3\2\2\2\u01c6") + buf.write("\u01c8\7}\2\2\u01c7\u01c9\5:\36\2\u01c8\u01c7\3\2\2\2") + buf.write("\u01c8\u01c9\3\2\2\2\u01c9\u01ca\3\2\2\2\u01ca\u01cc\7") + buf.write("~\2\2\u01cb\u01cd\t\3\2\2\u01cc\u01cb\3\2\2\2\u01cc\u01cd") + buf.write("\3\2\2\2\u01cd\u01cf\3\2\2\2\u01ce\u01d0\5\66\34\2\u01cf") + buf.write("\u01ce\3\2\2\2\u01cf\u01d0\3\2\2\2\u01d0\u01d1\3\2\2\2") + buf.write("\u01d1\u01d8\5\64\33\2\u01d2\u01d3\79\2\2\u01d3\u01d5") + buf.write("\7{\2\2\u01d4\u01d6\5X-\2\u01d5\u01d4\3\2\2\2\u01d5\u01d6") + buf.write("\3\2\2\2\u01d6\u01d7\3\2\2\2\u01d7\u01d9\7|\2\2\u01d8") + buf.write("\u01d2\3\2\2\2\u01d8\u01d9\3\2\2\2\u01d9\u01e0\3\2\2\2") + buf.write("\u01da\u01db\7:\2\2\u01db\u01dd\7{\2\2\u01dc\u01de\5X") + buf.write("-\2\u01dd\u01dc\3\2\2\2\u01dd\u01de\3\2\2\2\u01de\u01df") + buf.write("\3\2\2\2\u01df\u01e1\7|\2\2\u01e0\u01da\3\2\2\2\u01e0") + buf.write("\u01e1\3\2\2\2\u01e1\u01ea\3\2\2\2\u01e2\u01e3\7H\2\2") + buf.write("\u01e3\u01e4\7}\2\2\u01e4\u01e6\5\24\13\2\u01e5\u01e7") + buf.write("\5\22\n\2\u01e6\u01e5\3\2\2\2\u01e6\u01e7\3\2\2\2\u01e7") + buf.write("\u01e8\3\2\2\2\u01e8\u01e9\7~\2\2\u01e9\u01eb\3\2\2\2") + buf.write("\u01ea\u01e2\3\2\2\2\u01ea\u01eb\3\2\2\2\u01eb\u01ec\3") + buf.write("\2\2\2\u01ec\u01ed\5> \2\u01ed9\3\2\2\2\u01ee\u01f3\5") + buf.write("<\37\2\u01ef\u01f0\7\u0080\2\2\u01f0\u01f2\5<\37\2\u01f1") + buf.write("\u01ef\3\2\2\2\u01f2\u01f5\3\2\2\2\u01f3\u01f1\3\2\2\2") + buf.write("\u01f3\u01f4\3\2\2\2\u01f4;\3\2\2\2\u01f5\u01f3\3\2\2") + buf.write("\2\u01f6\u01f7\5\24\13\2\u01f7\u01f8\5\22\n\2\u01f8=\3") + buf.write("\2\2\2\u01f9\u01fe\7y\2\2\u01fa\u01fd\5B\"\2\u01fb\u01fd") + buf.write("\5H%\2\u01fc\u01fa\3\2\2\2\u01fc\u01fb\3\2\2\2\u01fd\u0200") + buf.write("\3\2\2\2\u01fe\u01fc\3\2\2\2\u01fe\u01ff\3\2\2\2\u01ff") + buf.write("\u0201\3\2\2\2\u0200\u01fe\3\2\2\2\u0201\u0202\5@!\2\u0202") + buf.write("\u0203\7z\2\2\u0203?\3\2\2\2\u0204\u0206\7G\2\2\u0205") + buf.write("\u0207\5P)\2\u0206\u0205\3\2\2\2\u0206\u0207\3\2\2\2\u0207") + buf.write("\u0208\3\2\2\2\u0208\u0209\7\177\2\2\u0209A\3\2\2\2\u020a") + buf.write("\u020b\5\24\13\2\u020b\u020e\5\22\n\2\u020c\u020d\7o\2") + buf.write("\2\u020d\u020f\5P)\2\u020e\u020c\3\2\2\2\u020e\u020f\3") + buf.write("\2\2\2\u020f\u0210\3\2\2\2\u0210\u0211\7\177\2\2\u0211") + buf.write("C\3\2\2\2\u0212\u0213\7Z\2\2\u0213\u0214\5\22\n\2\u0214") + buf.write("\u0217\7*\2\2\u0215\u0218\5\24\13\2\u0216\u0218\7t\2\2") + buf.write("\u0217\u0215\3\2\2\2\u0217\u0216\3\2\2\2\u0218\u0219\3") + buf.write("\2\2\2\u0219\u021a\7\177\2\2\u021aE\3\2\2\2\u021b\u021c") + buf.write("\5\24\13\2\u021c\u021d\5\22\n\2\u021d\u021e\7o\2\2\u021e") + buf.write("\u021f\5P)\2\u021f\u0225\3\2\2\2\u0220\u0221\5\22\n\2") + buf.write("\u0221\u0222\7o\2\2\u0222\u0223\5P)\2\u0223\u0225\3\2") + buf.write("\2\2\u0224\u021b\3\2\2\2\u0224\u0220\3\2\2\2\u0225G\3") + buf.write("\2\2\2\u0226\u022a\7y\2\2\u0227\u0229\5H%\2\u0228\u0227") + buf.write("\3\2\2\2\u0229\u022c\3\2\2\2\u022a\u0228\3\2\2\2\u022a") + buf.write("\u022b\3\2\2\2\u022b\u022d\3\2\2\2\u022c\u022a\3\2\2\2") + buf.write("\u022d\u0304\7z\2\2\u022e\u022f\5L\'\2\u022f\u0230\7\u0081") + buf.write("\2\2\u0230\u0231\7E\2\2\u0231\u0232\7}\2\2\u0232\u0233") + buf.write("\5P)\2\u0233\u0234\7~\2\2\u0234\u0235\7\177\2\2\u0235") + buf.write("\u0304\3\2\2\2\u0236\u0237\5L\'\2\u0237\u0238\7\u0081") + buf.write("\2\2\u0238\u0239\7=\2\2\u0239\u023a\7}\2\2\u023a\u023b") + buf.write("\7~\2\2\u023b\u023c\7\177\2\2\u023c\u0304\3\2\2\2\u023d") + buf.write("\u023e\7$\2\2\u023e\u023f\7}\2\2\u023f\u0242\5L\'\2\u0240") + buf.write("\u0241\7\u0080\2\2\u0241\u0243\5P)\2\u0242\u0240\3\2\2") + buf.write("\2\u0242\u0243\3\2\2\2\u0243\u0244\3\2\2\2\u0244\u0245") + buf.write("\7~\2\2\u0245\u0246\7\177\2\2\u0246\u0304\3\2\2\2\u0247") + buf.write("\u0248\7\24\2\2\u0248\u024b\5P)\2\u0249\u024a\7\u0080") + buf.write("\2\2\u024a\u024c\7`\2\2\u024b\u0249\3\2\2\2\u024b\u024c") + buf.write("\3\2\2\2\u024c\u024d\3\2\2\2\u024d\u024e\7\177\2\2\u024e") + buf.write("\u0304\3\2\2\2\u024f\u0250\5L\'\2\u0250\u0251\7o\2\2\u0251") + buf.write("\u0252\7;\2\2\u0252\u0253\5\22\n\2\u0253\u0255\7}\2\2") + buf.write("\u0254\u0256\5X-\2\u0255\u0254\3\2\2\2\u0255\u0256\3\2") + buf.write("\2\2\u0256\u0257\3\2\2\2\u0257\u0258\7~\2\2\u0258\u0259") + buf.write("\7\177\2\2\u0259\u0304\3\2\2\2\u025a\u025b\5P)\2\u025b") + buf.write("\u025c\7\u0081\2\2\u025c\u025d\7\33\2\2\u025d\u025e\7") + buf.write("}\2\2\u025e\u025f\5X-\2\u025f\u0260\7~\2\2\u0260\u0261") + buf.write("\7\177\2\2\u0261\u0304\3\2\2\2\u0262\u0263\7\4\2\2\u0263") + buf.write("\u0264\5\22\n\2\u0264\u0265\7o\2\2\u0265\u0266\5P)\2\u0266") + buf.write("\u0267\7\u0081\2\2\u0267\u0268\7\33\2\2\u0268\u0269\7") + buf.write("}\2\2\u0269\u026a\5X-\2\u026a\u026b\7~\2\2\u026b\u026c") + buf.write("\7\177\2\2\u026c\u0304\3\2\2\2\u026d\u026e\5L\'\2\u026e") + buf.write("\u026f\7o\2\2\u026f\u0270\5P)\2\u0270\u0271\7\u0081\2") + buf.write("\2\u0271\u0272\7\33\2\2\u0272\u0273\7}\2\2\u0273\u0274") + buf.write("\5X-\2\u0274\u0275\7~\2\2\u0275\u0276\7\177\2\2\u0276") + buf.write("\u0304\3\2\2\2\u0277\u0278\5P)\2\u0278\u0279\7\u0081\2") + buf.write("\2\u0279\u027a\7\35\2\2\u027a\u027b\7}\2\2\u027b\u027c") + buf.write("\5X-\2\u027c\u027d\7~\2\2\u027d\u027e\7\177\2\2\u027e") + buf.write("\u0304\3\2\2\2\u027f\u0280\7\b\2\2\u0280\u0281\5\22\n") + buf.write("\2\u0281\u0282\7o\2\2\u0282\u0283\5P)\2\u0283\u0284\7") + buf.write("\u0081\2\2\u0284\u0285\7\35\2\2\u0285\u0286\7}\2\2\u0286") + buf.write("\u0287\5X-\2\u0287\u0288\7~\2\2\u0288\u0289\7\177\2\2") + buf.write("\u0289\u0304\3\2\2\2\u028a\u028b\5P)\2\u028b\u028c\7\u0081") + buf.write("\2\2\u028c\u028d\7\34\2\2\u028d\u028e\7}\2\2\u028e\u028f") + buf.write("\5X-\2\u028f\u0290\7~\2\2\u0290\u0291\7\177\2\2\u0291") + buf.write("\u0304\3\2\2\2\u0292\u0293\7\4\2\2\u0293\u0294\5\22\n") + buf.write("\2\u0294\u0295\7o\2\2\u0295\u0296\5P)\2\u0296\u0297\7") + buf.write("\u0081\2\2\u0297\u0298\7\34\2\2\u0298\u0299\7}\2\2\u0299") + buf.write("\u029a\5X-\2\u029a\u029b\7~\2\2\u029b\u029c\7\177\2\2") + buf.write("\u029c\u0304\3\2\2\2\u029d\u029e\5L\'\2\u029e\u029f\7") + buf.write("\u0081\2\2\u029f\u02a0\5\22\n\2\u02a0\u02a2\7}\2\2\u02a1") + buf.write("\u02a3\5X-\2\u02a2\u02a1\3\2\2\2\u02a2\u02a3\3\2\2\2\u02a3") + buf.write("\u02a4\3\2\2\2\u02a4\u02a5\7~\2\2\u02a5\u02a6\7\177\2") + buf.write("\2\u02a6\u0304\3\2\2\2\u02a7\u02a8\5L\'\2\u02a8\u02a9") + buf.write("\7o\2\2\u02a9\u02aa\5L\'\2\u02aa\u02ab\7\u0081\2\2\u02ab") + buf.write("\u02ac\5\22\n\2\u02ac\u02ae\7}\2\2\u02ad\u02af\5X-\2\u02ae") + buf.write("\u02ad\3\2\2\2\u02ae\u02af\3\2\2\2\u02af\u02b0\3\2\2\2") + buf.write("\u02b0\u02b1\7~\2\2\u02b1\u02b2\7\177\2\2\u02b2\u0304") + buf.write("\3\2\2\2\u02b3\u02b4\5L\'\2\u02b4\u02b5\7o\2\2\u02b5\u02b6") + buf.write("\5Z.\2\u02b6\u02b7\7\177\2\2\u02b7\u0304\3\2\2\2\u02b8") + buf.write("\u02b9\7.\2\2\u02b9\u02ba\7}\2\2\u02ba\u02bb\5P)\2\u02bb") + buf.write("\u02bc\7~\2\2\u02bc\u02be\5H%\2\u02bd\u02bf\5J&\2\u02be") + buf.write("\u02bd\3\2\2\2\u02be\u02bf\3\2\2\2\u02bf\u0304\3\2\2\2") + buf.write("\u02c0\u02c1\7*\2\2\u02c1\u02c2\7}\2\2\u02c2\u02c7\5F") + buf.write("$\2\u02c3\u02c4\7\u0080\2\2\u02c4\u02c6\5F$\2\u02c5\u02c3") + buf.write("\3\2\2\2\u02c6\u02c9\3\2\2\2\u02c7\u02c5\3\2\2\2\u02c7") + buf.write("\u02c8\3\2\2\2\u02c8\u02ca\3\2\2\2\u02c9\u02c7\3\2\2\2") + buf.write("\u02ca\u02cb\7\177\2\2\u02cb\u02cc\5P)\2\u02cc\u02cd\7") + buf.write("\177\2\2\u02cd\u02ce\5P)\2\u02ce\u02cf\7\177\2\2\u02cf") + buf.write("\u02d0\7~\2\2\u02d0\u02d1\5H%\2\u02d1\u0304\3\2\2\2\u02d2") + buf.write("\u02d3\5\22\n\2\u02d3\u02d5\7}\2\2\u02d4\u02d6\5X-\2\u02d5") + buf.write("\u02d4\3\2\2\2\u02d5\u02d6\3\2\2\2\u02d6\u02d7\3\2\2\2") + buf.write("\u02d7\u02d8\7~\2\2\u02d8\u02d9\7\177\2\2\u02d9\u0304") + buf.write("\3\2\2\2\u02da\u02db\7P\2\2\u02db\u02dc\7}\2\2\u02dc\u02dd") + buf.write("\5P)\2\u02dd\u02de\7\u0080\2\2\u02de\u02df\7\'\2\2\u02df") + buf.write("\u02e0\7\u0080\2\2\u02e0\u02e1\5P)\2\u02e1\u02e2\7~\2") + buf.write("\2\u02e2\u02e3\7\177\2\2\u02e3\u0304\3\2\2\2\u02e4\u02e5") + buf.write("\5P)\2\u02e5\u02e6\7\u0081\2\2\u02e6\u02e7\7U\2\2\u02e7") + buf.write("\u02e8\7}\2\2\u02e8\u02e9\5P)\2\u02e9\u02ea\7~\2\2\u02ea") + buf.write("\u02eb\7\177\2\2\u02eb\u0304\3\2\2\2\u02ec\u02ed\7&\2") + buf.write("\2\u02ed\u02ee\5\22\n\2\u02ee\u02ef\7}\2\2\u02ef\u02f4") + buf.write("\5P)\2\u02f0\u02f1\7\u0080\2\2\u02f1\u02f3\5P)\2\u02f2") + buf.write("\u02f0\3\2\2\2\u02f3\u02f6\3\2\2\2\u02f4\u02f2\3\2\2\2") + buf.write("\u02f4\u02f5\3\2\2\2\u02f5\u02f7\3\2\2\2\u02f6\u02f4\3") + buf.write("\2\2\2\u02f7\u02f8\7~\2\2\u02f8\u02f9\7\177\2\2\u02f9") + buf.write("\u0304\3\2\2\2\u02fa\u02fb\7I\2\2\u02fb\u02fc\7}\2\2\u02fc") + buf.write("\u02ff\7`\2\2\u02fd\u02fe\7\u0080\2\2\u02fe\u0300\5X-") + buf.write("\2\u02ff\u02fd\3\2\2\2\u02ff\u0300\3\2\2\2\u0300\u0301") + buf.write("\3\2\2\2\u0301\u0302\7~\2\2\u0302\u0304\7\177\2\2\u0303") + buf.write("\u0226\3\2\2\2\u0303\u022e\3\2\2\2\u0303\u0236\3\2\2\2") + buf.write("\u0303\u023d\3\2\2\2\u0303\u0247\3\2\2\2\u0303\u024f\3") + buf.write("\2\2\2\u0303\u025a\3\2\2\2\u0303\u0262\3\2\2\2\u0303\u026d") + buf.write("\3\2\2\2\u0303\u0277\3\2\2\2\u0303\u027f\3\2\2\2\u0303") + buf.write("\u028a\3\2\2\2\u0303\u0292\3\2\2\2\u0303\u029d\3\2\2\2") + buf.write("\u0303\u02a7\3\2\2\2\u0303\u02b3\3\2\2\2\u0303\u02b8\3") + buf.write("\2\2\2\u0303\u02c0\3\2\2\2\u0303\u02d2\3\2\2\2\u0303\u02da") + buf.write("\3\2\2\2\u0303\u02e4\3\2\2\2\u0303\u02ec\3\2\2\2\u0303") + buf.write("\u02fa\3\2\2\2\u0304I\3\2\2\2\u0305\u0306\7%\2\2\u0306") + buf.write("\u0307\5H%\2\u0307K\3\2\2\2\u0308\u0309\b\'\1\2\u0309") + buf.write("\u030a\5\22\n\2\u030a\u0315\3\2\2\2\u030b\u030c\f\4\2") + buf.write("\2\u030c\u030d\7\u0081\2\2\u030d\u0314\5\22\n\2\u030e") + buf.write("\u030f\f\3\2\2\u030f\u0310\7{\2\2\u0310\u0311\5P)\2\u0311") + buf.write("\u0312\7|\2\2\u0312\u0314\3\2\2\2\u0313\u030b\3\2\2\2") + buf.write("\u0313\u030e\3\2\2\2\u0314\u0317\3\2\2\2\u0315\u0313\3") + buf.write("\2\2\2\u0315\u0316\3\2\2\2\u0316M\3\2\2\2\u0317\u0315") + buf.write("\3\2\2\2\u0318\u0319\7}\2\2\u0319\u031a\5\22\n\2\u031a") + buf.write("\u031b\7\u0080\2\2\u031b\u0320\5P)\2\u031c\u031d\7\u0080") + buf.write("\2\2\u031d\u031f\5P)\2\u031e\u031c\3\2\2\2\u031f\u0322") + buf.write("\3\2\2\2\u0320\u031e\3\2\2\2\u0320\u0321\3\2\2\2\u0321") + buf.write("\u0323\3\2\2\2\u0322\u0320\3\2\2\2\u0323\u0324\7~\2\2") + buf.write("\u0324\u032e\3\2\2\2\u0325\u0326\7}\2\2\u0326\u0327\5") + buf.write("P)\2\u0327\u0328\7\u0080\2\2\u0328\u0329\7\'\2\2\u0329") + buf.write("\u032a\7\u0080\2\2\u032a\u032b\5P)\2\u032b\u032c\7~\2") + buf.write("\2\u032c\u032e\3\2\2\2\u032d\u0318\3\2\2\2\u032d\u0325") + buf.write("\3\2\2\2\u032eO\3\2\2\2\u032f\u0330\b)\1\2\u0330\u03b5") + buf.write("\5R*\2\u0331\u0332\7}\2\2\u0332\u0333\5P)\2\u0333\u0334") + buf.write("\7~\2\2\u0334\u03b5\3\2\2\2\u0335\u0336\5\22\n\2\u0336") + buf.write("\u0337\7\u0081\2\2\u0337\u0338\5\22\n\2\u0338\u033a\7") + buf.write("}\2\2\u0339\u033b\5X-\2\u033a\u0339\3\2\2\2\u033a\u033b") + buf.write("\3\2\2\2\u033b\u033c\3\2\2\2\u033c\u033d\7~\2\2\u033d") + buf.write("\u03b5\3\2\2\2\u033e\u033f\5\22\n\2\u033f\u0341\7}\2\2") + buf.write("\u0340\u0342\5X-\2\u0341\u0340\3\2\2\2\u0341\u0342\3\2") + buf.write("\2\2\u0342\u0343\3\2\2\2\u0343\u0344\7~\2\2\u0344\u03b5") + buf.write("\3\2\2\2\u0345\u0346\7+\2\2\u0346\u0347\7}\2\2\u0347\u0348") + buf.write("\5&\24\2\u0348\u0349\7~\2\2\u0349\u034a\7}\2\2\u034a\u034b") + buf.write("\5P)\2\u034b\u034c\7~\2\2\u034c\u03b5\3\2\2\2\u034d\u034e") + buf.write("\7(\2\2\u034e\u034f\7}\2\2\u034f\u0350\5&\24\2\u0350\u0351") + buf.write("\7~\2\2\u0351\u0352\7}\2\2\u0352\u0353\5P)\2\u0353\u0354") + buf.write("\7~\2\2\u0354\u03b5\3\2\2\2\u0355\u0356\t\5\2\2\u0356") + buf.write("\u03b5\5P)\27\u0357\u0358\7M\2\2\u0358\u0359\7}\2\2\u0359") + buf.write("\u035a\5P)\2\u035a\u035b\7\u0080\2\2\u035b\u035c\5P)\2") + buf.write("\u035c\u035d\7~\2\2\u035d\u03b5\3\2\2\2\u035e\u035f\7") + buf.write("L\2\2\u035f\u0360\7}\2\2\u0360\u0361\5P)\2\u0361\u0362") + buf.write("\7\u0080\2\2\u0362\u0363\5P)\2\u0363\u0364\7~\2\2\u0364") + buf.write("\u03b5\3\2\2\2\u0365\u0366\7N\2\2\u0366\u0367\7}\2\2\u0367") + buf.write("\u0368\5P)\2\u0368\u0369\7\u0080\2\2\u0369\u036a\5P)\2") + buf.write("\u036a\u036b\7~\2\2\u036b\u03b5\3\2\2\2\u036c\u036d\7") + buf.write("K\2\2\u036d\u036e\7}\2\2\u036e\u036f\5P)\2\u036f\u0370") + buf.write("\7\u0080\2\2\u0370\u0371\5P)\2\u0371\u0372\7~\2\2\u0372") + buf.write("\u03b5\3\2\2\2\u0373\u0374\7O\2\2\u0374\u0375\7}\2\2\u0375") + buf.write("\u0376\5P)\2\u0376\u0377\7\u0080\2\2\u0377\u0378\5P)\2") + buf.write("\u0378\u0379\7~\2\2\u0379\u03b5\3\2\2\2\u037a\u037b\5") + buf.write("\22\n\2\u037b\u037c\7}\2\2\u037c\u037d\5P)\2\u037d\u037e") + buf.write("\7~\2\2\u037e\u03b5\3\2\2\2\u037f\u0380\7;\2\2\u0380\u0381") + buf.write("\5\22\n\2\u0381\u0383\7}\2\2\u0382\u0384\5X-\2\u0383\u0382") + buf.write("\3\2\2\2\u0383\u0384\3\2\2\2\u0384\u0385\3\2\2\2\u0385") + buf.write("\u0386\7~\2\2\u0386\u03b5\3\2\2\2\u0387\u0388\5\22\n\2") + buf.write("\u0388\u0389\7\u0081\2\2\u0389\u038a\7\22\2\2\u038a\u038b") + buf.write("\7}\2\2\u038b\u038c\7;\2\2\u038c\u038d\5\22\n\2\u038d") + buf.write("\u038f\7}\2\2\u038e\u0390\5X-\2\u038f\u038e\3\2\2\2\u038f") + buf.write("\u0390\3\2\2\2\u0390\u0391\3\2\2\2\u0391\u0392\7~\2\2") + buf.write("\u0392\u0393\7~\2\2\u0393\u03b5\3\2\2\2\u0394\u0395\7") + buf.write("\63\2\2\u0395\u0396\7}\2\2\u0396\u0397\5P)\2\u0397\u0398") + buf.write("\7\u0080\2\2\u0398\u0399\5P)\2\u0399\u039a\7\u0080\2\2") + buf.write("\u039a\u039b\5P)\2\u039b\u039c\7~\2\2\u039c\u03b5\3\2") + buf.write("\2\2\u039d\u039e\7#\2\2\u039e\u039f\7}\2\2\u039f\u03a0") + buf.write("\5\24\13\2\u03a0\u03a1\7~\2\2\u03a1\u03b5\3\2\2\2\u03a2") + buf.write("\u03a8\5N(\2\u03a3\u03a4\7\u0082\2\2\u03a4\u03a5\7\u0082") + buf.write("\2\2\u03a5\u03a7\5N(\2\u03a6\u03a3\3\2\2\2\u03a7\u03aa") + buf.write("\3\2\2\2\u03a8\u03a6\3\2\2\2\u03a8\u03a9\3\2\2\2\u03a9") + buf.write("\u03ab\3\2\2\2\u03aa\u03a8\3\2\2\2\u03ab\u03ac\7\u0082") + buf.write("\2\2\u03ac\u03ad\7\u0082\2\2\u03ad\u03ae\5R*\2\u03ae\u03b5") + buf.write("\3\2\2\2\u03af\u03b0\7<\2\2\u03b0\u03b1\7}\2\2\u03b1\u03b2") + buf.write("\5P)\2\u03b2\u03b3\7~\2\2\u03b3\u03b5\3\2\2\2\u03b4\u032f") + buf.write("\3\2\2\2\u03b4\u0331\3\2\2\2\u03b4\u0335\3\2\2\2\u03b4") + buf.write("\u033e\3\2\2\2\u03b4\u0345\3\2\2\2\u03b4\u034d\3\2\2\2") + buf.write("\u03b4\u0355\3\2\2\2\u03b4\u0357\3\2\2\2\u03b4\u035e\3") + buf.write("\2\2\2\u03b4\u0365\3\2\2\2\u03b4\u036c\3\2\2\2\u03b4\u0373") + buf.write("\3\2\2\2\u03b4\u037a\3\2\2\2\u03b4\u037f\3\2\2\2\u03b4") + buf.write("\u0387\3\2\2\2\u03b4\u0394\3\2\2\2\u03b4\u039d\3\2\2\2") + buf.write("\u03b4\u03a2\3\2\2\2\u03b4\u03af\3\2\2\2\u03b5\u03e7\3") + buf.write("\2\2\2\u03b6\u03b7\f\26\2\2\u03b7\u03b8\t\6\2\2\u03b8") + buf.write("\u03e6\5P)\27\u03b9\u03ba\f\22\2\2\u03ba\u03bb\t\7\2\2") + buf.write("\u03bb\u03e6\5P)\23\u03bc\u03bd\f\17\2\2\u03bd\u03be\t") + buf.write("\b\2\2\u03be\u03e6\5P)\20\u03bf\u03c0\f\16\2\2\u03c0\u03c1") + buf.write("\t\t\2\2\u03c1\u03e6\5P)\17\u03c2\u03c3\f\r\2\2\u03c3") + buf.write("\u03c4\7c\2\2\u03c4\u03e6\5P)\16\u03c5\u03c6\f\f\2\2\u03c6") + buf.write("\u03c7\7d\2\2\u03c7\u03e6\5P)\r\u03c8\u03c9\f\13\2\2\u03c9") + buf.write("\u03ca\t\n\2\2\u03ca\u03e6\5P)\f\u03cb\u03cc\f\35\2\2") + buf.write("\u03cc\u03cd\7\u0081\2\2\u03cd\u03e6\5\22\n\2\u03ce\u03cf") + buf.write("\f\34\2\2\u03cf\u03d0\7{\2\2\u03d0\u03d1\5P)\2\u03d1\u03d2") + buf.write("\7|\2\2\u03d2\u03e6\3\2\2\2\u03d3\u03d4\f\33\2\2\u03d4") + buf.write("\u03d5\7\u0081\2\2\u03d5\u03d6\7\67\2\2\u03d6\u03d7\7") + buf.write("}\2\2\u03d7\u03e6\7~\2\2\u03d8\u03d9\f\n\2\2\u03d9\u03da") + buf.write("\7e\2\2\u03da\u03e2\5P)\2\u03db\u03dc\7\u0080\2\2\u03dc") + buf.write("\u03dd\5P)\2\u03dd\u03de\7e\2\2\u03de\u03df\5P)\2\u03df") + buf.write("\u03e1\3\2\2\2\u03e0\u03db\3\2\2\2\u03e1\u03e4\3\2\2\2") + buf.write("\u03e2\u03e0\3\2\2\2\u03e2\u03e3\3\2\2\2\u03e3\u03e6\3") + buf.write("\2\2\2\u03e4\u03e2\3\2\2\2\u03e5\u03b6\3\2\2\2\u03e5\u03b9") + buf.write("\3\2\2\2\u03e5\u03bc\3\2\2\2\u03e5\u03bf\3\2\2\2\u03e5") + buf.write("\u03c2\3\2\2\2\u03e5\u03c5\3\2\2\2\u03e5\u03c8\3\2\2\2") + buf.write("\u03e5\u03cb\3\2\2\2\u03e5\u03ce\3\2\2\2\u03e5\u03d3\3") + buf.write("\2\2\2\u03e5\u03d8\3\2\2\2\u03e6\u03e9\3\2\2\2\u03e7\u03e5") + buf.write("\3\2\2\2\u03e7\u03e8\3\2\2\2\u03e8Q\3\2\2\2\u03e9\u03e7") + buf.write("\3\2\2\2\u03ea\u0415\5\22\n\2\u03eb\u0415\7[\2\2\u03ec") + buf.write("\u0415\7\25\2\2\u03ed\u0415\7Q\2\2\u03ee\u0415\7W\2\2") + buf.write("\u03ef\u0415\7X\2\2\u03f0\u0415\7\26\2\2\u03f1\u0415\7") + buf.write("\27\2\2\u03f2\u0415\7\30\2\2\u03f3\u0415\7\31\2\2\u03f4") + buf.write("\u0415\7\32\2\2\u03f5\u0415\78\2\2\u03f6\u0415\7\61\2") + buf.write("\2\u03f7\u0415\7\62\2\2\u03f8\u0415\7Y\2\2\u03f9\u03fa") + buf.write("\7;\2\2\u03fa\u03fb\7}\2\2\u03fb\u03fc\5\22\n\2\u03fc") + buf.write("\u03fd\7~\2\2\u03fd\u0415\3\2\2\2\u03fe\u03ff\7;\2\2\u03ff") + buf.write("\u0400\7}\2\2\u0400\u0401\7\25\2\2\u0401\u0415\7~\2\2") + buf.write("\u0402\u0403\7;\2\2\u0403\u0404\7}\2\2\u0404\u0405\78") + buf.write("\2\2\u0405\u0415\7~\2\2\u0406\u0415\7]\2\2\u0407\u0415") + buf.write("\7^\2\2\u0408\u0415\7_\2\2\u0409\u0415\7`\2\2\u040a\u0415") + buf.write("\7T\2\2\u040b\u040c\7\3\2\2\u040c\u040d\7}\2\2\u040d\u040e") + buf.write("\7T\2\2\u040e\u0415\7~\2\2\u040f\u0410\7\3\2\2\u0410\u0411") + buf.write("\7}\2\2\u0411\u0412\5\22\n\2\u0412\u0413\7~\2\2\u0413") + buf.write("\u0415\3\2\2\2\u0414\u03ea\3\2\2\2\u0414\u03eb\3\2\2\2") + buf.write("\u0414\u03ec\3\2\2\2\u0414\u03ed\3\2\2\2\u0414\u03ee\3") + buf.write("\2\2\2\u0414\u03ef\3\2\2\2\u0414\u03f0\3\2\2\2\u0414\u03f1") + buf.write("\3\2\2\2\u0414\u03f2\3\2\2\2\u0414\u03f3\3\2\2\2\u0414") + buf.write("\u03f4\3\2\2\2\u0414\u03f5\3\2\2\2\u0414\u03f6\3\2\2\2") + buf.write("\u0414\u03f7\3\2\2\2\u0414\u03f8\3\2\2\2\u0414\u03f9\3") + buf.write("\2\2\2\u0414\u03fe\3\2\2\2\u0414\u0402\3\2\2\2\u0414\u0406") + buf.write("\3\2\2\2\u0414\u0407\3\2\2\2\u0414\u0408\3\2\2\2\u0414") + buf.write("\u0409\3\2\2\2\u0414\u040a\3\2\2\2\u0414\u040b\3\2\2\2") + buf.write("\u0414\u040f\3\2\2\2\u0415S\3\2\2\2\u0416\u0417\5Z.\2") + buf.write("\u0417\u0418\7\u0080\2\2\u0418\u0421\3\2\2\2\u0419\u041c") + buf.write("\5Z.\2\u041a\u041b\7\u0080\2\2\u041b\u041d\5Z.\2\u041c") + buf.write("\u041a\3\2\2\2\u041d\u041e\3\2\2\2\u041e\u041c\3\2\2\2") + buf.write("\u041e\u041f\3\2\2\2\u041f\u0421\3\2\2\2\u0420\u0416\3") + buf.write("\2\2\2\u0420\u0419\3\2\2\2\u0421U\3\2\2\2\u0422\u0423") + buf.write("\5\22\n\2\u0423\u0424\7o\2\2\u0424\u0425\5Z.\2\u0425\u0426") + buf.write("\7\u0080\2\2\u0426\u0434\3\2\2\2\u0427\u0428\5\22\n\2") + buf.write("\u0428\u0429\7o\2\2\u0429\u042f\5Z.\2\u042a\u042b\7\u0080") + buf.write("\2\2\u042b\u042c\5\22\n\2\u042c\u042d\7o\2\2\u042d\u042e") + buf.write("\5Z.\2\u042e\u0430\3\2\2\2\u042f\u042a\3\2\2\2\u0430\u0431") + buf.write("\3\2\2\2\u0431\u042f\3\2\2\2\u0431\u0432\3\2\2\2\u0432") + buf.write("\u0434\3\2\2\2\u0433\u0422\3\2\2\2\u0433\u0427\3\2\2\2") + buf.write("\u0434W\3\2\2\2\u0435\u043a\5Z.\2\u0436\u0437\7\u0080") + buf.write("\2\2\u0437\u0439\5Z.\2\u0438\u0436\3\2\2\2\u0439\u043c") + buf.write("\3\2\2\2\u043a\u0438\3\2\2\2\u043a\u043b\3\2\2\2\u043b") + buf.write("Y\3\2\2\2\u043c\u043a\3\2\2\2\u043d\u043e\5P)\2\u043e") + buf.write("[\3\2\2\2k_amqt~\u0082\u0088\u008c\u0092\u009c\u00a4\u00a8") + buf.write("\u00ad\u00c0\u00cd\u00d4\u00dc\u00eb\u00f8\u0102\u0113") + buf.write("\u011c\u0126\u0140\u0143\u014b\u014f\u0155\u0158\u015d") + buf.write("\u0160\u0166\u016a\u016d\u0170\u0174\u0178\u017b\u017e") + buf.write("\u0182\u0186\u018a\u018e\u0192\u0196\u0199\u019c\u01a0") + buf.write("\u01a4\u01a8\u01ac\u01b0\u01b3\u01b6\u01ba\u01bc\u01c4") + buf.write("\u01c8\u01cc\u01cf\u01d5\u01d8\u01dd\u01e0\u01e6\u01ea") + buf.write("\u01f3\u01fc\u01fe\u0206\u020e\u0217\u0224\u022a\u0242") + buf.write("\u024b\u0255\u02a2\u02ae\u02be\u02c7\u02d5\u02f4\u02ff") + buf.write("\u0303\u0313\u0315\u0320\u032d\u033a\u0341\u0383\u038f") + buf.write("\u03a8\u03b4\u03e2\u03e5\u03e7\u0414\u041e\u0420\u0431") + buf.write("\u0433\u043a") + return buf.getvalue() + + +class CelestialParser ( Parser ): + + grammarFileName = "CelestialParser.g4" + + atn = ATNDeserializer().deserialize(serializedATN()) + + decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ] + + sharedContextCache = PredictionContextCache() + + literalNames = [ "", "'address'", "'bool'", "'enum'", "'event'", + "'eventlog'", "'uint'", "'uint8'", "'inst_map'", "'int'", + "'string'", "'contract'", "'mapping'", "'bytes'", "'bytes20'", + "'bytes32'", "'add'", "'as'", "'assert'", "'balance'", + "'block.coinbase'", "'block.difficulty'", "'block.gaslimit'", + "'block.number'", "'block.timestamp'", "'call'", "'call_bool'", + "'call_uint'", "'constant'", "'constructor'", "'contains'", + "'credit'", "'debit'", "'default'", "'delete'", "'else'", + "'emit'", "'eTransfer'", "'exists'", "'fallback'", + "'for'", "'forall'", "'from'", "'function'", "'if'", + "'import'", "'in'", "'int_min'", "'int_max'", "'ite'", + "'invariant'", "'keys'", "'lemma'", "'length'", "'log'", + "'modifies'", "'modifies_addresses'", "'new'", "'payable'", + "'pop'", "'post'", "'pragma'", "'pre'", "'print'", + "'private'", "'public'", "'pure'", "'push'", "'receive'", + "'return'", "'returns'", "'revert'", "'r_reverts'", + "'safe_add'", "'safe_div'", "'safe_mod'", "'safe_mul'", + "'safe_sub'", "'send'", "'sender'", "'spec'", "'struct'", + "'this'", "'transfer'", "'tx_reverts'", "'tx.gasprice'", + "'tx.origin'", "'uint_max'", "'using'", "'value'", + "'view'", "", "", "'null'", "", + "", "'!'", "'&&'", "'||'", "'=>'", "'==>'", + "'<==>'", "'=='", "'!='", "'<='", "'>='", "'<'", "'>'", + "'->'", "'='", "'+='", "'-='", "'+'", "'-'", "'*'", + "'/'", "'%'", "'^'", "'~'", "'{'", "'}'", "'['", "']'", + "'('", "')'", "';'", "','", "'.'", "':'" ] + + symbolicNames = [ "", "ADDR", "BOOL", "ENUM", "EVENT", "EVENTLOG", + "UINT", "UINT8", "INSTMAP", "INT", "STRING", "CONTRACT", + "MAP", "BYTES", "BYTES20", "BYTES32", "ADD", "AS", + "ASSERT", "BALANCE", "BCOINBASE", "BDIFF", "BGASLIMIT", + "BNUMBER", "BTIMESTAMP", "CALL", "CALLBOOL", "CALLUINT", + "CONSTANT", "CONSTR", "CONTAINS", "CREDIT", "DEBIT", + "DEFAULT", "DELETE", "ELSE", "EMIT", "ETRANSFER", + "EXISTS", "FALLBACK", "FOR", "FORALL", "FROM", "FUNCTION", + "IF", "IMPORT", "IN", "INT_MIN", "INT_MAX", "ITE", + "INVARIANT", "KEYS", "LEMMA", "LENGTH", "LOG", "MODIFIES", + "MODIFIESA", "NEW", "PAYABLE", "POP", "POST", "PRAGMA", + "PRE", "PRINT", "PRIVATE", "PUBLIC", "PURE", "PUSH", + "RECEIVE", "RETURN", "RETURNS", "REVERT", "RREVERTS", + "SAFEADD", "SAFEDIV", "SAFEMOD", "SAFEMUL", "SAFESUB", + "SEND", "SENDER", "SPEC", "STRUCT", "THIS", "TRANSFER", + "TXREVERTS", "TXGASPRICE", "TXORIGIN", "UINT_MAX", + "USING", "VALUE", "VIEW", "BoolLiteral", "IntLiteral", + "NullLiteral", "StringLiteral", "VersionLiteral", + "LNOT", "LAND", "LOR", "MAPUPD", "IMPL", "BIMPL", + "EQ", "NE", "LE", "GE", "LT", "GT", "RARROW", "ASSIGN", + "INSERT", "REMOVE", "PLUS", "SUB", "MUL", "DIV", "MOD", + "CARET", "BNOT", "LBRACE", "RBRACE", "LBRACK", "RBRACK", + "LPAREN", "RPAREN", "SEMI", "COMMA", "DOT", "COLON", + "Iden", "Whitespace", "BlockComment", "LineComment" ] + + RULE_program = 0 + RULE_pragmaDirective = 1 + RULE_pragmaValue = 2 + RULE_version = 3 + RULE_versionConstraint = 4 + RULE_versionOperator = 5 + RULE_importDirective = 6 + RULE_importDeclaration = 7 + RULE_iden = 8 + RULE_datatype = 9 + RULE_idenTypeList = 10 + RULE_idenType = 11 + RULE_contractDecl = 12 + RULE_contractBody = 13 + RULE_contractContents = 14 + RULE_enumDecl = 15 + RULE_structDecl = 16 + RULE_funDecl = 17 + RULE_funParamList = 18 + RULE_funParam = 19 + RULE_functionBody = 20 + RULE_invariantDecl = 21 + RULE_invariantBody = 22 + RULE_eventDecl = 23 + RULE_constructorDecl = 24 + RULE_spec = 25 + RULE_stateMutability = 26 + RULE_methodDecl = 27 + RULE_methodParamList = 28 + RULE_methodParam = 29 + RULE_methodBody = 30 + RULE_returnStatement = 31 + RULE_varDecl = 32 + RULE_usingForDecl = 33 + RULE_loopVarDecl = 34 + RULE_statement = 35 + RULE_elseStatement = 36 + RULE_lvalue = 37 + RULE_logcheck = 38 + RULE_expr = 39 + RULE_primitive = 40 + RULE_unnamedTupleBody = 41 + RULE_namedTupleBody = 42 + RULE_rvalueList = 43 + RULE_rvalue = 44 + + ruleNames = [ "program", "pragmaDirective", "pragmaValue", "version", + "versionConstraint", "versionOperator", "importDirective", + "importDeclaration", "iden", "datatype", "idenTypeList", + "idenType", "contractDecl", "contractBody", "contractContents", + "enumDecl", "structDecl", "funDecl", "funParamList", + "funParam", "functionBody", "invariantDecl", "invariantBody", + "eventDecl", "constructorDecl", "spec", "stateMutability", + "methodDecl", "methodParamList", "methodParam", "methodBody", + "returnStatement", "varDecl", "usingForDecl", "loopVarDecl", + "statement", "elseStatement", "lvalue", "logcheck", "expr", + "primitive", "unnamedTupleBody", "namedTupleBody", "rvalueList", + "rvalue" ] + + EOF = Token.EOF + ADDR=1 + BOOL=2 + ENUM=3 + EVENT=4 + EVENTLOG=5 + UINT=6 + UINT8=7 + INSTMAP=8 + INT=9 + STRING=10 + CONTRACT=11 + MAP=12 + BYTES=13 + BYTES20=14 + BYTES32=15 + ADD=16 + AS=17 + ASSERT=18 + BALANCE=19 + BCOINBASE=20 + BDIFF=21 + BGASLIMIT=22 + BNUMBER=23 + BTIMESTAMP=24 + CALL=25 + CALLBOOL=26 + CALLUINT=27 + CONSTANT=28 + CONSTR=29 + CONTAINS=30 + CREDIT=31 + DEBIT=32 + DEFAULT=33 + DELETE=34 + ELSE=35 + EMIT=36 + ETRANSFER=37 + EXISTS=38 + FALLBACK=39 + FOR=40 + FORALL=41 + FROM=42 + FUNCTION=43 + IF=44 + IMPORT=45 + IN=46 + INT_MIN=47 + INT_MAX=48 + ITE=49 + INVARIANT=50 + KEYS=51 + LEMMA=52 + LENGTH=53 + LOG=54 + MODIFIES=55 + MODIFIESA=56 + NEW=57 + PAYABLE=58 + POP=59 + POST=60 + PRAGMA=61 + PRE=62 + PRINT=63 + PRIVATE=64 + PUBLIC=65 + PURE=66 + PUSH=67 + RECEIVE=68 + RETURN=69 + RETURNS=70 + REVERT=71 + RREVERTS=72 + SAFEADD=73 + SAFEDIV=74 + SAFEMOD=75 + SAFEMUL=76 + SAFESUB=77 + SEND=78 + SENDER=79 + SPEC=80 + STRUCT=81 + THIS=82 + TRANSFER=83 + TXREVERTS=84 + TXGASPRICE=85 + TXORIGIN=86 + UINT_MAX=87 + USING=88 + VALUE=89 + VIEW=90 + BoolLiteral=91 + IntLiteral=92 + NullLiteral=93 + StringLiteral=94 + VersionLiteral=95 + LNOT=96 + LAND=97 + LOR=98 + MAPUPD=99 + IMPL=100 + BIMPL=101 + EQ=102 + NE=103 + LE=104 + GE=105 + LT=106 + GT=107 + RARROW=108 + ASSIGN=109 + INSERT=110 + REMOVE=111 + PLUS=112 + SUB=113 + MUL=114 + DIV=115 + MOD=116 + CARET=117 + BNOT=118 + LBRACE=119 + RBRACE=120 + LBRACK=121 + RBRACK=122 + LPAREN=123 + RPAREN=124 + SEMI=125 + COMMA=126 + DOT=127 + COLON=128 + Iden=129 + Whitespace=130 + BlockComment=131 + LineComment=132 + + def __init__(self, input:TokenStream, output:TextIO = sys.stdout): + super().__init__(input, output) + self.checkVersion("4.7.1") + self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) + self._predicates = None + + + + class ProgramContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def EOF(self): + return self.getToken(CelestialParser.EOF, 0) + + def contractDecl(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ContractDeclContext) + else: + return self.getTypedRuleContext(CelestialParser.ContractDeclContext,i) + + + def pragmaDirective(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.PragmaDirectiveContext) + else: + return self.getTypedRuleContext(CelestialParser.PragmaDirectiveContext,i) + + + def importDirective(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ImportDirectiveContext) + else: + return self.getTypedRuleContext(CelestialParser.ImportDirectiveContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_program + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterProgram" ): + listener.enterProgram(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitProgram" ): + listener.exitProgram(self) + + + + + def program(self): + + localctx = CelestialParser.ProgramContext(self, self._ctx, self.state) + self.enterRule(localctx, 0, self.RULE_program) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 95 + self._errHandler.sync(self) + _la = self._input.LA(1) + while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.CONTRACT) | (1 << CelestialParser.IMPORT) | (1 << CelestialParser.PRAGMA))) != 0): + self.state = 93 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.CONTRACT]: + self.state = 90 + self.contractDecl() + pass + elif token in [CelestialParser.PRAGMA]: + self.state = 91 + self.pragmaDirective() + pass + elif token in [CelestialParser.IMPORT]: + self.state = 92 + self.importDirective() + pass + else: + raise NoViableAltException(self) + + self.state = 97 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 98 + self.match(CelestialParser.EOF) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class PragmaDirectiveContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.pragmaName = None # IdenContext + + def PRAGMA(self): + return self.getToken(CelestialParser.PRAGMA, 0) + + def pragmaValue(self): + return self.getTypedRuleContext(CelestialParser.PragmaValueContext,0) + + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_pragmaDirective + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPragmaDirective" ): + listener.enterPragmaDirective(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPragmaDirective" ): + listener.exitPragmaDirective(self) + + + + + def pragmaDirective(self): + + localctx = CelestialParser.PragmaDirectiveContext(self, self._ctx, self.state) + self.enterRule(localctx, 2, self.RULE_pragmaDirective) + try: + self.enterOuterAlt(localctx, 1) + self.state = 100 + self.match(CelestialParser.PRAGMA) + self.state = 101 + localctx.pragmaName = self.iden() + self.state = 102 + self.pragmaValue() + self.state = 103 + self.match(CelestialParser.SEMI) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class PragmaValueContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def version(self): + return self.getTypedRuleContext(CelestialParser.VersionContext,0) + + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_pragmaValue + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPragmaValue" ): + listener.enterPragmaValue(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPragmaValue" ): + listener.exitPragmaValue(self) + + + + + def pragmaValue(self): + + localctx = CelestialParser.PragmaValueContext(self, self._ctx, self.state) + self.enterRule(localctx, 4, self.RULE_pragmaValue) + try: + self.state = 107 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.VersionLiteral, CelestialParser.LE, CelestialParser.GE, CelestialParser.LT, CelestialParser.GT, CelestialParser.ASSIGN, CelestialParser.CARET, CelestialParser.BNOT]: + self.enterOuterAlt(localctx, 1) + self.state = 105 + self.version() + pass + elif token in [CelestialParser.ADDR, CelestialParser.BALANCE, CelestialParser.BCOINBASE, CelestialParser.BDIFF, CelestialParser.BGASLIMIT, CelestialParser.BNUMBER, CelestialParser.BTIMESTAMP, CelestialParser.DEFAULT, CelestialParser.EXISTS, CelestialParser.FORALL, CelestialParser.INT_MIN, CelestialParser.INT_MAX, CelestialParser.ITE, CelestialParser.LOG, CelestialParser.NEW, CelestialParser.PAYABLE, CelestialParser.SAFEADD, CelestialParser.SAFEDIV, CelestialParser.SAFEMOD, CelestialParser.SAFEMUL, CelestialParser.SAFESUB, CelestialParser.SENDER, CelestialParser.THIS, CelestialParser.TXGASPRICE, CelestialParser.TXORIGIN, CelestialParser.UINT_MAX, CelestialParser.VALUE, CelestialParser.BoolLiteral, CelestialParser.IntLiteral, CelestialParser.NullLiteral, CelestialParser.StringLiteral, CelestialParser.LNOT, CelestialParser.SUB, CelestialParser.LPAREN, CelestialParser.Iden]: + self.enterOuterAlt(localctx, 2) + self.state = 106 + self.expr(0) + pass + else: + raise NoViableAltException(self) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class VersionContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def versionConstraint(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.VersionConstraintContext) + else: + return self.getTypedRuleContext(CelestialParser.VersionConstraintContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_version + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVersion" ): + listener.enterVersion(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVersion" ): + listener.exitVersion(self) + + + + + def version(self): + + localctx = CelestialParser.VersionContext(self, self._ctx, self.state) + self.enterRule(localctx, 6, self.RULE_version) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 109 + self.versionConstraint() + self.state = 111 + self._errHandler.sync(self) + _la = self._input.LA(1) + if ((((_la - 95)) & ~0x3f) == 0 and ((1 << (_la - 95)) & ((1 << (CelestialParser.VersionLiteral - 95)) | (1 << (CelestialParser.LE - 95)) | (1 << (CelestialParser.GE - 95)) | (1 << (CelestialParser.LT - 95)) | (1 << (CelestialParser.GT - 95)) | (1 << (CelestialParser.ASSIGN - 95)) | (1 << (CelestialParser.CARET - 95)) | (1 << (CelestialParser.BNOT - 95)))) != 0): + self.state = 110 + self.versionConstraint() + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class VersionConstraintContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def VersionLiteral(self): + return self.getToken(CelestialParser.VersionLiteral, 0) + + def versionOperator(self): + return self.getTypedRuleContext(CelestialParser.VersionOperatorContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_versionConstraint + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVersionConstraint" ): + listener.enterVersionConstraint(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVersionConstraint" ): + listener.exitVersionConstraint(self) + + + + + def versionConstraint(self): + + localctx = CelestialParser.VersionConstraintContext(self, self._ctx, self.state) + self.enterRule(localctx, 8, self.RULE_versionConstraint) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 114 + self._errHandler.sync(self) + _la = self._input.LA(1) + if ((((_la - 104)) & ~0x3f) == 0 and ((1 << (_la - 104)) & ((1 << (CelestialParser.LE - 104)) | (1 << (CelestialParser.GE - 104)) | (1 << (CelestialParser.LT - 104)) | (1 << (CelestialParser.GT - 104)) | (1 << (CelestialParser.ASSIGN - 104)) | (1 << (CelestialParser.CARET - 104)) | (1 << (CelestialParser.BNOT - 104)))) != 0): + self.state = 113 + self.versionOperator() + + + self.state = 116 + self.match(CelestialParser.VersionLiteral) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class VersionOperatorContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def CARET(self): + return self.getToken(CelestialParser.CARET, 0) + + def BNOT(self): + return self.getToken(CelestialParser.BNOT, 0) + + def GE(self): + return self.getToken(CelestialParser.GE, 0) + + def GT(self): + return self.getToken(CelestialParser.GT, 0) + + def LT(self): + return self.getToken(CelestialParser.LT, 0) + + def LE(self): + return self.getToken(CelestialParser.LE, 0) + + def ASSIGN(self): + return self.getToken(CelestialParser.ASSIGN, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_versionOperator + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVersionOperator" ): + listener.enterVersionOperator(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVersionOperator" ): + listener.exitVersionOperator(self) + + + + + def versionOperator(self): + + localctx = CelestialParser.VersionOperatorContext(self, self._ctx, self.state) + self.enterRule(localctx, 10, self.RULE_versionOperator) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 118 + _la = self._input.LA(1) + if not(((((_la - 104)) & ~0x3f) == 0 and ((1 << (_la - 104)) & ((1 << (CelestialParser.LE - 104)) | (1 << (CelestialParser.GE - 104)) | (1 << (CelestialParser.LT - 104)) | (1 << (CelestialParser.GT - 104)) | (1 << (CelestialParser.ASSIGN - 104)) | (1 << (CelestialParser.CARET - 104)) | (1 << (CelestialParser.BNOT - 104)))) != 0)): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ImportDirectiveContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def IMPORT(self): + return self.getToken(CelestialParser.IMPORT, 0) + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def StringLiteral(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.StringLiteral) + else: + return self.getToken(CelestialParser.StringLiteral, i) + + def AS(self): + return self.getToken(CelestialParser.AS, 0) + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def FROM(self): + return self.getToken(CelestialParser.FROM, 0) + + def MUL(self): + return self.getToken(CelestialParser.MUL, 0) + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def importDeclaration(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ImportDeclarationContext) + else: + return self.getTypedRuleContext(CelestialParser.ImportDeclarationContext,i) + + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_importDirective + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterImportDirective" ): + listener.enterImportDirective(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitImportDirective" ): + listener.exitImportDirective(self) + + + + + def importDirective(self): + + localctx = CelestialParser.ImportDirectiveContext(self, self._ctx, self.state) + self.enterRule(localctx, 12, self.RULE_importDirective) + self._la = 0 # Token type + try: + self.state = 166 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,12,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 120 + self.match(CelestialParser.IMPORT) + self.state = 122 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 121 + self.match(CelestialParser.StringLiteral) + self.state = 124 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==CelestialParser.StringLiteral): + break + + self.state = 128 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.AS: + self.state = 126 + self.match(CelestialParser.AS) + self.state = 127 + self.iden() + + + self.state = 130 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 131 + self.match(CelestialParser.IMPORT) + self.state = 134 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.MUL]: + self.state = 132 + self.match(CelestialParser.MUL) + pass + elif token in [CelestialParser.Iden]: + self.state = 133 + self.iden() + pass + else: + raise NoViableAltException(self) + + self.state = 138 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.AS: + self.state = 136 + self.match(CelestialParser.AS) + self.state = 137 + self.iden() + + + self.state = 140 + self.match(CelestialParser.FROM) + self.state = 142 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 141 + self.match(CelestialParser.StringLiteral) + self.state = 144 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==CelestialParser.StringLiteral): + break + + self.state = 146 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 147 + self.match(CelestialParser.IMPORT) + self.state = 148 + self.match(CelestialParser.LBRACE) + self.state = 149 + self.importDeclaration() + self.state = 154 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 150 + self.match(CelestialParser.COMMA) + self.state = 151 + self.importDeclaration() + self.state = 156 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 157 + self.match(CelestialParser.RBRACE) + self.state = 158 + self.match(CelestialParser.FROM) + self.state = 160 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 159 + self.match(CelestialParser.StringLiteral) + self.state = 162 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==CelestialParser.StringLiteral): + break + + self.state = 164 + self.match(CelestialParser.SEMI) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ImportDeclarationContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def AS(self): + return self.getToken(CelestialParser.AS, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_importDeclaration + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterImportDeclaration" ): + listener.enterImportDeclaration(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitImportDeclaration" ): + listener.exitImportDeclaration(self) + + + + + def importDeclaration(self): + + localctx = CelestialParser.ImportDeclarationContext(self, self._ctx, self.state) + self.enterRule(localctx, 14, self.RULE_importDeclaration) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 168 + self.iden() + self.state = 171 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.AS: + self.state = 169 + self.match(CelestialParser.AS) + self.state = 170 + self.iden() + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class IdenContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def Iden(self): + return self.getToken(CelestialParser.Iden, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_iden + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterIden" ): + listener.enterIden(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitIden" ): + listener.exitIden(self) + + + + + def iden(self): + + localctx = CelestialParser.IdenContext(self, self._ctx, self.state) + self.enterRule(localctx, 16, self.RULE_iden) + try: + self.enterOuterAlt(localctx, 1) + self.state = 173 + self.match(CelestialParser.Iden) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class DatatypeContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.arrayType = None # DatatypeContext + self.keyType = None # DatatypeContext + self.valueType = None # DatatypeContext + self.name = None # IdenContext + + def MAP(self): + return self.getToken(CelestialParser.MAP, 0) + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def MAPUPD(self): + return self.getToken(CelestialParser.MAPUPD, 0) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def datatype(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.DatatypeContext) + else: + return self.getTypedRuleContext(CelestialParser.DatatypeContext,i) + + + def BOOL(self): + return self.getToken(CelestialParser.BOOL, 0) + + def INT(self): + return self.getToken(CelestialParser.INT, 0) + + def UINT(self): + return self.getToken(CelestialParser.UINT, 0) + + def UINT8(self): + return self.getToken(CelestialParser.UINT8, 0) + + def STRING(self): + return self.getToken(CelestialParser.STRING, 0) + + def ADDR(self): + return self.getToken(CelestialParser.ADDR, 0) + + def PAYABLE(self): + return self.getToken(CelestialParser.PAYABLE, 0) + + def EVENTLOG(self): + return self.getToken(CelestialParser.EVENTLOG, 0) + + def EVENT(self): + return self.getToken(CelestialParser.EVENT, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def INSTMAP(self): + return self.getToken(CelestialParser.INSTMAP, 0) + + def LT(self): + return self.getToken(CelestialParser.LT, 0) + + def GT(self): + return self.getToken(CelestialParser.GT, 0) + + def BYTES(self): + return self.getToken(CelestialParser.BYTES, 0) + + def BYTES20(self): + return self.getToken(CelestialParser.BYTES20, 0) + + def BYTES32(self): + return self.getToken(CelestialParser.BYTES32, 0) + + def LBRACK(self): + return self.getToken(CelestialParser.LBRACK, 0) + + def RBRACK(self): + return self.getToken(CelestialParser.RBRACK, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_datatype + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterDatatype" ): + listener.enterDatatype(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitDatatype" ): + listener.exitDatatype(self) + + + + def datatype(self, _p:int=0): + _parentctx = self._ctx + _parentState = self.state + localctx = CelestialParser.DatatypeContext(self, self._ctx, _parentState) + _prevctx = localctx + _startState = 18 + self.enterRecursionRule(localctx, 18, self.RULE_datatype, _p) + try: + self.enterOuterAlt(localctx, 1) + self.state = 203 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.MAP]: + self.state = 176 + self.match(CelestialParser.MAP) + self.state = 177 + self.match(CelestialParser.LPAREN) + self.state = 178 + localctx.keyType = self.datatype(0) + self.state = 179 + self.match(CelestialParser.MAPUPD) + self.state = 180 + localctx.valueType = self.datatype(0) + self.state = 181 + self.match(CelestialParser.RPAREN) + pass + elif token in [CelestialParser.BOOL]: + self.state = 183 + self.match(CelestialParser.BOOL) + pass + elif token in [CelestialParser.INT]: + self.state = 184 + self.match(CelestialParser.INT) + pass + elif token in [CelestialParser.UINT]: + self.state = 185 + self.match(CelestialParser.UINT) + pass + elif token in [CelestialParser.UINT8]: + self.state = 186 + self.match(CelestialParser.UINT8) + pass + elif token in [CelestialParser.STRING]: + self.state = 187 + self.match(CelestialParser.STRING) + pass + elif token in [CelestialParser.ADDR]: + self.state = 188 + self.match(CelestialParser.ADDR) + self.state = 190 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,14,self._ctx) + if la_ == 1: + self.state = 189 + self.match(CelestialParser.PAYABLE) + + + pass + elif token in [CelestialParser.EVENTLOG]: + self.state = 192 + self.match(CelestialParser.EVENTLOG) + pass + elif token in [CelestialParser.EVENT]: + self.state = 193 + self.match(CelestialParser.EVENT) + pass + elif token in [CelestialParser.Iden]: + self.state = 194 + localctx.name = self.iden() + pass + elif token in [CelestialParser.INSTMAP]: + self.state = 195 + self.match(CelestialParser.INSTMAP) + self.state = 196 + self.match(CelestialParser.LT) + self.state = 197 + self.iden() + self.state = 198 + self.match(CelestialParser.GT) + pass + elif token in [CelestialParser.BYTES]: + self.state = 200 + self.match(CelestialParser.BYTES) + pass + elif token in [CelestialParser.BYTES20]: + self.state = 201 + self.match(CelestialParser.BYTES20) + pass + elif token in [CelestialParser.BYTES32]: + self.state = 202 + self.match(CelestialParser.BYTES32) + pass + else: + raise NoViableAltException(self) + + self._ctx.stop = self._input.LT(-1) + self.state = 210 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,16,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + _prevctx = localctx + localctx = CelestialParser.DatatypeContext(self, _parentctx, _parentState) + localctx.arrayType = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_datatype) + self.state = 205 + if not self.precpred(self._ctx, 15): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 15)") + self.state = 206 + self.match(CelestialParser.LBRACK) + self.state = 207 + self.match(CelestialParser.RBRACK) + self.state = 212 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,16,self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + class IdenTypeListContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def idenType(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenTypeContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenTypeContext,i) + + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_idenTypeList + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterIdenTypeList" ): + listener.enterIdenTypeList(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitIdenTypeList" ): + listener.exitIdenTypeList(self) + + + + + def idenTypeList(self): + + localctx = CelestialParser.IdenTypeListContext(self, self._ctx, self.state) + self.enterRule(localctx, 20, self.RULE_idenTypeList) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 213 + self.idenType() + self.state = 218 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 214 + self.match(CelestialParser.COMMA) + self.state = 215 + self.idenType() + self.state = 220 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class IdenTypeContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def COLON(self): + return self.getToken(CelestialParser.COLON, 0) + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_idenType + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterIdenType" ): + listener.enterIdenType(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitIdenType" ): + listener.exitIdenType(self) + + + + + def idenType(self): + + localctx = CelestialParser.IdenTypeContext(self, self._ctx, self.state) + self.enterRule(localctx, 22, self.RULE_idenType) + try: + self.enterOuterAlt(localctx, 1) + self.state = 221 + localctx.name = self.iden() + self.state = 222 + self.match(CelestialParser.COLON) + self.state = 223 + self.datatype(0) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ContractDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def CONTRACT(self): + return self.getToken(CelestialParser.CONTRACT, 0) + + def contractBody(self): + return self.getTypedRuleContext(CelestialParser.ContractBodyContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_contractDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractDecl" ): + listener.enterContractDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractDecl" ): + listener.exitContractDecl(self) + + + + + def contractDecl(self): + + localctx = CelestialParser.ContractDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 24, self.RULE_contractDecl) + try: + self.enterOuterAlt(localctx, 1) + self.state = 225 + self.match(CelestialParser.CONTRACT) + self.state = 226 + localctx.name = self.iden() + self.state = 227 + self.contractBody() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ContractBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def contractContents(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ContractContentsContext) + else: + return self.getTypedRuleContext(CelestialParser.ContractContentsContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_contractBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractBody" ): + listener.enterContractBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractBody" ): + listener.exitContractBody(self) + + + + + def contractBody(self): + + localctx = CelestialParser.ContractBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 26, self.RULE_contractBody) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 229 + self.match(CelestialParser.LBRACE) + self.state = 231 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 230 + self.contractContents() + self.state = 233 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not ((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.ENUM) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32) | (1 << CelestialParser.CONSTR) | (1 << CelestialParser.FALLBACK) | (1 << CelestialParser.FUNCTION) | (1 << CelestialParser.INVARIANT))) != 0) or ((((_la - 68)) & ~0x3f) == 0 and ((1 << (_la - 68)) & ((1 << (CelestialParser.RECEIVE - 68)) | (1 << (CelestialParser.SPEC - 68)) | (1 << (CelestialParser.STRUCT - 68)) | (1 << (CelestialParser.USING - 68)) | (1 << (CelestialParser.Iden - 68)))) != 0)): + break + + self.state = 235 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ContractContentsContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def varDecl(self): + return self.getTypedRuleContext(CelestialParser.VarDeclContext,0) + + + def enumDecl(self): + return self.getTypedRuleContext(CelestialParser.EnumDeclContext,0) + + + def structDecl(self): + return self.getTypedRuleContext(CelestialParser.StructDeclContext,0) + + + def funDecl(self): + return self.getTypedRuleContext(CelestialParser.FunDeclContext,0) + + + def invariantDecl(self): + return self.getTypedRuleContext(CelestialParser.InvariantDeclContext,0) + + + def eventDecl(self): + return self.getTypedRuleContext(CelestialParser.EventDeclContext,0) + + + def constructorDecl(self): + return self.getTypedRuleContext(CelestialParser.ConstructorDeclContext,0) + + + def methodDecl(self): + return self.getTypedRuleContext(CelestialParser.MethodDeclContext,0) + + + def usingForDecl(self): + return self.getTypedRuleContext(CelestialParser.UsingForDeclContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_contractContents + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterContractContents" ): + listener.enterContractContents(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitContractContents" ): + listener.exitContractContents(self) + + + + + def contractContents(self): + + localctx = CelestialParser.ContractContentsContext(self, self._ctx, self.state) + self.enterRule(localctx, 28, self.RULE_contractContents) + try: + self.state = 246 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,19,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 237 + self.varDecl() + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 238 + self.enumDecl() + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 239 + self.structDecl() + pass + + elif la_ == 4: + self.enterOuterAlt(localctx, 4) + self.state = 240 + self.funDecl() + pass + + elif la_ == 5: + self.enterOuterAlt(localctx, 5) + self.state = 241 + self.invariantDecl() + pass + + elif la_ == 6: + self.enterOuterAlt(localctx, 6) + self.state = 242 + self.eventDecl() + pass + + elif la_ == 7: + self.enterOuterAlt(localctx, 7) + self.state = 243 + self.constructorDecl() + pass + + elif la_ == 8: + self.enterOuterAlt(localctx, 8) + self.state = 244 + self.methodDecl() + pass + + elif la_ == 9: + self.enterOuterAlt(localctx, 9) + self.state = 245 + self.usingForDecl() + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class EnumDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def ENUM(self): + return self.getToken(CelestialParser.ENUM, 0) + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_enumDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterEnumDecl" ): + listener.enterEnumDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitEnumDecl" ): + listener.exitEnumDecl(self) + + + + + def enumDecl(self): + + localctx = CelestialParser.EnumDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 30, self.RULE_enumDecl) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 248 + self.match(CelestialParser.ENUM) + self.state = 249 + localctx.name = self.iden() + self.state = 250 + self.match(CelestialParser.LBRACE) + self.state = 251 + self.iden() + self.state = 256 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 252 + self.match(CelestialParser.COMMA) + self.state = 253 + self.iden() + self.state = 258 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 259 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class StructDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def STRUCT(self): + return self.getToken(CelestialParser.STRUCT, 0) + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def datatype(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.DatatypeContext) + else: + return self.getTypedRuleContext(CelestialParser.DatatypeContext,i) + + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def SEMI(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.SEMI) + else: + return self.getToken(CelestialParser.SEMI, i) + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_structDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterStructDecl" ): + listener.enterStructDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitStructDecl" ): + listener.exitStructDecl(self) + + + + + def structDecl(self): + + localctx = CelestialParser.StructDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 32, self.RULE_structDecl) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 261 + self.match(CelestialParser.STRUCT) + self.state = 262 + localctx.name = self.iden() + self.state = 263 + self.match(CelestialParser.LBRACE) + self.state = 264 + self.datatype(0) + self.state = 265 + self.iden() + self.state = 266 + self.match(CelestialParser.SEMI) + self.state = 273 + self._errHandler.sync(self) + _la = self._input.LA(1) + while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32))) != 0) or _la==CelestialParser.Iden: + self.state = 267 + self.datatype(0) + self.state = 268 + self.iden() + self.state = 269 + self.match(CelestialParser.SEMI) + self.state = 275 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 276 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class FunDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return CelestialParser.RULE_funDecl + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class FDeclContext(FunDeclContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CelestialParser.FunDeclContext + super().__init__(parser) + self.name = None # IdenContext + self.copyFrom(ctx) + + def SPEC(self): + return self.getToken(CelestialParser.SPEC, 0) + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + def functionBody(self): + return self.getTypedRuleContext(CelestialParser.FunctionBodyContext,0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + def funParamList(self): + return self.getTypedRuleContext(CelestialParser.FunParamListContext,0) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFDecl" ): + listener.enterFDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFDecl" ): + listener.exitFDecl(self) + + + + def funDecl(self): + + localctx = CelestialParser.FunDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 34, self.RULE_funDecl) + self._la = 0 # Token type + try: + localctx = CelestialParser.FDeclContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 278 + self.match(CelestialParser.SPEC) + self.state = 279 + localctx.name = self.iden() + self.state = 280 + self.match(CelestialParser.LPAREN) + self.state = 282 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32))) != 0) or _la==CelestialParser.Iden: + self.state = 281 + self.funParamList() + + + self.state = 284 + self.match(CelestialParser.RPAREN) + self.state = 285 + self.functionBody() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class FunParamListContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def funParam(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.FunParamContext) + else: + return self.getTypedRuleContext(CelestialParser.FunParamContext,i) + + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_funParamList + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFunParamList" ): + listener.enterFunParamList(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFunParamList" ): + listener.exitFunParamList(self) + + + + + def funParamList(self): + + localctx = CelestialParser.FunParamListContext(self, self._ctx, self.state) + self.enterRule(localctx, 36, self.RULE_funParamList) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 287 + self.funParam() + self.state = 292 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 288 + self.match(CelestialParser.COMMA) + self.state = 289 + self.funParam() + self.state = 294 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class FunParamContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_funParam + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFunParam" ): + listener.enterFunParam(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFunParam" ): + listener.exitFunParam(self) + + + + + def funParam(self): + + localctx = CelestialParser.FunParamContext(self, self._ctx, self.state) + self.enterRule(localctx, 38, self.RULE_funParam) + try: + self.enterOuterAlt(localctx, 1) + self.state = 295 + self.datatype(0) + self.state = 296 + localctx.name = self.iden() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class FunctionBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_functionBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterFunctionBody" ): + listener.enterFunctionBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitFunctionBody" ): + listener.exitFunctionBody(self) + + + + + def functionBody(self): + + localctx = CelestialParser.FunctionBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 40, self.RULE_functionBody) + try: + self.enterOuterAlt(localctx, 1) + self.state = 298 + self.match(CelestialParser.LBRACE) + self.state = 299 + self.expr(0) + self.state = 300 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class InvariantDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def INVARIANT(self): + return self.getToken(CelestialParser.INVARIANT, 0) + + def invariantBody(self): + return self.getTypedRuleContext(CelestialParser.InvariantBodyContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_invariantDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterInvariantDecl" ): + listener.enterInvariantDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitInvariantDecl" ): + listener.exitInvariantDecl(self) + + + + + def invariantDecl(self): + + localctx = CelestialParser.InvariantDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 42, self.RULE_invariantDecl) + try: + self.enterOuterAlt(localctx, 1) + self.state = 302 + self.match(CelestialParser.INVARIANT) + self.state = 303 + localctx.name = self.iden() + self.state = 304 + self.invariantBody() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class InvariantBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_invariantBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterInvariantBody" ): + listener.enterInvariantBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitInvariantBody" ): + listener.exitInvariantBody(self) + + + + + def invariantBody(self): + + localctx = CelestialParser.InvariantBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 44, self.RULE_invariantBody) + try: + self.enterOuterAlt(localctx, 1) + self.state = 306 + self.match(CelestialParser.LBRACE) + self.state = 307 + self.expr(0) + self.state = 308 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class EventDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def EVENT(self): + return self.getToken(CelestialParser.EVENT, 0) + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def datatype(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.DatatypeContext) + else: + return self.getTypedRuleContext(CelestialParser.DatatypeContext,i) + + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_eventDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterEventDecl" ): + listener.enterEventDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitEventDecl" ): + listener.exitEventDecl(self) + + + + + def eventDecl(self): + + localctx = CelestialParser.EventDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 46, self.RULE_eventDecl) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 310 + self.match(CelestialParser.EVENT) + self.state = 311 + localctx.name = self.iden() + self.state = 312 + self.match(CelestialParser.LPAREN) + self.state = 321 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32))) != 0) or _la==CelestialParser.Iden: + self.state = 313 + self.datatype(0) + self.state = 318 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 314 + self.match(CelestialParser.COMMA) + self.state = 315 + self.datatype(0) + self.state = 320 + self._errHandler.sync(self) + _la = self._input.LA(1) + + + + self.state = 323 + self.match(CelestialParser.RPAREN) + self.state = 324 + self.match(CelestialParser.SEMI) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ConstructorDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.modifies = None # RvalueListContext + self.modifies_addrs = None # RvalueListContext + + def CONSTR(self): + return self.getToken(CelestialParser.CONSTR, 0) + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def spec(self): + return self.getTypedRuleContext(CelestialParser.SpecContext,0) + + + def methodBody(self): + return self.getTypedRuleContext(CelestialParser.MethodBodyContext,0) + + + def methodParamList(self): + return self.getTypedRuleContext(CelestialParser.MethodParamListContext,0) + + + def MODIFIES(self): + return self.getToken(CelestialParser.MODIFIES, 0) + + def LBRACK(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.LBRACK) + else: + return self.getToken(CelestialParser.LBRACK, i) + + def RBRACK(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.RBRACK) + else: + return self.getToken(CelestialParser.RBRACK, i) + + def MODIFIESA(self): + return self.getToken(CelestialParser.MODIFIESA, 0) + + def PUBLIC(self): + return self.getToken(CelestialParser.PUBLIC, 0) + + def PRIVATE(self): + return self.getToken(CelestialParser.PRIVATE, 0) + + def rvalueList(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.RvalueListContext) + else: + return self.getTypedRuleContext(CelestialParser.RvalueListContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_constructorDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterConstructorDecl" ): + listener.enterConstructorDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitConstructorDecl" ): + listener.exitConstructorDecl(self) + + + + + def constructorDecl(self): + + localctx = CelestialParser.ConstructorDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 48, self.RULE_constructorDecl) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 326 + self.match(CelestialParser.CONSTR) + self.state = 327 + self.match(CelestialParser.LPAREN) + self.state = 329 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32))) != 0) or _la==CelestialParser.Iden: + self.state = 328 + self.methodParamList() + + + self.state = 331 + self.match(CelestialParser.RPAREN) + self.state = 333 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRIVATE or _la==CelestialParser.PUBLIC: + self.state = 332 + _la = self._input.LA(1) + if not(_la==CelestialParser.PRIVATE or _la==CelestialParser.PUBLIC): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + + + self.state = 335 + self.spec() + self.state = 342 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.MODIFIES: + self.state = 336 + self.match(CelestialParser.MODIFIES) + self.state = 337 + self.match(CelestialParser.LBRACK) + self.state = 339 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 338 + localctx.modifies = self.rvalueList() + + + self.state = 341 + self.match(CelestialParser.RBRACK) + + + self.state = 350 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.MODIFIESA: + self.state = 344 + self.match(CelestialParser.MODIFIESA) + self.state = 345 + self.match(CelestialParser.LBRACK) + self.state = 347 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 346 + localctx.modifies_addrs = self.rvalueList() + + + self.state = 349 + self.match(CelestialParser.RBRACK) + + + self.state = 352 + self.methodBody() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class SpecContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.pre = None # ExprContext + self.post = None # ExprContext + self.reverts = None # ExprContext + self.rreverts = None # ExprContext + + def PRE(self): + return self.getToken(CelestialParser.PRE, 0) + + def POST(self): + return self.getToken(CelestialParser.POST, 0) + + def CREDIT(self): + return self.getToken(CelestialParser.CREDIT, 0) + + def DEBIT(self): + return self.getToken(CelestialParser.DEBIT, 0) + + def TXREVERTS(self): + return self.getToken(CelestialParser.TXREVERTS, 0) + + def RREVERTS(self): + return self.getToken(CelestialParser.RREVERTS, 0) + + def expr(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ExprContext) + else: + return self.getTypedRuleContext(CelestialParser.ExprContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_spec + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterSpec" ): + listener.enterSpec(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitSpec" ): + listener.exitSpec(self) + + + + + def spec(self): + + localctx = CelestialParser.SpecContext(self, self._ctx, self.state) + self.enterRule(localctx, 50, self.RULE_spec) + self._la = 0 # Token type + try: + self.state = 442 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,56,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 356 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRE: + self.state = 354 + self.match(CelestialParser.PRE) + self.state = 355 + localctx.pre = self.expr(0) + + + self.state = 360 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.POST: + self.state = 358 + self.match(CelestialParser.POST) + self.state = 359 + localctx.post = self.expr(0) + + + self.state = 363 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.CREDIT: + self.state = 362 + self.match(CelestialParser.CREDIT) + + + self.state = 366 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.DEBIT: + self.state = 365 + self.match(CelestialParser.DEBIT) + + + self.state = 370 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.TXREVERTS: + self.state = 368 + self.match(CelestialParser.TXREVERTS) + self.state = 369 + localctx.reverts = self.expr(0) + + + self.state = 374 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.RREVERTS: + self.state = 372 + self.match(CelestialParser.RREVERTS) + self.state = 373 + localctx.rreverts = self.expr(0) + + + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 377 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.CREDIT: + self.state = 376 + self.match(CelestialParser.CREDIT) + + + self.state = 380 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.DEBIT: + self.state = 379 + self.match(CelestialParser.DEBIT) + + + self.state = 384 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRE: + self.state = 382 + self.match(CelestialParser.PRE) + self.state = 383 + localctx.pre = self.expr(0) + + + self.state = 388 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.POST: + self.state = 386 + self.match(CelestialParser.POST) + self.state = 387 + localctx.post = self.expr(0) + + + self.state = 392 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.TXREVERTS: + self.state = 390 + self.match(CelestialParser.TXREVERTS) + self.state = 391 + localctx.reverts = self.expr(0) + + + self.state = 396 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.RREVERTS: + self.state = 394 + self.match(CelestialParser.RREVERTS) + self.state = 395 + localctx.rreverts = self.expr(0) + + + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 400 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRE: + self.state = 398 + self.match(CelestialParser.PRE) + self.state = 399 + localctx.pre = self.expr(0) + + + self.state = 404 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.TXREVERTS: + self.state = 402 + self.match(CelestialParser.TXREVERTS) + self.state = 403 + localctx.reverts = self.expr(0) + + + self.state = 407 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.CREDIT: + self.state = 406 + self.match(CelestialParser.CREDIT) + + + self.state = 410 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.DEBIT: + self.state = 409 + self.match(CelestialParser.DEBIT) + + + self.state = 414 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.POST: + self.state = 412 + self.match(CelestialParser.POST) + self.state = 413 + localctx.post = self.expr(0) + + + self.state = 418 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.RREVERTS: + self.state = 416 + self.match(CelestialParser.RREVERTS) + self.state = 417 + localctx.rreverts = self.expr(0) + + + pass + + elif la_ == 4: + self.enterOuterAlt(localctx, 4) + self.state = 422 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRE: + self.state = 420 + self.match(CelestialParser.PRE) + self.state = 421 + localctx.pre = self.expr(0) + + + self.state = 426 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.TXREVERTS: + self.state = 424 + self.match(CelestialParser.TXREVERTS) + self.state = 425 + localctx.reverts = self.expr(0) + + + self.state = 430 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.POST: + self.state = 428 + self.match(CelestialParser.POST) + self.state = 429 + localctx.post = self.expr(0) + + + self.state = 433 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.CREDIT: + self.state = 432 + self.match(CelestialParser.CREDIT) + + + self.state = 436 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.DEBIT: + self.state = 435 + self.match(CelestialParser.DEBIT) + + + self.state = 440 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.RREVERTS: + self.state = 438 + self.match(CelestialParser.RREVERTS) + self.state = 439 + localctx.rreverts = self.expr(0) + + + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class StateMutabilityContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def PURE(self): + return self.getToken(CelestialParser.PURE, 0) + + def CONSTANT(self): + return self.getToken(CelestialParser.CONSTANT, 0) + + def VIEW(self): + return self.getToken(CelestialParser.VIEW, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_stateMutability + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterStateMutability" ): + listener.enterStateMutability(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitStateMutability" ): + listener.exitStateMutability(self) + + + + + def stateMutability(self): + + localctx = CelestialParser.StateMutabilityContext(self, self._ctx, self.state) + self.enterRule(localctx, 52, self.RULE_stateMutability) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 444 + _la = self._input.LA(1) + if not(((((_la - 28)) & ~0x3f) == 0 and ((1 << (_la - 28)) & ((1 << (CelestialParser.CONSTANT - 28)) | (1 << (CelestialParser.PURE - 28)) | (1 << (CelestialParser.VIEW - 28)))) != 0)): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class MethodDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + + def getRuleIndex(self): + return CelestialParser.RULE_methodDecl + + + def copyFrom(self, ctx:ParserRuleContext): + super().copyFrom(ctx) + + + + class MDeclContext(MethodDeclContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a CelestialParser.MethodDeclContext + super().__init__(parser) + self.name = None # IdenContext + self.modifies = None # RvalueListContext + self.modifies_addrs = None # RvalueListContext + self.returnval = None # IdenContext + self.copyFrom(ctx) + + def LPAREN(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.LPAREN) + else: + return self.getToken(CelestialParser.LPAREN, i) + def RPAREN(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.RPAREN) + else: + return self.getToken(CelestialParser.RPAREN, i) + def spec(self): + return self.getTypedRuleContext(CelestialParser.SpecContext,0) + + def methodBody(self): + return self.getTypedRuleContext(CelestialParser.MethodBodyContext,0) + + def RECEIVE(self): + return self.getToken(CelestialParser.RECEIVE, 0) + def FALLBACK(self): + return self.getToken(CelestialParser.FALLBACK, 0) + def FUNCTION(self): + return self.getToken(CelestialParser.FUNCTION, 0) + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + def methodParamList(self): + return self.getTypedRuleContext(CelestialParser.MethodParamListContext,0) + + def stateMutability(self): + return self.getTypedRuleContext(CelestialParser.StateMutabilityContext,0) + + def MODIFIES(self): + return self.getToken(CelestialParser.MODIFIES, 0) + def LBRACK(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.LBRACK) + else: + return self.getToken(CelestialParser.LBRACK, i) + def RBRACK(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.RBRACK) + else: + return self.getToken(CelestialParser.RBRACK, i) + def MODIFIESA(self): + return self.getToken(CelestialParser.MODIFIESA, 0) + def RETURNS(self): + return self.getToken(CelestialParser.RETURNS, 0) + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + def PUBLIC(self): + return self.getToken(CelestialParser.PUBLIC, 0) + def PRIVATE(self): + return self.getToken(CelestialParser.PRIVATE, 0) + def rvalueList(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.RvalueListContext) + else: + return self.getTypedRuleContext(CelestialParser.RvalueListContext,i) + + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMDecl" ): + listener.enterMDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMDecl" ): + listener.exitMDecl(self) + + + + def methodDecl(self): + + localctx = CelestialParser.MethodDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 54, self.RULE_methodDecl) + self._la = 0 # Token type + try: + localctx = CelestialParser.MDeclContext(self, localctx) + self.enterOuterAlt(localctx, 1) + self.state = 450 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.RECEIVE]: + self.state = 446 + self.match(CelestialParser.RECEIVE) + pass + elif token in [CelestialParser.FALLBACK]: + self.state = 447 + self.match(CelestialParser.FALLBACK) + pass + elif token in [CelestialParser.FUNCTION]: + self.state = 448 + self.match(CelestialParser.FUNCTION) + self.state = 449 + localctx.name = self.iden() + pass + else: + raise NoViableAltException(self) + + self.state = 452 + self.match(CelestialParser.LPAREN) + self.state = 454 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32))) != 0) or _la==CelestialParser.Iden: + self.state = 453 + self.methodParamList() + + + self.state = 456 + self.match(CelestialParser.RPAREN) + self.state = 458 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.PRIVATE or _la==CelestialParser.PUBLIC: + self.state = 457 + _la = self._input.LA(1) + if not(_la==CelestialParser.PRIVATE or _la==CelestialParser.PUBLIC): + self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + + + self.state = 461 + self._errHandler.sync(self) + _la = self._input.LA(1) + if ((((_la - 28)) & ~0x3f) == 0 and ((1 << (_la - 28)) & ((1 << (CelestialParser.CONSTANT - 28)) | (1 << (CelestialParser.PURE - 28)) | (1 << (CelestialParser.VIEW - 28)))) != 0): + self.state = 460 + self.stateMutability() + + + self.state = 463 + self.spec() + self.state = 470 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.MODIFIES: + self.state = 464 + self.match(CelestialParser.MODIFIES) + self.state = 465 + self.match(CelestialParser.LBRACK) + self.state = 467 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 466 + localctx.modifies = self.rvalueList() + + + self.state = 469 + self.match(CelestialParser.RBRACK) + + + self.state = 478 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.MODIFIESA: + self.state = 472 + self.match(CelestialParser.MODIFIESA) + self.state = 473 + self.match(CelestialParser.LBRACK) + self.state = 475 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 474 + localctx.modifies_addrs = self.rvalueList() + + + self.state = 477 + self.match(CelestialParser.RBRACK) + + + self.state = 488 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.RETURNS: + self.state = 480 + self.match(CelestialParser.RETURNS) + self.state = 481 + self.match(CelestialParser.LPAREN) + self.state = 482 + self.datatype(0) + self.state = 484 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.Iden: + self.state = 483 + localctx.returnval = self.iden() + + + self.state = 486 + self.match(CelestialParser.RPAREN) + + + self.state = 490 + self.methodBody() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class MethodParamListContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def methodParam(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.MethodParamContext) + else: + return self.getTypedRuleContext(CelestialParser.MethodParamContext,i) + + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_methodParamList + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMethodParamList" ): + listener.enterMethodParamList(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMethodParamList" ): + listener.exitMethodParamList(self) + + + + + def methodParamList(self): + + localctx = CelestialParser.MethodParamListContext(self, self._ctx, self.state) + self.enterRule(localctx, 56, self.RULE_methodParamList) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 492 + self.methodParam() + self.state = 497 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 493 + self.match(CelestialParser.COMMA) + self.state = 494 + self.methodParam() + self.state = 499 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class MethodParamContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_methodParam + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMethodParam" ): + listener.enterMethodParam(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMethodParam" ): + listener.exitMethodParam(self) + + + + + def methodParam(self): + + localctx = CelestialParser.MethodParamContext(self, self._ctx, self.state) + self.enterRule(localctx, 58, self.RULE_methodParam) + try: + self.enterOuterAlt(localctx, 1) + self.state = 500 + self.datatype(0) + self.state = 501 + localctx.name = self.iden() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class MethodBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def returnStatement(self): + return self.getTypedRuleContext(CelestialParser.ReturnStatementContext,0) + + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def varDecl(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.VarDeclContext) + else: + return self.getTypedRuleContext(CelestialParser.VarDeclContext,i) + + + def statement(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.StatementContext) + else: + return self.getTypedRuleContext(CelestialParser.StatementContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_methodBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterMethodBody" ): + listener.enterMethodBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitMethodBody" ): + listener.exitMethodBody(self) + + + + + def methodBody(self): + + localctx = CelestialParser.MethodBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 60, self.RULE_methodBody) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 503 + self.match(CelestialParser.LBRACE) + self.state = 508 + self._errHandler.sync(self) + _la = self._input.LA(1) + while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.EVENT) | (1 << CelestialParser.EVENTLOG) | (1 << CelestialParser.UINT) | (1 << CelestialParser.UINT8) | (1 << CelestialParser.INSTMAP) | (1 << CelestialParser.INT) | (1 << CelestialParser.STRING) | (1 << CelestialParser.MAP) | (1 << CelestialParser.BYTES) | (1 << CelestialParser.BYTES20) | (1 << CelestialParser.BYTES32) | (1 << CelestialParser.ASSERT) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.DELETE) | (1 << CelestialParser.EMIT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FOR) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.IF) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 71)) & ~0x3f) == 0 and ((1 << (_la - 71)) & ((1 << (CelestialParser.REVERT - 71)) | (1 << (CelestialParser.SAFEADD - 71)) | (1 << (CelestialParser.SAFEDIV - 71)) | (1 << (CelestialParser.SAFEMOD - 71)) | (1 << (CelestialParser.SAFEMUL - 71)) | (1 << (CelestialParser.SAFESUB - 71)) | (1 << (CelestialParser.SEND - 71)) | (1 << (CelestialParser.SENDER - 71)) | (1 << (CelestialParser.THIS - 71)) | (1 << (CelestialParser.TXGASPRICE - 71)) | (1 << (CelestialParser.TXORIGIN - 71)) | (1 << (CelestialParser.UINT_MAX - 71)) | (1 << (CelestialParser.VALUE - 71)) | (1 << (CelestialParser.BoolLiteral - 71)) | (1 << (CelestialParser.IntLiteral - 71)) | (1 << (CelestialParser.NullLiteral - 71)) | (1 << (CelestialParser.StringLiteral - 71)) | (1 << (CelestialParser.LNOT - 71)) | (1 << (CelestialParser.SUB - 71)) | (1 << (CelestialParser.LBRACE - 71)) | (1 << (CelestialParser.LPAREN - 71)) | (1 << (CelestialParser.Iden - 71)))) != 0): + self.state = 506 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,68,self._ctx) + if la_ == 1: + self.state = 504 + self.varDecl() + pass + + elif la_ == 2: + self.state = 505 + self.statement() + pass + + + self.state = 510 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 511 + self.returnStatement() + self.state = 512 + self.match(CelestialParser.RBRACE) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ReturnStatementContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def RETURN(self): + return self.getToken(CelestialParser.RETURN, 0) + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_returnStatement + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterReturnStatement" ): + listener.enterReturnStatement(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitReturnStatement" ): + listener.exitReturnStatement(self) + + + + + def returnStatement(self): + + localctx = CelestialParser.ReturnStatementContext(self, self._ctx, self.state) + self.enterRule(localctx, 62, self.RULE_returnStatement) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 514 + self.match(CelestialParser.RETURN) + self.state = 516 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 515 + self.expr(0) + + + self.state = 518 + self.match(CelestialParser.SEMI) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class VarDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def ASSIGN(self): + return self.getToken(CelestialParser.ASSIGN, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_varDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterVarDecl" ): + listener.enterVarDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitVarDecl" ): + listener.exitVarDecl(self) + + + + + def varDecl(self): + + localctx = CelestialParser.VarDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 64, self.RULE_varDecl) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 520 + self.datatype(0) + self.state = 521 + self.iden() + self.state = 524 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.ASSIGN: + self.state = 522 + self.match(CelestialParser.ASSIGN) + self.state = 523 + self.expr(0) + + + self.state = 526 + self.match(CelestialParser.SEMI) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class UsingForDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def USING(self): + return self.getToken(CelestialParser.USING, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def FOR(self): + return self.getToken(CelestialParser.FOR, 0) + + def SEMI(self): + return self.getToken(CelestialParser.SEMI, 0) + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def MUL(self): + return self.getToken(CelestialParser.MUL, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_usingForDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterUsingForDecl" ): + listener.enterUsingForDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitUsingForDecl" ): + listener.exitUsingForDecl(self) + + + + + def usingForDecl(self): + + localctx = CelestialParser.UsingForDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 66, self.RULE_usingForDecl) + try: + self.enterOuterAlt(localctx, 1) + self.state = 528 + self.match(CelestialParser.USING) + self.state = 529 + self.iden() + self.state = 530 + self.match(CelestialParser.FOR) + self.state = 533 + self._errHandler.sync(self) + token = self._input.LA(1) + if token in [CelestialParser.ADDR, CelestialParser.BOOL, CelestialParser.EVENT, CelestialParser.EVENTLOG, CelestialParser.UINT, CelestialParser.UINT8, CelestialParser.INSTMAP, CelestialParser.INT, CelestialParser.STRING, CelestialParser.MAP, CelestialParser.BYTES, CelestialParser.BYTES20, CelestialParser.BYTES32, CelestialParser.Iden]: + self.state = 531 + self.datatype(0) + pass + elif token in [CelestialParser.MUL]: + self.state = 532 + self.match(CelestialParser.MUL) + pass + else: + raise NoViableAltException(self) + + self.state = 535 + self.match(CelestialParser.SEMI) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class LoopVarDeclContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def ASSIGN(self): + return self.getToken(CelestialParser.ASSIGN, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_loopVarDecl + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterLoopVarDecl" ): + listener.enterLoopVarDecl(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitLoopVarDecl" ): + listener.exitLoopVarDecl(self) + + + + + def loopVarDecl(self): + + localctx = CelestialParser.LoopVarDeclContext(self, self._ctx, self.state) + self.enterRule(localctx, 68, self.RULE_loopVarDecl) + try: + self.state = 546 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,73,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 537 + self.datatype(0) + self.state = 538 + self.iden() + self.state = 539 + self.match(CelestialParser.ASSIGN) + self.state = 540 + self.expr(0) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 542 + self.iden() + self.state = 543 + self.match(CelestialParser.ASSIGN) + self.state = 544 + self.expr(0) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class StatementContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.arrayName = None # LvalueContext + self.value = None # ExprContext + self.toDelete = None # LvalueContext + self.assignTo = None # LvalueContext + self.otherContractInstance = None # LvalueContext + self.method = None # IdenContext + self.assignment = None # Token + self.thenBranch = None # StatementContext + self.loopBody = None # StatementContext + self.contract = None # ExprContext + self.payload = None # ExprContext + self.to = None # ExprContext + self.amount = None # ExprContext + self.event = None # IdenContext + + def LBRACE(self): + return self.getToken(CelestialParser.LBRACE, 0) + + def RBRACE(self): + return self.getToken(CelestialParser.RBRACE, 0) + + def statement(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.StatementContext) + else: + return self.getTypedRuleContext(CelestialParser.StatementContext,i) + + + def DOT(self): + return self.getToken(CelestialParser.DOT, 0) + + def PUSH(self): + return self.getToken(CelestialParser.PUSH, 0) + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def SEMI(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.SEMI) + else: + return self.getToken(CelestialParser.SEMI, i) + + def lvalue(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.LvalueContext) + else: + return self.getTypedRuleContext(CelestialParser.LvalueContext,i) + + + def expr(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ExprContext) + else: + return self.getTypedRuleContext(CelestialParser.ExprContext,i) + + + def POP(self): + return self.getToken(CelestialParser.POP, 0) + + def DELETE(self): + return self.getToken(CelestialParser.DELETE, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def ASSERT(self): + return self.getToken(CelestialParser.ASSERT, 0) + + def StringLiteral(self): + return self.getToken(CelestialParser.StringLiteral, 0) + + def ASSIGN(self): + return self.getToken(CelestialParser.ASSIGN, 0) + + def NEW(self): + return self.getToken(CelestialParser.NEW, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def rvalueList(self): + return self.getTypedRuleContext(CelestialParser.RvalueListContext,0) + + + def CALL(self): + return self.getToken(CelestialParser.CALL, 0) + + def BOOL(self): + return self.getToken(CelestialParser.BOOL, 0) + + def CALLUINT(self): + return self.getToken(CelestialParser.CALLUINT, 0) + + def UINT(self): + return self.getToken(CelestialParser.UINT, 0) + + def CALLBOOL(self): + return self.getToken(CelestialParser.CALLBOOL, 0) + + def rvalue(self): + return self.getTypedRuleContext(CelestialParser.RvalueContext,0) + + + def IF(self): + return self.getToken(CelestialParser.IF, 0) + + def elseStatement(self): + return self.getTypedRuleContext(CelestialParser.ElseStatementContext,0) + + + def FOR(self): + return self.getToken(CelestialParser.FOR, 0) + + def loopVarDecl(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.LoopVarDeclContext) + else: + return self.getTypedRuleContext(CelestialParser.LoopVarDeclContext,i) + + + def SEND(self): + return self.getToken(CelestialParser.SEND, 0) + + def ETRANSFER(self): + return self.getToken(CelestialParser.ETRANSFER, 0) + + def TRANSFER(self): + return self.getToken(CelestialParser.TRANSFER, 0) + + def EMIT(self): + return self.getToken(CelestialParser.EMIT, 0) + + def REVERT(self): + return self.getToken(CelestialParser.REVERT, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_statement + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterStatement" ): + listener.enterStatement(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitStatement" ): + listener.exitStatement(self) + + + + + def statement(self): + + localctx = CelestialParser.StatementContext(self, self._ctx, self.state) + self.enterRule(localctx, 70, self.RULE_statement) + self._la = 0 # Token type + try: + self.state = 769 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,85,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 548 + self.match(CelestialParser.LBRACE) + self.state = 552 + self._errHandler.sync(self) + _la = self._input.LA(1) + while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BOOL) | (1 << CelestialParser.UINT) | (1 << CelestialParser.ASSERT) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.DELETE) | (1 << CelestialParser.EMIT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FOR) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.IF) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 71)) & ~0x3f) == 0 and ((1 << (_la - 71)) & ((1 << (CelestialParser.REVERT - 71)) | (1 << (CelestialParser.SAFEADD - 71)) | (1 << (CelestialParser.SAFEDIV - 71)) | (1 << (CelestialParser.SAFEMOD - 71)) | (1 << (CelestialParser.SAFEMUL - 71)) | (1 << (CelestialParser.SAFESUB - 71)) | (1 << (CelestialParser.SEND - 71)) | (1 << (CelestialParser.SENDER - 71)) | (1 << (CelestialParser.THIS - 71)) | (1 << (CelestialParser.TXGASPRICE - 71)) | (1 << (CelestialParser.TXORIGIN - 71)) | (1 << (CelestialParser.UINT_MAX - 71)) | (1 << (CelestialParser.VALUE - 71)) | (1 << (CelestialParser.BoolLiteral - 71)) | (1 << (CelestialParser.IntLiteral - 71)) | (1 << (CelestialParser.NullLiteral - 71)) | (1 << (CelestialParser.StringLiteral - 71)) | (1 << (CelestialParser.LNOT - 71)) | (1 << (CelestialParser.SUB - 71)) | (1 << (CelestialParser.LBRACE - 71)) | (1 << (CelestialParser.LPAREN - 71)) | (1 << (CelestialParser.Iden - 71)))) != 0): + self.state = 549 + self.statement() + self.state = 554 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 555 + self.match(CelestialParser.RBRACE) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 556 + localctx.arrayName = self.lvalue(0) + self.state = 557 + self.match(CelestialParser.DOT) + self.state = 558 + self.match(CelestialParser.PUSH) + self.state = 559 + self.match(CelestialParser.LPAREN) + self.state = 560 + localctx.value = self.expr(0) + self.state = 561 + self.match(CelestialParser.RPAREN) + self.state = 562 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 564 + localctx.arrayName = self.lvalue(0) + self.state = 565 + self.match(CelestialParser.DOT) + self.state = 566 + self.match(CelestialParser.POP) + self.state = 567 + self.match(CelestialParser.LPAREN) + self.state = 568 + self.match(CelestialParser.RPAREN) + self.state = 569 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 4: + self.enterOuterAlt(localctx, 4) + self.state = 571 + self.match(CelestialParser.DELETE) + self.state = 572 + self.match(CelestialParser.LPAREN) + self.state = 573 + localctx.toDelete = self.lvalue(0) + self.state = 576 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.COMMA: + self.state = 574 + self.match(CelestialParser.COMMA) + self.state = 575 + localctx.value = self.expr(0) + + + self.state = 578 + self.match(CelestialParser.RPAREN) + self.state = 579 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 5: + self.enterOuterAlt(localctx, 5) + self.state = 581 + self.match(CelestialParser.ASSERT) + self.state = 582 + self.expr(0) + self.state = 585 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.COMMA: + self.state = 583 + self.match(CelestialParser.COMMA) + self.state = 584 + self.match(CelestialParser.StringLiteral) + + + self.state = 587 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 6: + self.enterOuterAlt(localctx, 6) + self.state = 589 + localctx.assignTo = self.lvalue(0) + self.state = 590 + self.match(CelestialParser.ASSIGN) + self.state = 591 + self.match(CelestialParser.NEW) + self.state = 592 + self.iden() + self.state = 593 + self.match(CelestialParser.LPAREN) + self.state = 595 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 594 + self.rvalueList() + + + self.state = 597 + self.match(CelestialParser.RPAREN) + self.state = 598 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 7: + self.enterOuterAlt(localctx, 7) + self.state = 600 + self.expr(0) + self.state = 601 + self.match(CelestialParser.DOT) + self.state = 602 + self.match(CelestialParser.CALL) + self.state = 603 + self.match(CelestialParser.LPAREN) + self.state = 604 + self.rvalueList() + self.state = 605 + self.match(CelestialParser.RPAREN) + self.state = 606 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 8: + self.enterOuterAlt(localctx, 8) + self.state = 608 + self.match(CelestialParser.BOOL) + self.state = 609 + self.iden() + self.state = 610 + self.match(CelestialParser.ASSIGN) + self.state = 611 + self.expr(0) + self.state = 612 + self.match(CelestialParser.DOT) + self.state = 613 + self.match(CelestialParser.CALL) + self.state = 614 + self.match(CelestialParser.LPAREN) + self.state = 615 + self.rvalueList() + self.state = 616 + self.match(CelestialParser.RPAREN) + self.state = 617 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 9: + self.enterOuterAlt(localctx, 9) + self.state = 619 + self.lvalue(0) + self.state = 620 + self.match(CelestialParser.ASSIGN) + self.state = 621 + self.expr(0) + self.state = 622 + self.match(CelestialParser.DOT) + self.state = 623 + self.match(CelestialParser.CALL) + self.state = 624 + self.match(CelestialParser.LPAREN) + self.state = 625 + self.rvalueList() + self.state = 626 + self.match(CelestialParser.RPAREN) + self.state = 627 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 10: + self.enterOuterAlt(localctx, 10) + self.state = 629 + self.expr(0) + self.state = 630 + self.match(CelestialParser.DOT) + self.state = 631 + self.match(CelestialParser.CALLUINT) + self.state = 632 + self.match(CelestialParser.LPAREN) + self.state = 633 + self.rvalueList() + self.state = 634 + self.match(CelestialParser.RPAREN) + self.state = 635 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 11: + self.enterOuterAlt(localctx, 11) + self.state = 637 + self.match(CelestialParser.UINT) + self.state = 638 + self.iden() + self.state = 639 + self.match(CelestialParser.ASSIGN) + self.state = 640 + self.expr(0) + self.state = 641 + self.match(CelestialParser.DOT) + self.state = 642 + self.match(CelestialParser.CALLUINT) + self.state = 643 + self.match(CelestialParser.LPAREN) + self.state = 644 + self.rvalueList() + self.state = 645 + self.match(CelestialParser.RPAREN) + self.state = 646 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 12: + self.enterOuterAlt(localctx, 12) + self.state = 648 + self.expr(0) + self.state = 649 + self.match(CelestialParser.DOT) + self.state = 650 + self.match(CelestialParser.CALLBOOL) + self.state = 651 + self.match(CelestialParser.LPAREN) + self.state = 652 + self.rvalueList() + self.state = 653 + self.match(CelestialParser.RPAREN) + self.state = 654 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 13: + self.enterOuterAlt(localctx, 13) + self.state = 656 + self.match(CelestialParser.BOOL) + self.state = 657 + self.iden() + self.state = 658 + self.match(CelestialParser.ASSIGN) + self.state = 659 + self.expr(0) + self.state = 660 + self.match(CelestialParser.DOT) + self.state = 661 + self.match(CelestialParser.CALLBOOL) + self.state = 662 + self.match(CelestialParser.LPAREN) + self.state = 663 + self.rvalueList() + self.state = 664 + self.match(CelestialParser.RPAREN) + self.state = 665 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 14: + self.enterOuterAlt(localctx, 14) + self.state = 667 + localctx.otherContractInstance = self.lvalue(0) + self.state = 668 + self.match(CelestialParser.DOT) + self.state = 669 + localctx.method = self.iden() + self.state = 670 + self.match(CelestialParser.LPAREN) + self.state = 672 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 671 + self.rvalueList() + + + self.state = 674 + self.match(CelestialParser.RPAREN) + self.state = 675 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 15: + self.enterOuterAlt(localctx, 15) + self.state = 677 + localctx.assignTo = self.lvalue(0) + self.state = 678 + self.match(CelestialParser.ASSIGN) + self.state = 679 + localctx.otherContractInstance = self.lvalue(0) + self.state = 680 + self.match(CelestialParser.DOT) + self.state = 681 + localctx.method = self.iden() + self.state = 682 + self.match(CelestialParser.LPAREN) + self.state = 684 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 683 + self.rvalueList() + + + self.state = 686 + self.match(CelestialParser.RPAREN) + self.state = 687 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 16: + self.enterOuterAlt(localctx, 16) + self.state = 689 + localctx.assignTo = self.lvalue(0) + self.state = 690 + localctx.assignment = self.match(CelestialParser.ASSIGN) + self.state = 691 + self.rvalue() + self.state = 692 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 17: + self.enterOuterAlt(localctx, 17) + self.state = 694 + self.match(CelestialParser.IF) + self.state = 695 + self.match(CelestialParser.LPAREN) + self.state = 696 + self.expr(0) + self.state = 697 + self.match(CelestialParser.RPAREN) + self.state = 698 + localctx.thenBranch = self.statement() + self.state = 700 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,80,self._ctx) + if la_ == 1: + self.state = 699 + self.elseStatement() + + + pass + + elif la_ == 18: + self.enterOuterAlt(localctx, 18) + self.state = 702 + self.match(CelestialParser.FOR) + self.state = 703 + self.match(CelestialParser.LPAREN) + self.state = 704 + self.loopVarDecl() + self.state = 709 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 705 + self.match(CelestialParser.COMMA) + self.state = 706 + self.loopVarDecl() + self.state = 711 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 712 + self.match(CelestialParser.SEMI) + self.state = 713 + self.expr(0) + self.state = 714 + self.match(CelestialParser.SEMI) + self.state = 715 + self.expr(0) + self.state = 716 + self.match(CelestialParser.SEMI) + self.state = 717 + self.match(CelestialParser.RPAREN) + self.state = 718 + localctx.loopBody = self.statement() + pass + + elif la_ == 19: + self.enterOuterAlt(localctx, 19) + self.state = 720 + localctx.method = self.iden() + self.state = 721 + self.match(CelestialParser.LPAREN) + self.state = 723 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 722 + self.rvalueList() + + + self.state = 725 + self.match(CelestialParser.RPAREN) + self.state = 726 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 20: + self.enterOuterAlt(localctx, 20) + self.state = 728 + self.match(CelestialParser.SEND) + self.state = 729 + self.match(CelestialParser.LPAREN) + self.state = 730 + localctx.contract = self.expr(0) + self.state = 731 + self.match(CelestialParser.COMMA) + self.state = 732 + self.match(CelestialParser.ETRANSFER) + self.state = 733 + self.match(CelestialParser.COMMA) + self.state = 734 + localctx.payload = self.expr(0) + self.state = 735 + self.match(CelestialParser.RPAREN) + self.state = 736 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 21: + self.enterOuterAlt(localctx, 21) + self.state = 738 + localctx.to = self.expr(0) + self.state = 739 + self.match(CelestialParser.DOT) + self.state = 740 + self.match(CelestialParser.TRANSFER) + self.state = 741 + self.match(CelestialParser.LPAREN) + self.state = 742 + localctx.amount = self.expr(0) + self.state = 743 + self.match(CelestialParser.RPAREN) + self.state = 744 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 22: + self.enterOuterAlt(localctx, 22) + self.state = 746 + self.match(CelestialParser.EMIT) + self.state = 747 + localctx.event = self.iden() + self.state = 748 + self.match(CelestialParser.LPAREN) + self.state = 749 + localctx.payload = self.expr(0) + self.state = 754 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 750 + self.match(CelestialParser.COMMA) + self.state = 751 + localctx.payload = self.expr(0) + self.state = 756 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 757 + self.match(CelestialParser.RPAREN) + self.state = 758 + self.match(CelestialParser.SEMI) + pass + + elif la_ == 23: + self.enterOuterAlt(localctx, 23) + self.state = 760 + self.match(CelestialParser.REVERT) + self.state = 761 + self.match(CelestialParser.LPAREN) + self.state = 762 + self.match(CelestialParser.StringLiteral) + self.state = 765 + self._errHandler.sync(self) + _la = self._input.LA(1) + if _la==CelestialParser.COMMA: + self.state = 763 + self.match(CelestialParser.COMMA) + self.state = 764 + self.rvalueList() + + + self.state = 767 + self.match(CelestialParser.RPAREN) + self.state = 768 + self.match(CelestialParser.SEMI) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ElseStatementContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def ELSE(self): + return self.getToken(CelestialParser.ELSE, 0) + + def statement(self): + return self.getTypedRuleContext(CelestialParser.StatementContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_elseStatement + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterElseStatement" ): + listener.enterElseStatement(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitElseStatement" ): + listener.exitElseStatement(self) + + + + + def elseStatement(self): + + localctx = CelestialParser.ElseStatementContext(self, self._ctx, self.state) + self.enterRule(localctx, 72, self.RULE_elseStatement) + try: + self.enterOuterAlt(localctx, 1) + self.state = 771 + self.match(CelestialParser.ELSE) + self.state = 772 + self.statement() + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class LvalueContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.name = None # IdenContext + self.field = None # IdenContext + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def lvalue(self): + return self.getTypedRuleContext(CelestialParser.LvalueContext,0) + + + def DOT(self): + return self.getToken(CelestialParser.DOT, 0) + + def LBRACK(self): + return self.getToken(CelestialParser.LBRACK, 0) + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def RBRACK(self): + return self.getToken(CelestialParser.RBRACK, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_lvalue + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterLvalue" ): + listener.enterLvalue(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitLvalue" ): + listener.exitLvalue(self) + + + + def lvalue(self, _p:int=0): + _parentctx = self._ctx + _parentState = self.state + localctx = CelestialParser.LvalueContext(self, self._ctx, _parentState) + _prevctx = localctx + _startState = 74 + self.enterRecursionRule(localctx, 74, self.RULE_lvalue, _p) + try: + self.enterOuterAlt(localctx, 1) + self.state = 775 + localctx.name = self.iden() + self._ctx.stop = self._input.LT(-1) + self.state = 787 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,87,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + _prevctx = localctx + self.state = 785 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,86,self._ctx) + if la_ == 1: + localctx = CelestialParser.LvalueContext(self, _parentctx, _parentState) + self.pushNewRecursionContext(localctx, _startState, self.RULE_lvalue) + self.state = 777 + if not self.precpred(self._ctx, 2): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 2)") + self.state = 778 + self.match(CelestialParser.DOT) + self.state = 779 + localctx.field = self.iden() + pass + + elif la_ == 2: + localctx = CelestialParser.LvalueContext(self, _parentctx, _parentState) + self.pushNewRecursionContext(localctx, _startState, self.RULE_lvalue) + self.state = 780 + if not self.precpred(self._ctx, 1): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 1)") + self.state = 781 + self.match(CelestialParser.LBRACK) + self.state = 782 + self.expr(0) + self.state = 783 + self.match(CelestialParser.RBRACK) + pass + + + self.state = 789 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,87,self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + class LogcheckContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.event = None # IdenContext + self.payload = None # ExprContext + self.to = None # ExprContext + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def expr(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ExprContext) + else: + return self.getTypedRuleContext(CelestialParser.ExprContext,i) + + + def ETRANSFER(self): + return self.getToken(CelestialParser.ETRANSFER, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_logcheck + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterLogcheck" ): + listener.enterLogcheck(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitLogcheck" ): + listener.exitLogcheck(self) + + + + + def logcheck(self): + + localctx = CelestialParser.LogcheckContext(self, self._ctx, self.state) + self.enterRule(localctx, 76, self.RULE_logcheck) + self._la = 0 # Token type + try: + self.state = 811 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,89,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 790 + self.match(CelestialParser.LPAREN) + self.state = 791 + localctx.event = self.iden() + self.state = 792 + self.match(CelestialParser.COMMA) + self.state = 793 + localctx.payload = self.expr(0) + self.state = 798 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 794 + self.match(CelestialParser.COMMA) + self.state = 795 + localctx.payload = self.expr(0) + self.state = 800 + self._errHandler.sync(self) + _la = self._input.LA(1) + + self.state = 801 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 803 + self.match(CelestialParser.LPAREN) + self.state = 804 + localctx.to = self.expr(0) + self.state = 805 + self.match(CelestialParser.COMMA) + self.state = 806 + self.match(CelestialParser.ETRANSFER) + self.state = 807 + self.match(CelestialParser.COMMA) + self.state = 808 + localctx.payload = self.expr(0) + self.state = 809 + self.match(CelestialParser.RPAREN) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class ExprContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self.array = None # ExprContext + self.lhs = None # ExprContext + self.method = None # IdenContext + self.op = None # Token + self.rhs = None # ExprContext + self.contractName = None # IdenContext + self.instmap = None # IdenContext + self.condition = None # ExprContext + self.thenBranch = None # ExprContext + self.elseBranch = None # ExprContext + self.logName = None # PrimitiveContext + self.field = None # IdenContext + self.index = None # ExprContext + + def primitive(self): + return self.getTypedRuleContext(CelestialParser.PrimitiveContext,0) + + + def LPAREN(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.LPAREN) + else: + return self.getToken(CelestialParser.LPAREN, i) + + def expr(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.ExprContext) + else: + return self.getTypedRuleContext(CelestialParser.ExprContext,i) + + + def RPAREN(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.RPAREN) + else: + return self.getToken(CelestialParser.RPAREN, i) + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def DOT(self): + return self.getToken(CelestialParser.DOT, 0) + + def rvalueList(self): + return self.getTypedRuleContext(CelestialParser.RvalueListContext,0) + + + def FORALL(self): + return self.getToken(CelestialParser.FORALL, 0) + + def funParamList(self): + return self.getTypedRuleContext(CelestialParser.FunParamListContext,0) + + + def EXISTS(self): + return self.getToken(CelestialParser.EXISTS, 0) + + def SUB(self): + return self.getToken(CelestialParser.SUB, 0) + + def LNOT(self): + return self.getToken(CelestialParser.LNOT, 0) + + def SAFEMOD(self): + return self.getToken(CelestialParser.SAFEMOD, 0) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def SAFEDIV(self): + return self.getToken(CelestialParser.SAFEDIV, 0) + + def SAFEMUL(self): + return self.getToken(CelestialParser.SAFEMUL, 0) + + def SAFEADD(self): + return self.getToken(CelestialParser.SAFEADD, 0) + + def SAFESUB(self): + return self.getToken(CelestialParser.SAFESUB, 0) + + def NEW(self): + return self.getToken(CelestialParser.NEW, 0) + + def ADD(self): + return self.getToken(CelestialParser.ADD, 0) + + def ITE(self): + return self.getToken(CelestialParser.ITE, 0) + + def DEFAULT(self): + return self.getToken(CelestialParser.DEFAULT, 0) + + def datatype(self): + return self.getTypedRuleContext(CelestialParser.DatatypeContext,0) + + + def logcheck(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.LogcheckContext) + else: + return self.getTypedRuleContext(CelestialParser.LogcheckContext,i) + + + def COLON(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COLON) + else: + return self.getToken(CelestialParser.COLON, i) + + def PAYABLE(self): + return self.getToken(CelestialParser.PAYABLE, 0) + + def MUL(self): + return self.getToken(CelestialParser.MUL, 0) + + def DIV(self): + return self.getToken(CelestialParser.DIV, 0) + + def MOD(self): + return self.getToken(CelestialParser.MOD, 0) + + def PLUS(self): + return self.getToken(CelestialParser.PLUS, 0) + + def LT(self): + return self.getToken(CelestialParser.LT, 0) + + def GT(self): + return self.getToken(CelestialParser.GT, 0) + + def GE(self): + return self.getToken(CelestialParser.GE, 0) + + def LE(self): + return self.getToken(CelestialParser.LE, 0) + + def IN(self): + return self.getToken(CelestialParser.IN, 0) + + def EQ(self): + return self.getToken(CelestialParser.EQ, 0) + + def NE(self): + return self.getToken(CelestialParser.NE, 0) + + def LAND(self): + return self.getToken(CelestialParser.LAND, 0) + + def LOR(self): + return self.getToken(CelestialParser.LOR, 0) + + def IMPL(self): + return self.getToken(CelestialParser.IMPL, 0) + + def BIMPL(self): + return self.getToken(CelestialParser.BIMPL, 0) + + def LBRACK(self): + return self.getToken(CelestialParser.LBRACK, 0) + + def RBRACK(self): + return self.getToken(CelestialParser.RBRACK, 0) + + def LENGTH(self): + return self.getToken(CelestialParser.LENGTH, 0) + + def MAPUPD(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.MAPUPD) + else: + return self.getToken(CelestialParser.MAPUPD, i) + + def getRuleIndex(self): + return CelestialParser.RULE_expr + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterExpr" ): + listener.enterExpr(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitExpr" ): + listener.exitExpr(self) + + + + def expr(self, _p:int=0): + _parentctx = self._ctx + _parentState = self.state + localctx = CelestialParser.ExprContext(self, self._ctx, _parentState) + _prevctx = localctx + _startState = 78 + self.enterRecursionRule(localctx, 78, self.RULE_expr, _p) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 946 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,95,self._ctx) + if la_ == 1: + self.state = 814 + self.primitive() + pass + + elif la_ == 2: + self.state = 815 + self.match(CelestialParser.LPAREN) + self.state = 816 + self.expr(0) + self.state = 817 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 3: + self.state = 819 + self.iden() + self.state = 820 + self.match(CelestialParser.DOT) + self.state = 821 + localctx.method = self.iden() + self.state = 822 + self.match(CelestialParser.LPAREN) + self.state = 824 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 823 + self.rvalueList() + + + self.state = 826 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 4: + self.state = 828 + localctx.method = self.iden() + self.state = 829 + self.match(CelestialParser.LPAREN) + self.state = 831 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 830 + self.rvalueList() + + + self.state = 833 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 5: + self.state = 835 + self.match(CelestialParser.FORALL) + self.state = 836 + self.match(CelestialParser.LPAREN) + self.state = 837 + self.funParamList() + self.state = 838 + self.match(CelestialParser.RPAREN) + self.state = 839 + self.match(CelestialParser.LPAREN) + self.state = 840 + self.expr(0) + self.state = 841 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 6: + self.state = 843 + self.match(CelestialParser.EXISTS) + self.state = 844 + self.match(CelestialParser.LPAREN) + self.state = 845 + self.funParamList() + self.state = 846 + self.match(CelestialParser.RPAREN) + self.state = 847 + self.match(CelestialParser.LPAREN) + self.state = 848 + self.expr(0) + self.state = 849 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 7: + self.state = 851 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(_la==CelestialParser.LNOT or _la==CelestialParser.SUB): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 852 + self.expr(21) + pass + + elif la_ == 8: + self.state = 853 + self.match(CelestialParser.SAFEMOD) + self.state = 854 + self.match(CelestialParser.LPAREN) + self.state = 855 + localctx.lhs = self.expr(0) + self.state = 856 + self.match(CelestialParser.COMMA) + self.state = 857 + localctx.rhs = self.expr(0) + self.state = 858 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 9: + self.state = 860 + self.match(CelestialParser.SAFEDIV) + self.state = 861 + self.match(CelestialParser.LPAREN) + self.state = 862 + localctx.lhs = self.expr(0) + self.state = 863 + self.match(CelestialParser.COMMA) + self.state = 864 + localctx.rhs = self.expr(0) + self.state = 865 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 10: + self.state = 867 + self.match(CelestialParser.SAFEMUL) + self.state = 868 + self.match(CelestialParser.LPAREN) + self.state = 869 + localctx.lhs = self.expr(0) + self.state = 870 + self.match(CelestialParser.COMMA) + self.state = 871 + localctx.rhs = self.expr(0) + self.state = 872 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 11: + self.state = 874 + self.match(CelestialParser.SAFEADD) + self.state = 875 + self.match(CelestialParser.LPAREN) + self.state = 876 + localctx.lhs = self.expr(0) + self.state = 877 + self.match(CelestialParser.COMMA) + self.state = 878 + localctx.rhs = self.expr(0) + self.state = 879 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 12: + self.state = 881 + self.match(CelestialParser.SAFESUB) + self.state = 882 + self.match(CelestialParser.LPAREN) + self.state = 883 + localctx.lhs = self.expr(0) + self.state = 884 + self.match(CelestialParser.COMMA) + self.state = 885 + localctx.rhs = self.expr(0) + self.state = 886 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 13: + self.state = 888 + self.iden() + self.state = 889 + self.match(CelestialParser.LPAREN) + self.state = 890 + self.expr(0) + self.state = 891 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 14: + self.state = 893 + self.match(CelestialParser.NEW) + self.state = 894 + localctx.contractName = self.iden() + self.state = 895 + self.match(CelestialParser.LPAREN) + self.state = 897 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 896 + self.rvalueList() + + + self.state = 899 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 15: + self.state = 901 + localctx.instmap = self.iden() + self.state = 902 + self.match(CelestialParser.DOT) + self.state = 903 + self.match(CelestialParser.ADD) + self.state = 904 + self.match(CelestialParser.LPAREN) + self.state = 905 + self.match(CelestialParser.NEW) + self.state = 906 + localctx.contractName = self.iden() + self.state = 907 + self.match(CelestialParser.LPAREN) + self.state = 909 + self._errHandler.sync(self) + _la = self._input.LA(1) + if (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << CelestialParser.ADDR) | (1 << CelestialParser.BALANCE) | (1 << CelestialParser.BCOINBASE) | (1 << CelestialParser.BDIFF) | (1 << CelestialParser.BGASLIMIT) | (1 << CelestialParser.BNUMBER) | (1 << CelestialParser.BTIMESTAMP) | (1 << CelestialParser.DEFAULT) | (1 << CelestialParser.EXISTS) | (1 << CelestialParser.FORALL) | (1 << CelestialParser.INT_MIN) | (1 << CelestialParser.INT_MAX) | (1 << CelestialParser.ITE) | (1 << CelestialParser.LOG) | (1 << CelestialParser.NEW) | (1 << CelestialParser.PAYABLE))) != 0) or ((((_la - 73)) & ~0x3f) == 0 and ((1 << (_la - 73)) & ((1 << (CelestialParser.SAFEADD - 73)) | (1 << (CelestialParser.SAFEDIV - 73)) | (1 << (CelestialParser.SAFEMOD - 73)) | (1 << (CelestialParser.SAFEMUL - 73)) | (1 << (CelestialParser.SAFESUB - 73)) | (1 << (CelestialParser.SENDER - 73)) | (1 << (CelestialParser.THIS - 73)) | (1 << (CelestialParser.TXGASPRICE - 73)) | (1 << (CelestialParser.TXORIGIN - 73)) | (1 << (CelestialParser.UINT_MAX - 73)) | (1 << (CelestialParser.VALUE - 73)) | (1 << (CelestialParser.BoolLiteral - 73)) | (1 << (CelestialParser.IntLiteral - 73)) | (1 << (CelestialParser.NullLiteral - 73)) | (1 << (CelestialParser.StringLiteral - 73)) | (1 << (CelestialParser.LNOT - 73)) | (1 << (CelestialParser.SUB - 73)) | (1 << (CelestialParser.LPAREN - 73)) | (1 << (CelestialParser.Iden - 73)))) != 0): + self.state = 908 + self.rvalueList() + + + self.state = 911 + self.match(CelestialParser.RPAREN) + self.state = 912 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 16: + self.state = 914 + self.match(CelestialParser.ITE) + self.state = 915 + self.match(CelestialParser.LPAREN) + self.state = 916 + localctx.condition = self.expr(0) + self.state = 917 + self.match(CelestialParser.COMMA) + self.state = 918 + localctx.thenBranch = self.expr(0) + self.state = 919 + self.match(CelestialParser.COMMA) + self.state = 920 + localctx.elseBranch = self.expr(0) + self.state = 921 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 17: + self.state = 923 + self.match(CelestialParser.DEFAULT) + self.state = 924 + self.match(CelestialParser.LPAREN) + self.state = 925 + self.datatype(0) + self.state = 926 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 18: + self.state = 928 + self.logcheck() + self.state = 934 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,94,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + self.state = 929 + self.match(CelestialParser.COLON) + self.state = 930 + self.match(CelestialParser.COLON) + self.state = 931 + self.logcheck() + self.state = 936 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,94,self._ctx) + + self.state = 937 + self.match(CelestialParser.COLON) + self.state = 938 + self.match(CelestialParser.COLON) + self.state = 939 + localctx.logName = self.primitive() + pass + + elif la_ == 19: + self.state = 941 + self.match(CelestialParser.PAYABLE) + self.state = 942 + self.match(CelestialParser.LPAREN) + self.state = 943 + self.expr(0) + self.state = 944 + self.match(CelestialParser.RPAREN) + pass + + + self._ctx.stop = self._input.LT(-1) + self.state = 997 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,98,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + if self._parseListeners is not None: + self.triggerExitRuleEvent() + _prevctx = localctx + self.state = 995 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,97,self._ctx) + if la_ == 1: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 948 + if not self.precpred(self._ctx, 20): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 20)") + self.state = 949 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(((((_la - 114)) & ~0x3f) == 0 and ((1 << (_la - 114)) & ((1 << (CelestialParser.MUL - 114)) | (1 << (CelestialParser.DIV - 114)) | (1 << (CelestialParser.MOD - 114)))) != 0)): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 950 + localctx.rhs = self.expr(21) + pass + + elif la_ == 2: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 951 + if not self.precpred(self._ctx, 16): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 16)") + self.state = 952 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(_la==CelestialParser.PLUS or _la==CelestialParser.SUB): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 953 + localctx.rhs = self.expr(17) + pass + + elif la_ == 3: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 954 + if not self.precpred(self._ctx, 13): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 13)") + self.state = 955 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(((((_la - 46)) & ~0x3f) == 0 and ((1 << (_la - 46)) & ((1 << (CelestialParser.IN - 46)) | (1 << (CelestialParser.LE - 46)) | (1 << (CelestialParser.GE - 46)) | (1 << (CelestialParser.LT - 46)) | (1 << (CelestialParser.GT - 46)))) != 0)): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 956 + localctx.rhs = self.expr(14) + pass + + elif la_ == 4: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 957 + if not self.precpred(self._ctx, 12): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 12)") + self.state = 958 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(_la==CelestialParser.EQ or _la==CelestialParser.NE): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 959 + localctx.rhs = self.expr(13) + pass + + elif la_ == 5: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 960 + if not self.precpred(self._ctx, 11): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 11)") + self.state = 961 + localctx.op = self.match(CelestialParser.LAND) + self.state = 962 + localctx.rhs = self.expr(12) + pass + + elif la_ == 6: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 963 + if not self.precpred(self._ctx, 10): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 10)") + self.state = 964 + localctx.op = self.match(CelestialParser.LOR) + self.state = 965 + localctx.rhs = self.expr(11) + pass + + elif la_ == 7: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.lhs = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 966 + if not self.precpred(self._ctx, 9): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 9)") + self.state = 967 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(_la==CelestialParser.IMPL or _la==CelestialParser.BIMPL): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 968 + localctx.rhs = self.expr(10) + pass + + elif la_ == 8: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 969 + if not self.precpred(self._ctx, 27): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 27)") + self.state = 970 + self.match(CelestialParser.DOT) + self.state = 971 + localctx.field = self.iden() + pass + + elif la_ == 9: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.array = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 972 + if not self.precpred(self._ctx, 26): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 26)") + self.state = 973 + self.match(CelestialParser.LBRACK) + self.state = 974 + localctx.index = self.expr(0) + self.state = 975 + self.match(CelestialParser.RBRACK) + pass + + elif la_ == 10: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + localctx.array = _prevctx + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 977 + if not self.precpred(self._ctx, 25): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 25)") + self.state = 978 + self.match(CelestialParser.DOT) + self.state = 979 + self.match(CelestialParser.LENGTH) + self.state = 980 + self.match(CelestialParser.LPAREN) + self.state = 981 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 11: + localctx = CelestialParser.ExprContext(self, _parentctx, _parentState) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 982 + if not self.precpred(self._ctx, 8): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 8)") + self.state = 983 + self.match(CelestialParser.MAPUPD) + self.state = 984 + self.expr(0) + self.state = 992 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,96,self._ctx) + while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: + if _alt==1: + self.state = 985 + self.match(CelestialParser.COMMA) + self.state = 986 + self.expr(0) + self.state = 987 + self.match(CelestialParser.MAPUPD) + self.state = 988 + self.expr(0) + self.state = 994 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,96,self._ctx) + + pass + + + self.state = 999 + self._errHandler.sync(self) + _alt = self._interp.adaptivePredict(self._input,98,self._ctx) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.unrollRecursionContexts(_parentctx) + return localctx + + class PrimitiveContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def iden(self): + return self.getTypedRuleContext(CelestialParser.IdenContext,0) + + + def VALUE(self): + return self.getToken(CelestialParser.VALUE, 0) + + def BALANCE(self): + return self.getToken(CelestialParser.BALANCE, 0) + + def SENDER(self): + return self.getToken(CelestialParser.SENDER, 0) + + def TXGASPRICE(self): + return self.getToken(CelestialParser.TXGASPRICE, 0) + + def TXORIGIN(self): + return self.getToken(CelestialParser.TXORIGIN, 0) + + def BCOINBASE(self): + return self.getToken(CelestialParser.BCOINBASE, 0) + + def BDIFF(self): + return self.getToken(CelestialParser.BDIFF, 0) + + def BGASLIMIT(self): + return self.getToken(CelestialParser.BGASLIMIT, 0) + + def BNUMBER(self): + return self.getToken(CelestialParser.BNUMBER, 0) + + def BTIMESTAMP(self): + return self.getToken(CelestialParser.BTIMESTAMP, 0) + + def LOG(self): + return self.getToken(CelestialParser.LOG, 0) + + def INT_MIN(self): + return self.getToken(CelestialParser.INT_MIN, 0) + + def INT_MAX(self): + return self.getToken(CelestialParser.INT_MAX, 0) + + def UINT_MAX(self): + return self.getToken(CelestialParser.UINT_MAX, 0) + + def NEW(self): + return self.getToken(CelestialParser.NEW, 0) + + def LPAREN(self): + return self.getToken(CelestialParser.LPAREN, 0) + + def RPAREN(self): + return self.getToken(CelestialParser.RPAREN, 0) + + def BoolLiteral(self): + return self.getToken(CelestialParser.BoolLiteral, 0) + + def IntLiteral(self): + return self.getToken(CelestialParser.IntLiteral, 0) + + def NullLiteral(self): + return self.getToken(CelestialParser.NullLiteral, 0) + + def StringLiteral(self): + return self.getToken(CelestialParser.StringLiteral, 0) + + def THIS(self): + return self.getToken(CelestialParser.THIS, 0) + + def ADDR(self): + return self.getToken(CelestialParser.ADDR, 0) + + def getRuleIndex(self): + return CelestialParser.RULE_primitive + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterPrimitive" ): + listener.enterPrimitive(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitPrimitive" ): + listener.exitPrimitive(self) + + + + + def primitive(self): + + localctx = CelestialParser.PrimitiveContext(self, self._ctx, self.state) + self.enterRule(localctx, 80, self.RULE_primitive) + try: + self.state = 1042 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,99,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 1000 + self.iden() + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 1001 + self.match(CelestialParser.VALUE) + pass + + elif la_ == 3: + self.enterOuterAlt(localctx, 3) + self.state = 1002 + self.match(CelestialParser.BALANCE) + pass + + elif la_ == 4: + self.enterOuterAlt(localctx, 4) + self.state = 1003 + self.match(CelestialParser.SENDER) + pass + + elif la_ == 5: + self.enterOuterAlt(localctx, 5) + self.state = 1004 + self.match(CelestialParser.TXGASPRICE) + pass + + elif la_ == 6: + self.enterOuterAlt(localctx, 6) + self.state = 1005 + self.match(CelestialParser.TXORIGIN) + pass + + elif la_ == 7: + self.enterOuterAlt(localctx, 7) + self.state = 1006 + self.match(CelestialParser.BCOINBASE) + pass + + elif la_ == 8: + self.enterOuterAlt(localctx, 8) + self.state = 1007 + self.match(CelestialParser.BDIFF) + pass + + elif la_ == 9: + self.enterOuterAlt(localctx, 9) + self.state = 1008 + self.match(CelestialParser.BGASLIMIT) + pass + + elif la_ == 10: + self.enterOuterAlt(localctx, 10) + self.state = 1009 + self.match(CelestialParser.BNUMBER) + pass + + elif la_ == 11: + self.enterOuterAlt(localctx, 11) + self.state = 1010 + self.match(CelestialParser.BTIMESTAMP) + pass + + elif la_ == 12: + self.enterOuterAlt(localctx, 12) + self.state = 1011 + self.match(CelestialParser.LOG) + pass + + elif la_ == 13: + self.enterOuterAlt(localctx, 13) + self.state = 1012 + self.match(CelestialParser.INT_MIN) + pass + + elif la_ == 14: + self.enterOuterAlt(localctx, 14) + self.state = 1013 + self.match(CelestialParser.INT_MAX) + pass + + elif la_ == 15: + self.enterOuterAlt(localctx, 15) + self.state = 1014 + self.match(CelestialParser.UINT_MAX) + pass + + elif la_ == 16: + self.enterOuterAlt(localctx, 16) + self.state = 1015 + self.match(CelestialParser.NEW) + self.state = 1016 + self.match(CelestialParser.LPAREN) + self.state = 1017 + self.iden() + self.state = 1018 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 17: + self.enterOuterAlt(localctx, 17) + self.state = 1020 + self.match(CelestialParser.NEW) + self.state = 1021 + self.match(CelestialParser.LPAREN) + self.state = 1022 + self.match(CelestialParser.BALANCE) + self.state = 1023 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 18: + self.enterOuterAlt(localctx, 18) + self.state = 1024 + self.match(CelestialParser.NEW) + self.state = 1025 + self.match(CelestialParser.LPAREN) + self.state = 1026 + self.match(CelestialParser.LOG) + self.state = 1027 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 19: + self.enterOuterAlt(localctx, 19) + self.state = 1028 + self.match(CelestialParser.BoolLiteral) + pass + + elif la_ == 20: + self.enterOuterAlt(localctx, 20) + self.state = 1029 + self.match(CelestialParser.IntLiteral) + pass + + elif la_ == 21: + self.enterOuterAlt(localctx, 21) + self.state = 1030 + self.match(CelestialParser.NullLiteral) + pass + + elif la_ == 22: + self.enterOuterAlt(localctx, 22) + self.state = 1031 + self.match(CelestialParser.StringLiteral) + pass + + elif la_ == 23: + self.enterOuterAlt(localctx, 23) + self.state = 1032 + self.match(CelestialParser.THIS) + pass + + elif la_ == 24: + self.enterOuterAlt(localctx, 24) + self.state = 1033 + self.match(CelestialParser.ADDR) + self.state = 1034 + self.match(CelestialParser.LPAREN) + self.state = 1035 + self.match(CelestialParser.THIS) + self.state = 1036 + self.match(CelestialParser.RPAREN) + pass + + elif la_ == 25: + self.enterOuterAlt(localctx, 25) + self.state = 1037 + self.match(CelestialParser.ADDR) + self.state = 1038 + self.match(CelestialParser.LPAREN) + self.state = 1039 + self.iden() + self.state = 1040 + self.match(CelestialParser.RPAREN) + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class UnnamedTupleBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self._rvalue = None # RvalueContext + self.fields = list() # of RvalueContexts + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def rvalue(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.RvalueContext) + else: + return self.getTypedRuleContext(CelestialParser.RvalueContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_unnamedTupleBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterUnnamedTupleBody" ): + listener.enterUnnamedTupleBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitUnnamedTupleBody" ): + listener.exitUnnamedTupleBody(self) + + + + + def unnamedTupleBody(self): + + localctx = CelestialParser.UnnamedTupleBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 82, self.RULE_unnamedTupleBody) + self._la = 0 # Token type + try: + self.state = 1054 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,101,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 1044 + localctx._rvalue = self.rvalue() + localctx.fields.append(localctx._rvalue) + self.state = 1045 + self.match(CelestialParser.COMMA) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 1047 + localctx._rvalue = self.rvalue() + localctx.fields.append(localctx._rvalue) + self.state = 1050 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 1048 + self.match(CelestialParser.COMMA) + self.state = 1049 + localctx._rvalue = self.rvalue() + localctx.fields.append(localctx._rvalue) + self.state = 1052 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==CelestialParser.COMMA): + break + + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class NamedTupleBodyContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + self._iden = None # IdenContext + self.names = list() # of IdenContexts + self._rvalue = None # RvalueContext + self.values = list() # of RvalueContexts + + def ASSIGN(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.ASSIGN) + else: + return self.getToken(CelestialParser.ASSIGN, i) + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def iden(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.IdenContext) + else: + return self.getTypedRuleContext(CelestialParser.IdenContext,i) + + + def rvalue(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.RvalueContext) + else: + return self.getTypedRuleContext(CelestialParser.RvalueContext,i) + + + def getRuleIndex(self): + return CelestialParser.RULE_namedTupleBody + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterNamedTupleBody" ): + listener.enterNamedTupleBody(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitNamedTupleBody" ): + listener.exitNamedTupleBody(self) + + + + + def namedTupleBody(self): + + localctx = CelestialParser.NamedTupleBodyContext(self, self._ctx, self.state) + self.enterRule(localctx, 84, self.RULE_namedTupleBody) + self._la = 0 # Token type + try: + self.state = 1073 + self._errHandler.sync(self) + la_ = self._interp.adaptivePredict(self._input,103,self._ctx) + if la_ == 1: + self.enterOuterAlt(localctx, 1) + self.state = 1056 + localctx._iden = self.iden() + localctx.names.append(localctx._iden) + self.state = 1057 + self.match(CelestialParser.ASSIGN) + self.state = 1058 + localctx._rvalue = self.rvalue() + localctx.values.append(localctx._rvalue) + self.state = 1059 + self.match(CelestialParser.COMMA) + pass + + elif la_ == 2: + self.enterOuterAlt(localctx, 2) + self.state = 1061 + localctx._iden = self.iden() + localctx.names.append(localctx._iden) + self.state = 1062 + self.match(CelestialParser.ASSIGN) + self.state = 1063 + localctx._rvalue = self.rvalue() + localctx.values.append(localctx._rvalue) + self.state = 1069 + self._errHandler.sync(self) + _la = self._input.LA(1) + while True: + self.state = 1064 + self.match(CelestialParser.COMMA) + self.state = 1065 + localctx._iden = self.iden() + localctx.names.append(localctx._iden) + self.state = 1066 + self.match(CelestialParser.ASSIGN) + self.state = 1067 + localctx._rvalue = self.rvalue() + localctx.values.append(localctx._rvalue) + self.state = 1071 + self._errHandler.sync(self) + _la = self._input.LA(1) + if not (_la==CelestialParser.COMMA): + break + + pass + + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class RvalueListContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def rvalue(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(CelestialParser.RvalueContext) + else: + return self.getTypedRuleContext(CelestialParser.RvalueContext,i) + + + def COMMA(self, i:int=None): + if i is None: + return self.getTokens(CelestialParser.COMMA) + else: + return self.getToken(CelestialParser.COMMA, i) + + def getRuleIndex(self): + return CelestialParser.RULE_rvalueList + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterRvalueList" ): + listener.enterRvalueList(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitRvalueList" ): + listener.exitRvalueList(self) + + + + + def rvalueList(self): + + localctx = CelestialParser.RvalueListContext(self, self._ctx, self.state) + self.enterRule(localctx, 86, self.RULE_rvalueList) + self._la = 0 # Token type + try: + self.enterOuterAlt(localctx, 1) + self.state = 1075 + self.rvalue() + self.state = 1080 + self._errHandler.sync(self) + _la = self._input.LA(1) + while _la==CelestialParser.COMMA: + self.state = 1076 + self.match(CelestialParser.COMMA) + self.state = 1077 + self.rvalue() + self.state = 1082 + self._errHandler.sync(self) + _la = self._input.LA(1) + + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + class RvalueContext(ParserRuleContext): + + def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): + super().__init__(parent, invokingState) + self.parser = parser + + def expr(self): + return self.getTypedRuleContext(CelestialParser.ExprContext,0) + + + def getRuleIndex(self): + return CelestialParser.RULE_rvalue + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterRvalue" ): + listener.enterRvalue(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitRvalue" ): + listener.exitRvalue(self) + + + + + def rvalue(self): + + localctx = CelestialParser.RvalueContext(self, self._ctx, self.state) + self.enterRule(localctx, 88, self.RULE_rvalue) + try: + self.enterOuterAlt(localctx, 1) + self.state = 1083 + self.expr(0) + except RecognitionException as re: + localctx.exception = re + self._errHandler.reportError(self, re) + self._errHandler.recover(self, re) + finally: + self.exitRule() + return localctx + + + + def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): + if self._predicates == None: + self._predicates = dict() + self._predicates[9] = self.datatype_sempred + self._predicates[37] = self.lvalue_sempred + self._predicates[39] = self.expr_sempred + pred = self._predicates.get(ruleIndex, None) + if pred is None: + raise Exception("No predicate with index:" + str(ruleIndex)) + else: + return pred(localctx, predIndex) + + def datatype_sempred(self, localctx:DatatypeContext, predIndex:int): + if predIndex == 0: + return self.precpred(self._ctx, 15) + + + def lvalue_sempred(self, localctx:LvalueContext, predIndex:int): + if predIndex == 1: + return self.precpred(self._ctx, 2) + + + if predIndex == 2: + return self.precpred(self._ctx, 1) + + + def expr_sempred(self, localctx:ExprContext, predIndex:int): + if predIndex == 3: + return self.precpred(self._ctx, 20) + + + if predIndex == 4: + return self.precpred(self._ctx, 16) + + + if predIndex == 5: + return self.precpred(self._ctx, 13) + + + if predIndex == 6: + return self.precpred(self._ctx, 12) + + + if predIndex == 7: + return self.precpred(self._ctx, 11) + + + if predIndex == 8: + return self.precpred(self._ctx, 10) + + + if predIndex == 9: + return self.precpred(self._ctx, 9) + + + if predIndex == 10: + return self.precpred(self._ctx, 27) + + + if predIndex == 11: + return self.precpred(self._ctx, 26) + + + if predIndex == 12: + return self.precpred(self._ctx, 25) + + + if predIndex == 13: + return self.precpred(self._ctx, 8) + + + + + diff --git a/Celestial/Compiler/CelestialParser.tokens b/Celestial/Compiler/CelestialParser.tokens new file mode 100644 index 00000000..9a55d8a5 --- /dev/null +++ b/Celestial/Compiler/CelestialParser.tokens @@ -0,0 +1,256 @@ +ADDR=1 +BOOL=2 +ENUM=3 +EVENT=4 +EVENTLOG=5 +UINT=6 +UINT8=7 +INSTMAP=8 +INT=9 +STRING=10 +CONTRACT=11 +MAP=12 +BYTES=13 +BYTES20=14 +BYTES32=15 +ADD=16 +AS=17 +ASSERT=18 +BALANCE=19 +BCOINBASE=20 +BDIFF=21 +BGASLIMIT=22 +BNUMBER=23 +BTIMESTAMP=24 +CALL=25 +CALLBOOL=26 +CALLUINT=27 +CONSTANT=28 +CONSTR=29 +CONTAINS=30 +CREDIT=31 +DEBIT=32 +DEFAULT=33 +DELETE=34 +ELSE=35 +EMIT=36 +ETRANSFER=37 +EXISTS=38 +FALLBACK=39 +FOR=40 +FORALL=41 +FROM=42 +FUNCTION=43 +IF=44 +IMPORT=45 +IN=46 +INT_MIN=47 +INT_MAX=48 +ITE=49 +INVARIANT=50 +KEYS=51 +LEMMA=52 +LENGTH=53 +LOG=54 +MODIFIES=55 +MODIFIESA=56 +NEW=57 +PAYABLE=58 +POP=59 +POST=60 +PRAGMA=61 +PRE=62 +PRINT=63 +PRIVATE=64 +PUBLIC=65 +PURE=66 +PUSH=67 +RECEIVE=68 +RETURN=69 +RETURNS=70 +REVERT=71 +RREVERTS=72 +SAFEADD=73 +SAFEDIV=74 +SAFEMOD=75 +SAFEMUL=76 +SAFESUB=77 +SEND=78 +SENDER=79 +SPEC=80 +STRUCT=81 +THIS=82 +TRANSFER=83 +TXREVERTS=84 +TXGASPRICE=85 +TXORIGIN=86 +UINT_MAX=87 +USING=88 +VALUE=89 +VIEW=90 +BoolLiteral=91 +IntLiteral=92 +NullLiteral=93 +StringLiteral=94 +VersionLiteral=95 +LNOT=96 +LAND=97 +LOR=98 +MAPUPD=99 +IMPL=100 +BIMPL=101 +EQ=102 +NE=103 +LE=104 +GE=105 +LT=106 +GT=107 +RARROW=108 +ASSIGN=109 +INSERT=110 +REMOVE=111 +PLUS=112 +SUB=113 +MUL=114 +DIV=115 +MOD=116 +CARET=117 +BNOT=118 +LBRACE=119 +RBRACE=120 +LBRACK=121 +RBRACK=122 +LPAREN=123 +RPAREN=124 +SEMI=125 +COMMA=126 +DOT=127 +COLON=128 +Iden=129 +Whitespace=130 +BlockComment=131 +LineComment=132 +'address'=1 +'bool'=2 +'enum'=3 +'event'=4 +'eventlog'=5 +'uint'=6 +'uint8'=7 +'inst_map'=8 +'int'=9 +'string'=10 +'contract'=11 +'mapping'=12 +'bytes'=13 +'bytes20'=14 +'bytes32'=15 +'add'=16 +'as'=17 +'assert'=18 +'balance'=19 +'block.coinbase'=20 +'block.difficulty'=21 +'block.gaslimit'=22 +'block.number'=23 +'block.timestamp'=24 +'call'=25 +'call_bool'=26 +'call_uint'=27 +'constant'=28 +'constructor'=29 +'contains'=30 +'credit'=31 +'debit'=32 +'default'=33 +'delete'=34 +'else'=35 +'emit'=36 +'eTransfer'=37 +'exists'=38 +'fallback'=39 +'for'=40 +'forall'=41 +'from'=42 +'function'=43 +'if'=44 +'import'=45 +'in'=46 +'int_min'=47 +'int_max'=48 +'ite'=49 +'invariant'=50 +'keys'=51 +'lemma'=52 +'length'=53 +'log'=54 +'modifies'=55 +'modifies_addresses'=56 +'new'=57 +'payable'=58 +'pop'=59 +'post'=60 +'pragma'=61 +'pre'=62 +'print'=63 +'private'=64 +'public'=65 +'pure'=66 +'push'=67 +'receive'=68 +'return'=69 +'returns'=70 +'revert'=71 +'r_reverts'=72 +'safe_add'=73 +'safe_div'=74 +'safe_mod'=75 +'safe_mul'=76 +'safe_sub'=77 +'send'=78 +'sender'=79 +'spec'=80 +'struct'=81 +'this'=82 +'transfer'=83 +'tx_reverts'=84 +'tx.gasprice'=85 +'tx.origin'=86 +'uint_max'=87 +'using'=88 +'value'=89 +'view'=90 +'null'=93 +'!'=96 +'&&'=97 +'||'=98 +'=>'=99 +'==>'=100 +'<==>'=101 +'=='=102 +'!='=103 +'<='=104 +'>='=105 +'<'=106 +'>'=107 +'->'=108 +'='=109 +'+='=110 +'-='=111 +'+'=112 +'-'=113 +'*'=114 +'/'=115 +'%'=116 +'^'=117 +'~'=118 +'{'=119 +'}'=120 +'['=121 +']'=122 +'('=123 +')'=124 +';'=125 +','=126 +'.'=127 +':'=128 diff --git a/Celestial/Compiler/CelestialParserListener.py b/Celestial/Compiler/CelestialParserListener.py new file mode 100644 index 00000000..f61315b0 --- /dev/null +++ b/Celestial/Compiler/CelestialParserListener.py @@ -0,0 +1,415 @@ +# Generated from CelestialParser.g4 by ANTLR 4.7.1 +from antlr4 import * +if __name__ is not None and "." in __name__: + from .CelestialParser import CelestialParser +else: + from CelestialParser import CelestialParser + +# This class defines a complete listener for a parse tree produced by CelestialParser. +class CelestialParserListener(ParseTreeListener): + + # Enter a parse tree produced by CelestialParser#program. + def enterProgram(self, ctx:CelestialParser.ProgramContext): + pass + + # Exit a parse tree produced by CelestialParser#program. + def exitProgram(self, ctx:CelestialParser.ProgramContext): + pass + + + # Enter a parse tree produced by CelestialParser#pragmaDirective. + def enterPragmaDirective(self, ctx:CelestialParser.PragmaDirectiveContext): + pass + + # Exit a parse tree produced by CelestialParser#pragmaDirective. + def exitPragmaDirective(self, ctx:CelestialParser.PragmaDirectiveContext): + pass + + + # Enter a parse tree produced by CelestialParser#pragmaValue. + def enterPragmaValue(self, ctx:CelestialParser.PragmaValueContext): + pass + + # Exit a parse tree produced by CelestialParser#pragmaValue. + def exitPragmaValue(self, ctx:CelestialParser.PragmaValueContext): + pass + + + # Enter a parse tree produced by CelestialParser#version. + def enterVersion(self, ctx:CelestialParser.VersionContext): + pass + + # Exit a parse tree produced by CelestialParser#version. + def exitVersion(self, ctx:CelestialParser.VersionContext): + pass + + + # Enter a parse tree produced by CelestialParser#versionConstraint. + def enterVersionConstraint(self, ctx:CelestialParser.VersionConstraintContext): + pass + + # Exit a parse tree produced by CelestialParser#versionConstraint. + def exitVersionConstraint(self, ctx:CelestialParser.VersionConstraintContext): + pass + + + # Enter a parse tree produced by CelestialParser#versionOperator. + def enterVersionOperator(self, ctx:CelestialParser.VersionOperatorContext): + pass + + # Exit a parse tree produced by CelestialParser#versionOperator. + def exitVersionOperator(self, ctx:CelestialParser.VersionOperatorContext): + pass + + + # Enter a parse tree produced by CelestialParser#importDirective. + def enterImportDirective(self, ctx:CelestialParser.ImportDirectiveContext): + pass + + # Exit a parse tree produced by CelestialParser#importDirective. + def exitImportDirective(self, ctx:CelestialParser.ImportDirectiveContext): + pass + + + # Enter a parse tree produced by CelestialParser#importDeclaration. + def enterImportDeclaration(self, ctx:CelestialParser.ImportDeclarationContext): + pass + + # Exit a parse tree produced by CelestialParser#importDeclaration. + def exitImportDeclaration(self, ctx:CelestialParser.ImportDeclarationContext): + pass + + + # Enter a parse tree produced by CelestialParser#iden. + def enterIden(self, ctx:CelestialParser.IdenContext): + pass + + # Exit a parse tree produced by CelestialParser#iden. + def exitIden(self, ctx:CelestialParser.IdenContext): + pass + + + # Enter a parse tree produced by CelestialParser#datatype. + def enterDatatype(self, ctx:CelestialParser.DatatypeContext): + pass + + # Exit a parse tree produced by CelestialParser#datatype. + def exitDatatype(self, ctx:CelestialParser.DatatypeContext): + pass + + + # Enter a parse tree produced by CelestialParser#idenTypeList. + def enterIdenTypeList(self, ctx:CelestialParser.IdenTypeListContext): + pass + + # Exit a parse tree produced by CelestialParser#idenTypeList. + def exitIdenTypeList(self, ctx:CelestialParser.IdenTypeListContext): + pass + + + # Enter a parse tree produced by CelestialParser#idenType. + def enterIdenType(self, ctx:CelestialParser.IdenTypeContext): + pass + + # Exit a parse tree produced by CelestialParser#idenType. + def exitIdenType(self, ctx:CelestialParser.IdenTypeContext): + pass + + + # Enter a parse tree produced by CelestialParser#contractDecl. + def enterContractDecl(self, ctx:CelestialParser.ContractDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#contractDecl. + def exitContractDecl(self, ctx:CelestialParser.ContractDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#contractBody. + def enterContractBody(self, ctx:CelestialParser.ContractBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#contractBody. + def exitContractBody(self, ctx:CelestialParser.ContractBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#contractContents. + def enterContractContents(self, ctx:CelestialParser.ContractContentsContext): + pass + + # Exit a parse tree produced by CelestialParser#contractContents. + def exitContractContents(self, ctx:CelestialParser.ContractContentsContext): + pass + + + # Enter a parse tree produced by CelestialParser#enumDecl. + def enterEnumDecl(self, ctx:CelestialParser.EnumDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#enumDecl. + def exitEnumDecl(self, ctx:CelestialParser.EnumDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#structDecl. + def enterStructDecl(self, ctx:CelestialParser.StructDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#structDecl. + def exitStructDecl(self, ctx:CelestialParser.StructDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#FDecl. + def enterFDecl(self, ctx:CelestialParser.FDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#FDecl. + def exitFDecl(self, ctx:CelestialParser.FDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#funParamList. + def enterFunParamList(self, ctx:CelestialParser.FunParamListContext): + pass + + # Exit a parse tree produced by CelestialParser#funParamList. + def exitFunParamList(self, ctx:CelestialParser.FunParamListContext): + pass + + + # Enter a parse tree produced by CelestialParser#funParam. + def enterFunParam(self, ctx:CelestialParser.FunParamContext): + pass + + # Exit a parse tree produced by CelestialParser#funParam. + def exitFunParam(self, ctx:CelestialParser.FunParamContext): + pass + + + # Enter a parse tree produced by CelestialParser#functionBody. + def enterFunctionBody(self, ctx:CelestialParser.FunctionBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#functionBody. + def exitFunctionBody(self, ctx:CelestialParser.FunctionBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#invariantDecl. + def enterInvariantDecl(self, ctx:CelestialParser.InvariantDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#invariantDecl. + def exitInvariantDecl(self, ctx:CelestialParser.InvariantDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#invariantBody. + def enterInvariantBody(self, ctx:CelestialParser.InvariantBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#invariantBody. + def exitInvariantBody(self, ctx:CelestialParser.InvariantBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#eventDecl. + def enterEventDecl(self, ctx:CelestialParser.EventDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#eventDecl. + def exitEventDecl(self, ctx:CelestialParser.EventDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#constructorDecl. + def enterConstructorDecl(self, ctx:CelestialParser.ConstructorDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#constructorDecl. + def exitConstructorDecl(self, ctx:CelestialParser.ConstructorDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#spec. + def enterSpec(self, ctx:CelestialParser.SpecContext): + pass + + # Exit a parse tree produced by CelestialParser#spec. + def exitSpec(self, ctx:CelestialParser.SpecContext): + pass + + + # Enter a parse tree produced by CelestialParser#stateMutability. + def enterStateMutability(self, ctx:CelestialParser.StateMutabilityContext): + pass + + # Exit a parse tree produced by CelestialParser#stateMutability. + def exitStateMutability(self, ctx:CelestialParser.StateMutabilityContext): + pass + + + # Enter a parse tree produced by CelestialParser#MDecl. + def enterMDecl(self, ctx:CelestialParser.MDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#MDecl. + def exitMDecl(self, ctx:CelestialParser.MDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#methodParamList. + def enterMethodParamList(self, ctx:CelestialParser.MethodParamListContext): + pass + + # Exit a parse tree produced by CelestialParser#methodParamList. + def exitMethodParamList(self, ctx:CelestialParser.MethodParamListContext): + pass + + + # Enter a parse tree produced by CelestialParser#methodParam. + def enterMethodParam(self, ctx:CelestialParser.MethodParamContext): + pass + + # Exit a parse tree produced by CelestialParser#methodParam. + def exitMethodParam(self, ctx:CelestialParser.MethodParamContext): + pass + + + # Enter a parse tree produced by CelestialParser#methodBody. + def enterMethodBody(self, ctx:CelestialParser.MethodBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#methodBody. + def exitMethodBody(self, ctx:CelestialParser.MethodBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#returnStatement. + def enterReturnStatement(self, ctx:CelestialParser.ReturnStatementContext): + pass + + # Exit a parse tree produced by CelestialParser#returnStatement. + def exitReturnStatement(self, ctx:CelestialParser.ReturnStatementContext): + pass + + + # Enter a parse tree produced by CelestialParser#varDecl. + def enterVarDecl(self, ctx:CelestialParser.VarDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#varDecl. + def exitVarDecl(self, ctx:CelestialParser.VarDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#usingForDecl. + def enterUsingForDecl(self, ctx:CelestialParser.UsingForDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#usingForDecl. + def exitUsingForDecl(self, ctx:CelestialParser.UsingForDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#loopVarDecl. + def enterLoopVarDecl(self, ctx:CelestialParser.LoopVarDeclContext): + pass + + # Exit a parse tree produced by CelestialParser#loopVarDecl. + def exitLoopVarDecl(self, ctx:CelestialParser.LoopVarDeclContext): + pass + + + # Enter a parse tree produced by CelestialParser#statement. + def enterStatement(self, ctx:CelestialParser.StatementContext): + pass + + # Exit a parse tree produced by CelestialParser#statement. + def exitStatement(self, ctx:CelestialParser.StatementContext): + pass + + + # Enter a parse tree produced by CelestialParser#elseStatement. + def enterElseStatement(self, ctx:CelestialParser.ElseStatementContext): + pass + + # Exit a parse tree produced by CelestialParser#elseStatement. + def exitElseStatement(self, ctx:CelestialParser.ElseStatementContext): + pass + + + # Enter a parse tree produced by CelestialParser#lvalue. + def enterLvalue(self, ctx:CelestialParser.LvalueContext): + pass + + # Exit a parse tree produced by CelestialParser#lvalue. + def exitLvalue(self, ctx:CelestialParser.LvalueContext): + pass + + + # Enter a parse tree produced by CelestialParser#logcheck. + def enterLogcheck(self, ctx:CelestialParser.LogcheckContext): + pass + + # Exit a parse tree produced by CelestialParser#logcheck. + def exitLogcheck(self, ctx:CelestialParser.LogcheckContext): + pass + + + # Enter a parse tree produced by CelestialParser#expr. + def enterExpr(self, ctx:CelestialParser.ExprContext): + pass + + # Exit a parse tree produced by CelestialParser#expr. + def exitExpr(self, ctx:CelestialParser.ExprContext): + pass + + + # Enter a parse tree produced by CelestialParser#primitive. + def enterPrimitive(self, ctx:CelestialParser.PrimitiveContext): + pass + + # Exit a parse tree produced by CelestialParser#primitive. + def exitPrimitive(self, ctx:CelestialParser.PrimitiveContext): + pass + + + # Enter a parse tree produced by CelestialParser#unnamedTupleBody. + def enterUnnamedTupleBody(self, ctx:CelestialParser.UnnamedTupleBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#unnamedTupleBody. + def exitUnnamedTupleBody(self, ctx:CelestialParser.UnnamedTupleBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#namedTupleBody. + def enterNamedTupleBody(self, ctx:CelestialParser.NamedTupleBodyContext): + pass + + # Exit a parse tree produced by CelestialParser#namedTupleBody. + def exitNamedTupleBody(self, ctx:CelestialParser.NamedTupleBodyContext): + pass + + + # Enter a parse tree produced by CelestialParser#rvalueList. + def enterRvalueList(self, ctx:CelestialParser.RvalueListContext): + pass + + # Exit a parse tree produced by CelestialParser#rvalueList. + def exitRvalueList(self, ctx:CelestialParser.RvalueListContext): + pass + + + # Enter a parse tree produced by CelestialParser#rvalue. + def enterRvalue(self, ctx:CelestialParser.RvalueContext): + pass + + # Exit a parse tree produced by CelestialParser#rvalue. + def exitRvalue(self, ctx:CelestialParser.RvalueContext): + pass + + diff --git a/Celestial/Compiler/CelestialParserVisitor.py b/Celestial/Compiler/CelestialParserVisitor.py new file mode 100644 index 00000000..f18712b4 --- /dev/null +++ b/Celestial/Compiler/CelestialParserVisitor.py @@ -0,0 +1,238 @@ +# Generated from CelestialParser.g4 by ANTLR 4.7.1 +from antlr4 import * +if __name__ is not None and "." in __name__: + from .CelestialParser import CelestialParser +else: + from CelestialParser import CelestialParser + +# This class defines a complete generic visitor for a parse tree produced by CelestialParser. + +class CelestialParserVisitor(ParseTreeVisitor): + + # Visit a parse tree produced by CelestialParser#program. + def visitProgram(self, ctx:CelestialParser.ProgramContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#pragmaDirective. + def visitPragmaDirective(self, ctx:CelestialParser.PragmaDirectiveContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#pragmaValue. + def visitPragmaValue(self, ctx:CelestialParser.PragmaValueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#version. + def visitVersion(self, ctx:CelestialParser.VersionContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#versionConstraint. + def visitVersionConstraint(self, ctx:CelestialParser.VersionConstraintContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#versionOperator. + def visitVersionOperator(self, ctx:CelestialParser.VersionOperatorContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#importDirective. + def visitImportDirective(self, ctx:CelestialParser.ImportDirectiveContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#importDeclaration. + def visitImportDeclaration(self, ctx:CelestialParser.ImportDeclarationContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#iden. + def visitIden(self, ctx:CelestialParser.IdenContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#datatype. + def visitDatatype(self, ctx:CelestialParser.DatatypeContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#idenTypeList. + def visitIdenTypeList(self, ctx:CelestialParser.IdenTypeListContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#idenType. + def visitIdenType(self, ctx:CelestialParser.IdenTypeContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#contractDecl. + def visitContractDecl(self, ctx:CelestialParser.ContractDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#contractBody. + def visitContractBody(self, ctx:CelestialParser.ContractBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#contractContents. + def visitContractContents(self, ctx:CelestialParser.ContractContentsContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#enumDecl. + def visitEnumDecl(self, ctx:CelestialParser.EnumDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#structDecl. + def visitStructDecl(self, ctx:CelestialParser.StructDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#FDecl. + def visitFDecl(self, ctx:CelestialParser.FDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#funParamList. + def visitFunParamList(self, ctx:CelestialParser.FunParamListContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#funParam. + def visitFunParam(self, ctx:CelestialParser.FunParamContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#functionBody. + def visitFunctionBody(self, ctx:CelestialParser.FunctionBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#invariantDecl. + def visitInvariantDecl(self, ctx:CelestialParser.InvariantDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#invariantBody. + def visitInvariantBody(self, ctx:CelestialParser.InvariantBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#eventDecl. + def visitEventDecl(self, ctx:CelestialParser.EventDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#constructorDecl. + def visitConstructorDecl(self, ctx:CelestialParser.ConstructorDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#spec. + def visitSpec(self, ctx:CelestialParser.SpecContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#stateMutability. + def visitStateMutability(self, ctx:CelestialParser.StateMutabilityContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#MDecl. + def visitMDecl(self, ctx:CelestialParser.MDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#methodParamList. + def visitMethodParamList(self, ctx:CelestialParser.MethodParamListContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#methodParam. + def visitMethodParam(self, ctx:CelestialParser.MethodParamContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#methodBody. + def visitMethodBody(self, ctx:CelestialParser.MethodBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#returnStatement. + def visitReturnStatement(self, ctx:CelestialParser.ReturnStatementContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#varDecl. + def visitVarDecl(self, ctx:CelestialParser.VarDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#usingForDecl. + def visitUsingForDecl(self, ctx:CelestialParser.UsingForDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#loopVarDecl. + def visitLoopVarDecl(self, ctx:CelestialParser.LoopVarDeclContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#statement. + def visitStatement(self, ctx:CelestialParser.StatementContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#elseStatement. + def visitElseStatement(self, ctx:CelestialParser.ElseStatementContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#lvalue. + def visitLvalue(self, ctx:CelestialParser.LvalueContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#logcheck. + def visitLogcheck(self, ctx:CelestialParser.LogcheckContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#expr. + def visitExpr(self, ctx:CelestialParser.ExprContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#primitive. + def visitPrimitive(self, ctx:CelestialParser.PrimitiveContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#unnamedTupleBody. + def visitUnnamedTupleBody(self, ctx:CelestialParser.UnnamedTupleBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#namedTupleBody. + def visitNamedTupleBody(self, ctx:CelestialParser.NamedTupleBodyContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#rvalueList. + def visitRvalueList(self, ctx:CelestialParser.RvalueListContext): + return self.visitChildren(ctx) + + + # Visit a parse tree produced by CelestialParser#rvalue. + def visitRvalue(self, ctx:CelestialParser.RvalueContext): + return self.visitChildren(ctx) + + + +del CelestialParser \ No newline at end of file diff --git a/Celestial/Compiler/FStarCodegen.py b/Celestial/Compiler/FStarCodegen.py new file mode 100644 index 00000000..4574c8c3 --- /dev/null +++ b/Celestial/Compiler/FStarCodegen.py @@ -0,0 +1,2290 @@ +import copy +from os import makedirs +from os.path import join, dirname + +from antlr4 import * + +from CelestialLexer import CelestialLexer +from CelestialParser import CelestialParser +from CelestialParserListener import CelestialParserListener +from Symbol import Symbol + + +class FStarCodegen: + + def __init__(self, outputDir): + """ + Per contract: + ``` + fields: Dictionary of field names -> datatype objects + fields["balance"] is always = None + dict(str, DatatypeContext) + invariants: List of invariant names + list(str) + methods: Dictionary of method names -> datatype objects of return type + dict(str, DatatypeContext) + functions: Dict of function names -> funParamList object + dict(str, FunParamListContext) + events: List of event names + list(str) + enumTypes: List of enum types + list(str) + enumValues: Dict of enum value -> enum type + dict(str, str) + ``` + + Per project: + ``` + contract: List of contract names (in the order of their declaration in the Celestial source) + The current contract is always the last element in the list + list(str) + fieldsOfContract: Dict of contract names -> list of tuple of field names and datatype + The current contract is always the last element in the list of keys + dict(str, list(tuple(str, DatatypeContext))) + ``` + """ + self.output = None + self.outputDir = outputDir + self.moduleName = "" + self.fieldPrefix = "" + self.fields = {} + self.initialFieldValues = {} + self.invariants = [] # required for spec + self.methods = {} # TODO: can keep these and remove 'scope' in getFStarExpr? + self.functions = {} # should modify this to store param and return types + self.events = [] + self.structs = [] + self.enumTypes = [] + self.enumValues = {} + self.indentationLevel = 0 + self.nestedLevel = 0 + self.temp = "" + self.letBindFlag = False + self.contracts = [] + self.invariantsOfContract = {} # Dict with keys as contract names and value a list of invariants for that contract + self.fieldsOfContract = {} # Dict with keys as contract names and value a list of that contract's field names + self.methodsOfContract = {} # Dict with keys = contract names and values = dict with key as method name and value as tuple of returnvalue and list as params of that method in the contract + self.returnVarNames = {} + + def clearCompilerVariables(self): + self.fields = {} + self.initialFieldValues = {} + self.invariants = [] + self.methods = {} + self.functions = {} + self.events = [] + self.structs = [] + self.enumTypes = [] + self.enumValues = {} + self.indentationLevel = 0 + self.nestedLevel = 0 + self.temp = "" + self.letBindFlag = False + self.returnVarNames = {} + + def existsMethod(self, method): + return (method in self.methods) + + def existsFunction(self, function): + return (function in self.functions) + + def existsField(self, field): + return (field in self.fields) + + def existsInvariant(self, invariant): + return (invariant in self.invariants) + + def addPrefix(self, varName): + return self.fieldPrefix + "_" + varName + + def setModuleName(self, moduleName): + """ + Sets the module name and field prefix + """ + + self.moduleName = moduleName + self.fieldPrefix = moduleName.lower() #TODO: Change all prefixes to entirely lowercase + + def enterContract(self, contracts): + self.clearCompilerVariables() + self.fieldsOfContract[self.moduleName] = [] + filename = join(self.outputDir, self.moduleName) + ".fst" + makedirs(dirname(filename), exist_ok=True) + self.output = open(filename, "w") + self.writeToFStar("(*Code generated by compiler*)\n") + self.writeToFStar("\n") + self.writeToFStar("module " + self.moduleName + "\n") + self.writeToFStar("\n") + self.writeToFStar("open FStar.Celestial\n") + self.writeToFStar("open FStar.Celestial.Effect\n") + self.writeToFStar("module CM = FStar.Celestial.ContractsMap\n") + self.writeToFStar("open FStar.Mul\n") + for contract in contracts: + self.writeToFStar("open " + contract + "\n") + self.writeToFStar("module M = FStar.Celestial.Map\n") + self.writeToFStar("module L = FStar.List.Tot\n") + self.writeToFStar("module A = FStar.Celestial.Array\n") + self.writeToFStar("\n") + + def exitContract(self): + self.output.close() + + def isArray(self, datatypeString): + """ + Given a string representing a type, returns if it + is an array or not + """ + + if datatypeString[-2:] == "[]": + return True + return False + + def isArrayOf(self, datatypeString): + """ + Given a string of the form "type[]", returns 'type' + """ + + start = datatypeString.find("[") + return datatypeString[0:start] + + def isMapping(self, datatypeString): + """ + Given a string representing a type, returns if it + is an array or not + """ + + if datatypeString[0:7] == "mapping": + return True + return False + + def getMapKeyType(self, mappingString): + """ + Given a string of the form 'mapping(type1 => type2), + returns the type of the key of the map 'type1' + """ + + start = mappingString.find("(") + 1 + end = mappingString.find("=>") + return mappingString[start:end] + + def getMapValueType(self, mappingString): + """ + Given a string of the form 'mapping(type1 => type2), + returns the type of the value of the map 'type2' + """ + + start = mappingString.find("=>") + 2 + end = mappingString.rfind(")") + return mappingString[start:end] + + + def exprType(self, ctx:CelestialParser.ExprContext, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=False): + if (ctx.primitive()): + primitiveCtx = ctx.primitive() + if primitiveCtx.BoolLiteral(): + return "bool" + elif primitiveCtx.IntLiteral() or primitiveCtx.INT_MIN() or primitiveCtx.INT_MAX(): + return "int" + elif primitiveCtx.NullLiteral() or primitiveCtx.SENDER() or primitiveCtx.ADDR() or primitiveCtx.TXORIGIN() or primitiveCtx.BCOINBASE(): + return "address" + elif primitiveCtx.StringLiteral(): + return "string" + elif primitiveCtx.VALUE() or primitiveCtx.BALANCE() or primitiveCtx.UINT_MAX() or primitiveCtx.BDIFF() or primitiveCtx.BGASLIMIT() or primitiveCtx.BNUMBER() or primitiveCtx.BTIMESTAMP() or primitiveCtx.TXGASPRICE(): + return "uint" + elif primitiveCtx.LOG(): + return "eventlog" + elif primitiveCtx.THIS(): + return "address" # TODO: ContractType? or return scope + elif primitiveCtx.NEW(): + identifierName = primitiveCtx.iden().Iden().getText() + for symbol in symbols: + if symbol.name == identifierName and symbol.scope == "global": + return symbol.type + else: + varName = primitiveCtx.iden().Iden().getText() + for symbol in symbols: + if symbol.name == varName and (symbol.scope == scope or symbol.scope == "global"): + return symbol.type + if varName in self.enumTypes: # enum types are not stored in symbols (only their values are) + return varName + + elif (ctx.getChild(0) == ctx.LPAREN(0)): + return self.exprType(ctx.getChild(1), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + + elif (ctx.DOT() and ctx.getChildCount() == 3 and ctx.field): + lvalue = ctx.expr(0) + rvalue = ctx.field + lvalueType = self.exprType(lvalue, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if lvalueType in self.structs: + structFieldName = rvalue.Iden().getText() + for symbol in symbols: + if symbol.name == structFieldName and symbol.isStructField and symbol.fieldOfStruct == lvalueType: + return symbol.type + elif lvalueType in self.contracts: + fieldName = rvalue.Iden().getText() + for fields in self.fieldsOfContract[lvalueType]: + if fieldName == fields[0]: + return fields[1].getText() + elif lvalue.getText() in self.enumTypes: + return lvalue.getText() + + elif (ctx.array): + lvalueType = self.exprType(ctx.array, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if self.isArray(lvalueType): + if (ctx.index): + if (ctx.index.MAPUPD()): + return lvalueType + return self.isArrayOf(lvalueType) + elif (ctx.LENGTH()): + return "uint" + elif self.isMapping(lvalueType): + valueType = self.getMapValueType(lvalueType) + if ctx.index.MAPUPD(): + return lvalueType + else: + return valueType + elif lvalueType[0:8] == "inst_map": + return lvalueType[9:-1] + + elif (ctx.method and not ctx.DOT()): + methodName = ctx.method.Iden().getText() + if methodName in self.contracts: # ContractName(values_of_fields) + return methodName + + else: # Normal method/function calls + for symbol in symbols: + if methodName == symbol.name and symbol.scope == "global": + return symbol.type + + elif (ctx.SUB() and (ctx.getChildCount() == 2)): + return "int" + + elif (ctx.LNOT() and (ctx.getChildCount() == 2)): + return "bool" + + elif (ctx.PLUS() or ctx.SUB() or ctx.MUL() or ctx.DIV() or ctx.MOD() + or ctx.SAFEADD() or ctx.SAFESUB() or ctx.SAFEMUL() or ctx.SAFEDIV() or ctx.SAFEMOD()): + op1 = ctx.lhs + op2 = ctx.rhs + op1type = self.exprType(op1, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + op2type = self.exprType(op2, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if (op2.primitive() and op2.primitive().IntLiteral()): + if op1type == "int": + return "int" + elif op1type == "uint": + return "uint" + elif (op1.primitive() and op1.primitive().IntLiteral()): + if op2type == "int": + return "int" + elif op2type == "uint": + return "uint" + else: + if (op1type == op2type and op1type == "int"): + return "int" + elif (op1type == op2type and op1type == "uint"): + return "uint" + + elif (ctx.LT() or ctx.GT() or ctx.GE() or ctx.LE() or ctx.IN() + or ctx.EQ() or ctx.NE() or ctx.LAND() or ctx.LOR() or ctx.ITE() + or ctx.IMPL() or ctx.BIMPL() or ctx.FORALL() or ctx.EXISTS()): + return "bool" + + elif (ctx.MAPUPD()): + lhsType = self.exprType(ctx.expr(0), scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + rhsType = self.exprType(ctx.expr(1), scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + return "mapping(" + lhsType + "=>" + rhsType + ")" + + elif (ctx.ADD()): + return ctx.contractName.Iden().getText() + + elif (ctx.logcheck()): + return "eventlog" + + elif (ctx.PAYABLE()): + return self.exprType(ctx.expr(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + + elif (ctx.method and ctx.DOT()): + if ctx.iden(0).Iden().getText() == "abi": + if ctx.method.Iden().getText() in ["encode", "encodePacked", "encodeWithSelector", "encodeWithSignature"]: + return "bytes" + + # assumes already typechecked (for eg: does not allow map[array[int], int]) + # replace F* type names with those provided in the F* data structure library by aseem + # implement similar function replacing the return strings with what needed, to get map/ds for types in Celestial/Solidity + def getFStarDatatype(self, datatype:CelestialParser.DatatypeContext, symbols, isQuantifier=False): + if (datatype.INT()): + return "int" + elif (datatype.UINT()): + if isQuantifier: + return "uint" + else: + return "uint" + elif (datatype.ADDR()): + return "address" + elif (datatype.BOOL()): + return "bool" + elif (datatype.UINT8()): + return "uint8" + elif (datatype.BYTES()): + return "bytes" + elif (datatype.BYTES20()): + return "bytes20" + elif (datatype.BYTES32()): + return "bytes32" + elif (datatype.STRING()): + return "string" + elif (datatype.EVENTLOG()): + return "log" + elif (datatype.EVENT()): #TODO: Remove passing this as arg to functions + return "string" + # return "eventName" + elif (datatype.arrayType): + return "(a:(A.array " + self.getFStarDatatype(datatype.datatype(0), symbols, isQuantifier=isQuantifier) + "){A.def_of a == " + self.defaultValue(datatype.datatype(0).getText(), symbols) + "})" + elif (datatype.MAP()): + keyType = self.getFStarDatatype(datatype.datatype(0), symbols, isQuantifier=isQuantifier) + comparator = "lt" + if keyType == "string": + comparator = "strcmp" + return "(m:(M.t " + keyType + " " + self.getFStarDatatype(datatype.datatype(1), symbols) + " " + comparator + "){M.def_of m == " + self.defaultValue(datatype.datatype(1).getText(), symbols) + "})" + elif (datatype.INSTMAP()): + contractName = datatype.iden().Iden().getText() + prefix = str.lower(contractName) + return "(m:(M.t " + prefix + "_" + "address bool lt){M.def_of m == false /\\ ~ (M.contains m null)})" + elif (datatype.iden()): + datatypeName = datatype.iden().Iden().getText() + if (datatypeName in self.contracts): + return str.lower(datatypeName) + "_address" + else: + return self.fieldPrefix + "_" + datatype.iden().Iden().getText() + + def getFStarDatatypeS(self, datatype:str, symbols): + if (datatype == "int"): + return "int" + elif (datatype == "uint"): + return "uint" + elif (datatype == "address"): + return "address" + elif (datatype == "bool"): + return "bool" + elif (datatype == "string"): + return "string" + elif self.isMapping(datatype): + keyType = self.getMapKeyType(datatype) + valueType = self.getMapValueType(datatype) + keyType = self.getFStarDatatypeS(keyType, symbols) + valueType = self.getFStarDatatypeS(valueType, symbols) + comparator = "lt" + if keyType == "string": + comparator = "strcmp" + return "(m:(M.t " + keyType + " " + valueType + " " + comparator + "){M.def_of m == " + self.defaultValue(valueType, symbols) + "})" + elif self.isArray(datatype): + arraytype = self.isArrayOf(datatype) + return "(a:(A.array " + self.getFStarDatatypeS(arraytype, symbols) + "){A.def_of a == " + self.defaultValue(valueType, symbols) + "})" + else: # structs and enums + return self.addPrefix(datatype) + + def getFStarExpression(self, expr:CelestialParser.ExprContext, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=False): + c = expr.getChild(0) + self.indentationLevel += 1 + indentation = self.indentationLevel * " " + + if expr.primitive() and not expr.logcheck(): + self.indentationLevel -= 1 + if c.BoolLiteral() or c.IntLiteral() or c.NullLiteral() or c.StringLiteral(): + return c.getText() #TODO Check scope and return contract_field if global + elif c.THIS(): + return "self" + # return c.getText() # TODO + elif c.NEW() and c.iden(): + varName = c.iden().Iden().getText() + for symbol in symbols: + if symbol.name == varName and (symbol.type[0:8] == "inst_map" or symbol.type in self.contracts) and isFunctionCall: #for instmaps in function call, pass a tuple + return "cs1." + self.addPrefix(varName) + ", " + "bst1" + return "cs1." + self.addPrefix(varName) + elif c.NEW() and c.BALANCE(): + return "b1" + elif c.NEW() and c.LOG(): + return "l1" + elif c.BALANCE(): + if isInvariant: + return self.addPrefix("balance") + if isPre: + return "b" + if isPost: + return "b0" + if isMethod: + # return "let x1 = get_balance self in x1" + # return "get_balance self" + return "balance" + elif c.LOG(): #TODO: + if isPre: + return "l" + if isPost: + return "l0" + return "l" + # return "cs." + self.addPrefix("log") + # if isInvariant: + # return "cs." + self.fieldPrefix + "_log" + # elif isMethod: + # return "let x1 = get_" + self.fieldPrefix + "_log () in x1" + elif c.SENDER() or c.TXORIGIN() or c.TXGASPRICE() or c.VALUE() or c.INT_MIN() or c.INT_MAX() or c.UINT_MAX(): + return c.getText() + elif c.BCOINBASE() or c.BDIFF() or c.BGASLIMIT() or c.BNUMBER() or c.BTIMESTAMP(): + return c.getText() + elif c.ADDR(): + idenName = c.iden().Iden().getText() + if idenName in self.fields: + if isInvariant: + return "cs." + self.addPrefix(idenName) + elif isMethod or isPre: + return "cs." + self.addPrefix(idenName) + elif isPost: + return "cs0." + self.addPrefix(idenName) + else: + return idenName + else: + varName = c.iden().Iden().getText() + if varName in self.fields: # TODO: if function arg has same name as field, then prob. Soln: put the elif branch above this + if isInvariant: + return "cs." + self.addPrefix(varName) + elif isPre: + # return "let x1 = " + self.addPrefix("get_" + varName) + " self in x1" + # return self.addPrefix("get_" + varName) + " self" + for symbol in symbols: + if symbol.name == varName and (symbol.type[0:8] == "inst_map" or symbol.type in self.contracts) and isFunctionCall: + return "cs." + self.addPrefix(varName) + ", " + "bst" + return "cs." + self.addPrefix(varName) + elif isMethod: + return "cs." + self.addPrefix(varName) + elif isPost: + for symbol in symbols: + if symbol.name == varName and (symbol.type[0:8] == "inst_map" or symbol.type in self.contracts) and isFunctionCall: + return "cs0." + self.addPrefix(varName) + ", " + "bst0" + return "cs0." + self.addPrefix(varName) + elif varName in list(self.enumValues.keys()): + return varName[:1].upper() + varName[1:] + else: + for sym in symbols: + if sym.name == varName: + if sym.type in self.contracts and not isMethod: #If it is a contract instance, retrieve it from the tupled bst + self.temp = sym.type # storing the type of contract in temp to retrieve its field prefix (when accessing its field in spec) + return "CM.sel (fst " + varName + ") (snd " + varName + ").cmap" + elif not isMethod and sym.type[0:8] == "inst_map": + return "fst " + varName + # if sym.type == "bool" and not isMethod: #Remove temporarily + # return "(b2t " + varName + ")" + break + + return varName + + elif (c == expr.LPAREN(0)): + self.indentationLevel -= 1 + return "(" + self.getFStarExpression(expr.getChild(1), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ")" + + elif expr.method and not expr.DOT(): + methodName = expr.method.Iden().getText() + + if methodName in self.contracts: # ContractName(values_for_fields) + contractFields = self.fieldsOfContract[methodName] + prefix = str.lower(methodName) + "_" + paramExprs = "" + if expr.rvalueList(): + i = 0 + paramExprs = "{" + for param in expr.rvalueList().rvalue(): + paramExpr = self.getFStarExpression(param.expr(), symbols, scope, isInvariant=isInvariant, isMethod=False, isFunctionCall=isFunctionCall, isIf=False, isPre=False, isPost=False) + paramExprs += " " + prefix + contractFields[i][0] + " = (" + paramExpr + ");" + i += 1 + # paramExprs += " " + prefix + "balance = 0;" + paramExprs += "}" + else: + paramExprs = self.defaultValue(methodName, symbols) + return paramExprs + else: # Normal method/function call + isMethodCalled = False + isFunction = False + isStruct = False + for sym in symbols: + if sym.name == methodName and sym.scope == "global": + if sym.isMethod: + isMethodCalled = True + break + elif sym.isFunction: + isFunction = True + break + elif sym.isStructType: + isStruct = True + break + FStarExprString = "" + x = 1 + i = 0 + xarr = {} + structFieldNames = [] + if isStruct: + for sym in symbols: + if sym.fieldOfStruct == methodName: + structFieldNames.append(sym.name) + + # If the method/function call has arguments: + if expr.rvalueList(): + for arg in expr.rvalueList().rvalue(): + argString = self.getFStarExpression(arg.expr(), symbols, scope, isInvariant, isMethod, True, isIf, isPre, isPost) + if " " in argString: + argString = "(" + argString + ")" + + # let-bind the argument in case it has further let-bindings + if isMethod and "=" in argString: + FStarExprString += "\nlet x" + str(x) + " = " + argString + " in" + argString = "x" + str(x) + xarr[x] = argString + x = x + 1 + i = i + 1 + + # Wrap the callee/struct in paranthesis/braces + if isMethodCalled or isFunction: + if methodName in ["sum_mapping", "keccak256", "sha256", "ripemd160", "ecrecover"]: + FStarExprString += "(" + methodName + else: + FStarExprString += "(" + methodName #TODO: Have prefixes for method names in addition to fields + elif isStruct: + FStarExprString += "{" + + # If it is a function, sender and value are not passed + if isMethodCalled and methodName not in ["keccak256", "sha256", "ripemd160", "ecrecover"]: + FStarExprString += " self self 0 tx block" + + # Generate the final call/record string + for i in range (1, x): + if isMethodCalled or isFunction: + FStarExprString += " " + xarr[i] + elif isStruct: + FStarExprString += " " + self.addPrefix(structFieldNames[i-1]) + " = " + xarr[i] + ";" + + self.indentationLevel -= 1 + if isMethodCalled or isFunction: + return FStarExprString + ")" + else: + return FStarExprString + " }" + + elif expr.method and expr.DOT(): + methodName = expr.iden(0).getText() + "_" + expr.method.getText() + xarr = {} + FStarExprString = "" + x = 1 + i = 0 + if expr.rvalueList(): + for arg in expr.rvalueList().rvalue(): + argString = self.getFStarExpression(arg.expr(), symbols, scope, isInvariant, isMethod, True, isIf, isPre, isPost) + if " " in argString: + argString = "(" + argString + ")" + + # let-bind the argument in case it has further let-bindings + if isMethod and "=" in argString: + FStarExprString += "\nlet x" + str(x) + " = " + argString + " in" + argString = "x" + str(x) + xarr[x] = argString + x = x + 1 + i = i + 1 + + # Wrap the callee/struct in paranthesis/braces + FStarExprString += "(" + methodName + + argString = xarr[1] + + # Generate the final call/record string + for i in range (2, x): + argString += ", " + xarr[i] + + self.indentationLevel -= 1 + return FStarExprString + "(" + argString + "))" + + elif (expr.SUB() and (expr.getChildCount() == 2)): + self.indentationLevel -= 1 + # return "\nlet x1 = (-1) * (" + self.getFStarExpression(expr.expr(0), symbols, scope, isInvariant, isMethod) + " ) in x1" + #TODO: x1 if = + exprString = self.getFStarExpression(expr.expr(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in exprString: + return "(-1) * (" + exprString + ")" + else: + return "(-1) * " + exprString + + elif (expr.LNOT()): + op = expr.getChild(1) + self.indentationLevel -= 1 + if isMethod: + # return "\nlet x1 = (" + self.getFStarExpression(op, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ") in op_Negation x1" + return "op_Negation (" + self.getFStarExpression(op, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ")" + else: + return "~ (" + self.getFStarExpression(op, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ")" + # return "\nlet x1 = (" + self.getFStarExpression(op, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ") in ~ x1" + + elif (expr.array): + s = "" + if expr.index: + if expr.index.MAPUPD(): + updates = len(expr.index.MAPUPD()) + s = "\n" + indentation + "let x1 = (" + self.getFStarExpression(expr.getChild(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ") in" + for i in range(updates): + s += "\n" + indentation + "let x2 = (" + self.getFStarExpression(expr.index.expr(2*i), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ") in" + s += "\n" + indentation + "let x3 = (" + self.getFStarExpression(expr.index.expr(2*i + 1), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ") in" + baseExprType = self.exprType(expr.getChild(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if self.isMapping(baseExprType) or baseExprType[0:8] == "inst_map": + s += "\n" + indentation + "let x1 = (M.upd x1 x2 x3) in" + elif self.isArray(baseExprType): + s += "\n" + indentation + "let x1 = (A.update x1 x2 x3) in" + s += "\n" + indentation + "x1" + # self.temp = "map" + # s += "\n" + indentation + "let x2 = (" + self.getFStarExpression(expr.index.expr(0), symbols, scope, isInvariant, isMethod) + ") in" + # s += "\n" + indentation + "let x3 = (" + self.getFStarExpression(expr.index.expr(1), symbols, scope, isInvariant, isMethod) + ") in" + # s += "\n" + indentation + "M.upd x1 x2 x3" + else: + s = "" + c = expr.expr(0) + arrayOrMapAccessed = expr.getChild(0) + indexOrKey = expr.getChild(2) + arrayOrMapAccessedFStarExpression = self.getFStarExpression(expr.getChild(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + indexOrKeyFStarExpression = self.getFStarExpression(expr.getChild(2), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + + arrayOrMapAccessed = arrayOrMapAccessedFStarExpression + # if arrayOrMapAccessed.primitive() and arrayOrMapAccessed.getText() not in self.fields: + # arrayOrMapAccessed = arrayOrMapAccessed.getText() + # elif arrayOrMapAccessed.primitive() and arrayOrMapAccessed.getText() in self.fields: + # arrayOrMapAccessed = "(" + arrayOrMapAccessedFStarExpression + ")" + # else: + + # if isMethod: + # s = "\n" + indentation + "let x1 = (" + arrayOrMapAccessedFStarExpression + ") in" + # arrayOrMapAccessed = "x1" + + if indexOrKey.primitive() and indexOrKey.getText() not in self.fields and "=" not in indexOrKey.getText(): #TODO: Check this + indexOrKey = indexOrKey.getText() + else: + # s += "\n" + indentation + "let x2 = (" + indexOrKeyFStarExpression + ") in" + # indexOrKey = "x2" + indexOrKey = indexOrKeyFStarExpression + + isMap = False + isInstMap = False + isArray = False + varName = "" + if c.primitive() and c.primitive().iden(): + varName = c.primitive().iden().Iden().getText() + else: + end = expr.getChild(0).getText().find("[") + varName = expr.getChild(0).getText()[0:end] + # Remove 'new()' to get the name of the variable + if varName[0:4] == "new(": + varName = varName[4:-1] + + for sym in symbols: + if sym.name == varName and sym.scope in [scope, "global"]: + if sym.isMap == True: + isMap = True + elif sym.type[0:8] == "inst_map": + isInstMap = True + elif self.isArray(sym.type): + isArray = True + break + + # Wrapping the map/array and key/index in paranthesis if they contain spaces + if " " in arrayOrMapAccessed: + arrayOrMapAccessed = "(" + arrayOrMapAccessed + ")" + if " " in indexOrKey: + indexOrKey = "(" + indexOrKey + ")" + + if isMap: + if arrayOrMapAccessed[0] != "x" and indexOrKey[0] != "x": + s += "M.sel " + arrayOrMapAccessed + " " + indexOrKey + else: + s += "\n" + indentation + "M.sel " + arrayOrMapAccessed + " " + indexOrKey + elif isArray: + if arrayOrMapAccessed[0] != "x" and indexOrKey[0] != "x": + s += "A.select " + arrayOrMapAccessed + " " + indexOrKey + else: + s += "\n" + indentation + "A.select " + arrayOrMapAccessed + " " + indexOrKey + elif isInstMap: + if isMethod: + s += "\nif M.contains " + arrayOrMapAccessed + " " + indexOrKey + " then " + indexOrKey + " else null" + else: # Inst_Map access inside spec (should return instance from the tupled bst) + for symbol in symbols: + if symbol.name == expr.getChild(0).getText(): + self.temp = symbol.type[9:-1] + break + arrayOrMapAccessedWithoutfst = expr.getChild(0).getText()#arrayOrMapAccessed[4:-1] + s += "CM.sel " + indexOrKey + " (snd " + arrayOrMapAccessedWithoutfst + ").cmap" + + elif expr.LENGTH(): + arrayExpr = self.getFStarExpression(expr.array, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in arrayExpr: + arrayExpr = "(" + arrayExpr + ")" + s = "A.length " + arrayExpr + self.indentationLevel -= 1 + return s + + elif (expr.ITE()): + condition = expr.condition + thenBranch = expr.thenBranch + elseBranch = expr.elseBranch + + FStarCondition = self.getFStarExpression(condition, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf=True, isPre=isPre, isPost=isPost) + FStarThen = self.getFStarExpression(thenBranch, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + FStarElse = self.getFStarExpression(elseBranch, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + FStarExprString = "if (" + FStarCondition + ") then\n" + FStarExprString += " (" + FStarThen + ")\n" + FStarExprString += "else\n" + FStarExprString += " (" + FStarElse + ")\n" + + self.indentationLevel -= 1 + return FStarExprString + + # TODO: DOT (eg: struct.field) + elif (expr.DOT() and expr.getChildCount() == 3): + lexpr = expr.expr(0) + lvalueType = self.exprType(lexpr, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + rvalName = expr.field.Iden().getText() + if lvalueType in self.structs: + lvalueFStarExpression = self.getFStarExpression(lexpr, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in lvalueFStarExpression: + lvalueFStarExpression = "(" + lvalueFStarExpression + ")" + return lvalueFStarExpression + "." + self.addPrefix(rvalName) + elif lvalueType in self.enumTypes: # same as lexpr.getText() in self.enumTypes + return rvalName[:1].upper() + rvalName[1:] + elif lvalueType in self.contracts: + rvalName = str.lower(lvalueType) + "_" + rvalName + lvalueFStarExpression = self.getFStarExpression(lexpr, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in lvalueFStarExpression: + lvalueFStarExpression = "(" + lvalueFStarExpression + ")" + return lvalueFStarExpression + "." + rvalName + + elif (expr.PLUS() or expr.SUB() or expr.MUL() or expr.DIV() or expr.MOD() + or expr.LT() or expr.GT() or expr.GE() or expr.LE() or expr.EQ() or expr.NE() + or expr.LAND() or expr.LOR() + or expr.SAFEDIV() or expr.SAFEMUL() or expr.SAFEADD() or expr.SAFESUB()): + self.temp = "" + s = "" + # isMethod = False + # for sym in symbols: + # if sym.name == scope: + # if sym.isMethod: + # isMethod = True + # break + + op1 = expr.lhs + op2 = expr.rhs + op1Expr = self.getFStarExpression(op1, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + op2Expr = self.getFStarExpression(op2, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + # if op1.primitive() and op1.getText() not in self.fields and op1.getText() != "balance": + # op1 = op1.getText() + ## if isMethod and ((op1.primitive() and op1.getText() in self.fields) or "=" in op1Expr): + ## s += "\n" + indentation + "let x1 = (" + op1Expr + ") in" + ## op1 = "x1" + ## else: + op1 = op1Expr + # elif (not op1.primitive() and "let" not in op1Expr) and not op1.method:# or (not isMethod and not isInvariant): #self.letBindFlag: + # op1 = op1Expr # op1.method check because can't use method calls directly in expressions just like fields (Con effect error) + # else: + # s = "\n" + indentation + "let x1 = (" + op1Expr + ") in" + # op1 = "x1" + + # if op2.primitive() and op2.getText() not in self.fields and op2.getText() != "balance": + # op2 = op2.getText() + ## if isMethod and ((op2.primitive() and op2.getText() in self.fields) or "=" in op2Expr): + ## s += "\n" + indentation + "let x2 = (" + op2Expr + ") in" + ## op2 = "x2" + ## else: + op2 = op2Expr + # else: + # op2 = op2Expr + # elif (not op2.primitive() and "let" not in op2Expr) and not op2.method:# or (not isMethod and not isInvariant): #self.letBindFlag: + # op2 = op2Expr # op2.method check because can't use method calls directly in expressions just like fields (Con effect error) + # else: + # s += "\n" + indentation + "let x2 = (" + op2Expr + ") in" + # op2 = "x2" + + if " " in op1: + op1 = "(" + op1 + ")" + if " " in op2: + op2 = "(" + op2 + ")" + + if op1[0] == "x" or op2[0] == "x": + s += "\n" + indentation + # self.letBindFlag = True + + if expr.PLUS(): + if not isMethod: + s += op1 + " + " + op2 + else: + # s += "(add_modula_lemma (" + op1 + ") (" + op2 + ");\n" + # s += "(" + op1 + " + " + op2 + ") % (uint_max + 1)" + s += "(_add " + op1 + " " + op2 + ")" + elif expr.SUB(): + if not isMethod: + s += op1 + " - " + op2 + else: + # s += "(assert ((" + op1 + " - " + op2 + ") == (_sub " + op1 + " " + op2 + ")); " + s += "(_sub " + op1 + " " + op2 + ")" + elif expr.MUL(): + if not isMethod: + s += op1 + " * " + op2 + else: + # s += "(multiply_modula_lemma (" + op1 + ") (" + op2 + ");\n" + s += "(_mul " + op1 + " " + op2 + ")" + elif expr.DIV(): + if isMethod: + # s += "division_modulo_lemma " + op1 + " " + op2 + "; \n" + s += "(_div " + op1 + " " + op2 + ")" + else: + s += op1 + " / " + op2 + elif expr.SAFEADD(): + # s += "(safe_add " + op1 + " " + op2 + ")" + s += "(if " + op1 + " <= uint_max - " + op2 + " then (" + op1 + " + " + op2 + ") else revert \"Overflow error\")" + elif expr.SAFESUB(): + # s += "(safe_sub " + op2 + " " + op1 + ")" + s += "(if " + op2 + " <= " + op1 + " then (" + op1 + " - " + op2 + ") else revert \"Underflow error\")" + elif expr.SAFEMUL(): + # s += "\nlet c = (" + op1 + " * " + op2 + ") in" + # s += "(if c /" + op1 + " = " + op2 + " then (" + op1 + " * " + op2 + ") else revert \"Overflow error\")" + s += "(safe_mul " + op1 + " " + op2 + ")" + elif expr.SAFEDIV(): + s += "(if " + op2 + " <> 0 then (" + op1 + " / " + op2 + ") else revert \"Division by 0 error\")" + elif expr.SAFEMOD(): + s += "(if " + op2 + " <> 0 then (" + op1 + " % " + op2 + ") else revert \"Division by 0 error\")" + elif expr.MOD(): + s += op1 + " % " + op2 + elif expr.LT(): + s += op1 + " < " + op2 + elif expr.GT(): + s += op1 + " > " + op2 + elif expr.GE(): + s += op1 + " >= " + op2 + elif expr.LE(): + s += op1 + " <= " + op2 + elif expr.EQ(): + if not isMethod and not isIf: + # if self.temp == "map": + lhsType = self.exprType(expr.lhs, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) # same as rhsType + if self.isMapping(lhsType) or lhsType[0:8] == "inst_map": + s += "M.equal " + op1 + " " + op2 + else: + s += op1 + " == " + op2 + else: + s += op1 + " = " + op2 + elif expr.NE(): + if isMethod or isIf: + s += op1 + " <> " + op2 + else: + s += op1 + " =!= " + op2 + elif expr.LAND(): + if not isMethod and not isIf: + s += op1 + " /\\ " + op2 + else: + s += op1 + " && " + op2 + elif expr.LOR(): + if not isMethod and not isIf: + s += op1 + " \\/ " + op2 + else: + s += op1 + " || " + op2 + + self.indentationLevel -= 1 + return s + + elif (expr.IMPL() or expr.BIMPL()): + op1 = expr.getChild(0) + op2 = expr.getChild(2) + op1Expr = self.getFStarExpression(op1, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + op2Expr = self.getFStarExpression(op2, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + # s = "\n" + indentation + "let x1 = (" + op1Expr + ") in" + # s += "\n" + indentation + "let x2 = (" + op2Expr + ") in" + if expr.IMPL(): + s = "(" + op1Expr + " ==> " + op2Expr + ")" + else: + s = "(" + op1Expr + " <==> " + op2Expr + ")" + self.indentationLevel -= 1 + return s + + elif (expr.FORALL() or expr.EXISTS()): + syms = copy.deepcopy(symbols) + for funParam in expr.funParamList().funParam(): + paramName = funParam.name.Iden().getText() + paramType = funParam.datatype().getText() + syms.append(Symbol(_name=paramName, _type=paramType, _scope=scope, _isQuantifierVar=True)) + + s = "(" + expr.getChild(0).getText() + for var in expr.funParamList().funParam(): + # if isInvariant: + # varName = "cs." + var.name.Iden().getText() + # else: + varName = var.name.Iden().getText() + s += " (" + varName + ":" + self.getFStarDatatype(var.datatype(), symbols, isQuantifier=True) + ")" + s += ". (" + s += self.getFStarExpression(expr.expr(0), syms, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + "))\n" + return s + + elif (expr.NEW() and expr.getChildCount() == 5): #TODO + contractTypeName = expr.contractName.Iden().getText() + FStarExprString = "(" + x = 1 + xarr = {} + + if expr.rvalueList(): + for arg in expr.rvalueList().rvalue(): + paramExpr = self.getFStarExpression(arg.expr(), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if (arg.expr().primitive() and arg.expr().getText() in self.fields) or "=" in paramExpr: # same as if "=" in paramExpr + FStarExprString += "\n" + indentation + "let x" + str(x) + " = (" + paramExpr + ") in" + paramExpr = "x" + str(x) + xarr[x] = paramExpr + x = x + 1 + if self.fieldsOfContract[contractTypeName]: + newContractRecordString = "({" + for fields in self.fieldsOfContract[contractTypeName]: + newContractRecordString += str.lower(contractTypeName)+ "_" + fields[0] + " = " + self.defaultValue(fields[1].getText(), symbols) + "; " + newContractRecordString += "})" + else: + newContractRecordString = "()" + s = "" + s += "let contract_addr = create_contract " + newContractRecordString + " in " + if "constructor" in self.methodsOfContract[contractTypeName].keys(): + s += "(" + str.lower(contractTypeName) + "_constructor self 0 tx block" + for i in range (1, x): + FStarExprString += " " + xarr[i] + s += "; " + # return "(" + str.lower(contractTypeName) + "_constructor self 0)" + s += "contract_addr" + return s + + elif (expr.IN()): + op1 = self.getFStarExpression(expr.expr(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + op2 = self.getFStarExpression(expr.expr(1), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in op1: + op1 = "(" + op1 + ")" + if " " in op2: + op2 = "(" + op2 + ")" + return "(M.contains " + op2 + " " + op1 + ")" + + elif (expr.DEFAULT()): + return self.defaultValue(expr.datatype().getText(), symbols) + + elif (expr.ADD()): + newContractOf = expr.contractName.Iden().getText() + instmapName = expr.instmap.Iden().getText() + FStarExprString = "(" + x = 1 + xarr = {} + + if expr.rvalueList(): + for arg in expr.rvalueList().rvalue(): + paramExpr = self.getFStarExpression(arg.expr(), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if (arg.expr().primitive() and arg.expr().getText() in self.fields) or "=" in paramExpr: # same as if "=" in paramExpr + FStarExprString += "\n" + indentation + "let x" + str(x) + " = (" + paramExpr + ") in" + paramExpr = "x" + str(x) + xarr[x] = paramExpr + x = x + 1 + if self.fieldsOfContract[newContractOf]: + newContractRecordString = "({" + for fields in self.fieldsOfContract[newContractOf]: + newContractRecordString += str.lower(newContractOf)+ "_" + fields[0] + " = " + self.defaultValue(fields[1].getText(), symbols) + "; " + newContractRecordString += "})" + else: + newContractRecordString = "()" + FStarExprString += "\nlet contract_addr = create_contract " + newContractRecordString + " in " + if "constructor" in self.methodsOfContract[newContractOf].keys(): + # FStarExprString += "\nassume (sender <> contract_addr); // NEWLY CREATED CONTRACT CANNOT HAVE THE SAME ADDRESS AS THE SENDER" + FStarExprString += "\nlet _ = " + str.lower(newContractOf) + "_constructor contract_addr self 0 tx block" + for i in range (1, x): + FStarExprString += " " + xarr[i] + self.indentationLevel -= 1 + FStarExprString += " in" + FStarExprString += "\nlet _ = " + self.addPrefix("set_" + instmapName) + " self (M.upd cs." + self.addPrefix(instmapName) + " contract_addr true) in contract_addr)" + # self.writeToFStar("\n" + indentation + "let cs = get_contract self in") + + return FStarExprString + + elif (expr.logcheck()): + s = "" + for logTuple in expr.logcheck(): + # If the log tuple is from an emit + if logTuple.event: + eventName = self.addPrefix(logTuple.event.Iden().getText()) + payloadStr = "" + for payloadExpr in logTuple.expr(): + payloadStr += self.getFStarExpression(payloadExpr, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if payloadExpr != logTuple.expr()[-1]: + payloadStr += ", " + + if " " in payloadStr: + payloadStr = "(" + payloadStr + ")" + s += "(mk_event null " + eventName + " " + payloadStr + ")::" + + elif logTuple.ETRANSFER(): + receiverExprStr = self.getFStarExpression(logTuple.to, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + amountExprStr = self.getFStarExpression(logTuple.payload, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + if " " in receiverExprStr: + receiverExprStr = "(" + receiverExprStr + ")" + if " " in amountExprStr: + amountExprStr = "(" + amountExprStr + ")" + s += "(mk_event " + receiverExprStr + " eTransfer " + amountExprStr + ")::" + + # logName = self.getFStarExpression(expr.logName, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + logName = "" + if expr.logName.NEW() and expr.logName.LOG(): + logName = "l1" + elif expr.logName.iden(): + logName = expr.logName.getText() + elif expr.logName.LOG() and isPre: + logName = "l" + elif expr.logName.LOG() and isPost: + logName = "l0" + + # oldLogStr = expr.logName.Iden().getText() #self.getFStarExpression(expr.logName, symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + s += logName + + return s + + elif (expr.PAYABLE()): + self.indentationLevel -= 1 + return "(" + self.getFStarExpression(expr.expr(0), symbols, scope, isInvariant, isMethod, isFunctionCall, isIf, isPre, isPost) + ")" + + def getFStarExpressionLvalue(self, lvalue:CelestialParser.LvalueContext, symbols, scope): + if lvalue.name: + self.indentationLevel += 1 + varName = lvalue.iden().Iden().getText() + if varName in self.fields: + self.indentationLevel -= 1 + return "cs." + self.addPrefix(varName) + # return "let x1 = " + self.addPrefix("get_" + varName) + " self in x1" + # return "let x1 = get_" + self.fieldPrefix + "_" + varName + " () in x1" + else: + self.indentationLevel -= 1 + return varName + + elif lvalue.LBRACK(): + c = lvalue.lvalue() + selectingFromExpr = self.getFStarExpressionLvalue(lvalue.getChild(0), symbols, scope) + selectingIndexExpr = self.getFStarExpression(lvalue.getChild(2), symbols, scope) + # s = "\n" + indentation + "let x1 = (" + self.getFStarExpressionLvalue(lvalue.getChild(0), symbols, scope) + ") in" + # s += "\n" + indentation + "let x2 = (" + self.getFStarExpression(lvalue.getChild(2), symbols, scope) + ") in" + isMap = False + isArray = False + isInstMap = False + varName = "" + if c.name: + varName = c.iden().Iden().getText() + else: + end = lvalue.getChild(0).getText().find("[") + varName = lvalue.getChild(0).getText()[0:end] + for sym in symbols: + if sym.name == varName and sym.scope in [scope, "global"]: + if sym.isMap: + isMap = True + elif self.isArray(sym.type): + isArray = True + elif sym.type[0:8] == "inst_map": + isInstMap = True + break + if isMap: + s = "M.sel (" + selectingFromExpr + ") (" + selectingIndexExpr + ")" + elif isInstMap: + s = "if M.contains " + selectingFromExpr + " " + selectingIndexExpr + " then " + selectingIndexExpr + " else null" + elif isArray: + s = "A.select (" + selectingFromExpr + ") (" + selectingIndexExpr + ")" + self.indentationLevel -= 1 + return s + + def writeEventDeclarations(self): + for event in self.events: + self.writeToFStar("assume val " + self.addPrefix(event) + " : string\n") + + def writeEnums(self): + for enumType in self.enumTypes: + self.writeToFStar("type " + self.addPrefix(enumType) + " =\n") + + for enum in list(self.enumValues.keys()): + self.writeToFStar("| " + enum[:1].upper() + enum[1:] + "\n") + + def writeStructDecl(self, structs, symbols): + for struct in structs: + self.writeToFStar("noeq type " + self.addPrefix(struct) + " = {\n") + structFields = {} + for sym in symbols: + if sym.isStructField and sym.fieldOfStruct == struct: + structFields[sym.name] = self.getFStarDatatypeS(sym.type, symbols) + # self.writeToFStar(" " + self.fieldPrefix + "_") + for structField in structFields.keys(): + self.writeToFStar(" " + self.addPrefix(structField) + " : " + structFields[structField]) + if structField != list(structFields.keys())[-1]: + self.writeToFStar(";") + self.writeToFStar("\n") + self.writeToFStar("}\n\n") + + def writeFieldRecord(self, symbols): + if self.fields: + self.writeToFStar("\nnoeq type t_" + str.lower(self.moduleName) + " = {") + keys = list(self.fields.keys()) + for k in keys: + self.fieldsOfContract[self.moduleName].append((k, self.fields[k])) + self.writeToFStar("\n " + self.addPrefix(k) + " : " + self.getFStarDatatype(self.fields[k], symbols) + ";") + + self.writeToFStar("\n}") + else: + self.writeToFStar("\ntype t_" + self.fieldPrefix + " = unit") + + def writeAddressAndLiveness(self): + contractName = str.lower(self.moduleName) + self.writeToFStar("\n") + self.writeToFStar("\n(* Contract address type, liveness, and field range macros *)") + self.writeToFStar("\n") + self.writeToFStar("\ntype " + self.addPrefix("address") + " = contract t_" + contractName) + self.writeToFStar("\nlet " + self.addPrefix("live") + " (c:" + self.addPrefix("address") + ") (bst:bstate) =") + self.writeToFStar("\n c `CM.live_in` bst.cmap") + + flag = False + s = "" + + for field in self.fields: + if self.fields[field].getText()[0:8] == "inst_map": + contractType = self.fields[field].getText()[9:-1] + contractAddressType = str.lower(contractType) + "_address" + field = self.addPrefix(field) + if flag: + s += "\n /\\ (forall (i:" + contractAddressType + "). M.contains cs." + field + " i ==> i `CM.live_in` bst.cmap /\\ i <> c)" + else: + s += "\n (forall (i:" + contractAddressType + "). M.contains cs." + field + " i ==> i `CM.live_in` bst.cmap /\\ i <> c)" + flag = True + + if flag: + self.writeToFStar("\n /\\ (let cs = CM.sel c bst.cmap in") + s += "\n )" + self.writeToFStar(s) + + def writeFieldGetterSetters(self, symbols): + c = self.fieldPrefix # contract name + + self.writeToFStar("\n") + self.writeToFStar("\n(* Field getters for contract " + self.moduleName + " *)") + for field in list(self.fields.keys()): + fp = self.addPrefix(field) # prefixed field name + self.writeToFStar("\n") + self.writeToFStar("\nlet " + self.addPrefix("get_" + field) + " (c:" + self.addPrefix("address") + ")") + self.writeToFStar("\n: StEth " + self.getFStarDatatype(self.fields[field], symbols, isQuantifier=False)) + self.writeToFStar("\n (fun st -> c `" + c + "_live` st.current)") + self.writeToFStar("\n (fun st0 r st1 ->") + self.writeToFStar("\n st0 == st1 /\\ r == (CM.sel c st0.current.cmap)." + fp +")") + self.writeToFStar("\n= let " + self.addPrefix("inst") + " = get_contract c in") + self.writeToFStar("\n " + self.addPrefix("inst") + "." + fp) + + self.writeToFStar("\n") + self.writeToFStar("\n(* Field setters for contract " + self.moduleName + " *)") + for field in list(self.fields.keys()): + fp = self.addPrefix(field) # prefixed field name + self.writeToFStar("\n") + self.writeToFStar("\nlet " + c + "_set_" + field + " (c:" + c + "_address) (_" + field + ":" + self.getFStarDatatype(self.fields[field], symbols) + ")") + self.writeToFStar("\n: StEth unit") + if self.fields[field].getText() == "uint": + self.writeToFStar("\n (fun st -> c `" + c + "_live` st.current") + self.writeToFStar("\n /\\ _" + field + " >= 0 /\\ _" + field + " <= uint_max)") + elif self.fields[field].getText() == "int": + self.writeToFStar("\n (fun st -> c `" + c + "_live` st.current") + self.writeToFStar("\n /\\ _" + field + " >= int_min /\\ _" + field + " <= int_max)") + elif (self.fields[field].getText()[0:8] == "inst_map"): + contractType = self.fields[field].getText()[9:-1] + contractAddressType = str.lower(contractType) + "_address" + self.writeToFStar("\n (fun st -> c `" + c + "_live` st.current") + self.writeToFStar("\n /\\ (forall (i:" + contractAddressType + "). M.contains _" + field + " i ==> " + str.lower(contractType) + "_live i st.current /\\ i <> c))") + else: + self.writeToFStar("\n (fun st -> c `" + c + "_live` st.current)") + self.writeToFStar("\n (fun st0 _ st1 ->") + self.writeToFStar("\n modifies_cmap_only (Set.singleton c) st0.current st1.current /\\") + self.writeToFStar("\n " + c + "_live c st1.current /\\") + self.writeToFStar("\n (let instance0 = CM.sel c st0.current.cmap in") + self.writeToFStar("\n let instance1 = CM.sel c st1.current.cmap in") + self.writeToFStar("\n instance1 == { instance0 with " + fp + " = _" + field + " }))") + self.writeToFStar("\n= let " + self.addPrefix("inst") + " = get_contract c in") + self.writeToFStar("\n let " + self.addPrefix("inst") + " = { " + self.addPrefix("inst") + " with " + fp + " = _" + field + " } in") + self.writeToFStar("\n set_contract c " + self.addPrefix("inst")) + + def writeInvariant(self, invariantName): + self.writeToFStar("\n") + self.writeToFStar("\nlet " + invariantName + " (self:" + self.addPrefix("address") + ") (bst:bstate{self `" + self.addPrefix("live") + "` bst}) : Type0 =") + self.writeToFStar("\n let " + self.addPrefix("balance") + " = pure_get_balance_bst self bst in") + self.writeToFStar("\n let cs = CM.sel self bst.cmap in") + + def writeInvariantBody(self, expr:CelestialParser.ExprContext, symbols, scope): + self.writeToFStar("\n " + self.getFStarExpression(expr, symbols, scope, isInvariant=True)) + + def writeFunction(self, ctx:CelestialParser.FunDeclContext, symbols): + functionName = ctx.iden().Iden().getText() + self.writeToFStar("\n") + self.writeToFStar("\nlet " + functionName) + if ctx.funParamList(): + for parameter in ctx.funParamList().funParam(): + paramName = parameter.iden().Iden().getText() + paramType = self.getFStarDatatype(parameter.datatype(), symbols) + if (parameter.datatype().getText()[0:8] == "inst_map" or parameter.datatype().getText() in self.contracts): + contractType = "" + if parameter.datatype().getText()[0:8] == "inst_map": + contractType = str.lower(parameter.datatype().getText()[9:-1]) + "_address" + elif parameter.datatype().getText() in self.contracts: + contractType = str.lower(parameter.datatype().getText()) + "_address" + paramType = "tuple2 " + paramType + " bstate{forall (k:" + contractType + "). M.contains (fst " + paramName + ") k ==> k `CM.live_in` (snd " + paramName + ").cmap}" + self.writeToFStar(" (" + paramName + ":" + paramType + ")") + self.writeToFStar("\n= ") + + def writeFunctionBody(self, expr:CelestialParser.ExprContext, symbols, scope): + self.writeToFStar(self.getFStarExpression(expr, symbols, scope)) + + def writeConstructor(self, symbols, scope, ctx:CelestialParser.ConstructorDeclContext=None): + self.writeToFStar("\n") + self.writeToFStar("\nlet " + self.addPrefix("constructor") + " (self:" + self.addPrefix("address") + ") (sender:address) (value:uint) (tx:tx) (block:block)") + if (ctx and ctx.methodParamList()): + for parameter in ctx.methodParamList().methodParam(): + paramName = parameter.iden().Iden().getText() + paramType = self.getFStarDatatype(parameter.datatype(), symbols) + self.writeToFStar(" (" + paramName + ":" + paramType + ")") + self.writeToFStar("\n: Eth1 unit") + + ################# Begin pre ################# + + self.writeToFStar("\n (fun bst -> ") + self.writeToFStar("\n " + self.addPrefix("live") + " self bst /\\") + self.writeToFStar("\n (let b = pure_get_balance_bst self bst in") # balance + self.writeToFStar("\n let cs = CM.sel self bst.cmap in") # contract record + self.writeToFStar("\n (sender <> null)") + + # Need to specify that all its fields are set to default values (other sum_mapping type invariants don't go through) + if self.fields: + for field in list(self.fields.keys()): + fieldName = self.fields[field].getText() + if fieldName not in self.contracts: + if fieldName in self.initialFieldValues: + fieldInitialValue = self.getFStarExpression(self.initialFieldValues[fieldName], symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + if " " in fieldInitialValue: + fieldInitialValue = "(" + fieldInitialValue + ")" + else: + fieldInitialValue = self.defaultValue(fieldName, symbols) + self.writeToFStar("\n /\\ (cs." + self.addPrefix(field) + " == " + fieldInitialValue + ")") + else: + self.writeToFStar("\n /\\ (cs." + self.addPrefix(field) + " == null)") + + # Check if any pre-condition is specified + if (ctx.spec().pre): + # pre = self.getFStarPrePost(ctx.spec().pre, symbols, scope, isPre=True) + pre = self.getFStarExpression(ctx.spec().pre, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + self.writeToFStar("\n /\\ (" + pre + ")") + + self.writeToFStar("\n )") + self.writeToFStar("\n )") + + ################# Begin reverts clause ################# + + # Constructor can revert only because of the arguments passed (and other methods called, + # whose arguments are in scope here at the callee), nothing else + if not ctx.spec().reverts: + self.writeToFStar("\n (fun bst -> False)") + else: + self.writeToFStar("\n (fun bst ->") + + flag = False + if (ctx.spec().reverts): + # reverts = self.getFStarPrePost(ctx.spec().reverts, symbols, scope, isPre=True) + reverts = self.getFStarExpression(ctx.spec().reverts, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + self.writeToFStar("\n (" + reverts + ")") + flag = True + + self.writeToFStar("\n )") + + ################# Begin post ################# + + self.writeToFStar("\n (fun bst0 x bst1 ->") + + # If there is nothing in the user-written post-condition, then no need to retrieve cs0, etc. Post condition here is just the liveness + if not ctx.spec().post and not ctx.spec().CREDIT() and not ctx.spec().DEBIT() and not ctx.MODIFIES() and not ctx.MODIFIESA(): + self.writeToFStar("\n " + self.addPrefix("live") + " self bst1") # liveness post condition + # self.writeToFStar("\n /\\ " + self.addPrefix("live") + " x bst1") # liveness post condition + # Check if there are any invariants defined + if (self.invariants and not ctx.PRIVATE()): + for invariant in self.invariants: + self.writeToFStar("\n /\\ (" + invariant + " self bst1)") + self.writeToFStar("\n )") + + # If there is something in the user-written post-condition + else: + self.writeToFStar("\n " + self.addPrefix("live") + " self bst1 /\\ (") # liveness post condition + self.writeToFStar("\n let cs1 = CM.sel self bst1.cmap in") # updated contract state + self.writeToFStar("\n let b0 = pure_get_balance_bst self bst0 in") # balance + self.writeToFStar("\n let b1 = pure_get_balance_bst self bst1 in") # new(balance) + self.writeToFStar("\n let l0 = bst0.log in") # log + self.writeToFStar("\n let l1 = bst1.log in") # new(log) + + flag = False + + # Check if there are any invariants defined + if (self.invariants and not ctx.PRIVATE()): + for invariant in self.invariants: + if invariant == self.invariants[0] and not flag: + self.writeToFStar("\n (" + invariant + " self bst1)") + else: + self.writeToFStar("\n /\\ (" + invariant + " self bst1)") + flag = True + + # Check if any post-condition is specified + if (ctx.spec().post): + post = self.getFStarExpression(ctx.spec().post, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=True) + # post = self.getFStarPrePost(ctx.spec().post, symbols, scope, isPre=False) + if flag: + self.writeToFStar("\n /\\ (" + post + ")") + else: + self.writeToFStar("\n (" + post + ")") + flag = True + + # Check if the method is a credit or debit method + # If both are present, then don't write any condition + # If only DEBIT is given, then don't write any condition (b0 isn't available) + # If only CREDIT is given, then write the following condition + if (ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + if flag: + self.writeToFStar("\n /\\ (b1 == value)") + else: + self.writeToFStar("\n (b1 == value)") + flag = True + + if (not ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + if flag: + self.writeToFStar("\n /\\ (bst0.balances == bst1.balances)") + else: + self.writeToFStar("\n (bst0.balances == bst1.balances)") + flag = True + + if (ctx.MODIFIES() and not ctx.modifies) or not ctx.MODIFIES(): + if flag: + self.writeToFStar("\n /\\ (l0 == l1)") + else: + self.writeToFStar("\n (l0 == l1)") + flag = True + + # Check if the 'modifies_addresses' clause is used + if (ctx.modifies_addrs): + modifiesAddressesList = [] + for address in ctx.modifies_addrs.rvalue(): + modifiesAddressesList.append(self.getFStarExpression(address.expr(), symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=True)) + stringOfSetOfAddresses = "" + + # The first element does not have an 'Set.union' + if " " in modifiesAddressesList[0]: + stringOfSetOfAddresses = "(Set.singleton (" + modifiesAddressesList[0] + "))" + else: + stringOfSetOfAddresses = "(Set.singleton " + modifiesAddressesList[0] + ")" + + # Union of singleton of each of the contract addresses + for address in modifiesAddressesList[1:]: + if " " in address: + address = "(" + address + ")" + stringOfSetOfAddresses = "(Set.union (Set.singleton " + address + ") " + stringOfSetOfAddresses + ")" + + if flag: + self.writeToFStar("\n /\\ CM.modifies_addrs " + stringOfSetOfAddresses + " bst0.cmap bst1.cmap") + else: + self.writeToFStar("\n CM.modifies_addrs " + stringOfSetOfAddresses + " bst0.cmap bst1.cmap") + + # Check if the modifies shorthand has been used + # if (ctx.modifies): # non-empty modifies + # modifiesList = [] + # if (ctx.spec().CREDIT() or ctx.spec().DEBIT()): + # modifiesList.append("log") + # for m in ctx.modifies.rvalue(): + # modifiesList.append(m.expr().getText()) + # fieldList = list(self.fields.keys()) + # unmodifiedList = list(set(fieldList) - set(modifiesList)) + # if not ctx.spec().CREDIT() and not ctx.spec().DEBIT(): + # self.writeToFStar("\n /\\ (b0 == b1)") + # if "log" not in modifiesList: + # self.writeToFStar("\n /\\ (l0 == l1)") #TODO: what if external method is called that updates to log? + # for f in unmodifiedList: + # self.writeToFStar("\n /\\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") + + # else: # empty modifies + # if (ctx.MODIFIES() and not ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + # self.writeToFStar("\n /\\ (bst0 == bst1)") # entire bstate remains same + # # for f in list(self.fields.keys()): + # # self.writeToFStar("\n /\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") + + # elif (ctx.MODIFIES() and (ctx.spec().CREDIT() or ctx.spec().DEBIT())): + # for f in list(self.fields.keys()): + # self.writeToFStar("\n /\\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") # all fields remain same (but balance and log change) + + if not flag: + self.writeToFStar("\n True))") # closing parenthesis for ensures and let bindings + else: + self.writeToFStar("\n ))") # closing parenthesis for ensures and let bindings + + self.writeToFStar("\n=") + + # if self.fields: + # newContractRecordString = "({" + # for field in list(self.fields.keys()): + # newContractRecordString += self.addPrefix(field) + " = " + self.defaultValue(self.fields[field].getText(), symbols) + "; " + # newContractRecordString += "})" + # else: + # newContractRecordString = "()" + # self.writeToFStar("\nlet self = create_contract " + newContractRecordString + " in") + + if ctx.spec().CREDIT(): + self.writeToFStar("\nlet b = get_balance self in") + self.writeToFStar("\nlet _ = set_balance self (") + self.writeToFStar("\n if (b + value > uint_max) then (b + value - uint_max)") + self.writeToFStar("\n else (b + value)) in") + # else: + # self.writeToFStar("\nlet _ = set_balance self 0 in") + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + + # def exitWriteConstructor(self, ctx:CelestialParser.ConstructorDeclContext): + # self.writeToFStar("\nself") + + def writeMethod(self, ctx:CelestialParser.MethodDeclContext, symbols, scope): + # Writing method definition + if ctx.name: + methodName = ctx.name.Iden().getText() + elif ctx.RECEIVE(): + methodName = "receive" + else: + methodName = "fallback" + + self.writeToFStar("\n") + self.writeToFStar("\nlet " + methodName + " (self:" + self.addPrefix("address") + ") (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block)") + if ctx.methodParamList(): + for parameter in ctx.methodParamList().methodParam(): + paramName = parameter.iden().Iden().getText() + paramType = self.getFStarDatatype(parameter.datatype(), symbols) + self.writeToFStar(" (" + paramName + ":" + paramType + ")") + if ctx.datatype(): + methodReturnType = self.getFStarDatatype(ctx.datatype(), symbols) + else: + methodReturnType = "unit" + self.writeToFStar("\n: Eth1 " + methodReturnType) + + ################# Begin pre ################# + + self.writeToFStar("\n (fun bst ->") + + # If there are no pre-conditions at all, just write the mandatory ones and don't retrieve cs, etc. + if (not self.invariants or ctx.PRIVATE()) and not ctx.spec().PRE() and not ctx.spec().CREDIT(): + self.writeToFStar("\n " + self.addPrefix("live") + " self bst") + self.writeToFStar("\n )") + else: + self.writeToFStar("\n " + self.addPrefix("live") + " self bst /\\ (") # liveness post condition + self.writeToFStar("\n let cs = CM.sel self bst.cmap in") # contract state + self.writeToFStar("\n let b = pure_get_balance_bst self bst in") # balance + self.writeToFStar("\n let l = bst.log in") # log + + conjunctFlag = False + + # Check if there are any invariants defined + if (self.invariants and not ctx.PRIVATE()): + for invariant in self.invariants: + if conjunctFlag: + self.writeToFStar("\n /\\ (" + invariant + " self bst)") + else: + self.writeToFStar("\n (" + invariant + " self bst)") + conjunctFlag = True + + # Check if any pre-condition is specified + if (ctx.spec().pre): + pre = self.getFStarExpression(ctx.spec().pre, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + if conjunctFlag: + self.writeToFStar("\n /\\ (" + pre + ")") + else: + self.writeToFStar("\n (" + pre + ")") + + self.writeToFStar("\n ))") + + ################# Begin reverts clause ################# + + if not ctx.spec().reverts and not ctx.spec().CREDIT() and not ctx.spec().rreverts: + self.writeToFStar("\n (fun bst -> False)") + else: + self.writeToFStar("\n (fun bst ->") + self.writeToFStar("\n let cs = CM.sel self bst.cmap in") # contract state + self.writeToFStar("\n let b = pure_get_balance_bst self bst in") # balance + self.writeToFStar("\n let l = bst.log in") # log + + flag = False + + if (ctx.spec().reverts): + reverts = self.getFStarExpression(ctx.spec().reverts, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + self.writeToFStar("\n (" + reverts + ")") + flag = True + + if (ctx.spec().rreverts): + rreverts = self.getFStarExpression(ctx.spec().rreverts, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=True, isPost=False) + if flag: + self.writeToFStar("\n \/ (" + rreverts + ")") + else: + self.writeToFStar("\n (" + rreverts + ")") + flag = True + + if not flag: + self.writeToFStar("\n False)") + else: + self.writeToFStar("\n )") + + ################# Begin post ################# + + if ctx.returnval: + retIden = ctx.returnval.Iden().getText() + self.returnVarNames[methodName] = retIden + else: + retIden = "x" + + self.writeToFStar("\n (fun bst0 " + retIden + " bst1 ->") + + # If there is nothing in the post-condition, then no need to retrieve cs0, etc. Post condition here is just the liveness + if not ctx.spec().post and not ctx.spec().CREDIT() and not ctx.spec().DEBIT() and not ctx.MODIFIES() and not ctx.MODIFIESA(): + self.writeToFStar("\n " + self.addPrefix("live") + " self bst1") # liveness post condition + # Check if there are any invariants defined + if (self.invariants and not ctx.PRIVATE()): + for invariant in self.invariants: + self.writeToFStar("\n /\\ (" + invariant + " self bst1)") + self.writeToFStar("\n )") + + else: + self.writeToFStar("\n " + self.addPrefix("live") + " self bst1 /\\ (") # liveness post condition + self.writeToFStar("\n let cs0 = CM.sel self bst0.cmap in") # contract state + self.writeToFStar("\n let cs1 = CM.sel self bst1.cmap in") # updated contract state + self.writeToFStar("\n let b0 = pure_get_balance_bst self bst0 in") # balance + self.writeToFStar("\n let b1 = pure_get_balance_bst self bst1 in") # new(balance) + self.writeToFStar("\n let l0 = bst0.log in") # log + self.writeToFStar("\n let l1 = bst1.log in") # new(log) + + flag = False + + # Check if there are any invariants defined + if (self.invariants and not ctx.PRIVATE()): + for invariant in self.invariants: + if invariant == self.invariants[0] and not flag: + self.writeToFStar("\n (" + invariant + " self bst1)") + else: + self.writeToFStar("\n /\\ (" + invariant + " self bst1)") + flag = True + + # Check if any post-condition is specified + if (ctx.spec().post): + post = self.getFStarExpression(ctx.spec().post, symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=True) + # post = self.getFStarPrePost(ctx.spec().post, symbols, scope, isPre=False) + if flag: + self.writeToFStar("\n /\\ (" + post + ")") + else: + self.writeToFStar("\n (" + post + ")") + flag = True + + # Check if the method is a credit or debit method + # if (ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + # if flag: + # self.writeToFStar("\n /\\ (b1 == b0 + value)") + # else: + # self.writeToFStar("\n (b1 == b0 + value)") + # flag = True + if (ctx.spec().DEBIT() and not ctx.spec().CREDIT()): + if flag: + self.writeToFStar("\n /\\ (b1 <= b0)") + else: + self.writeToFStar("\n (b1 <= b0)") + flag = True + elif (not ctx.spec().DEBIT() and not ctx.spec().CREDIT()): + # Generate predicate that states all balances remain the same + # This is true only if it is not a CREDIT or DEBIT method + # and, 'balance' isn't there in the MODIFIES clause + balanceChanged = False + if (ctx.modifies): + for m in ctx.modifies.rvalue(): + if m.getText() == "balance": + balanceChanged = True + break + if (not balanceChanged): + if flag: + self.writeToFStar("\n /\\ (bst0.balances == bst1.balances)") + else: + self.writeToFStar("\n (bst0.balances == bst1.balances)") + flag = True + + # Check if the 'modifies_addresses' clause is used + if (ctx.modifies_addrs): + modifiesAddressesList = [] + for address in ctx.modifies_addrs.rvalue(): + modifiesAddressesList.append(self.getFStarExpression(address.expr(), symbols, scope, isInvariant=False, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=True)) + stringOfSetOfAddresses = "" + + # The first element does not have an 'Set.union' + if " " in modifiesAddressesList[0]: + stringOfSetOfAddresses = "(Set.singleton (" + modifiesAddressesList[0] + "))" + else: + stringOfSetOfAddresses = "(Set.singleton " + modifiesAddressesList[0] + ")" + + # Union of singleton of each of the contract addresses + for address in modifiesAddressesList[1:]: + if " " in address: + address = "(" + address + ")" + stringOfSetOfAddresses = "(Set.union (Set.singleton " + address + ") " + stringOfSetOfAddresses + ")" + + if flag: + self.writeToFStar("\n /\\ CM.modifies_addrs " + stringOfSetOfAddresses + " bst0.cmap bst1.cmap") + else: + self.writeToFStar("\n CM.modifies_addrs " + stringOfSetOfAddresses + " bst0.cmap bst1.cmap") + + # Check if the modifies shorthand has been used + if (ctx.modifies): # non-empty modifies + + # Make a list of all the modifies fields + modifiesList = [] + for m in ctx.modifies.rvalue(): + modifiesList.append(m.expr().getText()) + + # Filter out the fields that are unmodified + fieldList = list(self.fields.keys()) + unmodifiedList = list(set(fieldList) - set(modifiesList)) + + # If the method is neither CREDIT or DEBIT and + # 'balance' or 'log' are not specifed in the + # 'modifies' clause, then they are unmodified + if not ctx.spec().CREDIT() and not ctx.spec().DEBIT(): + if "log" not in modifiesList: + if flag: + self.writeToFStar("\n /\\ (l0 == l1)") + else: + self.writeToFStar("\n (l0 == l1)") + flag = True + + # Generate the predicates for fields that are modified + for f in unmodifiedList: + if not flag and f == unmodifiedList[0]: + self.writeToFStar("\n (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") + else: + self.writeToFStar("\n /\\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") + + else: # empty modifies + if (ctx.MODIFIES()): # modifies talks only about its fields + if flag: + self.writeToFStar("\n /\\ (cs0 == cs1)") + else: + self.writeToFStar("\n (cs0 == cs1)") + flag = True + if (ctx.spec()): + if (not ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + self.writeToFStar("\n /\\ (l0 == l1)") + # if (ctx.MODIFIES() and not ctx.spec().CREDIT() and not ctx.spec().DEBIT()): + # self.writeToFStar("\n /\\ (bst0 == bst1)") # entire bstate remains same + # # for f in list(self.fields.keys()): + # # self.writeToFStar("\n /\\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") + + # elif (ctx.MODIFIES() and (ctx.spec().CREDIT() or ctx.spec().DEBIT())): + # for f in list(self.fields.keys()): + # self.writeToFStar("\n /\\ (cs0." + self.addPrefix(f) + " == cs1." + self.addPrefix(f) + ")") # all fields remain same (but balance and log change) + + if flag == False: + self.writeToFStar("\n True))") + else: + self.writeToFStar("\n ))") # closing parenthesis for ensures + + self.writeToFStar("\n=") + + if ctx.spec().CREDIT(): + self.writeToFStar("\nlet b = get_balance self in") + self.writeToFStar("\nlet _ = set_balance self (") + self.writeToFStar("\n if (b + value > uint_max) then (b + value - uint_max)") + self.writeToFStar("\n else (b + value)) in") + + if ctx.returnval: + self.writeToFStar("\nlet " + ctx.returnval.Iden().getText() + ":" + self.getFStarDatatype(ctx.datatype(), symbols) + " = " + self.defaultValue(ctx.datatype().getText(), symbols) + " in") + + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + + #TODO: Use self.defaultValue() + def writeVariable(self, ctx:CelestialParser.VarDeclContext, symbols, scope): + self.writeToFStar("\nlet " + ctx.iden().Iden().getText() + ":") + varType = self.getFStarDatatype(ctx.datatype(), symbols) + self.writeToFStar(varType + " = (") + if ctx.expr(): + self.writeToFStar(self.getFStarExpression(ctx.expr(), symbols, scope, isMethod=True)) + else: + if ctx.datatype().arrayType: + self.writeToFStar("A.create_empty (" + self.defaultValue(self.getFStarDatatype(ctx.arrayType, symbols), symbols) + ")") + elif ctx.datatype().BOOL(): + self.writeToFStar("false") + elif ctx.datatype().INT() or ctx.datatype().UINT(): + self.writeToFStar("0") + elif ctx.datatype().STRING(): + self.writeToFStar("\"\"") + elif ctx.datatype().ADDR(): + self.writeToFStar("null") + elif ctx.datatype().getText() in self.contracts: + self.writeToFStar("null") + # TODO: Handle struct (and enum?) local vars + self.writeToFStar(") in") + + def writePushStatement(self, ctx:CelestialParser.StatementContext, symbols, scope, arrayName): + # All arrays are global only for Celestial v0.1 + valueToPush = self.getFStarExpression(ctx.value, symbols, scope, isMethod=True) + lvalueToPushTo = self.getFStarExpressionLvalue(ctx.arrayName, symbols, scope) + if "=" in valueToPush: + self.writeToFStar("\nlet x1 = (" + valueToPush + ") in") + valueToPush = "x1" + if "=" in lvalueToPushTo: + self.writeToFStar("\nlet x2 = (" + lvalueToPushTo + ") in") + lvalueToPushTo = "x2" + #TODO: Nested array push + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + ctx.arrayName.name.Iden().getText()) + " self (A.push " + lvalueToPushTo + " " + valueToPush + ") in") + self.writeToFStar("\nlet cs = get_contract self in") + # self.writeToFStar("let cs = {cs with " + self.addPrefix(ctx.arrayName.name.Iden().getText()) + " = (A.update x2 (A.length x2) x1)} in\n") + # self.writeToFStar("set_" + self.fieldPrefix + "_" + ctx.name.name.Iden().getText() + "(A.update x2 (A.length x2) x1);\n") # this doesn't support multi dim arrays => have a get array name fn and use that + # self.writeToFStar("let " + arrayName + " = (snoc " + arrayName + " x1) in\n") # local arrays, for when it is supported + + def writePopStatement(self, ctx:CelestialParser.StatementContext, symbols, scope, arrayName): + arrayToPopFrom: self.getFStarExpressionLvalue(ctx.arrayName, symbols, scope) + if " " in arrayToPopFrom: + arrayToPopFrom = "(" + arrayToPopFrom + ")" + + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + ctx.arrayName.name.Iden().getText()) + " self (A.pop " + arrayToPopFrom + ") in") + self.writeToFStar("\nlet cs = get_contract self in") + + # TODO: Generalize lvalue to any lvalue and not just iden + def writeDeleteStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + fieldName = ctx.toDelete.name.Iden().getText() + fieldType = "" + setter = self.addPrefix("set_" + fieldName) + " self" + # getter = "(" + self.addPrefix("get_" + fieldName) + " self)" + getter = "cs." + self.addPrefix(fieldName) + for symbol in symbols: + if symbol.name == fieldName: + fieldType = symbol.type + break + if self.isMapping(fieldType): + keyExpr = self.getFStarExpression(ctx.value, symbols, scope, isMethod=True) + if "=" in keyExpr: + self.writeToFStar("\nlet x1 = (" + keyExpr + ") in") + keyExpr = "x1" + self.writeToFStar("\nlet _ = " + setter + " (M.delete " + getter + " " + keyExpr + ") in") + # self.writeToFStar(self.indentationLevel * " " + "let cs = {cs with " + prefixedFieldName + " = (M.delete cs." + prefixedFieldName + " " + keyExpr + ")} in\n") + elif self.isArray(fieldType): + if ctx.value: + indexExpr = self.getFStarExpression(ctx.value, symbols, scope, isMethod=True) + if "=" in indexExpr: + self.writeToFStar("\nlet x1 = (" + indexExpr + ") in") + indexExpr = "x1" + self.writeToFStar("\nlet _ = " + setter + " (A.delete " + getter + " " + indexExpr + ") in") + else: + arrValType = self.getFStarDatatypeS(fieldType[6:-1], symbols) + self.writeToFStar("\nlet _ = " + setter + " (A.create_empty " + arrValType + ") in") + elif fieldType[0:8] == "inst_map": + keyExpr = self.getFStarExpression(ctx.value, symbols, scope, isMethod=True) + if "=" in keyExpr: + self.writeToFStar("\nlet x1 = (" + keyExpr + ") in") + keyExpr = "x1" + self.writeToFStar("\nlet _ = " + setter + " (M.delete " + getter + " " + keyExpr + ") in") #TODO: replace M with instmap library + # self.writeToFStar(self.indentationLevel * " " + "let cs = {cs with " + prefixedFieldName + " = (M.delete cs." + prefixedFieldName + " " + keyExpr + ")} in\n") + else: + self.writeToFStar("\nlet _ = " + setter + " " + self.defaultValue(fieldType, symbols) + " in") + self.writeToFStar("\nlet cs = get_contract self in") + + # assumes just nested maps without arrays + # TODO Generalize to arrays + # TODO If no nesting, then write a case without x2 x1 etc + def nestedMap(self, ctx:CelestialParser.LvalueContext, symbols, scope, x): + self.nestedLevel += 1 + if ctx.LBRACK(): + if ctx.lvalue().name: + # return "(M.sel " + ctx.name.Iden().getText() + " " + self.getFStarExpression(ctx.expr(), symbols, scope) + ")" + exp = self.getFStarExpression(ctx.expr(), symbols, scope) + mapName = ctx.lvalue().name.Iden().getText() + if mapName in list(self.fields.keys()): + # r = "let x" + str(x+2) + " = (get_" + self.fieldPrefix + "_" + mapName + " () ) in\n" + # r = "let x" + str(x+2) + " = " + self.addPrefix("get_" + mapName) + " self in" + r = "let x" + str(x+2) + " = cs." + self.addPrefix(mapName) + " in\n" + else: # TODO: Remove this? This case won't happen I think (check functions) + r = "\nlet x" + str(x+2) + " = (" + mapName + ") in" + r += "\nlet x" + str(x+1) + " = (" + exp + ") in" + r += "\nlet x" + str(x) + " = (M.sel x" + str(x+2) + " x" + str(x+1) + ") in" + # if mapName in self.fields: # dont think there's a case otherwise + # mapName = self.addPrefix(mapName) + self.temp = mapName + return r + # return "let x" + str(x) + " = (M.sel " + ctx.lvalue().name.Iden().getText() + " " + self.getFStarExpression(ctx.expr(), symbols, scope) + ") in\n" + else: + s = self.nestedMap(ctx.lvalue(), symbols, scope, x+2) + exp = self.getFStarExpression(ctx.expr(), symbols, scope) + # print (ctx.expr(0)) + r = s + "\nlet x" + str(x+1) + " = (" + exp + ") in" + r += "\nlet x" + str(x) + " = (M.sel x" + str(x+2) + " x" + str(x+1) + ") in" + return r + # return s + "let x" + str(x) + " = (M.sel x" + str(x+1) + " " + exp + ") in\n" + + def writeAssignmentStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + rhsctx = ctx.rvalue().expr() + rhs = self.getFStarExpression(rhsctx, symbols, scope, isMethod=True) + indentation = self.indentationLevel * " " + + # iden = value + if ctx.assignTo.name: + # if rhsctx.primitive() and rhsctx.getText() not in self.fields: + # rhs = rhsctx.primitive().getText() + # else: + if "=" in rhs or rhs == "balance" or rhsctx.method: + # if "=" in rhs or rhs == "get_balance self" or rhsctx.method: #Changed way balance is retrieved + self.writeToFStar("\nlet x1 = (" + rhs + ") in") + rhs = "x1" + varName = ctx.assignTo.name.getText() + lvalueType = "" + for sym in symbols: + if sym.name == varName and sym.scope in [scope, "global"]: + lvalueType = sym.type + break + + if varName in self.fields: + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + varName) + " self " + rhs + " in") + # self.writeToFStar("\n" + indentation + "let cs = get_contract self in") + # self.writeToFStar("let cs = {cs with " + self.addPrefix(varName) + " = " + rhs +"} in\n") + else: + self.writeToFStar("\nlet " + varName + " = " + rhs + " in") + + # If a method call happens or .add() is called, contract state is updated, and hence has to be retrieved again + # if rhsctx.method or rhsctx.ADD(): + # self.writeToFStar("\nlet cs = get_contract self in") + + # iden[]* = value + elif ctx.assignTo.LBRACK(): + if (ctx.assignTo.lvalue().name): # iden[] = value + indexKeyctx = ctx.assignTo.expr() + indexKey = self.getFStarExpression(indexKeyctx, symbols, scope, isMethod=True) + if rhsctx.primitive() and rhsctx.getText() not in self.fields: + rhs = rhsctx.primitive().getText() + else: + self.writeToFStar("\nlet x1 = (" + rhs + ") in") + rhs = "x1" + if indexKeyctx.primitive() and indexKeyctx.getText() not in self.fields: + indexKey = indexKeyctx.primitive().getText() + else: + self.writeToFStar("\nlet x2 = (" + indexKey + ") in") + indexKey = "x2" + + varName = ctx.assignTo.lvalue().iden().Iden().getText() + varType = "" + for sym in symbols: + if sym.name == varName and sym.scope in [scope, "global"]: + varType = sym.type + break + lvalueType = self.getMapValueType(varType) + if varName in self.fields: + # self.writeToFStar("\n" + indentation + "let " + varName + " = " + self.addPrefix("get_" + varName) + " self in") + self.writeToFStar("\n" + "let " + varName + " = cs." + self.addPrefix(varName) + " in") + if self.isArray(varType): + self.writeToFStar("\n" + "let _ = " + self.addPrefix("set_" + varName) + " self (A.update " + varName + " " + indexKey + " " + rhs + ") in") #TODO: Check if this works or if getter should be let bound + # self.writeToFStar("let cs = {cs with " + self.addPrefix(varName) + " = " + "(A.update cs." + self.addPrefix(varName) + " " + indexKey + " " + rhs +")} in\n") + elif self.isMapping(varType): + self.writeToFStar("\n" + "let _ = " + self.addPrefix("set_" + varName) + " self (M.upd " + varName + " " + indexKey + " " + rhs + ") in") #TODO: Check if this works or if getter should be let bound + # self.writeToFStar("let cs = {cs with " + self.addPrefix(varName) + " = " + "(M.upd cs." + self.addPrefix(varName) + " " + indexKey + " " + rhs +")} in\n") + # self.writeToFStar("\n" + indentation + "let cs = get_contract self in") + else: + if self.isArray(varType): + self.writeToFStar("\n" + "let" + varName + " = (A.update " + varName + " " + indexKey + " " + rhs + ") in") + elif self.isMapping(varType): + self.writeToFStar("\n" + "let" + varName + " = (M.upd " + varName + " " + indexKey + " " + rhs + ") in") + else: # iden[][][].. = value + nestedMapString = self.nestedMap(ctx.assignTo, symbols, scope, 0) + valueToWrite = "let x" + str(2*self.nestedLevel + 1) + " = (" + rhs + ") in" + self.writeToFStar("\n" + valueToWrite) + self.writeToFStar("\n" + nestedMapString) + + s = "\nlet _ = " + self.addPrefix("set_" + self.temp) + " self (M.upd x" + str(2*self.nestedLevel) + " x" + str(2*self.nestedLevel - 1) #TODO: Test + # s = "let cs = {cs with " + self.temp + " = (M.upd x" + str(2*self.nestedLevel) + " x" + str(2*self.nestedLevel - 1) + # s = "set_" + self.temp + " (M.upd x" + str(2*self.nestedLevel) + " x" + str(2*self.nestedLevel - 1) + for i in range(2*self.nestedLevel - 1, 1, -2): + s += " (M.upd x" + str(i-1) + " x" + str(i - 2) + s += " x" + str(2*self.nestedLevel + 1) + for i in range(2*self.nestedLevel - 1, 1, -2): + s += ")" + s += ") in" + self.writeToFStar("\n" + indentation + s) + # self.writeToFStar("\n" + indentation + "let cs = get_contract self in") + self.nestedLevel = 0 + + elif ctx.assignTo.DOT(): + if " " in rhs and rhs[0] != "(": + rhs = "(" + rhs + ")" + self.writeToFStar("\nlet x1 = " + rhs + " in") + if ctx.assignTo.lvalue().LBRACK(): #TODO: Complete this + fieldName = ctx.assignTo.lvalue().lvalue().name.getText() # field[e].f = x + fieldKey = self.getFStarExpression(ctx.assignTo.lvalue().expr(), symbols, scope, isMethod=True) + structFieldUpdated = ctx.assignTo.field.Iden().getText() + self.writeToFStar("\nlet x2 = cs." + self.addPrefix(fieldName) + " in") + self.writeToFStar("\nlet x3 = " + fieldKey + " in") + self.writeToFStar("\nlet x4 = M.sel x2 x3 in") + self.writeToFStar("\nlet x5 = M.upd x2 x3 ({x4 with " + self.addPrefix(structFieldUpdated) + " = x1}) in") + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + fieldName) + " self x5 in") + # structName = "" + # for symbol in symbols: + # if symbol.isStructField and symbol.name == structFieldUpdated: + # structName = symbol.fieldOfStruct + # break + # structObjectStr = "" + # for symbol in symbols: + # if symbol.isStructField and symbol.fieldOfStruct: + # if symbol.name == structFieldUpdated: + # structObjectStr += self.addPrefix(symbol.name) + " = x1; " + # else: + # structObjectStr + + self.writeToFStar("\nlet cs = get_contract self in") + + def writeCallStatement(self, ctx:CelestialParser.StatementContext, symbols, scope, reentrancyReverts): + reentrancyRevertsStrings = [] + for expr in reentrancyReverts: + conditionString = self.getFStarExpression(expr, symbols, scope, isMethod=True) + if conditionString not in reentrancyRevertsStrings: + reentrancyRevertsStrings.append(conditionString) + + reentrancyRevertsString = "" + if reentrancyRevertsStrings: + reentrancyRevertsString = "(" + reentrancyRevertsStrings[0] + ")" + for string in reentrancyRevertsStrings[1:]: + reentrancyRevertsString += " /\ (" + string + ")" + + if reentrancyRevertsString: + self.writeToFStar("\nassert (" + reentrancyRevertsString + ");") + + callName = "" + if ctx.CALLBOOL(): + callName = "call_bool" + elif ctx.CALLUINT(): + callName = "call_uint" + else: + callName = "unknown_call" + + argExpr = ctx.rvalueList().rvalue(0).expr() + argString = self.getFStarExpression(argExpr, symbols, scope, isMethod=True) + if " " in argString: + argString = "(" + argString + ")" + + # If the return value of the '.call' is assigned to a variable + if ctx.ASSIGN(): + if ctx.lvalue() and ctx.lvalue()[0].name: + varName = ctx.lvalue()[0].name.getText() + if varName in self.fields: + self.writeToFStar("\nlet x1 = " + callName + " self " + argString + " in") + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + varName) + " self (x1) in") + else: + self.writeToFStar("\nlet " + varName + " = " + callName + " self " + argString + " in") + # TODO: + # elif ctx.lvalue()... + elif ctx.BOOL(): + self.writeToFStar("\nlet " + ctx.getChild(1).getText() + ":bool = " + callName + " self " + argString + " in") + elif ctx.UINT(): + self.writeToFStar("\nlet " + ctx.getChild(1).getText() + ":uint = " + callName + " self " + argString + " in") + else: + self.writeToFStar("\nlet _ = " + callName + " self " + argString + " in") + + # Fetching balance since '.call' might change balance + self.writeToFStar("\nlet balance = get_balance self in") + + def writeNewStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + newContractOf = ctx.iden().Iden().getText() + if self.fieldsOfContract[newContractOf]: + newContractRecordString = "({" + for fields in self.fieldsOfContract[newContractOf]: + newContractRecordString += str.lower(newContractOf)+ "_" + fields[0] + " = " + self.defaultValue(fields[1].getText(), symbols) + "; " + newContractRecordString += "})" + else: + newContractRecordString = "()" + + self.writeToFStar("\nlet contract_addr = create_contract " + newContractRecordString + " in ") + if "constructor" in self.methodsOfContract[newContractOf].keys(): + # rhs = "\nassume (sender <> contract_addr); // NEWLY CREATED CONTRACT CANNOT HAVE THE SAME ADDRESS AS THE SENDER" + rhs = "\nlet x = (" + str.lower(newContractOf) + "_constructor contract_addr self 0 tx block" + if ctx.rvalueList(): + params = ctx.rvalueList().rvalue() + for param in params: + paramExpr = self.getFStarExpression(param.expr(), symbols, scope, isMethod=True) + rhs += " (" + paramExpr + ")" + rhs += ") in" + self.writeToFStar("\n" + rhs) + # rhs += "\nx" + + if ctx.assignTo.name: + contractInstanceName = ctx.assignTo.name.Iden().getText() + # TODO: For local instnaces also + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + contractInstanceName) + " self contract_addr in") + + # self.writeToFStar("\nlet cs = {cs with " + self.addPrefix(contractInstanceName) + " = " + rhs + "} in") #No constructor arguments for now + + elif ctx.assignTo.LBRACK(): + nestedMapString = self.nestedMap(ctx.assignTo, symbols, scope, 0) + valueToWrite = "let x" + str(2*self.nestedLevel + 1) + " = " + rhs + " in\n" + self.writeToFStar(valueToWrite) + self.writeToFStar(nestedMapString) + # s = "\nlet cs = {cs with " + self.temp + " = (M.upd x" + str(2*self.nestedLevel) + " x" + str(2*self.nestedLevel - 1) + s = "\nlet _ =" + self.addPrefix("set_" + self.temp) + " (M.upd x" + str(2*self.nestedLevel) + " x" + str(2*self.nestedLevel - 1) + for i in range(2*self.nestedLevel - 1, 1, -2): + s += " (M.upd x" + str(i-1) + " x" + str(i - 2) + s += " x" + str(2*self.nestedLevel + 1) + for i in range(2*self.nestedLevel - 1, 1, -2): + s += ")" + s += " in\n" + self.writeToFStar(s) + self.nestedLevel = 0 + + def writeIfStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + if scope in self.returnVarNames: + retIden = self.returnVarNames[scope] + else: + retIden = "_" + ifCondition = self.getFStarExpression(ctx.expr(0), symbols, scope, isMethod=True, isIf=True) + if (ctx.expr(0).primitive() and ctx.expr(0).getText() not in self.fields) or "=" not in ifCondition: + self.writeToFStar("\nlet " + retIden + " = (if (" + ifCondition + ") then begin") + else: + self.writeToFStar("\nlet x1 = (" + ifCondition + ") in") + self.writeToFStar("\nlet " + retIden + " = (if x1 then begin") + + # if-condition without an else branch in CelLang + def endIfWithoutElse(self, scope): + if scope in self.returnVarNames: + retIden = self.returnVarNames[scope] + else: + retIden = "()" + self.writeToFStar("\n" + retIden + " end") + self.writeToFStar("\nelse " + retIden + ") in") + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + + # else branch and ending if branch + def writeElseStatement(self, ctx:CelestialParser.ElseStatementContext, scope): + if scope in self.returnVarNames: + retIden = self.returnVarNames[scope] + else: + retIden = "()" + self.writeToFStar("\n" + retIden + " end") + self.writeToFStar("\nelse begin") + + # ending the else branch + def endElse(self, ctx:CelestialParser.ElseStatementContext, scope): + if scope in self.returnVarNames: + retIden = self.returnVarNames[scope] + else: + retIden = "()" + self.writeToFStar("\n" + retIden + " end) in") + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_contract self in") + + def writeReturn(self, methodName): + returnType = self.methods[methodName] + if returnType is None: + self.writeToFStar("\n()") + elif returnType.BOOL(): + self.writeToFStar("\ntrue") + elif returnType.INT() or returnType.UINT(): + self.writeToFStar("\n0") + elif returnType.ADDR(): + self.writeToFStar("\nnull") + + def writeMethodCallStatement(self, ctx:CelestialParser.StatementContext, symbols, scope, isVoid): + methodName = ctx.iden().Iden().getText() + if (ctx.rvalueList()): + params = ctx.rvalueList().rvalue() + x = 1 + i = 0 + xarr = {} + for param in params: + paramExpr = self.getFStarExpression(param.expr(), symbols, scope, isMethod=True) + if (param.expr().primitive() and param.expr().getText() in self.fields) or "=" in paramExpr: # same as if "=" in paramExpr + # paramExpr = param.expr().getText() + # else: + self.writeToFStar("\nlet x" + str(x) + " = (" + paramExpr + ") in") + paramExpr = "x" + str(x) + xarr[x] = paramExpr + i = i + 1 + x = x + 1 + + self.writeToFStar("\nlet _ = (" + methodName + " self self 0 tx block") + for i in range(1, x): + self.writeToFStar(" " + xarr[i]) + self.writeToFStar(") in") + else: + self.writeToFStar("\nlet _ = (" + methodName + " self self 0 tx block) in") + self.writeToFStar("\nlet cs = get_contract self in") + + def writeCtAssignmentStatement(self, ctx, symbols, scope): + methodName = ctx.iden().Iden().getText() + methodArgs = "" + if ctx.rvalueList(): + params = ctx.rvalueList().rvalue() + for param in params: + paramExpr = self.getFStarExpression(param.expr(), symbols, scope, isMethod=True) + methodArgs += " (" + paramExpr + ")" + otherContractInstanceName = self.getFStarExpressionLvalue(ctx.otherContractInstance, symbols, scope) + if " " in otherContractInstanceName: + otherContractInstanceName = "(" + otherContractInstanceName + ")" + + contractType = "" + for symbol in symbols: + if symbol.name == otherContractInstanceName: + contractType = symbol.type + break + + self.writeToFStar("\nlet bst = (get ()).current in") + for invariant in self.invariantsOfContract[contractType]: + self.writeToFStar("\nassume (" + invariant + " " + otherContractInstanceName + " bst); // META-ARGUMENT: CONTRACT INVARIANTS ALWAYS HOLD AT CONTRACT BOUNDARIES AND HENCE IS ALWAYS TRUE") + # self.writeToFStar("\nassume (sender <> " + otherContractInstanceName + "); // " + otherContractInstanceName + " CANNOT BE EQUAL TO sender AND HENCE IS ALWAYS TRUE") + + if ctx.assignTo.name: + self.writeToFStar("\nlet x1 = " + methodName + " " + otherContractInstanceName + " self 0 tx block" + methodArgs + " in") + assignTo = ctx.assignTo.name.Iden().getText() + if assignTo in self.fields: + self.writeToFStar("\nlet _ = " + self.addPrefix("set_" + assignTo) + " self x1 in") + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + else: + self.writeToFStar("\nlet " + assignTo + " = x1 in") + self.writeToFStar("\nlet balance = get_balance self in") + # elif assignTo.lvalue(): # if writing to an array, map, etc + + def writeExternMethodCallStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + methodName = ctx.iden().Iden().getText() + methodArgs = "" + if ctx.rvalueList(): + params = ctx.rvalueList().rvalue() + for param in params: + paramExpr = self.getFStarExpression(param.expr(), symbols, scope, isMethod=True) + methodArgs += " (" + paramExpr + ")" + otherContractInstanceName = self.getFStarExpressionLvalue(ctx.otherContractInstance, symbols, scope) + if " " in otherContractInstanceName: + otherContractInstanceName = "(" + otherContractInstanceName + ")" + + contractType = "" + for symbol in symbols: + if symbol.name == otherContractInstanceName: + contractType = symbol.type + break + + self.writeToFStar("\nlet bst = (get ()).current in") + for invariant in self.invariantsOfContract[contractType]: + self.writeToFStar("\nassume (" + invariant + " " + otherContractInstanceName + " bst); // META-ARGUMENT: CONTRACT INVARIANTS ALWAYS HOLD AT CONTRACT BOUNDARIES AND HENCE IS ALWAYS TRUE") + # self.writeToFStar("\nassume (sender <> " + otherContractInstanceName + "); // " + otherContractInstanceName + " CANNOT BE EQUAL TO sender AND HENCE IS ALWAYS TRUE") + self.writeToFStar("\nlet _ = " + methodName + " " + otherContractInstanceName + " self 0 tx block" + methodArgs + " in") + self.writeToFStar("\nlet balance = get_balance self in") # in case the external contract method sends ether to callee + + def writeRevertStatement(self, ctx:CelestialParser.StatementContext): + revertString = ctx.StringLiteral().getText() + self.writeToFStar("\nrevert " + revertString + ";") + + def writeReturnStatement(self, ctx:CelestialParser.ReturnStatementContext, symbols, scope, isVoid=True): + if isVoid: + self.writeToFStar("\n()") + else: + returnExpression = self.getFStarExpression(ctx.expr(), symbols, scope, isMethod=True) + self.writeToFStar("\n" + returnExpression) + + def writeTransferStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + # val = self.getFStarExpression(ctx.expr(1), symbols, scope, isMethod=True) + to = self.getFStarExpression(ctx.to, symbols, scope, isMethod=True) + payloadString = self.getFStarExpression(ctx.amount, symbols, scope, isMethod=True) + + if "=" in to or ctx.to.getText() in self.fields: + self.writeToFStar("\n" + "let x1 = (" + to + ") in") + to = "x1" + if "=" in payloadString or ctx.expr(1).getText() in self.fields: + self.writeToFStar("\n" + "let x2 = (" + payloadString + ") in") + payloadString = "x2" + + if "," in payloadString: + payloadString = "(" + payloadString + ")" + + self.writeToFStar("\n" + "let _ = transfer self " + to + " " + payloadString + " in") + + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + + def writeEmitStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + + # Generate the event payload expressions translated to F* as a tuple + payloadString = "" + for payloadExpr in ctx.expr(): + payloadString += self.getFStarExpression(payloadExpr, symbols, scope, isMethod=True) + if payloadExpr != ctx.expr()[-1]: + payloadString += ", " + + # If any of the payload expressions are stateful, let bind the payload tuple + if "=" in payloadString: + self.writeToFStar("\n" + "let x2 = (" + payloadString + ") in") + payloadString = "x2" + + elif "," in payloadString: + payloadString = "(" + payloadString + ")" + + eventName = ctx.event.Iden().getText() + self.writeToFStar("\n" + "let _ = emit " + self.fieldPrefix + "_" + eventName + " " + payloadString + " in") + + # Retrieve the contract state and balance again since the payloads can be expressions that update the state + self.writeToFStar("\nlet cs = get_contract self in") + self.writeToFStar("\nlet balance = get_balance self in") + + def writeAssertStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + assertCondition = self.getFStarExpression(ctx.expr(0), symbols, scope, isInvariant=False, isMethod=True, isFunctionCall=False, isIf=False) + if "=" in assertCondition: + self.writeToFStar(" let x1 = " + assertCondition + " in\n") + assertCondition = "x1" + self.writeToFStar("assert (" + assertCondition + ");\n") + + def defaultValue(self, datatype, symbols): + """ + ``` + datatype: string + symbols: list of symbol objects + + Returns the default value of the datatype + ``` + """ + + if datatype == "address": + return "null" + elif datatype in ("int", "uint", "uint8"): + return "0" + elif datatype == "string": + return "\"\"" + elif datatype == "bool": + return "false" + elif datatype in ("bytes20", "bytes32"): + return "\"\"" + elif datatype == "bytes": + return "[]" + elif self.isMapping(datatype): + valueType = self.getMapValueType(datatype) + return "M.const (" + self.defaultValue(valueType, symbols) + ")" + elif self.isArray(datatype): + arrayType = self.isArrayOf(datatype) + return "A.create_empty (" + self.defaultValue(arrayType, symbols) + ")" + elif datatype[0:8] == "inst_map": + return "M.const false" + + elif datatype in self.enumTypes: # return the first enumValue for that enumType + for enumVal in list(self.enumValues.keys()): + if self.enumValues[enumVal] == datatype: + return enumVal[:1].upper() + enumVal[1:] + elif datatype in self.contracts: + if self.fieldsOfContract[datatype]: + prefix = str.lower(datatype) + s = "{" + for field in self.fieldsOfContract[datatype]: + s += prefix + "_" + field[0] + " = " + self.defaultValue(field[1].getText(), symbols) + "; " + # s += prefix + "_balance = 0;" + s += "}" + else: + s = "()" + return s + else: # struct + s = "{" + for symbol in symbols: + if symbol.isStructField and symbol.fieldOfStruct == datatype: + s += self.addPrefix(symbol.name) + " = " + self.defaultValue(symbol.type, symbols) + "; " + s += "}" + return s + + def writeToFStar(self, code): + #TODO: Add indentation and newlines here + self.output.write(code) diff --git a/Celestial/Compiler/MyListener.py b/Celestial/Compiler/MyListener.py new file mode 100644 index 00000000..9ba6f9df --- /dev/null +++ b/Celestial/Compiler/MyListener.py @@ -0,0 +1,1791 @@ +import sys +from antlr4 import * +from CelestialLexer import CelestialLexer +from CelestialParser import CelestialParser +from CelestialParserListener import CelestialParserListener +from FStarCodegen import FStarCodegen +from SolidityCodegen import SolidityCodegen +from Symbol import Symbol +from prettytable import PrettyTable + +def revert(errorString, ctx=None): + if ctx: + print (str(ctx.start.line) + ":" + str(ctx.start.column) + " : " + errorString) + else: + print(errorString) + exit(1) + +class MyListener(CelestialParserListener): + + def __init__(self, FSTCodegen, SolidityCodegen, printSymbolTableFlag, disableFuncBooleanCheck, verificationMode): + self.FSTCodegen = FSTCodegen + self.SolidityCodegen = SolidityCodegen + self.printSymbolTableFlag = printSymbolTableFlag + self.disableFuncBooleanCheck = disableFuncBooleanCheck + self.verificationMode = verificationMode # Added for VeriSol + + # The following variables are not cleared for different contracts + self.contracts = [] + self.methodsOfContract = {} # Dict with keys = contract names and values = dict with key as method name and value as tuple of returnvalue and list as params of that method in the contract + self.fieldsOfContract = {} # Dict with keys = contract names and values = list of tuples (fieldName, fieldType, isPublic=False), for when a contract can access another contract's public field variables (TODO) + + # The following variables are cleared for different contracts + self.currentContract = "" + self.symbols = [] + self.enums = [] # List of enum types per contract + self.structs = [] # List of struct types per contract + self.constructorDefined = False + self.currentScope = "global" # String which is either "global" or the name of the method/function/invariant + self.isParam = False # True if the walker is currently inside a function call + self.isSpec = False # True if the walker is inside a function, invariant or pre/post of a method + self.methodHasReturn = False # True if the current method body the walker is in has a return statement + self.isInPost = False # True if the walker is currently at the post of a method + self.reentrancyReverts = [] + + def clearCompilerVariables(self): + """ + Clears all compiler variables that are specific to a single contract + """ + + self.currentContract = "" + self.symbols = [] # TODO: Don't clear symbols, but have a 'contract' field in Symbol, and include in every symbol lookup the contract name also + self.symbols.append(Symbol(_name="keccak256", _type="bytes32", _params=["bytes"], _scope="global", _isMethod=True, _isFunction=True)) + self.symbols.append(Symbol(_name="sha256", _type="bytes32", _params=["bytes"], _scope="global", _isMethod=True, _isFunction=True)) + self.symbols.append(Symbol(_name="ripemd160", _type="bytes20", _params=["bytes"], _scope="global", _isMethod=True, _isFunction=True)) + self.symbols.append(Symbol(_name="ecrecover", _type="address", _params=["bytes32", "uint8", "bytes32", "bytes32"], _scope="global", _isMethod=True, _isFunction=True)) + self.symbols.append(Symbol(_name="sum_mapping", _type="uint", _params=["mapping(address=>uint)"], _scope="global", _isFunction=True)) + self.symbols.append(Symbol(_name="addmod", _type="uint", _params=["uint", "uint", "uint"], _scope="global", _isMethod=True)) + self.symbols.append(Symbol(_name="mulmod", _type="uint", _params=["uint", "uint", "uint"], _scope="global", _isMethod=True)) + + self.enums = [] + self.structs = [] + self.constructorDefined = False + self.currentScope = "global" + self.isParam = False + self.isSpec = False + self.methodHasReturn = False + self.isInPost = False + self.reentrancyReverts = [] + + # move this function to a typechecker class + def isBaseType(self, typ): + if typ in ["int", "uint", "address", "bool", "string"]: + return True + else: + return False + + + def enterProgram(self, ctx:CelestialParser.ProgramContext): + self.SolidityCodegen.enterProgram() + + def exitProgram(self, ctx:CelestialParser.ProgramContext): + self.SolidityCodegen.exitProgram() + + def enterImportDirective(self, ctx:CelestialParser.ImportDirectiveContext): + self.SolidityCodegen.writeImportDirective(ctx) + + def enterPragmaDirective(self, ctx:CelestialParser.PragmaDirectiveContext): + self.SolidityCodegen.writePragmaDirective(ctx) + + def enterDatatype(self, ctx:CelestialParser.DatatypeContext): + """ + Verifies if maps contain keys that are not maps or arrays themselves + """ + + if ctx.MAP(): + if ctx.datatype(0).MAP() or ctx.datatype(0).arrayType: + revert (": Map cannot have map or array as key", ctx) + elif ctx.INSTMAP(): + if ctx.iden().Iden().getText() not in self.contracts: + revert (": inst_map expects contract type as argument", ctx.iden()) + + def enterContractDecl(self, ctx:CelestialParser.ContractDeclContext): + """ + On entering ContractDecl, the contract name is now known + The contract name is appended to the local list of contracts + The methodsOfContract dict is initialized with an empty method list for this contract name as key + The current contract is also set + This contract name is used to name the F* file and the F* module + FSTCodegen.enterContract() opens the F* file + FSTCodegen.enterContract() also writes some boilerplate code to the generated F* + """ + + self.clearCompilerVariables() + + contractName = ctx.name.Iden().getText() + self.methodsOfContract[contractName] = {} + self.FSTCodegen.invariantsOfContract[contractName] = [] + self.FSTCodegen.methodsOfContract[contractName] = {} + self.fieldsOfContract[contractName] = [] + self.currentContract = contractName + + self.FSTCodegen.setModuleName(contractName) + self.FSTCodegen.enterContract(self.contracts) + self.SolidityCodegen.enterContractDecl(ctx) + + self.contracts.append(contractName) + self.FSTCodegen.contracts.append(contractName) + self.SolidityCodegen.contracts.append(contractName) + + def exitContractDecl(self, ctx:CelestialParser.ContractDeclContext): + """ + FSTCodegen.exitContract() closes the F* file that was opened + Also, prints the symbol table to stdout if the printSymbolTable flag is set + """ + + # if not self.constructorDefined: + # self.FSTCodegen.writeDefaultConstructor(self.symbols, "constructor") + self.FSTCodegen.exitContract() + self.SolidityCodegen.exitContractDecl(ctx) + # Dev Options + if (self.printSymbolTableFlag): + self.printSymbolTable() + + def enterContractBody(self, ctx:CelestialParser.ContractBodyContext): + """ + Sets the current scope to "global" + Populates the symbol table with fields, functions, invariants and methods + Also checks if there is any redeclaration and throws if identifiers are redeclared + For each function, method and invariant, the argument types are also stored. + They are stored as an array of strings where each string is a type written just as it is in Celestial + This way of storing datatypes is a convention throughout + Arguments have a slightly different syntax compared to variable declarations. + For function declarations, if a map is passed as an argument, we check here that keys are only basic types + as it is not handled in enterVarDecl() + Ensures maps and arrays cannot be passed as arguments to or returned from methods + FSTCodegen.writeFieldRecords() generates the F* record of contract fields and writes it to the F* file + FST.Codegen.writeEffectDefinitions() and FSTCodegen.writeGetPutEmitSend() write more boilerplate code to the F* file + """ + + self.currentScope = "global" + for f in ctx.contractContents(): + if f.constructorDecl(): + self.constructorDefined = True + break + + for f in ctx.contractContents(): + if f.funDecl(): + funcName = f.funDecl().iden().Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(funcName): + revert (": Identifier '" + funcName + "' already used", f.funDecl()) + + # if not declared earlier, write to functions + self.FSTCodegen.functions[funcName] = f.funDecl().funParamList() # storing the entire object (args can be extracted and typechecked) + + # generating function signature + params = [] + if f.funDecl().funParamList(): + for parameter in f.funDecl().funParamList().funParam(): + params.append(parameter.datatype().getText()) + self.symbols.append(Symbol(funcName, "bool", params, "global", False, False, True, False, False, "")) + + # adding it's arguments to the symbol table + if f.funDecl().funParamList(): + params = f.funDecl().funParamList().funParam() + for param in params: + paramName = param.iden().Iden().getText() + # we're allowing same param names and field names because functions cannot access fields directly anyway + paramType = param.datatype().getText() + if self.isMapping(paramType): + keyType = self.getMapKeyType(paramType) + if (not self.isBaseType(keyType)): + revert (": Keys can only be a basic type", param.datatype()) + self.symbols.append(Symbol(paramName, paramType, [], funcName, _isParam=True, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=True, _mapKeyType=keyType)) + else: + self.symbols.append(Symbol(paramName, paramType, [], funcName, _isParam=True, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="")) + + elif f.methodDecl(): + methodDeclContext = f.methodDecl() + if methodDeclContext.name: + methodName = methodDeclContext.name.Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(methodName, "global"): + revert (": Identifier '" + methodName + "' already used", f.methodDecl()) + + # typechecking method argument types + if methodDeclContext.methodParamList(): + for parameter in methodDeclContext.methodParamList().methodParam(): + if (parameter.datatype().MAP()): + revert (": Methods cannot take maps as arguments", f.methodDecl()) + elif (parameter.datatype().arrayType): + revert (": Methods cannot take arrays as arguments", f.methodDecl()) + elif (parameter.datatype().EVENTLOG()): + revert (": Methods cannot take argument of type eventlog", f.methodDecl()) + elif (parameter.datatype().EVENT()): + revert (": Methods cannot take argument of type event", f.methodDecl()) + if methodDeclContext.datatype(): + # typechecking method return types + if methodDeclContext.datatype().arrayType or methodDeclContext.datatype().MAP(): + revert (": Methods cannot return arrays/maps", f.methodDecl()) + methodReturnType = methodDeclContext.datatype().getText() + else: + methodReturnType = "void" + + # if not declared earlier, write to methods + self.FSTCodegen.methods[methodName] = methodDeclContext.datatype() # None if void + self.methodsOfContract[self.currentContract][methodName] = () + self.FSTCodegen.methodsOfContract[self.currentContract][methodName] = () + + returnVar = "" + if methodDeclContext.returnval: + returnVar = methodDeclContext.returnval.Iden().getText() + self.symbols.append(Symbol(returnVar, methodReturnType, _params=[], _scope=methodName, _isParam=False, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=False)) + + # generating method signature + params = [] + if methodDeclContext.methodParamList(): + for parameter in methodDeclContext.methodParamList().methodParam(): + params.append(parameter.datatype().getText()) + self.symbols.append(Symbol(methodName, methodReturnType, params, "global", _isParam=False, _isMethod=True, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=False, _returnVar=returnVar)) + + # adding the method to methodsOfContract + self.methodsOfContract[self.currentContract][methodName] = (methodReturnType, params) + self.FSTCodegen.methodsOfContract[self.currentContract][methodName] = (methodReturnType, params) + + # adding it's arguments to the symbol table + if methodDeclContext.methodParamList(): + params = methodDeclContext.methodParamList().methodParam() + for param in params: + paramName = param.iden().Iden().getText() + if self.checkIdentifierDeclared(paramName, "global"): + revert (": Variable '" + paramName + "' redeclared", f.methodDecl()) + paramType = param.datatype().getText() + self.symbols.append(Symbol(paramName, paramType, [], methodName, True, False)) + #TODO: Else ensure fallback doesn't have arguments + # also ensure there is only one of them defined + if methodDeclContext.spec() and methodDeclContext.spec().rreverts: + self.reentrancyReverts.append(methodDeclContext.spec().rreverts) + + elif f.enumDecl(): + enumName = f.enumDecl().name.Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(enumName): + revert (": Identifier '" + enumName + "' already used", f.enumDecl()) + + # if not declared, append to self.enums and write to FSTCodegen.enumTypes and SolidityCodegen.enumTypes + self.enums.append(enumName) + self.FSTCodegen.enumTypes.append(enumName) + self.SolidityCodegen.enumTypes.append(enumName) + + # writing the enumValues for the enumType to self.symbols and FSTCodegen.enumValues + for iden in f.enumDecl().iden(): + enumValueName = iden.Iden().getText() + if enumValueName == enumName: + continue + if self.checkIdentifierDeclared(enumValueName): + revert (": Identifier '" + enumValueName + "' already used", f.enumDecl()) + self.symbols.append(Symbol(_name=enumValueName, _type=enumName, _scope="global", _isEnumValue=True)) + self.FSTCodegen.enumValues[enumValueName] = enumName + + # writing the enum declaration to Solidity + self.SolidityCodegen.writeEnumDecl(f.enumDecl()) + + elif f.varDecl(): + fieldName = f.varDecl().iden().Iden().getText() + + # check if field has already been declared + if (self.FSTCodegen.existsField(fieldName)): + revert (": Field '" + fieldName + "' already used", f.varDecl()) + + # check if the identifier has already been declared before + if (self.FSTCodegen.existsMethod(fieldName) or self.FSTCodegen.existsInvariant(fieldName) or self.FSTCodegen.existsFunction(fieldName)): + revert (": Identifier '" + fieldName + "' already used", f.varDecl()) + + # if not declared earlier, write to fields and symbol table + fieldtypeObject = f.varDecl().datatype() + fieldType = fieldtypeObject.getText() + self.FSTCodegen.fields[fieldName] = fieldtypeObject + if (fieldtypeObject.MAP()): + keyType = fieldtypeObject.keyType.getText() # TODO check if map key type handling is done in vardecl only or have to do here also + self.symbols.append(Symbol(_name=fieldName, _type=fieldType, _scope="global", _isMap=True, _mapKeyType=keyType)) + elif fieldtypeObject.name: + datatypeName = fieldtypeObject.name.Iden().getText() + if datatypeName in self.structs: + self.symbols.append(Symbol(_name=fieldName, _type=datatypeName, _scope="global", _isStructObject=True)) + elif datatypeName in self.enums: + self.symbols.append(Symbol(_name=fieldName, _type=datatypeName, _scope="global")) + elif datatypeName in self.contracts[0:self.contracts.index(self.currentContract)]: + self.symbols.append(Symbol(_name=fieldName, _type=datatypeName, _scope="global", _isContractObject=True)) + else: + self.symbols.append(Symbol(_name=fieldName, _type=fieldType, _scope="global")) + self.fieldsOfContract[self.currentContract].append((fieldName, fieldType, False)) + if f.varDecl().expr(): + # TODO: Typecheck this expression, and check if its type matches the field type + self.FSTCodegen.initialFieldValues[fieldName] = f.varDecl().expr() + + elif f.structDecl(): + structContext = f.structDecl() + structName = structContext.name.Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(structName): + revert ("Identifier '" + structName + "' already used", structContext) + + structFieldTypes = [] + # checking if the field names have been used before, and adding them to the symbol table + numberOfStructFields = len(structContext.datatype()) + for i in range(numberOfStructFields): + structFieldName = structContext.iden(i+1).Iden().getText() + if self.checkIdentifierDeclared(structFieldName): + revert ("Identifier '" + structFieldName + "' already used", structContext) + structFieldType = structContext.datatype(i).getText() + structFieldTypes.append(structFieldType) + if "mapping" in structFieldType: + keyType = self.getMapKeyType(structFieldType) + if (not self.isBaseType(keyType)): + revert (": Keys can only be a basic type", structContext) + self.symbols.append(Symbol(_name=structFieldName, _scope="global", _type=structFieldType, _isMap=True, _mapKeyType=keyType, _isStructField=True, _fieldOfStruct=structName)) + else: + self.symbols.append(Symbol(_name=structFieldName, _scope="global", _type=structFieldType, _isStructField=True, _fieldOfStruct=structName)) + + # adding the struct itself to the symbol table and self.structs + self.structs.append(structName) + self.symbols.append(Symbol(_name=structName, _params=structFieldTypes, _scope="global", _type=structName, _isStructType=True)) + self.SolidityCodegen.writeStruct(structContext) + + elif f.invariantDecl(): + invariantName = f.invariantDecl().iden().Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(invariantName): + revert (": Identifier '" + invariantName + "' already used", f.enumDecl()) + + # if not declared earlier, write to invariants and symbol table + self.FSTCodegen.invariants.append(invariantName) + self.FSTCodegen.invariantsOfContract[self.currentContract].append(invariantName) + self.symbols.append(Symbol(invariantName, "logical", [], "global", False, False, False, True)) + + elif f.constructorDecl(): #TODO: Move to enterConstructorDecl + methodDeclContact = f.constructorDecl() + + # check if constructor already defined + if self.checkIdentifierDeclared("constructor"): # polymorphism not allowed for now + revert (": Constructor already declared", f.constructorDecl()) + + # typechecking method argument types + if methodDeclContact.methodParamList(): + for parameter in methodDeclContact.methodParamList().methodParam(): + if (parameter.datatype().MAP()): + revert (": Methods cannot take maps as arguments", f.constructorDecl()) + elif (parameter.datatype().arrayType): + revert (": Methods cannot take arrays as arguments", f.constructorDecl()) + elif (parameter.datatype().EVENTLOG()): + revert (": Methods cannot take argument of type eventlog", f.constructorDecl()) + elif (parameter.datatype().EVENT()): + revert (": Methods cannot take argument of type event", f.constructorDecl()) + # if methodDeclContact.datatype(): + # # typechecking method return types + # if methodDeclContact.datatype().arrayType or methodDeclContact.datatype().MAP(): + # revert (": Methods cannot return arrays/maps") + # methodReturnType = methodDeclContact.datatype().getText() + # else: + # methodReturnType = "void" + + self.FSTCodegen.methods["constructor"] = methodDeclContact + + returnVar = "" + # No return var in constructor + # if methodDeclContact.returnval: + # returnVar = methodDeclContact.returnval.Iden().getText() + # self.symbols.append(Symbol(returnVar, methodReturnType, _params=[], _scope=methodName, _isParam=False, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=False)) + + # generating method signature + params = [] + if methodDeclContact.methodParamList(): + for parameter in methodDeclContact.methodParamList().methodParam(): + params.append(parameter.datatype().getText()) + self.symbols.append(Symbol("constructor", "void", params, "global", _isParam=False, _isMethod=True, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=False, _returnVar=returnVar)) + + # adding the method to methodsOfContract + self.methodsOfContract[self.currentContract]["constructor"] = ("void", params) + self.FSTCodegen.methodsOfContract[self.currentContract]["constructor"] = ("void", params) + + # adding it's arguments to the symbol table + if methodDeclContact.methodParamList(): + params = methodDeclContact.methodParamList().methodParam() + for param in params: + paramName = param.iden().Iden().getText() + if self.checkIdentifierDeclared(paramName, "global"): + revert (": Variable '" + paramName + "' redeclared", f.constructorDecl()) + paramType = param.datatype().getText() + self.symbols.append(Symbol(paramName, paramType, [], "constructor", _isParam=True, _isMethod=False)) + + elif f.eventDecl(): + eventName = f.eventDecl().iden().Iden().getText() + + # check if the identifier has been declared before + if self.checkIdentifierDeclared(eventName): + revert(": Identifier '" + eventName + "' already used", f.eventDecl()) + + # if not declared earlier, write to events and symbol table + self.FSTCodegen.events.append(eventName) + + params = [] + for datatype in f.eventDecl().datatype(): + if datatype.MAP(): + revert (": Events cannot take a map as argument", f.eventDecl()) + params.append(datatype.getText()) + self.symbols.append(Symbol(eventName, "event", params, "global", _isParam=False, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=True)) + self.SolidityCodegen.writeEventDecl(f.eventDecl()) + + self.FSTCodegen.writeEventDeclarations() + self.FSTCodegen.writeEnums() + self.FSTCodegen.structs = self.structs + self.SolidityCodegen.structs = self.structs + self.FSTCodegen.writeStructDecl(self.structs, self.symbols) + self.FSTCodegen.writeFieldRecord(self.symbols) + self.FSTCodegen.writeAddressAndLiveness() + self.FSTCodegen.writeFieldGetterSetters(self.symbols) + + def enterUsingForDecl(self, ctx:CelestialParser.UsingForDeclContext): + self.SolidityCodegen.writeUsingForDecl(ctx, self.symbols) + + def enterVarDecl(self, ctx:CelestialParser.VarDeclContext): + """ + Checking if variables have been declared before + This check is only for fields and local variables; function/method arguments are handled separately inside `enterContractBody` + Variable names cannot be resued between fields and local variables/arguments + """ + + varName = ctx.iden().Iden().getText() + if (self.currentScope != "global"): + for sym in self.symbols: + if (sym.name == varName and (sym.scope == self.currentScope or sym.scope == "global")): + revert (": Variable redeclared", ctx) + + if ctx.datatype().EVENT() or ctx.datatype().EVENTLOG(): + revert (": Cannot create variable of type event or eventlog inside method", ctx) + if ctx.expr(): + rvalueType = self.exprType (ctx.expr(), self.currentScope) + if ctx.datatype().getText() != rvalueType: + if not (ctx.datatype().getText() == "address" and rvalueType in self.contracts): + revert (": Assignment type mismatch", ctx) + + self.symbols.append(Symbol(_name=varName, _type=ctx.datatype().getText(), _scope=self.currentScope, _isParam=self.isParam, _isLocal=True)) + self.FSTCodegen.writeVariable(ctx, self.symbols, self.currentScope) + + self.SolidityCodegen.enterVarDecl(ctx, self.currentScope, self.symbols) + + def enterInvariantDecl(self, ctx:CelestialParser.InvariantDeclContext): + """ + The expression inside an invariant should typecheck to boolean + Writes the invariant to the F* file + """ + + invariantName = ctx.iden().Iden().getText() + self.currentScope = invariantName + self.isSpec = True + self.FSTCodegen.writeInvariant(invariantName) + + def exitInvariantDecl(self, ctx:CelestialParser.InvariantDeclContext): + """ + Sets the current scope back to "global" after exiting the invariant body + """ + + self.currentScope = "global" + self.isSpec = False + + def enterInvariantBody(self, ctx:CelestialParser.InvariantBodyContext): + """ + Checks if the expression inside the invariant typechecks to boolean + Writes the invariant body to the F* file + """ + + expr = ctx.getChild(1) + if (self.exprType(expr, self.currentScope) != "bool"): + revert (": Invariants should have pure expressions of boolean type", ctx.getChild(1)) + self.FSTCodegen.writeInvariantBody(expr, self.symbols, self.currentScope) + if self.verificationMode == "VeriSol": + self.SolidityCodegen.appendInvariantBody(expr, self.symbols, self.currentScope) #Added for VeriSol + + def enterFDecl(self, ctx:CelestialParser.FunDeclContext): + """ + Sets current scope to the function name on entering the function + Needed to typecheck expressions inside the function body + Writes the function declaration to the F* file + The rest of the function (body) is typechecked to boolean and written to the F* file in `enterFunctionBody` + """ + + funcName = ctx.iden().Iden().getText() + self.currentScope = funcName + self.isSpec = True + self.FSTCodegen.writeFunction(ctx, self.symbols) + + def exitFDecl(self, ctx:CelestialParser.FunDeclContext): + """ + Sets current scope back to "global" after exiting the function body + """ + + self.currentScope = "global" + self.isSpec = False + + def enterFunctionBody(self, ctx:CelestialParser.FunctionBodyContext): + """ + Checks if the expression inside the function typechecks to boolean + Writes the function body to the F* file + disableFuncBooleanCheck is a flag to disable the above check to test expressions during compiler development + Expressions to be tested can be written inside a function no matter what they typecheck to + """ + + expr = ctx.getChild(1) + if not self.disableFuncBooleanCheck: # Dev Options + functionExprType = self.exprType(expr, self.currentScope) + if (functionExprType != "bool"): + revert (": Functions should have pure expressions of boolean type", ctx) + self.FSTCodegen.writeFunctionBody(expr, self.symbols, self.currentScope) + + def enterFunParamList(self, ctx:CelestialParser.FunParamListContext): + self.isParam = True # no need for this because the param declaration is different from a normal variable dec + # hence we are handling (adding to symtable) param variables differently anyway + # if it was the same, then ALL variables are added to symtable in enterVarDecl() and this line sets whether it is a param or not + + def exitFunParamList(self, ctx:CelestialParser.FunParamListContext): + self.isParam = False + + def enterConstructorDecl(self, ctx:CelestialParser.ConstructorDeclContext): + """ + Sets the current scope to "constructor" + Disallows writing pre-conditions for constructors + Checks if the post condition is a boolean expressions, and boolean formulae of function calls + Writes the constructor declaration to the F* file + Multiple constructor check is done in enterContractBody + """ + + self.currentScope = "constructor" + self.isInPost = False + + if ctx.spec(): + if ctx.spec().pre: + # We allow pre-conditions for constructor + preType = self.exprType(ctx.spec().pre, self.currentScope) + if (preType != "bool"): + revert (": Post-conditions can only be a boolean expression", ctx.spec().pre) + # if not self.checkPrePost(ctx.spec().pre): + # revert (": Post-conditions are boolean formulae of functions", ctx.spec().pre) + # revert (": Constructor cannot have a pre-condition") + if ctx.spec().post: + self.isInPost = True + postType = self.exprType(ctx.spec().post, self.currentScope) + if (postType != "bool"): + revert (": Post-conditions can only be a boolean expression", ctx.spec().post) + # if not self.checkPrePost(ctx.spec().post): + # revert (": Post-conditions are boolean formulae of functions", ctx.spec().post) + if ctx.spec().reverts: + self.isInPost = False + txrevertsType = self.exprType(ctx.spec().reverts, self.currentScope) + if (txrevertsType != "bool"): + revert (": Reverts-conditions can only be a boolean expression", ctx.spec().reverts) + # if not self.checkPrePost(ctx.spec().reverts): + # revert (": Reverts-conditions are boolean formulae of functions", ctx.spec().reverts) + if ctx.spec().DEBIT() and not ctx.spec().CREDIT(): + revert (": A constructor cannot debit without credit", ctx.spec().DEBIT()) + + self.FSTCodegen.writeConstructor(self.symbols, self.currentScope, ctx) + self.SolidityCodegen.writeConstructor(ctx) + + def exitConstructorDecl(self, ctx:CelestialParser.ConstructorDeclContext): + """ + Sets current scope back to "global" after exiting the constructor body + """ + + # self.FSTCodegen.exitWriteConstructor(ctx) + self.SolidityCodegen.exitWriteConstructor() + self.currentScope = "global" + + def enterMDecl(self, ctx:CelestialParser.MethodDeclContext): + """ + Sets the current scope to the method name + Checks if the pre and post conditions are boolean expressions, and boolean formulae of functions + Verifies the modifies clause to contain only field names + Writes the method declaration to the F* file + Writes the method spec to the F* file + """ + + if ctx.name: + methodName = ctx.name.Iden().getText() + elif ctx.RECEIVE(): + if self.verificationMode == "VeriSol": + revert (": VeriSol doesn't support receive function. Uptil Solidity version 0.5.10 is supported!", ctx.RECEIVE()) + else: + methodName = "receive" + else: + methodName = "fallback" + self.currentScope = methodName + + if ctx.spec(): + self.isSpec = True + if ctx.spec().pre: + self.isInPost = False + preType = self.exprType(ctx.spec().pre, self.currentScope) + if (preType != "bool"): + revert (": Pre-conditions can only be a boolean expression", ctx.spec().pre) + # if not self.checkPrePost(ctx.spec().pre): + # revert (": Pre-conditions are boolean formulae of functions", ctx.spec().pre) + if ctx.spec().post: + self.isInPost = True # not useful: 'error' + postType = self.exprType(ctx.spec().post, self.currentScope) + if (postType != "bool"): + revert (": Post-conditions can only be a boolean expression", ctx.spec().post) + # if not self.checkPrePost(ctx.spec().post): + # revert (": Post-conditions are boolean formulae of functions", ctx.spec().post) + if ctx.spec().reverts: + self.isInPost = False + txrevertsType = self.exprType(ctx.spec().reverts, self.currentScope) + if (txrevertsType != "bool"): + revert (": Reverts-conditions can only be a boolean expression", ctx.spec().reverts) + # if not self.checkPrePost(ctx.spec().reverts): + # revert (": Reverts-conditions are boolean formulae of functions", ctx.spec().reverts) + self.isSpec = False + if (ctx.modifies): + for rvalue in ctx.modifies.rvalue(): + if (rvalue.expr().getText() != "balance" and rvalue.expr().getText() != "log" and not self.FSTCodegen.existsField(rvalue.expr().getText())): + revert (": 'modifies' clause takes in only contract state variables", ctx.modifies) + + self.FSTCodegen.writeMethod(ctx, self.symbols, self.currentScope) # TODO: CurrentScope should be 'invariant' here + self.SolidityCodegen.writeMethod(ctx) + + def exitMDecl(self, ctx:CelestialParser.MDeclContext): + """ + Sets current scope back to "global" after exiting the method body + """ + + self.SolidityCodegen.exitWriteMethod() + self.currentScope = "global" + + def enterMethodBody(self, ctx:CelestialParser.MethodBodyContext): + """ + Disallows hanging block statements (grammar allows it) + Typecheck the return value and write it to F* + """ + + self.methodHasReturn = False + if ctx.statement(): + for statement in ctx.statement(): + if statement.LBRACE(): + revert (": Block statements only for if and for statment", ctx) + # if ctx.varDecl(): + # for variable in ctx.varDecl(): + # varName = variable.iden().Iden().getText() + # varTypeContext = variable.datatype() + # if varTypeContext.EVENT() or varTypeContext.EVENTLOG(): + # revert (": Cannot create variable of type event or eventlog inside method", ctx) + # if variable.expr(): + # if varTypeContext.getText() != self.exprType(variable.expr(), self.currentScope): + # revert (": ASsignment type mismatch") + # # self.symbols.append(Symbol(_name=varName, _type=varTypeContext.getText(), _scope=self.currentScope, _isLocal=True)) + # self.FSTCodegen.writeVariable(variable, self.symbols, self.currentScope) + + def exitMethodBody(self, ctx:CelestialParser.MethodBodyContext): + # if (not self.methodHasReturn): + # self.FSTCodegen.writeReturn(self.currentScope) + currentMethodReturnType = self.getIdenType(self.currentScope, self.currentScope) + valueReturned = ctx.returnStatement().expr() + if valueReturned: + if currentMethodReturnType == "void": + revert (": Not expecting a return value", ctx) + else: + valueReturnedType = self.exprType(valueReturned, self.currentScope, inFunctionCall=False) + if valueReturnedType != currentMethodReturnType: + revert(": Return expects a value of type " + currentMethodReturnType, ctx) + else: + self.FSTCodegen.writeReturnStatement(ctx.returnStatement(), self.symbols, self.currentScope, isVoid=False) + else: + if currentMethodReturnType != "void": + revert (": Expects a return value of type " + currentMethodReturnType, ctx.returnStatement()) + else: + # if self.currentScope != "constructor": + self.FSTCodegen.writeReturnStatement(ctx.returnStatement(), self.symbols, self.currentScope, isVoid=True) + + # for sym in self.symbols: + # if sym.scope == self.currentScope and sym.isLocal: + # self.symbols.remove(sym) + + def enterReturnStatement(self, ctx:CelestialParser.ReturnStatementContext): + self.SolidityCodegen.writeReturnStatement(ctx, self.symbols, self.currentScope) + + # def checkPrePost(self, ctx:CelestialParser.ExprContext): + # if ctx.method or (ctx.primitive() and ctx.primitive().BoolLiteral()): + # return True + # if ctx.LAND() or ctx.LOR(): + # return self.checkPrePost(ctx.expr(0)) and self.checkPrePost(ctx.expr(1)) + # elif ctx.LNOT(): + # return self.checkPrePost(ctx.expr(0)) + # elif ctx.LPAREN(0) and ctx.getChildCount() == 3: # (expr) + # return self.checkPrePost(ctx.expr(0)) + # else: + # return False + + def enterSpec (self, ctx:CelestialParser.SpecContext): + """ + Sets isSpec to True + """ + + self.isSpec = True + # if ctx.pre: + # preType = self.exprType(ctx.pre, self.currentScope) + # if (preType != "bool"): + # revert (": Pre-conditions can only be a boolean expression", ctx) + # if not self.checkPrePost(ctx.pre): + # revert (": Pre-conditions are boolean formulae of functions", ctx) + # if ctx.post: + # self.isInPost = True # not useful: 'error' + # postType = self.exprType(ctx.post, self.currentScope) + # if (postType != "bool"): + # revert (": Post-conditions can only be a boolean expression", ctx) + # if not self.checkPrePost(ctx.post): + # revert (": Post-conditions are boolean formulae of functions", ctx) + + def exitSpec (self, ctx:CelestialParser.SpecContext): + """ + Sets isSpec to False + """ + self.isSpec = False + self.isInPost = False + + def enterMethodParamList(self, ctx:CelestialParser.MethodParamListContext): + self.isParam = True # no need for this because the param declaration is different from a normal variable dec + # hence we are handling (adding to symtable) param variables differently (in enterContractBody itself) anyway + # if it was the same, then ALL variables are added to symtable in enterVarDecl() and this line sets whether it is a param or not + + def exitMethodParamList(self, ctx:CelestialParser.MethodParamListContext): + self.isParam = False + + def enterExpr(self, ctx:CelestialParser.ExprContext): + """ + Performing the following checks: + Invariants only operate on fields + Functions only operate on its arguments (pure) + Methods only operate on fields and its arguments + Enums are allowed in all + """ + # flag = False + # if (ctx.primitive() and ctx.primitive().iden() and not ctx.primitive().NEW()): + # varName = ctx.primitive().iden().Iden().getText() + # if varName not in self.enums: #TODO: Not a clean way of doing this + # isMFI = self.getIsMethodFuncInv(self.currentScope) + # if isMFI == "invariant": + # if not self.FSTCodegen.existsField(varName): # TODO: enums can be used + # revert (": Use of variable other than field variables inside invariants is not allowed", ctx) + # elif isMFI == "function": + # for sym in self.symbols: + # if sym.name == varName and sym.scope == self.currentScope: + # flag = True + # break + # if not flag: + # revert (": Variable " + varName + " not an argument to the function", ctx) + # elif isMFI == "method": + # for sym in self.symbols: + # if sym.name == varName and sym.scope in [self.currentScope, "global"]: + # flag = True + # break + # if not flag and varName != "eTransfer": + # revert (": Variable " + varName + " not declared", ctx) + + """ + Ensures functions and invariants cannot be called from inside methods + """ + if (not self.isSpec and ctx.method): #and ctx.getChildCount() == 4): + currentScopeType = self.getIsMethodFuncInv(self.currentScope) + callee = ctx.method.Iden().getText() + calleeType = self.getIsMethodFuncInv(callee) + if ((callee not in ["keccak256", "sha256", "ripemd160", "ecrecover"]) + and (calleeType in ["function", "invariant"])): + revert (": Methods cannot be called inside functions or invariants", ctx) + + """ + Ensures that only functions can be called in the 'pre' and 'post' + """ + if (self.isSpec and ctx.method): + callee = ctx.method.Iden().getText() + calleeType = self.getIsMethodFuncInv(callee) + if ((calleeType == "method" or calleeType == "invariant") + and (callee not in ["keccak256", "sha256", "ripemd160", "ecrecover"])): + revert (": Methods and invariants cannot be called from specifications", ctx.method) + + """ + Ensures that ite() can only be used in spec + """ + if (not self.isSpec and ctx.ITE()): + revert (": ite() cannot be used outside spec", ctx) + + # TODO: Add ==> operator + + # Typechecks the expression (it is redundant because it is recursive, but not optimizing the compiler at this stage) + # self.exprType(ctx, self.currentScope) + + def isArray(self, datatypeString): + """ + Given a string representing a type, returns if it + is an array or not + """ + + if datatypeString[-2:] == "[]": + return True + return False + + def isArrayOf(self, datatypeString): + """ + Given a string of the form "type[]", returns 'type' + """ + + start = datatypeString.find("[") + return datatypeString[0:start] + + def isMapping(self, datatypeString): + """ + Given a string representing a type, returns if it + is an array or not + """ + + if datatypeString[0:7] == "mapping": + return True + return False + + def getMapKeyType(self, mappingString): + """ + Given a string of the form 'mapping(type1 => type2), + returns the type of the key of the map 'type1' + """ + + start = mappingString.find("(") + 1 + end = mappingString.find("=>") + return mappingString[start:end] + + def getMapValueType(self, mappingString): + """ + Given a string of the form 'mapping(type1 => type2), + returns the type of the value of the map 'type2' + """ + + start = mappingString.find("=>") + 2 + end = mappingString.rfind(")") + return mappingString[start:end] + + # move the below function to a typechecker class? + def exprType(self, ctx, scope, inFunctionCall=False): + """ + Given an expression, returns the type of expression by recursively typechecking its children expressions + The type is represented as a string (for ex: "array[int]", "map[address, uint]") + For array or map access, the type returned is the value's type + For variable/field/method, the symbol table is looked up for the type + Otherwise, the type is determined based on the operator and operands + Expressions are also typechecked here (for ex, operators take operands of the same type, etc.) + The type is inferred (because it can be int or uint) for integer literals based on the surrounding context + """ + + if ctx.getChildCount() == 0: + return "" + c = ctx.getChild(0) + + # primitive + if (isinstance (c, CelestialParser.PrimitiveContext)): + if c.BoolLiteral(): + return "bool" + elif c.IntLiteral(): + return "int" + elif c.NullLiteral(): + return "address" + elif c.StringLiteral(): + return "string" + elif c.VALUE() or c.BDIFF() or c.BGASLIMIT() or c.BNUMBER() or c.BTIMESTAMP() or c.TXGASPRICE(): + flag = self.getIsMethodFuncInv(self.currentScope) + # if flag != "method": + # revert (": Cannot use '" + c.getText() + "' outside methods ", ctx) + return "uint" + elif c.BALANCE(): + flag = self.getIsMethodFuncInv(self.currentScope) + if flag != "method" and flag != "invariant": + revert (": Cannot use 'balance' outside methods, pre-post and invariants", ctx) + return "uint" + elif c.SENDER() or c.TXORIGIN() or c.BCOINBASE(): + flag = self.getIsMethodFuncInv(self.currentScope) + # if flag != "method": + # revert (": Cannot use '" + c.getText() + "' outside methods", ctx) + return "address" + elif c.LOG(): + flag = self.getIsMethodFuncInv(self.currentScope) + if flag != "method" and flag != "invariant" and not self.isSpec: + revert (": Cannot use 'log' outside pre-post and invariants", ctx) + return "eventlog" + elif c.THIS() or c.ADDR(): + return "address" # TODO: ContractType? or return scope + elif c.NEW(): + if not (self.FSTCodegen.existsField(c.iden().Iden().getText())): + revert (": new() used only for fields", ctx) + if not self.isInPost: + revert (": new() cannot be used in the pre or reverts conditions", ctx) + return self.getIdenType(c.iden().Iden().getText(), scope) + elif c.INT_MIN() or c.INT_MAX(): + return "int" + elif c.UINT_MAX(): + return "uint" + else: # getIdenType also checks if the variable has been declared or not + flag = False + varName = c.iden().Iden().getText() + for symbol in self.symbols: + if symbol.name == varName and symbol.isEnumValue: + revert (": enum value '" + varName + "' should be prefixed with '" + symbol.type + ".'", c.iden()) + if varName not in self.enums: #TODO: Not a clean way of doing this + isMFI = self.getIsMethodFuncInv(self.currentScope) + if isMFI == "invariant": + if not self.FSTCodegen.existsField(varName) and not self.getSym(varName).isQuantifierVar : # TODO: enums can be used + revert (": Use of variable other than field variables inside invariants is not allowed", ctx) + elif isMFI == "function": + if self.checkIdentifierDeclared(varName, self.currentScope): + flag = True + if not flag: + revert (": Variable " + varName + " not an argument to the function", ctx) + elif isMFI == "method": + for sym in self.symbols: + if sym.name == varName and sym.scope in [self.currentScope, "global"]: + flag = True + break + if not flag: + revert (": Variable " + varName + " not declared", ctx) + + return self.getIdenType(c.iden().Iden().getText(), scope) # TODO: when writing to symbols, scope=contractType for contract variables + + # LPAREN expr RPAREN + elif (c == ctx.LPAREN(0)): + return self.exprType(ctx.getChild(1), scope) + + # expr DOT field=iden + elif (ctx.DOT() and ctx.getChildCount() == 3): + # enumStruct = ctx.expr(0).primitive().iden().Iden().getText() + enumStruct = ctx.expr(0) + valueField = ctx.field.Iden().getText() + if enumStruct.primitive() and enumStruct.primitive().iden().Iden().getText() in self.enums: + enumStruct = enumStruct.primitive().iden().Iden().getText() #self.exprType(enumStruct, self.currentScope, inFunctionCall) + for sym in self.symbols: + if sym.name == valueField: + # if not sym.isEnumValue: + # revert (": " + valueField + " is not a valid enum value of type " + enumStruct) + if sym.type != enumStruct: + revert (": '" + valueField + "' is not a valid enum value of type " + enumStruct) + return sym.type + else: + # lvalType = self.getIdenType(enumStruct, self.currentScope) + lvalType = self.exprType(enumStruct, self.currentScope, inFunctionCall) + if lvalType in self.structs: # Struct Field Access + rvalName = ctx.field.Iden().getText() + for sym in self.symbols: + if rvalName == sym.name: + if sym.fieldOfStruct != lvalType: + revert (": '" + rvalName + "' is not a field of struct '" + lvalType + "'") + return self.getIdenType(rvalName, self.currentScope) + + elif lvalType in self.contracts: # InstMap Field Access + fieldName = ctx.field.Iden().getText() + for fields in self.fieldsOfContract[lvalType]: + if fieldName == fields[0]: + return fields[1] + revert (": " + fieldName + " is not a field of contract " + lvalType, ctx.field) + + # if lvalType not in self.structs: + # revert (": '" + enumStruct.getText() + "' is not a valid struct object or enum type") + + + # if enumStruct not in self.enums: + # revert (": Enum not defined", ctx) + # enumValue = ctx.field.Iden().getText() + # for sym in self.symbols: + # if sym.name == enumValue: + # if sym.type != enumStruct: + # revert (": Wrong enum") + # return sym.type + + # array=expr LBRACK index=expr RBRACK + # array=expr LENGTH LPAREN RPAREN + elif (ctx.array): + arrayOrMap = self.exprType(ctx.getChild(0), scope) + if self.isArray(arrayOrMap): + arrayValueType = self.isArrayOf(arrayOrMap) + if (ctx.LENGTH()): + return "uint" + else: + if (ctx.index.MAPUPD()): # If the index inside the [] has a => + updatedIndex = ctx.index.expr(0) + updatedIndexType = self.exprType(updatedIndex, scope) + # If the lhs of the => expression isn't an uint or a IntLiteral, revert + if (updatedIndexType != "uint" and not (updatedIndex.primitive() and updatedIndex.primitive().IntLiteral())): + revert (": Array expects index of type uint", updatedIndex) + # else return the entire array type. Eg: array[address] + return arrayOrMap + # Standard array access: check if the index is of type uint or is an IntLiteral and revert if not + elif (self.exprType(ctx.index, scope) != "uint") and not (ctx.index.primitive() and ctx.index.primitive().IntLiteral()): + revert (": Array expects index of type uint", ctx.index) + # if (ctx.index.MAPUPD()): + # if (self.exprType(ctx.index.expr(0), scope) != arrayValueType): + # if not (ctx.index.expr(0).primitive() and ctx.index.expr(0).primitive().IntLiteral() and arrayValueType in ["int", "uint"]): + # revert (": Array value type error", ctx.index.expr(0)) + # return arrayOrMap + # start = arrayOrMap.find("[") + 1 + # end = arrayOrMap.find("]") + # arrayValueType = arrayOrMap[start:end] + # else return the value type of the array (array access) + return arrayValueType + # else: + # print (self.exprType(ctx.index, scope)) + # revert (": Array access expects index type uint", ctx) + elif self.isMapping(arrayOrMap): + if (ctx.LENGTH()): + revert (".length() is not defined for maps", ctx) + else: + keyType = self.getMapKeyType(arrayOrMap) + valueType = self.getMapValueType(arrayOrMap) + if ctx.index.MAPUPD(): # TODO: Do this check separately + if (self.exprType(ctx.index.expr(0), scope) != keyType): + if not (ctx.index.expr(0).primitive() and ctx.index.expr(0).primitive().IntLiteral() and keyType in ["int", "uint"]): + revert (": Key error", ctx.index.expr(0)) + if (self.exprType(ctx.index.expr(1), scope) != valueType): + if not (ctx.index.expr(1).primitive() and ctx.index.expr(1).primitive().IntLiteral() and valueType in ["int", "uint"]): + revert (": Value error", ctx) + return arrayOrMap + elif (self.exprType(ctx.index, scope) != keyType): + if not (ctx.index.primitive() and ctx.index.primitive().IntLiteral()) and keyType in ["int", "uint"]: + revert (": Map access expects key type " + keyType, ctx) + return valueType + else: + return valueType + elif arrayOrMap[0:8] == "inst_map": + if (ctx.LENGTH()): + revert (".length() is not defined for inst_maps", ctx) + if ctx.index.MAPUPD(): # TODO: Do this check separately + if (self.exprType(ctx.index.expr(0), scope) != "address"): + revert (": Key error : inst_map expects key of type address", ctx) + if (self.exprType(ctx.index.expr(1), scope) != "bool"): + revert (": Value error : inst_map expects value of type bool", ctx) + return arrayOrMap + if (self.exprType(ctx.index, scope) != "address"): + revert (": Key error : inst_map expects key of type address", ctx) + return arrayOrMap[9:-1] + else: # 5[1], etc + revert (": Not a valid map/array", ctx) + + # method=iden LPAREN rvalueList? RPAREN + elif (ctx.method and not ctx.DOT()): + methodName = ctx.method.Iden().getText() + + if methodName in self.contracts: # ContractName(values_of_fields) + if self.getIsMethodFuncInv(self.currentScope) == "method": + revert (": (...) can be used only in functions and invariants", ctx) + contractFieldSignature = self.fieldsOfContract[methodName] # list of tuples (fieldName, fieldType) + if ctx.rvalueList(): + if len(contractFieldSignature) != len(ctx.rvalueList().rvalue()): + revert (": Incorrect number of arguments passed", ctx) + i = 0 + for param in ctx.rvalueList().rvalue(): # The order of args passed should be in the order of the fields declared + argType = self.exprType(param.expr(), scope, inFunctionCall=True) + supposedToBeType = contractFieldSignature[i][1] + if (argType != supposedToBeType): + if not (param.expr().primitive() and param.expr().primitive().IntLiteral() and supposedToBeType == "uint"): + revert (": Field '" + contractFieldSignature[i][0] + "' is of type '" + supposedToBeType + "' not " + argType, ctx) + i = i + 1 + return methodName + + else: # Normal method/function calls + methodReturnType = self.getIdenType(methodName, "global") # also checks whether variable has been declared or not + i = 0 + symbol = None + for sym in self.symbols: + if sym.name == methodName and (sym.scope == scope or sym.scope == "global"): # can remove the scope check, same otherwise + symbol = sym + break + + numberOfPassedArguments = 0 + if ctx.rvalueList(): + numberOfPassedArguments = len(ctx.rvalueList().rvalue()) + + if len(symbol.params) != numberOfPassedArguments: + revert (": Method/function call arguments does not match function signature", ctx) + + if ctx.rvalueList(): + for param in ctx.rvalueList().rvalue(): + argType = self.exprType(param.expr(), scope, inFunctionCall=True) + if (argType != symbol.params[i]): + if not (param.expr().primitive() and param.expr().primitive().IntLiteral() and symbol.params[i] == "uint"): + revert (": Method/function call arguments does not match function signature", ctx) + i = i + 1 + + # Void functions cannot be used in expressions + if methodReturnType == "void": + revert (": Cannot use a void function in an expression", ctx) + else: + return methodReturnType + + # op=(SUB | LNOT) expr + elif (ctx.SUB() and (ctx.getChildCount() == 2)): + if (self.exprType(ctx.expr(0), scope) not in ["int", "uint"]): + revert (": - used only for int/uint", ctx) + else: + return "int" + + # op=(SUB | LNOT) expr + elif (ctx.LNOT() and (ctx.getChildCount() == 2)): + if (self.exprType(ctx.expr(0), scope) != "bool"): + revert (": ! used only for bool", ctx) + else: + return "bool" + + # lhs=expr op=(ADD | SUB) rhs=expr + # lhs=expr op=(MUL | DIV) rhs=expr + elif (ctx.PLUS() or ctx.SUB() or ctx.MUL() or ctx.DIV() or ctx.MOD() + or ctx.SAFEADD() or ctx.SAFESUB() or ctx.SAFEMUL() or ctx.SAFEDIV() or ctx.SAFEMOD()): + op1 = ctx.lhs + op2 = ctx.rhs + if (op2.primitive() and op2.primitive().IntLiteral()): + op1type = self.exprType(op1, scope) + if op1type == "int": + return "int" + elif op1type == "uint": + return "uint" + else: + revert (": Arithmetic operators are defined only on int and uint and both operands should be int or uint", ctx) + elif (op1.primitive() and op1.primitive().IntLiteral()): + op2type = self.exprType(op2, scope) + if op2type == "int": + return "int" + elif op2type == "uint": + return "uint" + else: + revert (": Arithmetic operators are defined only on int and uint and both operands should be int or uint", ctx) + else: + op1type = self.exprType(op1, scope) + op2type = self.exprType(op2, scope) + if (op1type == op2type and op1type == "int"): + return "int" + elif (op1type == op2type and op1type == "uint"): + return "uint" + else: + revert (": Arithmetic operators are defined only on int and uint and both operands should be int or uint", ctx) + + # lhs=expr op=(LT | GT | GE | LE | IN) rhs=expr + elif (ctx.LT() or ctx.GT() or ctx.GE() or ctx.LE()): + op1 = ctx.getChild(0) + op2 = ctx.getChild(2) + if (op2.primitive() and op2.primitive().IntLiteral()): + op1type = self.exprType(op1, scope) + if op1type in ["int", "uint"]: + return "bool" + else: + revert (": Comparision operators are defined only on int and uint and both operands should be int or uint", ctx) + elif (op1.primitive() and op1.primitive().IntLiteral()): + op2type = self.exprType(op2, scope) + if op2type in ["int", "uint"]: + return "bool" + else: + revert (": Comparision operators are defined only on int and uint and both operands should be int or uint", ctx) + else: + op1type = self.exprType(op1, scope) + op2type = self.exprType(op2, scope) + if (op1type == op2type and op1type in ["int", "uint"]): + return "bool" + else: + revert (": Comparision operators are defined only on int and uint and both operands should be int or uint", ctx) + + elif (ctx.IN()): + isMFI = self.getIsMethodFuncInv(self.currentScope) + # if isMFI == "method": + # print (ctx.getText()) + # revert (": 'in' cannot be used inside methods") + op1 = ctx.getChild(0) + op2 = ctx.getChild(2) + op1Type = self.exprType(op1, scope) + op2Type = self.exprType(op2, scope) + if not self.isMapping(op2Type) and op2Type[0:8] != "inst_map" : + revert (": 'in' is defined only on maps", ctx) + if self.isMapping(op2Type) and op1Type != self.getMapKeyType(op2Type): #TODO: Handle if keyType is int, then constant primitive etc + revert (": first operand of in has to be of keyType of map") + elif op2Type[0:8] == "inst_map" and (op1Type != (op2Type[9:-1]) and op1Type != "address"): + revert (": first operand of in has to be of type " + op2Type[9:-1]) + return "bool" + + # lhs=expr op=(EQ | NE) rhs=expr + elif (ctx.EQ() or ctx.NE()): + op1 = ctx.getChild(0) + op2 = ctx.getChild(2) + op1type = self.exprType(op1, scope) + op2type = self.exprType(op2, scope) + if (op1type == op2type): + if self.isSpec: # maps and arrays can be compared in spec + if self.isMapping(op1type): + self.FSTCodegen.temp = "mapping" + return "bool" + elif self.isBaseType(op1type) or op1type in self.enums: + return "bool" + elif (op1type != op2type) and ((op2type in ["int", "uint"] and op1.primitive() and op1.primitive().IntLiteral()) or (op1type in ["int", "uint"] and op2.primitive() and op2.primitive().IntLiteral())): + return "bool" + elif (op1type != op2type and ((op1type == "address" and op2type in self.contracts) or (op1type in self.contracts and op2type == "address"))): # can compare contract instances to addresses/null + return "bool" + else: + revert (": invalid use of == or != (operands have to be of same type)", ctx) + + # lhs=expr op=LAND rhs=expr + # lhs=expr op=LOR rhs=expr + elif (ctx.LAND() or ctx.LOR()): + op1 = ctx.getChild(0) + op2 = ctx.getChild(2) + op1type = self.exprType(op1, scope) + op2type = self.exprType(op2, scope) + if not (op1type == "bool" and op2type == "bool"): + revert (": && and || are defined only on booleans", ctx) + return "bool" + + # ITE + elif (ctx.ITE()): + isMFV = self.getIsMethodFuncInv(self.currentScope) + if isMFV == "method" and not self.isSpec: + revert (": ite() cannot be used in methods", ctx) + condition = ctx.condition + thenBranch = ctx.thenBranch + elseBranch = ctx.elseBranch + conditionType = self.exprType(condition, scope) + thenBranchType = self.exprType(thenBranch, scope) + elseBranchType = self.exprType(elseBranch, scope) + if (not (conditionType == "bool" and thenBranchType == "bool" and elseBranchType == "bool")): + revert (": All expressions in ite() should be of boolean type", ctx) + return "bool" + + # TODO: complete for all comma separated exprs + elif (ctx.MAPUPD()): + if (self.getIsMethodFuncInv(self.currentScope) == "method" and not self.isSpec): + revert (": mapupd cannot be used inside methods", ctx) + lhsType = self.exprType(ctx.expr(0), scope) + rhsType = self.exprType(ctx.expr(1), scope) # Because this RHS is never typechecked otherwise + # Also check for the correct key value type + # return "map[" + lhsType + "=>" + rhsType + "]" + return rhsType + + elif (ctx.IMPL() or ctx.BIMPL()): + if (self.getIsMethodFuncInv(self.currentScope) == "method" and not self.isSpec): + revert (": ==> cannot be used inside methods") + expr1Type = self.exprType(ctx.expr(0), scope, inFunctionCall) + expr2Type = self.exprType(ctx.expr(1), scope, inFunctionCall) + if expr1Type != "bool" or expr2Type != "bool": + revert (": Both expressions for ==> have to be of type bool", ctx) + return "bool" + + elif (ctx.FORALL() or ctx.EXISTS()): + isMFI = self.getIsMethodFuncInv(self.currentScope) + if isMFI == "method" and (not self.isSpec): + revert (": Cannot use " + ctx.getChild(0).getText() + " inside a method") + for funParam in ctx.funParamList().funParam(): + paramName = funParam.name.Iden().getText() + if self.checkIdentifierDeclared(paramName): + revert (": Identifier " + paramName + " already used", funParam.name) + paramType = funParam.datatype().getText() + self.symbols.append(Symbol(_name=paramName, _type=paramType, _scope=self.currentScope, _isQuantifierVar=True)) + if self.exprType(ctx.expr(0), self.currentScope) != "bool": + revert (": forall/exists takes a boolean predicate as the second argument", ctx.expr(0)) + for param in ctx.funParamList().funParam(): + paramName = param.name.Iden().getText() + paramType = param.datatype().getText() + self.symbols.remove(Symbol(_name=paramName, _type=paramType, _scope=self.currentScope, _isQuantifierVar=True)) + return "bool" + + # iden LPAREN expr RPAREN //# CastExpr + # NEW contractName=iden LPAREN rvalueList? RPAREN //# CreateExpr + # TODO: Can be removed because there is a separate create statement + elif (ctx.NEW() and ctx.getChildCount() == 5): + newContractOf = ctx.contractName.Iden().getText() + flag = True + currentContractIndex = self.contracts.index(self.currentContract) + for i in range (currentContractIndex): + if self.contracts[i] == newContractOf: + flag = False + break + if flag: + revert (": Contract " + newContractOf + " not found", ctx.contractName) + return newContractOf + + elif (ctx.DEFAULT()): + if (self.getIsMethodFuncInv(self.currentScope) == "method"): + revert (": 'default()' cannot be used inside methods", ctx) + if (ctx.datatype().EVENTLOG() or ctx.datatype().EVENT()): + revert (": 'default()' for eventlog or event is undefined.", ctx.datatype()) + return ctx.datatype().getText() + + # iden DOT ADD LPAREN NEW iden LPAREN rvalueList? RPAREN RPAREN SEMI //# InstMapAdd + # Adding to a inst_map using new() + elif (ctx.ADD()): + instmapName = ctx.instmap.Iden().getText() + instmapType = self.getIdenType(instmapName, scope) + instmapOf = "" + if instmapType[0:8] != "inst_map": + revert (": .add() is defined only for inst_maps", ctx.instmap) + else: + instmapOf = instmapType[9:instmapType.find(">")] + + newContractOf = ctx.contractName.Iden().getText() + + flag = True + currentContractIndex = self.contracts.index(self.currentContract) + for i in range (currentContractIndex): + if self.contracts[i] == newContractOf: + flag = False + break + if flag: + revert (": Contract " + newContractOf + " not found") + + if instmapOf != newContractOf: + revert (": contract created does not match type of instmap (" + instmapOf + ")", ctx.contractName) + + return newContractOf + + # TODO: Different contract method call + # contractInstance=lvalue DOT method=iden LPAREN rvalueList? RPAREN + + elif (ctx.logcheck()): + # for log in ctx.logcheck(): + if not ctx.logName.LOG(): + for symbol in self.symbols: + if symbol.name == ctx.logName.getText() and symbol.scope == scope: + if symbol.type != "eventlog": + revert (": A value of type 'eventlog' has to follow ::", ctx.logName) + # logType = self.exprType(logName, scope) + #TODO: Check all logchecks + # if logType != "eventlog": + # revert (": " + logName + " has to be of type log", ctx.logName) + return "eventlog" + + elif (ctx.PAYABLE()): + if self.verificationMode == "VeriSol": + revert (": VeriSol doesn't support payable" + ctx.PAYABLE()) #Added for VeriSol compatibility. + else: + return self.exprType(ctx.expr(0), scope) + + elif (ctx.method and ctx.DOT()): + if ctx.iden(0).Iden().getText() == "abi": + if ctx.method.Iden().getText() in ["encode", "encodePacked", "encodeWithSelector", "encodeWithSignature"]: + return "bytes" + + def lvalueType(self, ctx:CelestialParser.LvalueContext, scope): + """ + Similar to exprType but for the lvalue production rule to typecheck assignment, create and delete statements + """ + + if ctx.name: + return self.getIdenType(ctx.iden().Iden().getText(), scope) # also checks whether variable declared or not + + elif ctx.LBRACK(): + arrayOrMap = self.lvalueType(ctx.getChild(0), scope) + + if self.isArray(arrayOrMap): + if (ctx.expr()): + if (ctx.expr().primitive() and ctx.expr().primitive().IntLiteral()) or (self.exprType(ctx.expr(), scope) == "uint"): + start = arrayOrMap.find("[") + 1 + end = arrayOrMap.rfind("]") + arrayValueType = arrayOrMap[start:end] + return arrayValueType + else: + revert (": Array access expects index type uint", ctx) + elif self.isMapping(arrayOrMap): + keyType = self.getMapKeyType(arrayOrMap) + if (self.exprType(ctx.expr(), scope) != keyType): + if not (ctx.expr().primitive() and ctx.expr().primitive().IntLiteral()) and keyType in ["int", "uint"]: + revert (": Map access expects key type " + keyType, ctx) + # else: + valueType = self.getMapValueType(arrayOrMap) + return valueType + elif arrayOrMap[0:8] == "inst_map": + if (self.exprType(ctx.expr(), scope) != "address"): + revert (": Key error : inst_map expects key of type address", ctx) + return arrayOrMap[9:-1] + else: # 5[1], etc + revert (": Not a valid map/array", ctx) + + #TODO : lvalue DOT field=iden + elif ctx.DOT() and ctx.getChildCount() == 3: + lvalType = self.lvalueType(ctx.getChild(0), scope) + if lvalType not in self.structs: + revert (": '" + lvalName + "' is not a valid struct object") + lvalName = ctx.getChild(0).getText() + rvalName = ctx.field.Iden().getText() + + for sym in self.symbols: + if sym.name == rvalName and sym.fieldOfStruct != lvalType: + revert (": Field '" + rvalName + "' does not belong to struct") + + return self.getIdenType(rvalName, scope) + + def enterStatement(self, ctx:CelestialParser.StatementContext): + + # Push Statement + # name=expr DOT PUSH LPAREN value=expr RPAREN SEMI + if ctx.PUSH(): + # if not (ctx.name.primitive() and ctx.name.primitive().iden()): + # revert (": push() is defined only for arrays") + # idenName = ctx.name.primitive().iden() + idenType = self.lvalueType(ctx.arrayName, self.currentScope) + if not self.isArray(idenType): # TODO: Correct this + revert (": push() is defined only for arrays", ctx) + + # Type of the value pushed to the array + valueType = self.exprType(ctx.value, self.currentScope) + + # The actual type of the array + arrayValueType = self.isArrayOf(idenType) # self.getArrayValueType(arrayName, self.currentScope) + + if ctx.arrayName.name: # Eg: variable.push() + arrayName = ctx.arrayName.iden().Iden().getText() + else: # Eg: variable[e].push() + end = ctx.arrayName.getText().find("[") + arrayName = ctx.arrayName.getText()[0:end] + if valueType != arrayValueType: + revert(": " + ctx.arrayName.getText() + ".push() expects a value of type " + arrayValueType, ctx) + self.FSTCodegen.writePushStatement(ctx, self.symbols, self.currentScope, arrayName) + + elif ctx.POP(): + idenType = self.lvalueType(ctx.arrayName, self.currentScope) + if not self.isArray(idenType): # TODO: Correct this + revert (": pop() is defined only for arrays", ctx) + arrayName = "" + if ctx.arrayName.name: # Eg: variable.pop() + arrayName = ctx.arrayName.iden().Iden().getText() + else: # Eg: variable[e].pop() + end = ctx.arrayName.getText().find("[") + arrayName = ctx.arrayName.getText()[0:end] + self.FSTCodegen.writePopStatement(ctx, self.symbols, self.currentScope, arrayName) + + # Delete Statement + elif ctx.DELETE(): + # TODO: DOT + + # Get the name of the variable + if ctx.toDelete.name: + varName = ctx.toDelete.iden().Iden().getText() + else: + end = ctx.toDelete.getText().find("[") + varName = ctx.toDelete.getText()[0:end] + + # Check if that variable is a field + if not self.FSTCodegen.existsField(varName): + revert(": delete() works only for state variables", ctx) + + varType = self.lvalueType(ctx.toDelete, self.currentScope) + # varType = self.getIdenType(varName, self.currentScope) wrong + # If the variable is an array, typecheck its index if it has one + if self.isArray(varType): + if ctx.value: # It may not have an index (delete arrayName works) + deleteIndex = self.exprType(ctx.value, self.currentScope) + if deleteIndex != "uint" and not (ctx.value.primitive() and ctx.value.primitive().IntLiteral()): + revert(": Array index should be uint", ctx) + # If the variable is a map, typecheck its key + elif self.isMapping(varType): + if not ctx.value: # It is compulsory to have a key (delete mapName is wrong) + revert (": delete() cannot be applied to mapping", ctx) + else: + mapValueType = self.getMapValueType(varType) + if self.isMapping(mapValueType): # If it has a key but the value is also a map + revert (": delete() cannot be applied to map", ctx) # Example: the initial map was map[c => map[a => b]] + else: # Typecheck the map value now + deleteIndex = self.exprType(ctx.value, self.currentScope) + if deleteIndex != self.getMapKeyType(varType): + revert (": map expects a key of type " + mapValueType, ctx) + elif varType[0:8] == "inst_map": + if not ctx.value: + revert (": delete() cannot be applied to mapping (an index has to be provided)", ctx) + else: + instMapType = varType[9:-1] + providedIndexType = self.exprType(ctx.value, self.currentScope) + if providedIndexType != instMapType and providedIndexType != "address": + revert (": key has to be of type " + instMapType + " or address", ctx.value) + # If the variable is neither an array nor map not instmap but has an index + else: + if ctx.value: + revert (": Index provided for non-array/map type", ctx) + + self.FSTCodegen.writeDeleteStatement(ctx, self.symbols, self.currentScope) + + # Assert Statement + # ASSERT expr (COMMA StringLiteral)? SEMI + elif ctx.ASSERT(): + exprType = self.exprType(ctx.expr(0), self.currentScope) + if exprType != "bool": + revert(": assert() expects a boolean condition", ctx) + self.FSTCodegen.writeAssertStatement(ctx, self.symbols, self.currentScope) + + # Create statement + elif ctx.NEW() and ctx.ASSIGN(): + contractInstanceType = self.lvalueType(ctx.assignTo, self.currentScope) + contractType = ctx.iden().Iden().getText() + if contractInstanceType != contractType: + revert (": " + ctx.assignTo.getText() + " not of contract type " + contractType, ctx) + self.FSTCodegen.writeNewStatement(ctx, self.symbols, self.currentScope) + + # Unkown call statements - 3 types possible + # a.call() + # bool s = a.call() + # s = a.call() + elif ctx.CALL() or ctx.CALLUINT() or ctx.CALLBOOL(): + + # Check if the '.call' is used on an 'address' type + calleeType = self.exprType(ctx.expr(0), self.currentScope) + if calleeType != "address": + revert(": '.call()' can only be used on addresses") + + # If a local variable is declared + if ctx.ASSIGN() and (ctx.BOOL() or ctx.UINT()): + varName = ctx.iden().getText() + + # Check if the variable is redeclared + for sym in self.symbols: + if (sym.name == varName and (sym.scope == self.currentScope or sym.scope == "global")): + revert (": Variable '" + varName + "' redeclared", ctx.expr(0)) + + # Add to the symbol table if it is not redeclared + self.symbols.append(Symbol(_name=varName, _type=ctx.getChild(0).getText(), _scope=self.currentScope, _isParam=False, _isLocal=True)) + + self.FSTCodegen.writeCallStatement(ctx, self.symbols, self.currentScope, self.reentrancyReverts) + + # Other contract method call statement + elif ctx.otherContractInstance and not ctx.ASSIGN(): + methodCalled = ctx.method.Iden().getText() + contractInstanceType = self.lvalueType(ctx.otherContractInstance, self.currentScope) + + # Checking if the method called is actually a method of the corresponding contract + if methodCalled not in self.methodsOfContract[contractInstanceType].keys(): + revert (": '" + methodCalled + "' not a method of contract " + contractInstanceType, ctx) + + # Checking if the arguments to the method match its signature + methodArgumentTypes = self.methodsOfContract[contractInstanceType][methodCalled][1] + if ctx.rvalueList(): + if len(methodArgumentTypes) != len(ctx.rvalueList().rvalue()): + revert (": Method/function call arguments do not match function signature", ctx) + i = 0 + for param in ctx.rvalueList().rvalue(): + argType = self.exprType(param.expr(), self.currentScope) + if (argType != methodArgumentTypes[i]): + if not (param.expr().primitive() and param.expr().primitive().IntLiteral() and methodArgumentTypes[i] == "uint"): + revert (": Method/function call arguments do not match function signature", ctx) + i = i + 1 + self.FSTCodegen.writeExternMethodCallStatement(ctx, self.symbols, self.currentScope)#, contractInstanceType) + + # Other contract method call and assigning return value + elif ctx.otherContractInstance and ctx.ASSIGN(): + self.FSTCodegen.writeCtAssignmentStatement(ctx, self.symbols, self.currentScope) + + # Return Statement + # RETURN expr? SEMI + # elif ctx.RETURN(): + # self.methodHasReturn = True + # currentFunctionReturnType = self.getIdenType(self.currentScope, self.currentScope) + # valueReturned = ctx.expr(0) + # if valueReturned: + # if currentFunctionReturnType == "void": + # revert (": Return value should not be present") + # else: + # valueReturnedType = self.exprType(valueReturned, self.currentScope) + # if valueReturnedType != currentFunctionReturnType: + # revert(": Invalid return type") + # else: + # self.FSTCodegen.writeReturnStatement(ctx, self.symbols, self.currentScope, False) + # else: + # if currentFunctionReturnType != "void": + # revert (": Expects a return value of type " + currentFunctionReturnType) + # else: + # self.FSTCodegen.writeReturnStatement(ctx, self.symbols, self.currentScope, True) + + # Assign Statement + elif ctx.assignment: + lhsType = self.lvalueType(ctx.assignTo, self.currentScope) + rhsType = self.exprType(ctx.rvalue().expr(), self.currentScope) + if lhsType != rhsType: + if not (lhsType == "address" and rhsType in self.contracts) and not (lhsType == "uint" and ctx.rvalue().expr().primitive() and ctx.rvalue().expr().primitive().IntLiteral().getText()): + revert (": Assignment statement type mismatch", ctx) + self.FSTCodegen.writeAssignmentStatement(ctx, self.symbols, self.currentScope) + + # If Statement + elif ctx.IF(): + conditionType = self.exprType(ctx.expr(0), self.currentScope) + if conditionType != "bool": + revert (": If condition should be a boolean expression", ctx) + self.FSTCodegen.writeIfStatement(ctx, self.symbols, self.currentScope) + # if ctx.elseBranch: + # self.FSTCodegen.writeStatement(ctx) + + # MethodCall Statement + elif ctx.method and not ctx.DOT(): + methodName = ctx.iden().Iden().getText() + methodReturnType = self.getIdenType(methodName, "global") # also checks whether method has been declared or not + + if self.getIsMethodFuncInv(methodName) in ["function", "invariant", "lemma"]: + revert (": Spec cannot be called from methods", ctx) + + i = 0 + symbol = None + for sym in self.symbols: + if sym.name == methodName and (sym.scope == self.currentScope or sym.scope == "global"): # can remove the scope check, same otherwise + symbol = sym + break + + numberOfPassedArguments = 0 + if ctx.rvalueList(): + numberOfPassedArguments = len(ctx.rvalueList().rvalue()) + + if len(symbol.params) != numberOfPassedArguments: + revert (": Method/function call arguments do not match function signature", ctx) + + if ctx.rvalueList(): + for param in ctx.rvalueList().rvalue(): + argType = self.exprType(param.expr(), self.currentScope) + if (argType != symbol.params[i]): + if not (param.expr().primitive() and param.expr().primitive().IntLiteral() and symbol.params[i] == "uint"): + revert (": Method/function call arguments do not match function signature", ctx) + i = i + 1 + + if methodReturnType == "void": + self.FSTCodegen.writeMethodCallStatement(ctx, self.symbols, self.currentScope, True) + else: + self.FSTCodegen.writeMethodCallStatement(ctx, self.symbols, self.currentScope, False) + + # Revert Statement + elif ctx.REVERT(): + self.FSTCodegen.writeRevertStatement(ctx) + + # Send Statement + # elif ctx.SEND(): + # payloadType = self.exprType(ctx.payload, self.currentScope, inFunctionCall=False) + # toType = self.exprType(ctx.contract, self.currentScope, inFunctionCall=False) + # if toType != "address": + # revert (": First arg of send is address", ctx) + + # if payloadType != "uint" and not (ctx.payload.primitive() and ctx.payload.primitive().IntLiteral()): + # revert (": eTransfer send expects a uint", ctx) + + # self.FSTCodegen.writeSendStatement(ctx, self.symbols, self.currentScope) + + elif ctx.TRANSFER(): + payloadType = self.exprType(ctx.amount, self.currentScope, inFunctionCall=False) + toType = self.exprType(ctx.to, self.currentScope, inFunctionCall=False) + if toType != "address": + revert (": 'transfer' is defined only on addresses", ctx.to) + + if payloadType != "uint" and not (ctx.amount.primitive() and ctx.amount.primitive().IntLiteral()): + revert (": 'transfer' expects a uint", ctx) + + self.FSTCodegen.writeTransferStatement(ctx, self.symbols, self.currentScope) + + + elif ctx.EMIT(): + eventName = ctx.event.Iden().getText() + requiredPayloadTypes = [] + for sym in self.symbols: + if sym.name == eventName: + requiredPayloadTypes = sym.params + break + + numberOfProvidedArguments = len(ctx.expr()) + numberOfRequiredArguments = len(requiredPayloadTypes) + if (numberOfProvidedArguments != numberOfRequiredArguments): + revert (": Got " + str(numberOfProvidedArguments) + " arguments, expected " + str(numberOfRequiredArguments) + " for event '" + eventName + "'", ctx.expr()[-1]) + + for (payloadExpr, requiredPayloadType) in zip(ctx.expr(), requiredPayloadTypes): + payloadType = self.exprType(payloadExpr, self.currentScope, inFunctionCall=False) + if payloadType != requiredPayloadType: + if (payloadExpr.primitive() and payloadExpr.primitive().IntLiteral()): + if requiredPayloadType != "uint": + revert (": Invalid payload type", payloadExpr) + self.FSTCodegen.writeEmitStatement(ctx, self.symbols, self.currentScope) + + self.SolidityCodegen.writeStatement(ctx, self.symbols, self.currentScope) + + def exitStatement(self, ctx:CelestialParser.StatementContext): + self.SolidityCodegen.exitWriteStatement(ctx) + if ctx.IF() and not ctx.elseStatement(): + self.FSTCodegen.endIfWithoutElse(self.currentScope) + + def enterElseStatement(self, ctx:CelestialParser.ElseStatementContext): + self.FSTCodegen.writeElseStatement(ctx, self.currentScope) + self.SolidityCodegen.writeElseStatement(ctx) + + def exitElseStatement(self, ctx:CelestialParser.ElseStatementContext): + self.FSTCodegen.endElse(ctx, self.currentScope) + + def checkIdentifierDeclared(self, identifier, scope=""): + if scope != "": + for symbol in self.symbols: + if symbol.name == identifier and symbol.scope == scope: + return True + return False + else: + for symbol in self.symbols: + if symbol.name == identifier: + return True + return False + + def getArrayValueType(self, identifier, scope): + """ + Given an array type, returns what it is an array of + Example: array[map[int => int]] returns map[int => int] + """ + + arrayType = self.getIdenType(identifier, scope) + arrayValueType = self.isArrayOf(arrayType) + return arrayValueType + + # def getMapValueType(self, identifier, scope): + # """ + # Given a map type, returns the valuetype of the map + # """ + + # mapType = self.getIdenType(identifier, scope) + # mapValueType = mapType[mapType.find("=>") + 2:mapType.rfind("]")] + # return mapValueType + + def getIdenType(self, identifier, scope): + """ + Given an identifier, returns the type of the identifier after looking up the symbol table + The type is a string just as in `exprType` + Error if the identifier is not found (because `getIdenType` is called only when the identifier is + accessed, and hence can throw an error) + """ + + if identifier == "eTransfer": + return "" + elif identifier == "constructor": + return "void" + elif identifier in self.enums: + return identifier + elif identifier in ["fallback", "receive"]: + return "void" + for sym in self.symbols: + if sym.name == identifier and (sym.scope == scope or sym.scope == "global"): + return sym.type + revert (": Variable " + identifier + " not found") + + def getSym(self, identifier): + for sym in self.symbols: + if sym.name == identifier: + return sym + + def printSymbolTable (self): + """ + Prints the symbol table if the --printSymbolTable option is used + """ + + t = PrettyTable(['Name', 'Type', 'Parameters', 'Scope', 'isParameter?', 'isMethod?', 'isMap?', 'mapKeyType']) + for sym in self.symbols: + t.add_row([sym.name, sym.type, sym.params, sym.scope, sym.isParam, sym.isMethod, sym.isMap, sym.mapKeyType]) + print (t) + + def getIsMethodFuncInv (self, name): + """ + Given an identifier, returns whether it is a function, invariant or method + """ + + if name == ["constructor", "receive", "fallback"]: + return "method" + for sym in self.symbols: + if name == sym.name and sym.scope == "global": # scope = global not necessary + if sym.isMethod: + return "method" + elif sym.isFunction: + return "function" + elif sym.isInvariant: + return "invariant" + break \ No newline at end of file diff --git a/Celestial/Compiler/README.md b/Celestial/Compiler/README.md new file mode 100644 index 00000000..a01d1221 --- /dev/null +++ b/Celestial/Compiler/README.md @@ -0,0 +1,18 @@ +# Celestial Compiler +### Instructions to compile a Celestial source: +```sh +$ python3 ./main.py [--fstDir="path_to_output_directory_for_FStar_code"] +[--solDir="path_to_output_directory_for_Solidity_code"] +``` + +The F\* code will be generated in the current directory (if `fstDir` is not specified) with the same name as the contract. The Solidity file will be named `contract.sol`. + +### Instructions to verify the generated code using F\* +``` +fstar --include ../Compiler/lib [--z3rlimit 50] +``` +One can increase ```z3rlimit``` if required. More details about F* can be found [here](https://github.com/FStarLang/FStar). + +### Platform + +We have tested Celestial on Ubuntu running on Windows 10, via the Windows Subsystem for Linux. The tool should run as intended on other flavors of Linux, and MacOS. \ No newline at end of file diff --git a/Celestial/Compiler/SolidityCodegen.py b/Celestial/Compiler/SolidityCodegen.py new file mode 100644 index 00000000..680dfa93 --- /dev/null +++ b/Celestial/Compiler/SolidityCodegen.py @@ -0,0 +1,758 @@ +import sys +from os import makedirs +from os.path import join, dirname, realpath +from shutil import copyfile + +from antlr4 import * + +from CelestialLexer import CelestialLexer +from CelestialParser import CelestialParser +from CelestialParserListener import CelestialParserListener + + +class SolidityCodegen: + + def __init__(self, outputDir, verificationMode): + self.output = None + self.outputDir = outputDir + self.verificationMode = verificationMode #Added for Verisol + self.invariants_collected = "" #Added for Verisol + self.fieldPrefix = "" + self.indentationLevel = 0 + self.arithLibFlag = False + self.callLibFlag = False + self.contracts = [] + self.structs = [] + self.enumTypes = [] + + def isBasicType(self, varType): + return (varType in ["int", "uint", "address", "bool"]) + + def writeLibrary(self): + libName = join(self.outputDir, "Safe_Arith.sol") + libFile = open(libName, "w") + libFile.write("// SPDX-License-Identifier: MIT") + libFile.write("\n/* Code generated by compiler */") + libFile.write("\nlibrary Safe_Arith {") + libFile.write("\n") + libFile.write("\n function safe_add (uint a, uint b) public pure returns (uint) {") + libFile.write("\n if (a > a + b) revert (\" Overflow Error\");") + libFile.write("\n else return (a + b);") + libFile.write("\n }") + libFile.write("\n ") + libFile.write("\n function safe_sub (uint a, uint b) public pure returns (uint) {") + libFile.write("\n if (a < b) revert (\" Underflow Error\");") + libFile.write("\n else return (a - b);") + libFile.write("\n }") + libFile.write("\n ") + libFile.write("\n function safe_mul (uint a, uint b) public pure returns (uint) {") + libFile.write("\n if (b == 0) return 0;") + libFile.write("\n if (a != (a * b)/b) revert (\" Overflow Error\");") + libFile.write("\n else return (a * b);") + libFile.write("\n }") + libFile.write("\n ") + libFile.write("\n function safe_div (uint a, uint b) public pure returns (uint) {") + libFile.write("\n if (b == 0) revert (\" Division by 0 error\");") + libFile.write("\n else return (a / b);") + libFile.write("\n }") + libFile.write("\n}") + + dir_path = dirname(realpath(__file__)) + copyfile(join(dir_path + "/lib/Call.sol"), join(self.outputDir, "Call.sol")) + + if self.verificationMode == "VeriSol": + copyfile(join(dir_path + "/lib/VeriSolContracts.sol"), join(self.outputDir, "VeriSolContracts.sol")) + + + def enterProgram(self): + filename = join(self.outputDir, "contract.sol") + makedirs(dirname(filename), exist_ok=True) + self.output = open(filename, "w") + self.output.write("// SPDX-License-Identifier: MIT") + # self.output.write("\n/* Code generated by compiler */") + # self.writeToSolidity("") + # self.writeToSolidity("pragma solidity >=0.5.0 <0.7.0;") + # self.writeToSolidity("") + + self.writeLibrary() + + def exitProgram(self): + # if self.arithLibFlag or self.callLibFlag: + # filename = join(self.outputDir, "contract.sol") + # self.output.close() + # self.output = open(filename, "r") + # contents = self.output.readlines() + # index = contents.index("pragma solidity >=0.5.0 <0.7.0;\n") + # library = "" + # if self.arithLibFlag: + # library = "\nimport {Safe_Arith} from \"./Safe_Arith.sol\";" + # if self.callLibFlag: + # library += "\nimport \"./Call.sol\";" + # contents.insert(index + 1, library) + + # appendedSolFile = open(filename, "w") + # contents = "".join(contents) + # appendedSolFile.write(contents) + # appendedSolFile.close() + self.output.close() + + def writeImportDirective(self, ctx): + s = "" + for child in ctx.getChildren(): + s += (child.getText() + " ") + self.writeToSolidity(s) + + def writePragmaDirective(self, ctx): + if self.verificationMode == "VeriSol": + self.writeToSolidity("pragma solidity >=0.5.0 <0.7.0;") + self.writeToSolidity("\nimport \"./VeriSolContracts.sol\";") + else: + self.writeToSolidity("pragma " + ctx.pragmaName.getText() + ctx.pragmaValue().getText() + ";") + self.writeToSolidity("") + + def enterContractDecl(self, ctx:CelestialParser.ContractDeclContext): + contractName = ctx.iden().Iden().getText() + self.writeToSolidity("") + self.writeToSolidity("contract " + contractName + " {") + self.indentationLevel = 1 + if self.verificationMode == "VeriSol": + self.invariants_collected = "" + + def exitContractDecl(self, ctx:CelestialParser.ContractDeclContext): + if self.callLibFlag: + contractName = ctx.iden().Iden().getText() + filename = join(self.outputDir, "contract.sol") + self.output.close() + self.output = open(filename, "r") + contents = self.output.readlines() + self.output.close() + index = contents.index("contract " + contractName + "{") + contents.insert(index + 1, "\nusing Call for address;") + + self.output = open(filename, "w") + contents = "".join(contents) + self.output.write(contents) + + if self.verificationMode == "VeriSol" and not(self.invariants_collected == ""): + self.writeallInvariants() #Added for VeriSol + self.indentationLevel = 0 + self.writeToSolidity("}") + + def writeUsingForDecl(self, ctx:CelestialParser.UsingForDeclContext, symbols): + s = "" + for child in ctx.getChildren(): + s += child.getText() + " " + self.writeToSolidity(s) + + def getSolidityDatatype(self, ctx:CelestialParser.DatatypeContext): + if ctx.MAP(): + return "mapping (" + self.getSolidityDatatype(ctx.keyType) + " => " + self.getSolidityDatatype(ctx.valueType) + ")" + elif ctx.arrayType: + return self.getSolidityDatatype(ctx.arrayType) + "[]" + elif ctx.INSTMAP(): + if self.verificationMode == "VeriSol": + return "mapping (address => bool)" #Added for Verisol + else: + return "mapping (" + ctx.iden().Iden().getText() + " => bool)" + else: + return ctx.getText() + + def enterVarDecl(self, ctx:CelestialParser.VarDeclContext, currentScope, symbols): + varType = self.getSolidityDatatype(ctx.datatype()) + varName = ctx.iden().Iden().getText() + varString = "" + if varType in ["string", "bytes"] and currentScope != "global": + varString = varType + " memory " + varName # string is memory + elif not self.isBasicType(varType) and varType not in self.contracts and currentScope != "global" and varType not in ["bytes20", "bytes32"]: + varString = varType + " storage " + varName + else: + varString = varType + " " + varName + + if ctx.expr(): + varString += " = " + self.getSolidityExpr(ctx.expr(), symbols, currentScope) + + varString += ";" + self.writeToSolidity(varString) + + # Defining an add function for inst_map fields + if ctx.datatype().getText()[0:8] == "inst_map": + self.writeToSolidity("") + if self.verificationMode == "VeriSol": #Added for VeriSol & making code straightforward + self.writeToSolidity("function get_from_" + ctx.iden().Iden().getText() + " ( address payable i) private returns (" + ctx.datatype().getText()[9:-1] + ") {") + self.writeToSolidity(" if (" + ctx.iden().Iden().getText() + "[i]) return "+ ctx.datatype().getText()[9:-1] +"(i);") + else: + self.writeToSolidity("function get_from_" + ctx.iden().Iden().getText() + " (" + ctx.datatype().getText()[9:-1] + " i) private returns (" + ctx.datatype().getText()[9:-1] + ") {") + self.writeToSolidity(" if (" + ctx.iden().Iden().getText() + "[i]) return i;") + # self.writeToSolidity(" else return ") + self.writeToSolidity("}") + + self.writeToSolidity("") + self.writeToSolidity("function add_to_" + ctx.iden().Iden().getText() + " (" + ctx.datatype().getText()[9:-1] + " i) private returns (" + ctx.datatype().getText()[9:-1] + ") {") + if self.verificationMode == "VeriSol": #Added for VeriSol & making code straightforward + self.writeToSolidity(" " + ctx.iden().Iden().getText() + "[address(i)] = true;") + else: + self.writeToSolidity(" " + ctx.iden().Iden().getText() + "[i] = true;") + self.writeToSolidity(" return i;") + self.writeToSolidity("}") + + def writeEnumDecl(self, ctx:CelestialParser.EnumDeclContext): + enumType = ctx.name.Iden().getText() + self.writeToSolidity("enum " + enumType) + self.writeToSolidity("{") + self.indentationLevel += 1 + enumValueString = "" + for enumValue in ctx.iden(): + if enumValue.Iden().getText() == enumType: + continue + enumValueString += enumValue.Iden().getText() + if enumValue != ctx.iden()[-1]: + enumValueString += ", " + self.writeToSolidity(enumValueString) + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def writeEventDecl(self, ctx:CelestialParser.EventDeclContext): + argList = "" + for datatype in ctx.datatype(): + argList += self.getSolidityDatatype(datatype) + if datatype != ctx.datatype()[-1]: + argList += ", " + + self.writeToSolidity("event " + ctx.name.Iden().getText() + "("+ argList + ");") + + def writeStruct(self, ctx:CelestialParser.StructDeclContext): + self.writeToSolidity("struct " + ctx.name.Iden().getText()) + self.writeToSolidity("{") + self.indentationLevel += 1 + for i in range(1, len(ctx.iden())): + self.writeToSolidity(self.getSolidityDatatype(ctx.datatype(i-1)) + " " + ctx.iden(i).Iden().getText() + ";") + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def writeMethod(self, ctx:CelestialParser.MethodDeclContext): + methodDeclString = "" + if ctx.name: + methodName = ctx.name.Iden().getText() + + params = ctx.methodParamList() + paramString = "" + if params: + for param in params.methodParam(): + paramType = self.getSolidityDatatype(param.datatype()) + if paramType in ["string", "bytes"]: + paramString += paramType + " memory " + param.name.Iden().getText() + else: + paramString += paramType + " " + param.name.Iden().getText() + if param != params.methodParam()[-1]: + paramString += ", " + + methodDeclString = "function " + methodName + " (" + paramString + ")" + + if ctx.PRIVATE(): + methodDeclString += " private" + else: + methodDeclString += " public" + + if ctx.stateMutability(): + methodDeclString += " " + ctx.stateMutability().getText() + + # if (not (ctx.spec() and (ctx.spec().CREDIT() or ctx.spec().DEBIT()))) and (ctx.MODIFIES() and not ctx.modifies): + # methodDeclString += " view" + + if (ctx.spec() and ctx.spec().CREDIT()): + methodDeclString += " payable" + + if ctx.RETURNS(): + methodDeclString += " returns (" + self.getSolidityDatatype(ctx.datatype()) + if ctx.returnval: + methodDeclString += " " + ctx.returnval.Iden().getText() + methodDeclString += ")" + elif ctx.RECEIVE(): + methodDeclString = "receive () external payable" + elif ctx.FALLBACK() and ctx.spec() and ctx.spec().CREDIT(): + if self.verificationMode == "VeriSol": + methodDeclString = "function () external payable" #Added for Verisol + else: + methodDeclString = "fallback () external payable" + elif ctx.FALLBACK(): + if self.verificationMode == "VeriSol": + methodDeclString = "function () external" #Added for Verisol + else: + methodDeclString = "fallback () external" + + methodDeclString += " {" + + self.writeToSolidity("") + self.writeToSolidity(methodDeclString) + self.indentationLevel += 1 + + def exitWriteMethod(self): + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def writeallInvariants(self): #Added for VeriSol + self.writeToSolidity("") + self.writeToSolidity("function ContractInvariant () private view {") + self.indentationLevel += 1 + # + self.writeToSolidity("VeriSol.ContractInvariant("+self.invariants_collected+");") + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def appendInvariantBody(self, ctx:CelestialParser.ExprContext, symbols, scope): #Added for VeriSol + if ctx.op and ctx.getChildCount() == 3: + lhs = ctx.expr(0) + rhs = ctx.expr(1) + lhsExpr = self.getSolidityExpr(lhs, symbols, scope) + rhsExpr = self.getSolidityExpr(rhs, symbols, scope) + lhsExpr = lhsExpr.replace('sum_mapping', 'VeriSol.SumMapping') + rhsExpr = rhsExpr.replace('sum_mapping', 'VeriSol.SumMapping') + optr = "==" + if ctx.op.text == "==" or ctx.op.text == "!=" or ctx.op.text == "<=" or ctx.op.text == ">=" or ctx.op.text == "<" or ctx.op.text == ">": + s = lhsExpr + " " + ctx.op.text + " " + rhsExpr + elif ctx.op.text == "==>": + s = "!(" + lhsExpr + ") || (" + rhsExpr +")" + elif ctx.op.text == "<==>": + s = "((!(" + lhsExpr + ") || (" + rhsExpr +")) && ( !(" + rhsExpr + ") || (" + lhsExpr +")))" + + if self.invariants_collected == "": + self.invariants_collected = "("+ s +")" + else: + self.invariants_collected = self.invariants_collected + " && ("+ s +")" + else: + print ("Dropping the invariant not verifiable using VeriSol:"+ctx.getText()) + + + def writeConstructor(self, ctx:CelestialParser.ConstructorDeclContext): + params = ctx.methodParamList() + paramString = "" + if params: + for param in params.methodParam(): + paramString += self.getSolidityDatatype(param.datatype()) + " " + param.name.Iden().getText() + if param != params.methodParam()[-1]: + paramString += ", " + + self.writeToSolidity("") + self.writeToSolidity("constructor (" + paramString + ") public {") + self.indentationLevel += 1 + + def exitWriteConstructor(self): + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def exprType(self, ctx, symbols, scope, isMethod=False, isFunctionCall=False, isIf=False, isPre=False, isPost=False): + if (ctx.primitive()): + primitiveCtx = ctx.primitive() + if primitiveCtx.BoolLiteral(): + return "bool" + elif primitiveCtx.IntLiteral() or primitiveCtx.INT_MIN() or primitiveCtx.INT_MAX(): + return "int" + elif primitiveCtx.NullLiteral() or primitiveCtx.SENDER() or primitiveCtx.ADDR() or primitiveCtx.TXORIGIN() or primitiveCtx.BCOINBASE(): + return "address" + elif primitiveCtx.StringLiteral(): + return "string" + elif primitiveCtx.VALUE() or primitiveCtx.BALANCE() or primitiveCtx.UINT_MAX() or primitiveCtx.BDIFF() or primitiveCtx.BGASLIMIT() or primitiveCtx.BNUMBER() or primitiveCtx.BTIMESTAMP() or primitiveCtx.TXGASPRICE(): + return "uint" + elif primitiveCtx.LOG(): + return "eventlog" + elif primitiveCtx.THIS(): + return "address" # TODO: ContractType? or return scope + elif primitiveCtx.NEW(): + identifierName = primitiveCtx.iden().Iden().getText() + for symbol in symbols: + if symbol.name == identifierName and symbol.scope == "global": + return symbol.type + else: + varName = primitiveCtx.iden().Iden().getText() + for symbol in symbols: + if symbol.name == varName and (symbol.scope == scope or symbol.scope == "global"): + return symbol.type + if varName in self.enumTypes: # enum types are not stored in symbols (only their values are) + return varName + + elif (ctx.getChild(0) == ctx.LPAREN(0)): + return self.exprType(ctx.getChild(1), symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + + elif (ctx.DOT() and ctx.getChildCount() == 3 and ctx.field): + lvalue = ctx.expr(0) + rvalue = ctx.field + lvalueType = self.exprType(lvalue, symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + if lvalueType in self.structs: + structFieldName = rvalue.Iden().getText() + for symbol in symbols: + if symbol.name == structFieldName and symbol.isStructField and symbol.fieldOfStruct == lvalueType: + return symbol.type + # elif lvalueType in self.contracts: + # fieldName = rvalue.Iden().getText() + # for fields in self.fieldsOfContract[lvalueType]: + # if fieldName == fields[0]: + # return fields[1].getText() + elif lvalue.getText() in self.enumTypes: + return lvalue.getText() + + elif (ctx.array): + lvalueType = self.exprType(ctx.array, symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + if lvalueType[-2:] == "[]": + if (ctx.index): + if (ctx.index.MAPUPD()): + return lvalueType + return lvalueType[6:-1] + elif (ctx.LENGTH()): + return "uint" + elif lvalueType[0:7] == "mapping": + start = lvalueType.find("=>") + 2 + end = lvalueType.rfind("]") + valueType = lvalueType[start:end] + if ctx.index.MAPUPD(): + return lvalueType + else: + return valueType + elif lvalueType[0:8] == "inst_map": + return lvalueType[9:-1] + + elif (ctx.method and not ctx.DOT()): + if (ctx.method.Iden().getText() == "sum_mapping"): + return "uint" + + methodName = ctx.method.Iden().getText() + if methodName in self.contracts: # ContractName(values_of_fields) + return methodName + + else: # Normal method/function calls + for symbol in symbols: + if methodName == symbol.name and symbol.scope == "global": + return symbol.type + + elif (ctx.SUB() and (ctx.getChildCount() == 2)): + return "int" + + elif (ctx.LNOT() and (ctx.getChildCount() == 2)): + return "bool" + + elif (ctx.PLUS() or ctx.SUB() or ctx.MUL() or ctx.DIV() or ctx.MOD() + or ctx.SAFEADD() or ctx.SAFESUB() or ctx.SAFEMUL() or ctx.SAFEDIV() or ctx.SAFEMOD()): + op1 = ctx.lhs + op2 = ctx.rhs + op1type = self.exprType(op1, symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + op2type = self.exprType(op2, symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + if (op2.primitive() and op2.primitive().IntLiteral()): + if op1type == "int": + return "int" + elif op1type == "uint": + return "uint" + elif (op1.primitive() and op1.primitive().IntLiteral()): + if op2type == "int": + return "int" + elif op2type == "uint": + return "uint" + else: + if (op1type == op2type and op1type == "int"): + return "int" + elif (op1type == op2type and op1type == "uint"): + return "uint" + + elif (ctx.LT() or ctx.GT() or ctx.GE() or ctx.LE() or ctx.IN() + or ctx.EQ() or ctx.NE() or ctx.LAND() or ctx.LOR() or ctx.ITE() + or ctx.IMPL() or ctx.BIMPL() or ctx.FORALL() or ctx.EXISTS()): + return "bool" + + elif (ctx.MAPUPD()): + lhsType = self.exprType(ctx.expr(0), scope, isMethod, isFunctionCall, isIf, isPre, isPost) + rhsType = self.exprType(ctx.expr(1), scope, isMethod, isFunctionCall, isIf, isPre, isPost) + return "mapping(" + lhsType + "=>" + rhsType + ")" + + elif (ctx.ADD()): + return ctx.contractName.Iden().getText() + + elif (ctx.logcheck()): + return "eventlog" + + elif (ctx.PAYABLE()): + return self.exprType(ctx.expr(0), symbols, scope, isMethod, isFunctionCall, isIf, isPre, isPost) + + elif (ctx.method and ctx.DOT()): + if ctx.iden(0).Iden().getText() == "abi": + if ctx.method.Iden().getText() in ["encode", "encodePacked", "encodeWithSelector", "encodeWithSignature"]: + return "bytes" + + def getSolidityExpr(self, ctx:CelestialParser.ExprContext, symbols, scope): + if ctx.primitive(): + if ctx.primitive().VALUE(): + return "msg.value" + elif ctx.primitive().BALANCE(): + return "address(this).balance" + elif ctx.primitive().SENDER(): + return "msg.sender" + elif ctx.primitive().TXORIGIN() or ctx.primitive().TXGASPRICE(): + return ctx.getText() + elif ctx.primitive().BCOINBASE() or ctx.primitive().BDIFF() or ctx.primitive().BGASLIMIT() or ctx.primitive().BNUMBER() or ctx.primitive().BTIMESTAMP(): + return ctx.getText() + elif ctx.primitive().BoolLiteral() or ctx.primitive().IntLiteral() or ctx.primitive().StringLiteral() or ctx.primitive().iden(): + return ctx.getText() + elif ctx.primitive().INT_MIN(): + return "(int256(uint256(1) << 255))" + elif ctx.primitive().INT_MAX(): + return "(int256(~(uint256(1) << 255)))" + elif ctx.primitive().UINT_MAX(): + if self.verificationMode == "VeriSol": + return "(uint256(0) - uint256(1))" + else: + return "(~uint256(0))" + elif ctx.primitive().NullLiteral(): + return "address(0)" + elif ctx.primitive().ADDR(): + return "address(" + ctx.primitive().getChild(2).getText() + ")" + elif ctx.primitive().THIS(): + return "this" + + elif (ctx.getChild(0) == ctx.LPAREN(0)): + return "(" + self.getSolidityExpr(ctx.expr(0), symbols, scope) + ")" + + elif ctx.array: + if ctx.expr(0).primitive() and ctx.expr(0).primitive().iden() and ctx.LBRACK(): #TODO: Use exprType instead + idenName = ctx.expr(0).primitive().iden().Iden().getText() + for symbol in symbols: + if symbol.name == idenName and symbol.type[0:8] == "inst_map": + if self.verificationMode == "VeriSol": #Added for VeriSol & making code straightforward + return "get_from_" + idenName + "(" + self.getSolidityExpr(ctx.index, symbols, scope) + ")" + else: + return "get_from_" + idenName + "(" + symbol.type[9:-1] + "(payable(" + self.getSolidityExpr(ctx.index, symbols, scope) + ")))" + + if ctx.LBRACK(): + return self.getSolidityExpr(ctx.expr(0), symbols, scope) + "[" + self.getSolidityExpr(ctx.expr(1), symbols, scope) + "]" + elif ctx.LENGTH(): + return self.getSolidityExpr(ctx.expr(0), symbols, scope) + ".length" + + elif ctx.method and not ctx.DOT(): + args = ctx.rvalueList() + s = ctx.method.Iden().getText() + "(" + if args: + for arg in args.rvalue(): + s += self.getSolidityExpr(arg.expr(), symbols, scope) + if arg != args.rvalue()[-1]: + s += ", " + s += ")" + return s + + elif ctx.method and ctx.DOT(): + args = ctx.rvalueList() + s = ctx.iden(0).Iden().getText() + "." + ctx.method.Iden().getText() + "(" + if args: + for arg in args.rvalue(): + s += self.getSolidityExpr(arg.expr(), symbols, scope) + if arg != args.rvalue()[-1]: + s += ", " + s += ")" + return s + + elif ctx.LNOT() or (ctx.getChildCount() == 2 and ctx.SUB()): + return ctx.op.text + " " + self.getSolidityExpr(ctx.expr(0), symbols, scope) + + elif ctx.op and ctx.getChildCount() == 3: + lhs = ctx.expr(0) + rhs = ctx.expr(1) + lhsExpr = self.getSolidityExpr(lhs, symbols, scope) + rhsExpr = self.getSolidityExpr(rhs, symbols, scope) + if ctx.op.text == "==": + lhsType = self.exprType(lhs, symbols, scope) + rhsType = self.exprType(rhs, symbols, scope) + if (lhsType == "string"): + return "keccak256(bytes(" + lhsExpr + ") == keccak256(bytes(" + rhsExpr + "))" + + if ctx.op.text == "==>": #Added for VeriSol + lhsType = self.exprType(lhs, symbols, scope) + rhsType = self.exprType(rhs, symbols, scope) + return "!("+ lhsExpr + ") || (" + rhsExpr + ")" + + if ctx.op.text == "<==>": #Added for VeriSol + lhsType = self.exprType(lhs, symbols, scope) + rhsType = self.exprType(rhs, symbols, scope) + return "((!("+ lhsExpr + ") || (" + rhsExpr + ")) && (!("+ rhsExpr + ") || (" + lhsExpr + ")))" + + return lhsExpr + " " + ctx.op.text + " " + rhsExpr + + elif ctx.DOT() and ctx.getChildCount() == 3: + return ctx.getText() + + elif ctx.SAFEADD() or ctx.SAFESUB() or ctx.SAFEMUL() or ctx.SAFEMOD() or ctx.SAFEDIV(): + self.arithLibFlag = True + return "Safe_Arith." + ctx.getChild(0).getText() + "(" + self.getSolidityExpr(ctx.lhs, symbols, scope) + ", " + self.getSolidityExpr(ctx.rhs, symbols, scope) + ")" + + elif ctx.ADD(): + s = "(" + if ctx.rvalueList(): + for arg in ctx.rvalueList().rvalue(): + s += self.getSolidityExpr(arg.expr(), symbols, scope) + if arg != ctx.rvalueList().rvalue()[-1]: + s += ", " + s += ")" + return "address(add_to_" + ctx.instmap.Iden().getText() + "(new " + ctx.contractName.Iden().getText() + s + "))" + # return ctx.getChild(4).getText() + " " + ctx.getChild(5).getText() + " " + ctx.getChild(6).getText() + " " + ctx.getChild(7).getText() + + elif ctx.PAYABLE(): + return "payable(" + self.getSolidityExpr(ctx.expr(0), symbols, scope) + ")" + + # TODO: Cast Expr, Create Expr + + def getSolidityLvalueExpr(self, ctx:CelestialParser.LvalueContext, symbols, scope): + if ctx.name: + return ctx.name.Iden().getText() + elif ctx.LBRACK(): + return self.getSolidityLvalueExpr(ctx.lvalue(), symbols, scope) + "[" + self.getSolidityExpr(ctx.expr(), symbols, scope) + "]" + elif ctx.DOT(): + return ctx.getText() + + def writeStatement(self, ctx:CelestialParser.StatementContext, symbols, scope): + if ctx.LBRACE(): + # self.writeToSolidity(self.indentationLevel * " ") + self.writeToSolidity("{") + self.indentationLevel += 1 + # for stmt in ctx.statement(): + # self.writeToSolidity(self.indentationLevel * " ") + # self.writeStatement(stmt) + # self.indentationLevel -= 1 + # self.writeToSolidity(self.indentationLevel * " ") + # self.writeToSolidity("}\n") + + elif ctx.PUSH(): + self.writeToSolidity(self.getSolidityLvalueExpr(ctx.arrayName, symbols, scope) + ".push(" + self.getSolidityExpr(ctx.expr(0), symbols, scope) + ");") + + elif ctx.POP(): + self.writeToSolidity(self.getSolidityLvalueExpr(ctx.arrayName, symbols, scope) + ".pop();") + + # TODO: delete + # elif ctx.DELETE(): + # toDelete = ctx.lvalue() + # self.writeToSolidity("delete " + ) + + elif ctx.ASSERT(): + if self.verificationMode == "VeriSol": + e = self.getSolidityExpr(ctx.expr(0), symbols, scope) + self.writeToSolidity("assert (" + e.replace('sum_mapping', 'VeriSol.SumMapping') + ");") + else: + self.writeToSolidity("assert (" + self.getSolidityExpr(ctx.expr(0), symbols, scope) + ");") + + elif ctx.NEW(): + self.writeToSolidity(self.getSolidityLvalueExpr(ctx.assignTo, symbols, scope) + " = new " + ctx.iden().Iden().getText() + " ();") + + elif ctx.CALL() or ctx.CALLUINT() or ctx.CALLBOOL(): + callName = "" + if ctx.CALL(): + callName = "call" + elif ctx.CALLUINT(): + callName = "call_uint" + elif ctx.CALLBOOL(): + callName = "call_bool" + + caller = self.getSolidityExpr(ctx.expr(0), symbols, scope) + # s = "abi.encodeWithSignature(" + self.getSolidityExpr(ctx.rvalueList().rvalue()[0].expr(), symbols, scope) + # for rvalue in ctx.rvalueList().rvalue()[1:]: + # s += ", " + self.getSolidityExpr(rvalue.expr(), symbols, scope) + s = self.getSolidityExpr(ctx.rvalueList().rvalue(0).expr(), symbols, scope) + s = caller + "." + callName + "(" + s + ");" + + # Set the lock to true to disallow re-entrancy due to '.call' + # self.writeToSolidity("_lock_ = true;") + if ctx.BOOL() and ctx.CALLBOOL(): + self.writeToSolidity("bool " + ctx.iden().getText() + " = " + s) + elif ctx.UINT() and ctx.CALLUINT(): + self.writeToSolidity("uint " + ctx.iden().getText() + " = " + s) + elif ctx.lvalue() and (ctx.CALLBOOL() or ctx.CALLUINT()): + assignToExpr = self.getSolidityLvalueExpr(ctx.lvalue()[0], symbols, scope) + self.writeToSolidity(assignToExpr + " = " + s) + elif ctx.lvalue(): + assignToExpr = self.getSolidityLvalueExpr(ctx.lvalue()[0], symbols, scope) + self.writeToSolidity("(" + assignToExpr + ", ) = " + s) + else: + self.writeToSolidity(s) + + # Set the lock to false after the execution of '.call' + # self.writeToSolidity("_lock_ = false;") + + elif ctx.assignment: + self.writeToSolidity(self.getSolidityLvalueExpr(ctx.assignTo, symbols, scope) + " = " + self.getSolidityExpr(ctx.rvalue().expr(), symbols, scope) + ";") + + elif ctx.IF(): + self.writeToSolidity("if (" + self.getSolidityExpr(ctx.expr(0), symbols, scope) + ")") + # self.writeStatement(ctx.thenBranch) + + # TODO: forStatment + + elif ctx.otherContractInstance: + s = self.getSolidityLvalueExpr(ctx.otherContractInstance, symbols, scope) + "." + ctx.method.Iden().getText() + "(" + args = ctx.rvalueList() + if args: + for arg in args.rvalue(): + s += self.getSolidityExpr(arg.expr(), symbols, scope) + if arg != args.rvalue()[-1]: + s += ", " + s += ");" + self.writeToSolidity(s) + + # Method Call statement + elif ctx.method and ctx.getChildCount() == 5: + args = ctx.rvalueList() + s = ctx.method.Iden().getText() + "(" + if args: + for arg in args.rvalue(): + s += self.getSolidityExpr(arg.expr(), symbols, scope) + if arg != args.rvalue()[-1]: + s += ", " + s += ");" + self.writeToSolidity(s) + + elif ctx.TRANSFER(): + to = self.getSolidityExpr(ctx.to, symbols, scope) + amount = self.getSolidityExpr(ctx.amount, symbols, scope) + if self.verificationMode == "VeriSol" and to!="msg.sender": #Added for VeriSol. + payableto = to.replace("(" ,"") + payableto = payableto.replace(")" ,"") + payableto = payableto.replace("payable" ,"") + self.writeToSolidity("address payable "+payableto+" = address(uint160(address("+payableto+")));") + self.writeToSolidity(payableto+".transfer(" + amount + ");") + #self.writeToSolidity(to + ".call.value(" + amount + ").gas(2300)(\"\");") + else: + self.writeToSolidity(to + ".transfer(" + amount + ");") + + # self.writeToSolidity("if (address(this).balance < " + amount + ") revert (\"Insufficient balance\");") + # if self.verificationMode == "VeriSol": + # self.writeToSolidity(to + ".call.value(" + amount + ").gas(2300)(\"\");") + # else: + # self.writeToSolidity(to + ".call{value: (" + amount + "), gas: 2300}(\"\");") + # self.indentationLevel += 1 + # self.writeToSolidity("if (!success)") + # self.indentationLevel += 1 + # self.writeToSolidity("revert (\" Sending of ether failed\");") + # self.indentationLevel -= 2 + + elif ctx.EMIT(): + payloadString = "" + for payloadExpr in ctx.expr(): + payloadString += self.getSolidityExpr(payloadExpr, symbols, scope) + if payloadExpr != ctx.expr()[-1]: + payloadString += ", " + eventName = ctx.event.Iden().getText() + self.writeToSolidity("emit " + eventName + "(" + payloadString + ");") + + elif ctx.REVERT(): + self.writeToSolidity("revert (" + ctx.StringLiteral().getText() + ");") + + def exitWriteStatement(self, ctx:CelestialParser.StatementContext): + if ctx.LBRACE(): + self.indentationLevel -= 1 + self.writeToSolidity("}") + + def writeElseStatement(self, ctx:CelestialParser.ElseStatementContext): + self.writeToSolidity("else") #(" + self.getSolidityExpr(ctx.expr(0)) + ") ") + + def writeReturnStatement(self, ctx:CelestialParser.ReturnStatementContext, symbols, scope): + if ctx.expr(): + self.writeToSolidity("return " + self.getSolidityExpr(ctx.expr(), symbols, scope) + ";") + else: + self.writeToSolidity("return;") + + def writeToSolidity(self, code): + if code == "": + self.output.write("\n") + else: + self.output.write("\n" + self.indentationLevel * " " + code) diff --git a/Celestial/Compiler/Symbol.py b/Celestial/Compiler/Symbol.py new file mode 100644 index 00000000..a267ab86 --- /dev/null +++ b/Celestial/Compiler/Symbol.py @@ -0,0 +1,26 @@ +class Symbol: + + def __init__(self, _name="", _type="", _params=[], _scope="", _isParam=False, _isMethod=False, _isFunction=False, _isInvariant=False, _isMap=False, _mapKeyType="", _isEvent=False, _returnVar="", _isEnumValue=False, _isStructType=False, _isStructObject=False, _fieldOfStruct="", _isStructField=False, _isQuantifierVar=False, _isLocal=False, _isContractObject=False): + self.name = _name + self.type = _type + self.params = _params + self.scope = _scope + self.isParam = _isParam + self.isMethod = _isMethod + self.isFunction = _isFunction + self.isInvariant = _isInvariant + self.isMap = _isMap + self.mapKeyType = _mapKeyType + self.isEvent = _isEvent + self.returnVar = _returnVar + self.isEnumValue = _isEnumValue + self.isStructType = _isStructType + self.isStructObject = _isStructObject + self.fieldOfStruct = _fieldOfStruct + self.isStructField = _isStructField + self.isQuantifierVar = _isQuantifierVar + self.isLocal = _isLocal + self.isContractObject = _isContractObject + + def __eq__(self, otherObj): + return (self.name == otherObj.name and self.type == otherObj.type and self.params == otherObj.params and self.scope == otherObj.scope and self.isParam == otherObj.isParam and self.isMethod == otherObj.isMethod and self.isFunction == otherObj.isFunction and self.isInvariant == otherObj.isInvariant and self.isMap == otherObj.isMap and self.mapKeyType == otherObj.mapKeyType and self.isEvent == otherObj.isEvent and self.returnVar == otherObj.returnVar and self.isEnumValue == otherObj.isEnumValue and self.isStructType == otherObj.isStructType and self.isStructObject == otherObj.isStructObject and self.fieldOfStruct == otherObj.fieldOfStruct and self.isStructField == otherObj.isStructField and self.isQuantifierVar == otherObj.isQuantifierVar) \ No newline at end of file diff --git a/Celestial/Compiler/Tests/OtherContract.fst b/Celestial/Compiler/Tests/OtherContract.fst new file mode 100644 index 00000000..c76d2ae1 --- /dev/null +++ b/Celestial/Compiler/Tests/OtherContract.fst @@ -0,0 +1,84 @@ +(*Code generated by compiler*) + +module OtherContract + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + + +noeq type t_othercontract = { + othercontract_otherContractField : int; +} + +(* Contract address type, liveness, and field range macros *) + +type othercontract_address = contract t_othercontract +let othercontract_live (c:othercontract_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +let othercontract_fields_in_range (self:othercontract_address) (bst:bstate{self `othercontract_live` bst}) : Type0 = + let cs = CM.sel self bst.cmap in + (cs.othercontract_otherContractField >= int_min) /\ (cs.othercontract_otherContractField <= int_max) + +(* Field getters for contract OtherContract *) + +let othercontract_get_otherContractField (c:othercontract_address) +: StEth int + (fun st -> c `othercontract_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).othercontract_otherContractField) += let othercontract_inst = get_contract c in + othercontract_inst.othercontract_otherContractField + +(* Field setters for contract OtherContract *) + +let othercontract_set_otherContractField (c:othercontract_address) (_otherContractField:int) +: StEth unit + (fun st -> c `othercontract_live` st.current + /\ _otherContractField >= int_min /\ _otherContractField <= int_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + othercontract_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with othercontract_otherContractField = _otherContractField })) += let othercontract_inst = get_contract c in + let othercontract_inst = { othercontract_inst with othercontract_otherContractField = _otherContractField } in + set_contract c othercontract_inst + +let setOtherContractField (self:othercontract_address) (sender:address) (value:int) (now:int) (_otherContractField:int) +: Eth unit + (fun bst -> + othercontract_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sender <> null) /\ (value <= uint_max) /\ (sender <> self) + /\ (_otherContractField >= int_min) /\ (_otherContractField <= int_max) + /\ (othercontract_fields_in_range self bst) + /\ (value >= 0) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + othercontract_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (othercontract_fields_in_range self bst1) + /\ (cs1.othercontract_otherContractField == _otherContractField) + /\ (bst0.balances == bst1.balances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = othercontract_set_otherContractField self _otherContractField in +let cs = get_contract self in +() \ No newline at end of file diff --git a/Celestial/Compiler/Tests/Sample.fst b/Celestial/Compiler/Tests/Sample.fst new file mode 100644 index 00000000..05f35fde --- /dev/null +++ b/Celestial/Compiler/Tests/Sample.fst @@ -0,0 +1,127 @@ +(*Code generated by compiler*) + +module Sample + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +open OtherContract +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + + +noeq type t_sample = { + sample_m : (m:(M.t othercontract_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}); + sample_t : othercontract_address; +} + +(* Contract address type, liveness, and field range macros *) + +type sample_address = contract t_sample +let sample_live (c:sample_address) (bst:bstate) = + c `CM.live_in` bst.cmap + /\ (let cs = CM.sel c bst.cmap in + (forall (i:othercontract_address). M.contains cs.sample_m i ==> i `CM.live_in` bst.cmap /\ i <> c) + ) + +let sample_fields_in_range (self:sample_address) (bst:bstate{self `sample_live` bst}) : Type0 = + let cs = CM.sel self bst.cmap in + False + +(* Field getters for contract Sample *) + +let sample_get_m (c:sample_address) +: StEth (m:(M.t othercontract_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}) + (fun st -> c `sample_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).sample_m) += let sample_inst = get_contract c in + sample_inst.sample_m + +let sample_get_t (c:sample_address) +: StEth othercontract_address + (fun st -> c `sample_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).sample_t) += let sample_inst = get_contract c in + sample_inst.sample_t + +(* Field setters for contract Sample *) + +let sample_set_m (c:sample_address) (_m:(m:(M.t othercontract_address bool lt){M.def_of m == false /\ ~ (M.contains m null)})) +: StEth unit + (fun st -> c `sample_live` st.current + /\ (forall (i:othercontract_address). M.contains _m i ==> othercontract_live i st.current /\ i <> c)) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + sample_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with sample_m = _m })) += let sample_inst = get_contract c in + let sample_inst = { sample_inst with sample_m = _m } in + set_contract c sample_inst + +let sample_set_t (c:sample_address) (_t:othercontract_address) +: StEth unit + (fun st -> c `sample_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + sample_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with sample_t = _t })) += let sample_inst = get_contract c in + let sample_inst = { sample_inst with sample_t = _t } in + set_contract c sample_inst + +let access_contract_instance_1 (_m:tuple2 (m:(M.t othercontract_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}) bstate{forall (k:othercontract_address). M.contains (fst _m) k ==> k `CM.live_in` (snd _m).cmap}) (_a:address) += ((M.contains (fst _m) _a)) /\ (((CM.sel _a (snd _m).cmap).othercontract_otherContractField) == 5) + +let check_external_call (self:sample_address) (sender:address) (value:int) (now:int) (_a:address) +: Eth unit + (fun bst -> + sample_live self bst /\ + (sender <> null) /\ (value <= uint_max) /\ (now >= 0) /\ (now <= uint_max) /\ (sender <> self) /\ (value >= 0) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + sample_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sample_fields_in_range self bst1) + /\ ((access_contract_instance_1 (cs0.sample_m, bst0) _a)) + /\ (bst0.balances == bst1.balances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let localAddressVariable:address = (null) in +let x1 = (( + let x1 = (cs.sample_m) in +if M.contains x1 _a then _a else null) = null) in +let _ = (if x1 then begin +revert "address passed is not of type OtherContract"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let localOtherContractInstance:othercontract_address = (null) in +let x1 = ( + let x1 = (cs.sample_m) in +if M.contains x1 _a then _a else null) in +let localOtherContractInstance = x1 in +let cs = get_contract self in +let bst = (get ()).current in +assume (othercontract_fields_in_range localOtherContractInstance bst); +assume (sender <> localOtherContractInstance); +let x1 = setOtherContractField localOtherContractInstance sender 0 now (5) in +let localAddressVariable = x1 in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Compiler/Tests/crypto_functions/Safe_Arith.sol b/Celestial/Compiler/Tests/crypto_functions/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Compiler/Tests/crypto_functions/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Compiler/Tests/crypto_functions/Test.fst b/Celestial/Compiler/Tests/crypto_functions/Test.fst new file mode 100644 index 00000000..f694877b --- /dev/null +++ b/Celestial/Compiler/Tests/crypto_functions/Test.fst @@ -0,0 +1,67 @@ +(*Code generated by compiler*) + +module Test + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + + +type t_test = unit + +(* Contract address type, liveness, and field range macros *) + +type test_address = contract t_test +let test_live (c:test_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract Test *) + +(* Field setters for contract Test *) + +let foo (self:test_address) (sender:address) (value:uint) (now:uint) (b:bytes) +: Eth1 bytes32 + (fun bst -> + test_live self bst /\ + (sender <> null) + ) + (fun bst -> False) + (fun bst0 ret bst1 -> + test_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((ret == ((keccak256 b)))) + /\ (bst0.balances == bst1.balances) + )) += +let ret:bytes32 = {} in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((keccak256 b)) in +let ret = x1 in +let cs = get_contract self in +ret + +let bar (self:test_address) (sender:address) (value:uint) (now:uint) (b:bytes) +: Eth1 unit + (fun bst -> + test_live self bst /\ + (sender <> null) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + test_live self bst1 + ) += +let cs = get_contract self in +let balance = get_balance self in +let local_var:bytes32 = ((sha256 b)) in +() \ No newline at end of file diff --git a/Celestial/Compiler/Tests/crypto_functions/contract.sol b/Celestial/Compiler/Tests/crypto_functions/contract.sol new file mode 100644 index 00000000..932aa59d --- /dev/null +++ b/Celestial/Compiler/Tests/crypto_functions/contract.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ + +pragma solidity >=0.5.0 <0.7.0; + + +contract Test +{ + receive() external payable {} + bool _lock_ = false; + + modifier isUnlocked () { + require (_lock_ == false); + _; + } + + + function foo (bytes memory b) public isUnlocked returns (bytes32 ret) { + ret = keccak256(b); + return ret; + } + + function bar (bytes memory b) public isUnlocked { + bytes32 local_var = sha256(b); + return; + } +} \ No newline at end of file diff --git a/Celestial/Compiler/Tests/crypto_functions/crypto_functions.cel b/Celestial/Compiler/Tests/crypto_functions/crypto_functions.cel new file mode 100644 index 00000000..e8bfeb9d --- /dev/null +++ b/Celestial/Compiler/Tests/crypto_functions/crypto_functions.cel @@ -0,0 +1,16 @@ +contract Test +{ + function foo (bytes b) public + post (ret == keccak256(b)) + returns (bytes32 ret) + { + ret = keccak256(b); + return ret; + } + + function bar (bytes b) public + { + bytes32 local_var = sha256 (b); + return; + } +} \ No newline at end of file diff --git a/Celestial/Compiler/Tests/sample.cel b/Celestial/Compiler/Tests/sample.cel new file mode 100644 index 00000000..b32a2547 --- /dev/null +++ b/Celestial/Compiler/Tests/sample.cel @@ -0,0 +1,233 @@ +contract OtherContract { + int otherContractField; + + // method otherContractMethod() + // tx_reverts false + // { + // return; + // } + + // method otherContractMethod2(int zx, bool yz) + // tx_reverts false + // returns (bool) + // { + // return true; + // } + + method setOtherContractField (int _otherContractField) + post new(otherContractField) == _otherContractField + { + otherContractField = _otherContractField; + return; + } +} + +// contract AnotherContract { +// int anotherContractField; +// int a; + +// enum testEnum { aaa, bbb, ccc } + +// method anotherContractMethod() +// tx_reverts false +// { +// return; +// } +// } + +contract Sample { + // OtherContract otherContractInstance; + // AnotherContract anotherContractInstance; + // map[int, OtherContract] mapOfContractInstances; + // int a; + // int b; + // bool c; + // map[address, int] i; + // map[int, map[int, int]] d; + // array[int] e; + // array[bool] f; + // array[uint] g; + // array[array[int]] h; + // map[int, map[int, map[int, int]]] pp; + + // enum testEnum { aaa, bbb, ccc } + // testEnum state; + + // struct someStruct + // { + // int structVar; + // bool structVar2; + // } + + // someStruct someStructObject; + // array[someStruct] structArray; + + // event someEvent(uint); + + // // invariant inv { + // // c || error + // // } + + // // invariant inv2 { + // // c || error + // // } + + // invariant inv3 { + // true + // } + + // function takesInEnum (testEnum v) + // { + // true + // } + + // function foo (array[array[int]] q, map[int, uint] x, array[int] l, array[array[int]] lol, + // map[int, map[int, int]] zozo + // ) { + // // e.length() + // // d[e[1]] + // //(5 == g[5]) && false && true && (!c) && !c + // // -m(a) + // // f[1][1] // disallowed + // // lol[3][x[l[2]]] + // // l[4] + 5 + // // bar(4) + // // undeclared_function() + // // undeclared_variable + // // ite (l[1] > 5, true, true) //&& x == x[5 => 6, 10 => 11] + // // && + // zozo == zozo[5 => zozo[6][2 => 3]] + // } + + // function baz(someStruct structArg, array[bool] ff) + // { + // (forall (int pop, bool aaba) (aaba)) && + // (forall (uint zzz, bool zzzz, address abcd) (ff[zzz] ==> zzzz)) + // } + + // function bar(int ll) { + // true + // } + + // function usesImpl () { + // true ==> true + // } + + // function usesDefault (someStruct structObjArg) { + // structObjArg == default(someStruct) + // } + + // function takesErrorLog (eventlog elog, event eeps) + // { + // true + // } + + // constructor () + // public + // post baz(new(someStructObject), new(f)) + // tx_reverts false + // // post true + // { + // int constructor_local; + // state = testEnum.aaa; + // constructor_local = someStructObject.structVar; + // structArray.push(someStruct(a, true)); + // // mapOfContractInstances[2] = new OtherContract(); + + // // mapOfContractInstances[2].otherContractMethod2(5, true); + // return; + // } + + // function createsInstancePost(map[int, OtherContract] mapOfContractInstances_old, map[int, OtherContract] mapOfContractInstances_new) + // { + // mapOfContractInstances_new == mapOfContractInstances_old[1 => OtherContract()] + // } + + // method createsInstance() + // post createsInstancePost(mapOfContractInstances, new(mapOfContractInstances)) + // { + // otherContractInstance = new OtherContract(); + // anotherContractInstance = new AnotherContract(); + // // otherContractInstance.otherContractMethod2(5, true); + + // mapOfContractInstances[1] = new OtherContract(); + // return; + // } + + // method method_1 (int param1_1) + // credit + // tx_reverts false + // modifies [] + // returns (bool) + // { + // // h[1].push(1); + // // a = b; + // pp[5][4][3] = 2; + // someStructObject.structVar = 5; + // delete(e, 4); + // return true; + // } + + // method method_2 (uint param1, bool param2) + // pre true //true && bar(5) && bar(new(a)) + // post bar(a) && bar(new(b)) && true && bar(e[1]) + // tx_reverts bar(a) + // modifies [] + // returns (int lolol) + // { + // // int method_2_local; + // // delete (d[1][1]); + // lolol = 2; + // if (b + 5 < int_max) { + // a = b + 5; + // } + // // send(sender, someEvent, 5); + // delete(i, null); + // return 0; + // } + + // method another_method () + // pre true + // credit + // tx_reverts false + // { + // int another_method_local; + // if (true) + // { + // method_2(5, method_1(5)); + // } + // revert ("Error"); + // return; + // } + + // ****************** External Contract Tests ****************** + + inst_map m; + OtherContract t; + + function access_contract_instance_1 (inst_map _m, address _a) + { + _a in _m && _m[_a].otherContractField == 5 + } + + // function access_contract_instance_2 (OtherContract _t) + // { + // _t.otherContractField == 10 + // } + + method check_external_call (address _a) + post access_contract_instance_1 (m, _a) + { + address localAddressVariable; + if (m[_a] == null) + { + revert ("address passed is not of type OtherContract"); + } + OtherContract localOtherContractInstance; + localOtherContractInstance = m[_a]; + localAddressVariable = localOtherContractInstance.setOtherContractField(5); + return; + } + + // ****************** End External Contract Tests ****************** +} \ No newline at end of file diff --git a/Celestial/Compiler/lib/.depend b/Celestial/Compiler/lib/.depend new file mode 100644 index 00000000..7611bb06 --- /dev/null +++ b/Celestial/Compiler/lib/.depend @@ -0,0 +1,366 @@ +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Properties.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_List_Tot.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.fst.checked\ + + +_output/FStar_List_Tot.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.fst.checked\ + + +_output/FStar_List_Tot.cmx: _output/FStar_List_Tot.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_List_Tot_Base.cmx\ + _output/FStar_List_Tot_Properties.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/experimental/FStar.OrdSet.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fsti.checked + +_output/FStar_OrdSet.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fst.checked\ + + +_output/FStar_OrdSet.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fst.checked\ + + +_output/FStar_OrdSet.cmx: _output/FStar_OrdSet.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_List_Tot.cmx\ + _output/FStar_Pervasives_Native.cmx\ + _output/FStar_Set.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Mul.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Mul.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_Mul.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Mul.fst.checked\ + + +_output/FStar_Mul.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Mul.fst.checked\ + + +_output/FStar_Mul.cmx: _output/FStar_Mul.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/prims.fst\ + + +_output/prims.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + + +_output/prims.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + + +_output/prims.cmx: _output/prims.ml\ + + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/experimental/FStar.OrdSet.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Squash.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.FunctionalExtensionality.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked + +_output/FStar_FunctionalExtensionality.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fst.checked\ + + +_output/FStar_FunctionalExtensionality.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fst.checked\ + + +_output/FStar_FunctionalExtensionality.cmx: _output/FStar_FunctionalExtensionality.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Set.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked + +_output/FStar_Set.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fst.checked\ + + +_output/FStar_Set.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fst.checked\ + + +_output/FStar_Set.cmx: _output/FStar_Set.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_FunctionalExtensionality.cmx\ + _output/FStar_Classical.cmx + +FStar.Celestial.Map.fst.checked: FStar.Celestial.Map.fst\ + FStar.Celestial.Map.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked + +_output/FStar_Celestial_Map.ml: FStar.Celestial.Map.fst.checked\ + + +_output/FStar_Celestial_Map.krml: FStar.Celestial.Map.fst.checked\ + + +_output/FStar_Celestial_Map.cmx: _output/FStar_Celestial_Map.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_OrdSet.cmx\ + _output/FStar_FunctionalExtensionality.cmx\ + _output/FStar_Pervasives_Native.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.FunctionalExtensionality.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Properties.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.Properties.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.StrongExcludedMiddle.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_List_Tot_Properties.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Properties.fst.checked\ + + +_output/FStar_List_Tot_Properties.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Properties.fst.checked\ + + +_output/FStar_List_Tot_Properties.cmx: _output/FStar_List_Tot_Properties.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_List_Tot_Base.cmx\ + _output/FStar_Pervasives_Native.cmx\ + _output/FStar_StrongExcludedMiddle.cmx\ + _output/FStar_Classical.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Set.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Classical.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fsti.checked + +_output/FStar_Classical.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fst.checked\ + + +_output/FStar_Classical.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fst.checked\ + + +_output/FStar_Classical.cmx: _output/FStar_Classical.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_Squash.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Squash.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked + +_output/FStar_Squash.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fst.checked\ + + +_output/FStar_Squash.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fst.checked\ + + +_output/FStar_Squash.cmx: _output/FStar_Squash.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx + +FStar.Celestial.fst.checked: FStar.Celestial.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Mul.fst.checked\ + FStar.Celestial.Map.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_Celestial.ml: FStar.Celestial.fst.checked\ + + +_output/FStar_Celestial.krml: FStar.Celestial.fst.checked\ + + +_output/FStar_Celestial.cmx: _output/FStar_Celestial.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_Celestial_Map.cmx\ + _output/FStar_Mul.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.Base.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_List_Tot_Base.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked\ + + +_output/FStar_List_Tot_Base.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked\ + + +_output/FStar_List_Tot_Base.cmx: _output/FStar_List_Tot_Base.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx\ + _output/FStar_Pervasives_Native.cmx\ + _output/FStar_Classical.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.StrongExcludedMiddle.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.StrongExcludedMiddle.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_StrongExcludedMiddle.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.StrongExcludedMiddle.fst.checked\ + + +_output/FStar_StrongExcludedMiddle.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.StrongExcludedMiddle.fst.checked\ + + +_output/FStar_StrongExcludedMiddle.cmx: _output/FStar_StrongExcludedMiddle.ml\ + _output/prims.cmx\ + _output/FStar_Pervasives.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_Pervasives.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fst.checked\ + + +_output/FStar_Pervasives.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fst.checked\ + + +_output/FStar_Pervasives.cmx: _output/FStar_Pervasives.ml\ + _output/FStar_Pervasives_Native.cmx\ + _output/prims.cmx + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Classical.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked: C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.Native.fst\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +_output/FStar_Pervasives_Native.ml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + + +_output/FStar_Pervasives_Native.krml: C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked\ + + +_output/FStar_Pervasives_Native.cmx: _output/FStar_Pervasives_Native.ml\ + _output/prims.cmx + +FStar.Celestial.Map.fsti.checked: FStar.Celestial.Map.fsti\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked\ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked + +ALL_FST_FILES=\ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Classical.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.FunctionalExtensionality.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.Base.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.Properties.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.List.Tot.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Mul.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.Native.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Set.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Squash.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.StrongExcludedMiddle.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/experimental/FStar.OrdSet.fst \ + C:/cygwin64/home/aseemr/FStar/ulib/prims.fst \ + FStar.Celestial.Map.fst \ + FStar.Celestial.fst \ + +ALL_FSTI_FILES=\ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Classical.fsti \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.FunctionalExtensionality.fsti \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Pervasives.fsti \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Set.fsti \ + C:/cygwin64/home/aseemr/FStar/ulib/FStar.Squash.fsti \ + C:/cygwin64/home/aseemr/FStar/ulib/experimental/FStar.OrdSet.fsti \ + FStar.Celestial.Map.fsti \ + +ALL_CHECKED_FILES=\ + FStar.Celestial.Map.fsti.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.Native.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fsti.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.StrongExcludedMiddle.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Base.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Pervasives.fsti.checked \ + FStar.Celestial.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Classical.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fsti.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.Properties.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fsti.checked \ + FStar.Celestial.Map.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Set.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.FunctionalExtensionality.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Squash.fsti.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fsti.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/prims.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.Mul.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.OrdSet.fst.checked \ + C:/cygwin64/home/aseemr/FStar/bin/../ulib/.cache/FStar.List.Tot.fst.checked \ + +ALL_ML_FILES=\ + _output/prims.ml \ + _output/FStar_Pervasives_Native.ml \ + _output/FStar_Pervasives.ml \ + _output/FStar_Mul.ml \ + _output/FStar_Squash.ml \ + _output/FStar_Classical.ml \ + _output/FStar_StrongExcludedMiddle.ml \ + _output/FStar_List_Tot_Base.ml \ + _output/FStar_List_Tot_Properties.ml \ + _output/FStar_FunctionalExtensionality.ml \ + _output/FStar_Set.ml \ + _output/FStar_List_Tot.ml \ + _output/FStar_OrdSet.ml \ + _output/FStar_Celestial_Map.ml \ + _output/FStar_Celestial.ml \ + +ALL_KRML_FILES=\ + _output/prims.krml \ + _output/FStar_Pervasives_Native.krml \ + _output/FStar_Pervasives.krml \ + _output/FStar_Mul.krml \ + _output/FStar_Squash.krml \ + _output/FStar_Classical.krml \ + _output/FStar_StrongExcludedMiddle.krml \ + _output/FStar_List_Tot_Base.krml \ + _output/FStar_List_Tot_Properties.krml \ + _output/FStar_FunctionalExtensionality.krml \ + _output/FStar_Set.krml \ + _output/FStar_List_Tot.krml \ + _output/FStar_OrdSet.krml \ + _output/FStar_Celestial_Map.krml \ + _output/FStar_Celestial.krml \ + diff --git a/Celestial/Compiler/lib/Call.sol b/Celestial/Compiler/lib/Call.sol new file mode 100644 index 00000000..43365e63 --- /dev/null +++ b/Celestial/Compiler/lib/Call.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT + +//pragma solidity^0.6.8; +pragma solidity >=0.5.0 <0.7.0; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Compiler/lib/FStar.Celestial.Array.fst b/Celestial/Compiler/lib/FStar.Celestial.Array.fst new file mode 100644 index 00000000..febdfabf --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.Array.fst @@ -0,0 +1,80 @@ +(* This module implements Solidity Array semantics.*) + +module FStar.Celestial.Array +open FStar.Celestial +module List = FStar.List.Tot + +noeq +type array (a:Type u#a) = +{ + arr : (s:Seq.seq a{Seq.length s <= uint_max}); + def : a +} + +let create_empty #a v += { + arr = Seq.empty #a; + def = v +} + +let length #a s += Seq.length s.arr + +let update #a s n v += { + arr = Seq.upd s.arr n v; + def = s.def +} + +let push #a s v += { + arr = Seq.snoc s.arr v; + def = s.def +} + +let select #a s n += Seq.index s.arr n + +let delete #a s n += update s n s.def + +let def_of #a s += s.def + +let pop #a s += { + arr = Seq.slice s.arr 0 (Seq.length s.arr - 1); + def = s.def +} + +let lemma_len_create #_ _ = () +let lemma_len_update1 #_ _ _ _ = () +let lemma_len_push #_ _ _ = () +let lemma_len_pop #_ _ = () +let lemma_len_del #_ _ _ = () +let lemma_select_update1 #_ _ _ _ = () +let lemma_select_update2 #_ _ _ _ _ = () +let lemma_select_push #_ _ _ = () +let lemma_select_push2 #_ _ _ _ = () +let lemma_select_pop #_ _ _ = () +let lemma_select_delete1 #_ _ _ = () +let lemma_select_delete2 #_ _ _ _ = () +let lemma_default_update #_ _ _ _ = () +let lemma_default_push #_ _ _ = () +let lemma_default_pop #_ _ = () +let lemma_default_delete #_ _ _ = () +let lemma_pop_empty #_ _ = () + +let equal #a s1 s2 += (length s1 = length s2 + /\ (forall (i:nat{i < length s1}).{:pattern (select s1 i); (select s2 i)} (select s1 i == select s2 i)) + /\ (s1.def == s2.def)) + +let lemma_eq_intro #_ _ _ = () +let lemma_eq_refl #_ _ _ = () +let lemma_eq_elim #a s1 s2 = + assert (length s1 == Seq.length s1.arr); + assert (length s2 == Seq.length s2.arr); + assert (forall (i: nat). i < length s1 ==> select s1 i == Seq.index s1.arr i); + assert (forall (i: nat). i < length s1 ==> select s2 i == Seq.index s2.arr i); + Seq.lemma_eq_elim (s1.arr) (s2.arr) diff --git a/Celestial/Compiler/lib/FStar.Celestial.Array.fsti b/Celestial/Compiler/lib/FStar.Celestial.Array.fsti new file mode 100644 index 00000000..0fdc1134 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.Array.fsti @@ -0,0 +1,106 @@ +(* This library provides an abstract type array and models Solidity array semantics. *) + +module FStar.Celestial.Array +open FStar.Celestial + +val array (a:Type u#a) :Type u#a + +val create_empty: #a:Type -> a -> Tot (array a) +val length : #a:Type -> s:array a -> Tot (n:nat{n <= uint_max}) +val update : #a:Type -> s:array a -> i:nat{i < length s} -> a -> Tot (array a) +val push : #a:Type -> s:array a{length s < uint_max} -> a -> Tot (array a) +val select : #a:Type -> s:array a -> i:nat{i < length s} -> Tot a +val delete : #a:Type -> s:array a -> i:nat{i < length s} -> Tot (array a) +val def_of : #a:Type -> s:array a -> GTot a +val pop : #a:Type -> s:array a{length s > 0} -> Tot (array a) + +(* Lemmas on length *) + +val lemma_len_create: #a:Type -> i:a -> + Lemma (ensures (length (create_empty i) = 0)) + [SMTPat (length (create_empty i))] + +val lemma_len_update1: #a:Type -> s:array a -> i:nat{i < length s} -> v:a -> + Lemma (ensures (length (update s i v) = length s)) + [SMTPat (length (update s i v))] + +val lemma_len_push: #a:Type -> s:array a{length s < uint_max} -> v:a -> + Lemma (ensures length (push s v) = (length s) + 1) + [SMTPat (length (push s v))] + +val lemma_len_pop: #a:Type -> s:array a{length s > 0} -> + Lemma (ensures (length (pop s) == (length s) - 1)) + [SMTPat (length (pop s))] + +val lemma_len_del: #a:Type -> s:array a -> i:nat{i < length s} -> + Lemma (ensures (length (delete s i) = length s)) + [SMTPat (length (delete s i))] + +(* Lemmas on select *) + +val lemma_select_update1: #a:Type -> s:array a -> i:nat{i < length s} -> v:a -> + Lemma (ensures (select (update s i v) i == v)) + [SMTPat (select (update s i v) i)] + +val lemma_select_update2: #a:Type -> s:array a -> j:nat{j < length s} -> v:a -> i:nat{i =!= j /\ i < length s} -> + Lemma (ensures (select (update s j v) i == select s i)) + [SMTPat (select (update s j v) i)] + +val lemma_select_push: #a:Type -> s:array a{length s < uint_max} -> v:a -> + Lemma (ensures (select (push s v) (length s)) == v) + [SMTPat (select (push s v) (length s))] + +val lemma_select_push2: #a:Type -> s:array a{length s < uint_max} -> v:a -> i:nat{i < length s} -> + Lemma (ensures (select (push s v) i) == (select s i)) + [SMTPat (select (push s v) i)] + +val lemma_select_pop: #a:Type -> s:array a{length s > 1} -> i:nat{i < (length s) - 1} -> + Lemma (ensures (select (pop s) i) == select s i) + [SMTPat (select (pop s) i)] + +val lemma_select_delete1: #a:Type -> s:array a -> i:nat{i < length s} -> + Lemma (ensures select #a (delete #a s i) i == def_of s) + [SMTPat (select #a (delete #a s i) i)] + +val lemma_select_delete2: #a:Type -> s:array a -> i:nat{i < length s} -> j:nat{j < length s} -> + Lemma (ensures (i =!= j ==> select #a (delete #a s i) j == select #a s j)) + [SMTPat (select #a (delete #a s i) j)] + +(* Lemmas on default value *) + +val lemma_default_update: #a:Type -> s:array a -> i:nat{i < length s} -> v:a -> + Lemma (ensures def_of (update s i v) == def_of s) + [SMTPat (def_of (update s i v))] + +val lemma_default_push: #a:Type -> s:array a{length s < uint_max} -> v:a -> + Lemma (ensures def_of (push s v) == def_of s) + [SMTPat (def_of (push s v))] + +val lemma_default_pop: #a:Type -> s:array a{length s > 0} -> + Lemma (ensures def_of (pop s) == def_of s) + [SMTPat (def_of (pop s))] + +val lemma_default_delete: #a:Type -> s:array a -> i:nat{i < length s} -> + Lemma (ensures def_of (delete s i) == def_of s) + [SMTPat (def_of (delete s i))] + +val lemma_pop_empty: #a:Type -> s:array a{length s == 1} -> + Lemma (ensures (pop #a s) == create_empty #a (def_of s)) + [SMTPat (pop s)] + +val equal (#a:Type) (s1:array a) (s2:array a): Type0 + +val lemma_eq_intro: #a:Type -> s1:array a -> s2:array a -> + Lemma (requires (length s1 = length s2 /\ (forall (i:nat{i < length s1}).{:pattern (select s1 i); (select s2 i)} (select s1 i == select s2 i)) /\ (def_of s1) == (def_of s2))) + (ensures (equal s1 s2)) + [SMTPat (equal s1 s2)] + +val lemma_eq_refl: #a:Type -> s1:array a -> s2:array a -> + Lemma (requires (s1 == s2)) + (ensures (equal s1 s2)) + [SMTPat (equal s1 s2)] + +val lemma_eq_elim: #a:Type -> s1:array a -> s2:array a -> + Lemma (requires (equal s1 s2)) + (ensures (s1 == s2)) + [SMTPat (equal s1 s2)] diff --git a/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fst b/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fst new file mode 100644 index 00000000..bcab51a6 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fst @@ -0,0 +1,47 @@ +module FStar.Celestial.ContractsMap + +open FStar.Celestial +module S = FStar.Set +module M = FStar.Map + +noeq type cvalue = { + cvalue_a : Type0; + cvalue_inst : cvalue_a; +} + +noeq +type cmap = { + ctr : pos; + contracts : (m:M.t address cvalue{ + (ctr > 0) /\ + (~ (m `M.contains` 0)) /\ + (forall (i: address).{:pattern M.contains m i} m `M.contains` i ==> i < ctr) + }); +} + +let live_in #a c m = + m.contracts `M.contains` c /\ + (M.sel m.contracts c).cvalue_a == a + +let not_in #_ c m = ~ (M.contains m.contracts c) + + +let sel #_ c m = (M.sel m.contracts c).cvalue_inst + +let upd #a c m x = + let ct = M.sel m.contracts c in + let ct = { ct with cvalue_inst = x } in + { m with contracts = M.upd m.contracts c ct } + +let create #a m x = + let cval = { cvalue_a = a; cvalue_inst = x } in + m.ctr, { m with ctr = m.ctr + 1; + contracts = M.upd m.contracts m.ctr cval } + +let distinct_addrs_distinct_types #_ #_ _ _ _ = () +let distinct_addrs_unused #_ #_ _ _ _ = () +let live_in_not_in #_ _ _ = () +let live_not_null #_ _ _ = () +let upd_modifies #_ _ _ _ = () +let sel_upd #_ _ _ _ = () +let create_modifies #_ _ _ = () diff --git a/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fsti b/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fsti new file mode 100644 index 00000000..31ab8b95 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.ContractsMap.fsti @@ -0,0 +1,74 @@ +module FStar.Celestial.ContractsMap + +open FStar.Celestial +module S = FStar.Set + +/// This library provides an abstract type of contractsmap which models +/// the logical mapping from addresses to contract instances in a blockchain. + +val cmap : Type u#1 + +let addr_of (#a:Type0) (c:contract a) : address = c + +val live_in (#a:Type0) (c:contract a) (m:cmap) : prop + +val not_in (#a:Type0) (c:contract a) (m:cmap) : prop + +unfold +let fresh (#a:Type0) (c:contract a) (m0 m1:cmap) : prop = + c `not_in` m0 /\ c `live_in` m1 + +val sel (#a:Type0) (c:contract a) (m:cmap{c `live_in` m}) : a + +val upd (#a:Type0) (c:contract a) (m:cmap{c `live_in` m}) (x:a) : cmap + +val create (#a:Type0) (m:cmap) (x:a) : contract a & cmap + +let modifies_addrs (s:S.set address) (m0 m1:cmap) = + (forall (a:Type0) (c:contract a). + c `live_in` m0 ==> c `live_in` m1) /\ + (forall (a:Type0) (c:contract a). + ((~ (S.mem c s)) /\ c `live_in` m0) ==> sel c m0 == sel c m1) + +val distinct_addrs_distinct_types (#a #b:Type0) (m:cmap) (ca:contract a) (cb:contract b) +: Lemma + (requires a =!= b /\ ca `live_in` m /\ cb `live_in` m) + (ensures ~ (eq2 #address ca cb)) + [SMTPat (ca `live_in` m); SMTPat (cb `live_in` m)] + +val distinct_addrs_unused (#a #b:Type0) (c1:contract a) (c2:contract b) (m:cmap) +: Lemma + (requires c1 `not_in` m /\ ~ (c2 `not_in` m)) + (ensures addr_of c1 =!= addr_of c2 /\ (~ (c1 === c2))) + [SMTPat (c1 `not_in` m); SMTPat (c2 `not_in` m)] + +val live_in_not_in (#a:Type0) (c:contract a) (m:cmap) +: Lemma + (requires c `live_in` m) + (ensures (~ (c `not_in` m))) + [SMTPatOr [[SMTPat (c `live_in` m)]; [SMTPat (c `not_in` m)]]] + +val live_not_null (#a:Type0) (m:cmap) (c:contract a) +: Lemma + (requires c `live_in` m) + (ensures c <> null) + [SMTPat (c `live_in` m)] + +val upd_modifies (#a:Type0) (c:contract a) (m:cmap{c `live_in` m}) (x:a) +: Lemma + (modifies_addrs (Set.singleton c) m (upd c m x)) + [SMTPat (upd c m x)] + +val sel_upd (#a:Type0) (c:contract a) (m:cmap{c `live_in` m}) (x:a) +: Lemma + (sel c (upd c m x) == x) + [SMTPat (sel c (upd c m x))] + +val create_modifies (#a:Type0) (m:cmap) (x:a) +: Lemma + (let c, m' = create m x in + c =!= null /\ + fresh c m m' /\ + modifies_addrs S.empty m m' /\ + sel c m' == x) + [SMTPat (create m x)] diff --git a/Celestial/Compiler/lib/FStar.Celestial.Effect.fst b/Celestial/Compiler/lib/FStar.Celestial.Effect.fst new file mode 100644 index 00000000..4220acd8 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.Effect.fst @@ -0,0 +1,323 @@ +module FStar.Celestial.Effect + +open FStar.Celestial +module M = FStar.Map +module CM = FStar.Celestial.ContractsMap + +noeq +type bstate = { + cmap : CM.cmap; + balances : M.t address uint; + log : log +} + +noeq +type state = { + tx_begin : bstate; + current : bstate; +} + + +(* Pure functions to read and modify state *) + +let pure_commit_tx (st:state) : state = { st with tx_begin = st.current } +let pure_revert_tx (st:state) : state = { st with current = st.tx_begin } + +let pure_get_cmap (st:state) = st.current.cmap +let pure_get_log (st:state) = st.current.log + +let pure_update_cmap (st:state) (m:CM.cmap) = + { st with current = { st.current with cmap = m } } +let pure_update_log (st:state) (l:log) = + { st with current = { st.current with log = l } } + +let pure_get_log_bst (bst:bstate) = bst.log +let pure_update_log_bst (bst:bstate) (l:log) = + { bst with log = l } + +let pure_get_balance_st (addr:address) (st:state) = M.sel st.current.balances addr +let pure_set_balance_st (addr:address) (n:uint) (st:state) = + { st with current = { st.current with + balances = M.upd (st.current.balances) addr n } } + +let pure_get_balance_bst (addr:address) (bst:bstate) = M.sel bst.balances addr +let pure_set_balance_bst (addr:address) (n:uint) (bst:bstate) = + { bst with balances = M.upd bst.balances addr n } + + +(* Effect definition *) + +new_effect STETH = STATE_h state + +effect StEth (a:Type) (pre:state -> Type0) (post:(s:state{pre s}) -> a -> state -> Type0) = + STETH a (fun p s0 -> pre s0 /\ (forall (x:a) (s1:state). post s0 x s1 ==> p x s1)) + +unfold +let lift_pure_steth (a:Type) (wp:pure_wp a) (p:a -> state -> Type0) (s0:state) = wp (fun x -> p x s0) + +sub_effect PURE ~> STETH = lift_pure_steth + +type result (a:Type) = + | V : x:a -> result a + | E : s:string -> result a + +type pre_t = state -> Type0 +type post_t (a:Type) = result a -> state -> Type0 +type wp_t (a:Type) = post_t a -> pre_t + +unfold +let return_wp (a:Type) (x:a) : wp_t a = + fun p s -> p (V x) s + +unfold +let bind_wp (_:range) (a:Type) (b:Type) (wp1:wp_t a) (wp2:a -> wp_t b) : wp_t b = + fun p st0 -> wp1 (fun x st1 -> + match x with + | V x -> (wp2 x) p st1 + | E x -> p (E x) st1) st0 + +unfold +let if_then_else_wp (a:Type) (p:Type0) (wp_then wp_else: wp_t a) : wp_t a = + fun post st0 -> l_ITE p (wp_then post st0) (wp_else post st0) + +unfold +let ite_wp (a: Type) (wp:wp_t a) : wp_t a = + fun p st0 -> + forall (k:post_t a). + (forall (x:result a) (st1:state). {:pattern (guard_free (k x st1))} p x st1 ==> k x st1) ==> wp k st0 + +unfold +let stronger (a:Type) (wp1 wp2:wp_t a) = forall (p:post_t a) (st:state). wp1 p st ==> wp2 p st + +unfold +let close_wp (a b:Type) (wp:(b -> GTot (wp_t a))) : wp_t a = + fun p st0 -> forall (b:b). wp b p st0 + +unfold +let trivial (a:Type) (wp:wp_t a) = forall st0. wp (fun _ _ -> True) st0 + +new_effect { + ETH : a:Type -> wp:wp_t a -> Effect + with + return_wp = return_wp; + bind_wp = bind_wp; + if_then_else = if_then_else_wp; + ite_wp = ite_wp; + stronger = stronger; + close_wp = close_wp; + trivial = trivial +} + +unfold +let lift_steth_eth (a:Type) (wp:st_wp_h state a) : wp_t a = + fun p st -> wp (fun x st1 -> p (V x) st1) st + +sub_effect STETH ~> ETH = lift_steth_eth + + +(*** These are primitive effect actions. ***) +assume val get (_:unit) : STETH state (fun p st -> p st st) +assume val put (st:state) : STETH unit (fun p _ -> p () st) +assume val raise (#a:Type) (s:string) : ETH a (fun p st -> p (E s) st) + + +(* Begin, commit, getters, setters *) + +let begin_transaction (_:unit) : STETH unit (fun p st -> p () st) = () + +let commit_transaction (_:unit) +: STETH unit (fun p st -> p () (pure_commit_tx st)) += let st = get () in + put ({ st with tx_begin = st.current }) + +let revert (#a:Type) (s:string) +: ETH a (fun p st -> p (E s) (pure_revert_tx st)) += let st = get () in + put ({ st with current = st.tx_begin }); + raise s + +let create_contract (#a:Type0) (x:a) +: STETH (contract a) (fun p st -> + let c, m = CM.create st.current.cmap x in + p c (pure_update_cmap st m)) += let st = get () in + let c, m = CM.create st.current.cmap x in + put (pure_update_cmap st m); + c + +let get_contract (#a:Type0) (c:contract a) +: STETH a (fun p st -> + c `CM.live_in` st.current.cmap /\ + (let c = CM.sel c st.current.cmap in + p c st)) += let st = get () in + CM.sel c st.current.cmap + +let get_balance (addr:address) +: STETH nat + (fun p st -> p (pure_get_balance_st addr st) st) += let st = get () in + pure_get_balance_st addr st + +let set_contract (#a:Type0) (c:contract a) (x:a) +: STETH unit (fun p st -> + c `CM.live_in` st.current.cmap /\ + p () (pure_update_cmap st (CM.upd c st.current.cmap x))) += let st = get () in + let m = CM.upd c st.current.cmap x in + put (pure_update_cmap st m) + +let set_balance (addr:address) (n:nat{n <= uint_max}) +: STETH unit (fun p st -> p () (pure_set_balance_st addr n st)) += let st = get () in + put (pure_set_balance_st addr n st) + +let add_event (ev:event) +: STETH unit + (fun p st -> p () (pure_update_log st (ev::(pure_get_log st)))) += let st = get () in + put (pure_update_log st (ev::(pure_get_log st))) + +effect Eth0 + (a:Type) + (pre:state -> Type0) + (post:(st:state{pre st}) -> result a -> state -> Type0) += ETH a + (fun p st -> pre st /\ (forall (x:result a) (st1:state). post st x st1 ==> p x st1)) + +effect Eth + (a:Type) + (pre:bstate -> Type0) + (revert:(bst:bstate{pre bst}) -> Type0) + (post:(bst:bstate{pre bst /\ (~ (revert bst))}) -> a -> bstate -> Type0) += Eth0 a + (fun st -> pre st.current) + (fun st0 r st1 -> + (E? r <==> revert st0.current) /\ + (V? r ==> post st0.current (V?.x r) st1.current)) + +effect Eth1 + (a:Type) + (pre:bstate -> Type0) + (revert:(bst:bstate{pre bst}) -> Type0) + (post:(bst:bstate{pre bst /\ (~ (revert bst))}) -> a -> bstate -> Type0) += Eth0 a + (fun st -> pre st.current) + (fun st0 r st1 -> + (revert st0.current ==> E? r) /\ + (V? r ==> post st0.current (V?.x r) st1.current)) + +let modifies_cmap_only (s:Set.set address) (bst0 bst1:bstate) = + CM.modifies_addrs s bst0.cmap bst1.cmap /\ + bst0.balances == bst1.balances /\ + bst0.log == bst1.log + +let modifies_cmap_and_log_only (s:Set.set address) (l: list event) (bst0 bst1:bstate) = + CM.modifies_addrs s bst0.cmap bst1.cmap /\ + bst0.balances == bst1.balances /\ + bst1.log == l@bst0.log + +let modifies_balances (s:Set.set address) (m0 m1: M.t address (n:nat{n <= uint_max})) = + (forall (a: address). + (~ (Set.mem a s)) ==> M.sel m0 a == M.sel m1 a) + +let modifies_cmap_log_balances (cs:Set.set address) (l: list event) (bs:Set.set address) (bst0 bst1:bstate) = + CM.modifies_addrs cs bst0.cmap bst1.cmap /\ + modifies_balances bs bst0.balances bst1.balances /\ + bst1.log == l@bst0.log + +let modifies_log_balances_only (l: list event) (bs:Set.set address) (bst0 bst1:bstate) = + CM.modifies_addrs (Set.empty) bst0.cmap bst1.cmap /\ + modifies_balances bs bst0.balances bst1.balances /\ + bst1.log == l@bst0.log + + +(* emit and send definitions *) + +let emit (#a:Type0) (evn:string) (payload:a) +: STETH unit + (fun p st -> p () (pure_update_log st ((mk_event null evn payload)::(pure_get_log st)))) += add_event (mk_event null evn payload) + +// assume val call_value (sender:address) (recipient:address) (amount:uint) +// : Eth bool +// (fun _ -> True) +// (fun _ -> False) +// (fun st0 _ st1 -> st0 == st1) + +let transfer (#a:Type0) (c_addr:contract a) (to:address) (amount:uint) +: Eth1 unit + (fun bst -> c_addr `CM.live_in` bst.cmap /\ (pure_get_balance_bst c_addr bst) >= amount) + (fun bst -> False) + (fun bst0 r bst1 -> + (bst1.log == ((mk_event to eTransfer amount)::[])@(bst0.log)) /\ + (bst1.cmap == bst0.cmap) /\ + ( + if c_addr <> to then + modifies_cmap_log_balances (Set.empty) ((mk_event to eTransfer amount)::[]) (Set.union (Set.singleton c_addr) (Set.singleton to)) bst0 bst1 /\ + (let b = pure_get_balance_bst c_addr bst0 in + let b_to = pure_get_balance_bst to bst0 in + let b_to_updated = (if b_to + amount > uint_max then (b_to + amount - uint_max) else (b_to + amount)) in + M.equal bst1.balances (M.upd (M.upd bst0.balances c_addr (b - amount)) to (b_to_updated))) + else + bst1.balances == bst0.balances + ) + ) += let b = get_balance c_addr in + let _ = add_event (mk_event to eTransfer amount) in + let b_to = get_balance to in + if c_addr <> to then begin + set_balance c_addr (b - amount); + (if b_to + amount > uint_max then set_balance to (b_to + amount - uint_max) + else set_balance to (b_to + amount)) + end + else + () + +/// Models a call made to an external/unknown entity +/// caller's state remains the same since reentrancy is disallowed +/// caller's balance may increase/decrease due to selfdestruct() and overflow +assume val unknown_call : (#a:Type0) -> (self:contract a) -> bytes -> Eth (bool * bytes) +(fun bst -> self `CM.live_in` bst.cmap) +(fun bst -> False) +(fun bst0 _ bst1 -> + (self `CM.live_in` bst1.cmap) + /\ (CM.sel self bst1.cmap) == (CM.sel self bst0.cmap) +) + + +assume val call_uint : (#a:Type0) -> (self:contract a) -> (b:bytes) -> Eth1 uint +(fun bst -> self `CM.live_in` bst.cmap) +(fun bst -> False) +(fun bst0 _ bst1 -> + (self `CM.live_in` bst1.cmap) + /\ (CM.sel self bst1.cmap) == (CM.sel self bst0.cmap) +) + +assume val call_bool : (#a:Type0) -> (self:contract a) -> (b:bytes) -> Eth1 bool +(fun bst -> self `CM.live_in` bst.cmap) +(fun bst -> False) +(fun bst0 _ bst1 -> + (self `CM.live_in` bst1.cmap) + /\ (CM.sel self bst1.cmap) == (CM.sel self bst0.cmap) +) + +assume val addmod : (x:uint) -> (y:uint) -> (k:uint) -> Eth uint +(fun _ -> True) +(fun _ -> k == 0) +(fun _ r _ -> r == (x + y) % k) + +assume val mulmod : (x:uint) -> (y:uint) -> (k:uint) -> Eth uint +(fun _ -> True) +(fun _ -> k == 0) +(fun _ r _ -> r == (op_Multiply x y) % k) + +let safe_mul (a:uint) (b:uint) : Eth uint +(fun _ -> True) +(fun _ -> (op_Multiply a b) > uint_max) +(fun bst0 r bst1 -> + bst0 == bst1 + /\ r == (_mul a b) +) += if (op_Multiply a b) > uint_max then revert "" + else (_mul a b) \ No newline at end of file diff --git a/Celestial/Compiler/lib/FStar.Celestial.Map.fst b/Celestial/Compiler/lib/FStar.Celestial.Map.fst new file mode 100644 index 00000000..885e1699 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.Map.fst @@ -0,0 +1,136 @@ +module FStar.Celestial.Map + +open FStar.OrdSet +module S = FStar.OrdSet +open FStar.FunctionalExtensionality +module F = FStar.FunctionalExtensionality + +noeq +type t (key:eqtype) (value:Type) (f:cmp key) += { + domain: S.ordset key f; + def: value; + mappings:m:(key ^-> value){forall x. (~ (S.mem x domain)) ==> m x == def} +} + +let const #key #value #f v += { + domain = S.empty; + def = v; + mappings = F.on key (fun _ -> v); +} + +let sel #key #value #f m k += m.mappings k + +let domain #key #value #f m += m.domain + +let upd #key #value #f m k v += { + mappings = F.on key (fun x -> if x = k then v else m.mappings x); + domain = (S.union (domain m) (singleton k)); + def = m.def +} + +let contains #key #value #f m k += S.mem k m.domain + +let delete #key #value #f m k += { + domain = S.remove k (m.domain); + def = m.def; + mappings = F.on key (fun x -> if x = k then m.def else m.mappings x); +} + +let choose #key #value #f m += match OrdSet.choose (m.domain) with + | None -> None + | Some x -> Some (x, (m.mappings x)) + +let size #key #value #f m += S.size m.domain + +let equal #key #value #f m1 m2 += F.feq m1.mappings m2.mappings /\ + S.equal m1.domain m2.domain /\ + m1.def == m2.def + + +let def_of #key #value #f m += m.def + +let mappings_of #key #value #f m += m.mappings + +let size_const #key #value #f x = () +let size_delete #key #value #f y m = () +let eq_intro #key #value #f m1 m2 = () +let eq_lemma #key #value #f m1 m2 = () +let sel_lemma #key #value #f x m = () +let sel_upd1 #key #value #f x y m = () +let sel_upd2 #key #value #f x y x' m = () +let sel_const #key #value #f x y = () +let contains_upd1 #key #value #f x y x' m = () +let contains_upd2 #key #value #f x y x' m = () +let domain_upd #key #value #f m k v = () +let domain_upd2 #key #value #f m k v = () +let domain_check #key #value #f m k v = () +let def_of_upd #key #value #f x y m = () +let def_of_delete #key #value #f x m = () +let def_of_const #key #value #f y = () +let sel_del2 #key #value #f x x' m = () +let upd_order #key #value #f x y x' y' m = () +let upd_same_k #key #value #f x y y' m = () +let domain_const #key #value #f y = () +let contains_delete #key #value #f x y m = () +let contains_const #key #value #f y k = () +let eq_delete #key #value #f x m = () +let delete_upd #key #value #f x x' y' m = () +let delete_upd_same_k #key #value #f x y m = () +let upd_delete_same_k #key #value #f x y m = () +let choose_const #key #value #f y = () +let choose_m #key #value #f m = () +let choose_upd #key #value #f m x y = () +let choose_not_already_exist #key #value #f m x y = () +let non_zero_size_choose #_ #_ #_ _ = () + +let contains_choose #_ #_ #_ _ = () +let size_upd1 #k #v #f m x y = + let m1 = (upd m x y) in + if (not (mem x m.domain)) then OrdSet.size_union2 #k #f (m.domain) x; () + +let size_upd2 #k #v #f m x y = + let m1 = (upd m x y) in + if (mem x m.domain) then OrdSet.size_union3 #k #f (m.domain) x; () + +let size_upd #_ #_ #_ m x y = size_upd1 m x y; size_upd2 m x y; () + +let choose_after_update #key #value #f m x y = + choose_upd m x y; + non_zero_size_choose m; + + let m1 = (upd m x y) in + let k' = (fst (Some?.v (choose m1))) in + let k'' = (fst (Some?.v (choose m))) in + if (x <> k') then OrdSet.choose_upd_det (m.domain) x ; () + + +let choose_commute_up_del #key #value #f m x y = + choose_upd m x y; + non_zero_size_choose m; + let k'' = fst (Some?.v (choose m)) in + let rest_m = (delete m k'') in + let m1 = (upd m x y) in + let k' = fst (Some?.v (choose m1)) in + let rest_m1 = delete m1 k' in + if (x <> k') then OrdSet.choose_upd_det (m.domain) x + else + if ((contains m x) && (x <> k'') ) then OrdSet.choose_upd_det2 (m.domain) x + +let empty_contains #_ #_ #_ _ _ = () +let contains_size #_ #_ #_ _ _ = () +let delete_upd_cancel_out #k #v #f m x y = () + +let fold_base_case _ _ _ = () +let fold_induction _ _ _ = () diff --git a/Celestial/Compiler/lib/FStar.Celestial.Map.fsti b/Celestial/Compiler/lib/FStar.Celestial.Map.fsti new file mode 100644 index 00000000..4feaa036 --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.Map.fsti @@ -0,0 +1,265 @@ +module FStar.Celestial.Map + +open FStar.OrdSet +module S = FStar.OrdSet +open FStar.FunctionalExtensionality +module F = FStar.FunctionalExtensionality + +type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = + (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) + /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) + /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) + +let cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} + +val t (key:eqtype) (value:Type) (f:cmp key) : Type u#a + +val const : #key:eqtype -> #value:Type -> #f:cmp key -> x:value -> Tot (t key value f) +val sel : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> key -> Tot value +val domain : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> Tot (ordset key f) +val upd : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> key -> value -> Tot (t key value f) +val contains : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> key -> Tot bool +val delete : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> key -> Tot (t key value f) +val choose : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> Tot (option (key * value)) +val size : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> Tot nat +val equal : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> t key value f -> Tot prop +val def_of : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> Tot value +val mappings_of : #key:eqtype -> #value:Type -> #f:cmp key -> t key value f -> Tot (key ^-> value) + +val size_const: #k:eqtype -> #v:Type -> #f:cmp k -> x:v -> + Lemma (requires True) + (ensures (size #k #v #f (const #k #v #f x) = 0)) + [SMTPat (size #k #v #f (const #k #v #f x))] + +val size_delete: #k:eqtype -> #v:Type -> #f:cmp k -> y:k -> m:t k v f -> + Lemma (requires (contains #k #v #f m y)) + (ensures (size #k #v #f m = size #k #v #f (delete #k #v #f m y) + 1)) + [SMTPat (size #k #v #f (delete #k #v #f m y))] + +val eq_intro: #k:eqtype -> #v:Type -> #f:cmp k -> m1:t k v f -> m2:t k v f -> + Lemma (requires (S.equal (domain m1) (domain m2))/\(def_of m1 == def_of m2) /\ F.feq (mappings_of m1) (mappings_of m2) ) + (ensures (equal m1 m2)) + [SMTPat (equal m1 m2)] + +val eq_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> m1:t k v f -> m2:t k v f -> + Lemma (requires (equal m1 m2)) + (ensures (m1 == m2)) + [SMTPat (equal m1 m2)] + +val sel_lemma: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> m:t k v f -> + Lemma (requires True) + (ensures + (if contains m x then (sel m x == mappings_of m x) + else (sel m x == def_of m))) + [SMTPat (sel m x)] + +val sel_upd1: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> m:t k v f -> + Lemma (requires True) + (ensures sel (upd m x y) x == y) + [SMTPat (sel (upd m x y) x)] + +val sel_upd2: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> m:t k v f -> + Lemma (requires True) + (ensures (x =!= x' ==> (sel (upd m x y) x' == sel m x'))) + [SMTPat (sel (upd m x y) x')] + +val sel_const: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> + Lemma (requires True) + (ensures (sel (const #k #v #f y) x == y)) + [SMTPat (sel (const #k #v #f y) x)] + +val contains_upd1: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> m:t k v f -> + Lemma (requires True) + (ensures (contains (upd m x y) x' = (x = x' || contains m x'))) + [SMTPat (contains (upd m x y) x')] + +val contains_upd2: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> m:t k v f -> + Lemma (requires True) + (ensures (x =!= x' ==> (contains (upd m x y) x' = contains m x'))) + [SMTPat (contains (upd m x y) x')] + +val domain_upd : #key:eqtype -> #value:Type -> #f:cmp key -> m: t key value f -> k:key -> v:value -> + Lemma (requires True) + (ensures (domain (upd m k v)) == (S.union (domain m) (singleton k))) + [SMTPat (domain (upd m k v))] + +val domain_upd2 : #key:eqtype -> #value:Type -> #f:cmp key -> m: t key value f -> k:key -> v:value -> + Lemma (requires True) + (ensures (contains m k) ==> OrdSet.equal (domain (upd m k v)) (domain m) ) + [SMTPat (domain (upd m k v))] + +val domain_check : #key:eqtype -> #value:Type -> #f:cmp key -> m: t key value f -> k:key -> v:value -> + Lemma (requires True) + (ensures (not (contains m k)) ==> OrdSet.equal ((empty)) (OrdSet.intersect (domain m) (singleton k)) ) + [SMTPat (domain (upd m k v))] + +val def_of_upd: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> m:t k v f -> + Lemma (requires True) + (ensures (def_of m) == (def_of (upd m x y))) + [SMTPat (def_of (upd m x y))] + +val def_of_delete: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> m:t k v f -> + Lemma (requires True) + (ensures (def_of (delete #k #v #f m x) == def_of m)) + [SMTPat (def_of (delete #k #v #f m x))] + +val def_of_const: #k:eqtype -> #v:Type -> #f:cmp k -> y:v -> + Lemma (requires True) + (ensures def_of (const #k #v #f y) == y) + [SMTPat (def_of (const #k #v #f y))] + +val sel_del2: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> x':k -> m:t k v f -> + Lemma (requires True) + (ensures (x =!= x' ==> sel (delete m x) x' == sel m x')) + [SMTPat (sel (delete m x) x')] + +val upd_order: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> x':k -> y':v -> m:t k v f -> + Lemma (requires (x =!= x')) + (ensures (equal (upd (upd m x' y') x y) (upd (upd m x y) x' y'))) + [SMTPat (upd (upd m x' y') x y)] //This pattern is too aggresive; it will fire for any pair of upds + +val upd_same_k: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> y':v -> m:t k v f -> + Lemma (requires True) + (ensures (equal (upd (upd m x y') x y) (upd m x y))) + [SMTPat (upd (upd m x y') x y)] //This pattern is too aggresive; it will fire for any pair of upds + +val domain_const: #k:eqtype -> #v:Type -> #f:cmp k -> y:v -> + Lemma (requires True) + (ensures (domain #k #v #f (const #k #v #f y) = S.empty)) + [SMTPat (domain #k #v #f (const #k #v #f y))] + +val contains_delete: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:k -> m:t k v f -> + Lemma (requires True) + (ensures (contains (delete #k #v #f m y) x = (contains #k #v #f m x && not (x = y)))) + [SMTPat (contains #k #v #f (delete #k #v #f m y) x)] + +val contains_const: #k:eqtype -> #v:Type -> #f:cmp k -> y:v -> x:k -> + Lemma (requires True) + (ensures ~ (contains #k #v #f (const #k #v #f y) x)) + [SMTPat (contains #k #v #f (const #k #v #f y) x)] + +val eq_delete: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> m:t k v f -> + Lemma (requires (not (mem x (domain #k #v #f m)))) + (ensures (equal m (delete #k #v #f m x))) + [SMTPat (delete #k #v #f m x)] + +val delete_upd: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> x':k -> y':v -> m:t k v f -> + Lemma (requires (x =!= x')) + (ensures (equal (delete #k #v #f (upd m x' y') x) (upd (delete #k #v #f m x) x' y'))) + [SMTPat (delete #k #v #f (upd #k #v #f m x' y') x)] + +val delete_upd_same_k: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> m:t k v f -> + Lemma (requires True) + (ensures (equal (delete #k #v #f (upd m x y) x) (delete #k #v #f m x))) + [SMTPat (delete #k #v #f (upd m x y) x)] // Is this pattern is too aggresive; will it fire for any pair of upds? + +val upd_delete_same_k: #k:eqtype -> #v:Type -> #f:cmp k -> x:k -> y:v -> m:t k v f -> + Lemma (requires True) + (ensures (equal (upd (delete #k #v #f m x) x y) (upd m x y))) + [SMTPat (upd (delete #k #v #f m x) x y)] //Is this pattern is too aggresive; will it fire for any pair of upds? + +val choose_const: #k:eqtype -> #v:Type -> #f:cmp k -> y:v -> + Lemma (requires True) + (ensures (None? (choose #k #v #f (const #k #v #f y))) <==> (domain #k #v #f (const #k #v #f y) == S.empty)) + [SMTPat (choose #k #v #f (const #k #v #f y))] + +val choose_m: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> + Lemma (requires (~ ((domain m) == S.empty))) + (ensures (Some? (choose #k #v #f m) + /\ (sel #k #v #f m (fst (Some?.v (choose #k #v #f m))) == (snd (Some?.v (choose #k #v #f m)))) + /\ (equal m (upd #k #v #f (delete #k #v #f m (fst (Some?.v (choose #k #v #f m)))) + (fst (Some?.v (choose #k #v #f m))) + (snd (Some?.v (choose #k #v #f m))) + ) + ) + ) + ) + [SMTPat (choose #k #v #f m)] + +val choose_upd: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v -> + Lemma (requires True) + (ensures (Some? (choose (upd m x y)))) + +val choose_not_already_exist: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v -> + Lemma (requires True) + (ensures ( + choose_upd m x y; + (x <> (fst (Some?.v (choose (upd m x y))))) ==> (size m > 0))) + +val non_zero_size_choose: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> + Lemma + (requires size m > 0) + (ensures Some? (choose m)) + +val contains_choose: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> + Lemma + (requires (Some? (choose m))) + (ensures contains m (fst (Some?.v (choose m)))) + +val size_upd1: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v + -> Lemma (requires True) + (ensures (not (contains m x) ==> size (upd m x y) == size m + 1)) + +val size_upd2: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v + -> Lemma (requires True) + (ensures (contains m x) ==> size (upd m x y) == size m) + +val size_upd: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v -> Lemma +(requires (True)) +(ensures ( + (contains #k #v #f m x ==> size (upd m x y) == size m) /\ + ((~ (contains #k #v #f m x)) ==> size (upd m x y) == size m + 1) /\ + (size (upd m x y) > 0)) ) + + +val choose_after_update: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v -> Lemma +(requires (size m > 0)) +(ensures ( + (x <> (fst (Some?.v (choose (upd m x y))))) ==> + ((fst (Some?.v (choose m))) == ((fst (Some?.v (choose (upd m x y)))))) /\ + ((snd (Some?.v (choose m))) == ((snd (Some?.v (choose (upd m x y)))))) +)) + +val choose_commute_up_del: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> y:v -> Lemma +(requires (size m >0)) +(ensures ( + ( x <> (fst (Some?.v (choose (upd m x y)))) + \/ ((contains m x) /\ (x <> (fst (Some?.v (choose m))))) + ) ==> + ( + let k'' = fst (Some?.v (choose m)) in + let rest_m = (delete m k'') in + let m1 = (upd m x y) in + let k' = fst (Some?.v (choose m1)) in + let rest_m1 = delete m1 k' in + (upd rest_m x y) == rest_m1 + ) +) +) + +val empty_contains: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> + Lemma + (requires size m == 0) + (ensures ~ (contains m x)) + +val contains_size: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k -> + Lemma + (requires contains m x) + (ensures size m > 0) + +val delete_upd_cancel_out: #k:eqtype -> #v:Type -> #f:cmp k -> m:t k v f -> x:k{~ (contains m x)} -> y:v -> + Lemma + (requires True) + (ensures (delete (upd m x y) x) == m) + +let rec fold (#key:eqtype) (#value:_) (#accType:_) (#f:_) (g:key -> value -> accType -> accType) (m:t key value f) (a:accType) +: Tot accType (decreases (size m)) += if size m = 0 then a + else begin + non_zero_size_choose m; + let Some (k, v) = choose m in + let rest_m = delete m k in + contains_choose m; + fold g (delete m k) (g k v a) + end + diff --git a/Celestial/Compiler/lib/FStar.Celestial.fst b/Celestial/Compiler/lib/FStar.Celestial.fst new file mode 100644 index 00000000..382cfcfa --- /dev/null +++ b/Celestial/Compiler/lib/FStar.Celestial.fst @@ -0,0 +1,229 @@ +module FStar.Celestial + +module M = FStar.Celestial.Map +open FStar.Mul + +let address = nat +let null:address = 0 +assume type bytes +assume type bytes4 +assume type bytes20 + +let contract (a:Type0) : Type0 = address + +let int_max : int = 57896044618658097711785492504343953926634992332820282019728792003956564819967 +let int_min : int = -1 * (57896044618658097711785492504343953926634992332820282019728792003956564819968) +let uint_max : int = 115792089237316195423570985008687907853269984665640564039457584007913129639935 +let uint8_max : int = 255 + +type uint = n:nat{n <= uint_max} +type int = n:int{n >= int_min /\ n <= int_max} +type uint8 = n:nat{n <= uint8_max} +let bytes32 = uint + +noeq +type event = { + payload_typ : Type0; + receiver : address; + name : string; + payload : payload_typ +} + +let mk_event (#a:Type0) (to:address) (evn:string) (payload:a) = { + payload_typ = a; + receiver = to; + name = evn; + payload = payload +} + +type log = list event + +let eTransfer : string = "eTransfer" + +noeq +type block = { + coinbase : (a:address{a <> null}); + difficulty : uint; + gaslimit : uint; + number : (n:uint{n <> 0}); + timestamp : (n:uint{n <> 0}) +} + +noeq +type tx = { + origin : (a:address{a <> null}); + gasprice : uint +} + +let _add (a b : uint) : Pure uint +(requires a + b <= uint_max) +(ensures fun r -> r == a + b) += a + b + +let _sub (a b : uint) : Pure uint +(requires a >= b) +(ensures fun r -> r == a - b) += a - b + +let _mul (a b : uint) : Pure uint +(requires a * b <= uint_max) +(ensures fun r -> r == a * b) += a * b + +let _div (a:uint) (b:uint{b <> 0}) : Pure uint +(requires True) +(ensures fun r -> r == op_Division a b) += op_Division a b + +let fold_add_fun (#key:eqtype) : key -> uint -> Prims.int -> Prims.int = fun _ v1 v2 -> v1 + v2 + +let sum_mapping_aux (#key:eqtype) (#c:M.cmp key) (m:M.t key uint c) (n:Prims.int) : Prims.int = + M.fold fold_add_fun m n + +let rec sum_mapping_acc (#key:eqtype) (#c:M.cmp key) (m:M.t key uint c) (n1 n2:Prims.int) +: Lemma + (ensures sum_mapping_aux m (n1 + n2) = n1 + sum_mapping_aux m n2) + (decreases (M.size m)) += if M.size m = 0 then () + else begin + M.non_zero_size_choose m; + let Some (k, v) = M.choose m in + let rest_m = M.delete m k in + M.contains_choose m; + sum_mapping_acc rest_m n1 (v+n2) + end + +let sum_mapping_rest (#key:eqtype) (#c:M.cmp key) (m:M.t key uint c) (n:Prims.int) +: Lemma + (requires M.size m > 0) + (ensures sum_mapping_aux m n == + (M.non_zero_size_choose m; + let Some (k, v) = M.choose m in + let rest_m = M.delete m k in + v + sum_mapping_aux rest_m n)) += M.non_zero_size_choose m; + let Some (k, v) = M.choose m in + let rest_m = M.delete m k in + sum_mapping_acc rest_m v n + +let rec sum_mapping_aux_upd (#key:eqtype) (#c:M.cmp key) (m:M.t key uint c) (k:key) (v:uint) (n:Prims.int) +: Lemma + (requires ~ (M.contains m k)) + (ensures sum_mapping_aux (M.upd m k v) n == v + sum_mapping_aux m n) + (decreases (M.size m)) += let m1 = M.upd m k v in + M.size_upd m k v; + M.non_zero_size_choose m1; + let Some (k', v') = M.choose m1 in + let rest_m1 = M.delete m1 k' in + + if k' = k then begin + sum_mapping_rest m1 n; + M.delete_upd_cancel_out m k v + end + else begin + M.choose_not_already_exist m k v; + M.non_zero_size_choose m; + let Some (k'', v'') = M.choose m in + let rest_m = M.delete m k'' in + M.choose_after_update m k v; + M.choose_commute_up_del m k v; + M.contains_choose m; + sum_mapping_aux_upd rest_m k v n; + sum_mapping_rest m1 n; + sum_mapping_rest m n + end + +let sum_mapping (#k:eqtype) (#f:M.cmp k) (m:M.t k uint f) = sum_mapping_aux #k #f m 0 + +let sum_mapping_emp (#key:eqtype) (#f:M.cmp key) (m:(M.t key uint f){M.def_of m == 0}) +: Lemma + (requires M.size m == 0) + (ensures sum_mapping m == 0) + [SMTPat (M.domain m); SMTPat (sum_mapping m)] += () + +let sum_mapping_const (#key:eqtype) (#f:M.cmp key) +: Lemma + (ensures (sum_mapping (M.const #key #uint #f 0)) == 0) + [SMTPat (M.const #key #uint #f)] += () + +let rec sum_mapping_gt_val (#key:eqtype) (#f:M.cmp key) + (m:(M.t key uint f){M.def_of m == 0}) (k:key) +: Lemma + (requires (forall (i:key{M.contains m i}). M.sel m i >= 0)) + (ensures sum_mapping m >= M.sel m k) + (decreases (M.size m)) + [SMTPat (sum_mapping m); SMTPat (m `M.contains` k)] += if M.size m = 0 then M.empty_contains m k + else begin + M.non_zero_size_choose m; + let Some (k', v) = M.choose m in + let rest_m = M.delete m k' in + M.contains_choose m; + sum_mapping_rest m 0; + sum_mapping_gt_val rest_m k + end + +let rec sum_mapping_upd (#key:eqtype) (#f:M.cmp key) + (m:(M.t key uint f){M.def_of m == 0}) (k:key) (v:uint) +: Lemma + (requires True) + (ensures + (let m1 = M.upd m k v in + let prev_n = M.sel m k in + eq2 #Prims.int (sum_mapping m1) (sum_mapping m - prev_n + v))) + (decreases (M.size m)) + [SMTPat (sum_mapping (M.upd m k v))] += let m1 = M.upd m k v in + M.size_upd m k v; + + if M.contains m k then begin + M.contains_size m k; + M.non_zero_size_choose m; + M.non_zero_size_choose m1; + + let Some (k', v') = M.choose m in + let Some (k'', v'') = M.choose m1 in + + let rest_m = M.delete m k' in + let rest_m1 = M.delete m1 k'' in + + M.contains_choose m; + + + M.choose_after_update m k v; + + if k' = k then begin + sum_mapping_rest m 0; + sum_mapping_rest m1 0 + end + else begin + + M.choose_commute_up_del m k v; + sum_mapping_rest m 0; + sum_mapping_rest m1 0; + sum_mapping_upd rest_m k v + end + end + else sum_mapping_aux_upd m k v 0 + +let lt = fun x y -> x <= y + + +(*** It is the string comparison function, e.g. the strcmp in OCaml: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Stdlib.html#VALcompare +which behaves like a total order ***) +assume val strcmp : f:(string -> string -> bool){M.total_order string f} + +(* ABI Enconding and Decoding functions *) +assume val abi_encode : (#a:Type0) -> a -> bytes +assume val abi_encodePacked : (#a:Type0) -> a -> bytes +assume val abi_encodeWithSelector : (#a:Type0) -> bytes4 -> a -> bytes +assume val abi_encodeWithSignature : (#a:Type0) -> a -> bytes + +(* Precompiles and other pure functions *) +assume val keccak256 : bytes -> bytes32 +assume val sha256 : bytes -> bytes32 // precompile +assume val ripemd160 : bytes -> bytes20 // precompile +assume val ecrecover : bytes32 -> uint8 -> bytes32 -> bytes32 -> address // precompile \ No newline at end of file diff --git a/Celestial/Compiler/lib/FStar.OrdSet.fst b/Celestial/Compiler/lib/FStar.OrdSet.fst new file mode 100644 index 00000000..2c9701ec --- /dev/null +++ b/Celestial/Compiler/lib/FStar.OrdSet.fst @@ -0,0 +1,322 @@ +(* + Copyright 2008-2018 Microsoft Research + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*) +module FStar.OrdSet + +type ordset a f = l:(list a){sorted f l} + +let hasEq_ordset _ _ = () + +let as_list #_ #_ s = s + +let empty #_ #_ = [] + +let mem #_ #_ x s = List.Tot.mem x s + +private val insert': #a:eqtype -> #f:cmp a -> x:a -> s:ordset a f + -> Tot (l:(ordset a f){let s = as_list s in let l = as_list l in + (Cons? l /\ + (Cons?.hd l = x \/ + (Cons? s /\ Cons?.hd l = Cons?.hd s)))}) +let rec insert' #_ #f x s = + match s with + | [] -> [x] + | hd::tl -> + if x = hd then hd::tl + else if f x hd then x::hd::tl + else hd::(insert' #_ #f x tl) + +let rec union #_ #_ s1 s2 = match s1 with + | [] -> s2 + | hd::tl -> union tl (insert' hd s2) + +let rec intersect #a #f s1 s2 = match s1 with + | [] -> [] + | hd::tl -> + if mem #_ #f hd s2 then + insert' #_ #f hd (intersect #_ #f tl s2) + else + intersect #_ #f tl s2 + +let choose #a #f s = match s with + | [] -> None + | x::_ -> Some x + +private val remove': #a:eqtype -> #f:cmp a -> x:a -> s:ordset a f + -> Tot (l:(ordset a f){let s = as_list s in let l = as_list l in + ((Nil? s ==> Nil? l) /\ + (Cons? s ==> Cons?.hd s = x ==> l = Cons?.tl s) /\ + (Cons? s ==> Cons?.hd s =!= x ==> (Cons? l /\ Cons?.hd l = Cons?.hd s)))}) +let rec remove' #a #f x s = match s with + | [] -> [] + | hd::tl -> + if x = hd then tl + else hd::(remove' #_ #f x tl) + +let remove #a #f x s = remove' #_ #f x s + +let size #a #f s = List.Tot.length s + +let rec subset #a #f s1 s2 = match s1, s2 with + | [], _ -> true + | hd::tl, hd'::tl' -> + if f hd hd' && hd = hd' then subset #a #f tl tl' + else if f hd hd' && not (hd = hd') then false + else subset #a #f s1 tl' + | _, _ -> false + +let singleton (#a:eqtype) #f x = [x] + +private +let rec remove_le #a #f x (s:ordset a f) + : Pure (ordset a f) + (requires True) + (ensures (fun r -> let r = as_list r in sorted f (x :: r))) + (decreases s) += + match s with + | [] -> [] + | y :: ys -> + if f x y && x <> y + then s + else remove_le #a #f x ys + +private +let rec minus' (#a:eqtype) (#f:cmp a) (x:a) (s1 s2:ordset a f) + : Pure (ordset a f) + (requires (let s1 = as_list s1 in let s2 = as_list s2 in sorted f (x::s1) /\ sorted f (x::s2))) + (ensures (fun r -> let r = as_list r in sorted f (x::r))) + (decreases s1) += + match s1 with + | [] -> [] + | x1 :: xs1 -> + assert (sorted f xs1) ; + match s2 with + | [] -> s1 + | x2 :: xs2 -> + assert (sorted f xs1) ; + if x1 = x2 + then minus' #a #f x xs1 xs2 + else x1 :: (minus' #a #f x1 xs1 (remove_le x1 s2)) + +let minus #a #f s1 s2 = + match s1 with + | [] -> [] + | x1 :: xs1 -> minus' #a #f x1 xs1 (remove_le #a #f x1 s2) + +let strict_subset #a #f s1 s2 = s1 <> s2 && subset #a #f s1 s2 + +private val set_props: + #a:eqtype -> #f:cmp a -> s:ordset a f{Cons? (as_list s)} + -> Lemma (requires True) + (ensures (let s = as_list s in + (forall x. List.Tot.mem x (Cons?.tl s) ==> (f (Cons?.hd s) x /\ Cons?.hd s =!= x)))) +let rec set_props (#a:eqtype) #f s = match s with + | x::tl -> if tl = [] then () else set_props #a #f tl + +private val hd_unique: #a:eqtype -> #f:cmp a -> s:ordset a f + -> Lemma (requires (Cons? (as_list s))) + (ensures (let s = as_list s in + not (List.Tot.mem (Cons?.hd s) (Cons?.tl s)))) +let hd_unique #a #f s = set_props #a #f s + +private val eq_helper: #a:eqtype -> #f:cmp a -> x:a -> s:ordset a f + -> Lemma (requires (let s = as_list s in Cons? s /\ f x (Cons?.hd s) /\ x =!= Cons?.hd s)) + (ensures (not (mem #a #f x s))) +let eq_helper (#a:eqtype) #f x s = set_props #a #f s + +let rec eq_lemma (#a:eqtype) #f s1 s2 = match s1, s2 with + | [], [] -> () + | _::_, [] -> () + | [], _::_ -> () + | hd1::tl1, hd2::tl2 -> + if hd1 = hd2 then + //hd_unique calls help us prove that forall x. mem f x tl1 = mem f x tl2 + //so that we can apply IH + (hd_unique #_ #f s1; hd_unique #_ #f s2; eq_lemma #_ #f tl1 tl2) + else if f hd1 hd2 then + eq_helper #_ #f hd1 s2 + else + eq_helper #_ #f hd2 s1 + +let mem_empty #_ #_ _ = () + +let mem_singleton #_ #_ _ _ = () + +private val insert_mem: #a:eqtype -> #f:cmp a -> x:a -> y:a -> s:ordset a f + -> Lemma (requires (True)) + (ensures (mem #a #f y (insert' #a #f x s) = + (x = y || mem #a #f y s))) +let rec insert_mem (#a:eqtype) #f x y s = match s with + | [] -> () + | hd::tl -> + if x = hd then () + else if f x hd then () + else insert_mem #_ #f x y tl + +let rec mem_union #_ #f x s1 s2 = match s1 with + | [] -> () + | hd::tl -> + mem_union #_ #f x tl (insert' #_ #f hd s2); insert_mem #_ #f hd x s2 + +let rec mem_intersect #_ #f x s1 s2 = match s1 with + | [] -> () + | hd::tl -> + let _ = mem_intersect #_ #f x tl s2 in + if mem #_ #f hd s2 then insert_mem #_ #f hd x (intersect #_ #f tl s2) else () + +private val subset_implies_mem: + #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires (True)) + (ensures (subset #a #f s1 s2 ==> (forall x. mem #a #f x s1 ==> + mem #a #f x s2))) +let rec subset_implies_mem (#a:eqtype) #f s1 s2 = match s1, s2 with + | [], _ -> () + | hd::tl, hd'::tl' -> + if f hd hd' && hd = hd' then subset_implies_mem #a #f tl tl' + else subset_implies_mem #a #f s1 tl' + | _, _ -> () + +private val mem_implies_subset: + #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires (True)) + (ensures ((forall x. mem #a #f x s1 ==> mem #a #f x s2) ==> subset #a #f s1 s2)) +let rec mem_implies_subset (#a:eqtype) #f s1 s2 = match s1, s2 with + | [], [] -> () + | _::_, [] -> () + | [], _::_ -> () + | hd::tl, hd'::tl' -> + set_props #a #f s1; set_props #a #f s2; + + if f hd hd' && hd = hd' then + mem_implies_subset #a #f tl tl' + else if f hd hd' && not (hd = hd') then + () + else mem_implies_subset #a #f s1 tl' + +let mem_subset (#a:eqtype) #f s1 s2 = + subset_implies_mem #a #f s1 s2; mem_implies_subset #a #f s1 s2 + +let choose_empty (#a:eqtype) #f = () + +let choose_s (#a:eqtype) #f s = + let Some e = choose #_ #f s in + cut (equal #a #f s (insert' #a #f e (remove #a #f e s))) + + + +let rec mem_remove (#a:eqtype) #f x y s = match s with + | [] -> () + | hd::tl -> if y = hd then hd_unique #_ #f s else mem_remove #_ #f x y tl + +let rec eq_remove (#a:eqtype) #f x s = match s with + | [] -> () + | _::tl -> eq_remove #_ #f x tl + +let size_empty (#a:eqtype) #f s = () + +let rec size_remove (#a:eqtype) #f x s = match s with + | hd::tl -> + if x = hd then () else size_remove #_ #f x tl + +let size_singleton (#a:eqtype) #f x = () + +let rec subset_size (#a:eqtype) #f x y = match x, y with + | [], _ -> () + | hd::tl, hd'::tl' -> + if f hd hd' && hd = hd' then subset_size #a #f tl tl' + else subset_size #a #f x tl' + +(**********) + +(* TODO:FIXME: implement *) +let size_union #a #f s1 s2 = admit () + +let size_union2 #a #f s k = admit () + +let size_union3 #a #f s k = admit () + +(**********) + +let non_zero_size_choose (#a:eqtype) #f s = () +let choose_upd_det (#a:eqtype) #f s x = admit () +let choose_upd_det2 (#a:eqtype) #f s x = admit () +let del_union_choose (#a:eqtype) #f s x = admit () + +let fold #a #acc #f g init s = List.Tot.fold_left g init s + +private +let rec map_internal (#a #b:eqtype) (#fa:cmp a) (#fb:cmp b) (g:a -> b) (sa:ordset a fa) + : Pure (ordset b fb) + (requires (forall x y. x `fa` y ==> g x `fb` g y)) + (ensures (fun sb -> let sa = as_list sa in let sb = as_list sb in Cons? sb ==> Cons? sa /\ Cons?.hd sb == g (Cons?.hd sa))) += match sa with + | [] -> [] + | x :: xs -> + let y = g x in + let ys = map_internal #a #b #fa #fb g xs in + if not (Cons? ys) || Cons?.hd ys <> y then + y :: ys + else ys + +let map #a #b #fa #fb g sa = map_internal #a #b #fa #fb g sa + +let lemma_strict_subset_size #a #f s1 s2 = admit () + +let lemma_minus_mem #a #f s1 s2 x = admit () + +let lemma_strict_subset_minus_size #a #f s1 s2 s = admit () + +let lemma_disjoint_union_subset #a #f s1 s2 = admit () + +let lemma_subset_union #a #f s1 s2 s = admit () + +let lemma_strict_subset_transitive #a #f s1 s2 s3 = admit () + +let lemma_intersect_symmetric #a #f s1 s2 = admit () + +let lemma_intersect_union_empty #a #f s1 s2 s3 = admit () + +let lemma_intersect_union_empty' #a #f s1 s2 s3 = admit () + +let union_comm #a #f s1 s2 = admit () + +let union_of_disj #a #f s1 s2 = admit () + +(* Conversion from OrdSet to Set *) + +module S = FStar.Set + +let rec as_set #a #f s = + match s with + | [] -> S.empty + | hd::tl -> S.union (S.singleton hd) (as_set #a #f tl) + +let rec lemma_as_set_mem #a #f s x + = match s with + | [] -> () + | hd::tl -> + if x = hd + then () + else lemma_as_set_mem #a #f tl x + +let rec lemma_as_set_disjoint #a #f s1 s2 + = match s1 with + | [] -> () + | hd::tl -> + if mem hd s2 + then assert (S.mem hd (as_set s2)) + else lemma_as_set_disjoint tl s2 diff --git a/Celestial/Compiler/lib/FStar.OrdSet.fsti b/Celestial/Compiler/lib/FStar.OrdSet.fsti new file mode 100644 index 00000000..72f8218c --- /dev/null +++ b/Celestial/Compiler/lib/FStar.OrdSet.fsti @@ -0,0 +1,272 @@ +(* + Copyright 2008-2018 Microsoft Research + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*) +module FStar.OrdSet + +type total_order (a:eqtype) (f: (a -> a -> Tot bool)) = + (forall a1 a2. (f a1 a2 /\ f a2 a1) ==> a1 = a2) (* anti-symmetry *) + /\ (forall a1 a2 a3. f a1 a2 /\ f a2 a3 ==> f a1 a3) (* transitivity *) + /\ (forall a1 a2. f a1 a2 \/ f a2 a1) (* totality *) + +type cmp (a:eqtype) = f:(a -> a -> Tot bool){total_order a f} + +let rec sorted (#a:eqtype) (f:cmp a) (l:list a) : Tot bool = + match l with + | [] -> true + | x::[] -> true + | x::y::tl -> f x y && x <> y && sorted f (y::tl) + +val ordset (a:eqtype) (f:cmp a) : Type0 + +val hasEq_ordset: a:eqtype -> f:cmp a + -> Lemma (requires (True)) (ensures (hasEq (ordset a f))) + [SMTPat (hasEq (ordset a f))] + +private val as_list (#a:eqtype) (#f:cmp a) (s:ordset a f) : Tot (l:list a{sorted f l}) + +val empty : #a:eqtype -> #f:cmp a -> Tot (ordset a f) +val mem : #a:eqtype -> #f:cmp a -> a -> s:ordset a f -> Tot bool + +val union : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) +val intersect : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) + +val choose : #a:eqtype -> #f:cmp a -> s:ordset a f -> Tot (option a) +val remove : #a:eqtype -> #f:cmp a -> a -> ordset a f -> Tot (ordset a f) + +val size : #a:eqtype -> #f:cmp a -> ordset a f -> Tot nat + +val subset : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool +val singleton : #a:eqtype -> #f:cmp a -> a -> Tot (ordset a f) + +val minus : #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot (ordset a f) +val strict_subset: #a:eqtype -> #f:cmp a -> ordset a f -> ordset a f -> Tot bool + +let disjoint #a #f (s1 s2 : ordset a f) : Tot bool = intersect s1 s2 = empty + +let equal (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) : Tot prop = + forall x. mem #_ #f x s1 = mem #_ #f x s2 + +val eq_lemma: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires (equal s1 s2)) + (ensures (s1 = s2)) + [SMTPat (equal s1 s2)] + +val mem_empty: #a:eqtype -> #f:cmp a -> x:a + -> Lemma (requires True) (ensures (not (mem #a #f x (empty #a #f)))) + [SMTPat (mem #a #f x (empty #a #f))] + +val mem_singleton: #a:eqtype -> #f:cmp a -> x:a -> y:a + -> Lemma (requires True) + (ensures (mem #a #f y (singleton #a #f x)) = (x = y)) + [SMTPat (mem #a #f y (singleton #a #f x))] + +val mem_union: #a:eqtype -> #f:cmp a -> x:a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires True) + (ensures (mem #a #f x (union #a #f s1 s2) = + (mem #a #f x s1 || mem #a #f x s2))) + [SMTPat (mem #a #f x (union #a #f s1 s2))] + +val mem_intersect: #a:eqtype -> #f:cmp a -> x:a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires True) + (ensures (mem #a #f x (intersect s1 s2) = + (mem #a #f x s1 && mem #a #f x s2))) + [SMTPat (mem #a #f x (intersect #a #f s1 s2))] + +val mem_subset: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires True) + (ensures (subset #a #f s1 s2 <==> + (forall x. mem #a #f x s1 ==> mem #a #f x s2))) + [SMTPat (subset #a #f s1 s2)] + +val choose_empty: #a:eqtype -> #f:cmp a + -> Lemma (requires True) (ensures (None? (choose #a #f (empty #a #f)))) + [SMTPat (choose #a #f (empty #a #f))] + +(* TODO: FIXME: Pattern does not contain all quantified vars *) +val choose_s: #a:eqtype -> #f:cmp a -> s:ordset a f + -> Lemma (requires (not (s = (empty #a #f)))) + (ensures (Some? (choose #a #f s) /\ + s = union #a #f (singleton #a #f (Some?.v (choose #a #f s))) + (remove #a #f (Some?.v (choose #a #f s)) s))) + [SMTPat (choose #a #f s)] + + + + +val mem_remove: #a:eqtype -> #f:cmp a -> x:a -> y:a -> s:ordset a f + -> Lemma (requires True) + (ensures (mem #a #f x (remove #a #f y s) = + (mem #a #f x s && not (x = y)))) + [SMTPat (mem #a #f x (remove #a #f y s))] + +val eq_remove: #a:eqtype -> #f:cmp a -> x:a -> s:ordset a f + -> Lemma (requires (not (mem #a #f x s))) + (ensures (s = remove #a #f x s)) + [SMTPat (remove #a #f x s)] + +val size_empty: #a:eqtype -> #f:cmp a -> s:ordset a f + -> Lemma (requires True) (ensures ((size #a #f s = 0) = (s = empty #a #f))) + [SMTPat (size #a #f s)] + +val size_remove: #a:eqtype -> #f:cmp a -> y:a -> s:ordset a f + -> Lemma (requires (mem #a #f y s)) + (ensures (size #a #f s = size #a #f (remove #a #f y s) + 1)) + [SMTPat (size #a #f (remove #a #f y s))] + +val size_singleton: #a:eqtype -> #f:cmp a -> x:a + -> Lemma (requires True) (ensures (size #a #f (singleton #a #f x) = 1)) + [SMTPat (size #a #f (singleton #a #f x))] + +val subset_size: #a:eqtype -> #f:cmp a -> x:ordset a f -> y:ordset a f + -> Lemma (requires (subset #a #f x y)) + (ensures (size #a #f x <= size #a #f y)) + [SMTPat (subset #a #f x y)] + +(**********) + +val size_union: #a:eqtype -> #f:cmp a -> s1:ordset a f -> s2:ordset a f + -> Lemma (requires True) + (ensures ((size #a #f (union #a #f s1 s2) >= size #a #f s1) && + (size #a #f (union #a #f s1 s2) >= size #a #f s2))) + [SMTPat (size #a #f (union #a #f s1 s2))] + +val size_union2: #a:eqtype -> #f:cmp a -> s:ordset a f -> k:a + -> Lemma (requires True) + (ensures not (mem k s) ==> size (union s (singleton k)) == size s + 1) + [SMTPat (size #a #f (union #a #f s k))] + +val size_union3: #a:eqtype -> #f:cmp a -> s:ordset a f -> k:a + -> Lemma (requires True) + (ensures (mem k s) ==> size (union s (singleton k)) == size s + /\ equal s (union s (singleton k)) + ) + [SMTPat (size #a #f (union #a #f s k))] + + +(**********) + +val non_zero_size_choose: #a:eqtype -> #f:cmp a -> s:ordset a f -> + Lemma + (requires size s > 0) + (ensures Some? (choose s)) + +val choose_upd_det: #a:eqtype -> #f:cmp a -> s:ordset a f -> x:a + -> Lemma (requires (not (s = (empty #a #f)))) + (ensures ( Some? (choose #a #f s) /\ + ( size_union s (singleton x); non_zero_size_choose s; + (x <> (Some?.v (choose #a #f (union #a #f s (singleton x)))) ) ==> ( + //(not (f x (Some?.v (choose #a #f (union #a #f s (singleton x)))))) /\ + ( (Some?.v (choose #a #f (union #a #f s (singleton x)))) = (Some?.v (choose #a #f s)) ) + ) + ))) + //[SMTPat (choose #a #f s); SMTPat (choose #a #f (union #a #f s (singleton x)))] + +val choose_upd_det2: #a:eqtype -> #f:cmp a -> s:ordset a f -> x:a + -> Lemma (requires (not (s = (empty #a #f)))) + (ensures ( Some? (choose #a #f s) /\ + ( size_union s (singleton x); non_zero_size_choose s; + ( (mem x s) /\ x <> (Some?.v (choose #a #f s)) ) ==> ( + //(not (f x (Some?.v (choose #a #f (union #a #f s (singleton x)))))) /\ + ( (Some?.v (choose #a #f (union #a #f s (singleton x)))) = (Some?.v (choose #a #f s)) ) + ) + ))) + //[SMTPat (choose #a #f s); SMTPat (choose #a #f (union #a #f s (singleton x)))] + +val del_union_choose: #a:eqtype -> #f:cmp a -> s:ordset a f -> x:a + -> Lemma (requires (not (s = (empty #a #f)))) + (ensures ( Some? (choose #a #f s) /\ + ( size_union s (singleton x); non_zero_size_choose s; choose_upd_det s x; + let k'' = (Some?.v (choose #a #f s)) in let k' = (Some?.v (choose #a #f (union #a #f s (singleton x)))) in + (x <> k' /\ k' = k'') ==> ( + equal (remove k'' s) (remove k' (union #a #f s (singleton x)) ) + ) + ) + )) //It might go thru if you write expressions completely instead of letting them. + [SMTPat (choose #a #f s); SMTPat (choose #a #f (union #a #f s (singleton x)))] //FIXME: Pattern may be insufficient. + +val fold (#a:eqtype) (#acc:Type) (#f:cmp a) (g:acc -> a -> acc) (init:acc) (s:ordset a f) + : Tot acc + +val map (#a #b:eqtype) (#fa:cmp a) (#fb:cmp b) (g:a -> b) (sa:ordset a fa) + : Pure (ordset b fb) + (requires (forall x y. x `fa` y ==> g x `fb` g y)) + (ensures (fun sb -> True)) + +val lemma_strict_subset_size (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) + :Lemma (requires (strict_subset s1 s2)) + (ensures (subset s1 s2 /\ size s1 < size s2)) + [SMTPat (strict_subset s1 s2)] + +val lemma_minus_mem (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (x:a) + :Lemma (requires True) (ensures (mem x (minus s1 s2) = (mem x s1 && not (mem x s2)))) + [SMTPat (mem x (minus s1 s2))] + +val lemma_strict_subset_minus_size (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (s:ordset a f) + :Lemma (requires (strict_subset s1 s2 /\ subset s1 s /\ subset s2 s)) + (ensures (size (minus s s2) < size (minus s s1))) + [SMTPat (strict_subset s1 s2); SMTPat (subset s1 s); SMTPat (subset s2 s)] + +val lemma_disjoint_union_subset (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) + :Lemma (requires (~ (s1 == empty) /\ ~ (s2 == empty) /\ intersect s1 s2 == empty)) + (ensures (strict_subset s1 (union s1 s2) /\ strict_subset s2 (union s1 s2))) + [SMTPatOr [[SMTPat (strict_subset s1 (union s1 s2))]; [SMTPat (strict_subset s2 (union s1 s2))]]] + +val lemma_subset_union (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (s:ordset a f) + :Lemma (requires (subset s1 s /\ subset s2 s)) + (ensures (subset (union s1 s2) s)) + [SMTPat (subset (union s1 s2) s)] + +val lemma_strict_subset_transitive (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (s3:ordset a f) + :Lemma (requires (strict_subset s1 s2 /\ strict_subset s2 s3)) + (ensures (strict_subset s1 s3)) + [SMTPat (strict_subset s1 s2); SMTPat (strict_subset s2 s3)] + +val lemma_intersect_symmetric (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) + :Lemma (requires True) (ensures (intersect s1 s2 == intersect s2 s1)) + [SMTPatOr [[SMTPat (intersect s1 s2)]; [SMTPat (intersect s2 s1)]]] + +val lemma_intersect_union_empty (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (s3:ordset a f) + :Lemma (requires (intersect s1 s3 == empty /\ intersect s2 s3 == empty)) + (ensures (intersect (union s1 s2) s3 == empty)) + [SMTPat (intersect (union s1 s2) s3)] + +val lemma_intersect_union_empty' (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) (s3:ordset a f) + :Lemma (requires (intersect (union s1 s2) s3 == empty)) + (ensures (intersect s1 s3 == empty /\ intersect s2 s3 == empty)) + [SMTPat (intersect (union s1 s2) s3)] + +val union_comm (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) + :Lemma (union s1 s2 == union s2 s1) + [SMTPat (union s1 s2)] + +val union_of_disj (#a:eqtype) (#f:cmp a) (s1:ordset a f) (s2:ordset a f) + :Lemma (requires (disjoint s1 s2)) + (ensures (minus (union s1 s2) s1 == s2)) + [SMTPat (union s1 s2); SMTPat (disjoint s1 s2)] + +(* Conversion from OrdSet to Set *) + +module S = FStar.Set + +val as_set : #a:eqtype -> #f:cmp a -> ordset a f -> Tot (S.set a) + +val lemma_as_set_mem (#a:eqtype) (#f:cmp a) (s:ordset a f) (x:a) + : Lemma (mem x s <==> S.mem x (as_set s)) + [SMTPat (mem x s); + SMTPat (S.mem x (as_set s))] + +val lemma_as_set_disjoint (#a:eqtype) (#f:cmp a) (s1 s2:ordset a f) + : Lemma (intersect s1 s2 = empty <==> S.disjoint (as_set s1) (as_set s2)) + [SMTPat (S.disjoint (as_set s1) (as_set s2))] diff --git a/Celestial/Compiler/lib/ForLoopTest.fst b/Celestial/Compiler/lib/ForLoopTest.fst new file mode 100644 index 00000000..f0475477 --- /dev/null +++ b/Celestial/Compiler/lib/ForLoopTest.fst @@ -0,0 +1,97 @@ +module ForLoopTest + + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +noeq type t_contract = { + contract_sumCredits : int; +} + +type contract_address = contract t_contract +let contract_live (c:contract_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +let contract_get_sumCredits (c:contract_address) +: StEth int + (fun st -> c `contract_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).contract_sumCredits) += let contract_inst = get_contract c in + contract_inst.contract_sumCredits + +let contract_set_sumCredits (c:contract_address) (_sumCredits:int) +: StEth unit + (fun st -> c `contract_live` st.current + /\ _sumCredits >= 0 /\ _sumCredits <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + contract_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with contract_sumCredits = _sumCredits })) += let contract_inst = get_contract c in + let contract_inst = { contract_inst with contract_sumCredits = _sumCredits } in + set_contract c contract_inst + +(*For combinator*) +/// I initially thought of writing the `for` combinator in a separate F* module, but one of +/// its arguments `self` has to be of type `contract t_contract` which is contract specific +/// so decided to generate it once for each contract (I guess we can have an implicit Type +/// argument as well, but wanted to try out the easiest possible thing for now) +val for: + start :uint -> + finish :uint{finish >= start} -> + freverts :(bstate -> uint -> Type0) -> // Reverts condition for the function `f` + fpost :(bstate -> bstate -> uint -> Type0) -> // Post condition for the function `f` (assuming a trivial pre-condition for now. can have a `fpre` argument too) + linv :(bstate -> uint -> Type0) -> // Loop invariant + lreverts :(bstate -> uint -> Type0) -> // Reverts condition for the combinator itself + self :contract_address -> + sender :address -> + value :uint -> + f :(self:contract_address -> sender:address -> value:uint -> i:uint{i >= start /\ i < finish} -> + Eth unit (fun bst -> contract_live self bst /\ (linv bst i)) + (fun bst -> freverts bst i) + (fun bst0 x bst1 -> (contract_live self bst1) /\ (fpost bst0 bst1 i) /\ (linv bst1 i))) -> + // f is the body of the loop. Not handling local variables for now + Eth unit + (fun bst -> (contract_live self bst) /\ (linv bst start)) // /\ fpre bst + + (fun bst -> lreverts bst start) // freverts bst0 start || freverts bst1 start+1 || ... freverts bstn finish + (fun bst0 x bst1 -> (contract_live self bst1) /\ (linv bst1 finish)) + +let rec for start finish freverts fpost linv lreverts self sender value f = + if start = finish then () + else begin + f self sender value start; + for (start + 1) finish freverts fpost linv lreverts self sender value f + end +(*End For combinator*) + +/// the reverts and post condition for `foo` +let foo_reverts (bst:bstate) (i:uint) : Type0 = False +let foo_post (bst0:bstate) (bst1:bstate) (i:uint) : Type0 = True + +/// foo is the body of the for-loop +/// the body of the loop just updates the value of the field variable `sumCredits` to the loop iterator 'i' +let foo (self:contract_address) (sender:address) (value:uint) (i:uint) : Eth unit +(fun bst -> contract_live self bst) +(fun bst -> foo_reverts bst i) +(fun bst0 _ bst1 -> (contract_live self bst1) /\ (foo_post bst0 bst1 i)) += contract_set_sumCredits self i + +/// bar is a method that has a for-loop +let bar (self:contract_address) (sender:address) (value:uint) : Eth unit +(fun bst -> contract_live self bst) +(fun bst -> foo_reverts bst 0) +(fun _ _ _ -> True) += for 0 10 foo_reverts foo_post (fun _ _ -> True) (fun bst i -> foo_reverts bst i) self sender 0 foo + +/// The issue is that, writing a `for` combinator in the style of KreMLin C loops requires passing +/// in the `reverts` condition (`lreverts`) for the combinator itself as an argument to the combinator. +/// And hence F* is not able to verify it under the Eth effect since it doesn't know what `lreverts` is \ No newline at end of file diff --git a/Celestial/Compiler/lib/Makefile b/Celestial/Compiler/lib/Makefile new file mode 100644 index 00000000..1a9e2ace --- /dev/null +++ b/Celestial/Compiler/lib/Makefile @@ -0,0 +1,88 @@ +SHELL := /bin/bash +.PHONY: verify-all basic_clean test test.kremlin test.ocaml +################################################################################ +# Customize these variables for your project +################################################################################ +# The root files of your project, from which to begin scanning dependences +FSTAR_FILES ?= FStar.Celestial.Map.fst FStar.Celestial.Map.fsti FStar.Celestial.fst +FSTAR = fstar +# The paths to related files which to include for scanning +# -- No need to add FSTAR_HOME/ulib; it is included by default +INCLUDE_PATHS ?= + +# The executable file you want to produce +PROGRAM ?= + +# A driver in ML to call into your program +TOP_LEVEL_FILE ?= + +# A place to put all the emitted .ml files +OUTPUT_DIRECTORY ?= _output + +################################################################################ +MY_FSTAR=$(FSTAR) --cache_checked_modules --odir $(OUTPUT_DIRECTORY) +ML_FILES=$(addprefix $(OUTPUT_DIRECTORY)/,$(addsuffix .ml,$(subst .,_, $(subst .fst,,$(FSTAR_FILES))))) +OCAML_EXE=$(PROGRAM).ocaml.exe +KREMLIN_EXE=$(PROGRAM).exe + +# a.fst.checked is the binary, checked version of a.fst +%.fst.checked: %.fst + $(MY_FSTAR) $*.fst + touch -c $@ + +# a.fsti.checked is the binary, checked version of a.fsti +%.fsti.checked: %.fsti + $(MY_FSTAR) $*.fsti + touch -c $@ + +# The _tags file is a directive to ocamlbuild +# The extracted ML files are precious, because you may want to examine them, +# e.g., to see how type signatures were transformed from F* +.PRECIOUS: _tags $(ML_FILES) $(addsuffix .checked,$(FSTAR_FILES)) $(OUTPUT_DIRECTORY)/out.krml + +_tags: + echo ": traverse" > $@ + echo "<$(OUTPUT_DIRECTORY)>: traverse\n" >> $@ + echo "<$(OUTPUT_DIRECTORY)/c>: -traverse\n" >> $@ + +# To extract an A.ml ML file from an A.fst, we just reload its A.fst.checked file +# and then with the --codegen OCaml option, emit an A.ml +# Note, by default F* will extract all files in the dependency graph +# With the --extract_module, we instruct it to just extract A.ml +$(OUTPUT_DIRECTORY)/%.ml: + $(MY_FSTAR) $(subst .checked,,$<) --codegen OCaml --extract_module $(subst .fst.checked,,$<) + +$(OCAML_EXE): _tags $(ML_FILES) $(TOP_LEVEL_FILE) $(FSTAR_HOME)/bin/fstarlib/fstarlib.cmxa + OCAMLPATH="$(FSTAR_HOME)/bin" ocamlbuild -I $(OUTPUT_DIRECTORY) -use-ocamlfind -pkg fstarlib $(subst .ml,.native,$(TOP_LEVEL_FILE)) + mv _build/$(subst .ml,.native,$(TOP_LEVEL_FILE)) $@ + +test.ocaml: $(OCAML_EXE) + ./$< hello + +$(OUTPUT_DIRECTORY)/c/out.krml: $(addsuffix .checked,$(FSTAR_FILES)) + krml -fsopts --cache_checked_modules -tmpdir $(OUTPUT_DIRECTORY)/c -skip-translation $(FSTAR_FILES) + +$(KREMLIN_EXE): $(OUTPUT_DIRECTORY)/c/out.krml + krml $< -tmpdir $(OUTPUT_DIRECTORY)/c -no-prefix A -o $@ + +test.kremlin: $(KREMLIN_EXE) + ./$< hello + +test: test.kremlin test.ocaml + +$(FSTAR_HOME)/bin/fstarlib/fstarlib.cmxa: + +$(MAKE) -C $(FSTAR_HOME)/ulib/ml + +basic_clean: + rm -rf _build $(OUTPUT_DIRECTORY) *~ *.checked $(OCAML_EXE) $(KREMLIN_EXE) .depend + +.depend: $(FSTAR_FILES) + $(MY_FSTAR) --dep full $(addprefix --include , $(INCLUDE_PATHS)) $(FSTAR_FILES) > .depend + +depend: .depend + +include .depend + +# The default target is to verify all files, without extracting anything +# It needs to be here, because it reads the variable ALL_FST_FILES in .depend +verify-all: $(addsuffix .checked, $(ALL_FST_FILES)) \ No newline at end of file diff --git a/Celestial/Compiler/lib/VeriSolContracts.sol b/Celestial/Compiler/lib/VeriSolContracts.sol new file mode 100644 index 00000000..181d0715 --- /dev/null +++ b/Celestial/Compiler/lib/VeriSolContracts.sol @@ -0,0 +1,104 @@ +pragma solidity >=0.4.24<0.6.0; + +/** + * Library for VeriSol Code Contracts + * + * Mechanism to add various specification constructs + * loop invariants + * contract invariants + * precondition + * postcondition + * + * Also support enriching the assertion language + * + */ +library VeriSol { + + /* + ******************************************************************** + * Specification mechanisms + ******************************************************************** + */ + + /** + * Loop invariant + * + * Calling this function within a loop VeriSol.Invariant(I) installs + * I as a loop invariant. I should only refer to variables in scope + * at the loop entry, and evaluated at the loop head. + * + * Using "Invariant" to avoid clash with a potential "invariant" keyword in Solidity + * to directly support loop invariants https://github.com/ethereum/solidity/issues/6210 + */ + function Invariant(bool b) external pure; + + /** + * Contract invariant + * + * + * Calling this function within exactly one view function + * VeriSol.ContractInvariant(I) installs I as a loop invariant + * for the harness that calls public methods in the contract in a + * loop. See https://arxiv.org/abs/1812.08829 (Sec IV A) + * + * It is currently not inherited by derived contracts + * + * I should only refer to variables in global scope i.e. state variables. + * + */ + function ContractInvariant(bool b) external pure; + + /** + * Postconditions + * + * Calling this function within a function f VeriSol.Ensures(E) installs + * E as a post condition of f. + */ + function Ensures(bool b) external pure; + + /** + * Preconditions + * + * Calling this function within a function f VeriSol.Requires(E) installs + * E as a pre condition of f. + */ + function Requires(bool b) external pure; + + + /* + ******************************************************************** + * New functions for extending assertion language + ******************************************************************** + */ + + /** + * A new in-built function that returns the sum of all values of a mapping + * + */ + function SumMapping(mapping (address => int256) storage a) external pure returns (int256); + function SumMapping(mapping (address => uint256) storage a) external pure returns (uint256); + + /** + * Function to refer to the state of an expression at the entry to a method + * + */ + function Old(uint x) external pure returns (uint); + function Old(int x) external pure returns (uint); + function Old(address x) external pure returns (address); + + /** + * Function to specify the upper bound on the modifies set + * + */ + function Modifies(mapping (address => uint256) storage a, address[1] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[2] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[3] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[4] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[5] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[6] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[7] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[8] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[9] memory x) public pure; + function Modifies(mapping (address => uint256) storage a, address[10] memory x) public pure; + +} \ No newline at end of file diff --git a/Celestial/Compiler/main.py b/Celestial/Compiler/main.py new file mode 100644 index 00000000..04ffff2f --- /dev/null +++ b/Celestial/Compiler/main.py @@ -0,0 +1,50 @@ +import argparse +import sys + +from antlr4 import * + +from CelestialLexer import CelestialLexer +from CelestialParser import CelestialParser +from FStarCodegen import FStarCodegen +from SolidityCodegen import SolidityCodegen +from MyListener import MyListener + + +def main (argv): + argParser = argparse.ArgumentParser() + argParser.add_argument("celestialSource", help="The Celestial source code", type=str) + argParser.add_argument("--v", "--verificationMode", type=str, choices=["FStar", "VeriSol"], default="FStar", help="Specify whether to use FStar or VeriSol for verification.", required=False) + argParser.add_argument("--disableFuncBooleanCheck", default=False, action="store_true", help="Setting true allows non-boolean expressions inside functions. Used during compiler development.") + argParser.add_argument("--printSymbolTable", default=False, action="store_true", help="Displays symbol table. Used during compiler development") + argParser.add_argument("--outputDir", help="Specify output directory", default=".", type=str) + argParser.add_argument("--solDir", help="Specify output directory for Solidity file", type=str, required=False) + argParser.add_argument("--fstDir", help="Specify output directory for FStar file", type=str, required=False) + arguments = argParser.parse_args() + + sourceCode = FileStream(arguments.celestialSource) + lexer = CelestialLexer(sourceCode) + stream = CommonTokenStream(lexer) + parser = CelestialParser(stream) + tree = parser.program() + + verificationMode = arguments.v + print ("Generating input for verification using "+verificationMode) + outputDirectory = arguments.outputDir + solidityDirectory = arguments.solDir + fstarDirectory = arguments.fstDir + if solidityDirectory is None: + solidityDirectory = outputDirectory + if fstarDirectory is None: + fstarDirectory = outputDirectory + + FSTCodegen = FStarCodegen(fstarDirectory) + SolCodegen = SolidityCodegen(solidityDirectory, verificationMode) + + listenerOutput = MyListener(FSTCodegen, SolCodegen, arguments.printSymbolTable, arguments.disableFuncBooleanCheck, verificationMode) + walker = ParseTreeWalker() + walker.walk(listenerOutput, tree) + print (arguments.celestialSource + " compiled successfully.") + +if __name__ == '__main__': + print("Celestial v0.0.1") + main(sys.argv) diff --git a/Celestial/Language.md b/Celestial/Language.md new file mode 100644 index 00000000..ec5b4258 --- /dev/null +++ b/Celestial/Language.md @@ -0,0 +1,128 @@ +# Celestial + +Celestial as a framework evolved a lot over the last 2 years from its inception as a completely new language to a framework that allows annotating Solidity contracts with expressive specifications and automatically discharging them. However, even after repeated iterations, some elements from Celestial's previous versions still remain. (These differences and restrictions are **purely** syntactic). This document explains these deviations from vanilla Solidity and also its specification language. + +## Language + +A contract in Celestial follows the below structure: +``` +contract +{ + ; + + invariant + { + + } + + spec () + { + + } + + function () + + + + pre + post + tx_reverts + modifies [] + modifies_addresses [] + returns ( ) + { + ; + return; + } +} +``` + +## Specification Language + +Celestial's specification language contains the following constructs and annotations: +* `invariant` +* `spec` functions +* function specifications: + * `credit` + * `debit` + * `pre` + * `post` + * `tx_reverts` + * `modifies` + * `modifies_addresses` +* `log` ghost variable +* quantifiers +* other macros + +These elements are erased when generating Solidity. Note that all these constructs are 'pure'. None of the boolean expressions used in the specifications can modify the state. The following sections explain each of these constructs in detail. + +### `invariant` +These are contract-level invariants. An `invariant`'s body is a single boolean expression over the contract field variables, including `balance`. All defined contract-invariants are conjugated and assumed in functions' pre-conditions are asserted in their post-conditions. We allow writing multiple `invariant` blocks for developer convenience and code readability. + +### `spec` functions +These are pure functions whose bodies are just boolean expressions over their arguments. These functions allow for code reuse - repeating expressions can be wrapped in a `spec` function and called within `pre`, `post`, `tx_reverts` and other `spec` functions. + +### function specifications + +#### `credit` / `debit` +These are keywords that denote whether a contract function receives Ether, sends out Ether, both or neither. Functions that are not annotated with either `credit` or `debit` have a `new_balance == old_balance` clause added to its post-condition automatically. This check ensures that a contract does not send out Ether by accident. This forces developers to be cognizent of their contract's behviour, and explicitly add a `credit` or `debit` annotation to the function. Functions annotated with both `credit` and `debit` do not have any extra checks added automatically. + +#### `pre` +This is the function's pre-condition, which is just a boolean expression over the function's arguments, field variables, `balance` and `spec` function invocations. For public functions, this is almost always trivial (`true`). For public functions in a contract that are never called by other functions in the same contract, for example, the pre-condiitons `address(this) != msg.sender` is sound. Private functions can have non-trivial pre-conditions. Of course, these pre-conditions have to be ensured before calling this private function, without which the verification would fail. + +#### `post` +This is the function's post-condition, which is a boolean expression over the function's arguments, field variables, `log`, `balance`, the return variable, `spec` function invocations and also `new()`. `new()` denotes the updated value of the field variable (including `log` and `balance`) after the function is executed. The return variable is the name of the variable returned, denoted using Solidity's `returns ( )` clause. + +#### `tx_reverts` +This is the function's revert clause which again is a boolean expression similar to `pre`. This specifies the conditions under which a function may revert (described in the paper in more detail). + +#### `modifies` +This is a list of contract field variables that a function can modify. For all the field variables that are not in the `modifies` list, a `new_field_var == old_field_var` clause is added to the function's post-condition automatically. This ensures that a function cannot accidentally update a field variable. For functions that `emit` an event, the `log` variable should be added to the `modifies` clause explicitly. This prevents any unintended `emit`s caused due to that function. + +#### `modifies_addresses` +This is a list of addresses that a function can modify. These are not address literals (of course, our blockchain model is unaware of the actual state of the Ethereum blockchain) but variables that represent contract addresses. For example, `Item.getPrice()` in the Overview example requires that `modifies_addresses[address(this)]` be specified so that the caller `SimpleMarket.buy()` is assured that its own state would not be modified on an invocation to `getPrice()` (due to a re-entrant call, for example). + + +### `log` ghost variable +The `log` is a specification-only variable (cannot be used in the contract body) that models the EVM log. An `emit(...)` in Celestial appends to the head of this log (a list) with a tuple `(, ...)`. Post-conditions on `log` are written as follows: `new(log) == ()::():: ... ::log`, where the head of the list is the last emitted event. + +### quantifiers +Celestial also supports quantifiers in specification expressions as follows: `forall/exists ( , , ...) ()`. Note that excessive use of quantifiers can pollute Z3's VCs and may cause verification to break. + +### macros +Celestial supports macros such as `sum_mapping` which sums all values contained in a `mapping (... => uint)`. It also supports checking membership of a key within a `mapping` using the `in` keyword (e.g. `... && (key in map_var) ...`). Soldity does not support these constructs, and hence are specification-only within Celestial. (Note, Solidity's `mapping()` type does not have the concept of a domain - all keys of that type are present in the mapping. However, we extend this mapping type in our F* model to allow writing more expressive specifications with respect to key membership in a mapping, say after adding or removing an element from the mapping). Celestial also provides a way to concisely represent the following predicate - A map has only a key `k` updated with value `v` while keeping the other key-value pairs same - using the syntax `new(map_var) == map_var[k => v]`. + +The support for custom macros and functions is only bounded by F*'s expressiveness. It is easy to add new macros to Celestial to ease developer effort and to support more intricate specifications, akin to programming in F* directly, albeit in a more imperative style. These were just few macros that we found particularly useful during our analysis of popular smart contracts. + +
+ +## Deviations from Solidity + +Celestial's flavour of Solidity has minor syntactic changes compared to vanilla Solidity and also has some restrictions. We are working on Celestial to support vanilla Solidity for a better developer experience. Until then, the following are the changes: +* `msg.value` is just `value` in Celestial +* `msg.sender` is just `sender` in Celestial +* `address(this).balance` is just `balance` in Celestial +* The zero address `address(0)` is `null` in Celestial +* Celestial defines macros `uint_max`, `int_max` and `int_min` that correspond to `~uint256(0)`, `(int256(~(uint256(1) << 255)))` and `(int256(uint256(1) << 255))` respectively (the maximum and minimum values for the `uint` and `int` types). +* Celestial requires `return`ing only at the end of a function and not in between. +* Functions in Celestial require explicitly writing a `return` at the end of the function body. +* Celestial supports a type `inst_map` where `T` is a contract type. This is just a `mapping (Item => bool)` in Solidity with additonal semantics during verification. The semantics are as follows: + * Any addresses in an `inst_map` are guaranteed to be of a contract type `T`, which in turn gives stronger guarantees on methods invoked on contract instances corresponding to this address. + * This is ensured by allowing additions into the `inst_map` only via an `add()` function defined on the `inst_map` that requires `new T(...)` as an argument - such a restriction guarantees that the addresses are of type `T`. + * Additions to the `inst_map` translate to setting the value in the `mapping` to `true`. + * Lookups of an address from the `inst_map` returns the contract instance corresponding to that address if present (i.e. if the `mapping` value is `true`) or `address(0)` otherwise. +* `inst_map`s in specifications can only be used within `spec` functions and cannot be inlined in the `pre`, `post` and `tx_reverts` conditions. +* Local variables cannot be mutated within blocks. +* Explicit casting is not allowed, for e.g.: `Item(some_address)` + +These syntactic changes can be resolved in the following ways: +* Exposing a lightweight library for the macros `uint_max`, ... +* Use Solidity's `mapping(T => bool)` itself in place of `inst_map`s but provide an extra annotation (for the verification backend) to mark this `mapping()` to semantically equivalent to an `inst_map`. This annotation will be erased along with other specifications. +* Removing mandatory `return` statements is just a tweak in the prettyprinter. +* Field variables can be used instead of local variables if their mutability is required within blocks. + +## Other remarks + +* The Celestial -> F* and Celestial -> Solidity prettyprinters do lightweight typechecking. This will also be removed - F*'s typechecker suffices. +* F* verification may fail with an `unknown assertion failed` error if the contract is large. In such cases, the `z3rlimit` has to be increased. +* The specification eraser can sometimes reorder field variable declarations. However, this does not affect the semantics of the contract. This will be fixed in a future update. \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/README.md b/Celestial/Samples/AssetTransfer/README.md new file mode 100644 index 00000000..6cfafe8f --- /dev/null +++ b/Celestial/Samples/AssetTransfer/README.md @@ -0,0 +1,3 @@ +# Asset Transfer + +[Original contract](https://github.com/Azure-Samples/blockchain/blob/master/blockchain-workbench/application-and-smart-contract-samples/asset-transfer/ethereum/AssetTransfer.sol) \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace.json b/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace.json new file mode 100644 index 00000000..e4ec238f --- /dev/null +++ b/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace.json @@ -0,0 +1,8411 @@ +{ + "contractName": "MarketPlace", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_seller", + "type": "address" + }, + { + "internalType": "address", + "name": "_buyer", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eAcceptOffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eMakeOffer", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_sellingPrice", + "type": "uint256" + } + ], + "name": "MakeOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "_increase", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_change", + "type": "uint256" + } + ], + "name": "ModifyOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "RejectOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "AcceptOffer", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "Accept", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "Withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_seller\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_buyer\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eAcceptOffer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eMakeOffer\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"Accept\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"AcceptOffer\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_sellingPrice\",\"type\":\"uint256\"}],\"name\":\"MakeOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_increase\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_change\",\"type\":\"uint256\"}],\"name\":\"ModifyOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"RejectOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"Withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/AssetTransfer.sol\":\"MarketPlace\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/AssetTransfer.sol\":{\"keccak256\":\"0x8dcbfa9bcc23dc1844875e97c7c50b1a810c3fb3069bbe8b10b91dc4b8517d10\",\"urls\":[\"bzz-raw://061f3cbc9d9b045718dc8ef1fb1e19c900f94a81b42d649b13fbb5a1d1275909\",\"dweb:/ipfs/QmUA8g3Rz7ayQeV9fWHQ3rLU9wEy7GKDktchbUhLiexaj1\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051610cd1380380610cd18339818101604052604081101561003357600080fd5b810190808051906020019092919080519060200190929190505050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460006101000a81548160ff021916908360058111156100ee57fe5b02179055505050610bcd806101046000396000f3fe6080604052600436106100555760003560e01c806357ea89b61461005a57806358993640146100715780636bd6fe801461008857806372ffb2fe1461009f578063d12cd942146100da578063ff01a152146100e4575b600080fd5b34801561006657600080fd5b5061006f61012b565b005b34801561007d57600080fd5b5061008661029c565b005b34801561009457600080fd5b5061009d610638565b005b3480156100ab57600080fd5b506100d8600480360360208110156100c257600080fd5b8101908080359060200190929190505050610738565b005b6100e26108ce565b005b3480156100f057600080fd5b506101296004803603604081101561010757600080fd5b8101908080351515906020019092919080359060200190929190505050610a6d565b005b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461018557600080fd5b60058081111561019157fe5b600460009054906101000a900460ff1660058111156101ac57fe5b14610202576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660035460405180600001905060006040518083038185875af1925050503d8060008114610285576040519150601f19603f3d011682016040523d82523d6000602084013e61028a565b606091505b505090508061029857600080fd5b5050565b600260058111156102a957fe5b600460009054906101000a900460ff1660058111156102c457fe5b14806102f55750600360058111156102d857fe5b600460009054906101000a900460ff1660058111156102f357fe5b145b8061032557506004600581111561030857fe5b600460009054906101000a900460ff16600581111561032357fe5b145b61037a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6002600581111561038757fe5b600460009054906101000a900460ff1660058111156103a257fe5b1480156103fc5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1561042a576003600460006101000a81548160ff0219169083600581111561042057fe5b0217905550610636565b6002600581111561043757fe5b600460009054906101000a900460ff16600581111561045257fe5b1480156104ab57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156104d85760048060006101000a81548160ff021916908360058111156104ce57fe5b0217905550610635565b600360058111156104e557fe5b600460009054906101000a900460ff16600581111561050057fe5b14801561055957506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610587576005600460006101000a81548160ff0219169083600581111561057d57fe5b0217905550610634565b6004600581111561059457fe5b600460009054906101000a900460ff1660058111156105af57fe5b1480156106095750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610633576005600460006101000a81548160ff0219169083600581111561062d57fe5b02179055505b5b5b5b565b33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461069357600080fd5b600160058111156106a057fe5b600460009054906101000a900460ff1660058111156106bb57fe5b14610711576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6000600460006101000a81548160ff0219169083600581111561073057fe5b021790555050565b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461079257600080fd5b6000600581111561079f57fe5b600460009054906101000a900460ff1660058111156107ba57fe5b14610810576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b816002819055506001600460006101000a81548160ff0219169083600581111561083657fe5b02179055507fac2a732696baf520f05929eb1f8ee293cc8166f98af0cfd49f9c5fc019f3132c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600254604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461092957600080fd5b6001600581111561093657fe5b600460009054906101000a900460ff16600581111561095157fe5b146109a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6002543410610a6a57346003819055507fa9a2c228cc57d1d709c8bd829952b1187721791bde967500f8e72bc5fcec89346000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600354604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16002600460006101000a81548160ff02191690836005811115610a6457fe5b02179055505b50565b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610ac757600080fd5b60016005811115610ad457fe5b600460009054906101000a900460ff166005811115610aef57fe5b14610b45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b8215610b5b578160025401600281905550610b67565b81600254036002819055505b50505056fe3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465a265627a7a723158209e2c8567a0634ddb298a675005b0247a4b6ae7866d668cc403321f3921e7899464736f6c63430005100032", + "deployedBytecode": "0x6080604052600436106100555760003560e01c806357ea89b61461005a57806358993640146100715780636bd6fe801461008857806372ffb2fe1461009f578063d12cd942146100da578063ff01a152146100e4575b600080fd5b34801561006657600080fd5b5061006f61012b565b005b34801561007d57600080fd5b5061008661029c565b005b34801561009457600080fd5b5061009d610638565b005b3480156100ab57600080fd5b506100d8600480360360208110156100c257600080fd5b8101908080359060200190929190505050610738565b005b6100e26108ce565b005b3480156100f057600080fd5b506101296004803603604081101561010757600080fd5b8101908080351515906020019092919080359060200190929190505050610a6d565b005b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461018557600080fd5b60058081111561019157fe5b600460009054906101000a900460ff1660058111156101ac57fe5b14610202576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660035460405180600001905060006040518083038185875af1925050503d8060008114610285576040519150601f19603f3d011682016040523d82523d6000602084013e61028a565b606091505b505090508061029857600080fd5b5050565b600260058111156102a957fe5b600460009054906101000a900460ff1660058111156102c457fe5b14806102f55750600360058111156102d857fe5b600460009054906101000a900460ff1660058111156102f357fe5b145b8061032557506004600581111561030857fe5b600460009054906101000a900460ff16600581111561032357fe5b145b61037a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6002600581111561038757fe5b600460009054906101000a900460ff1660058111156103a257fe5b1480156103fc5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b1561042a576003600460006101000a81548160ff0219169083600581111561042057fe5b0217905550610636565b6002600581111561043757fe5b600460009054906101000a900460ff16600581111561045257fe5b1480156104ab57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156104d85760048060006101000a81548160ff021916908360058111156104ce57fe5b0217905550610635565b600360058111156104e557fe5b600460009054906101000a900460ff16600581111561050057fe5b14801561055957506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610587576005600460006101000a81548160ff0219169083600581111561057d57fe5b0217905550610634565b6004600581111561059457fe5b600460009054906101000a900460ff1660058111156105af57fe5b1480156106095750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610633576005600460006101000a81548160ff0219169083600581111561062d57fe5b02179055505b5b5b5b565b33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461069357600080fd5b600160058111156106a057fe5b600460009054906101000a900460ff1660058111156106bb57fe5b14610711576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6000600460006101000a81548160ff0219169083600581111561073057fe5b021790555050565b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461079257600080fd5b6000600581111561079f57fe5b600460009054906101000a900460ff1660058111156107ba57fe5b14610810576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b816002819055506001600460006101000a81548160ff0219169083600581111561083657fe5b02179055507fac2a732696baf520f05929eb1f8ee293cc8166f98af0cfd49f9c5fc019f3132c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600254604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461092957600080fd5b6001600581111561093657fe5b600460009054906101000a900460ff16600581111561095157fe5b146109a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b6002543410610a6a57346003819055507fa9a2c228cc57d1d709c8bd829952b1187721791bde967500f8e72bc5fcec89346000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600354604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16002600460006101000a81548160ff02191690836005811115610a6457fe5b02179055505b50565b336000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610ac757600080fd5b60016005811115610ad457fe5b600460009054906101000a900460ff166005811115610aef57fe5b14610b45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b6d602c913960400191505060405180910390fd5b8215610b5b578160025401600281905550610b67565b81600254036002819055505b50505056fe3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465a265627a7a723158209e2c8567a0634ddb298a675005b0247a4b6ae7866d668cc403321f3921e7899464736f6c63430005100032", + "sourceMap": "26:3727:0:-;;;642:180;8:9:-1;5:2;;;30:1;27;20:12;5:2;642:180:0;;;;;;;;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;642:180:0;;;;;;;;;;;;;;;;;;;;;;;;;726:7;717:6;;:16;;;;;;;;;;;;;;;;;;751:6;743:5;;:14;;;;;;;;;;;;;;;;;;791:24;768:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;642:180;;26:3727;;;;;;", + "deployedSourceMap": "26:3727:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3453:298;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3453:298:0;;;:::i;:::-;;2378:1069;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2378:1069:0;;;:::i;:::-;;1631:257;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1631:257:0;;;:::i;:::-;;828:358;;8:9:-1;5:2;;;30:1;27;20:12;5:2;828:358:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;828:358:0;;;;;;;;;;;;;;;;;:::i;:::-;;1894:478;;;:::i;:::-;;1192:433;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1192:433:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1192:433:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;3453:298;3506:10;513:6;;;;;;;;;;;502:17;;:7;:17;;;494:26;;;;;;3564:24;3540:48;;;;;;;;:20;;;;;;;;;;;:48;;;;;;;;;3532:105;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3649:12;3667:6;;;;;;;;;;;:11;;3685;;3667:34;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;3648:53:0;;;3715:7;3711:33;;3736:8;;;3711:33;530:1;3453:298;:::o;2378:1069::-;2457:32;2433:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:113;;;;2517:29;2493:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;2433:113;:187;;;;2590:30;2566:54;;;;;;;;:20;;;;;;;;;;;:54;;;;;;;;;2433:187;2425:244;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2708:32;2684:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:79;;;;;2758:5;;;;;;;;;;;2744:19;;:10;:19;;;2684:79;2680:761;;;2810:29;2787:20;;:52;;;;;;;;;;;;;;;;;;;;;;;;2680:761;;;2893:32;2869:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:80;;;;;2943:6;;;;;;;;;;;2929:20;;:10;:20;;;2869:80;2865:576;;;2996:30;2973:20;;:53;;;;;;;;;;;;;;;;;;;;;;;;2865:576;;;3080:29;3056:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;:77;;;;;3127:6;;;;;;;;;;;3113:20;;:10;:20;;;3056:77;3052:389;;;3228:24;3205:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;3052:389;;;3306:30;3282:54;;;;;;;;:20;;;;;;;;;;;:54;;;;;;;;;:77;;;;;3354:5;;;;;;;;;;;3340:19;;:10;:19;;;3282:77;3278:163;;;3406:24;3383:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;3278:163;3052:389;2865:576;2680:761;2378:1069::o;1631:257::-;1687:10;612:5;;;;;;;;;;;601:16;;:7;:16;;;593:25;;;;;;1745:29;1721:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;1713:110;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1857:24;1834:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;1631:257;:::o;828:358::-;901:10;513:6;;;;;;;;;;;502:17;;:7;:17;;;494:26;;;;;;959:24;935:48;;;;;;;;:20;;;;;;;;;;;:48;;;;;;;;;927:105;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1058:13;1043:12;:28;;;;1104:29;1081:20;;:52;;;;;;;;;;;;;;;;;;;;;;;;1148:31;1159:5;;;;;;;;;;;1166:12;;1148:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;828:358;;:::o;1894:478::-;1966:10;612:5;;;;;;;;;;;601:16;;:7;:16;;;593:25;;;;;;2069:29;2045:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;2037:110;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2175:12;;2162:9;:25;2158:208;;2225:9;2211:11;:23;;;;2253:33;2266:6;;;;;;;;;;;2274:11;;2253:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;2323:32;2300:20;;:55;;;;;;;;;;;;;;;;;;;;;;;;2158:208;1894:478;:::o;1192:433::-;1277:10;513:6;;;;;;;;;;;502:17;;:7;:17;;;494:26;;;;;;1335:29;1311:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;1303:110;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1428:9;1424:195;;;1491:7;1476:12;;:22;1461:12;:37;;;;1424:195;;;1587:7;1572:12;;:22;1557:12;:37;;;;1424:195;1192:433;;;:::o", + "source": "pragma solidity >=0.5.1;\n\ncontract MarketPlace\n{\n address seller;\n address buyer;\n\n uint sellingPrice;\n uint buyingPrice;\n\n enum State\n {\n MarketPlace_Active, MarketPlace_OfferPlaced, MarketPlace_NotionalAccept,\n MarketPlace_BuyerAccept, MarketPlace_SellerAccept, MarketPlace_Accept\n }\n State private ContractCurrentState;\n\n event eMakeOffer(address, uint);\n event eAcceptOffer(address, uint);\n\n modifier isSeller (address _caller)\n {\n require(_caller == seller);\n _;\n }\n\n modifier isBuyer (address _caller)\n {\n require(_caller == buyer);\n _;\n }\n\n constructor (address _seller, address _buyer)\n public\n {\n seller = _seller;\n buyer = _buyer;\n\n ContractCurrentState = State.MarketPlace_Active;\n }\n\n function MakeOffer (uint _sellingPrice)\n public\n isSeller (msg.sender)\n {\n require(ContractCurrentState == State.MarketPlace_Active, \" function invoked in invalid state\");\n\n sellingPrice = _sellingPrice;\n ContractCurrentState = State.MarketPlace_OfferPlaced;\n emit eMakeOffer(buyer, sellingPrice);\n }\n\n function ModifyOffer (bool _increase, uint _change)\n public\n isSeller (msg.sender)\n {\n require(ContractCurrentState == State.MarketPlace_OfferPlaced, \" function invoked in invalid state\");\n\n if (_increase)\n {\n sellingPrice = sellingPrice + _change; // overflow\n }\n else\n {\n sellingPrice = sellingPrice - _change; // underflow\n }\n }\n\n function RejectOffer ()\n public\n isBuyer (msg.sender)\n {\n require(ContractCurrentState == State.MarketPlace_OfferPlaced, \" function invoked in invalid state\");\n\n ContractCurrentState = State.MarketPlace_Active;\n }\n\n function AcceptOffer ()\n public\n payable\n isBuyer (msg.sender)\n {\n // Workbench bug: MarketPlace_Active\n require(ContractCurrentState == State.MarketPlace_OfferPlaced, \" function invoked in invalid state\");\n\n if (msg.value >= sellingPrice)\n {\n buyingPrice = msg.value;\n emit eAcceptOffer(seller, buyingPrice);\n ContractCurrentState = State.MarketPlace_NotionalAccept;\n }\n }\n\n function Accept()\n public\n {\n require(ContractCurrentState == State.MarketPlace_NotionalAccept || ContractCurrentState == State.MarketPlace_BuyerAccept ||\n ContractCurrentState == State.MarketPlace_SellerAccept, \" function invoked in invalid state\");\n\n if (ContractCurrentState == State.MarketPlace_NotionalAccept && msg.sender == buyer)\n {\n ContractCurrentState = State.MarketPlace_BuyerAccept;\n }\n\n else if (ContractCurrentState == State.MarketPlace_NotionalAccept && msg.sender == seller)\n {\n ContractCurrentState = State.MarketPlace_SellerAccept;\n }\n\n else if (ContractCurrentState == State.MarketPlace_BuyerAccept && msg.sender == seller)\n {\n // workbench bug: goto SellerAccept\n ContractCurrentState = State.MarketPlace_Accept;\n }\n\n else if (ContractCurrentState == State.MarketPlace_SellerAccept && msg.sender == buyer)\n {\n ContractCurrentState = State.MarketPlace_Accept;\n }\n }\n\n function Withdraw()\n public\n isSeller (msg.sender)\n {\n require(ContractCurrentState == State.MarketPlace_Accept, \" function invoked in invalid state\");\n\n (bool success, ) = seller.call.value(buyingPrice)(\"\");\n if(!success)\n revert();\n }\n}", + "sourcePath": "C:\\Users\\t-sumukh\\source\\repos\\smart-contracts\\gitrepo\\celestial\\Experiments\\AssetTransfer\\contracts\\AssetTransfer.sol", + "ast": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/AssetTransfer.sol", + "exportedSymbols": { + "MarketPlace": [ + 320 + ] + }, + "id": 321, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + ">=", + "0.5", + ".1" + ], + "nodeType": "PragmaDirective", + "src": "0:24:0" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 320, + "linearizedBaseContracts": [ + 320 + ], + "name": "MarketPlace", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 3, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "53:14:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 2, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "53:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 5, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "73:13:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 4, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "73:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 7, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "93:17:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 6, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "93:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 9, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "116:16:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 8, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "116:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "canonicalName": "MarketPlace.State", + "id": 16, + "members": [ + { + "id": 10, + "name": "MarketPlace_Active", + "nodeType": "EnumValue", + "src": "164:18:0" + }, + { + "id": 11, + "name": "MarketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "184:23:0" + }, + { + "id": 12, + "name": "MarketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "209:26:0" + }, + { + "id": 13, + "name": "MarketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "246:23:0" + }, + { + "id": 14, + "name": "MarketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "271:24:0" + }, + { + "id": 15, + "name": "MarketPlace_Accept", + "nodeType": "EnumValue", + "src": "297:18:0" + } + ], + "name": "State", + "nodeType": "EnumDefinition", + "src": "139:182:0" + }, + { + "constant": false, + "id": 18, + "name": "ContractCurrentState", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "326:34:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "typeName": { + "contractScope": null, + "id": 17, + "name": "State", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 16, + "src": "326:5:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "value": null, + "visibility": "private" + }, + { + "anonymous": false, + "documentation": null, + "id": 24, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 23, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 20, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 24, + "src": "384:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 19, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "384:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 22, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 24, + "src": "393:4:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 21, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "393:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "383:15:0" + }, + "src": "367:32:0" + }, + { + "anonymous": false, + "documentation": null, + "id": 30, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 26, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "423:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 25, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "423:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 28, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "432:4:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 27, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "432:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "422:15:0" + }, + "src": "404:34:0" + }, + { + "body": { + "id": 41, + "nodeType": "Block", + "src": "484:54:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 37, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 35, + "name": "_caller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 32, + "src": "502:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 36, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "513:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "502:17:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 34, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 826, + "src": "494:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 38, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "494:26:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 39, + "nodeType": "ExpressionStatement", + "src": "494:26:0" + }, + { + "id": 40, + "nodeType": "PlaceholderStatement", + "src": "530:1:0" + } + ] + }, + "documentation": null, + "id": 42, + "name": "isSeller", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 33, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 32, + "name": "_caller", + "nodeType": "VariableDeclaration", + "scope": 42, + "src": "463:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 31, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "463:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "462:17:0" + }, + "src": "444:94:0", + "visibility": "internal" + }, + { + "body": { + "id": 53, + "nodeType": "Block", + "src": "583:53:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 47, + "name": "_caller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 44, + "src": "601:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 48, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "612:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "601:16:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 46, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 826, + "src": "593:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "593:25:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "593:25:0" + }, + { + "id": 52, + "nodeType": "PlaceholderStatement", + "src": "628:1:0" + } + ] + }, + "documentation": null, + "id": 54, + "name": "isBuyer", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 44, + "name": "_caller", + "nodeType": "VariableDeclaration", + "scope": 54, + "src": "562:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 43, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "562:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "561:17:0" + }, + "src": "544:92:0", + "visibility": "internal" + }, + { + "body": { + "id": 74, + "nodeType": "Block", + "src": "707:115:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 61, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "717:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 62, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 56, + "src": "726:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "717:16:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 64, + "nodeType": "ExpressionStatement", + "src": "717:16:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 67, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 65, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "743:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 66, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 58, + "src": "751:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "743:14:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 68, + "nodeType": "ExpressionStatement", + "src": "743:14:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 72, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 69, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "768:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 70, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "791:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 71, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "791:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "768:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 73, + "nodeType": "ExpressionStatement", + "src": "768:47:0" + } + ] + }, + "documentation": null, + "id": 75, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 59, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 75, + "src": "655:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 55, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "655:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 58, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 75, + "src": "672:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 57, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "672:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "654:33:0" + }, + "returnParameters": { + "id": 60, + "nodeType": "ParameterList", + "parameters": [], + "src": "707:0:0" + }, + "scope": 320, + "src": "642:180:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 106, + "nodeType": "Block", + "src": "917:269:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 88, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 85, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "935:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 86, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "959:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 87, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "959:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "935:48:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 89, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "985:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 84, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "927:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 90, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "927:105:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 91, + "nodeType": "ExpressionStatement", + "src": "927:105:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 94, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 92, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1043:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 93, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 77, + "src": "1058:13:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1043:28:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 95, + "nodeType": "ExpressionStatement", + "src": "1043:28:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 99, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 96, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1081:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 97, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1104:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 98, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1104:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1081:52:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 100, + "nodeType": "ExpressionStatement", + "src": "1081:52:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 102, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "1159:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 103, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1166:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 101, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 24, + "src": "1148:10:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1148:31:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 105, + "nodeType": "EmitStatement", + "src": "1143:36:0" + } + ] + }, + "documentation": null, + "id": 107, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 80, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "901:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 81, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "901:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 82, + "modifierName": { + "argumentTypes": null, + "id": 79, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "891:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "891:21:0" + } + ], + "name": "MakeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 78, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 77, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 107, + "src": "848:18:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 76, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "848:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "847:20:0" + }, + "returnParameters": { + "id": 83, + "nodeType": "ParameterList", + "parameters": [], + "src": "917:0:0" + }, + "scope": 320, + "src": "828:358:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 142, + "nodeType": "Block", + "src": "1293:332:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 122, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 119, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1311:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 120, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1335:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 121, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1335:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1311:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 123, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1366:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 118, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "1303:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 124, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1303:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 125, + "nodeType": "ExpressionStatement", + "src": "1303:110:0" + }, + { + "condition": { + "argumentTypes": null, + "id": 126, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 109, + "src": "1428:9:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 140, + "nodeType": "Block", + "src": "1543:76:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 138, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 134, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1557:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 137, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 135, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1572:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 136, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 111, + "src": "1587:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1572:22:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1557:37:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 139, + "nodeType": "ExpressionStatement", + "src": "1557:37:0" + } + ] + }, + "id": 141, + "nodeType": "IfStatement", + "src": "1424:195:0", + "trueBody": { + "id": 133, + "nodeType": "Block", + "src": "1447:74:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 131, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 127, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1461:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 130, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 128, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1476:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 129, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 111, + "src": "1491:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1476:22:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1461:37:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 132, + "nodeType": "ExpressionStatement", + "src": "1461:37:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 143, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 114, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1277:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 115, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1277:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 116, + "modifierName": { + "argumentTypes": null, + "id": 113, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "1267:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1267:21:0" + } + ], + "name": "ModifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 112, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 109, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 143, + "src": "1214:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 108, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1214:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 111, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 143, + "src": "1230:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 110, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1230:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1213:30:0" + }, + "returnParameters": { + "id": 117, + "nodeType": "ParameterList", + "parameters": [], + "src": "1293:0:0" + }, + "scope": 320, + "src": "1192:433:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 163, + "nodeType": "Block", + "src": "1703:185:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 154, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 151, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1721:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 152, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1745:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 153, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1745:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1721:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 155, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1776:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 150, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "1713:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 156, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1713:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 157, + "nodeType": "ExpressionStatement", + "src": "1713:110:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 161, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 158, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1834:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 159, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1857:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 160, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1857:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1834:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 162, + "nodeType": "ExpressionStatement", + "src": "1834:47:0" + } + ] + }, + "documentation": null, + "id": 164, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 146, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1687:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 147, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1687:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 148, + "modifierName": { + "argumentTypes": null, + "id": 145, + "name": "isBuyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 54, + "src": "1678:7:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1678:20:0" + } + ], + "name": "RejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 144, + "nodeType": "ParameterList", + "parameters": [], + "src": "1652:2:0" + }, + "returnParameters": { + "id": 149, + "nodeType": "ParameterList", + "parameters": [], + "src": "1703:0:0" + }, + "scope": 320, + "src": "1631:257:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 200, + "nodeType": "Block", + "src": "1982:390:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 175, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 172, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2045:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 173, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2069:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 174, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2069:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2045:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 176, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2100:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 171, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "2037:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 177, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2037:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 178, + "nodeType": "ExpressionStatement", + "src": "2037:110:0" + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 182, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 179, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2162:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 180, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2162:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 181, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "2175:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2162:25:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 199, + "nodeType": "IfStatement", + "src": "2158:208:0", + "trueBody": { + "id": 198, + "nodeType": "Block", + "src": "2197:169:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 186, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 183, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "2211:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 184, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2225:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 185, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2225:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2211:23:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 187, + "nodeType": "ExpressionStatement", + "src": "2211:23:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 189, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "2266:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 190, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "2274:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 188, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 30, + "src": "2253:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 191, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2253:33:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 192, + "nodeType": "EmitStatement", + "src": "2248:38:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 196, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 193, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2300:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 194, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2323:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 195, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2323:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2300:55:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 197, + "nodeType": "ExpressionStatement", + "src": "2300:55:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 201, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 167, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1966:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 168, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1966:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 169, + "modifierName": { + "argumentTypes": null, + "id": 166, + "name": "isBuyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 54, + "src": "1957:7:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1957:20:0" + } + ], + "name": "AcceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 165, + "nodeType": "ParameterList", + "parameters": [], + "src": "1915:2:0" + }, + "returnParameters": { + "id": 170, + "nodeType": "ParameterList", + "parameters": [], + "src": "1982:0:0" + }, + "scope": 320, + "src": "1894:478:0", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 286, + "nodeType": "Block", + "src": "2415:1032:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 218, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 213, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 208, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 205, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2433:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 206, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2457:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 207, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2457:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2433:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 212, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 209, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2493:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 210, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2517:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 211, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2517:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2493:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2433:113:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 217, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 214, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2566:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 215, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2590:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 216, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2590:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2566:54:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2433:187:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 219, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2622:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 204, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "2425:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 220, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2425:244:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 221, + "nodeType": "ExpressionStatement", + "src": "2425:244:0" + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 230, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 225, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 222, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2684:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 223, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2708:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 224, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2708:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2684:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 229, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 226, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2744:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 227, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2744:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 228, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "2758:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2744:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2684:79:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 245, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 240, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 237, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2869:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 238, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2893:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 239, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2893:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2869:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 244, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 241, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2929:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 242, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2929:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 243, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "2943:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2929:20:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2869:80:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 260, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 255, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 252, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3056:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 253, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3080:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 254, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3080:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3056:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 259, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 256, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3113:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 257, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3113:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 258, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "3127:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3113:20:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3056:77:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 275, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 270, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 267, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3282:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 268, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3306:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 269, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3306:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3282:54:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 274, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 271, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3340:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 272, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3340:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 273, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "3354:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3340:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3282:77:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 282, + "nodeType": "IfStatement", + "src": "3278:163:0", + "trueBody": { + "id": 281, + "nodeType": "Block", + "src": "3369:72:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 279, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 276, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3383:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 277, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3406:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 278, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3406:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3383:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 280, + "nodeType": "ExpressionStatement", + "src": "3383:47:0" + } + ] + } + }, + "id": 283, + "nodeType": "IfStatement", + "src": "3052:389:0", + "trueBody": { + "id": 266, + "nodeType": "Block", + "src": "3143:120:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 264, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 261, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3205:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 262, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3228:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 263, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3228:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3205:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 265, + "nodeType": "ExpressionStatement", + "src": "3205:47:0" + } + ] + } + }, + "id": 284, + "nodeType": "IfStatement", + "src": "2865:576:0", + "trueBody": { + "id": 251, + "nodeType": "Block", + "src": "2959:78:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 249, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 246, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2973:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 247, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2996:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 248, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2996:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2973:53:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 250, + "nodeType": "ExpressionStatement", + "src": "2973:53:0" + } + ] + } + }, + "id": 285, + "nodeType": "IfStatement", + "src": "2680:761:0", + "trueBody": { + "id": 236, + "nodeType": "Block", + "src": "2773:77:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 234, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 231, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2787:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 232, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2810:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 233, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2810:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2787:52:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 235, + "nodeType": "ExpressionStatement", + "src": "2787:52:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 287, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "Accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 202, + "nodeType": "ParameterList", + "parameters": [], + "src": "2393:2:0" + }, + "returnParameters": { + "id": 203, + "nodeType": "ParameterList", + "parameters": [], + "src": "2415:0:0" + }, + "scope": 320, + "src": "2378:1069:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 318, + "nodeType": "Block", + "src": "3522:229:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 298, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 295, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3540:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 296, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3564:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 297, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3564:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3540:48:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 299, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3590:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 294, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "3532:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 300, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3532:105:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 301, + "nodeType": "ExpressionStatement", + "src": "3532:105:0" + }, + { + "assignments": [ + 303, + null + ], + "declarations": [ + { + "constant": false, + "id": 303, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 318, + "src": "3649:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 302, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "3649:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 311, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 309, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3698:2:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "id": 307, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "3685:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 304, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "3667:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 305, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3667:11:0", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 306, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3667:17:0", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 308, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3667:30:0", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 310, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3667:34:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "3648:53:0" + }, + { + "condition": { + "argumentTypes": null, + "id": 313, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3714:8:0", + "subExpression": { + "argumentTypes": null, + "id": 312, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 303, + "src": "3715:7:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 317, + "nodeType": "IfStatement", + "src": "3711:33:0", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "id": 314, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 828, + "src": "3736:6:0", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$__$returns$__$", + "typeString": "function () pure" + } + }, + "id": 315, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3736:8:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 316, + "nodeType": "ExpressionStatement", + "src": "3736:8:0" + } + } + ] + }, + "documentation": null, + "id": 319, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 290, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3506:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 291, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3506:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 292, + "modifierName": { + "argumentTypes": null, + "id": 289, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "3496:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "3496:21:0" + } + ], + "name": "Withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 288, + "nodeType": "ParameterList", + "parameters": [], + "src": "3470:2:0" + }, + "returnParameters": { + "id": 293, + "nodeType": "ParameterList", + "parameters": [], + "src": "3522:0:0" + }, + "scope": 320, + "src": "3453:298:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 321, + "src": "26:3727:0" + } + ], + "src": "0:3753:0" + }, + "legacyAST": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/AssetTransfer.sol", + "exportedSymbols": { + "MarketPlace": [ + 320 + ] + }, + "id": 321, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + ">=", + "0.5", + ".1" + ], + "nodeType": "PragmaDirective", + "src": "0:24:0" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 320, + "linearizedBaseContracts": [ + 320 + ], + "name": "MarketPlace", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 3, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "53:14:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 2, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "53:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 5, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "73:13:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 4, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "73:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 7, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "93:17:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 6, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "93:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 9, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "116:16:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 8, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "116:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "canonicalName": "MarketPlace.State", + "id": 16, + "members": [ + { + "id": 10, + "name": "MarketPlace_Active", + "nodeType": "EnumValue", + "src": "164:18:0" + }, + { + "id": 11, + "name": "MarketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "184:23:0" + }, + { + "id": 12, + "name": "MarketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "209:26:0" + }, + { + "id": 13, + "name": "MarketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "246:23:0" + }, + { + "id": 14, + "name": "MarketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "271:24:0" + }, + { + "id": 15, + "name": "MarketPlace_Accept", + "nodeType": "EnumValue", + "src": "297:18:0" + } + ], + "name": "State", + "nodeType": "EnumDefinition", + "src": "139:182:0" + }, + { + "constant": false, + "id": 18, + "name": "ContractCurrentState", + "nodeType": "VariableDeclaration", + "scope": 320, + "src": "326:34:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "typeName": { + "contractScope": null, + "id": 17, + "name": "State", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 16, + "src": "326:5:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "value": null, + "visibility": "private" + }, + { + "anonymous": false, + "documentation": null, + "id": 24, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 23, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 20, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 24, + "src": "384:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 19, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "384:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 22, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 24, + "src": "393:4:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 21, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "393:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "383:15:0" + }, + "src": "367:32:0" + }, + { + "anonymous": false, + "documentation": null, + "id": 30, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 26, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "423:7:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 25, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "423:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 28, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "432:4:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 27, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "432:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "422:15:0" + }, + "src": "404:34:0" + }, + { + "body": { + "id": 41, + "nodeType": "Block", + "src": "484:54:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 37, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 35, + "name": "_caller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 32, + "src": "502:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 36, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "513:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "502:17:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 34, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 826, + "src": "494:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 38, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "494:26:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 39, + "nodeType": "ExpressionStatement", + "src": "494:26:0" + }, + { + "id": 40, + "nodeType": "PlaceholderStatement", + "src": "530:1:0" + } + ] + }, + "documentation": null, + "id": 42, + "name": "isSeller", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 33, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 32, + "name": "_caller", + "nodeType": "VariableDeclaration", + "scope": 42, + "src": "463:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 31, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "463:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "462:17:0" + }, + "src": "444:94:0", + "visibility": "internal" + }, + { + "body": { + "id": 53, + "nodeType": "Block", + "src": "583:53:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 47, + "name": "_caller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 44, + "src": "601:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 48, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "612:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "601:16:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 46, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 826, + "src": "593:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "593:25:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "593:25:0" + }, + { + "id": 52, + "nodeType": "PlaceholderStatement", + "src": "628:1:0" + } + ] + }, + "documentation": null, + "id": 54, + "name": "isBuyer", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 44, + "name": "_caller", + "nodeType": "VariableDeclaration", + "scope": 54, + "src": "562:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 43, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "562:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "561:17:0" + }, + "src": "544:92:0", + "visibility": "internal" + }, + { + "body": { + "id": 74, + "nodeType": "Block", + "src": "707:115:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 61, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "717:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 62, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 56, + "src": "726:7:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "717:16:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 64, + "nodeType": "ExpressionStatement", + "src": "717:16:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 67, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 65, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "743:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 66, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 58, + "src": "751:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "743:14:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 68, + "nodeType": "ExpressionStatement", + "src": "743:14:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 72, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 69, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "768:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 70, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "791:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 71, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "791:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "768:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 73, + "nodeType": "ExpressionStatement", + "src": "768:47:0" + } + ] + }, + "documentation": null, + "id": 75, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 59, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 75, + "src": "655:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 55, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "655:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 58, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 75, + "src": "672:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 57, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "672:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "654:33:0" + }, + "returnParameters": { + "id": 60, + "nodeType": "ParameterList", + "parameters": [], + "src": "707:0:0" + }, + "scope": 320, + "src": "642:180:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 106, + "nodeType": "Block", + "src": "917:269:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 88, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 85, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "935:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 86, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "959:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 87, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "959:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "935:48:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 89, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "985:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 84, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "927:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 90, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "927:105:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 91, + "nodeType": "ExpressionStatement", + "src": "927:105:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 94, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 92, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1043:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 93, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 77, + "src": "1058:13:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1043:28:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 95, + "nodeType": "ExpressionStatement", + "src": "1043:28:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 99, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 96, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1081:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 97, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1104:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 98, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1104:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1081:52:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 100, + "nodeType": "ExpressionStatement", + "src": "1081:52:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 102, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "1159:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 103, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1166:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 101, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 24, + "src": "1148:10:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1148:31:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 105, + "nodeType": "EmitStatement", + "src": "1143:36:0" + } + ] + }, + "documentation": null, + "id": 107, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 80, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "901:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 81, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "901:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 82, + "modifierName": { + "argumentTypes": null, + "id": 79, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "891:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "891:21:0" + } + ], + "name": "MakeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 78, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 77, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 107, + "src": "848:18:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 76, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "848:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "847:20:0" + }, + "returnParameters": { + "id": 83, + "nodeType": "ParameterList", + "parameters": [], + "src": "917:0:0" + }, + "scope": 320, + "src": "828:358:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 142, + "nodeType": "Block", + "src": "1293:332:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 122, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 119, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1311:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 120, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1335:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 121, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1335:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1311:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 123, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1366:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 118, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "1303:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 124, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1303:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 125, + "nodeType": "ExpressionStatement", + "src": "1303:110:0" + }, + { + "condition": { + "argumentTypes": null, + "id": 126, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 109, + "src": "1428:9:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 140, + "nodeType": "Block", + "src": "1543:76:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 138, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 134, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1557:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 137, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 135, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1572:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 136, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 111, + "src": "1587:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1572:22:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1557:37:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 139, + "nodeType": "ExpressionStatement", + "src": "1557:37:0" + } + ] + }, + "id": 141, + "nodeType": "IfStatement", + "src": "1424:195:0", + "trueBody": { + "id": 133, + "nodeType": "Block", + "src": "1447:74:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 131, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 127, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1461:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 130, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 128, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1476:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 129, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 111, + "src": "1491:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1476:22:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1461:37:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 132, + "nodeType": "ExpressionStatement", + "src": "1461:37:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 143, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 114, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1277:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 115, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1277:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 116, + "modifierName": { + "argumentTypes": null, + "id": 113, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "1267:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1267:21:0" + } + ], + "name": "ModifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 112, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 109, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 143, + "src": "1214:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 108, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1214:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 111, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 143, + "src": "1230:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 110, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1230:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1213:30:0" + }, + "returnParameters": { + "id": 117, + "nodeType": "ParameterList", + "parameters": [], + "src": "1293:0:0" + }, + "scope": 320, + "src": "1192:433:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 163, + "nodeType": "Block", + "src": "1703:185:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 154, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 151, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1721:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 152, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1745:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 153, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1745:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1721:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 155, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1776:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 150, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "1713:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 156, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1713:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 157, + "nodeType": "ExpressionStatement", + "src": "1713:110:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 161, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 158, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "1834:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 159, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "1857:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 160, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1857:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "1834:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 162, + "nodeType": "ExpressionStatement", + "src": "1834:47:0" + } + ] + }, + "documentation": null, + "id": 164, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 146, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1687:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 147, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1687:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 148, + "modifierName": { + "argumentTypes": null, + "id": 145, + "name": "isBuyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 54, + "src": "1678:7:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1678:20:0" + } + ], + "name": "RejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 144, + "nodeType": "ParameterList", + "parameters": [], + "src": "1652:2:0" + }, + "returnParameters": { + "id": 149, + "nodeType": "ParameterList", + "parameters": [], + "src": "1703:0:0" + }, + "scope": 320, + "src": "1631:257:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 200, + "nodeType": "Block", + "src": "1982:390:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 175, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 172, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2045:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 173, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2069:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 174, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2069:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2045:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 176, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2100:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 171, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "2037:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 177, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2037:110:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 178, + "nodeType": "ExpressionStatement", + "src": "2037:110:0" + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 182, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 179, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2162:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 180, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2162:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 181, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "2175:12:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2162:25:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 199, + "nodeType": "IfStatement", + "src": "2158:208:0", + "trueBody": { + "id": 198, + "nodeType": "Block", + "src": "2197:169:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 186, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 183, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "2211:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 184, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2225:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 185, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2225:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2211:23:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 187, + "nodeType": "ExpressionStatement", + "src": "2211:23:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 189, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "2266:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 190, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "2274:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 188, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 30, + "src": "2253:12:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 191, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2253:33:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 192, + "nodeType": "EmitStatement", + "src": "2248:38:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 196, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 193, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2300:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 194, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2323:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 195, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2323:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2300:55:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 197, + "nodeType": "ExpressionStatement", + "src": "2300:55:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 201, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 167, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1966:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 168, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1966:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 169, + "modifierName": { + "argumentTypes": null, + "id": 166, + "name": "isBuyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 54, + "src": "1957:7:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "1957:20:0" + } + ], + "name": "AcceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 165, + "nodeType": "ParameterList", + "parameters": [], + "src": "1915:2:0" + }, + "returnParameters": { + "id": 170, + "nodeType": "ParameterList", + "parameters": [], + "src": "1982:0:0" + }, + "scope": 320, + "src": "1894:478:0", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 286, + "nodeType": "Block", + "src": "2415:1032:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 218, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 213, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 208, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 205, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2433:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 206, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2457:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 207, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2457:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2433:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 212, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 209, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2493:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 210, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2517:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 211, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2517:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2493:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2433:113:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 217, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 214, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2566:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 215, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2590:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 216, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2590:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2566:54:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2433:187:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 219, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2622:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 204, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "2425:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 220, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2425:244:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 221, + "nodeType": "ExpressionStatement", + "src": "2425:244:0" + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 230, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 225, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 222, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2684:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 223, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2708:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 224, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2708:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2684:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 229, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 226, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2744:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 227, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2744:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 228, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "2758:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2744:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2684:79:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 245, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 240, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 237, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2869:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 238, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2893:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 239, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2893:32:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2869:56:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 244, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 241, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2929:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 242, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2929:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 243, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "2943:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2929:20:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2869:80:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 260, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 255, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 252, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3056:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 253, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3080:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 254, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3080:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3056:53:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 259, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 256, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3113:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 257, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3113:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 258, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "3127:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3113:20:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3056:77:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 275, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 270, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 267, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3282:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 268, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3306:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 269, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3306:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3282:54:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 274, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 271, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3340:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 272, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3340:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 273, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "3354:5:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3340:19:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3282:77:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 282, + "nodeType": "IfStatement", + "src": "3278:163:0", + "trueBody": { + "id": 281, + "nodeType": "Block", + "src": "3369:72:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 279, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 276, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3383:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 277, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3406:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 278, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3406:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3383:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 280, + "nodeType": "ExpressionStatement", + "src": "3383:47:0" + } + ] + } + }, + "id": 283, + "nodeType": "IfStatement", + "src": "3052:389:0", + "trueBody": { + "id": 266, + "nodeType": "Block", + "src": "3143:120:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 264, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 261, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3205:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 262, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3228:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 263, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3228:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3205:47:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 265, + "nodeType": "ExpressionStatement", + "src": "3205:47:0" + } + ] + } + }, + "id": 284, + "nodeType": "IfStatement", + "src": "2865:576:0", + "trueBody": { + "id": 251, + "nodeType": "Block", + "src": "2959:78:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 249, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 246, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2973:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 247, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2996:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 248, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2996:30:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2973:53:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 250, + "nodeType": "ExpressionStatement", + "src": "2973:53:0" + } + ] + } + }, + "id": 285, + "nodeType": "IfStatement", + "src": "2680:761:0", + "trueBody": { + "id": 236, + "nodeType": "Block", + "src": "2773:77:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 234, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 231, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "2787:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 232, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "2810:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 233, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2810:29:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "2787:52:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "id": 235, + "nodeType": "ExpressionStatement", + "src": "2787:52:0" + } + ] + } + } + ] + }, + "documentation": null, + "id": 287, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "Accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 202, + "nodeType": "ParameterList", + "parameters": [], + "src": "2393:2:0" + }, + "returnParameters": { + "id": 203, + "nodeType": "ParameterList", + "parameters": [], + "src": "2415:0:0" + }, + "scope": 320, + "src": "2378:1069:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 318, + "nodeType": "Block", + "src": "3522:229:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + }, + "id": 298, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 295, + "name": "ContractCurrentState", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "3540:20:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 296, + "name": "State", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "3564:5:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_State_$16_$", + "typeString": "type(enum MarketPlace.State)" + } + }, + "id": 297, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "MarketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3564:24:0", + "typeDescriptions": { + "typeIdentifier": "t_enum$_State_$16", + "typeString": "enum MarketPlace.State" + } + }, + "src": "3540:48:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 299, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3590:46:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 294, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 826, + 827 + ], + "referencedDeclaration": 827, + "src": "3532:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", + "typeString": "function (bool,string memory) pure" + } + }, + "id": 300, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3532:105:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 301, + "nodeType": "ExpressionStatement", + "src": "3532:105:0" + }, + { + "assignments": [ + 303, + null + ], + "declarations": [ + { + "constant": false, + "id": 303, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 318, + "src": "3649:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 302, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "3649:4:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 311, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 309, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3698:2:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "id": 307, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 9, + "src": "3685:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 304, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 3, + "src": "3667:6:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 305, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3667:11:0", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 306, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3667:17:0", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 308, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3667:30:0", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 310, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3667:34:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "3648:53:0" + }, + { + "condition": { + "argumentTypes": null, + "id": 313, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3714:8:0", + "subExpression": { + "argumentTypes": null, + "id": 312, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 303, + "src": "3715:7:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 317, + "nodeType": "IfStatement", + "src": "3711:33:0", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "id": 314, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 828, + "src": "3736:6:0", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$__$returns$__$", + "typeString": "function () pure" + } + }, + "id": 315, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3736:8:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 316, + "nodeType": "ExpressionStatement", + "src": "3736:8:0" + } + } + ] + }, + "documentation": null, + "id": 319, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 290, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3506:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 291, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3506:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "id": 292, + "modifierName": { + "argumentTypes": null, + "id": 289, + "name": "isSeller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 42, + "src": "3496:8:0", + "typeDescriptions": { + "typeIdentifier": "t_modifier$_t_address_$", + "typeString": "modifier (address)" + } + }, + "nodeType": "ModifierInvocation", + "src": "3496:21:0" + } + ], + "name": "Withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 288, + "nodeType": "ParameterList", + "parameters": [], + "src": "3470:2:0" + }, + "returnParameters": { + "id": 293, + "nodeType": "ParameterList", + "parameters": [], + "src": "3522:0:0" + }, + "scope": 320, + "src": "3453:298:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 321, + "src": "26:3727:0" + } + ], + "src": "0:3753:0" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "3.2.0", + "updatedAt": "2020-05-30T14:27:13.258Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace_Cel.json b/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace_Cel.json new file mode 100644 index 00000000..b330a1ab --- /dev/null +++ b/Celestial/Samples/AssetTransfer/build/contracts/MarketPlace_Cel.json @@ -0,0 +1,11931 @@ +{ + "contractName": "MarketPlace_Cel", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "_seller", + "type": "address" + }, + { + "internalType": "address", + "name": "_buyer", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eAcceptOffer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "eMakeOffer", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_sellingPrice", + "type": "uint256" + } + ], + "name": "makeOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "bool", + "name": "_increase", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "_change", + "type": "uint256" + } + ], + "name": "modifyOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "rejectOffer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "acceptOffer", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "accept", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "withdraw", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_seller\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_buyer\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eAcceptOffer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"eMakeOffer\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"accept\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"acceptOffer\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_sellingPrice\",\"type\":\"uint256\"}],\"name\":\"makeOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"bool\",\"name\":\"_increase\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"_change\",\"type\":\"uint256\"}],\"name\":\"modifyOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"rejectOffer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"withdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol\":\"MarketPlace_Cel\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol\":{\"keccak256\":\"0x7fa65ae50dca185ae1b44513e25481d7cc5cb06a5154dfac9959d6fbf2830eaa\",\"urls\":[\"bzz-raw://0e8cdfdca65455f80c6951577ac9fa1400ebb99a58da6bed9bee6a669f093af8\",\"dweb:/ipfs/QmUc5X5GQcgrwqjBLyqhBQMhgjUcBZYdChRayxDfmXE7Ur\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50604051610cfb380380610cfb8339818101604052604081101561003357600080fd5b810190808051906020019092919080519060200190929190505050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600460006101000a81548160ff021916908360058111156100ee57fe5b02179055505050610bf7806101046000396000f3fe6080604052600436106100555760003560e01c80632852b71c1461005a5780633ccfd60b146100715780639a2f647414610088578063c0873729146100c3578063eb62df611461010a578063efd998ad14610114575b600080fd5b34801561006657600080fd5b5061006f61012b565b005b34801561007d57600080fd5b506100866104c7565b005b34801561009457600080fd5b506100c1600480360360208110156100ab57600080fd5b8101908080359060200190929190505050610686565b005b3480156100cf57600080fd5b50610108600480360360408110156100e657600080fd5b81019080803515159060200190929190803590602001909291905050506107c1565b005b6101126108d9565b005b34801561012057600080fd5b50610129610a77565b005b6002600581111561013857fe5b600460009054906101000a900460ff16600581111561015357fe5b148061018457506003600581111561016757fe5b600460009054906101000a900460ff16600581111561018257fe5b145b806101b457506004600581111561019757fe5b600460009054906101000a900460ff1660058111156101b257fe5b145b610209576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6002600581111561021657fe5b600460009054906101000a900460ff16600581111561023157fe5b14801561028b5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156102b9576003600460006101000a81548160ff021916908360058111156102af57fe5b02179055506104c5565b600260058111156102c657fe5b600460009054906101000a900460ff1660058111156102e157fe5b14801561033a57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156103675760048060006101000a81548160ff0219169083600581111561035d57fe5b02179055506104c4565b6003600581111561037457fe5b600460009054906101000a900460ff16600581111561038f57fe5b1480156103e857506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610416576005600460006101000a81548160ff0219169083600581111561040c57fe5b02179055506104c3565b6004600581111561042357fe5b600460009054906101000a900460ff16600581111561043e57fe5b1480156104985750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156104c2576005600460006101000a81548160ff021916908360058111156104bc57fe5b02179055505b5b5b5b565b6005808111156104d357fe5b600460009054906101000a900460ff1660058111156104ee57fe5b14801561054757506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61059c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166003546108fc90604051806000019050600060405180830381858888f193505050503d8060008114610624576040519150601f19603f3d011682016040523d82523d6000602084013e610629565b606091505b5050905080610683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610ba16022913960400191505060405180910390fd5b50565b6000600581111561069357fe5b600460009054906101000a900460ff1660058111156106ae57fe5b14610704576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b806002819055506001600460006101000a81548160ff0219169083600581111561072a57fe5b02179055507fac2a732696baf520f05929eb1f8ee293cc8166f98af0cfd49f9c5fc019f3132c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600254604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150565b600160058111156107ce57fe5b600460009054906101000a900460ff1660058111156107e957fe5b14801561084257506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610897576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b8180156108aa5750806000190360025411155b156108bf5780600254016002819055506108d5565b80600254106108d45780600254036002819055505b5b5050565b600160058111156108e657fe5b600460009054906101000a900460ff16600581111561090157fe5b14158061095c5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b156109b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6002543410610a7557346003819055507fa9a2c228cc57d1d709c8bd829952b1187721791bde967500f8e72bc5fcec89346000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600354604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16002600460006101000a81548160ff02191690836005811115610a6f57fe5b02179055505b565b60016005811115610a8457fe5b600460009054906101000a900460ff166005811115610a9f57fe5b148015610af95750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610b4e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6000600460006101000a81548160ff02191690836005811115610b6d57fe5b021790555056fe3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c69642073746174653c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564a265627a7a7231582003ea0b308eec3ba5f40f84be29047ffbaebee527f6ba314bc03df801552424cb64736f6c63430005100032", + "deployedBytecode": "0x6080604052600436106100555760003560e01c80632852b71c1461005a5780633ccfd60b146100715780639a2f647414610088578063c0873729146100c3578063eb62df611461010a578063efd998ad14610114575b600080fd5b34801561006657600080fd5b5061006f61012b565b005b34801561007d57600080fd5b506100866104c7565b005b34801561009457600080fd5b506100c1600480360360208110156100ab57600080fd5b8101908080359060200190929190505050610686565b005b3480156100cf57600080fd5b50610108600480360360408110156100e657600080fd5b81019080803515159060200190929190803590602001909291905050506107c1565b005b6101126108d9565b005b34801561012057600080fd5b50610129610a77565b005b6002600581111561013857fe5b600460009054906101000a900460ff16600581111561015357fe5b148061018457506003600581111561016757fe5b600460009054906101000a900460ff16600581111561018257fe5b145b806101b457506004600581111561019757fe5b600460009054906101000a900460ff1660058111156101b257fe5b145b610209576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6002600581111561021657fe5b600460009054906101000a900460ff16600581111561023157fe5b14801561028b5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156102b9576003600460006101000a81548160ff021916908360058111156102af57fe5b02179055506104c5565b600260058111156102c657fe5b600460009054906101000a900460ff1660058111156102e157fe5b14801561033a57506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156103675760048060006101000a81548160ff0219169083600581111561035d57fe5b02179055506104c4565b6003600581111561037457fe5b600460009054906101000a900460ff16600581111561038f57fe5b1480156103e857506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b15610416576005600460006101000a81548160ff0219169083600581111561040c57fe5b02179055506104c3565b6004600581111561042357fe5b600460009054906101000a900460ff16600581111561043e57fe5b1480156104985750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b156104c2576005600460006101000a81548160ff021916908360058111156104bc57fe5b02179055505b5b5b5b565b6005808111156104d357fe5b600460009054906101000a900460ff1660058111156104ee57fe5b14801561054757506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b61059c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166003546108fc90604051806000019050600060405180830381858888f193505050503d8060008114610624576040519150601f19603f3d011682016040523d82523d6000602084013e610629565b606091505b5050905080610683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180610ba16022913960400191505060405180910390fd5b50565b6000600581111561069357fe5b600460009054906101000a900460ff1660058111156106ae57fe5b14610704576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b806002819055506001600460006101000a81548160ff0219169083600581111561072a57fe5b02179055507fac2a732696baf520f05929eb1f8ee293cc8166f98af0cfd49f9c5fc019f3132c600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600254604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a150565b600160058111156107ce57fe5b600460009054906101000a900460ff1660058111156107e957fe5b14801561084257506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610897576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b8180156108aa5750806000190360025411155b156108bf5780600254016002819055506108d5565b80600254106108d45780600254036002819055505b5b5050565b600160058111156108e657fe5b600460009054906101000a900460ff16600581111561090157fe5b14158061095c5750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614155b156109b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6002543410610a7557346003819055507fa9a2c228cc57d1d709c8bd829952b1187721791bde967500f8e72bc5fcec89346000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600354604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a16002600460006101000a81548160ff02191690836005811115610a6f57fe5b02179055505b565b60016005811115610a8457fe5b600460009054906101000a900460ff166005811115610a9f57fe5b148015610af95750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610b4e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180610b75602c913960400191505060405180910390fd5b6000600460006101000a81548160ff02191690836005811115610b6d57fe5b021790555056fe3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c69642073746174653c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564a265627a7a7231582003ea0b308eec3ba5f40f84be29047ffbaebee527f6ba314bc03df801552424cb64736f6c63430005100032", + "sourceMap": "701:3735:2:-;;;1091:185;8:9:-1;5:2;;;30:1;27;20:12;5:2;1091:185:2;;;;;;;;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1091:185:2;;;;;;;;;;;;;;;;;;;;;;;;;1165:7;1156:6;;:16;;;;;;;;;;;;;;;;;;1191:6;1183:5;;:14;;;;;;;;;;;;;;;;;;1231:24;1208:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;1091:185;;701:3735;;;;;;", + "deployedSourceMap": "701:3735:2:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2984:1052;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2984:1052:2;;;:::i;:::-;;4044:389;;8:9:-1;5:2;;;30:1;27;20:12;5:2;4044:389:2;;;:::i;:::-;;1284:372;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1284:372:2;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1284:372:2;;;;;;;;;;;;;;;;;:::i;:::-;;1664:542;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1664:542:2;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1664:542:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;2519:457;;;:::i;:::-;;2214:297;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2214:297:2;;;:::i;:::-;;2984:1052;3057:32;3033:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:113;;;;3117:29;3093:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;3033:113;:171;;;;3174:30;3150:54;;;;;;;;:20;;;;;;;;;;;:54;;;;;;;;;3033:171;3026:263;;3222:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3026:263;3327:32;3303:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:79;;;;;3377:5;;;;;;;;;;;3363:19;;:10;:19;;;3303:79;3299:713;;;3422:29;3399:20;;:52;;;;;;;;;;;;;;;;;;;;;;;;3299:713;;;3514:32;3490:56;;;;;;;;:20;;;;;;;;;;;:56;;;;;;;;;:80;;;;;3564:6;;;;;;;;;;;3550:20;;:10;:20;;;3490:80;3486:526;;;3610:30;3587:20;;:53;;;;;;;;;;;;;;;;;;;;;;;;3486:526;;;3703:29;3679:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;:77;;;;;3750:6;;;;;;;;;;;3736:20;;:10;:20;;;3679:77;3675:337;;;3796:24;3773:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;3675:337;;;3883:30;3859:54;;;;;;;;:20;;;;;;;;;;;:54;;;;;;;;;:77;;;;;3931:5;;;;;;;;;;;3917:19;;:10;:19;;;3859:77;3855:157;;;3976:24;3953:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;3855:157;3675:337;3486:526;3299:713;2984:1052::o;4044:389::-;4119:24;4095:48;;;;;;;;:20;;;;;;;;;;;:48;;;;;;;;;:72;;;;;4161:6;;;;;;;;;;;4147:20;;:10;:20;;;4095:72;4088:164;;4185:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4088:164;4263:12;4281:6;;;;;;;;;;;:11;;4299;;4316:4;4281:40;:44;;;;;;;;;;;;;;;;;;;;;;;;14:1:-1;21;16:31;;;;75:4;69:11;64:16;;144:4;140:9;133:4;115:16;111:27;107:43;104:1;100:51;94:4;87:65;169:16;166:1;159:27;225:16;222:1;215:4;212:1;208:12;193:49;7:242;;16:31;36:4;31:9;;7:242;;4262:63:2;;;4341:7;4336:72;;4363:45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4336:72;4419:7;4044:389::o;1284:372::-;1375:24;1351:48;;;;;;;;:20;;;;;;;;;;;:48;;;;;;;;;1347:136;;1416:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1347:136;1508:13;1493:12;:28;;;;1555:29;1532:20;;:52;;;;;;;;;;;;;;;;;;;;;;;;1600:31;1611:5;;;;;;;;;;;1618:12;;1600:31;;;;;;;;;;;;;;;;;;;;;;;;;;;;1284:372;:::o;1664:542::-;1770:29;1746:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;:77;;;;;1817:6;;;;;;;;;;;1803:20;;:10;:20;;;1746:77;1739:169;;1841:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1739:169;1922:9;:52;;;;;1967:7;1961:1;1952:11;1951:23;1935:12;;:39;;1922:52;1918:264;;;2021:7;2006:12;;:22;1991:12;:37;;;;1918:264;;;2090:7;2074:12;;:23;2070:101;;2148:7;2133:12;;:22;2118:12;:37;;;;2070:101;1918:264;1664:542;;:::o;2519:457::-;2602:29;2578:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;;:76;;;;2649:5;;;;;;;;;;;2635:19;;:10;:19;;;;2578:76;2574:164;;;2671:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2574:164;2765:12;;2752:9;:25;2748:204;;2808:9;2794:11;:23;;;;2837:33;2850:6;;;;;;;;;;;2858:11;;2837:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;2908:32;2885:20;;:55;;;;;;;;;;;;;;;;;;;;;;;;2748:204;2519:457::o;2214:297::-;2292:29;2268:53;;;;;;;;:20;;;;;;;;;;;:53;;;;;;;;;:76;;;;;2339:5;;;;;;;;;;;2325:19;;:10;:19;;;2268:76;2261:168;;2362:55;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2261:168;2462:24;2439:20;;:47;;;;;;;;;;;;;;;;;;;;;;;;2214:297::o", + "source": "/* Code generated by compiler */\r\n\r\npragma solidity >=0.5.0 <0.7.0;\r\n\r\nlibrary Safe_Arith {\r\n\r\nfunction safe_add (uint a, uint b) public pure returns (uint) {\r\n if (a < a + b) revert (\"Overflow Error\");\r\n else return (a + b);\r\n}\r\n\r\nfunction safe_sub (uint a, uint b) public pure returns (uint) {\r\n if (a - b > 0) revert (\"Underflow Error\");\r\n else return (a - b);\r\n}\r\n\r\nfunction safe_mul (uint a, uint b) public pure returns (uint) {\r\n if (b == 0) return 0;\r\n if (a != (a * b)/b) revert (\"Overflow Error\");\r\n else return (a * b);\r\n}\r\n\r\nfunction safe_div (uint a, uint b) public pure returns (uint) {\r\n if (b == 0) revert (\"Division by 0 error\");\r\n else return (a / b);\r\n}\r\n}contract MarketPlace_Cel\r\n{\r\n\r\nenum state\r\n{ marketPlace_Active, marketPlace_OfferPlaced, marketPlace_NotionalAccept, marketPlace_BuyerAccept, marketPlace_SellerAccept, marketPlace_Accept}\r\nevent eMakeOffer(address, uint);\r\nevent eAcceptOffer(address, uint);\r\n\r\n address seller;\r\n address buyer;\r\n uint sellingPrice;\r\n uint buyingPrice;\r\n state ContractCurrentstate;\r\nconstructor (address _seller, address _buyer)\r\npublic {\r\n seller = _seller;\r\n buyer = _buyer;\r\n ContractCurrentstate = state.marketPlace_Active;\r\n return;\r\n}\r\n\r\n function makeOffer (uint _sellingPrice)\r\n public {\r\n if (ContractCurrentstate != state.marketPlace_Active) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n sellingPrice = _sellingPrice;\r\n ContractCurrentstate = state.marketPlace_OfferPlaced;\r\n emit eMakeOffer(buyer, sellingPrice);\r\n return;\r\n }\r\n\r\n function modifyOffer (bool _increase, uint _change)\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_OfferPlaced && msg.sender == seller)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (_increase && sellingPrice <= (~uint256(0)) - _change) {\r\n sellingPrice = sellingPrice + _change;\r\n }\r\n else {\r\n if (sellingPrice >= _change) {\r\n sellingPrice = sellingPrice - _change;\r\n }\r\n }\r\n return;\r\n }\r\n\r\n function rejectOffer ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_OfferPlaced && msg.sender == buyer)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n ContractCurrentstate = state.marketPlace_Active;\r\n return;\r\n }\r\n\r\n function acceptOffer ()\r\n public payable {\r\n if (ContractCurrentstate != state.marketPlace_OfferPlaced || msg.sender != buyer) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (msg.value >= sellingPrice) {\r\n buyingPrice = msg.value;\r\n emit eAcceptOffer(seller, buyingPrice);\r\n ContractCurrentstate = state.marketPlace_NotionalAccept;\r\n }\r\n return;\r\n }\r\n\r\n function accept ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_NotionalAccept || ContractCurrentstate == state.marketPlace_BuyerAccept || ContractCurrentstate == state.marketPlace_SellerAccept)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (ContractCurrentstate == state.marketPlace_NotionalAccept && msg.sender == buyer) {\r\n ContractCurrentstate = state.marketPlace_BuyerAccept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_NotionalAccept && msg.sender == seller) {\r\n ContractCurrentstate = state.marketPlace_SellerAccept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_BuyerAccept && msg.sender == seller) {\r\n ContractCurrentstate = state.marketPlace_Accept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_SellerAccept && msg.sender == buyer) {\r\n ContractCurrentstate = state.marketPlace_Accept;\r\n }\r\n return;\r\n }\r\n\r\n function withdraw ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_Accept && msg.sender == seller)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n (bool success, ) = seller.call.value(buyingPrice).gas(2300)(\"\");\r\n if (!success)\r\n revert (\" Sending of ether failed\");\r\n return;\r\n }\r\n}\r\n", + "sourcePath": "C:\\Users\\t-sumukh\\source\\repos\\smart-contracts\\gitrepo\\celestial\\Experiments\\AssetTransfer\\contracts\\contract.sol", + "ast": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol", + "exportedSymbols": { + "MarketPlace_Cel": [ + 808 + ], + "Safe_Arith": [ + 467 + ] + }, + "id": 809, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 359, + "literals": [ + "solidity", + ">=", + "0.5", + ".0", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "36:31:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "library", + "documentation": null, + "fullyImplemented": true, + "id": 467, + "linearizedBaseContracts": [ + 467 + ], + "name": "Safe_Arith", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 383, + "nodeType": "Block", + "src": "157:77:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 372, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 368, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "168:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 371, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 369, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "172:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 370, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "176:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "172:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "168:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 379, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 377, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "224:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 378, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "228:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "224:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 380, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "223:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 367, + "id": 381, + "nodeType": "Return", + "src": "216:14:2" + }, + "id": 382, + "nodeType": "IfStatement", + "src": "164:66:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 374, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "187:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 373, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "179:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 375, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "179:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 376, + "nodeType": "ExpressionStatement", + "src": "179:25:2" + } + } + ] + }, + "documentation": null, + "id": 384, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_add", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 364, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 361, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "114:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 360, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "114:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 363, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "122:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 362, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "122:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "113:16:2" + }, + "returnParameters": { + "id": 367, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 366, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "151:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 365, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "151:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:6:2" + }, + "scope": 467, + "src": "95:139:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 408, + "nodeType": "Block", + "src": "300:78:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 397, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 395, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 393, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "311:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 394, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "315:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "311:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 396, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "319:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "311:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 404, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 402, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "368:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 403, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "372:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "368:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 405, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "367:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 392, + "id": 406, + "nodeType": "Return", + "src": "360:14:2" + }, + "id": 407, + "nodeType": "IfStatement", + "src": "307:67:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "556e646572666c6f77204572726f72", + "id": 399, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "330:17:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + }, + "value": "Underflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + } + ], + "id": 398, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "322:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 400, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "322:26:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 401, + "nodeType": "ExpressionStatement", + "src": "322:26:2" + } + } + ] + }, + "documentation": null, + "id": 409, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_sub", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 389, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 386, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "257:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 385, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "257:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 388, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "265:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 387, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "265:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "256:16:2" + }, + "returnParameters": { + "id": 392, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 391, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "294:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 390, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "294:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "293:6:2" + }, + "scope": 467, + "src": "238:140:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 442, + "nodeType": "Block", + "src": "444:109:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 420, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 418, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "455:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 419, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "460:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "455:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 423, + "nodeType": "IfStatement", + "src": "451:20:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "hexValue": "30", + "id": 421, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "470:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "functionReturnParameters": 417, + "id": 422, + "nodeType": "Return", + "src": "463:8:2" + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 431, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 424, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "482:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 430, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 427, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 425, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "488:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 426, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "492:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "488:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 428, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "487:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 429, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "495:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "487:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "482:14:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 438, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 436, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "543:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 437, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "547:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "543:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 439, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "542:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 417, + "id": 440, + "nodeType": "Return", + "src": "535:14:2" + }, + "id": 441, + "nodeType": "IfStatement", + "src": "478:71:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 433, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "506:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 432, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "498:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 434, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "498:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 435, + "nodeType": "ExpressionStatement", + "src": "498:25:2" + } + } + ] + }, + "documentation": null, + "id": 443, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_mul", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 414, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 411, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "401:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 410, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "401:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 413, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "409:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 412, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "409:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "400:16:2" + }, + "returnParameters": { + "id": 417, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 416, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "438:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 415, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "438:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "437:6:2" + }, + "scope": 467, + "src": "382:171:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 465, + "nodeType": "Block", + "src": "619:79:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 454, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 452, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "630:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 453, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "635:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "630:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 461, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 459, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 445, + "src": "688:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 460, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "692:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "688:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 462, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "687:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 451, + "id": 463, + "nodeType": "Return", + "src": "680:14:2" + }, + "id": 464, + "nodeType": "IfStatement", + "src": "626:68:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4469766973696f6e2062792030206572726f72", + "id": 456, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "646:21:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + }, + "value": "Division by 0 error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + } + ], + "id": 455, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "638:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 457, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "638:30:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 458, + "nodeType": "ExpressionStatement", + "src": "638:30:2" + } + } + ] + }, + "documentation": null, + "id": 466, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_div", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 448, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 445, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "576:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 444, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "576:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 447, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "584:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 446, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "584:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "575:16:2" + }, + "returnParameters": { + "id": 451, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 450, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "613:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 449, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "613:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "612:6:2" + }, + "scope": 467, + "src": "557:141:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "71:630:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 808, + "linearizedBaseContracts": [ + 808 + ], + "name": "MarketPlace_Cel", + "nodeType": "ContractDefinition", + "nodes": [ + { + "canonicalName": "MarketPlace_Cel.state", + "id": 474, + "members": [ + { + "id": 468, + "name": "marketPlace_Active", + "nodeType": "EnumValue", + "src": "753:18:2" + }, + { + "id": 469, + "name": "marketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "773:23:2" + }, + { + "id": 470, + "name": "marketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "798:26:2" + }, + { + "id": 471, + "name": "marketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "826:23:2" + }, + { + "id": 472, + "name": "marketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "851:24:2" + }, + { + "id": 473, + "name": "marketPlace_Accept", + "nodeType": "EnumValue", + "src": "877:18:2" + } + ], + "name": "state", + "nodeType": "EnumDefinition", + "src": "732:164:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 480, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 479, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 476, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "915:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 475, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "915:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 478, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "924:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 477, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "924:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "914:15:2" + }, + "src": "898:32:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 486, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 485, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 482, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "951:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 481, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "951:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 484, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "960:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 483, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "960:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "950:15:2" + }, + "src": "932:34:2" + }, + { + "constant": false, + "id": 488, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "974:14:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 487, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "974:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 490, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "995:13:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 489, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "995:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 492, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1015:17:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 491, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1015:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 494, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1039:16:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 493, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1039:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 496, + "name": "ContractCurrentstate", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1062:26:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "typeName": { + "contractScope": null, + "id": 495, + "name": "state", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 474, + "src": "1062:5:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 517, + "nodeType": "Block", + "src": "1145:131:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 505, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 503, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1156:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 504, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 498, + "src": "1165:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1156:16:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 506, + "nodeType": "ExpressionStatement", + "src": "1156:16:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 509, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 507, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1183:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 508, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 500, + "src": "1191:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1183:14:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 510, + "nodeType": "ExpressionStatement", + "src": "1183:14:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 514, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 511, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1208:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 512, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1231:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 513, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1231:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1208:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 515, + "nodeType": "ExpressionStatement", + "src": "1208:47:2" + }, + { + "expression": null, + "functionReturnParameters": 502, + "id": 516, + "nodeType": "Return", + "src": "1266:7:2" + } + ] + }, + "documentation": null, + "id": 518, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 501, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 498, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1104:15:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 497, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1104:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 500, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1121:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 499, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1121:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1103:33:2" + }, + "returnParameters": { + "id": 502, + "nodeType": "ParameterList", + "parameters": [], + "src": "1145:0:2" + }, + "scope": 808, + "src": "1091:185:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 548, + "nodeType": "Block", + "src": "1336:320:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 526, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 523, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1351:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 524, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1375:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 525, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1375:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1351:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 532, + "nodeType": "IfStatement", + "src": "1347:136:2", + "trueBody": { + "id": 531, + "nodeType": "Block", + "src": "1401:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 528, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1424:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 527, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1416:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 529, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1416:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 530, + "nodeType": "ExpressionStatement", + "src": "1416:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 535, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 533, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1493:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 534, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 520, + "src": "1508:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1493:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 536, + "nodeType": "ExpressionStatement", + "src": "1493:28:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 540, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 537, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1532:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 538, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1555:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 539, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1555:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1532:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 541, + "nodeType": "ExpressionStatement", + "src": "1532:52:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 543, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1611:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 544, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1618:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 542, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 480, + "src": "1600:10:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 545, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1600:31:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 546, + "nodeType": "EmitStatement", + "src": "1595:36:2" + }, + { + "expression": null, + "functionReturnParameters": 522, + "id": 547, + "nodeType": "Return", + "src": "1642:7:2" + } + ] + }, + "documentation": null, + "id": 549, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "makeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 521, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 520, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 549, + "src": "1304:18:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 519, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1304:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1303:20:2" + }, + "returnParameters": { + "id": 522, + "nodeType": "ParameterList", + "parameters": [], + "src": "1336:0:2" + }, + "scope": 808, + "src": "1284:372:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 605, + "nodeType": "Block", + "src": "1728:478:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 566, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "1743:81:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 564, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 559, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 556, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1746:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 557, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1770:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 558, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1770:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1746:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 563, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 560, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1803:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 561, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1803:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 562, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1817:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1803:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1746:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 565, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1745:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 572, + "nodeType": "IfStatement", + "src": "1739:169:2", + "trueBody": { + "id": 571, + "nodeType": "Block", + "src": "1826:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 568, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1849:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 567, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1841:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 569, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1841:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 570, + "nodeType": "ExpressionStatement", + "src": "1841:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 583, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 573, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 551, + "src": "1922:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 582, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 574, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1935:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 581, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "id": 578, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "~", + "prefix": true, + "src": "1952:11:2", + "subExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "30", + "id": 576, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1961:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "id": 575, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1953:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_uint256_$", + "typeString": "type(uint256)" + }, + "typeName": "uint256" + }, + "id": 577, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1953:10:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 579, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1951:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 580, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "1967:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1951:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1935:39:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1922:52:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 602, + "nodeType": "Block", + "src": "2055:127:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 593, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 591, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2074:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 592, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2090:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2074:23:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 601, + "nodeType": "IfStatement", + "src": "2070:101:2", + "trueBody": { + "id": 600, + "nodeType": "Block", + "src": "2099:72:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 598, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 594, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2118:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 597, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 595, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2133:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 596, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2148:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2133:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2118:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 599, + "nodeType": "ExpressionStatement", + "src": "2118:37:2" + } + ] + } + } + ] + }, + "id": 603, + "nodeType": "IfStatement", + "src": "1918:264:2", + "trueBody": { + "id": 590, + "nodeType": "Block", + "src": "1976:64:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 588, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 584, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1991:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 587, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 585, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2006:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 586, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2021:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2006:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1991:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 589, + "nodeType": "ExpressionStatement", + "src": "1991:37:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 555, + "id": 604, + "nodeType": "Return", + "src": "2192:7:2" + } + ] + }, + "documentation": null, + "id": 606, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "modifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 554, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 551, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1686:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 550, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1686:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 553, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1702:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 552, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1702:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1685:30:2" + }, + "returnParameters": { + "id": 555, + "nodeType": "ParameterList", + "parameters": [], + "src": "1728:0:2" + }, + "scope": 808, + "src": "1664:542:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 632, + "nodeType": "Block", + "src": "2250:261:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 619, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "2265:80:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 617, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 612, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 609, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2268:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 610, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2292:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 611, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2292:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2268:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 616, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 613, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2325:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 614, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2325:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 615, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2339:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2325:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2268:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 618, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "2267:78:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 625, + "nodeType": "IfStatement", + "src": "2261:168:2", + "trueBody": { + "id": 624, + "nodeType": "Block", + "src": "2347:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 621, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2370:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 620, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2362:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 622, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2362:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 623, + "nodeType": "ExpressionStatement", + "src": "2362:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 629, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 626, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2439:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 627, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2462:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 628, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2462:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2439:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 630, + "nodeType": "ExpressionStatement", + "src": "2439:47:2" + }, + { + "expression": null, + "functionReturnParameters": 608, + "id": 631, + "nodeType": "Return", + "src": "2497:7:2" + } + ] + }, + "documentation": null, + "id": 633, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "rejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 607, + "nodeType": "ParameterList", + "parameters": [], + "src": "2235:2:2" + }, + "returnParameters": { + "id": 608, + "nodeType": "ParameterList", + "parameters": [], + "src": "2250:0:2" + }, + "scope": 808, + "src": "2214:297:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 673, + "nodeType": "Block", + "src": "2563:413:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 644, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 639, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 636, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2578:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 637, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2602:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 638, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2602:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2578:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 643, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 640, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2635:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 641, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2635:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "id": 642, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2649:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2635:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2578:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 650, + "nodeType": "IfStatement", + "src": "2574:164:2", + "trueBody": { + "id": 649, + "nodeType": "Block", + "src": "2656:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 646, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2679:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 645, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2671:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 647, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2671:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 648, + "nodeType": "ExpressionStatement", + "src": "2671:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 654, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 651, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2752:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 652, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2752:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 653, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2765:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2752:25:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 671, + "nodeType": "IfStatement", + "src": "2748:204:2", + "trueBody": { + "id": 670, + "nodeType": "Block", + "src": "2779:173:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 658, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 655, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2794:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 656, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2808:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 657, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2808:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2794:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 659, + "nodeType": "ExpressionStatement", + "src": "2794:23:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 661, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "2850:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 662, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2858:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 660, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 486, + "src": "2837:12:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 663, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2837:33:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 664, + "nodeType": "EmitStatement", + "src": "2832:38:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 668, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 665, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2885:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 666, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2908:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 667, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2908:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2885:55:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 669, + "nodeType": "ExpressionStatement", + "src": "2885:55:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 635, + "id": 672, + "nodeType": "Return", + "src": "2962:7:2" + } + ] + }, + "documentation": null, + "id": 674, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "acceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 634, + "nodeType": "ParameterList", + "parameters": [], + "src": "2540:2:2" + }, + "returnParameters": { + "id": 635, + "nodeType": "ParameterList", + "parameters": [], + "src": "2563:0:2" + }, + "scope": 808, + "src": "2519:457:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 764, + "nodeType": "Block", + "src": "3015:1021:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 692, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3030:175:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 690, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 685, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 680, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 677, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3033:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 678, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3057:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 679, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3057:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3033:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 684, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 681, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3093:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 682, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3117:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 683, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3117:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3093:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:113:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 689, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 686, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3150:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 687, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3174:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 688, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3174:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3150:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:171:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 691, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "3032:173:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 698, + "nodeType": "IfStatement", + "src": "3026:263:2", + "trueBody": { + "id": 697, + "nodeType": "Block", + "src": "3207:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 694, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3230:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 693, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "3222:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 695, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3222:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 696, + "nodeType": "ExpressionStatement", + "src": "3222:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 707, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 702, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 699, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3303:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 700, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3327:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 701, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3327:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3303:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 706, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 703, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3363:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 704, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3363:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 705, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3377:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3363:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3303:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 722, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 717, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 714, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3490:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 715, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3514:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 716, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3514:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3490:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 721, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 718, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3550:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 719, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3550:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 720, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3564:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3550:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3490:80:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 737, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 732, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 729, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3679:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 730, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3703:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 731, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3703:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3679:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 736, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 733, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3736:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 734, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3736:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 735, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3750:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3736:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3679:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 752, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 747, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 744, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3859:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 745, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3883:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 746, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3883:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3859:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 751, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 748, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3917:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 749, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3917:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 750, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3931:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3917:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3859:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 759, + "nodeType": "IfStatement", + "src": "3855:157:2", + "trueBody": { + "id": 758, + "nodeType": "Block", + "src": "3938:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 756, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 753, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3953:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 754, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3976:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 755, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3976:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3953:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 757, + "nodeType": "ExpressionStatement", + "src": "3953:47:2" + } + ] + } + }, + "id": 760, + "nodeType": "IfStatement", + "src": "3675:337:2", + "trueBody": { + "id": 743, + "nodeType": "Block", + "src": "3758:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 741, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 738, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3773:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 739, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3796:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 740, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3796:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3773:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 742, + "nodeType": "ExpressionStatement", + "src": "3773:47:2" + } + ] + } + }, + "id": 761, + "nodeType": "IfStatement", + "src": "3486:526:2", + "trueBody": { + "id": 728, + "nodeType": "Block", + "src": "3572:80:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 726, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 723, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3587:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 724, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3610:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 725, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3610:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3587:53:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 727, + "nodeType": "ExpressionStatement", + "src": "3587:53:2" + } + ] + } + }, + "id": 762, + "nodeType": "IfStatement", + "src": "3299:713:2", + "trueBody": { + "id": 713, + "nodeType": "Block", + "src": "3384:79:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 711, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 708, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3399:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 709, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3422:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 710, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3422:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3399:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 712, + "nodeType": "ExpressionStatement", + "src": "3399:52:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 676, + "id": 763, + "nodeType": "Return", + "src": "4022:7:2" + } + ] + }, + "documentation": null, + "id": 765, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 675, + "nodeType": "ParameterList", + "parameters": [], + "src": "3000:2:2" + }, + "returnParameters": { + "id": 676, + "nodeType": "ParameterList", + "parameters": [], + "src": "3015:0:2" + }, + "scope": 808, + "src": "2984:1052:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 806, + "nodeType": "Block", + "src": "4077:356:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 778, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4092:76:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 776, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 771, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 768, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "4095:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 769, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "4119:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 770, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4119:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "4095:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 775, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 772, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "4147:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 773, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4147:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 774, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4161:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "4147:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "4095:72:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 777, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "4094:74:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 784, + "nodeType": "IfStatement", + "src": "4088:164:2", + "trueBody": { + "id": 783, + "nodeType": "Block", + "src": "4170:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 780, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4193:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 779, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4185:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 781, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4185:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 782, + "nodeType": "ExpressionStatement", + "src": "4185:55:2" + } + ] + } + }, + { + "assignments": [ + 786, + null + ], + "declarations": [ + { + "constant": false, + "id": 786, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 806, + "src": "4263:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 785, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "4263:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 797, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 795, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4322:2:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "hexValue": "32333030", + "id": 793, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4316:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + }, + "value": "2300" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + } + ], + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 790, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "4299:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 787, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4281:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 788, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:11:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 789, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:17:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 791, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:30:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 792, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "gas", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:34:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setgas_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue_$value", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 794, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:40:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 796, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:44:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "4262:63:2" + }, + { + "condition": { + "argumentTypes": null, + "id": 799, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4340:8:2", + "subExpression": { + "argumentTypes": null, + "id": 798, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 786, + "src": "4341:7:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 804, + "nodeType": "IfStatement", + "src": "4336:72:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564", + "id": 801, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4371:36:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + }, + "value": " Sending of ether failed" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + } + ], + "id": 800, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4363:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 802, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4363:45:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 803, + "nodeType": "ExpressionStatement", + "src": "4363:45:2" + } + }, + { + "expression": null, + "functionReturnParameters": 767, + "id": 805, + "nodeType": "Return", + "src": "4419:7:2" + } + ] + }, + "documentation": null, + "id": 807, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 766, + "nodeType": "ParameterList", + "parameters": [], + "src": "4062:2:2" + }, + "returnParameters": { + "id": 767, + "nodeType": "ParameterList", + "parameters": [], + "src": "4077:0:2" + }, + "scope": 808, + "src": "4044:389:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "701:3735:2" + } + ], + "src": "36:4402:2" + }, + "legacyAST": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol", + "exportedSymbols": { + "MarketPlace_Cel": [ + 808 + ], + "Safe_Arith": [ + 467 + ] + }, + "id": 809, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 359, + "literals": [ + "solidity", + ">=", + "0.5", + ".0", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "36:31:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "library", + "documentation": null, + "fullyImplemented": true, + "id": 467, + "linearizedBaseContracts": [ + 467 + ], + "name": "Safe_Arith", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 383, + "nodeType": "Block", + "src": "157:77:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 372, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 368, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "168:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 371, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 369, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "172:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 370, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "176:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "172:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "168:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 379, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 377, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "224:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 378, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "228:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "224:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 380, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "223:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 367, + "id": 381, + "nodeType": "Return", + "src": "216:14:2" + }, + "id": 382, + "nodeType": "IfStatement", + "src": "164:66:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 374, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "187:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 373, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "179:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 375, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "179:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 376, + "nodeType": "ExpressionStatement", + "src": "179:25:2" + } + } + ] + }, + "documentation": null, + "id": 384, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_add", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 364, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 361, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "114:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 360, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "114:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 363, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "122:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 362, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "122:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "113:16:2" + }, + "returnParameters": { + "id": 367, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 366, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "151:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 365, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "151:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:6:2" + }, + "scope": 467, + "src": "95:139:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 408, + "nodeType": "Block", + "src": "300:78:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 397, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 395, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 393, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "311:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 394, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "315:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "311:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 396, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "319:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "311:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 404, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 402, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "368:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 403, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "372:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "368:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 405, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "367:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 392, + "id": 406, + "nodeType": "Return", + "src": "360:14:2" + }, + "id": 407, + "nodeType": "IfStatement", + "src": "307:67:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "556e646572666c6f77204572726f72", + "id": 399, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "330:17:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + }, + "value": "Underflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + } + ], + "id": 398, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "322:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 400, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "322:26:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 401, + "nodeType": "ExpressionStatement", + "src": "322:26:2" + } + } + ] + }, + "documentation": null, + "id": 409, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_sub", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 389, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 386, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "257:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 385, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "257:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 388, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "265:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 387, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "265:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "256:16:2" + }, + "returnParameters": { + "id": 392, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 391, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "294:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 390, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "294:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "293:6:2" + }, + "scope": 467, + "src": "238:140:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 442, + "nodeType": "Block", + "src": "444:109:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 420, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 418, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "455:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 419, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "460:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "455:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 423, + "nodeType": "IfStatement", + "src": "451:20:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "hexValue": "30", + "id": 421, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "470:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "functionReturnParameters": 417, + "id": 422, + "nodeType": "Return", + "src": "463:8:2" + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 431, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 424, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "482:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 430, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 427, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 425, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "488:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 426, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "492:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "488:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 428, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "487:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 429, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "495:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "487:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "482:14:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 438, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 436, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "543:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 437, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "547:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "543:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 439, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "542:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 417, + "id": 440, + "nodeType": "Return", + "src": "535:14:2" + }, + "id": 441, + "nodeType": "IfStatement", + "src": "478:71:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 433, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "506:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 432, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "498:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 434, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "498:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 435, + "nodeType": "ExpressionStatement", + "src": "498:25:2" + } + } + ] + }, + "documentation": null, + "id": 443, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_mul", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 414, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 411, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "401:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 410, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "401:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 413, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "409:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 412, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "409:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "400:16:2" + }, + "returnParameters": { + "id": 417, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 416, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "438:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 415, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "438:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "437:6:2" + }, + "scope": 467, + "src": "382:171:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 465, + "nodeType": "Block", + "src": "619:79:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 454, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 452, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "630:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 453, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "635:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "630:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 461, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 459, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 445, + "src": "688:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 460, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "692:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "688:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 462, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "687:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 451, + "id": 463, + "nodeType": "Return", + "src": "680:14:2" + }, + "id": 464, + "nodeType": "IfStatement", + "src": "626:68:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4469766973696f6e2062792030206572726f72", + "id": 456, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "646:21:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + }, + "value": "Division by 0 error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + } + ], + "id": 455, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "638:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 457, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "638:30:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 458, + "nodeType": "ExpressionStatement", + "src": "638:30:2" + } + } + ] + }, + "documentation": null, + "id": 466, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_div", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 448, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 445, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "576:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 444, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "576:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 447, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "584:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 446, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "584:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "575:16:2" + }, + "returnParameters": { + "id": 451, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 450, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "613:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 449, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "613:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "612:6:2" + }, + "scope": 467, + "src": "557:141:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "71:630:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 808, + "linearizedBaseContracts": [ + 808 + ], + "name": "MarketPlace_Cel", + "nodeType": "ContractDefinition", + "nodes": [ + { + "canonicalName": "MarketPlace_Cel.state", + "id": 474, + "members": [ + { + "id": 468, + "name": "marketPlace_Active", + "nodeType": "EnumValue", + "src": "753:18:2" + }, + { + "id": 469, + "name": "marketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "773:23:2" + }, + { + "id": 470, + "name": "marketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "798:26:2" + }, + { + "id": 471, + "name": "marketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "826:23:2" + }, + { + "id": 472, + "name": "marketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "851:24:2" + }, + { + "id": 473, + "name": "marketPlace_Accept", + "nodeType": "EnumValue", + "src": "877:18:2" + } + ], + "name": "state", + "nodeType": "EnumDefinition", + "src": "732:164:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 480, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 479, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 476, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "915:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 475, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "915:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 478, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "924:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 477, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "924:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "914:15:2" + }, + "src": "898:32:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 486, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 485, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 482, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "951:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 481, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "951:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 484, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "960:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 483, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "960:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "950:15:2" + }, + "src": "932:34:2" + }, + { + "constant": false, + "id": 488, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "974:14:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 487, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "974:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 490, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "995:13:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 489, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "995:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 492, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1015:17:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 491, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1015:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 494, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1039:16:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 493, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1039:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 496, + "name": "ContractCurrentstate", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1062:26:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "typeName": { + "contractScope": null, + "id": 495, + "name": "state", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 474, + "src": "1062:5:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 517, + "nodeType": "Block", + "src": "1145:131:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 505, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 503, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1156:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 504, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 498, + "src": "1165:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1156:16:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 506, + "nodeType": "ExpressionStatement", + "src": "1156:16:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 509, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 507, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1183:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 508, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 500, + "src": "1191:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1183:14:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 510, + "nodeType": "ExpressionStatement", + "src": "1183:14:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 514, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 511, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1208:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 512, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1231:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 513, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1231:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1208:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 515, + "nodeType": "ExpressionStatement", + "src": "1208:47:2" + }, + { + "expression": null, + "functionReturnParameters": 502, + "id": 516, + "nodeType": "Return", + "src": "1266:7:2" + } + ] + }, + "documentation": null, + "id": 518, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 501, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 498, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1104:15:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 497, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1104:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 500, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1121:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 499, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1121:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1103:33:2" + }, + "returnParameters": { + "id": 502, + "nodeType": "ParameterList", + "parameters": [], + "src": "1145:0:2" + }, + "scope": 808, + "src": "1091:185:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 548, + "nodeType": "Block", + "src": "1336:320:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 526, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 523, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1351:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 524, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1375:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 525, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1375:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1351:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 532, + "nodeType": "IfStatement", + "src": "1347:136:2", + "trueBody": { + "id": 531, + "nodeType": "Block", + "src": "1401:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 528, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1424:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 527, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1416:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 529, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1416:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 530, + "nodeType": "ExpressionStatement", + "src": "1416:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 535, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 533, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1493:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 534, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 520, + "src": "1508:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1493:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 536, + "nodeType": "ExpressionStatement", + "src": "1493:28:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 540, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 537, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1532:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 538, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1555:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 539, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1555:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1532:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 541, + "nodeType": "ExpressionStatement", + "src": "1532:52:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 543, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1611:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 544, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1618:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 542, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 480, + "src": "1600:10:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 545, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1600:31:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 546, + "nodeType": "EmitStatement", + "src": "1595:36:2" + }, + { + "expression": null, + "functionReturnParameters": 522, + "id": 547, + "nodeType": "Return", + "src": "1642:7:2" + } + ] + }, + "documentation": null, + "id": 549, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "makeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 521, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 520, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 549, + "src": "1304:18:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 519, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1304:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1303:20:2" + }, + "returnParameters": { + "id": 522, + "nodeType": "ParameterList", + "parameters": [], + "src": "1336:0:2" + }, + "scope": 808, + "src": "1284:372:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 605, + "nodeType": "Block", + "src": "1728:478:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 566, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "1743:81:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 564, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 559, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 556, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1746:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 557, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1770:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 558, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1770:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1746:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 563, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 560, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1803:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 561, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1803:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 562, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1817:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1803:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1746:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 565, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1745:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 572, + "nodeType": "IfStatement", + "src": "1739:169:2", + "trueBody": { + "id": 571, + "nodeType": "Block", + "src": "1826:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 568, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1849:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 567, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1841:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 569, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1841:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 570, + "nodeType": "ExpressionStatement", + "src": "1841:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 583, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 573, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 551, + "src": "1922:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 582, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 574, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1935:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 581, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "id": 578, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "~", + "prefix": true, + "src": "1952:11:2", + "subExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "30", + "id": 576, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1961:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "id": 575, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1953:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_uint256_$", + "typeString": "type(uint256)" + }, + "typeName": "uint256" + }, + "id": 577, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1953:10:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 579, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1951:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 580, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "1967:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1951:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1935:39:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1922:52:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 602, + "nodeType": "Block", + "src": "2055:127:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 593, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 591, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2074:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 592, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2090:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2074:23:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 601, + "nodeType": "IfStatement", + "src": "2070:101:2", + "trueBody": { + "id": 600, + "nodeType": "Block", + "src": "2099:72:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 598, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 594, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2118:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 597, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 595, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2133:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 596, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2148:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2133:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2118:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 599, + "nodeType": "ExpressionStatement", + "src": "2118:37:2" + } + ] + } + } + ] + }, + "id": 603, + "nodeType": "IfStatement", + "src": "1918:264:2", + "trueBody": { + "id": 590, + "nodeType": "Block", + "src": "1976:64:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 588, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 584, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1991:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 587, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 585, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2006:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 586, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2021:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2006:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1991:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 589, + "nodeType": "ExpressionStatement", + "src": "1991:37:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 555, + "id": 604, + "nodeType": "Return", + "src": "2192:7:2" + } + ] + }, + "documentation": null, + "id": 606, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "modifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 554, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 551, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1686:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 550, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1686:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 553, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1702:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 552, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1702:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1685:30:2" + }, + "returnParameters": { + "id": 555, + "nodeType": "ParameterList", + "parameters": [], + "src": "1728:0:2" + }, + "scope": 808, + "src": "1664:542:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 632, + "nodeType": "Block", + "src": "2250:261:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 619, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "2265:80:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 617, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 612, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 609, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2268:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 610, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2292:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 611, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2292:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2268:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 616, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 613, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2325:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 614, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2325:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 615, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2339:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2325:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2268:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 618, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "2267:78:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 625, + "nodeType": "IfStatement", + "src": "2261:168:2", + "trueBody": { + "id": 624, + "nodeType": "Block", + "src": "2347:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 621, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2370:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 620, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2362:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 622, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2362:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 623, + "nodeType": "ExpressionStatement", + "src": "2362:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 629, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 626, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2439:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 627, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2462:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 628, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2462:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2439:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 630, + "nodeType": "ExpressionStatement", + "src": "2439:47:2" + }, + { + "expression": null, + "functionReturnParameters": 608, + "id": 631, + "nodeType": "Return", + "src": "2497:7:2" + } + ] + }, + "documentation": null, + "id": 633, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "rejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 607, + "nodeType": "ParameterList", + "parameters": [], + "src": "2235:2:2" + }, + "returnParameters": { + "id": 608, + "nodeType": "ParameterList", + "parameters": [], + "src": "2250:0:2" + }, + "scope": 808, + "src": "2214:297:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 673, + "nodeType": "Block", + "src": "2563:413:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 644, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 639, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 636, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2578:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 637, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2602:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 638, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2602:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2578:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 643, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 640, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2635:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 641, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2635:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "id": 642, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2649:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2635:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2578:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 650, + "nodeType": "IfStatement", + "src": "2574:164:2", + "trueBody": { + "id": 649, + "nodeType": "Block", + "src": "2656:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 646, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2679:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 645, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2671:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 647, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2671:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 648, + "nodeType": "ExpressionStatement", + "src": "2671:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 654, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 651, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2752:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 652, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2752:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 653, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2765:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2752:25:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 671, + "nodeType": "IfStatement", + "src": "2748:204:2", + "trueBody": { + "id": 670, + "nodeType": "Block", + "src": "2779:173:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 658, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 655, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2794:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 656, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2808:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 657, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2808:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2794:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 659, + "nodeType": "ExpressionStatement", + "src": "2794:23:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 661, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "2850:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 662, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2858:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 660, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 486, + "src": "2837:12:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 663, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2837:33:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 664, + "nodeType": "EmitStatement", + "src": "2832:38:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 668, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 665, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2885:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 666, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2908:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 667, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2908:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2885:55:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 669, + "nodeType": "ExpressionStatement", + "src": "2885:55:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 635, + "id": 672, + "nodeType": "Return", + "src": "2962:7:2" + } + ] + }, + "documentation": null, + "id": 674, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "acceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 634, + "nodeType": "ParameterList", + "parameters": [], + "src": "2540:2:2" + }, + "returnParameters": { + "id": 635, + "nodeType": "ParameterList", + "parameters": [], + "src": "2563:0:2" + }, + "scope": 808, + "src": "2519:457:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 764, + "nodeType": "Block", + "src": "3015:1021:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 692, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3030:175:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 690, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 685, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 680, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 677, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3033:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 678, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3057:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 679, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3057:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3033:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 684, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 681, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3093:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 682, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3117:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 683, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3117:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3093:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:113:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 689, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 686, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3150:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 687, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3174:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 688, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3174:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3150:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:171:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 691, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "3032:173:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 698, + "nodeType": "IfStatement", + "src": "3026:263:2", + "trueBody": { + "id": 697, + "nodeType": "Block", + "src": "3207:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 694, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3230:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 693, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "3222:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 695, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3222:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 696, + "nodeType": "ExpressionStatement", + "src": "3222:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 707, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 702, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 699, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3303:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 700, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3327:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 701, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3327:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3303:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 706, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 703, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3363:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 704, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3363:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 705, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3377:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3363:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3303:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 722, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 717, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 714, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3490:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 715, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3514:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 716, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3514:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3490:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 721, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 718, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3550:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 719, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3550:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 720, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3564:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3550:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3490:80:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 737, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 732, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 729, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3679:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 730, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3703:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 731, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3703:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3679:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 736, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 733, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3736:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 734, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3736:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 735, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3750:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3736:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3679:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 752, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 747, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 744, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3859:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 745, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3883:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 746, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3883:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3859:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 751, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 748, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3917:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 749, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3917:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 750, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3931:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3917:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3859:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 759, + "nodeType": "IfStatement", + "src": "3855:157:2", + "trueBody": { + "id": 758, + "nodeType": "Block", + "src": "3938:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 756, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 753, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3953:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 754, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3976:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 755, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3976:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3953:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 757, + "nodeType": "ExpressionStatement", + "src": "3953:47:2" + } + ] + } + }, + "id": 760, + "nodeType": "IfStatement", + "src": "3675:337:2", + "trueBody": { + "id": 743, + "nodeType": "Block", + "src": "3758:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 741, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 738, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3773:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 739, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3796:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 740, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3796:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3773:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 742, + "nodeType": "ExpressionStatement", + "src": "3773:47:2" + } + ] + } + }, + "id": 761, + "nodeType": "IfStatement", + "src": "3486:526:2", + "trueBody": { + "id": 728, + "nodeType": "Block", + "src": "3572:80:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 726, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 723, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3587:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 724, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3610:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 725, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3610:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3587:53:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 727, + "nodeType": "ExpressionStatement", + "src": "3587:53:2" + } + ] + } + }, + "id": 762, + "nodeType": "IfStatement", + "src": "3299:713:2", + "trueBody": { + "id": 713, + "nodeType": "Block", + "src": "3384:79:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 711, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 708, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3399:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 709, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3422:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 710, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3422:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3399:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 712, + "nodeType": "ExpressionStatement", + "src": "3399:52:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 676, + "id": 763, + "nodeType": "Return", + "src": "4022:7:2" + } + ] + }, + "documentation": null, + "id": 765, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 675, + "nodeType": "ParameterList", + "parameters": [], + "src": "3000:2:2" + }, + "returnParameters": { + "id": 676, + "nodeType": "ParameterList", + "parameters": [], + "src": "3015:0:2" + }, + "scope": 808, + "src": "2984:1052:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 806, + "nodeType": "Block", + "src": "4077:356:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 778, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4092:76:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 776, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 771, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 768, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "4095:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 769, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "4119:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 770, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4119:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "4095:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 775, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 772, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "4147:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 773, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4147:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 774, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4161:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "4147:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "4095:72:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 777, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "4094:74:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 784, + "nodeType": "IfStatement", + "src": "4088:164:2", + "trueBody": { + "id": 783, + "nodeType": "Block", + "src": "4170:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 780, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4193:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 779, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4185:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 781, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4185:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 782, + "nodeType": "ExpressionStatement", + "src": "4185:55:2" + } + ] + } + }, + { + "assignments": [ + 786, + null + ], + "declarations": [ + { + "constant": false, + "id": 786, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 806, + "src": "4263:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 785, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "4263:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 797, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 795, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4322:2:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "hexValue": "32333030", + "id": 793, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4316:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + }, + "value": "2300" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + } + ], + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 790, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "4299:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 787, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4281:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 788, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:11:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 789, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:17:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 791, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:30:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 792, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "gas", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:34:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setgas_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue_$value", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 794, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:40:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 796, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:44:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "4262:63:2" + }, + { + "condition": { + "argumentTypes": null, + "id": 799, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4340:8:2", + "subExpression": { + "argumentTypes": null, + "id": 798, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 786, + "src": "4341:7:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 804, + "nodeType": "IfStatement", + "src": "4336:72:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564", + "id": 801, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4371:36:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + }, + "value": " Sending of ether failed" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + } + ], + "id": 800, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4363:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 802, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4363:45:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 803, + "nodeType": "ExpressionStatement", + "src": "4363:45:2" + } + }, + { + "expression": null, + "functionReturnParameters": 767, + "id": 805, + "nodeType": "Return", + "src": "4419:7:2" + } + ] + }, + "documentation": null, + "id": 807, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 766, + "nodeType": "ParameterList", + "parameters": [], + "src": "4062:2:2" + }, + "returnParameters": { + "id": 767, + "nodeType": "ParameterList", + "parameters": [], + "src": "4077:0:2" + }, + "scope": 808, + "src": "4044:389:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "701:3735:2" + } + ], + "src": "36:4402:2" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "3.2.0", + "updatedAt": "2020-05-30T14:27:13.271Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/build/contracts/Migrations.json b/Celestial/Samples/AssetTransfer/build/contracts/Migrations.json new file mode 100644 index 00000000..27d35645 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/build/contracts/Migrations.json @@ -0,0 +1,906 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/Migrations.sol\":{\"keccak256\":\"0x5b3bf470fddc971545b13240a991587d98d71ca0bcff91819e54bd51e32ab21a\",\"urls\":[\"bzz-raw://7f783f6433812edb781db0ea7432e04652dac4796dde274d3e194dafdae19c14\",\"dweb:/ipfs/QmZFZNLk25y7UBLDNnjAzoH8SXBPfEN6bWNzGZ2x9C9aVK\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061019c806100606000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610064578063fdacd576146100ae575b600080fd5b61004e6100dc565b6040518082815260200191505060405180910390f35b61006c6100e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100da600480360360208110156100c457600080fd5b8101908080359060200190929190505050610107565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561016457806001819055505b5056fea265627a7a72315820615d47f6d0950a8f31d0e84dbfe953d7f2273e7160adac20aa606131f601a1ef64736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c8063445df0ac146100465780638da5cb5b14610064578063fdacd576146100ae575b600080fd5b61004e6100dc565b6040518082815260200191505060405180910390f35b61006c6100e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100da600480360360208110156100c457600080fd5b8101908080359060200190929190505050610107565b005b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561016457806001819055505b5056fea265627a7a72315820615d47f6d0950a8f31d0e84dbfe953d7f2273e7160adac20aa606131f601a1ef64736f6c63430005100032", + "sourceMap": "34:311:1:-;;;123:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;123:50:1;158:10;150:5;;:18;;;;;;;;;;;;;;;;;;34:311;;;;;;", + "deployedSourceMap": "34:311:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:311:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;82:36;;;:::i;:::-;;;;;;;;;;;;;;;;;;;58:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;240:103;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;240:103:1;;;;;;;;;;;;;;;;;:::i;:::-;;82:36;;;;:::o;58:20::-;;;;;;;;;;;;;:::o;240:103::-;223:5;;;;;;;;;;;209:19;;:10;:19;;;205:26;;;329:9;302:24;:36;;;;205:26;240:103;:::o", + "source": "pragma solidity >=0.4.21 <0.7.0;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n}\n", + "sourcePath": "C:\\Users\\t-sumukh\\source\\repos\\smart-contracts\\gitrepo\\celestial\\Experiments\\AssetTransfer\\contracts\\Migrations.sol", + "ast": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 357 + ] + }, + "id": 358, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 322, + "literals": [ + "solidity", + ">=", + "0.4", + ".21", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 357, + "linearizedBaseContracts": [ + 357 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 324, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 357, + "src": "58:20:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 323, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "58:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 326, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 357, + "src": "82:36:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 325, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "82:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 334, + "nodeType": "Block", + "src": "144:29:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 332, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 329, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "150:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 330, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "158:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 331, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "158:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "src": "150:18:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 333, + "nodeType": "ExpressionStatement", + "src": "150:18:1" + } + ] + }, + "documentation": null, + "id": 335, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 327, + "nodeType": "ParameterList", + "parameters": [], + "src": "134:2:1" + }, + "returnParameters": { + "id": 328, + "nodeType": "ParameterList", + "parameters": [], + "src": "144:0:1" + }, + "scope": 357, + "src": "123:50:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 343, + "nodeType": "Block", + "src": "199:37:1", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 340, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 337, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "209:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 338, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "209:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 339, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "223:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "209:19:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 342, + "nodeType": "IfStatement", + "src": "205:26:1", + "trueBody": { + "id": 341, + "nodeType": "PlaceholderStatement", + "src": "230:1:1" + } + } + ] + }, + "documentation": null, + "id": 344, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 336, + "nodeType": "ParameterList", + "parameters": [], + "src": "196:2:1" + }, + "src": "177:59:1", + "visibility": "internal" + }, + { + "body": { + "id": 355, + "nodeType": "Block", + "src": "296:47:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 353, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 351, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 326, + "src": "302:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 352, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 346, + "src": "329:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "302:36:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 354, + "nodeType": "ExpressionStatement", + "src": "302:36:1" + } + ] + }, + "documentation": null, + "id": 356, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": null, + "id": 349, + "modifierName": { + "argumentTypes": null, + "id": 348, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 344, + "src": "285:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "285:10:1" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 347, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 346, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 356, + "src": "262:14:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 345, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "262:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "261:16:1" + }, + "returnParameters": { + "id": 350, + "nodeType": "ParameterList", + "parameters": [], + "src": "296:0:1" + }, + "scope": 357, + "src": "240:103:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 358, + "src": "34:311:1" + } + ], + "src": "0:346:1" + }, + "legacyAST": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 357 + ] + }, + "id": 358, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 322, + "literals": [ + "solidity", + ">=", + "0.4", + ".21", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 357, + "linearizedBaseContracts": [ + 357 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 324, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 357, + "src": "58:20:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 323, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "58:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 326, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 357, + "src": "82:36:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 325, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "82:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 334, + "nodeType": "Block", + "src": "144:29:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 332, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 329, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "150:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 330, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "158:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 331, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "158:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "src": "150:18:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 333, + "nodeType": "ExpressionStatement", + "src": "150:18:1" + } + ] + }, + "documentation": null, + "id": 335, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 327, + "nodeType": "ParameterList", + "parameters": [], + "src": "134:2:1" + }, + "returnParameters": { + "id": 328, + "nodeType": "ParameterList", + "parameters": [], + "src": "144:0:1" + }, + "scope": 357, + "src": "123:50:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 343, + "nodeType": "Block", + "src": "199:37:1", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 340, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 337, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "209:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 338, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "209:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 339, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "223:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "209:19:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 342, + "nodeType": "IfStatement", + "src": "205:26:1", + "trueBody": { + "id": 341, + "nodeType": "PlaceholderStatement", + "src": "230:1:1" + } + } + ] + }, + "documentation": null, + "id": 344, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 336, + "nodeType": "ParameterList", + "parameters": [], + "src": "196:2:1" + }, + "src": "177:59:1", + "visibility": "internal" + }, + { + "body": { + "id": 355, + "nodeType": "Block", + "src": "296:47:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 353, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 351, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 326, + "src": "302:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 352, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 346, + "src": "329:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "302:36:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 354, + "nodeType": "ExpressionStatement", + "src": "302:36:1" + } + ] + }, + "documentation": null, + "id": 356, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": null, + "id": 349, + "modifierName": { + "argumentTypes": null, + "id": 348, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 344, + "src": "285:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "285:10:1" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 347, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 346, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 356, + "src": "262:14:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 345, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "262:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "261:16:1" + }, + "returnParameters": { + "id": 350, + "nodeType": "ParameterList", + "parameters": [], + "src": "296:0:1" + }, + "scope": 357, + "src": "240:103:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 358, + "src": "34:311:1" + } + ], + "src": "0:346:1" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0xE82925a601D308f26737E778CA10C39b54dC9077", + "transactionHash": "0xbfde7ad7ad49f9580943ef607f755bae9f0142b0b4dbf85894aaf211b30e7b26" + } + }, + "schemaVersion": "3.2.0", + "updatedAt": "2020-05-30T14:27:13.915Z", + "networkType": "ethereum", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/build/contracts/Safe_Arith.json b/Celestial/Samples/AssetTransfer/build/contracts/Safe_Arith.json new file mode 100644 index 00000000..921279ae --- /dev/null +++ b/Celestial/Samples/AssetTransfer/build/contracts/Safe_Arith.json @@ -0,0 +1,11909 @@ +{ + "contractName": "Safe_Arith", + "abi": [ + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "safe_add", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "safe_sub", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "safe_mul", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "uint256", + "name": "a", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "safe_div", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"b\",\"type\":\"uint256\"}],\"name\":\"safe_add\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"b\",\"type\":\"uint256\"}],\"name\":\"safe_div\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"b\",\"type\":\"uint256\"}],\"name\":\"safe_mul\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"a\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"b\",\"type\":\"uint256\"}],\"name\":\"safe_sub\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol\":\"Safe_Arith\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol\":{\"keccak256\":\"0x7fa65ae50dca185ae1b44513e25481d7cc5cb06a5154dfac9959d6fbf2830eaa\",\"urls\":[\"bzz-raw://0e8cdfdca65455f80c6951577ac9fa1400ebb99a58da6bed9bee6a669f093af8\",\"dweb:/ipfs/QmUc5X5GQcgrwqjBLyqhBQMhgjUcBZYdChRayxDfmXE7Ur\"]}},\"version\":1}", + "bytecode": "0x6103f3610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80630ea17a761461005b578063d9637826146100a7578063daa7ddba146100f3578063f703601e1461013f575b600080fd5b6100916004803603604081101561007157600080fd5b81019080803590602001909291908035906020019092919050505061018b565b6040518082815260200191505060405180910390f35b6100dd600480360360408110156100bd57600080fd5b81019080803590602001909291908035906020019092919050505061022a565b6040518082815260200191505060405180910390f35b6101296004803603604081101561010957600080fd5b8101908080359060200190929190803590602001909291905050506102af565b6040518082815260200191505060405180910390f35b6101756004803603604081101561015557600080fd5b810190808035906020019092919080359060200190929190505050610339565b6040518082815260200191505060405180910390f35b60008082141561019e5760009050610224565b81828402816101a957fe5b04831461021e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f4f766572666c6f77204572726f7200000000000000000000000000000000000081525060200191505060405180910390fd5b81830290505b92915050565b60008082840311156102a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f556e646572666c6f77204572726f72000000000000000000000000000000000081525060200191505060405180910390fd5b818303905092915050565b600080821415610327576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4469766973696f6e2062792030206572726f720000000000000000000000000081525060200191505060405180910390fd5b81838161033057fe5b04905092915050565b60008183018310156103b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f4f766572666c6f77204572726f7200000000000000000000000000000000000081525060200191505060405180910390fd5b81830190509291505056fea265627a7a7231582091ffc392953734a2529ca1d35da99b7a1afa0f2868b987cbac9d46306ea1a02264736f6c63430005100032", + "deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600436106100565760003560e01c80630ea17a761461005b578063d9637826146100a7578063daa7ddba146100f3578063f703601e1461013f575b600080fd5b6100916004803603604081101561007157600080fd5b81019080803590602001909291908035906020019092919050505061018b565b6040518082815260200191505060405180910390f35b6100dd600480360360408110156100bd57600080fd5b81019080803590602001909291908035906020019092919050505061022a565b6040518082815260200191505060405180910390f35b6101296004803603604081101561010957600080fd5b8101908080359060200190929190803590602001909291905050506102af565b6040518082815260200191505060405180910390f35b6101756004803603604081101561015557600080fd5b810190808035906020019092919080359060200190929190505050610339565b6040518082815260200191505060405180910390f35b60008082141561019e5760009050610224565b81828402816101a957fe5b04831461021e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f4f766572666c6f77204572726f7200000000000000000000000000000000000081525060200191505060405180910390fd5b81830290505b92915050565b60008082840311156102a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f556e646572666c6f77204572726f72000000000000000000000000000000000081525060200191505060405180910390fd5b818303905092915050565b600080821415610327576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f4469766973696f6e2062792030206572726f720000000000000000000000000081525060200191505060405180910390fd5b81838161033057fe5b04905092915050565b60008183018310156103b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f4f766572666c6f77204572726f7200000000000000000000000000000000000081525060200191505060405180910390fd5b81830190509291505056fea265627a7a7231582091ffc392953734a2529ca1d35da99b7a1afa0f2868b987cbac9d46306ea1a02264736f6c63430005100032", + "sourceMap": "71:630:2:-;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24", + "deployedSourceMap": "71:630:2:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;382:171;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;382:171:2;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;238:140;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;238:140:2;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;557:141;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;557:141:2;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;95:139;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;95:139:2;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;382:171;438:4;460:1;455;:6;451:20;;;470:1;463:8;;;;451:20;495:1;492;488;:5;487:9;;;;;;482:1;:14;478:71;;498:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;478:71;547:1;543;:5;535:14;;382:171;;;;;:::o;238:140::-;294:4;319:1;315;311;:5;:9;307:67;;;322:26;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;307:67;372:1;368;:5;360:14;;238:140;;;;:::o;557:141::-;613:4;635:1;630;:6;626:68;;;638:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;626:68;692:1;688;:5;;;;;;680:14;;557:141;;;;:::o;95:139::-;151:4;176:1;172;:5;168:1;:9;164:66;;;179:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;164:66;228:1;224;:5;216:14;;95:139;;;;:::o", + "source": "/* Code generated by compiler */\r\n\r\npragma solidity >=0.5.0 <0.7.0;\r\n\r\nlibrary Safe_Arith {\r\n\r\nfunction safe_add (uint a, uint b) public pure returns (uint) {\r\n if (a < a + b) revert (\"Overflow Error\");\r\n else return (a + b);\r\n}\r\n\r\nfunction safe_sub (uint a, uint b) public pure returns (uint) {\r\n if (a - b > 0) revert (\"Underflow Error\");\r\n else return (a - b);\r\n}\r\n\r\nfunction safe_mul (uint a, uint b) public pure returns (uint) {\r\n if (b == 0) return 0;\r\n if (a != (a * b)/b) revert (\"Overflow Error\");\r\n else return (a * b);\r\n}\r\n\r\nfunction safe_div (uint a, uint b) public pure returns (uint) {\r\n if (b == 0) revert (\"Division by 0 error\");\r\n else return (a / b);\r\n}\r\n}contract MarketPlace_Cel\r\n{\r\n\r\nenum state\r\n{ marketPlace_Active, marketPlace_OfferPlaced, marketPlace_NotionalAccept, marketPlace_BuyerAccept, marketPlace_SellerAccept, marketPlace_Accept}\r\nevent eMakeOffer(address, uint);\r\nevent eAcceptOffer(address, uint);\r\n\r\n address seller;\r\n address buyer;\r\n uint sellingPrice;\r\n uint buyingPrice;\r\n state ContractCurrentstate;\r\nconstructor (address _seller, address _buyer)\r\npublic {\r\n seller = _seller;\r\n buyer = _buyer;\r\n ContractCurrentstate = state.marketPlace_Active;\r\n return;\r\n}\r\n\r\n function makeOffer (uint _sellingPrice)\r\n public {\r\n if (ContractCurrentstate != state.marketPlace_Active) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n sellingPrice = _sellingPrice;\r\n ContractCurrentstate = state.marketPlace_OfferPlaced;\r\n emit eMakeOffer(buyer, sellingPrice);\r\n return;\r\n }\r\n\r\n function modifyOffer (bool _increase, uint _change)\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_OfferPlaced && msg.sender == seller)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (_increase && sellingPrice <= (~uint256(0)) - _change) {\r\n sellingPrice = sellingPrice + _change;\r\n }\r\n else {\r\n if (sellingPrice >= _change) {\r\n sellingPrice = sellingPrice - _change;\r\n }\r\n }\r\n return;\r\n }\r\n\r\n function rejectOffer ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_OfferPlaced && msg.sender == buyer)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n ContractCurrentstate = state.marketPlace_Active;\r\n return;\r\n }\r\n\r\n function acceptOffer ()\r\n public payable {\r\n if (ContractCurrentstate != state.marketPlace_OfferPlaced || msg.sender != buyer) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (msg.value >= sellingPrice) {\r\n buyingPrice = msg.value;\r\n emit eAcceptOffer(seller, buyingPrice);\r\n ContractCurrentstate = state.marketPlace_NotionalAccept;\r\n }\r\n return;\r\n }\r\n\r\n function accept ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_NotionalAccept || ContractCurrentstate == state.marketPlace_BuyerAccept || ContractCurrentstate == state.marketPlace_SellerAccept)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n if (ContractCurrentstate == state.marketPlace_NotionalAccept && msg.sender == buyer) {\r\n ContractCurrentstate = state.marketPlace_BuyerAccept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_NotionalAccept && msg.sender == seller) {\r\n ContractCurrentstate = state.marketPlace_SellerAccept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_BuyerAccept && msg.sender == seller) {\r\n ContractCurrentstate = state.marketPlace_Accept;\r\n }\r\n else if (ContractCurrentstate == state.marketPlace_SellerAccept && msg.sender == buyer) {\r\n ContractCurrentstate = state.marketPlace_Accept;\r\n }\r\n return;\r\n }\r\n\r\n function withdraw ()\r\n public {\r\n if (! (ContractCurrentstate == state.marketPlace_Accept && msg.sender == seller)) {\r\n revert (\" function invoked in invalid state\");\r\n }\r\n (bool success, ) = seller.call.value(buyingPrice).gas(2300)(\"\");\r\n if (!success)\r\n revert (\" Sending of ether failed\");\r\n return;\r\n }\r\n}\r\n", + "sourcePath": "C:\\Users\\t-sumukh\\source\\repos\\smart-contracts\\gitrepo\\celestial\\Experiments\\AssetTransfer\\contracts\\contract.sol", + "ast": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol", + "exportedSymbols": { + "MarketPlace_Cel": [ + 808 + ], + "Safe_Arith": [ + 467 + ] + }, + "id": 809, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 359, + "literals": [ + "solidity", + ">=", + "0.5", + ".0", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "36:31:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "library", + "documentation": null, + "fullyImplemented": true, + "id": 467, + "linearizedBaseContracts": [ + 467 + ], + "name": "Safe_Arith", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 383, + "nodeType": "Block", + "src": "157:77:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 372, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 368, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "168:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 371, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 369, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "172:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 370, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "176:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "172:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "168:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 379, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 377, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "224:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 378, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "228:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "224:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 380, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "223:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 367, + "id": 381, + "nodeType": "Return", + "src": "216:14:2" + }, + "id": 382, + "nodeType": "IfStatement", + "src": "164:66:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 374, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "187:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 373, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "179:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 375, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "179:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 376, + "nodeType": "ExpressionStatement", + "src": "179:25:2" + } + } + ] + }, + "documentation": null, + "id": 384, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_add", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 364, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 361, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "114:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 360, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "114:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 363, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "122:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 362, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "122:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "113:16:2" + }, + "returnParameters": { + "id": 367, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 366, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "151:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 365, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "151:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:6:2" + }, + "scope": 467, + "src": "95:139:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 408, + "nodeType": "Block", + "src": "300:78:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 397, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 395, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 393, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "311:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 394, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "315:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "311:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 396, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "319:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "311:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 404, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 402, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "368:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 403, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "372:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "368:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 405, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "367:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 392, + "id": 406, + "nodeType": "Return", + "src": "360:14:2" + }, + "id": 407, + "nodeType": "IfStatement", + "src": "307:67:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "556e646572666c6f77204572726f72", + "id": 399, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "330:17:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + }, + "value": "Underflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + } + ], + "id": 398, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "322:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 400, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "322:26:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 401, + "nodeType": "ExpressionStatement", + "src": "322:26:2" + } + } + ] + }, + "documentation": null, + "id": 409, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_sub", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 389, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 386, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "257:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 385, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "257:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 388, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "265:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 387, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "265:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "256:16:2" + }, + "returnParameters": { + "id": 392, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 391, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "294:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 390, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "294:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "293:6:2" + }, + "scope": 467, + "src": "238:140:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 442, + "nodeType": "Block", + "src": "444:109:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 420, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 418, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "455:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 419, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "460:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "455:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 423, + "nodeType": "IfStatement", + "src": "451:20:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "hexValue": "30", + "id": 421, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "470:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "functionReturnParameters": 417, + "id": 422, + "nodeType": "Return", + "src": "463:8:2" + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 431, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 424, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "482:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 430, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 427, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 425, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "488:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 426, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "492:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "488:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 428, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "487:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 429, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "495:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "487:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "482:14:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 438, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 436, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "543:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 437, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "547:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "543:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 439, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "542:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 417, + "id": 440, + "nodeType": "Return", + "src": "535:14:2" + }, + "id": 441, + "nodeType": "IfStatement", + "src": "478:71:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 433, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "506:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 432, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "498:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 434, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "498:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 435, + "nodeType": "ExpressionStatement", + "src": "498:25:2" + } + } + ] + }, + "documentation": null, + "id": 443, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_mul", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 414, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 411, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "401:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 410, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "401:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 413, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "409:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 412, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "409:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "400:16:2" + }, + "returnParameters": { + "id": 417, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 416, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "438:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 415, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "438:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "437:6:2" + }, + "scope": 467, + "src": "382:171:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 465, + "nodeType": "Block", + "src": "619:79:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 454, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 452, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "630:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 453, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "635:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "630:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 461, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 459, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 445, + "src": "688:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 460, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "692:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "688:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 462, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "687:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 451, + "id": 463, + "nodeType": "Return", + "src": "680:14:2" + }, + "id": 464, + "nodeType": "IfStatement", + "src": "626:68:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4469766973696f6e2062792030206572726f72", + "id": 456, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "646:21:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + }, + "value": "Division by 0 error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + } + ], + "id": 455, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "638:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 457, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "638:30:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 458, + "nodeType": "ExpressionStatement", + "src": "638:30:2" + } + } + ] + }, + "documentation": null, + "id": 466, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_div", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 448, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 445, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "576:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 444, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "576:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 447, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "584:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 446, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "584:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "575:16:2" + }, + "returnParameters": { + "id": 451, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 450, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "613:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 449, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "613:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "612:6:2" + }, + "scope": 467, + "src": "557:141:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "71:630:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 808, + "linearizedBaseContracts": [ + 808 + ], + "name": "MarketPlace_Cel", + "nodeType": "ContractDefinition", + "nodes": [ + { + "canonicalName": "MarketPlace_Cel.state", + "id": 474, + "members": [ + { + "id": 468, + "name": "marketPlace_Active", + "nodeType": "EnumValue", + "src": "753:18:2" + }, + { + "id": 469, + "name": "marketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "773:23:2" + }, + { + "id": 470, + "name": "marketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "798:26:2" + }, + { + "id": 471, + "name": "marketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "826:23:2" + }, + { + "id": 472, + "name": "marketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "851:24:2" + }, + { + "id": 473, + "name": "marketPlace_Accept", + "nodeType": "EnumValue", + "src": "877:18:2" + } + ], + "name": "state", + "nodeType": "EnumDefinition", + "src": "732:164:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 480, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 479, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 476, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "915:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 475, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "915:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 478, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "924:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 477, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "924:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "914:15:2" + }, + "src": "898:32:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 486, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 485, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 482, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "951:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 481, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "951:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 484, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "960:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 483, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "960:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "950:15:2" + }, + "src": "932:34:2" + }, + { + "constant": false, + "id": 488, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "974:14:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 487, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "974:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 490, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "995:13:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 489, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "995:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 492, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1015:17:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 491, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1015:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 494, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1039:16:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 493, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1039:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 496, + "name": "ContractCurrentstate", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1062:26:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "typeName": { + "contractScope": null, + "id": 495, + "name": "state", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 474, + "src": "1062:5:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 517, + "nodeType": "Block", + "src": "1145:131:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 505, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 503, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1156:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 504, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 498, + "src": "1165:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1156:16:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 506, + "nodeType": "ExpressionStatement", + "src": "1156:16:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 509, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 507, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1183:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 508, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 500, + "src": "1191:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1183:14:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 510, + "nodeType": "ExpressionStatement", + "src": "1183:14:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 514, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 511, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1208:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 512, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1231:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 513, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1231:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1208:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 515, + "nodeType": "ExpressionStatement", + "src": "1208:47:2" + }, + { + "expression": null, + "functionReturnParameters": 502, + "id": 516, + "nodeType": "Return", + "src": "1266:7:2" + } + ] + }, + "documentation": null, + "id": 518, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 501, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 498, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1104:15:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 497, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1104:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 500, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1121:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 499, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1121:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1103:33:2" + }, + "returnParameters": { + "id": 502, + "nodeType": "ParameterList", + "parameters": [], + "src": "1145:0:2" + }, + "scope": 808, + "src": "1091:185:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 548, + "nodeType": "Block", + "src": "1336:320:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 526, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 523, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1351:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 524, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1375:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 525, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1375:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1351:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 532, + "nodeType": "IfStatement", + "src": "1347:136:2", + "trueBody": { + "id": 531, + "nodeType": "Block", + "src": "1401:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 528, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1424:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 527, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1416:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 529, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1416:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 530, + "nodeType": "ExpressionStatement", + "src": "1416:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 535, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 533, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1493:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 534, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 520, + "src": "1508:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1493:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 536, + "nodeType": "ExpressionStatement", + "src": "1493:28:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 540, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 537, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1532:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 538, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1555:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 539, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1555:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1532:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 541, + "nodeType": "ExpressionStatement", + "src": "1532:52:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 543, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1611:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 544, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1618:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 542, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 480, + "src": "1600:10:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 545, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1600:31:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 546, + "nodeType": "EmitStatement", + "src": "1595:36:2" + }, + { + "expression": null, + "functionReturnParameters": 522, + "id": 547, + "nodeType": "Return", + "src": "1642:7:2" + } + ] + }, + "documentation": null, + "id": 549, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "makeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 521, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 520, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 549, + "src": "1304:18:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 519, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1304:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1303:20:2" + }, + "returnParameters": { + "id": 522, + "nodeType": "ParameterList", + "parameters": [], + "src": "1336:0:2" + }, + "scope": 808, + "src": "1284:372:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 605, + "nodeType": "Block", + "src": "1728:478:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 566, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "1743:81:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 564, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 559, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 556, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1746:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 557, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1770:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 558, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1770:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1746:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 563, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 560, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1803:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 561, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1803:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 562, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1817:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1803:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1746:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 565, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1745:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 572, + "nodeType": "IfStatement", + "src": "1739:169:2", + "trueBody": { + "id": 571, + "nodeType": "Block", + "src": "1826:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 568, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1849:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 567, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1841:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 569, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1841:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 570, + "nodeType": "ExpressionStatement", + "src": "1841:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 583, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 573, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 551, + "src": "1922:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 582, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 574, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1935:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 581, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "id": 578, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "~", + "prefix": true, + "src": "1952:11:2", + "subExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "30", + "id": 576, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1961:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "id": 575, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1953:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_uint256_$", + "typeString": "type(uint256)" + }, + "typeName": "uint256" + }, + "id": 577, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1953:10:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 579, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1951:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 580, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "1967:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1951:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1935:39:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1922:52:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 602, + "nodeType": "Block", + "src": "2055:127:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 593, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 591, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2074:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 592, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2090:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2074:23:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 601, + "nodeType": "IfStatement", + "src": "2070:101:2", + "trueBody": { + "id": 600, + "nodeType": "Block", + "src": "2099:72:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 598, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 594, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2118:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 597, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 595, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2133:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 596, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2148:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2133:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2118:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 599, + "nodeType": "ExpressionStatement", + "src": "2118:37:2" + } + ] + } + } + ] + }, + "id": 603, + "nodeType": "IfStatement", + "src": "1918:264:2", + "trueBody": { + "id": 590, + "nodeType": "Block", + "src": "1976:64:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 588, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 584, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1991:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 587, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 585, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2006:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 586, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2021:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2006:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1991:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 589, + "nodeType": "ExpressionStatement", + "src": "1991:37:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 555, + "id": 604, + "nodeType": "Return", + "src": "2192:7:2" + } + ] + }, + "documentation": null, + "id": 606, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "modifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 554, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 551, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1686:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 550, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1686:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 553, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1702:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 552, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1702:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1685:30:2" + }, + "returnParameters": { + "id": 555, + "nodeType": "ParameterList", + "parameters": [], + "src": "1728:0:2" + }, + "scope": 808, + "src": "1664:542:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 632, + "nodeType": "Block", + "src": "2250:261:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 619, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "2265:80:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 617, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 612, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 609, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2268:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 610, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2292:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 611, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2292:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2268:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 616, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 613, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2325:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 614, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2325:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 615, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2339:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2325:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2268:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 618, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "2267:78:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 625, + "nodeType": "IfStatement", + "src": "2261:168:2", + "trueBody": { + "id": 624, + "nodeType": "Block", + "src": "2347:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 621, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2370:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 620, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2362:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 622, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2362:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 623, + "nodeType": "ExpressionStatement", + "src": "2362:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 629, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 626, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2439:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 627, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2462:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 628, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2462:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2439:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 630, + "nodeType": "ExpressionStatement", + "src": "2439:47:2" + }, + { + "expression": null, + "functionReturnParameters": 608, + "id": 631, + "nodeType": "Return", + "src": "2497:7:2" + } + ] + }, + "documentation": null, + "id": 633, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "rejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 607, + "nodeType": "ParameterList", + "parameters": [], + "src": "2235:2:2" + }, + "returnParameters": { + "id": 608, + "nodeType": "ParameterList", + "parameters": [], + "src": "2250:0:2" + }, + "scope": 808, + "src": "2214:297:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 673, + "nodeType": "Block", + "src": "2563:413:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 644, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 639, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 636, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2578:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 637, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2602:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 638, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2602:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2578:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 643, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 640, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2635:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 641, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2635:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "id": 642, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2649:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2635:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2578:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 650, + "nodeType": "IfStatement", + "src": "2574:164:2", + "trueBody": { + "id": 649, + "nodeType": "Block", + "src": "2656:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 646, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2679:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 645, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2671:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 647, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2671:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 648, + "nodeType": "ExpressionStatement", + "src": "2671:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 654, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 651, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2752:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 652, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2752:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 653, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2765:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2752:25:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 671, + "nodeType": "IfStatement", + "src": "2748:204:2", + "trueBody": { + "id": 670, + "nodeType": "Block", + "src": "2779:173:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 658, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 655, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2794:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 656, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2808:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 657, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2808:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2794:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 659, + "nodeType": "ExpressionStatement", + "src": "2794:23:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 661, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "2850:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 662, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2858:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 660, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 486, + "src": "2837:12:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 663, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2837:33:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 664, + "nodeType": "EmitStatement", + "src": "2832:38:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 668, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 665, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2885:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 666, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2908:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 667, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2908:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2885:55:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 669, + "nodeType": "ExpressionStatement", + "src": "2885:55:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 635, + "id": 672, + "nodeType": "Return", + "src": "2962:7:2" + } + ] + }, + "documentation": null, + "id": 674, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "acceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 634, + "nodeType": "ParameterList", + "parameters": [], + "src": "2540:2:2" + }, + "returnParameters": { + "id": 635, + "nodeType": "ParameterList", + "parameters": [], + "src": "2563:0:2" + }, + "scope": 808, + "src": "2519:457:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 764, + "nodeType": "Block", + "src": "3015:1021:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 692, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3030:175:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 690, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 685, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 680, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 677, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3033:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 678, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3057:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 679, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3057:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3033:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 684, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 681, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3093:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 682, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3117:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 683, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3117:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3093:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:113:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 689, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 686, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3150:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 687, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3174:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 688, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3174:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3150:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:171:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 691, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "3032:173:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 698, + "nodeType": "IfStatement", + "src": "3026:263:2", + "trueBody": { + "id": 697, + "nodeType": "Block", + "src": "3207:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 694, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3230:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 693, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "3222:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 695, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3222:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 696, + "nodeType": "ExpressionStatement", + "src": "3222:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 707, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 702, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 699, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3303:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 700, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3327:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 701, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3327:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3303:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 706, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 703, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3363:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 704, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3363:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 705, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3377:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3363:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3303:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 722, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 717, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 714, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3490:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 715, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3514:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 716, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3514:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3490:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 721, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 718, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3550:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 719, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3550:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 720, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3564:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3550:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3490:80:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 737, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 732, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 729, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3679:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 730, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3703:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 731, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3703:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3679:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 736, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 733, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3736:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 734, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3736:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 735, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3750:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3736:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3679:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 752, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 747, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 744, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3859:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 745, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3883:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 746, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3883:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3859:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 751, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 748, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3917:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 749, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3917:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 750, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3931:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3917:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3859:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 759, + "nodeType": "IfStatement", + "src": "3855:157:2", + "trueBody": { + "id": 758, + "nodeType": "Block", + "src": "3938:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 756, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 753, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3953:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 754, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3976:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 755, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3976:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3953:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 757, + "nodeType": "ExpressionStatement", + "src": "3953:47:2" + } + ] + } + }, + "id": 760, + "nodeType": "IfStatement", + "src": "3675:337:2", + "trueBody": { + "id": 743, + "nodeType": "Block", + "src": "3758:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 741, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 738, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3773:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 739, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3796:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 740, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3796:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3773:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 742, + "nodeType": "ExpressionStatement", + "src": "3773:47:2" + } + ] + } + }, + "id": 761, + "nodeType": "IfStatement", + "src": "3486:526:2", + "trueBody": { + "id": 728, + "nodeType": "Block", + "src": "3572:80:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 726, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 723, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3587:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 724, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3610:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 725, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3610:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3587:53:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 727, + "nodeType": "ExpressionStatement", + "src": "3587:53:2" + } + ] + } + }, + "id": 762, + "nodeType": "IfStatement", + "src": "3299:713:2", + "trueBody": { + "id": 713, + "nodeType": "Block", + "src": "3384:79:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 711, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 708, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3399:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 709, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3422:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 710, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3422:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3399:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 712, + "nodeType": "ExpressionStatement", + "src": "3399:52:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 676, + "id": 763, + "nodeType": "Return", + "src": "4022:7:2" + } + ] + }, + "documentation": null, + "id": 765, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 675, + "nodeType": "ParameterList", + "parameters": [], + "src": "3000:2:2" + }, + "returnParameters": { + "id": 676, + "nodeType": "ParameterList", + "parameters": [], + "src": "3015:0:2" + }, + "scope": 808, + "src": "2984:1052:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 806, + "nodeType": "Block", + "src": "4077:356:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 778, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4092:76:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 776, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 771, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 768, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "4095:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 769, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "4119:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 770, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4119:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "4095:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 775, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 772, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "4147:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 773, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4147:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 774, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4161:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "4147:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "4095:72:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 777, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "4094:74:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 784, + "nodeType": "IfStatement", + "src": "4088:164:2", + "trueBody": { + "id": 783, + "nodeType": "Block", + "src": "4170:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 780, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4193:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 779, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4185:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 781, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4185:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 782, + "nodeType": "ExpressionStatement", + "src": "4185:55:2" + } + ] + } + }, + { + "assignments": [ + 786, + null + ], + "declarations": [ + { + "constant": false, + "id": 786, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 806, + "src": "4263:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 785, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "4263:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 797, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 795, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4322:2:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "hexValue": "32333030", + "id": 793, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4316:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + }, + "value": "2300" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + } + ], + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 790, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "4299:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 787, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4281:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 788, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:11:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 789, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:17:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 791, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:30:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 792, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "gas", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:34:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setgas_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue_$value", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 794, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:40:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 796, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:44:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "4262:63:2" + }, + { + "condition": { + "argumentTypes": null, + "id": 799, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4340:8:2", + "subExpression": { + "argumentTypes": null, + "id": 798, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 786, + "src": "4341:7:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 804, + "nodeType": "IfStatement", + "src": "4336:72:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564", + "id": 801, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4371:36:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + }, + "value": " Sending of ether failed" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + } + ], + "id": 800, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4363:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 802, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4363:45:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 803, + "nodeType": "ExpressionStatement", + "src": "4363:45:2" + } + }, + { + "expression": null, + "functionReturnParameters": 767, + "id": 805, + "nodeType": "Return", + "src": "4419:7:2" + } + ] + }, + "documentation": null, + "id": 807, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 766, + "nodeType": "ParameterList", + "parameters": [], + "src": "4062:2:2" + }, + "returnParameters": { + "id": 767, + "nodeType": "ParameterList", + "parameters": [], + "src": "4077:0:2" + }, + "scope": 808, + "src": "4044:389:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "701:3735:2" + } + ], + "src": "36:4402:2" + }, + "legacyAST": { + "absolutePath": "/C/Users/t-sumukh/source/repos/smart-contracts/gitrepo/celestial/Experiments/AssetTransfer/contracts/contract.sol", + "exportedSymbols": { + "MarketPlace_Cel": [ + 808 + ], + "Safe_Arith": [ + 467 + ] + }, + "id": 809, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 359, + "literals": [ + "solidity", + ">=", + "0.5", + ".0", + "<", + "0.7", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "36:31:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "library", + "documentation": null, + "fullyImplemented": true, + "id": 467, + "linearizedBaseContracts": [ + 467 + ], + "name": "Safe_Arith", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 383, + "nodeType": "Block", + "src": "157:77:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 372, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 368, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "168:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 371, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 369, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "172:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 370, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "176:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "172:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "168:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 379, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 377, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 361, + "src": "224:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 378, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 363, + "src": "228:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "224:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 380, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "223:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 367, + "id": 381, + "nodeType": "Return", + "src": "216:14:2" + }, + "id": 382, + "nodeType": "IfStatement", + "src": "164:66:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 374, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "187:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 373, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "179:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 375, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "179:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 376, + "nodeType": "ExpressionStatement", + "src": "179:25:2" + } + } + ] + }, + "documentation": null, + "id": 384, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_add", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 364, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 361, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "114:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 360, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "114:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 363, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "122:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 362, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "122:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "113:16:2" + }, + "returnParameters": { + "id": 367, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 366, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 384, + "src": "151:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 365, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "151:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:6:2" + }, + "scope": 467, + "src": "95:139:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 408, + "nodeType": "Block", + "src": "300:78:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 397, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 395, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 393, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "311:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 394, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "315:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "311:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 396, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "319:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "311:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 404, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 402, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 386, + "src": "368:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 403, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 388, + "src": "372:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "368:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 405, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "367:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 392, + "id": 406, + "nodeType": "Return", + "src": "360:14:2" + }, + "id": 407, + "nodeType": "IfStatement", + "src": "307:67:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "556e646572666c6f77204572726f72", + "id": 399, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "330:17:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + }, + "value": "Underflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_089c3c230686c1bda038412439b5be0193c86c49e536ee8e51fbbff78e95864e", + "typeString": "literal_string \"Underflow Error\"" + } + ], + "id": 398, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "322:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 400, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "322:26:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 401, + "nodeType": "ExpressionStatement", + "src": "322:26:2" + } + } + ] + }, + "documentation": null, + "id": 409, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_sub", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 389, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 386, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "257:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 385, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "257:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 388, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "265:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 387, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "265:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "256:16:2" + }, + "returnParameters": { + "id": 392, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 391, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 409, + "src": "294:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 390, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "294:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "293:6:2" + }, + "scope": 467, + "src": "238:140:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 442, + "nodeType": "Block", + "src": "444:109:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 420, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 418, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "455:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 419, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "460:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "455:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 423, + "nodeType": "IfStatement", + "src": "451:20:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "hexValue": "30", + "id": 421, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "470:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "functionReturnParameters": 417, + "id": 422, + "nodeType": "Return", + "src": "463:8:2" + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 431, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 424, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "482:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 430, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 427, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 425, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "488:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 426, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "492:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "488:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 428, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "487:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 429, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "495:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "487:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "482:14:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 438, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 436, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 411, + "src": "543:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "id": 437, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 413, + "src": "547:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "543:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 439, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "542:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 417, + "id": 440, + "nodeType": "Return", + "src": "535:14:2" + }, + "id": 441, + "nodeType": "IfStatement", + "src": "478:71:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4f766572666c6f77204572726f72", + "id": 433, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "506:16:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + }, + "value": "Overflow Error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_86fd51be534062ec0bfd39fb2bcdb41b38dd6ae901784ed204768882091902cb", + "typeString": "literal_string \"Overflow Error\"" + } + ], + "id": 432, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "498:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 434, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "498:25:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 435, + "nodeType": "ExpressionStatement", + "src": "498:25:2" + } + } + ] + }, + "documentation": null, + "id": 443, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_mul", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 414, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 411, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "401:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 410, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "401:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 413, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "409:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 412, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "409:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "400:16:2" + }, + "returnParameters": { + "id": 417, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 416, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 443, + "src": "438:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 415, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "438:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "437:6:2" + }, + "scope": 467, + "src": "382:171:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 465, + "nodeType": "Block", + "src": "619:79:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 454, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 452, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "630:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 453, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "635:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "630:6:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "expression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 461, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 459, + "name": "a", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 445, + "src": "688:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 460, + "name": "b", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 447, + "src": "692:1:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "688:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 462, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "687:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "functionReturnParameters": 451, + "id": 463, + "nodeType": "Return", + "src": "680:14:2" + }, + "id": 464, + "nodeType": "IfStatement", + "src": "626:68:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "4469766973696f6e2062792030206572726f72", + "id": 456, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "646:21:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + }, + "value": "Division by 0 error" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_2638385e4bbf50d52befb498e60db4a80ba65db311360b90cadcf4a834611e56", + "typeString": "literal_string \"Division by 0 error\"" + } + ], + "id": 455, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "638:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 457, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "638:30:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 458, + "nodeType": "ExpressionStatement", + "src": "638:30:2" + } + } + ] + }, + "documentation": null, + "id": 466, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "safe_div", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 448, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 445, + "name": "a", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "576:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 444, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "576:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 447, + "name": "b", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "584:6:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 446, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "584:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "575:16:2" + }, + "returnParameters": { + "id": 451, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 450, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 466, + "src": "613:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 449, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "613:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "612:6:2" + }, + "scope": 467, + "src": "557:141:2", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "71:630:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 808, + "linearizedBaseContracts": [ + 808 + ], + "name": "MarketPlace_Cel", + "nodeType": "ContractDefinition", + "nodes": [ + { + "canonicalName": "MarketPlace_Cel.state", + "id": 474, + "members": [ + { + "id": 468, + "name": "marketPlace_Active", + "nodeType": "EnumValue", + "src": "753:18:2" + }, + { + "id": 469, + "name": "marketPlace_OfferPlaced", + "nodeType": "EnumValue", + "src": "773:23:2" + }, + { + "id": 470, + "name": "marketPlace_NotionalAccept", + "nodeType": "EnumValue", + "src": "798:26:2" + }, + { + "id": 471, + "name": "marketPlace_BuyerAccept", + "nodeType": "EnumValue", + "src": "826:23:2" + }, + { + "id": 472, + "name": "marketPlace_SellerAccept", + "nodeType": "EnumValue", + "src": "851:24:2" + }, + { + "id": 473, + "name": "marketPlace_Accept", + "nodeType": "EnumValue", + "src": "877:18:2" + } + ], + "name": "state", + "nodeType": "EnumDefinition", + "src": "732:164:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 480, + "name": "eMakeOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 479, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 476, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "915:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 475, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "915:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 478, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 480, + "src": "924:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 477, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "924:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "914:15:2" + }, + "src": "898:32:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 486, + "name": "eAcceptOffer", + "nodeType": "EventDefinition", + "parameters": { + "id": 485, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 482, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "951:7:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 481, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "951:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 484, + "indexed": false, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 486, + "src": "960:4:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 483, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "960:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "950:15:2" + }, + "src": "932:34:2" + }, + { + "constant": false, + "id": 488, + "name": "seller", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "974:14:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 487, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "974:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 490, + "name": "buyer", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "995:13:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 489, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "995:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 492, + "name": "sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1015:17:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 491, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1015:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 494, + "name": "buyingPrice", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1039:16:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 493, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1039:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 496, + "name": "ContractCurrentstate", + "nodeType": "VariableDeclaration", + "scope": 808, + "src": "1062:26:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "typeName": { + "contractScope": null, + "id": 495, + "name": "state", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 474, + "src": "1062:5:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 517, + "nodeType": "Block", + "src": "1145:131:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 505, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 503, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1156:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 504, + "name": "_seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 498, + "src": "1165:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1156:16:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 506, + "nodeType": "ExpressionStatement", + "src": "1156:16:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 509, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 507, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1183:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 508, + "name": "_buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 500, + "src": "1191:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1183:14:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 510, + "nodeType": "ExpressionStatement", + "src": "1183:14:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 514, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 511, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1208:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 512, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1231:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 513, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1231:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1208:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 515, + "nodeType": "ExpressionStatement", + "src": "1208:47:2" + }, + { + "expression": null, + "functionReturnParameters": 502, + "id": 516, + "nodeType": "Return", + "src": "1266:7:2" + } + ] + }, + "documentation": null, + "id": 518, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 501, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 498, + "name": "_seller", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1104:15:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 497, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1104:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 500, + "name": "_buyer", + "nodeType": "VariableDeclaration", + "scope": 518, + "src": "1121:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 499, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1121:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1103:33:2" + }, + "returnParameters": { + "id": 502, + "nodeType": "ParameterList", + "parameters": [], + "src": "1145:0:2" + }, + "scope": 808, + "src": "1091:185:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 548, + "nodeType": "Block", + "src": "1336:320:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 526, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 523, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1351:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 524, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1375:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 525, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1375:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1351:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 532, + "nodeType": "IfStatement", + "src": "1347:136:2", + "trueBody": { + "id": 531, + "nodeType": "Block", + "src": "1401:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 528, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1424:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 527, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1416:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 529, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1416:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 530, + "nodeType": "ExpressionStatement", + "src": "1416:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 535, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 533, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1493:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 534, + "name": "_sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 520, + "src": "1508:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1493:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 536, + "nodeType": "ExpressionStatement", + "src": "1493:28:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 540, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 537, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1532:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 538, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1555:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 539, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1555:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1532:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 541, + "nodeType": "ExpressionStatement", + "src": "1532:52:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 543, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "1611:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 544, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1618:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 542, + "name": "eMakeOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 480, + "src": "1600:10:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 545, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1600:31:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 546, + "nodeType": "EmitStatement", + "src": "1595:36:2" + }, + { + "expression": null, + "functionReturnParameters": 522, + "id": 547, + "nodeType": "Return", + "src": "1642:7:2" + } + ] + }, + "documentation": null, + "id": 549, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "makeOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 521, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 520, + "name": "_sellingPrice", + "nodeType": "VariableDeclaration", + "scope": 549, + "src": "1304:18:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 519, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1304:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1303:20:2" + }, + "returnParameters": { + "id": 522, + "nodeType": "ParameterList", + "parameters": [], + "src": "1336:0:2" + }, + "scope": 808, + "src": "1284:372:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 605, + "nodeType": "Block", + "src": "1728:478:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 566, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "1743:81:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 564, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 559, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 556, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "1746:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 557, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "1770:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 558, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1770:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "1746:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 563, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 560, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "1803:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 561, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1803:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 562, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "1817:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "1803:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1746:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 565, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1745:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 572, + "nodeType": "IfStatement", + "src": "1739:169:2", + "trueBody": { + "id": 571, + "nodeType": "Block", + "src": "1826:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 568, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1849:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 567, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "1841:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 569, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1841:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 570, + "nodeType": "ExpressionStatement", + "src": "1841:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 583, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 573, + "name": "_increase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 551, + "src": "1922:9:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 582, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 574, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1935:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 581, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "id": 578, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "~", + "prefix": true, + "src": "1952:11:2", + "subExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "30", + "id": 576, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1961:1:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "id": 575, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1953:7:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_uint256_$", + "typeString": "type(uint256)" + }, + "typeName": "uint256" + }, + "id": 577, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1953:10:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "id": 579, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "1951:13:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 580, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "1967:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1951:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1935:39:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "1922:52:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "id": 602, + "nodeType": "Block", + "src": "2055:127:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 593, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 591, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2074:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 592, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2090:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2074:23:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 601, + "nodeType": "IfStatement", + "src": "2070:101:2", + "trueBody": { + "id": 600, + "nodeType": "Block", + "src": "2099:72:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 598, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 594, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2118:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 597, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 595, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2133:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "-", + "rightExpression": { + "argumentTypes": null, + "id": 596, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2148:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2133:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2118:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 599, + "nodeType": "ExpressionStatement", + "src": "2118:37:2" + } + ] + } + } + ] + }, + "id": 603, + "nodeType": "IfStatement", + "src": "1918:264:2", + "trueBody": { + "id": 590, + "nodeType": "Block", + "src": "1976:64:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 588, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 584, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "1991:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 587, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 585, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2006:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "+", + "rightExpression": { + "argumentTypes": null, + "id": 586, + "name": "_change", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 553, + "src": "2021:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2006:22:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1991:37:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 589, + "nodeType": "ExpressionStatement", + "src": "1991:37:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 555, + "id": 604, + "nodeType": "Return", + "src": "2192:7:2" + } + ] + }, + "documentation": null, + "id": 606, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "modifyOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 554, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 551, + "name": "_increase", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1686:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 550, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1686:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 553, + "name": "_change", + "nodeType": "VariableDeclaration", + "scope": 606, + "src": "1702:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 552, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1702:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1685:30:2" + }, + "returnParameters": { + "id": 555, + "nodeType": "ParameterList", + "parameters": [], + "src": "1728:0:2" + }, + "scope": 808, + "src": "1664:542:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 632, + "nodeType": "Block", + "src": "2250:261:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 619, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "2265:80:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 617, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 612, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 609, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2268:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 610, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2292:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 611, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2292:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2268:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 616, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 613, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2325:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 614, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2325:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 615, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2339:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2325:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2268:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 618, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "2267:78:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 625, + "nodeType": "IfStatement", + "src": "2261:168:2", + "trueBody": { + "id": 624, + "nodeType": "Block", + "src": "2347:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 621, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2370:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 620, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2362:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 622, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2362:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 623, + "nodeType": "ExpressionStatement", + "src": "2362:55:2" + } + ] + } + }, + { + "expression": { + "argumentTypes": null, + "id": 629, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 626, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2439:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 627, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2462:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 628, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Active", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2462:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2439:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 630, + "nodeType": "ExpressionStatement", + "src": "2439:47:2" + }, + { + "expression": null, + "functionReturnParameters": 608, + "id": 631, + "nodeType": "Return", + "src": "2497:7:2" + } + ] + }, + "documentation": null, + "id": 633, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "rejectOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 607, + "nodeType": "ParameterList", + "parameters": [], + "src": "2235:2:2" + }, + "returnParameters": { + "id": 608, + "nodeType": "ParameterList", + "parameters": [], + "src": "2250:0:2" + }, + "scope": 808, + "src": "2214:297:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 673, + "nodeType": "Block", + "src": "2563:413:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 644, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 639, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 636, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2578:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 637, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2602:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 638, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_OfferPlaced", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2602:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2578:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 643, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 640, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2635:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 641, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2635:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "!=", + "rightExpression": { + "argumentTypes": null, + "id": 642, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "2649:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "2635:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "2578:76:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 650, + "nodeType": "IfStatement", + "src": "2574:164:2", + "trueBody": { + "id": 649, + "nodeType": "Block", + "src": "2656:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 646, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "2679:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 645, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "2671:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 647, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2671:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 648, + "nodeType": "ExpressionStatement", + "src": "2671:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 654, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 651, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2752:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 652, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2752:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 653, + "name": "sellingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 492, + "src": "2765:12:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2752:25:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 671, + "nodeType": "IfStatement", + "src": "2748:204:2", + "trueBody": { + "id": 670, + "nodeType": "Block", + "src": "2779:173:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 658, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 655, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2794:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 656, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "2808:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 657, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2808:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "2794:23:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 659, + "nodeType": "ExpressionStatement", + "src": "2794:23:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 661, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "2850:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 662, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "2858:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 660, + "name": "eAcceptOffer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 486, + "src": "2837:12:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,uint256)" + } + }, + "id": 663, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "2837:33:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 664, + "nodeType": "EmitStatement", + "src": "2832:38:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 668, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 665, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "2885:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 666, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "2908:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 667, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "2908:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "2885:55:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 669, + "nodeType": "ExpressionStatement", + "src": "2885:55:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 635, + "id": 672, + "nodeType": "Return", + "src": "2962:7:2" + } + ] + }, + "documentation": null, + "id": 674, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "acceptOffer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 634, + "nodeType": "ParameterList", + "parameters": [], + "src": "2540:2:2" + }, + "returnParameters": { + "id": 635, + "nodeType": "ParameterList", + "parameters": [], + "src": "2563:0:2" + }, + "scope": 808, + "src": "2519:457:2", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 764, + "nodeType": "Block", + "src": "3015:1021:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 692, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "3030:175:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 690, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 685, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 680, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 677, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3033:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 678, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3057:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 679, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3057:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3033:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 684, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 681, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3093:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 682, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3117:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 683, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3117:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3093:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:113:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "||", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 689, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 686, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3150:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 687, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3174:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 688, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3174:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3150:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3033:171:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 691, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "3032:173:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 698, + "nodeType": "IfStatement", + "src": "3026:263:2", + "trueBody": { + "id": 697, + "nodeType": "Block", + "src": "3207:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 694, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "3230:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 693, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "3222:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 695, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "3222:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 696, + "nodeType": "ExpressionStatement", + "src": "3222:55:2" + } + ] + } + }, + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 707, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 702, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 699, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3303:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 700, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3327:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 701, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3327:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3303:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 706, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 703, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3363:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 704, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3363:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 705, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3377:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3363:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3303:79:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 722, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 717, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 714, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3490:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 715, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3514:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 716, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_NotionalAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3514:32:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3490:56:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 721, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 718, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3550:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 719, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3550:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 720, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3564:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3550:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3490:80:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 737, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 732, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 729, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3679:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 730, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3703:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 731, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3703:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3679:53:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 736, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 733, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3736:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 734, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3736:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 735, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "3750:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3736:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3679:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 752, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 747, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 744, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3859:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 745, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3883:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 746, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3883:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3859:54:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 751, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 748, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "3917:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 749, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3917:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 750, + "name": "buyer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 490, + "src": "3931:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "3917:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "3859:77:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 759, + "nodeType": "IfStatement", + "src": "3855:157:2", + "trueBody": { + "id": 758, + "nodeType": "Block", + "src": "3938:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 756, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 753, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3953:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 754, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3976:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 755, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3976:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3953:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 757, + "nodeType": "ExpressionStatement", + "src": "3953:47:2" + } + ] + } + }, + "id": 760, + "nodeType": "IfStatement", + "src": "3675:337:2", + "trueBody": { + "id": 743, + "nodeType": "Block", + "src": "3758:74:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 741, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 738, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3773:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 739, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3796:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 740, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3796:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3773:47:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 742, + "nodeType": "ExpressionStatement", + "src": "3773:47:2" + } + ] + } + }, + "id": 761, + "nodeType": "IfStatement", + "src": "3486:526:2", + "trueBody": { + "id": 728, + "nodeType": "Block", + "src": "3572:80:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 726, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 723, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3587:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 724, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3610:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 725, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_SellerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3610:30:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3587:53:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 727, + "nodeType": "ExpressionStatement", + "src": "3587:53:2" + } + ] + } + }, + "id": 762, + "nodeType": "IfStatement", + "src": "3299:713:2", + "trueBody": { + "id": 713, + "nodeType": "Block", + "src": "3384:79:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 711, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 708, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "3399:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 709, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "3422:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 710, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_BuyerAccept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "3422:29:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "3399:52:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "id": 712, + "nodeType": "ExpressionStatement", + "src": "3399:52:2" + } + ] + } + }, + { + "expression": null, + "functionReturnParameters": 676, + "id": 763, + "nodeType": "Return", + "src": "4022:7:2" + } + ] + }, + "documentation": null, + "id": 765, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "accept", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 675, + "nodeType": "ParameterList", + "parameters": [], + "src": "3000:2:2" + }, + "returnParameters": { + "id": 676, + "nodeType": "ParameterList", + "parameters": [], + "src": "3015:0:2" + }, + "scope": 808, + "src": "2984:1052:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 806, + "nodeType": "Block", + "src": "4077:356:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "id": 778, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4092:76:2", + "subExpression": { + "argumentTypes": null, + "components": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "id": 776, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + }, + "id": 771, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 768, + "name": "ContractCurrentstate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 496, + "src": "4095:20:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 769, + "name": "state", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 474, + "src": "4119:5:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_enum$_state_$474_$", + "typeString": "type(enum MarketPlace_Cel.state)" + } + }, + "id": 770, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "memberName": "marketPlace_Accept", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4119:24:2", + "typeDescriptions": { + "typeIdentifier": "t_enum$_state_$474", + "typeString": "enum MarketPlace_Cel.state" + } + }, + "src": "4095:48:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "nodeType": "BinaryOperation", + "operator": "&&", + "rightExpression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 775, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 772, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 823, + "src": "4147:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 773, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4147:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 774, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4161:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "4147:20:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "src": "4095:72:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "id": 777, + "isConstant": false, + "isInlineArray": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "TupleExpression", + "src": "4094:74:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 784, + "nodeType": "IfStatement", + "src": "4088:164:2", + "trueBody": { + "id": 783, + "nodeType": "Block", + "src": "4170:82:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2066756e6374696f6e20696e766f6b656420696e20696e76616c6964207374617465", + "id": 780, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4193:46:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + }, + "value": " function invoked in invalid state" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_08eb628bc9256861c38631c828196d6b134296bd95bd27211e3e14c50a8507b9", + "typeString": "literal_string \" function invoked in invalid state\"" + } + ], + "id": 779, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4185:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 781, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4185:55:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 782, + "nodeType": "ExpressionStatement", + "src": "4185:55:2" + } + ] + } + }, + { + "assignments": [ + 786, + null + ], + "declarations": [ + { + "constant": false, + "id": 786, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 806, + "src": "4263:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 785, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "4263:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + }, + null + ], + "id": 797, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "", + "id": 795, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4322:2:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + }, + "value": "" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "typeString": "literal_string \"\"" + } + ], + "arguments": [ + { + "argumentTypes": null, + "hexValue": "32333030", + "id": 793, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4316:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + }, + "value": "2300" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_rational_2300_by_1", + "typeString": "int_const 2300" + } + ], + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 790, + "name": "buyingPrice", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 494, + "src": "4299:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 787, + "name": "seller", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 488, + "src": "4281:6:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 788, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "call", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:11:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 789, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:17:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setvalue_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value_$", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 791, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:30:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$value", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 792, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "gas", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "4281:34:2", + "typeDescriptions": { + "typeIdentifier": "t_function_setgas_pure$_t_uint256_$returns$_t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue_$value", + "typeString": "function (uint256) pure returns (function (bytes memory) payable returns (bool,bytes memory))" + } + }, + "id": 794, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:40:2", + "typeDescriptions": { + "typeIdentifier": "t_function_barecall_payable$_t_bytes_memory_ptr_$returns$_t_bool_$_t_bytes_memory_ptr_$gasvalue", + "typeString": "function (bytes memory) payable returns (bool,bytes memory)" + } + }, + "id": 796, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4281:44:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$_t_bool_$_t_bytes_memory_ptr_$", + "typeString": "tuple(bool,bytes memory)" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "4262:63:2" + }, + { + "condition": { + "argumentTypes": null, + "id": 799, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "UnaryOperation", + "operator": "!", + "prefix": true, + "src": "4340:8:2", + "subExpression": { + "argumentTypes": null, + "id": 798, + "name": "success", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 786, + "src": "4341:7:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 804, + "nodeType": "IfStatement", + "src": "4336:72:2", + "trueBody": { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "hexValue": "3c4572726f724c6f673e2053656e64696e67206f66206574686572206661696c6564", + "id": 801, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "4371:36:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + }, + "value": " Sending of ether failed" + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_stringliteral_768b99094cbc9553fa1e48cb1ff71ee3a6ddcff7b4277402c2c8faa315de36ad", + "typeString": "literal_string \" Sending of ether failed\"" + } + ], + "id": 800, + "name": "revert", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 828, + 829 + ], + "referencedDeclaration": 829, + "src": "4363:6:2", + "typeDescriptions": { + "typeIdentifier": "t_function_revert_pure$_t_string_memory_ptr_$returns$__$", + "typeString": "function (string memory) pure" + } + }, + "id": 802, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "4363:45:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 803, + "nodeType": "ExpressionStatement", + "src": "4363:45:2" + } + }, + { + "expression": null, + "functionReturnParameters": 767, + "id": 805, + "nodeType": "Return", + "src": "4419:7:2" + } + ] + }, + "documentation": null, + "id": 807, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "withdraw", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 766, + "nodeType": "ParameterList", + "parameters": [], + "src": "4062:2:2" + }, + "returnParameters": { + "id": 767, + "nodeType": "ParameterList", + "parameters": [], + "src": "4077:0:2" + }, + "scope": 808, + "src": "4044:389:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 809, + "src": "701:3735:2" + } + ], + "src": "36:4402:2" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": {}, + "schemaVersion": "3.2.0", + "updatedAt": "2020-05-30T14:27:13.277Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/celestial/AssetTransfer.cel b/Celestial/Samples/AssetTransfer/celestial/AssetTransfer.cel new file mode 100644 index 00000000..4a2da013 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/celestial/AssetTransfer.cel @@ -0,0 +1,235 @@ +pragma solidity^0.6.8; + +import {Safe_Arith} from "./Safe_Arith.sol" ; + +contract MarketPlace_Cel +{ + address seller; + address buyer; + + uint sellingPrice; + uint buyingPrice; + + enum state + { + marketPlace_Active, marketPlace_OfferPlaced, marketPlace_NotionalAccept, + marketPlace_BuyerAccept, marketPlace_SellerAccept, marketPlace_Accept + } + state contractCurrentState; + + event eMakeOffer (address, uint); + event eAcceptOffer (address, uint); + + invariant distinctBuyerSeller + { + seller != buyer + } + + spec modifyOfferPost (bool _increase, uint _change, uint old_sellingPrice, uint new_sellingPrice) + { + ite + ( + _increase && old_sellingPrice + _change <= uint_max, + new_sellingPrice == old_sellingPrice + _change, + ite + ( + old_sellingPrice >= _change, + new_sellingPrice == old_sellingPrice - _change, + new_sellingPrice == old_sellingPrice + ) + ) + } + + spec acceptPost (address _from, address _seller, address _buyer, state old_state, state new_state) + { + ((old_state == state.marketPlace_NotionalAccept && _from == _buyer) ==> (new_state == state.marketPlace_BuyerAccept)) && + ((old_state == state.marketPlace_NotionalAccept && _from == _seller) ==> (new_state == state.marketPlace_SellerAccept)) && + ((old_state == state.marketPlace_BuyerAccept && _from == _seller) ==> (new_state == state.marketPlace_Accept)) && + ((old_state == state.marketPlace_SellerAccept && _from == _buyer) ==> (new_state == state.marketPlace_Accept)) + } + + constructor (address _seller, address _buyer) + public + pre _seller != _buyer + post new(contractCurrentState) == state.marketPlace_Active + { + seller = _seller; + buyer = _buyer; + contractCurrentState = state.marketPlace_Active; + return; + } + + function makeOffer (uint _sellingPrice) + public + post (new(sellingPrice) == _sellingPrice) && (new(contractCurrentState) == state.marketPlace_OfferPlaced) + tx_reverts (contractCurrentState != state.marketPlace_Active) || (sender != seller) + modifies [sellingPrice, contractCurrentState, log] + { + if (sender != seller) + { + revert (""); + } + + if (contractCurrentState != state.marketPlace_Active) + { + revert (" function invoked in invalid state"); + } + + sellingPrice = _sellingPrice; + contractCurrentState = state.marketPlace_OfferPlaced; + emit eMakeOffer (buyer, sellingPrice); + return; + } + + function modifyOffer (bool _increase, uint _change) + public + post modifyOfferPost (_increase, _change, sellingPrice, new(sellingPrice)) + tx_reverts (contractCurrentState != state.marketPlace_OfferPlaced) || (sender != seller) + modifies [sellingPrice] + { + if (sender != seller) + { + revert (""); + } + + if (!(contractCurrentState == state.marketPlace_OfferPlaced && sender == seller)) + { + revert (" function invoked in invalid state"); + } + + if (_increase) + { + sellingPrice = safe_add(sellingPrice, _change); // ensures no overflow + } + else + { + sellingPrice = safe_sub(sellingPrice, _change); // ensures no underflow + } + return; + } + + function rejectOffer () + public + post new(contractCurrentState) == state.marketPlace_Active + tx_reverts (contractCurrentState != state.marketPlace_OfferPlaced) || (sender != buyer) + modifies [contractCurrentState] + { + if (sender != buyer) + { + revert (""); + } + + if (!(contractCurrentState == state.marketPlace_OfferPlaced && sender == buyer)) + { + revert (" function invoked in invalid state"); + } + + contractCurrentState = state.marketPlace_Active; + return; + } + + spec acceptOfferPost ( + address _seller, state old_state, state new_state, uint _val, + uint _sellingPrice, uint _buyingPrice, eventlog old_log, eventlog new_log) + { + (_val >= _sellingPrice) ==> ((_buyingPrice == _val) && (new_state == state.marketPlace_NotionalAccept) && new_log == (eAcceptOffer, _seller, _buyingPrice)::old_log) + } + + function acceptOffer () + public + post acceptOfferPost (seller, contractCurrentState, new(contractCurrentState), value, sellingPrice, new(buyingPrice), log, new(log)) + credit + tx_reverts (contractCurrentState != state.marketPlace_OfferPlaced) || (sender != buyer) + modifies [buyingPrice, contractCurrentState] + { + // Implementation bug: Currentstate was Active + if (contractCurrentState != state.marketPlace_OfferPlaced || sender != buyer) + { + revert (" function invoked in invalid state"); + } + + if (value >= sellingPrice) + { + buyingPrice = value; + emit eAcceptOffer (seller, buyingPrice); + contractCurrentState = state.marketPlace_NotionalAccept; + } + return; + } + + spec acceptReverts (state old_contractCurrentState) + { + old_contractCurrentState != state.marketPlace_NotionalAccept + && old_contractCurrentState != state.marketPlace_BuyerAccept + && old_contractCurrentState != state.marketPlace_SellerAccept + } + + function accept () + public + post acceptPost (sender, seller, buyer, contractCurrentState, new(contractCurrentState)) + tx_reverts acceptReverts (contractCurrentState) + modifies [contractCurrentState] + { + if (!(contractCurrentState == state.marketPlace_NotionalAccept || contractCurrentState == state.marketPlace_BuyerAccept || + contractCurrentState == state.marketPlace_SellerAccept)) + { + revert (" function invoked in invalid state"); + } + + if (contractCurrentState == state.marketPlace_NotionalAccept && sender == buyer) + { + contractCurrentState = state.marketPlace_BuyerAccept; + } + else if (contractCurrentState == state.marketPlace_NotionalAccept && sender == seller) + { + contractCurrentState = state.marketPlace_SellerAccept; + } + else if (contractCurrentState == state.marketPlace_BuyerAccept && sender == seller) + { + contractCurrentState = state.marketPlace_Accept; + } + else if (contractCurrentState == state.marketPlace_SellerAccept && sender == buyer) + { + contractCurrentState = state.marketPlace_Accept; + } + return; + } + + spec withdrawReverts (state old_contractCurrentState, address _sender, address old_seller, uint old_balance, uint old_buyingPrice) + { + old_contractCurrentState != state.marketPlace_Accept || old_seller != _sender || old_balance < old_buyingPrice + } + + spec withdrawPost ( + uint old_balance, uint new_balance, uint old_buyingPrice, + address old_seller, eventlog old_log, eventlog new_log) + { + new_log == (old_seller, eTransfer, old_buyingPrice) :: old_log + && (new_balance == old_balance - old_buyingPrice || new_balance == old_balance) + } + + function withdraw () + public + post withdrawPost (balance, new(balance), buyingPrice, seller, log, new(log)) + debit + tx_reverts withdrawReverts (contractCurrentState, sender, seller, balance, buyingPrice) + { + if (sender != seller) + { + revert (""); + } + + if (! (contractCurrentState == state.marketPlace_Accept && sender == seller)) + { + revert (" function invoked in invalid state"); + } + + if (balance < buyingPrice) + { + revert ("Insufficient balance"); + } + + payable(seller).transfer(buyingPrice); + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/contracts/Call.sol b/Celestial/Samples/AssetTransfer/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/contracts/Migrations.sol b/Celestial/Samples/AssetTransfer/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/AssetTransfer/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/AssetTransfer/contracts/Safe_Arith.sol b/Celestial/Samples/AssetTransfer/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/AssetTransfer/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/contracts/contract.sol b/Celestial/Samples/AssetTransfer/contracts/contract.sol new file mode 100644 index 00000000..633ef31c --- /dev/null +++ b/Celestial/Samples/AssetTransfer/contracts/contract.sol @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract MarketPlace_Cel { + enum state + { + marketPlace_Active, marketPlace_OfferPlaced, marketPlace_NotionalAccept, marketPlace_BuyerAccept, marketPlace_SellerAccept, marketPlace_Accept + } + event eMakeOffer(address, uint); + event eAcceptOffer(address, uint); + address seller; + address buyer; + uint sellingPrice; + uint buyingPrice; + state contractCurrentState; + + constructor (address _seller, address _buyer) public { + seller = _seller; + buyer = _buyer; + contractCurrentState = state.marketPlace_Active; + return; + } + + function makeOffer (uint _sellingPrice) public { + if (msg.sender != seller) + { + revert (""); + } + if (contractCurrentState != state.marketPlace_Active) + { + revert (" function invoked in invalid state"); + } + sellingPrice = _sellingPrice; + contractCurrentState = state.marketPlace_OfferPlaced; + emit eMakeOffer(buyer, sellingPrice); + return; + } + + function modifyOffer (bool _increase, uint _change) public { + if (msg.sender != seller) + { + revert (""); + } + if (! (contractCurrentState == state.marketPlace_OfferPlaced && msg.sender == seller)) + { + revert (" function invoked in invalid state"); + } + if (_increase) + { + sellingPrice = Safe_Arith.safe_add(sellingPrice, _change); + } + else + { + sellingPrice = Safe_Arith.safe_sub(sellingPrice, _change); + } + return; + } + + function rejectOffer () public { + if (msg.sender != buyer) + { + revert (""); + } + if (! (contractCurrentState == state.marketPlace_OfferPlaced && msg.sender == buyer)) + { + revert (" function invoked in invalid state"); + } + contractCurrentState = state.marketPlace_Active; + return; + } + + function acceptOffer () public payable { + if (contractCurrentState != state.marketPlace_OfferPlaced || msg.sender != buyer) + { + revert (" function invoked in invalid state"); + } + if (msg.value >= sellingPrice) + { + buyingPrice = msg.value; + emit eAcceptOffer(seller, buyingPrice); + contractCurrentState = state.marketPlace_NotionalAccept; + } + return; + } + + function accept () public { + if (! (contractCurrentState == state.marketPlace_NotionalAccept || contractCurrentState == state.marketPlace_BuyerAccept || contractCurrentState == state.marketPlace_SellerAccept)) + { + revert (" function invoked in invalid state"); + } + if (contractCurrentState == state.marketPlace_NotionalAccept && msg.sender == buyer) + { + contractCurrentState = state.marketPlace_BuyerAccept; + } + else + if (contractCurrentState == state.marketPlace_NotionalAccept && msg.sender == seller) + { + contractCurrentState = state.marketPlace_SellerAccept; + } + else + if (contractCurrentState == state.marketPlace_BuyerAccept && msg.sender == seller) + { + contractCurrentState = state.marketPlace_Accept; + } + else + if (contractCurrentState == state.marketPlace_SellerAccept && msg.sender == buyer) + { + contractCurrentState = state.marketPlace_Accept; + } + return; + } + + function withdraw () public { + if (msg.sender != seller) + { + revert (""); + } + if (! (contractCurrentState == state.marketPlace_Accept && msg.sender == seller)) + { + revert (" function invoked in invalid state"); + } + if (address(this).balance < buyingPrice) + { + revert ("Insufficient balance"); + } + payable(seller).transfer(buyingPrice); + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/fstar/MarketPlace_Cel.fst b/Celestial/Samples/AssetTransfer/fstar/MarketPlace_Cel.fst new file mode 100644 index 00000000..485eeceb --- /dev/null +++ b/Celestial/Samples/AssetTransfer/fstar/MarketPlace_Cel.fst @@ -0,0 +1,575 @@ +(*Code generated by compiler*) + +module MarketPlace_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val marketplace_cel_eMakeOffer : string +assume val marketplace_cel_eAcceptOffer : string +type marketplace_cel_state = +| MarketPlace_Active +| MarketPlace_OfferPlaced +| MarketPlace_NotionalAccept +| MarketPlace_BuyerAccept +| MarketPlace_SellerAccept +| MarketPlace_Accept + +noeq type t_marketplace_cel = { + marketplace_cel_seller : address; + marketplace_cel_buyer : address; + marketplace_cel_sellingPrice : uint; + marketplace_cel_buyingPrice : uint; + marketplace_cel_contractCurrentState : marketplace_cel_state; +} + +(* Contract address type, liveness, and field range macros *) + +type marketplace_cel_address = contract t_marketplace_cel +let marketplace_cel_live (c:marketplace_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract MarketPlace_Cel *) + +let marketplace_cel_get_seller (c:marketplace_cel_address) +: StEth address + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).marketplace_cel_seller) += let marketplace_cel_inst = get_contract c in + marketplace_cel_inst.marketplace_cel_seller + +let marketplace_cel_get_buyer (c:marketplace_cel_address) +: StEth address + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).marketplace_cel_buyer) += let marketplace_cel_inst = get_contract c in + marketplace_cel_inst.marketplace_cel_buyer + +let marketplace_cel_get_sellingPrice (c:marketplace_cel_address) +: StEth uint + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).marketplace_cel_sellingPrice) += let marketplace_cel_inst = get_contract c in + marketplace_cel_inst.marketplace_cel_sellingPrice + +let marketplace_cel_get_buyingPrice (c:marketplace_cel_address) +: StEth uint + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).marketplace_cel_buyingPrice) += let marketplace_cel_inst = get_contract c in + marketplace_cel_inst.marketplace_cel_buyingPrice + +let marketplace_cel_get_contractCurrentState (c:marketplace_cel_address) +: StEth marketplace_cel_state + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).marketplace_cel_contractCurrentState) += let marketplace_cel_inst = get_contract c in + marketplace_cel_inst.marketplace_cel_contractCurrentState + +(* Field setters for contract MarketPlace_Cel *) + +let marketplace_cel_set_seller (c:marketplace_cel_address) (_seller:address) +: StEth unit + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + marketplace_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with marketplace_cel_seller = _seller })) += let marketplace_cel_inst = get_contract c in + let marketplace_cel_inst = { marketplace_cel_inst with marketplace_cel_seller = _seller } in + set_contract c marketplace_cel_inst + +let marketplace_cel_set_buyer (c:marketplace_cel_address) (_buyer:address) +: StEth unit + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + marketplace_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with marketplace_cel_buyer = _buyer })) += let marketplace_cel_inst = get_contract c in + let marketplace_cel_inst = { marketplace_cel_inst with marketplace_cel_buyer = _buyer } in + set_contract c marketplace_cel_inst + +let marketplace_cel_set_sellingPrice (c:marketplace_cel_address) (_sellingPrice:uint) +: StEth unit + (fun st -> c `marketplace_cel_live` st.current + /\ _sellingPrice >= 0 /\ _sellingPrice <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + marketplace_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with marketplace_cel_sellingPrice = _sellingPrice })) += let marketplace_cel_inst = get_contract c in + let marketplace_cel_inst = { marketplace_cel_inst with marketplace_cel_sellingPrice = _sellingPrice } in + set_contract c marketplace_cel_inst + +let marketplace_cel_set_buyingPrice (c:marketplace_cel_address) (_buyingPrice:uint) +: StEth unit + (fun st -> c `marketplace_cel_live` st.current + /\ _buyingPrice >= 0 /\ _buyingPrice <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + marketplace_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with marketplace_cel_buyingPrice = _buyingPrice })) += let marketplace_cel_inst = get_contract c in + let marketplace_cel_inst = { marketplace_cel_inst with marketplace_cel_buyingPrice = _buyingPrice } in + set_contract c marketplace_cel_inst + +let marketplace_cel_set_contractCurrentState (c:marketplace_cel_address) (_contractCurrentState:marketplace_cel_state) +: StEth unit + (fun st -> c `marketplace_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + marketplace_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with marketplace_cel_contractCurrentState = _contractCurrentState })) += let marketplace_cel_inst = get_contract c in + let marketplace_cel_inst = { marketplace_cel_inst with marketplace_cel_contractCurrentState = _contractCurrentState } in + set_contract c marketplace_cel_inst + +let distinctBuyerSeller (self:marketplace_cel_address) (bst:bstate{self `marketplace_cel_live` bst}) : Type0 = + let marketplace_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.marketplace_cel_seller =!= cs.marketplace_cel_buyer + +let modifyOfferPost (_increase:bool) (_change:uint) (old_sellingPrice:uint) (new_sellingPrice:uint) += if (_increase && ((old_sellingPrice + _change) <= uint_max)) then + (new_sellingPrice == (old_sellingPrice + _change)) +else + (if (old_sellingPrice >= _change) then + (new_sellingPrice == (old_sellingPrice - _change)) +else + (new_sellingPrice == old_sellingPrice) +) + + +let acceptPost (_from:address) (_seller:address) (_buyer:address) (old_state:marketplace_cel_state) (new_state:marketplace_cel_state) += (((((((old_state == MarketPlace_NotionalAccept) /\ (_from == _buyer)) ==> (new_state == MarketPlace_BuyerAccept)))) /\ (((((old_state == MarketPlace_NotionalAccept) /\ (_from == _seller)) ==> (new_state == MarketPlace_SellerAccept))))) /\ (((((old_state == MarketPlace_BuyerAccept) /\ (_from == _seller)) ==> (new_state == MarketPlace_Accept))))) /\ (((((old_state == MarketPlace_SellerAccept) /\ (_from == _buyer)) ==> (new_state == MarketPlace_Accept)))) + +let marketplace_cel_constructor (self:marketplace_cel_address) (sender:address) (value:uint) (tx:tx) (block:block) (_seller:address) (_buyer:address) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.marketplace_cel_seller == null) + /\ (cs.marketplace_cel_buyer == null) + /\ (cs.marketplace_cel_sellingPrice == 0) + /\ (cs.marketplace_cel_buyingPrice == 0) + /\ (cs.marketplace_cel_contractCurrentState == MarketPlace_Active) + /\ (_seller =!= _buyer) + ) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ (cs1.marketplace_cel_contractCurrentState == MarketPlace_Active) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = marketplace_cel_set_seller self _seller in +let cs = get_contract self in +let _ = marketplace_cel_set_buyer self _buyer in +let cs = get_contract self in +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_Active in +let cs = get_contract self in +() + +let makeOffer (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_sellingPrice:uint) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.marketplace_cel_contractCurrentState =!= MarketPlace_Active)) \/ ((sender =!= cs.marketplace_cel_seller))) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ (((cs1.marketplace_cel_sellingPrice == _sellingPrice)) /\ ((cs1.marketplace_cel_contractCurrentState == MarketPlace_OfferPlaced))) + /\ (bst0.balances == bst1.balances) + /\ (cs0.marketplace_cel_buyer == cs1.marketplace_cel_buyer) + /\ (cs0.marketplace_cel_seller == cs1.marketplace_cel_seller) + /\ (cs0.marketplace_cel_buyingPrice == cs1.marketplace_cel_buyingPrice) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.marketplace_cel_seller) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.marketplace_cel_contractCurrentState <> MarketPlace_Active) then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = marketplace_cel_set_sellingPrice self _sellingPrice in +let cs = get_contract self in +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_OfferPlaced in +let cs = get_contract self in +let _ = emit marketplace_cel_eMakeOffer (cs.marketplace_cel_buyer, cs.marketplace_cel_sellingPrice) in +let cs = get_contract self in +let balance = get_balance self in +() + +let modifyOffer (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_increase:bool) (_change:uint) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.marketplace_cel_contractCurrentState =!= MarketPlace_OfferPlaced)) \/ ((sender =!= cs.marketplace_cel_seller))) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ ((modifyOfferPost _increase _change cs0.marketplace_cel_sellingPrice cs1.marketplace_cel_sellingPrice)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.marketplace_cel_contractCurrentState == cs1.marketplace_cel_contractCurrentState) + /\ (cs0.marketplace_cel_seller == cs1.marketplace_cel_seller) + /\ (cs0.marketplace_cel_buyingPrice == cs1.marketplace_cel_buyingPrice) + /\ (cs0.marketplace_cel_buyer == cs1.marketplace_cel_buyer) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.marketplace_cel_seller) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (op_Negation (((cs.marketplace_cel_contractCurrentState = MarketPlace_OfferPlaced) && (sender = cs.marketplace_cel_seller)))) in +let _ = (if x1 then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (_increase) then begin +let x1 = ((if cs.marketplace_cel_sellingPrice <= uint_max - _change then (cs.marketplace_cel_sellingPrice + _change) else revert "Overflow error")) in +let _ = marketplace_cel_set_sellingPrice self x1 in +let cs = get_contract self in +() end +else begin +let x1 = ((if _change <= cs.marketplace_cel_sellingPrice then (cs.marketplace_cel_sellingPrice - _change) else revert "Underflow error")) in +let _ = marketplace_cel_set_sellingPrice self x1 in +let cs = get_contract self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +() + +let rejectOffer (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.marketplace_cel_contractCurrentState =!= MarketPlace_OfferPlaced)) \/ ((sender =!= cs.marketplace_cel_buyer))) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ (cs1.marketplace_cel_contractCurrentState == MarketPlace_Active) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.marketplace_cel_sellingPrice == cs1.marketplace_cel_sellingPrice) + /\ (cs0.marketplace_cel_buyer == cs1.marketplace_cel_buyer) + /\ (cs0.marketplace_cel_seller == cs1.marketplace_cel_seller) + /\ (cs0.marketplace_cel_buyingPrice == cs1.marketplace_cel_buyingPrice) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.marketplace_cel_buyer) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (op_Negation (((cs.marketplace_cel_contractCurrentState = MarketPlace_OfferPlaced) && (sender = cs.marketplace_cel_buyer)))) in +let _ = (if x1 then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_Active in +let cs = get_contract self in +() + +let acceptOfferPost (_seller:address) (old_state:marketplace_cel_state) (new_state:marketplace_cel_state) (_val:uint) (_sellingPrice:uint) (_buyingPrice:uint) (old_log:log) (new_log:log) += ((_val >= _sellingPrice) ==> ((((_buyingPrice == _val)) /\ ((new_state == MarketPlace_NotionalAccept))) /\ (new_log == ((mk_event null marketplace_cel_eAcceptOffer (_seller, _buyingPrice))::old_log)))) + +let acceptOffer (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.marketplace_cel_contractCurrentState =!= MarketPlace_OfferPlaced)) \/ ((sender =!= cs.marketplace_cel_buyer))) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ ((acceptOfferPost cs0.marketplace_cel_seller cs0.marketplace_cel_contractCurrentState cs1.marketplace_cel_contractCurrentState value cs0.marketplace_cel_sellingPrice cs1.marketplace_cel_buyingPrice l0 l1)) + /\ (cs0.marketplace_cel_sellingPrice == cs1.marketplace_cel_sellingPrice) + /\ (cs0.marketplace_cel_buyer == cs1.marketplace_cel_buyer) + /\ (cs0.marketplace_cel_seller == cs1.marketplace_cel_seller) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((cs.marketplace_cel_contractCurrentState <> MarketPlace_OfferPlaced) || (sender <> cs.marketplace_cel_buyer)) then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (value >= cs.marketplace_cel_sellingPrice) in +let _ = (if x1 then begin +let _ = marketplace_cel_set_buyingPrice self value in +let cs = get_contract self in +let _ = emit marketplace_cel_eAcceptOffer (cs.marketplace_cel_seller, cs.marketplace_cel_buyingPrice) in +let cs = get_contract self in +let balance = get_balance self in +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_NotionalAccept in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() + +let acceptReverts (old_contractCurrentState:marketplace_cel_state) += ((old_contractCurrentState =!= MarketPlace_NotionalAccept) /\ (old_contractCurrentState =!= MarketPlace_BuyerAccept)) /\ (old_contractCurrentState =!= MarketPlace_SellerAccept) + +let accept (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((acceptReverts cs.marketplace_cel_contractCurrentState)) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ ((acceptPost sender cs0.marketplace_cel_seller cs0.marketplace_cel_buyer cs0.marketplace_cel_contractCurrentState cs1.marketplace_cel_contractCurrentState)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.marketplace_cel_sellingPrice == cs1.marketplace_cel_sellingPrice) + /\ (cs0.marketplace_cel_buyer == cs1.marketplace_cel_buyer) + /\ (cs0.marketplace_cel_seller == cs1.marketplace_cel_seller) + /\ (cs0.marketplace_cel_buyingPrice == cs1.marketplace_cel_buyingPrice) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (op_Negation ((((cs.marketplace_cel_contractCurrentState = MarketPlace_NotionalAccept) || (cs.marketplace_cel_contractCurrentState = MarketPlace_BuyerAccept)) || (cs.marketplace_cel_contractCurrentState = MarketPlace_SellerAccept)))) in +let _ = (if x1 then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((cs.marketplace_cel_contractCurrentState = MarketPlace_NotionalAccept) && (sender = cs.marketplace_cel_buyer)) in +let _ = (if x1 then begin +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_BuyerAccept in +let cs = get_contract self in +() end +else begin +let x1 = ((cs.marketplace_cel_contractCurrentState = MarketPlace_NotionalAccept) && (sender = cs.marketplace_cel_seller)) in +let _ = (if x1 then begin +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_SellerAccept in +let cs = get_contract self in +() end +else begin +let x1 = ((cs.marketplace_cel_contractCurrentState = MarketPlace_BuyerAccept) && (sender = cs.marketplace_cel_seller)) in +let _ = (if x1 then begin +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_Accept in +let cs = get_contract self in +() end +else begin +let x1 = ((cs.marketplace_cel_contractCurrentState = MarketPlace_SellerAccept) && (sender = cs.marketplace_cel_buyer)) in +let _ = (if x1 then begin +let _ = marketplace_cel_set_contractCurrentState self MarketPlace_Accept in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +() + +let withdrawReverts (old_contractCurrentState:marketplace_cel_state) (_sender:address) (old_seller:address) (old_balance:uint) (old_buyingPrice:uint) += ((old_contractCurrentState =!= MarketPlace_Accept) \/ (old_seller =!= _sender)) \/ (old_balance < old_buyingPrice) + +let withdrawPost (old_balance:uint) (new_balance:uint) (old_buyingPrice:uint) (old_seller:address) (old_log:log) (new_log:log) += (new_log == ((mk_event old_seller eTransfer old_buyingPrice)::old_log)) /\ (((new_balance == (old_balance - old_buyingPrice)) \/ (new_balance == old_balance))) + +let withdraw (self:marketplace_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + marketplace_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (distinctBuyerSeller self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((withdrawReverts cs.marketplace_cel_contractCurrentState sender cs.marketplace_cel_seller b cs.marketplace_cel_buyingPrice)) + ) + (fun bst0 x bst1 -> + marketplace_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (distinctBuyerSeller self bst1) + /\ ((withdrawPost b0 b1 cs0.marketplace_cel_buyingPrice cs0.marketplace_cel_seller l0 l1)) + /\ (b1 <= b0) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.marketplace_cel_seller) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (op_Negation (((cs.marketplace_cel_contractCurrentState = MarketPlace_Accept) && (sender = cs.marketplace_cel_seller)))) in +let _ = (if x1 then begin +revert " function invoked in invalid state"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (balance < cs.marketplace_cel_buyingPrice) then begin +revert "Insufficient balance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x2 = (cs.marketplace_cel_buyingPrice) in +let _ = transfer self (cs.marketplace_cel_seller) x2 in +let cs = get_contract self in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/migrations/1_initial_migration.js b/Celestial/Samples/AssetTransfer/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/AssetTransfer/package-lock.json b/Celestial/Samples/AssetTransfer/package-lock.json new file mode 100644 index 00000000..352d1933 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "csv-writer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", + "integrity": "sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==" + } + } +} diff --git a/Celestial/Samples/AssetTransfer/result.csv b/Celestial/Samples/AssetTransfer/result.csv new file mode 100644 index 00000000..12eca07c --- /dev/null +++ b/Celestial/Samples/AssetTransfer/result.csv @@ -0,0 +1,8 @@ +Method,Celestial Gas,Solidity Gas +Deployment,1262587,800621 +MakeOffer,67130,67157 +ModifyOffer,32210,29332 +AcceptOffer,52761,52752 +Accept (Buyer),29821,29843 +Accept (Seller),32590,32612 +Withdraw,33835,32146 diff --git a/Celestial/Samples/AssetTransfer/test/assetTransfer.js b/Celestial/Samples/AssetTransfer/test/assetTransfer.js new file mode 100644 index 00000000..feebb999 --- /dev/null +++ b/Celestial/Samples/AssetTransfer/test/assetTransfer.js @@ -0,0 +1,114 @@ +const createCsvWriter = require('csv-writer').createObjectCsvWriter; +const csvWriter = createCsvWriter({ + path: 'result.csv', + header: [ + {id: 'method', title: 'Method'}, + {id: 'cel_gas', title: 'Celestial Gas'}, + {id: 'sol_gas', title: 'Solidity Gas'}, + ] + }); +const MarketPlace = artifacts.require("MarketPlace"); +const MarketPlace_cel = artifacts.require("MarketPlace_Cel"); +const Safe_Arith = artifacts.require("Safe_Arith"); + +contract("AssetTransfer evaluation", async accounts => { + it("Evaluating Solidity and Celestial versions of AssetTransfer for gas consumption", async () => { + + let buyer = accounts[0]; + let seller = accounts[1]; + let sellingPrice = 100; + let incrementOffer = 50; + + // get data for original AssetTransfer + let instance = await MarketPlace.new(seller, buyer); + let deploymentReceipt = await web3.eth.getTransactionReceipt(instance.transactionHash); + var deploymentGas = parseInt(deploymentReceipt.gasUsed); // retrieve gas needed for deployment + + let tx = await instance.MakeOffer(sellingPrice, {from:seller}); + var makeOfferGas = tx.receipt.gasUsed; + + tx = await instance.ModifyOffer(true, incrementOffer, {from:seller}); + var modifyOfferGas = tx.receipt.gasUsed; + + tx = await instance.AcceptOffer({from:buyer, value:sellingPrice + incrementOffer}); + var acceptOfferGas = tx.receipt.gasUsed; + + tx = await instance.Accept({from:buyer}); + var acceptBuyerGas = tx.receipt.gasUsed; + + tx = await instance.Accept({from:seller}); + var acceptSellerGas = tx.receipt.gasUsed; + + tx = await instance.Withdraw({from:seller}); + var withdrawGas = tx.receipt.gasUsed; + + // get data for Celestial AssetTransfer + let libraryInstance_cel = await Safe_Arith.new(); + let libraryReceipt_cel = await web3.eth.getTransactionReceipt(libraryInstance_cel.transactionHash); + var libraryGas_cel = parseInt(libraryReceipt_cel.gasUsed); + await MarketPlace_cel.link("Safe_Arith", libraryInstance_cel.address); + let instance_cel = await MarketPlace_cel.new(seller, buyer); + let deploymentReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + var deploymentGas_cel = parseInt(deploymentReceipt_cel.gasUsed) + libraryGas_cel; // retrieve gas needed for deployment + + let tx_cel = await instance_cel.makeOffer(sellingPrice, {from:seller}); + var makeOfferGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.modifyOffer(true, incrementOffer, {from:seller}); + var modifyOfferGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.acceptOffer({from:buyer, value:sellingPrice + incrementOffer}); + var acceptOfferGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.accept({from:buyer}); + var acceptBuyerGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.accept({from:seller}); + var acceptSellerGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.withdraw({from:seller}); + var withdrawGas_cel = tx_cel.receipt.gasUsed; + + // dump results to csv + const data = [ + { + method: 'Deployment', + cel_gas: deploymentGas_cel, + sol_gas: deploymentGas, + }, + { + method: 'MakeOffer', + cel_gas: makeOfferGas_cel, + sol_gas: makeOfferGas, + }, + { + method: 'ModifyOffer', + cel_gas: modifyOfferGas_cel, + sol_gas: modifyOfferGas, + }, + { + method: 'AcceptOffer', + cel_gas: acceptOfferGas_cel, + sol_gas: acceptOfferGas, + }, + { + method: 'Accept (Buyer)', + cel_gas: acceptBuyerGas_cel, + sol_gas: acceptBuyerGas, + }, + { + method: 'Accept (Seller)', + cel_gas: acceptSellerGas_cel, + sol_gas: acceptSellerGas, + }, + { + method: 'Withdraw', + cel_gas: withdrawGas_cel, + sol_gas: withdrawGas, + } + ]; + + csvWriter + .writeRecords(data) + .then(()=> console.log('The CSV file was written successfully')); + })}); \ No newline at end of file diff --git a/Celestial/Samples/AssetTransfer/truffle-config.js b/Celestial/Samples/AssetTransfer/truffle-config.js new file mode 100644 index 00000000..a6177e0d --- /dev/null +++ b/Celestial/Samples/AssetTransfer/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + version: "0.6.8", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/BinanceCoin/README.md b/Celestial/Samples/BinanceCoin/README.md new file mode 100644 index 00000000..ec4a7b51 --- /dev/null +++ b/Celestial/Samples/BinanceCoin/README.md @@ -0,0 +1,3 @@ +# Binance Coin + +[Original contract](https://etherscan.io/address/0xb8c77482e45f1f44de1745f52c74426c631bdd52#code) \ No newline at end of file diff --git a/Celestial/Samples/BinanceCoin/celestial/BinanceCoin.cel b/Celestial/Samples/BinanceCoin/celestial/BinanceCoin.cel new file mode 100644 index 00000000..a4b3a33a --- /dev/null +++ b/Celestial/Samples/BinanceCoin/celestial/BinanceCoin.cel @@ -0,0 +1,139 @@ +pragma solidity^0.6.8; + +import {Safe_Arith} from "./Safe_Arith.sol" ; + +contract BNB_Cel +{ + string name; + string symbol; + uint8 decimals; + uint totalSupply; + address owner; + + mapping (address => uint) balanceOf; + mapping (address => uint) freezeOf; + mapping (address => mapping (address => uint)) allowance; + event Transfer(address , address , uint); + event Burn(address , uint ); + event Freeze(address , uint ); + event Unfreeze(address , uint ); + + invariant totalSupplyInv + { + totalSupply == sum_mapping (balanceOf) + sum_mapping (freezeOf) + } + + constructor (uint initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) + { + balanceOf[sender] = initialSupply; // Give the creator all initial tokens + totalSupply = initialSupply; // Update total supply + name = tokenName; // Set the name for display purposes + symbol = tokenSymbol; // Set the symbol for display purposes + decimals = decimalUnits; // Amount of decimals for display purposes + owner = sender; + return; + } + + function _transfer (address _to, uint _value) + tx_reverts _to == null || _value <= 0 || balanceOf[sender] < _value || balanceOf[_to] > uint_max - _value + post new(log) == (Transfer, sender, _to, _value)::log + && ite (sender != _to, new(balanceOf) == balanceOf[sender => balanceOf[sender] - _value, _to => balanceOf[_to] + _value], new(balanceOf) == balanceOf[sender => balanceOf[sender]] ) + modifies [balanceOf, log] + { + if (_to == null) revert ("Preventing transfer to 0x0 address"); // Prevent transfer to 0x0 address. Use burn() instead + if (_value <= 0) revert ("Value is 0"); + if (balanceOf[sender] < _value) revert ("Sender doesn't have enough"); // Check if the sender has enough + if (balanceOf[_to] > uint_max - _value) revert ("Overflow!"); + balanceOf[sender] = safe_sub(balanceOf[sender], _value); // Subtract from the sender + balanceOf[_to] = safe_add(balanceOf[_to], _value); // Add the same to the recipient + emit Transfer(sender, _to, _value); // Notify anyone listening that this transfer took place + return; + } + + function approve(address _spender, uint _value) + tx_reverts _value <= 0 + post new(allowance) == allowance[sender => allowance[sender][_spender => _value]] + modifies [allowance] + returns (bool success) + { + if (_value <= 0) revert ("value leq 0"); + allowance[sender][_spender] = _value; + return true; + } + + function transferFrom(address _from, address _to, uint _value) + tx_reverts _to == null || _value <= 0 || balanceOf[_from] < _value || balanceOf[_to] > uint_max - _value || _value > allowance[_from][sender] + post new(allowance) == allowance[_from => allowance[_from][sender => allowance[_from][sender] - _value]] && new(log) == (Transfer, _from, _to, _value)::log + && ite ( _from != _to, new(balanceOf) == balanceOf[_from => balanceOf[_from] - _value, _to => balanceOf[_to] + _value], new(balanceOf) == balanceOf[_from => balanceOf[_from]] ) + modifies [balanceOf,allowance,log] + returns (bool success) + { + if (_to == null) revert("preventing transfer to address 0x00"); // Prevent transfer to 0x0 address. Use burn() instead + if (_value <= 0) revert("value leq 0"); + if (balanceOf[_from] < _value) revert ("sender doesn't have enough!"); // Check if the sender has enough + if (balanceOf[_to] > uint_max - _value) revert ("Overflow!"); + if (_value > allowance[_from][sender]) revert ("allowance check failed"); // Check allowance + balanceOf[_from] = safe_sub(balanceOf[_from], _value); // Subtract from the sender + balanceOf[_to] = safe_add(balanceOf[_to], _value); // Add the same to the recipient + allowance[_from][sender] = safe_sub(allowance[_from][sender], _value); + emit Transfer(_from, _to, _value); + return true; + } + + function burn(uint _value) + tx_reverts _value <= 0 || balanceOf[sender] < _value || totalSupply < _value + post new(balanceOf) == balanceOf[sender => balanceOf[sender] - _value] && new(totalSupply) == totalSupply - _value && new(log) == (Burn, sender, _value)::log + modifies [balanceOf, totalSupply, log] + returns (bool success) + { + if (balanceOf[sender] < _value) revert("sender doesn't have enough!"); // Check if the sender has enough + if (_value <= 0) revert("value leq 0"); + balanceOf[sender] = safe_sub(balanceOf[sender], _value); // Subtract from the sender + totalSupply = safe_sub(totalSupply,_value); // Updates totalSupply + emit Burn(sender, _value); + return true; + } + + function freeze (uint _value) + tx_reverts freezeOf[sender] > uint_max - _value || balanceOf[sender] < _value || _value <= 0 + post new(balanceOf) == balanceOf[sender => balanceOf[sender] - _value] && new(freezeOf) == freezeOf[sender => freezeOf[sender] + _value] + && new(log) == (Freeze, sender, _value)::log + modifies [balanceOf,freezeOf,log] + returns (bool success) + { + if (balanceOf[sender] < _value) revert("sender doesn't have enough!"); // Check if the sender has enough + if (_value <= 0) revert("value leq 0"); + balanceOf[sender] = safe_sub(balanceOf[sender], _value); // Subtract from the sender + freezeOf[sender] = safe_add(freezeOf[sender], _value); // Updates totalSupply + emit Freeze(sender, _value); + return true; + } + + function unfreeze(uint _value) + tx_reverts balanceOf[sender] > uint_max - _value || freezeOf[sender] < _value || _value <= 0 + post new(balanceOf) == balanceOf[sender => balanceOf[sender] + _value] && new(freezeOf) == freezeOf[sender => freezeOf[sender] - _value] && new(log) == (Unfreeze, sender, _value)::log + modifies [balanceOf,freezeOf,log] + returns (bool success) + { + if (freezeOf[sender] < _value) revert("sender doesn't have enough!"); // Check if the sender has enough + if (_value <= 0) revert("value leq 0"); + freezeOf[sender] = safe_sub(freezeOf[sender], _value); // Subtract from the sender + balanceOf[sender] = safe_add(balanceOf[sender], _value); + emit Unfreeze(sender, _value); + return true; + } + + function withdrawEther(uint amount) debit + post (new(log) == (owner, eTransfer, amount)::log) + tx_reverts sender != owner + { + if(sender != owner) revert("sender is not owner"); + if (amount > balance) revert ("Insufficient balance"); + payable(owner).transfer(amount); + return; + } + + receive() credit { + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/BinanceCoin/contracts/Call.sol b/Celestial/Samples/BinanceCoin/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/BinanceCoin/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/BinanceCoin/contracts/Safe_Arith.sol b/Celestial/Samples/BinanceCoin/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/BinanceCoin/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/BinanceCoin/contracts/contract.sol b/Celestial/Samples/BinanceCoin/contracts/contract.sol new file mode 100644 index 00000000..8b03971f --- /dev/null +++ b/Celestial/Samples/BinanceCoin/contracts/contract.sol @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract BNB_Cel { + event Transfer(address, address, uint); + event Burn(address, uint); + event Freeze(address, uint); + event Unfreeze(address, uint); + string name; + string symbol; + uint8 decimals; + uint totalSupply; + address owner; + mapping (address => uint) balanceOf; + mapping (address => uint) freezeOf; + mapping (address => mapping (address => uint)) allowance; + + constructor (uint initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) public { + balanceOf[msg.sender] = initialSupply; + totalSupply = initialSupply; + name = tokenName; + symbol = tokenSymbol; + decimals = decimalUnits; + owner = msg.sender; + return; + } + + function _transfer (address _to, uint _value) public { + if (_to == address(0)) + revert ("Preventing transfer to 0x0 address"); + if (_value <= 0) + revert ("Value is 0"); + if (balanceOf[msg.sender] < _value) + revert ("Sender doesn't have enough"); + if (balanceOf[_to] > (~uint256(0)) - _value) + revert ("Overflow!"); + balanceOf[msg.sender] = Safe_Arith.safe_sub(balanceOf[msg.sender], _value); + balanceOf[_to] = Safe_Arith.safe_add(balanceOf[_to], _value); + emit Transfer(msg.sender, _to, _value); + return; + } + + function approve (address _spender, uint _value) public returns (bool success) { + if (_value <= 0) + revert ("value leq 0"); + allowance[msg.sender][_spender] = _value; + return true; + } + + function transferFrom (address _from, address _to, uint _value) public returns (bool success) { + if (_to == address(0)) + revert ("preventing transfer to address 0x00"); + if (_value <= 0) + revert ("value leq 0"); + if (balanceOf[_from] < _value) + revert ("sender doesn't have enough!"); + if (balanceOf[_to] > (~uint256(0)) - _value) + revert ("Overflow!"); + if (_value > allowance[_from][msg.sender]) + revert ("allowance check failed"); + balanceOf[_from] = Safe_Arith.safe_sub(balanceOf[_from], _value); + balanceOf[_to] = Safe_Arith.safe_add(balanceOf[_to], _value); + allowance[_from][msg.sender] = Safe_Arith.safe_sub(allowance[_from][msg.sender], _value); + emit Transfer(_from, _to, _value); + return true; + } + + function burn (uint _value) public returns (bool success) { + if (balanceOf[msg.sender] < _value) + revert ("sender doesn't have enough!"); + if (_value <= 0) + revert ("value leq 0"); + balanceOf[msg.sender] = Safe_Arith.safe_sub(balanceOf[msg.sender], _value); + totalSupply = Safe_Arith.safe_sub(totalSupply, _value); + emit Burn(msg.sender, _value); + return true; + } + + function freeze (uint _value) public returns (bool success) { + if (balanceOf[msg.sender] < _value) + revert ("sender doesn't have enough!"); + if (_value <= 0) + revert ("value leq 0"); + balanceOf[msg.sender] = Safe_Arith.safe_sub(balanceOf[msg.sender], _value); + freezeOf[msg.sender] = Safe_Arith.safe_add(freezeOf[msg.sender], _value); + emit Freeze(msg.sender, _value); + return true; + } + + function unfreeze (uint _value) public returns (bool success) { + if (freezeOf[msg.sender] < _value) + revert ("sender doesn't have enough!"); + if (_value <= 0) + revert ("value leq 0"); + freezeOf[msg.sender] = Safe_Arith.safe_sub(freezeOf[msg.sender], _value); + balanceOf[msg.sender] = Safe_Arith.safe_add(balanceOf[msg.sender], _value); + emit Unfreeze(msg.sender, _value); + return true; + } + + function withdrawEther (uint amount) public { + if (msg.sender != owner) + revert ("sender is not owner"); + if (amount > address(this).balance) + revert ("Insufficient balance"); + payable(owner).transfer(amount); + return; + } + + receive () external payable { + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/BinanceCoin/fstar/BNB_Cel.fst b/Celestial/Samples/BinanceCoin/fstar/BNB_Cel.fst new file mode 100644 index 00000000..c80a54ab --- /dev/null +++ b/Celestial/Samples/BinanceCoin/fstar/BNB_Cel.fst @@ -0,0 +1,824 @@ +(*Code generated by compiler*) + +module BNB_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val bnb_cel_Transfer : string +assume val bnb_cel_Burn : string +assume val bnb_cel_Freeze : string +assume val bnb_cel_Unfreeze : string + +noeq type t_bnb_cel = { + bnb_cel_name : string; + bnb_cel_symbol : string; + bnb_cel_decimals : uint8; + bnb_cel_totalSupply : uint; + bnb_cel_owner : address; + bnb_cel_balanceOf : (m:(M.t address uint lt){M.def_of m == 0}); + bnb_cel_freezeOf : (m:(M.t address uint lt){M.def_of m == 0}); + bnb_cel_allowance : (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}); +} + +(* Contract address type, liveness, and field range macros *) + +type bnb_cel_address = contract t_bnb_cel +let bnb_cel_live (c:bnb_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract BNB_Cel *) + +let bnb_cel_get_name (c:bnb_cel_address) +: StEth string + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_name) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_name + +let bnb_cel_get_symbol (c:bnb_cel_address) +: StEth string + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_symbol) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_symbol + +let bnb_cel_get_decimals (c:bnb_cel_address) +: StEth uint8 + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_decimals) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_decimals + +let bnb_cel_get_totalSupply (c:bnb_cel_address) +: StEth uint + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_totalSupply) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_totalSupply + +let bnb_cel_get_owner (c:bnb_cel_address) +: StEth address + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_owner) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_owner + +let bnb_cel_get_balanceOf (c:bnb_cel_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_balanceOf) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_balanceOf + +let bnb_cel_get_freezeOf (c:bnb_cel_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_freezeOf) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_freezeOf + +let bnb_cel_get_allowance (c:bnb_cel_address) +: StEth (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}) + (fun st -> c `bnb_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).bnb_cel_allowance) += let bnb_cel_inst = get_contract c in + bnb_cel_inst.bnb_cel_allowance + +(* Field setters for contract BNB_Cel *) + +let bnb_cel_set_name (c:bnb_cel_address) (_name:string) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_name = _name })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_name = _name } in + set_contract c bnb_cel_inst + +let bnb_cel_set_symbol (c:bnb_cel_address) (_symbol:string) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_symbol = _symbol })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_symbol = _symbol } in + set_contract c bnb_cel_inst + +let bnb_cel_set_decimals (c:bnb_cel_address) (_decimals:uint8) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_decimals = _decimals })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_decimals = _decimals } in + set_contract c bnb_cel_inst + +let bnb_cel_set_totalSupply (c:bnb_cel_address) (_totalSupply:uint) +: StEth unit + (fun st -> c `bnb_cel_live` st.current + /\ _totalSupply >= 0 /\ _totalSupply <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_totalSupply = _totalSupply })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_totalSupply = _totalSupply } in + set_contract c bnb_cel_inst + +let bnb_cel_set_owner (c:bnb_cel_address) (_owner:address) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_owner = _owner })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_owner = _owner } in + set_contract c bnb_cel_inst + +let bnb_cel_set_balanceOf (c:bnb_cel_address) (_balanceOf:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_balanceOf = _balanceOf })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_balanceOf = _balanceOf } in + set_contract c bnb_cel_inst + +let bnb_cel_set_freezeOf (c:bnb_cel_address) (_freezeOf:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_freezeOf = _freezeOf })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_freezeOf = _freezeOf } in + set_contract c bnb_cel_inst + +let bnb_cel_set_allowance (c:bnb_cel_address) (_allowance:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) +: StEth unit + (fun st -> c `bnb_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + bnb_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with bnb_cel_allowance = _allowance })) += let bnb_cel_inst = get_contract c in + let bnb_cel_inst = { bnb_cel_inst with bnb_cel_allowance = _allowance } in + set_contract c bnb_cel_inst + +let totalSupplyInv (self:bnb_cel_address) (bst:bstate{self `bnb_cel_live` bst}) : Type0 = + let bnb_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.bnb_cel_totalSupply == (((sum_mapping cs.bnb_cel_balanceOf)) + ((sum_mapping cs.bnb_cel_freezeOf))) + +let bnb_cel_constructor (self:bnb_cel_address) (sender:address) (value:uint) (tx:tx) (block:block) (initialSupply:uint) (tokenName:string) (decimalUnits:uint8) (tokenSymbol:string) +: Eth1 unit + (fun bst -> + bnb_cel_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.bnb_cel_name == "") + /\ (cs.bnb_cel_symbol == "") + /\ (cs.bnb_cel_decimals == 0) + /\ (cs.bnb_cel_totalSupply == 0) + /\ (cs.bnb_cel_owner == null) + /\ (cs.bnb_cel_balanceOf == M.const (0)) + /\ (cs.bnb_cel_freezeOf == M.const (0)) + /\ (cs.bnb_cel_allowance == M.const (M.const (0))) + ) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + bnb_cel_live self bst1 + /\ (totalSupplyInv self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf sender initialSupply) in +let cs = get_contract self in +let _ = bnb_cel_set_totalSupply self initialSupply in +let cs = get_contract self in +let _ = bnb_cel_set_name self tokenName in +let cs = get_contract self in +let _ = bnb_cel_set_symbol self tokenSymbol in +let cs = get_contract self in +let _ = bnb_cel_set_decimals self decimalUnits in +let cs = get_contract self in +let _ = bnb_cel_set_owner self sender in +let cs = get_contract self in +() + +let _transfer (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_to:address) (_value:uint) +: Eth1 unit + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((_to == null) \/ (_value <= 0)) \/ ((M.sel cs.bnb_cel_balanceOf sender) < _value)) \/ ((M.sel cs.bnb_cel_balanceOf _to) > (uint_max - _value))) + ) + (fun bst0 x bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ ((l1 == ((mk_event null bnb_cel_Transfer (sender, _to, _value))::l0)) /\ (if (sender <> _to) then + (M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf sender) - _value) in + let x1 = (M.upd x1 x2 x3) in + let x2 = (_to) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf _to) + _value) in + let x1 = (M.upd x1 x2 x3) in + x1)) +else + (M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (sender) in + let x3 = (M.sel cs0.bnb_cel_balanceOf sender) in + let x1 = (M.upd x1 x2 x3) in + x1)) +)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.bnb_cel_allowance == cs1.bnb_cel_allowance) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_totalSupply == cs1.bnb_cel_totalSupply) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + /\ (cs0.bnb_cel_freezeOf == cs1.bnb_cel_freezeOf) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_to = null) in +let _ = (if x1 then begin +revert "Preventing transfer to 0x0 address"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let _ = (if x1 then begin +revert "Value is 0"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((M.sel cs.bnb_cel_balanceOf sender) < _value) then begin +revert "Sender doesn't have enough"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((M.sel cs.bnb_cel_balanceOf _to) > ((_sub uint_max _value))) then begin +revert "Overflow!"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if _value <= (M.sel cs.bnb_cel_balanceOf sender) then ((M.sel cs.bnb_cel_balanceOf sender) - _value) else revert "Underflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let x1 = ((if (M.sel cs.bnb_cel_balanceOf _to) <= uint_max - _value then ((M.sel cs.bnb_cel_balanceOf _to) + _value) else revert "Overflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf _to x1) in +let cs = get_contract self in +let _ = emit bnb_cel_Transfer (sender, _to, _value) in +let cs = get_contract self in +let balance = get_balance self in +() + +let approve (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_spender:address) (_value:uint) +: Eth1 bool + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (_value <= 0) + ) + (fun bst0 success bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (M.equal cs1.bnb_cel_allowance ( + let x1 = (cs0.bnb_cel_allowance) in + let x2 = (sender) in + let x3 = ( + let x1 = (M.sel cs0.bnb_cel_allowance sender) in + let x2 = (_spender) in + let x3 = (_value) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_totalSupply == cs1.bnb_cel_totalSupply) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + /\ (cs0.bnb_cel_freezeOf == cs1.bnb_cel_freezeOf) + /\ (cs0.bnb_cel_balanceOf == cs1.bnb_cel_balanceOf) + )) += +let success:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let success = (if x1 then begin +revert "value leq 0"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x5 = (_value) in +let x4 = cs.bnb_cel_allowance in + +let x3 = (sender) in +let x2 = (M.sel x4 x3) in +let x1 = (_spender) in +let x0 = (M.sel x2 x1) in + +let _ = bnb_cel_set_allowance self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +true + +let transferFrom (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_from:address) (_to:address) (_value:uint) +: Eth1 bool + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((((_to == null) \/ (_value <= 0)) \/ ((M.sel cs.bnb_cel_balanceOf _from) < _value)) \/ ((M.sel cs.bnb_cel_balanceOf _to) > (uint_max - _value))) \/ (_value > (M.sel (M.sel cs.bnb_cel_allowance _from) sender))) + ) + (fun bst0 success bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (((M.equal cs1.bnb_cel_allowance ( + let x1 = (cs0.bnb_cel_allowance) in + let x2 = (_from) in + let x3 = ( + let x1 = (M.sel cs0.bnb_cel_allowance _from) in + let x2 = (sender) in + let x3 = ((M.sel (M.sel cs0.bnb_cel_allowance _from) sender) - _value) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (l1 == ((mk_event null bnb_cel_Transfer (_from, _to, _value))::l0))) /\ (if (_from <> _to) then + (M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (_from) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf _from) - _value) in + let x1 = (M.upd x1 x2 x3) in + let x2 = (_to) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf _to) + _value) in + let x1 = (M.upd x1 x2 x3) in + x1)) +else + (M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (_from) in + let x3 = (M.sel cs0.bnb_cel_balanceOf _from) in + let x1 = (M.upd x1 x2 x3) in + x1)) +)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_totalSupply == cs1.bnb_cel_totalSupply) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + /\ (cs0.bnb_cel_freezeOf == cs1.bnb_cel_freezeOf) + )) += +let success:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_to = null) in +let success = (if x1 then begin +revert "preventing transfer to address 0x00"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let success = (if x1 then begin +revert "value leq 0"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let success = (if ((M.sel cs.bnb_cel_balanceOf _from) < _value) then begin +revert "sender doesn't have enough!"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let success = (if ((M.sel cs.bnb_cel_balanceOf _to) > ((_sub uint_max _value))) then begin +revert "Overflow!"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let success = (if (_value > (M.sel (M.sel cs.bnb_cel_allowance _from) sender)) then begin +revert "allowance check failed"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if _value <= (M.sel cs.bnb_cel_balanceOf _from) then ((M.sel cs.bnb_cel_balanceOf _from) - _value) else revert "Underflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf _from x1) in +let cs = get_contract self in +let x1 = ((if (M.sel cs.bnb_cel_balanceOf _to) <= uint_max - _value then ((M.sel cs.bnb_cel_balanceOf _to) + _value) else revert "Overflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf _to x1) in +let cs = get_contract self in +let x5 = ((if _value <= (M.sel (M.sel cs.bnb_cel_allowance _from) sender) then ((M.sel (M.sel cs.bnb_cel_allowance _from) sender) - _value) else revert "Underflow error")) in +let x4 = cs.bnb_cel_allowance in + +let x3 = (_from) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = bnb_cel_set_allowance self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit bnb_cel_Transfer (_from, _to, _value) in +let cs = get_contract self in +let balance = get_balance self in +true + +let burn (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_value:uint) +: Eth1 bool + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((_value <= 0) \/ ((M.sel cs.bnb_cel_balanceOf sender) < _value)) \/ (cs.bnb_cel_totalSupply < _value)) + ) + (fun bst0 success bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (((M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf sender) - _value) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (cs1.bnb_cel_totalSupply == (cs0.bnb_cel_totalSupply - _value))) /\ (l1 == ((mk_event null bnb_cel_Burn (sender, _value))::l0))) + /\ (bst0.balances == bst1.balances) + /\ (cs0.bnb_cel_allowance == cs1.bnb_cel_allowance) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + /\ (cs0.bnb_cel_freezeOf == cs1.bnb_cel_freezeOf) + )) += +let success:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let success = (if ((M.sel cs.bnb_cel_balanceOf sender) < _value) then begin +revert "sender doesn't have enough!"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let success = (if x1 then begin +revert "value leq 0"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if _value <= (M.sel cs.bnb_cel_balanceOf sender) then ((M.sel cs.bnb_cel_balanceOf sender) - _value) else revert "Underflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let x1 = ((if _value <= cs.bnb_cel_totalSupply then (cs.bnb_cel_totalSupply - _value) else revert "Underflow error")) in +let _ = bnb_cel_set_totalSupply self x1 in +let cs = get_contract self in +let _ = emit bnb_cel_Burn (sender, _value) in +let cs = get_contract self in +let balance = get_balance self in +true + +let freeze (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_value:uint) +: Eth1 bool + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((M.sel cs.bnb_cel_freezeOf sender) > (uint_max - _value)) \/ ((M.sel cs.bnb_cel_balanceOf sender) < _value)) \/ (_value <= 0)) + ) + (fun bst0 success bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (((M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf sender) - _value) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (M.equal cs1.bnb_cel_freezeOf ( + let x1 = (cs0.bnb_cel_freezeOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_freezeOf sender) + _value) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (l1 == ((mk_event null bnb_cel_Freeze (sender, _value))::l0))) + /\ (bst0.balances == bst1.balances) + /\ (cs0.bnb_cel_allowance == cs1.bnb_cel_allowance) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_totalSupply == cs1.bnb_cel_totalSupply) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + )) += +let success:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let success = (if ((M.sel cs.bnb_cel_balanceOf sender) < _value) then begin +revert "sender doesn't have enough!"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let success = (if x1 then begin +revert "value leq 0"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if _value <= (M.sel cs.bnb_cel_balanceOf sender) then ((M.sel cs.bnb_cel_balanceOf sender) - _value) else revert "Underflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let x1 = ((if (M.sel cs.bnb_cel_freezeOf sender) <= uint_max - _value then ((M.sel cs.bnb_cel_freezeOf sender) + _value) else revert "Overflow error")) in +let freezeOf = cs.bnb_cel_freezeOf in +let _ = bnb_cel_set_freezeOf self (M.upd freezeOf sender x1) in +let cs = get_contract self in +let _ = emit bnb_cel_Freeze (sender, _value) in +let cs = get_contract self in +let balance = get_balance self in +true + +let unfreeze (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_value:uint) +: Eth1 bool + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((M.sel cs.bnb_cel_balanceOf sender) > (uint_max - _value)) \/ ((M.sel cs.bnb_cel_freezeOf sender) < _value)) \/ (_value <= 0)) + ) + (fun bst0 success bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (((M.equal cs1.bnb_cel_balanceOf ( + let x1 = (cs0.bnb_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_balanceOf sender) + _value) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (M.equal cs1.bnb_cel_freezeOf ( + let x1 = (cs0.bnb_cel_freezeOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.bnb_cel_freezeOf sender) - _value) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (l1 == ((mk_event null bnb_cel_Unfreeze (sender, _value))::l0))) + /\ (bst0.balances == bst1.balances) + /\ (cs0.bnb_cel_allowance == cs1.bnb_cel_allowance) + /\ (cs0.bnb_cel_symbol == cs1.bnb_cel_symbol) + /\ (cs0.bnb_cel_name == cs1.bnb_cel_name) + /\ (cs0.bnb_cel_owner == cs1.bnb_cel_owner) + /\ (cs0.bnb_cel_totalSupply == cs1.bnb_cel_totalSupply) + /\ (cs0.bnb_cel_decimals == cs1.bnb_cel_decimals) + )) += +let success:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let success = (if ((M.sel cs.bnb_cel_freezeOf sender) < _value) then begin +revert "sender doesn't have enough!"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_value <= 0) in +let success = (if x1 then begin +revert "value leq 0"; +success end +else success) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if _value <= (M.sel cs.bnb_cel_freezeOf sender) then ((M.sel cs.bnb_cel_freezeOf sender) - _value) else revert "Underflow error")) in +let freezeOf = cs.bnb_cel_freezeOf in +let _ = bnb_cel_set_freezeOf self (M.upd freezeOf sender x1) in +let cs = get_contract self in +let x1 = ((if (M.sel cs.bnb_cel_balanceOf sender) <= uint_max - _value then ((M.sel cs.bnb_cel_balanceOf sender) + _value) else revert "Overflow error")) in +let balanceOf = cs.bnb_cel_balanceOf in +let _ = bnb_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let _ = emit bnb_cel_Unfreeze (sender, _value) in +let cs = get_contract self in +let balance = get_balance self in +true + +let withdrawEther (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (amount:uint) +: Eth1 unit + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sender =!= cs.bnb_cel_owner) + ) + (fun bst0 x bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ ((l1 == ((mk_event cs0.bnb_cel_owner eTransfer amount)::l0))) + /\ (b1 <= b0) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.bnb_cel_owner) then begin +revert "sender is not owner"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (amount > balance) then begin +revert "Insufficient balance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = transfer self (cs.bnb_cel_owner) amount in +let cs = get_contract self in +let balance = get_balance self in +() + +let receive (self:bnb_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + bnb_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + False) + (fun bst0 x bst1 -> + bnb_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/README.md b/Celestial/Samples/ConsenSys/Multisig/README.md new file mode 100644 index 00000000..6a19fae9 --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/README.md @@ -0,0 +1,3 @@ +# ConsenSys MultiSig + +[Original contract](https://etherscan.io/address/0x851b7F3Ab81bd8dF354F0D7640EFcD7288553419#code) \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/celestial/MultiSig.cel b/Celestial/Samples/ConsenSys/Multisig/celestial/MultiSig.cel new file mode 100644 index 00000000..8704f0bf --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/celestial/MultiSig.cel @@ -0,0 +1,438 @@ +pragma solidity^0.6.8; + +import {Safe_Arith} from "./Safe_Arith.sol" ; + +contract MultiSigWalletWithDailyLimit_Cel { + + uint MAX_OWNER_COUNT = 50; + + struct Transaction { + address destination; + uint tval; + bool executed; + } + + event Confirmation(address, uint); + event Revocation(address, uint); + event Submission(uint); + event Execution(uint); + // event ExecutionFailure(uint transactionId); + event OwnerAddition(address); + event OwnerRemoval(address); + event RequirementChange(uint); + + mapping (uint => Transaction) transactions; + mapping (uint => uint) confirmationCounts; + mapping (uint => mapping (address => bool)) confirmations; + mapping (address => bool) isOwner; + uint ownerCount; + uint required; + uint transactionCount; + + bool walletActive; + bool tx_isConfirmed; + bool tx_isUnderLimit; + + event DailyLimitChange(uint); + + uint dailyLimit; + uint lastDay; + uint spentToday; + + // when wallet is active, there are more owners than the required number for consensus + invariant walletActiveInv + { + walletActive ==> (required <= ownerCount) + } + + // if there is an address _a which is an owner, then ownerCount is nonzero + // ownerCount is always below permitted limit + invariant ownerCountInv + { + ownerCount <= MAX_OWNER_COUNT + } + + invariant transactionCountInv + { + forall (uint i) ((i < transactionCount) ==> (i in transactions)) + } + + // every txId in transactions has a corresponding entry in confirmationCounts + // for an txId i in transactions, if there is at least one owner who has confirmed it, then the confirmationCount for i is nonzero + invariant confirmationCountsInv + { + forall (uint i) ((i in transactions) ==> (i in confirmationCounts)) + } + + receive () credit { + return; + } + + constructor (address initial_owner, uint _required, uint _dailyLimit) + pre (initial_owner != null && _required > 0) + { + isOwner[initial_owner] = true; + ownerCount = 1; + required = _required; + MAX_OWNER_COUNT = 50; + dailyLimit = _dailyLimit; + return; + } + + spec addOwnerReverts (address _owner, mapping (address => bool) old_isOwner, uint old_ownerCt, uint old_MAX_OWNER_COUNT) + { + old_isOwner[_owner] || _owner == null || (old_ownerCt + 1) > uint_max || (old_ownerCt + 1) > old_MAX_OWNER_COUNT + } + + spec addOwnerPost ( + mapping (address => bool) old_isOwner, mapping (address => bool) new_isOwner, + uint old_ownerCount, uint new_ownerCount, uint _required, + bool old_walletActive, bool new_walletActive, address _owner) + { + new_isOwner == old_isOwner[_owner => true] + && new_ownerCount == old_ownerCount + 1 + && ite ( + new_ownerCount >= _required, + new_walletActive == true, + new_walletActive == old_walletActive + ) + } + + function addOwner (address owner) public + post addOwnerPost (isOwner, new(isOwner), ownerCount, new(ownerCount), required, walletActive, new(walletActive), owner) + tx_reverts addOwnerReverts (owner, isOwner, ownerCount, MAX_OWNER_COUNT) + modifies [isOwner, ownerCount, walletActive, log] + { + uint target_ownerCount = safe_add (ownerCount, 1); + if (isOwner[owner] || owner == null || target_ownerCount > MAX_OWNER_COUNT) { + revert ("Invalid owner addition"); + } + + isOwner[owner] = true; + ownerCount = ownerCount + 1; + if (ownerCount >= required) + { + walletActive = true; + } + emit OwnerAddition (owner); + return; + } + + spec removeOwnerPost ( + address _owner, mapping (address => bool) old_isOwner, mapping (address => bool) new_isOwner, + uint old_ownerCount, uint new_ownerCount, uint old_required, bool old_walletActive, bool new_walletActive) + { + new_isOwner == old_isOwner[_owner => false] + && new_ownerCount == old_ownerCount - 1 + && ite ( + new_ownerCount < old_required, + new_walletActive == false, + new_walletActive == old_walletActive + ) + } + + function removeOwner (address owner) public + post removeOwnerPost (owner, isOwner, new(isOwner), ownerCount, new(ownerCount), required, walletActive, new(walletActive)) + tx_reverts (!isOwner[owner]) || (ownerCount == 0) + modifies [isOwner, ownerCount, walletActive, log] + { + if (!isOwner[owner]) + { + revert ("Invalid owner removal"); + } + + ownerCount = safe_sub (ownerCount, 1); + isOwner[owner] = false; + + if (ownerCount < required) + { + walletActive = false; + } + + emit OwnerRemoval (owner); + return; + } + + spec replaceOwnerPost (mapping (address => bool) old_isOwner, mapping (address => bool) new_isOwner, address _owner, address newOwner) + { + new_isOwner == old_isOwner[_owner => false, newOwner => true] + } + + function replaceOwner (address owner, address newOwner) public + post replaceOwnerPost (isOwner, new(isOwner), owner, newOwner) + tx_reverts (!isOwner[owner] || isOwner[newOwner]) + modifies [isOwner, log] + { + if (!isOwner[owner] || isOwner[newOwner]) + { + revert("Invalid owner replacement"); + } + + isOwner[owner] = false; + isOwner[newOwner] = true; + emit OwnerRemoval (owner); + emit OwnerAddition (newOwner); + return; + } + + spec changeRequirementsPost (uint new_required, uint old_ownerCount, bool old_walletActive, bool new_walletActive) + { + ite( + new_required > old_ownerCount, + new_walletActive == false, + new_walletActive == old_walletActive + ) + } + + function changeRequirement (uint _required) public + post changeRequirementsPost (new(required), ownerCount, walletActive, new(walletActive)) + modifies [required, ownerCount, log, walletActive] + { + required = _required; + if (required > ownerCount) + { + walletActive = false; + } + emit RequirementChange (_required); + return; + } + + spec addTransactionPost ( + mapping (uint => Transaction) old_transactions, mapping (uint => Transaction) new_transactions, + uint _txId, address _destination, uint _val, mapping (uint => uint) old_confirmationCounts, + mapping (uint => uint) new_confirmationCounts, uint old_transactionCount) + { + // !(txId in old_transactions) && + new_transactions == old_transactions[_txId => Transaction (_destination, _val, false)] + && new_confirmationCounts == old_confirmationCounts[_txId => 0] + && _txId == old_transactionCount + } + + function addTransaction (address _destination, uint _val) private + pre (_destination != null) + post addTransactionPost (transactions, new(transactions), transactionId, _destination, _val, confirmationCounts, new(confirmationCounts), transactionCount) + modifies [transactions, confirmationCounts, log] + returns (uint transactionId) + { + transactionId = transactionCount; + transactions[transactionId] = Transaction (_destination, _val, false); + confirmationCounts[transactionId] = 0; + emit Submission (transactionId); + return transactionId; + } + + spec isConfirmedPost (mapping (uint => uint) old_confirmationCounts, uint _transactionId, uint old_required, bool _ret) + { + (_ret == true <==> old_confirmationCounts[_transactionId] == old_required) + && (_ret == false <==> old_confirmationCounts[_transactionId] != old_required) + } + + function isConfirmed (uint transactionId) private + post isConfirmedPost (confirmationCounts, transactionId, required, ret) + modifies [] + returns (bool ret) + { + if (confirmationCounts[transactionId] == required) + { + ret = true; + } + else + { + ret = false; + } + return ret; + } + + spec isUnderLimitPost ( + uint time, uint old_lastDay, uint new_lastDay, + uint old_spentToday, uint new_spentToday, + uint _amount, uint old_dailyLimit, bool _ret) + { + ite + ( + time > old_lastDay + 86400, + new_lastDay == time && new_spentToday == 0, + new_lastDay == old_lastDay && new_spentToday == old_spentToday + ) + && ite + ( + new_spentToday + _amount > old_dailyLimit || new_spentToday + _amount > uint_max, + _ret == false, + _ret == true + ) + } + + function isUnderLimit (uint _amount) private + post isUnderLimitPost (block.timestamp, lastDay, new(lastDay), spentToday, new(spentToday), _amount, dailyLimit, ret) + tx_reverts (lastDay + 86400 > uint_max) + modifies [lastDay, spentToday] + returns (bool ret) + { + uint t = safe_add (lastDay, 86400); + if (block.timestamp > t) + { + lastDay = block.timestamp; + spentToday = 0; + } + if (_amount > uint_max - spentToday) + { + ret = false; + } + else if (!ret) + { + if (spentToday + _amount > dailyLimit) + { + ret = false; + } + else + { + ret = true; + } + } + return ret; + } + + spec executeTransactionReverts ( + uint _transactionId, uint old_transactionCount, + mapping (uint => Transaction) old_transactions, uint old_balance) + { + _transactionId >= old_transactionCount + || old_transactions[_transactionId].executed + || old_balance < old_transactions[_transactionId].tval + } + + function executeTransaction (uint transactionId) public + debit + post + ite ( + confirmationCounts[transactionId] == required, + new(tx_isConfirmed) == true, + new(tx_isConfirmed) == false + ) + && (ite ( + new(tx_isConfirmed) || new(tx_isUnderLimit), + (new(log) == (Execution, transactionId)::(transactions[transactionId].destination, eTransfer, transactions[transactionId].tval)::log) + && (new(transactions) == transactions[transactionId => Transaction(transactions[transactionId].destination, transactions[transactionId].tval, true)]), + new(log) == log && new(transactions) == transactions + )) + + tx_reverts (lastDay + 86400 > uint_max) || executeTransactionReverts (transactionId, transactionCount, transactions, balance) + modifies [transactions, tx_isConfirmed, tx_isUnderLimit, log, lastDay, spentToday] + { + if (transactionId >= transactionCount || transactions[transactionId].executed || balance < transactions[transactionId].tval) { + revert ("invalid"); + } + + Transaction trx = transactions[transactionId]; + tx_isConfirmed = isConfirmed (transactionId); + tx_isUnderLimit = isUnderLimit (trx.tval); + + if (tx_isConfirmed || tx_isUnderLimit) + { + if (!tx_isConfirmed) + { + spentToday = spentToday + trx.tval; + } + + transactions[transactionId].executed = true; + payable(transactions[transactionId].destination).transfer(trx.tval); + emit Execution (transactionId); + } + return; + } + + function confirmTransaction (uint transactionId) public + post + new(confirmationCounts) == confirmationCounts[transactionId => confirmationCounts[transactionId] + 1] && + new(confirmations) == confirmations[transactionId => confirmations[transactionId][sender => true]] && + ite ( + new(confirmationCounts)[transactionId] == required || new(tx_isUnderLimit), + new(log) == (Execution, transactionId)::(transactions[transactionId].destination, eTransfer, transactions[transactionId].tval)::(Confirmation, sender, transactionId)::log + && new(transactions) == transactions[transactionId => Transaction(transactions[transactionId].destination, transactions[transactionId].tval, true)], + new(transactions) == transactions + ) + debit + tx_reverts (!walletActive || !isOwner[sender] || transactionId >= transactionCount + || confirmations[transactionId][sender] || confirmationCounts[transactionId] + 1 > uint_max + || balance < transactions[transactionId].tval || transactions[transactionId].executed + || lastDay + 86400 > uint_max) + modifies [confirmationCounts, confirmations, transactions, log, lastDay, spentToday, tx_isConfirmed, tx_isUnderLimit] + { + if (!walletActive || !isOwner[sender] || transactionId >= transactionCount || confirmations[transactionId][sender]) + { + revert ("invalid"); + } + confirmationCounts[transactionId] = safe_add (confirmationCounts[transactionId], 1); + confirmations[transactionId][sender] = true; + emit Confirmation (sender, transactionId); + executeTransaction (transactionId); + return; + } + + function submitTransaction (address _dest, uint _amount) + public + tx_reverts (!walletActive || !isOwner[sender] || _dest == null || transactionCount + 1 > uint_max) + returns (uint transactionId) + { + if (!walletActive || !isOwner[sender] || _dest == null) { + revert ("invalid"); + } + transactionId = addTransaction (_dest, _amount); + transactionCount = safe_add (transactionCount, 1); + return transactionId; + } + + function revokeConfirmation (uint transactionId) public + pre (confirmationCounts[transactionId] > 0) + tx_reverts (!isOwner[sender] || !confirmations[transactionId][sender] || transactionId > transactionCount || transactions[transactionId].executed) + modifies [confirmations, confirmationCounts, log] + { + if (!isOwner[sender] || !confirmations[transactionId][sender] || transactionId > transactionCount || transactions[transactionId].executed) + { + revert ("Invalid"); + } + confirmations[transactionId][sender] = false; + // assuming the _confirmationCounts invariant at the start should prove the safety of the following + confirmationCounts[transactionId] = safe_sub (confirmationCounts[transactionId], 1); + emit Revocation (sender, transactionId); + return; + } + + function getConfirmationCount (uint transactionId) public + modifies[] + returns (uint) + { + return confirmationCounts[transactionId]; + } + + + function changeDailyLimit (uint _dailyLimit) public + modifies [dailyLimit, log] + { + dailyLimit = _dailyLimit; + emit DailyLimitChange (_dailyLimit); + return; + } + + function calcMaxWithdraw () public + tx_reverts (lastDay + 86400 > uint_max) + modifies [] + returns (uint) + { + uint ret; + uint endTime = safe_add (lastDay, 86400); + if (block.timestamp > endTime) // rewrite 24 hours as 86400 seconds + { + ret = dailyLimit; + } + else if (dailyLimit < spentToday) + { + ret = 0; + } + else + { + ret = dailyLimit - spentToday; + } + return ret; + } +} \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/contracts/Call.sol b/Celestial/Samples/ConsenSys/Multisig/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/contracts/Migrations.sol b/Celestial/Samples/ConsenSys/Multisig/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/ConsenSys/Multisig/contracts/Safe_Arith.sol b/Celestial/Samples/ConsenSys/Multisig/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/contracts/contract.sol b/Celestial/Samples/ConsenSys/Multisig/contracts/contract.sol new file mode 100644 index 00000000..cd9b5e29 --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/contracts/contract.sol @@ -0,0 +1,230 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract MultiSigWalletWithDailyLimit_Cel { + struct Transaction + { + address destination; + uint tval; + bool executed; + } + event Confirmation(address, uint); + event Revocation(address, uint); + event Submission(uint); + event Execution(uint); + event OwnerAddition(address); + event OwnerRemoval(address); + event RequirementChange(uint); + event DailyLimitChange(uint); + uint MAX_OWNER_COUNT = 50; + mapping (uint => Transaction) transactions; + mapping (uint => uint) confirmationCounts; + mapping (uint => mapping (address => bool)) confirmations; + mapping (address => bool) isOwner; + uint ownerCount; + uint required; + uint transactionCount; + bool walletActive; + bool tx_isConfirmed; + bool tx_isUnderLimit; + uint dailyLimit; + uint lastDay; + uint spentToday; + + receive () external payable { + return; + } + + constructor (address initial_owner, uint _required, uint _dailyLimit) public { + isOwner[initial_owner] = true; + ownerCount = 1; + required = _required; + MAX_OWNER_COUNT = 50; + dailyLimit = _dailyLimit; + return; + } + + function addOwner (address owner) public { + uint target_ownerCount = Safe_Arith.safe_add(ownerCount, 1); + if (isOwner[owner] || owner == address(0) || target_ownerCount > MAX_OWNER_COUNT) + { + revert ("Invalid owner addition"); + } + isOwner[owner] = true; + ownerCount = ownerCount + 1; + if (ownerCount >= required) + { + walletActive = true; + } + emit OwnerAddition(owner); + return; + } + + function removeOwner (address owner) public { + if (! isOwner[owner]) + { + revert ("Invalid owner removal"); + } + ownerCount = Safe_Arith.safe_sub(ownerCount, 1); + isOwner[owner] = false; + if (ownerCount < required) + { + walletActive = false; + } + emit OwnerRemoval(owner); + return; + } + + function replaceOwner (address owner, address newOwner) public { + if (! isOwner[owner] || isOwner[newOwner]) + { + revert ("Invalid owner replacement"); + } + isOwner[owner] = false; + isOwner[newOwner] = true; + emit OwnerRemoval(owner); + emit OwnerAddition(newOwner); + return; + } + + function changeRequirement (uint _required) public { + required = _required; + if (required > ownerCount) + { + walletActive = false; + } + emit RequirementChange(_required); + return; + } + + function addTransaction (address _destination, uint _val) private returns (uint transactionId) { + transactionId = transactionCount; + transactions[transactionId] = Transaction(_destination, _val, false); + confirmationCounts[transactionId] = 0; + emit Submission(transactionId); + return transactionId; + } + + function isConfirmed (uint transactionId) private returns (bool ret) { + if (confirmationCounts[transactionId] == required) + { + ret = true; + } + else + { + ret = false; + } + return ret; + } + + function isUnderLimit (uint _amount) private returns (bool ret) { + uint t = Safe_Arith.safe_add(lastDay, 86400); + if (block.timestamp > t) + { + lastDay = block.timestamp; + spentToday = 0; + } + if (_amount > (~uint256(0)) - spentToday) + { + ret = false; + } + else + if (! ret) + { + if (spentToday + _amount > dailyLimit) + { + ret = false; + } + else + { + ret = true; + } + } + return ret; + } + + function executeTransaction (uint transactionId) public { + if (transactionId >= transactionCount || transactions[transactionId].executed || address(this).balance < transactions[transactionId].tval) + { + revert ("invalid"); + } + Transaction storage trx = transactions[transactionId]; + tx_isConfirmed = isConfirmed(transactionId); + tx_isUnderLimit = isUnderLimit(trx.tval); + if (tx_isConfirmed || tx_isUnderLimit) + { + if (! tx_isConfirmed) + { + spentToday = spentToday + trx.tval; + } + transactions[transactionId].executed = true; + payable(transactions[transactionId].destination).transfer(trx.tval); + emit Execution(transactionId); + } + return; + } + + function confirmTransaction (uint transactionId) public { + if (! walletActive || ! isOwner[msg.sender] || transactionId >= transactionCount || confirmations[transactionId][msg.sender]) + { + revert ("invalid"); + } + confirmationCounts[transactionId] = Safe_Arith.safe_add(confirmationCounts[transactionId], 1); + confirmations[transactionId][msg.sender] = true; + emit Confirmation(msg.sender, transactionId); + executeTransaction(transactionId); + return; + } + + function submitTransaction (address _dest, uint _amount) public returns (uint transactionId) { + if (! walletActive || ! isOwner[msg.sender] || _dest == address(0)) + { + revert ("invalid"); + } + transactionId = addTransaction(_dest, _amount); + transactionCount = Safe_Arith.safe_add(transactionCount, 1); + return transactionId; + } + + function revokeConfirmation (uint transactionId) public { + if (! isOwner[msg.sender] || ! confirmations[transactionId][msg.sender] || transactionId > transactionCount || transactions[transactionId].executed) + { + revert ("Invalid"); + } + confirmations[transactionId][msg.sender] = false; + confirmationCounts[transactionId] = Safe_Arith.safe_sub(confirmationCounts[transactionId], 1); + emit Revocation(msg.sender, transactionId); + return; + } + + function getConfirmationCount (uint transactionId) public returns (uint) { + return confirmationCounts[transactionId]; + } + + function changeDailyLimit (uint _dailyLimit) public { + dailyLimit = _dailyLimit; + emit DailyLimitChange(_dailyLimit); + return; + } + + function calcMaxWithdraw () public returns (uint) { + uint ret; + uint endTime = Safe_Arith.safe_add(lastDay, 86400); + if (block.timestamp > endTime) + { + ret = dailyLimit; + } + else + if (dailyLimit < spentToday) + { + ret = 0; + } + else + { + ret = dailyLimit - spentToday; + } + return ret; + } +} \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/fstar/MultiSigWalletWithDailyLimit_Cel.fst b/Celestial/Samples/ConsenSys/Multisig/fstar/MultiSigWalletWithDailyLimit_Cel.fst new file mode 100644 index 00000000..526704ff --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/fstar/MultiSigWalletWithDailyLimit_Cel.fst @@ -0,0 +1,1422 @@ +(*Code generated by compiler*) + +module MultiSigWalletWithDailyLimit_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val multisigwalletwithdailylimit_cel_Confirmation : string +assume val multisigwalletwithdailylimit_cel_Revocation : string +assume val multisigwalletwithdailylimit_cel_Submission : string +assume val multisigwalletwithdailylimit_cel_Execution : string +assume val multisigwalletwithdailylimit_cel_OwnerAddition : string +assume val multisigwalletwithdailylimit_cel_OwnerRemoval : string +assume val multisigwalletwithdailylimit_cel_RequirementChange : string +assume val multisigwalletwithdailylimit_cel_DailyLimitChange : string +noeq type multisigwalletwithdailylimit_cel_Transaction = { + multisigwalletwithdailylimit_cel_destination : address; + multisigwalletwithdailylimit_cel_tval : uint; + multisigwalletwithdailylimit_cel_executed : bool +} + + +noeq type t_multisigwalletwithdailylimit_cel = { + multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT : uint; + multisigwalletwithdailylimit_cel_transactions : (m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }}); + multisigwalletwithdailylimit_cel_confirmationCounts : (m:(M.t uint uint lt){M.def_of m == 0}); + multisigwalletwithdailylimit_cel_confirmations : (m:(M.t uint (m:(M.t address bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)}); + multisigwalletwithdailylimit_cel_isOwner : (m:(M.t address bool lt){M.def_of m == false}); + multisigwalletwithdailylimit_cel_ownerCount : uint; + multisigwalletwithdailylimit_cel_required : uint; + multisigwalletwithdailylimit_cel_transactionCount : uint; + multisigwalletwithdailylimit_cel_walletActive : bool; + multisigwalletwithdailylimit_cel_tx_isConfirmed : bool; + multisigwalletwithdailylimit_cel_tx_isUnderLimit : bool; + multisigwalletwithdailylimit_cel_dailyLimit : uint; + multisigwalletwithdailylimit_cel_lastDay : uint; + multisigwalletwithdailylimit_cel_spentToday : uint; +} + +(* Contract address type, liveness, and field range macros *) + +type multisigwalletwithdailylimit_cel_address = contract t_multisigwalletwithdailylimit_cel +let multisigwalletwithdailylimit_cel_live (c:multisigwalletwithdailylimit_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract MultiSigWalletWithDailyLimit_Cel *) + +let multisigwalletwithdailylimit_cel_get_MAX_OWNER_COUNT (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT + +let multisigwalletwithdailylimit_cel_get_transactions (c:multisigwalletwithdailylimit_cel_address) +: StEth (m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }}) + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_transactions) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_transactions + +let multisigwalletwithdailylimit_cel_get_confirmationCounts (c:multisigwalletwithdailylimit_cel_address) +: StEth (m:(M.t uint uint lt){M.def_of m == 0}) + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_confirmationCounts) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_confirmationCounts + +let multisigwalletwithdailylimit_cel_get_confirmations (c:multisigwalletwithdailylimit_cel_address) +: StEth (m:(M.t uint (m:(M.t address bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)}) + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_confirmations) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_confirmations + +let multisigwalletwithdailylimit_cel_get_isOwner (c:multisigwalletwithdailylimit_cel_address) +: StEth (m:(M.t address bool lt){M.def_of m == false}) + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_isOwner) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_isOwner + +let multisigwalletwithdailylimit_cel_get_ownerCount (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_ownerCount) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_ownerCount + +let multisigwalletwithdailylimit_cel_get_required (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_required) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_required + +let multisigwalletwithdailylimit_cel_get_transactionCount (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_transactionCount) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_transactionCount + +let multisigwalletwithdailylimit_cel_get_walletActive (c:multisigwalletwithdailylimit_cel_address) +: StEth bool + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_walletActive) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_walletActive + +let multisigwalletwithdailylimit_cel_get_tx_isConfirmed (c:multisigwalletwithdailylimit_cel_address) +: StEth bool + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_tx_isConfirmed) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_tx_isConfirmed + +let multisigwalletwithdailylimit_cel_get_tx_isUnderLimit (c:multisigwalletwithdailylimit_cel_address) +: StEth bool + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_tx_isUnderLimit) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_tx_isUnderLimit + +let multisigwalletwithdailylimit_cel_get_dailyLimit (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_dailyLimit) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_dailyLimit + +let multisigwalletwithdailylimit_cel_get_lastDay (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_lastDay) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_lastDay + +let multisigwalletwithdailylimit_cel_get_spentToday (c:multisigwalletwithdailylimit_cel_address) +: StEth uint + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).multisigwalletwithdailylimit_cel_spentToday) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + multisigwalletwithdailylimit_cel_inst.multisigwalletwithdailylimit_cel_spentToday + +(* Field setters for contract MultiSigWalletWithDailyLimit_Cel *) + +let multisigwalletwithdailylimit_cel_set_MAX_OWNER_COUNT (c:multisigwalletwithdailylimit_cel_address) (_MAX_OWNER_COUNT:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _MAX_OWNER_COUNT >= 0 /\ _MAX_OWNER_COUNT <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT = _MAX_OWNER_COUNT })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT = _MAX_OWNER_COUNT } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_transactions (c:multisigwalletwithdailylimit_cel_address) (_transactions:(m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }})) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_transactions = _transactions })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_transactions = _transactions } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_confirmationCounts (c:multisigwalletwithdailylimit_cel_address) (_confirmationCounts:(m:(M.t uint uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_confirmationCounts = _confirmationCounts })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_confirmationCounts = _confirmationCounts } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_confirmations (c:multisigwalletwithdailylimit_cel_address) (_confirmations:(m:(M.t uint (m:(M.t address bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)})) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_confirmations = _confirmations })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_confirmations = _confirmations } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_isOwner (c:multisigwalletwithdailylimit_cel_address) (_isOwner:(m:(M.t address bool lt){M.def_of m == false})) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_isOwner = _isOwner })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_isOwner = _isOwner } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_ownerCount (c:multisigwalletwithdailylimit_cel_address) (_ownerCount:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _ownerCount >= 0 /\ _ownerCount <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_ownerCount = _ownerCount })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_ownerCount = _ownerCount } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_required (c:multisigwalletwithdailylimit_cel_address) (_required:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _required >= 0 /\ _required <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_required = _required })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_required = _required } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_transactionCount (c:multisigwalletwithdailylimit_cel_address) (_transactionCount:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _transactionCount >= 0 /\ _transactionCount <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_transactionCount = _transactionCount })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_transactionCount = _transactionCount } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_walletActive (c:multisigwalletwithdailylimit_cel_address) (_walletActive:bool) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_walletActive = _walletActive })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_walletActive = _walletActive } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_tx_isConfirmed (c:multisigwalletwithdailylimit_cel_address) (_tx_isConfirmed:bool) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_tx_isConfirmed = _tx_isConfirmed })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_tx_isConfirmed = _tx_isConfirmed } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_tx_isUnderLimit (c:multisigwalletwithdailylimit_cel_address) (_tx_isUnderLimit:bool) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_tx_isUnderLimit = _tx_isUnderLimit })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_tx_isUnderLimit = _tx_isUnderLimit } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_dailyLimit (c:multisigwalletwithdailylimit_cel_address) (_dailyLimit:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _dailyLimit >= 0 /\ _dailyLimit <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_dailyLimit = _dailyLimit })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_dailyLimit = _dailyLimit } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_lastDay (c:multisigwalletwithdailylimit_cel_address) (_lastDay:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _lastDay >= 0 /\ _lastDay <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_lastDay = _lastDay })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_lastDay = _lastDay } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let multisigwalletwithdailylimit_cel_set_spentToday (c:multisigwalletwithdailylimit_cel_address) (_spentToday:uint) +: StEth unit + (fun st -> c `multisigwalletwithdailylimit_cel_live` st.current + /\ _spentToday >= 0 /\ _spentToday <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + multisigwalletwithdailylimit_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with multisigwalletwithdailylimit_cel_spentToday = _spentToday })) += let multisigwalletwithdailylimit_cel_inst = get_contract c in + let multisigwalletwithdailylimit_cel_inst = { multisigwalletwithdailylimit_cel_inst with multisigwalletwithdailylimit_cel_spentToday = _spentToday } in + set_contract c multisigwalletwithdailylimit_cel_inst + +let walletActiveInv (self:multisigwalletwithdailylimit_cel_address) (bst:bstate{self `multisigwalletwithdailylimit_cel_live` bst}) : Type0 = + let multisigwalletwithdailylimit_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (cs.multisigwalletwithdailylimit_cel_walletActive ==> (cs.multisigwalletwithdailylimit_cel_required <= cs.multisigwalletwithdailylimit_cel_ownerCount)) + +let ownerCountInv (self:multisigwalletwithdailylimit_cel_address) (bst:bstate{self `multisigwalletwithdailylimit_cel_live` bst}) : Type0 = + let multisigwalletwithdailylimit_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.multisigwalletwithdailylimit_cel_ownerCount <= cs.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT + +let transactionCountInv (self:multisigwalletwithdailylimit_cel_address) (bst:bstate{self `multisigwalletwithdailylimit_cel_live` bst}) : Type0 = + let multisigwalletwithdailylimit_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (forall (i:uint). (((i < cs.multisigwalletwithdailylimit_cel_transactionCount) ==> ((M.contains cs.multisigwalletwithdailylimit_cel_transactions i))))) + + +let confirmationCountsInv (self:multisigwalletwithdailylimit_cel_address) (bst:bstate{self `multisigwalletwithdailylimit_cel_live` bst}) : Type0 = + let multisigwalletwithdailylimit_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (forall (i:uint). ((((M.contains cs.multisigwalletwithdailylimit_cel_transactions i)) ==> ((M.contains cs.multisigwalletwithdailylimit_cel_confirmationCounts i))))) + + +let receive (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + False) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +() + +let multisigwalletwithdailylimit_cel_constructor (self:multisigwalletwithdailylimit_cel_address) (sender:address) (value:uint) (tx:tx) (block:block) (initial_owner:address) (_required:uint) (_dailyLimit:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == 0) + /\ (cs.multisigwalletwithdailylimit_cel_transactions == M.const ({multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; })) + /\ (cs.multisigwalletwithdailylimit_cel_confirmationCounts == M.const (0)) + /\ (cs.multisigwalletwithdailylimit_cel_confirmations == M.const (M.const (false))) + /\ (cs.multisigwalletwithdailylimit_cel_isOwner == M.const (false)) + /\ (cs.multisigwalletwithdailylimit_cel_ownerCount == 0) + /\ (cs.multisigwalletwithdailylimit_cel_required == 0) + /\ (cs.multisigwalletwithdailylimit_cel_transactionCount == 0) + /\ (cs.multisigwalletwithdailylimit_cel_walletActive == false) + /\ (cs.multisigwalletwithdailylimit_cel_tx_isConfirmed == false) + /\ (cs.multisigwalletwithdailylimit_cel_tx_isUnderLimit == false) + /\ (cs.multisigwalletwithdailylimit_cel_dailyLimit == 0) + /\ (cs.multisigwalletwithdailylimit_cel_lastDay == 0) + /\ (cs.multisigwalletwithdailylimit_cel_spentToday == 0) + /\ (((initial_owner =!= null) /\ (_required > 0))) + ) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 + /\ (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let isOwner = cs.multisigwalletwithdailylimit_cel_isOwner in +let _ = multisigwalletwithdailylimit_cel_set_isOwner self (M.upd isOwner initial_owner true) in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_ownerCount self 1 in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_required self _required in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_MAX_OWNER_COUNT self 50 in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_dailyLimit self _dailyLimit in +let cs = get_contract self in +() + +let addOwnerReverts (_owner:address) (old_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (old_ownerCt:uint) (old_MAX_OWNER_COUNT:uint) += (((M.sel old_isOwner _owner) \/ (_owner == null)) \/ (((old_ownerCt + 1)) > uint_max)) \/ (((old_ownerCt + 1)) > old_MAX_OWNER_COUNT) + +let addOwnerPost (old_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (new_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (old_ownerCount:uint) (new_ownerCount:uint) (_required:uint) (old_walletActive:bool) (new_walletActive:bool) (_owner:address) += ((M.equal new_isOwner ( + let x1 = (old_isOwner) in + let x2 = (_owner) in + let x3 = (true) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (new_ownerCount == (old_ownerCount + 1))) /\ (if (new_ownerCount >= _required) then + (new_walletActive == true) +else + (new_walletActive == old_walletActive) +) + +let addOwner (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (owner:address) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((addOwnerReverts owner cs.multisigwalletwithdailylimit_cel_isOwner cs.multisigwalletwithdailylimit_cel_ownerCount cs.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT)) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ ((addOwnerPost cs0.multisigwalletwithdailylimit_cel_isOwner cs1.multisigwalletwithdailylimit_cel_isOwner cs0.multisigwalletwithdailylimit_cel_ownerCount cs1.multisigwalletwithdailylimit_cel_ownerCount cs0.multisigwalletwithdailylimit_cel_required cs0.multisigwalletwithdailylimit_cel_walletActive cs1.multisigwalletwithdailylimit_cel_walletActive owner)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let target_ownerCount:uint = ((if cs.multisigwalletwithdailylimit_cel_ownerCount <= uint_max - 1 then (cs.multisigwalletwithdailylimit_cel_ownerCount + 1) else revert "Overflow error")) in +let x1 = (((M.sel cs.multisigwalletwithdailylimit_cel_isOwner owner) || (owner = null)) || (target_ownerCount > cs.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT)) in +let _ = (if x1 then begin +revert "Invalid owner addition"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let isOwner = cs.multisigwalletwithdailylimit_cel_isOwner in +let _ = multisigwalletwithdailylimit_cel_set_isOwner self (M.upd isOwner owner true) in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_ownerCount self (_add cs.multisigwalletwithdailylimit_cel_ownerCount 1) in +let cs = get_contract self in +let x1 = (cs.multisigwalletwithdailylimit_cel_ownerCount >= cs.multisigwalletwithdailylimit_cel_required) in +let _ = (if x1 then begin +let _ = multisigwalletwithdailylimit_cel_set_walletActive self true in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit multisigwalletwithdailylimit_cel_OwnerAddition owner in +let cs = get_contract self in +let balance = get_balance self in +() + +let removeOwnerPost (_owner:address) (old_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (new_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (old_ownerCount:uint) (new_ownerCount:uint) (old_required:uint) (old_walletActive:bool) (new_walletActive:bool) += ((M.equal new_isOwner ( + let x1 = (old_isOwner) in + let x2 = (_owner) in + let x3 = (false) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (new_ownerCount == (old_ownerCount - 1))) /\ (if (new_ownerCount < old_required) then + (new_walletActive == false) +else + (new_walletActive == old_walletActive) +) + +let removeOwner (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (owner:address) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((~ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner owner))) \/ ((cs.multisigwalletwithdailylimit_cel_ownerCount == 0))) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ ((removeOwnerPost owner cs0.multisigwalletwithdailylimit_cel_isOwner cs1.multisigwalletwithdailylimit_cel_isOwner cs0.multisigwalletwithdailylimit_cel_ownerCount cs1.multisigwalletwithdailylimit_cel_ownerCount cs0.multisigwalletwithdailylimit_cel_required cs0.multisigwalletwithdailylimit_cel_walletActive cs1.multisigwalletwithdailylimit_cel_walletActive)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (op_Negation (M.sel cs.multisigwalletwithdailylimit_cel_isOwner owner)) then begin +revert "Invalid owner removal"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if 1 <= cs.multisigwalletwithdailylimit_cel_ownerCount then (cs.multisigwalletwithdailylimit_cel_ownerCount - 1) else revert "Underflow error")) in +let _ = multisigwalletwithdailylimit_cel_set_ownerCount self x1 in +let cs = get_contract self in +let isOwner = cs.multisigwalletwithdailylimit_cel_isOwner in +let _ = multisigwalletwithdailylimit_cel_set_isOwner self (M.upd isOwner owner false) in +let cs = get_contract self in +let _ = (if (cs.multisigwalletwithdailylimit_cel_ownerCount < cs.multisigwalletwithdailylimit_cel_required) then begin +let _ = multisigwalletwithdailylimit_cel_set_walletActive self false in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit multisigwalletwithdailylimit_cel_OwnerRemoval owner in +let cs = get_contract self in +let balance = get_balance self in +() + +let replaceOwnerPost (old_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (new_isOwner:(m:(M.t address bool lt){M.def_of m == false})) (_owner:address) (newOwner:address) += M.equal new_isOwner ( + let x1 = (old_isOwner) in + let x2 = (_owner) in + let x3 = (false) in + let x1 = (M.upd x1 x2 x3) in + let x2 = (newOwner) in + let x3 = (true) in + let x1 = (M.upd x1 x2 x3) in + x1) + +let replaceOwner (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (owner:address) (newOwner:address) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((~ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner owner)) \/ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner newOwner))) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ ((replaceOwnerPost cs0.multisigwalletwithdailylimit_cel_isOwner cs1.multisigwalletwithdailylimit_cel_isOwner owner newOwner)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((op_Negation (M.sel cs.multisigwalletwithdailylimit_cel_isOwner owner)) || (M.sel cs.multisigwalletwithdailylimit_cel_isOwner newOwner)) then begin +revert "Invalid owner replacement"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let isOwner = cs.multisigwalletwithdailylimit_cel_isOwner in +let _ = multisigwalletwithdailylimit_cel_set_isOwner self (M.upd isOwner owner false) in +let cs = get_contract self in +let isOwner = cs.multisigwalletwithdailylimit_cel_isOwner in +let _ = multisigwalletwithdailylimit_cel_set_isOwner self (M.upd isOwner newOwner true) in +let cs = get_contract self in +let _ = emit multisigwalletwithdailylimit_cel_OwnerRemoval owner in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit multisigwalletwithdailylimit_cel_OwnerAddition newOwner in +let cs = get_contract self in +let balance = get_balance self in +() + +let changeRequirementsPost (new_required:uint) (old_ownerCount:uint) (old_walletActive:bool) (new_walletActive:bool) += if (new_required > old_ownerCount) then + (new_walletActive == false) +else + (new_walletActive == old_walletActive) + + +let changeRequirement (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_required:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ ((changeRequirementsPost cs1.multisigwalletwithdailylimit_cel_required cs0.multisigwalletwithdailylimit_cel_ownerCount cs0.multisigwalletwithdailylimit_cel_walletActive cs1.multisigwalletwithdailylimit_cel_walletActive)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = multisigwalletwithdailylimit_cel_set_required self _required in +let cs = get_contract self in +let _ = (if (cs.multisigwalletwithdailylimit_cel_required > cs.multisigwalletwithdailylimit_cel_ownerCount) then begin +let _ = multisigwalletwithdailylimit_cel_set_walletActive self false in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit multisigwalletwithdailylimit_cel_RequirementChange _required in +let cs = get_contract self in +let balance = get_balance self in +() + +let addTransactionPost (old_transactions:(m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }})) (new_transactions:(m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }})) (_txId:uint) (_destination:address) (_val:uint) (old_confirmationCounts:(m:(M.t uint uint lt){M.def_of m == 0})) (new_confirmationCounts:(m:(M.t uint uint lt){M.def_of m == 0})) (old_transactionCount:uint) += ((M.equal new_transactions ( + let x1 = (old_transactions) in + let x2 = (_txId) in + let x3 = ({ multisigwalletwithdailylimit_cel_destination = _destination; multisigwalletwithdailylimit_cel_tval = _val; multisigwalletwithdailylimit_cel_executed = false; }) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (M.equal new_confirmationCounts ( + let x1 = (old_confirmationCounts) in + let x2 = (_txId) in + let x3 = (0) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (_txId == old_transactionCount) + +let addTransaction (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_destination:address) (_val:uint) +: Eth1 uint + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((_destination =!= null)) + )) + (fun bst -> False) + (fun bst0 transactionId bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((addTransactionPost cs0.multisigwalletwithdailylimit_cel_transactions cs1.multisigwalletwithdailylimit_cel_transactions transactionId _destination _val cs0.multisigwalletwithdailylimit_cel_confirmationCounts cs1.multisigwalletwithdailylimit_cel_confirmationCounts cs0.multisigwalletwithdailylimit_cel_transactionCount)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let transactionId:uint = 0 in +let cs = get_contract self in +let balance = get_balance self in +let transactionId = cs.multisigwalletwithdailylimit_cel_transactionCount in +let cs = get_contract self in +let x1 = ({ multisigwalletwithdailylimit_cel_destination = _destination; multisigwalletwithdailylimit_cel_tval = _val; multisigwalletwithdailylimit_cel_executed = false; }) in +let transactions = cs.multisigwalletwithdailylimit_cel_transactions in +let _ = multisigwalletwithdailylimit_cel_set_transactions self (M.upd transactions transactionId x1) in +let cs = get_contract self in +let confirmationCounts = cs.multisigwalletwithdailylimit_cel_confirmationCounts in +let _ = multisigwalletwithdailylimit_cel_set_confirmationCounts self (M.upd confirmationCounts transactionId 0) in +let cs = get_contract self in +let _ = emit multisigwalletwithdailylimit_cel_Submission transactionId in +let cs = get_contract self in +let balance = get_balance self in +transactionId + +let isConfirmedPost (old_confirmationCounts:(m:(M.t uint uint lt){M.def_of m == 0})) (_transactionId:uint) (old_required:uint) (_ret:bool) += (((_ret == true <==> (M.sel old_confirmationCounts _transactionId) == old_required))) /\ (((_ret == false <==> (M.sel old_confirmationCounts _transactionId) =!= old_required))) + +let isConfirmed (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (transactionId:uint) +: Eth1 bool + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst + ) + (fun bst -> False) + (fun bst0 ret bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((isConfirmedPost cs0.multisigwalletwithdailylimit_cel_confirmationCounts transactionId cs0.multisigwalletwithdailylimit_cel_required ret)) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let ret:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) = cs.multisigwalletwithdailylimit_cel_required) in +let ret = (if x1 then begin +let ret = true in +let cs = get_contract self in +ret end +else begin +let ret = false in +let cs = get_contract self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret + +let isUnderLimitPost (time:uint) (old_lastDay:uint) (new_lastDay:uint) (old_spentToday:uint) (new_spentToday:uint) (_amount:uint) (old_dailyLimit:uint) (_ret:bool) += (if (time > (old_lastDay + 86400)) then + ((new_lastDay == time) /\ (new_spentToday == 0)) +else + ((new_lastDay == old_lastDay) /\ (new_spentToday == old_spentToday)) +) /\ (if (((new_spentToday + _amount) > old_dailyLimit) || ((new_spentToday + _amount) > uint_max)) then + (_ret == false) +else + (_ret == true) +) + +let isUnderLimit (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_amount:uint) +: Eth1 bool + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst + ) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.multisigwalletwithdailylimit_cel_lastDay + 86400) > uint_max)) + ) + (fun bst0 ret bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((isUnderLimitPost block.timestamp cs0.multisigwalletwithdailylimit_cel_lastDay cs1.multisigwalletwithdailylimit_cel_lastDay cs0.multisigwalletwithdailylimit_cel_spentToday cs1.multisigwalletwithdailylimit_cel_spentToday _amount cs0.multisigwalletwithdailylimit_cel_dailyLimit ret)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let ret:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let t:uint = ((if cs.multisigwalletwithdailylimit_cel_lastDay <= uint_max - 86400 then (cs.multisigwalletwithdailylimit_cel_lastDay + 86400) else revert "Overflow error")) in +let ret = (if (block.timestamp > t) then begin +let _ = multisigwalletwithdailylimit_cel_set_lastDay self block.timestamp in +let cs = get_contract self in +let _ = multisigwalletwithdailylimit_cel_set_spentToday self 0 in +let cs = get_contract self in +ret end +else ret) in +let cs = get_contract self in +let balance = get_balance self in +let ret = (if (_amount > ((_sub uint_max cs.multisigwalletwithdailylimit_cel_spentToday))) then begin +let ret = false in +let cs = get_contract self in +ret end +else begin +let ret = (if (op_Negation (ret)) then begin +let ret = (if (((_add cs.multisigwalletwithdailylimit_cel_spentToday _amount)) > cs.multisigwalletwithdailylimit_cel_dailyLimit) then begin +let ret = false in +let cs = get_contract self in +ret end +else begin +let ret = true in +let cs = get_contract self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret end +else ret) in +let cs = get_contract self in +let balance = get_balance self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret + +let executeTransactionReverts (_transactionId:uint) (old_transactionCount:uint) (old_transactions:(m:(M.t uint multisigwalletwithdailylimit_cel_Transaction lt){M.def_of m == {multisigwalletwithdailylimit_cel_destination = null; multisigwalletwithdailylimit_cel_tval = 0; multisigwalletwithdailylimit_cel_executed = false; }})) (old_balance:uint) += ((_transactionId >= old_transactionCount) \/ ((M.sel old_transactions _transactionId).multisigwalletwithdailylimit_cel_executed)) \/ (old_balance < ((M.sel old_transactions _transactionId).multisigwalletwithdailylimit_cel_tval)) + +let executeTransaction (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (transactionId:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((cs.multisigwalletwithdailylimit_cel_lastDay + 86400) > uint_max)) \/ ((executeTransactionReverts transactionId cs.multisigwalletwithdailylimit_cel_transactionCount cs.multisigwalletwithdailylimit_cel_transactions b))) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ ((if ((M.sel cs0.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) = cs0.multisigwalletwithdailylimit_cel_required) then + (cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed == true) +else + (cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed == false) +) /\ ((if (cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed || cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) then + (((l1 == ((mk_event null multisigwalletwithdailylimit_cel_Execution transactionId)::(mk_event ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_destination) eTransfer ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval))::l0))) /\ ((M.equal cs1.multisigwalletwithdailylimit_cel_transactions ( + let x1 = (cs0.multisigwalletwithdailylimit_cel_transactions) in + let x2 = (transactionId) in + let x3 = ({ multisigwalletwithdailylimit_cel_destination = ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_destination); multisigwalletwithdailylimit_cel_tval = ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval); multisigwalletwithdailylimit_cel_executed = true; }) in + let x1 = (M.upd x1 x2 x3) in + x1)))) +else + ((l1 == l0) /\ (M.equal cs1.multisigwalletwithdailylimit_cel_transactions cs0.multisigwalletwithdailylimit_cel_transactions)) +))) + /\ (b1 <= b0) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (((transactionId >= cs.multisigwalletwithdailylimit_cel_transactionCount) || ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_executed)) || (balance < ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval))) in +let _ = (if x1 then begin +revert "invalid"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let trx:multisigwalletwithdailylimit_cel_Transaction = (M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId) in +let x1 = ((isConfirmed self self 0 tx block transactionId)) in +let _ = multisigwalletwithdailylimit_cel_set_tx_isConfirmed self x1 in +let cs = get_contract self in +let x1 = ((isUnderLimit self self 0 tx block trx.multisigwalletwithdailylimit_cel_tval)) in +let _ = multisigwalletwithdailylimit_cel_set_tx_isUnderLimit self x1 in +let cs = get_contract self in +let _ = (if (cs.multisigwalletwithdailylimit_cel_tx_isConfirmed || cs.multisigwalletwithdailylimit_cel_tx_isUnderLimit) then begin +let _ = (if (op_Negation (cs.multisigwalletwithdailylimit_cel_tx_isConfirmed)) then begin +let _ = multisigwalletwithdailylimit_cel_set_spentToday self (_add cs.multisigwalletwithdailylimit_cel_spentToday trx.multisigwalletwithdailylimit_cel_tval) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = true in +let x2 = cs.multisigwalletwithdailylimit_cel_transactions in +let x3 = transactionId in +let x4 = M.sel x2 x3 in +let x5 = M.upd x2 x3 ({x4 with multisigwalletwithdailylimit_cel_executed = x1}) in +let _ = multisigwalletwithdailylimit_cel_set_transactions self x5 in +let cs = get_contract self in +let _ = transfer self ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_destination) trx.multisigwalletwithdailylimit_cel_tval in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit multisigwalletwithdailylimit_cel_Execution transactionId in +let cs = get_contract self in +let balance = get_balance self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() + +let confirmTransaction (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (transactionId:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((((((((~ (cs.multisigwalletwithdailylimit_cel_walletActive)) \/ (~ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender))) \/ (transactionId >= cs.multisigwalletwithdailylimit_cel_transactionCount)) \/ (M.sel (M.sel cs.multisigwalletwithdailylimit_cel_confirmations transactionId) sender)) \/ (((M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) + 1) > uint_max)) \/ (b < ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval))) \/ ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_executed)) \/ ((cs.multisigwalletwithdailylimit_cel_lastDay + 86400) > uint_max))) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ (((M.equal cs1.multisigwalletwithdailylimit_cel_confirmationCounts ( + let x1 = (cs0.multisigwalletwithdailylimit_cel_confirmationCounts) in + let x2 = (transactionId) in + let x3 = ((M.sel cs0.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) + 1) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (M.equal cs1.multisigwalletwithdailylimit_cel_confirmations ( + let x1 = (cs0.multisigwalletwithdailylimit_cel_confirmations) in + let x2 = (transactionId) in + let x3 = ( + let x1 = (M.sel cs0.multisigwalletwithdailylimit_cel_confirmations transactionId) in + let x2 = (sender) in + let x3 = (true) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (if (((M.sel cs1.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) = cs0.multisigwalletwithdailylimit_cel_required) || cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) then + ((l1 == ((mk_event null multisigwalletwithdailylimit_cel_Execution transactionId)::(mk_event ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_destination) eTransfer ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval))::(mk_event null multisigwalletwithdailylimit_cel_Confirmation (sender, transactionId))::l0)) /\ (M.equal cs1.multisigwalletwithdailylimit_cel_transactions ( + let x1 = (cs0.multisigwalletwithdailylimit_cel_transactions) in + let x2 = (transactionId) in + let x3 = ({ multisigwalletwithdailylimit_cel_destination = ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_destination); multisigwalletwithdailylimit_cel_tval = ((M.sel cs0.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_tval); multisigwalletwithdailylimit_cel_executed = true; }) in + let x1 = (M.upd x1 x2 x3) in + x1))) +else + (M.equal cs1.multisigwalletwithdailylimit_cel_transactions cs0.multisigwalletwithdailylimit_cel_transactions) +)) + /\ (b1 <= b0) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((((op_Negation (cs.multisigwalletwithdailylimit_cel_walletActive)) || (op_Negation (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender))) || (transactionId >= cs.multisigwalletwithdailylimit_cel_transactionCount)) || (M.sel (M.sel cs.multisigwalletwithdailylimit_cel_confirmations transactionId) sender)) in +let _ = (if x1 then begin +revert "invalid"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if (M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) <= uint_max - 1 then ((M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) + 1) else revert "Overflow error")) in +let confirmationCounts = cs.multisigwalletwithdailylimit_cel_confirmationCounts in +let _ = multisigwalletwithdailylimit_cel_set_confirmationCounts self (M.upd confirmationCounts transactionId x1) in +let cs = get_contract self in +let x5 = (true) in +let x4 = cs.multisigwalletwithdailylimit_cel_confirmations in + +let x3 = (transactionId) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = multisigwalletwithdailylimit_cel_set_confirmations self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit multisigwalletwithdailylimit_cel_Confirmation (sender, transactionId) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (executeTransaction self self 0 tx block transactionId) in +let cs = get_contract self in +() + +let submitTransaction (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_dest:address) (_amount:uint) +: Eth1 uint + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((((~ (cs.multisigwalletwithdailylimit_cel_walletActive)) \/ (~ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender))) \/ (_dest == null)) \/ ((cs.multisigwalletwithdailylimit_cel_transactionCount + 1) > uint_max))) + ) + (fun bst0 transactionId bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 + /\ (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + ) += +let transactionId:uint = 0 in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (((op_Negation (cs.multisigwalletwithdailylimit_cel_walletActive)) || (op_Negation (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender))) || (_dest = null)) in +let transactionId = (if x1 then begin +revert "invalid"; +transactionId end +else transactionId) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((addTransaction self self 0 tx block _dest _amount)) in +let transactionId = x1 in +let cs = get_contract self in +let x1 = ((if cs.multisigwalletwithdailylimit_cel_transactionCount <= uint_max - 1 then (cs.multisigwalletwithdailylimit_cel_transactionCount + 1) else revert "Overflow error")) in +let _ = multisigwalletwithdailylimit_cel_set_transactionCount self x1 in +let cs = get_contract self in +transactionId + +let revokeConfirmation (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (transactionId:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + /\ (((M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) > 0)) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((((~ (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender)) \/ (~ (M.sel (M.sel cs.multisigwalletwithdailylimit_cel_confirmations transactionId) sender))) \/ (transactionId > cs.multisigwalletwithdailylimit_cel_transactionCount)) \/ ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_executed))) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_dailyLimit == cs1.multisigwalletwithdailylimit_cel_dailyLimit) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((((op_Negation (M.sel cs.multisigwalletwithdailylimit_cel_isOwner sender)) || (op_Negation (M.sel (M.sel cs.multisigwalletwithdailylimit_cel_confirmations transactionId) sender))) || (transactionId > cs.multisigwalletwithdailylimit_cel_transactionCount)) || ((M.sel cs.multisigwalletwithdailylimit_cel_transactions transactionId).multisigwalletwithdailylimit_cel_executed)) then begin +revert "Invalid"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x5 = (false) in +let x4 = cs.multisigwalletwithdailylimit_cel_confirmations in + +let x3 = (transactionId) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = multisigwalletwithdailylimit_cel_set_confirmations self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let x1 = ((if 1 <= (M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) then ((M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId) - 1) else revert "Underflow error")) in +let confirmationCounts = cs.multisigwalletwithdailylimit_cel_confirmationCounts in +let _ = multisigwalletwithdailylimit_cel_set_confirmationCounts self (M.upd confirmationCounts transactionId x1) in +let cs = get_contract self in +let _ = emit multisigwalletwithdailylimit_cel_Revocation (sender, transactionId) in +let cs = get_contract self in +let balance = get_balance self in +() + +let getConfirmationCount (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (transactionId:uint) +: Eth1 uint + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +M.sel cs.multisigwalletwithdailylimit_cel_confirmationCounts transactionId + +let changeDailyLimit (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_dailyLimit:uint) +: Eth1 unit + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0.multisigwalletwithdailylimit_cel_required == cs1.multisigwalletwithdailylimit_cel_required) + /\ (cs0.multisigwalletwithdailylimit_cel_ownerCount == cs1.multisigwalletwithdailylimit_cel_ownerCount) + /\ (cs0.multisigwalletwithdailylimit_cel_transactions == cs1.multisigwalletwithdailylimit_cel_transactions) + /\ (cs0.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT == cs1.multisigwalletwithdailylimit_cel_MAX_OWNER_COUNT) + /\ (cs0.multisigwalletwithdailylimit_cel_isOwner == cs1.multisigwalletwithdailylimit_cel_isOwner) + /\ (cs0.multisigwalletwithdailylimit_cel_walletActive == cs1.multisigwalletwithdailylimit_cel_walletActive) + /\ (cs0.multisigwalletwithdailylimit_cel_spentToday == cs1.multisigwalletwithdailylimit_cel_spentToday) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmations == cs1.multisigwalletwithdailylimit_cel_confirmations) + /\ (cs0.multisigwalletwithdailylimit_cel_transactionCount == cs1.multisigwalletwithdailylimit_cel_transactionCount) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isConfirmed == cs1.multisigwalletwithdailylimit_cel_tx_isConfirmed) + /\ (cs0.multisigwalletwithdailylimit_cel_confirmationCounts == cs1.multisigwalletwithdailylimit_cel_confirmationCounts) + /\ (cs0.multisigwalletwithdailylimit_cel_lastDay == cs1.multisigwalletwithdailylimit_cel_lastDay) + /\ (cs0.multisigwalletwithdailylimit_cel_tx_isUnderLimit == cs1.multisigwalletwithdailylimit_cel_tx_isUnderLimit) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = multisigwalletwithdailylimit_cel_set_dailyLimit self _dailyLimit in +let cs = get_contract self in +let _ = emit multisigwalletwithdailylimit_cel_DailyLimitChange _dailyLimit in +let cs = get_contract self in +let balance = get_balance self in +() + +let calcMaxWithdraw (self:multisigwalletwithdailylimit_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 uint + (fun bst -> + multisigwalletwithdailylimit_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (walletActiveInv self bst) + /\ (ownerCountInv self bst) + /\ (transactionCountInv self bst) + /\ (confirmationCountsInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.multisigwalletwithdailylimit_cel_lastDay + 86400) > uint_max)) + ) + (fun bst0 x bst1 -> + multisigwalletwithdailylimit_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (walletActiveInv self bst1) + /\ (ownerCountInv self bst1) + /\ (transactionCountInv self bst1) + /\ (confirmationCountsInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +let ret:uint = (0) in +let endTime:uint = ((if cs.multisigwalletwithdailylimit_cel_lastDay <= uint_max - 86400 then (cs.multisigwalletwithdailylimit_cel_lastDay + 86400) else revert "Overflow error")) in +let _ = (if (block.timestamp > endTime) then begin +let ret = cs.multisigwalletwithdailylimit_cel_dailyLimit in +let cs = get_contract self in +() end +else begin +let _ = (if (cs.multisigwalletwithdailylimit_cel_dailyLimit < cs.multisigwalletwithdailylimit_cel_spentToday) then begin +let ret = 0 in +let cs = get_contract self in +() end +else begin +let ret = (_sub cs.multisigwalletwithdailylimit_cel_dailyLimit cs.multisigwalletwithdailylimit_cel_spentToday) in +let cs = get_contract self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +() end) in +let cs = get_contract self in +let balance = get_contract self in +ret \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/migrations/1_initial_migration.js b/Celestial/Samples/ConsenSys/Multisig/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/ConsenSys/Multisig/result.csv b/Celestial/Samples/ConsenSys/Multisig/result.csv new file mode 100644 index 00000000..4fb56e7b --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/result.csv @@ -0,0 +1,7 @@ +Method,Celestial Gas,Solidity Gas +Deployment,2551683,2147351 +addOwner,57577,73358 +removeOwner,24085,25936 +replaceOwner,38108,55471 +changeRequirement,29161,28574 +Tx-approval,306667,223075 diff --git a/Celestial/Samples/ConsenSys/Multisig/test/multisig.js b/Celestial/Samples/ConsenSys/Multisig/test/multisig.js new file mode 100644 index 00000000..979b5932 --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/test/multisig.js @@ -0,0 +1,149 @@ +const createCsvWriter = require('csv-writer').createObjectCsvWriter; +const csvWriter = createCsvWriter({ + path: 'result.csv', + header: [ + {id: 'method', title: 'Method'}, + {id: 'cel_gas', title: 'Celestial Gas'}, + {id: 'sol_gas', title: 'Solidity Gas'}, + ] + }); +const MultiSig = artifacts.require("MultiSigWalletWithDailyLimit"); +const Safe_Arith = artifacts.require("Safe_Arith"); +const MultiSig_cel = artifacts.require("MultiSigWalletWithDailyLimit_Cel"); + +contract("Consensys MultiSig evaluation", async accounts => { + it("Evaluating Solidity and Celestial versions of Consensys MultiSig for gas consumption", async () => { + + let owner1 = accounts[0]; + let owner2 = accounts[1]; + let owner3 = accounts[2]; + let owner4 = accounts[3]; + let owner5 = accounts[4]; + + let daily_limit = 10; + + let required = 3; + let new_required = 2; + + let tx_destination = accounts[5]; // arbitrary destination address + let tx_val = 100; + + // get data for original AssetTransfer + console.log(".Creating and deploying MultiSig"); + let instance = await MultiSig.new([owner1, owner2, owner3], required, daily_limit); // constructor + console.log("..Getting deployment receipt"); + let deploymentReceipt = await web3.eth.getTransactionReceipt(instance.transactionHash); + var deploymentGas = parseInt(deploymentReceipt.gasUsed); // retrieve gas needed for deployment + + console.log(".Sending ether"); + instance.send(1000, {from:accounts[6]}); + + console.log(".Adding Owner"); + let tx = await instance.addOwner(owner4); + var addOwnerGas = tx.receipt.gasUsed; + + console.log(".Replace Owner"); + tx = await instance.replaceOwner(owner4, owner5); + var replaceOwnerGas = tx.receipt.gasUsed; + + console.log(".Change Requirements"); + tx = await instance.changeRequirement(new_required); + var changeRequirementGas = tx.receipt.gasUsed; + + console.log(".Remove Owner"); + tx = await instance.removeOwner(owner5); + var removeOwnerGas = tx.receipt.gasUsed; + + console.log(".Submit Transaction"); + tx = await instance.submitTransaction(tx_destination, tx_val, {from:owner1}); + var txApproveGas = tx.receipt.gasUsed; + + console.log(".Confirm Transaction"); + tx = await instance.confirmTransaction(0, {from:owner2}); + txApproveGas += tx.receipt.gasUsed; + + // get data for Celestial MultiSig + console.log(".Creating and Deploying Celestial MultiSig"); + let instance_cel = await Safe_Arith.new(); + let libraryReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + var libraryGas_cel = parseInt(libraryReceipt_cel.gasUsed); + await MultiSig_cel.link("Safe_Arith", instance_cel.address); + instance_cel = await MultiSig_cel.new(owner1, required, daily_limit); + let deploymentReceipt_cel = await web3.eth.getTransactionReceipt(instance.transactionHash); + let contractAddress_cel = instance_cel.address // address where the contract is deployed (needed because there is a weird modifier that says sender should be equal to address(this) -- private?) + var deploymentGas_cel = parseInt(deploymentReceipt_cel.gasUsed) + libraryGas_cel; // retrieve gas needed for deployment + + tx = await instance_cel.addOwner(owner2); + deploymentGas_cel += tx.receipt.gasUsed; + + tx = await instance_cel.addOwner(owner3); + deploymentGas_cel += tx.receipt.gasUsed; + + console.log(".Sending ether"); + instance_cel.send(1000, {from:accounts[6]}); + + console.log(".Celestial Adding owner"); + tx = await instance_cel.addOwner(owner4); + var addOwnerGas_cel = tx.receipt.gasUsed; + + console.log(".Celestial Replacing owner"); + tx = await instance_cel.replaceOwner(owner4, owner5); + var replaceOwnerGas_cel = tx.receipt.gasUsed; + + console.log(".Celestial Changing Requirement"); + tx = await instance_cel.changeRequirement(new_required); + var changeRequirementGas_cel = tx.receipt.gasUsed; + + console.log(".Celestial Removing owner"); + tx = await instance_cel.removeOwner(owner5); + var removeOwnerGas_cel = tx.receipt.gasUsed; + + console.log(".Celestial Submitting Transaction"); + tx = await instance_cel.submitTransaction(tx_destination, tx_val, {from:owner1}); + var txApproveGas_cel = tx.receipt.gasUsed; + + tx = await instance_cel.confirmTransaction(0, {from:owner1}); + txApproveGas_cel += tx.receipt.gasUsed; + + console.log(".Celestial Confirming transaction"); + tx = await instance_cel.confirmTransaction(0, {from:owner2}); + txApproveGas_cel += tx.receipt.gasUsed; + + // dump results to csv + const data = [ + { + method: 'Deployment', + cel_gas: deploymentGas_cel, + sol_gas: deploymentGas, + }, + { + method: 'addOwner', + cel_gas: addOwnerGas_cel, + sol_gas: addOwnerGas, + }, + { + method: 'removeOwner', + cel_gas: removeOwnerGas_cel, + sol_gas: removeOwnerGas, + }, + { + method: 'replaceOwner', + cel_gas: replaceOwnerGas_cel, + sol_gas: replaceOwnerGas, + }, + { + method: 'changeRequirement', + cel_gas: changeRequirementGas_cel, + sol_gas: changeRequirementGas, + }, + { + method: 'Tx-approval', + cel_gas: txApproveGas_cel, + sol_gas: txApproveGas, + } + ]; + + csvWriter + .writeRecords(data) + .then(()=> console.log('The CSV file was written successfully')); + })}); \ No newline at end of file diff --git a/Celestial/Samples/ConsenSys/Multisig/truffle-config.js b/Celestial/Samples/ConsenSys/Multisig/truffle-config.js new file mode 100644 index 00000000..08496a0c --- /dev/null +++ b/Celestial/Samples/ConsenSys/Multisig/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + version: "0.6.8" // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/EtherDelta/README.md b/Celestial/Samples/EtherDelta/README.md new file mode 100644 index 00000000..ad3539a7 --- /dev/null +++ b/Celestial/Samples/EtherDelta/README.md @@ -0,0 +1,8 @@ +# EtherDelta + +[Original contract](https://etherscan.io/address/0x8d12a197cb00d4747a1fe03395095ce2a5cc6819#code) + +In Token1.fst, the following predicate should be conjuncted (`/\`) to the post conditions of `token1_constructor`, `transfer` and `transferFrom` methods since we don't want to support a `modifies_addresses` clause at the Celestial level: +``` +(modifies_cmap_only (Set.singleton self) bst0 bst1) +``` \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/celestial/EtherDelta.cel b/Celestial/Samples/EtherDelta/celestial/EtherDelta.cel new file mode 100644 index 00000000..3110cc33 --- /dev/null +++ b/Celestial/Samples/EtherDelta/celestial/EtherDelta.cel @@ -0,0 +1,360 @@ +pragma solidity^0.6.8; + +import {Safe_Arith} from "./Safe_Arith.sol"; +import {Call} from "./Call.sol" ; + +contract EtherDelta_Cel +{ + address admin; //the admin address + address feeAccount; //the account that will receive fees + address accountLevelsAddr; + uint feeMake; //percentage times (1 ether) + uint feeTake; //percentage times (1 ether) + uint feeRebate; //percentage times (1 ether) + mapping (address => mapping (address => uint)) tokens; //mapping of token addresses to mapping of account balances (token=0 means Ether) + mapping (address => mapping (bytes32 => bool)) orders; + mapping (address => mapping (bytes32 => uint)) orderFills; //mapping of user accounts to mapping of order hashes to uints (amount of order that has been filled) + event Deposit(address, address, uint, uint); + event Withdraw(address, address, uint, uint); + event Order(address, uint, address, uint, uint, uint, address); + event Cancel(address, uint, address, uint, uint, uint, address, uint8, bytes32, bytes32); + event Trade(address, uint, address, uint, address, address); + + uint totalBalance; + bool _lock_; + + using Call for address; + + invariant eth_balances2 { + balance == totalBalance + } + + invariant eth_balances { + totalBalance >= sum_mapping(tokens[null]) + } + + constructor (address admin_, address feeAccount_, uint feeMake_, uint feeTake_, uint feeRebate_) + pre (balance == 0) + { + admin = admin_; + feeAccount = feeAccount_; + feeMake = feeMake_; + feeTake = feeTake_; + feeRebate = feeRebate_; + return; + } + + fallback () { + revert (""); + return; + } + + function changeAdmin (address admin_) public + post (new(admin) == admin_) + tx_reverts (sender != admin) + r_reverts _lock_ + modifies [admin] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (sender != admin) + { + revert (""); + } + + admin = admin_; + return; + } + + function changeFeeAccount (address feeAccount_) public + tx_reverts (sender != admin) + r_reverts _lock_ + modifies [feeAccount] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (sender != admin) + { + revert (""); + } + + feeAccount = feeAccount_; + return; + } + + function changeFeeMake (uint feeMake_) public + post new(feeMake) == feeMake_ + tx_reverts (sender != admin || feeMake_ > feeMake) + r_reverts _lock_ + modifies [feeMake] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (sender != admin || feeMake_ > feeMake) + { + revert (""); + } + + feeMake = feeMake_; + return; + } + + function changeFeeTake (uint feeTake_) public + post new(feeTake) == feeTake_ + tx_reverts (sender != admin || feeTake_ > feeTake || feeTake_ < feeRebate) + r_reverts _lock_ + modifies [feeTake] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (sender != admin || feeTake_ > feeTake || feeTake_ < feeRebate) { + revert (""); + } + + feeTake = feeTake_; + return; + } + + function changeFeeRebate (uint feeRebate_) public + post new(feeRebate) == feeRebate_ + tx_reverts (sender != admin || feeRebate_ < feeRebate || feeRebate_ > feeTake) + r_reverts _lock_ + modifies [feeRebate] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (sender != admin || feeRebate_ < feeRebate || feeRebate_ > feeTake) + { + revert("invalid"); + } + + feeRebate = feeRebate_; + return; + } + + function deposit () public + post (new(tokens) == tokens[null => tokens[null][sender => (tokens[null][sender] + value)]]) + && (new(totalBalance) == totalBalance + value) + credit + tx_reverts (totalBalance + value > uint_max) + r_reverts _lock_ + modifies [tokens, totalBalance, log] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + totalBalance = safe_add(totalBalance, value); + tokens[null][sender] = tokens[null][sender] + value; + emit Deposit (null, sender, value, tokens[null][sender]); + return; + } + + function withdraw (uint amount) public + post (new(tokens) == tokens[null => tokens[null][sender => tokens[null][sender] - amount]]) + && new(log) == (Withdraw, null, sender, amount, new(tokens)[null][sender])::(sender, eTransfer, amount)::log + debit + tx_reverts (tokens[null][sender] < amount) + r_reverts _lock_ + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (tokens[null][sender] < amount) + { + revert ("Insufficient balance"); + } + + sender.transfer(amount); + if (balance == totalBalance) + { + revert ("Ether sent to self"); + } + + tokens[null][sender] = tokens[null][sender] - amount; + totalBalance = totalBalance - amount; + emit Withdraw (null, sender, amount, tokens[null][sender]); + return; + } + + function depositToken (address token, uint amount) public + post new(tokens) == tokens[token => tokens[token][sender => tokens[token][sender] + amount]] + tx_reverts token == null || tokens[token][sender] + amount > uint_max + r_reverts _lock_ + modifies [tokens, totalBalance, balance, log, _lock_] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (token == null || amount > uint_max - tokens[token][sender]) + { + revert ("Invalid token type or overflow"); + } + + _lock_ = true; + bool tokenTxStatus = token.call_bool(abi.encodeWithSignature("transferFrom(address,address,uint)", sender, address(this), amount)); + _lock_ = false; + if (tokenTxStatus == false) + { + revert (""); + } + + // The .call may have increased our balance + if (totalBalance != balance) + { + revert ("Unexpected Ether transferred to self"); + } + totalBalance = balance; + + tokens[token][sender] = tokens[token][sender] + amount; + emit Deposit (token, sender, amount, tokens[token][sender]); + return; + } + + function withdrawToken (address token, uint amount) + post (new(tokens) == tokens[token => tokens[token][sender => tokens[token][sender] - amount]]) + tx_reverts token == null || tokens[token][sender] < amount + r_reverts _lock_ + modifies[tokens, totalBalance, balance, log, _lock_] + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + + if (token == null || tokens[token][sender] < amount) + { + revert ("Invalid token type or overflow"); + } + + _lock_ = true; + bool tokenTxStatus = token.call_bool(abi.encodeWithSignature("transfer(address,uint)", sender, amount)); + _lock_ = false; + if (tokenTxStatus == false) + { + revert (""); + } + + // The .call may have increased our balance + if (totalBalance != balance) + { + revert ("Unexpected Ether transferred to self"); + } + totalBalance = balance; + + tokens[token][sender] = tokens[token][sender] - amount; + emit Withdraw (sender, token, amount, tokens[token][sender]); + return; + } + + function balanceOf (address token, address user) + r_reverts _lock_ + returns (uint) + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + return tokens[token][user]; + } + + function order (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) + r_reverts _lock_ + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256 (abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + orders[sender][hash] = true; + emit Order (tokenGet, amountGet, tokenGive, amountGive, expires, nonce, sender); + return; + } + + function availableVolume(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) + r_reverts _lock_ + modifies [] + returns (uint ret) + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + uint available1; + uint available2; + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + if (!( + (orders[user][hash] || ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s) == user) + && block.number <= expires + )) { + ret = 0; + } + else + { + if (amountGive == 0) revert ("Divide by 0"); + available1 = safe_sub(amountGet, orderFills[user][hash]); + available2 = safe_mul(tokens[tokenGive][user], amountGet) / amountGive; + if (available1= amount + && availableVol >= amount + )) ret = false; + else ret = true; + return ret; + } + + + function amountFilled (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) + r_reverts _lock_ + returns (uint) + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + return orderFills[user][hash]; + } + + function cancelOrder(address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) + r_reverts _lock_ + { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + if (!(orders[sender][hash] || ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),v,r,s) == sender)) revert (""); + orderFills[sender][hash] = amountGet; + emit Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, sender, v, r, s); + return; + } + +} \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/contracts/Call.sol b/Celestial/Samples/EtherDelta/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/EtherDelta/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/contracts/Migrations.sol b/Celestial/Samples/EtherDelta/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/EtherDelta/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/EtherDelta/contracts/Safe_Arith.sol b/Celestial/Samples/EtherDelta/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/EtherDelta/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/contracts/contract.sol b/Celestial/Samples/EtherDelta/contracts/contract.sol new file mode 100644 index 00000000..8c9ac0dc --- /dev/null +++ b/Celestial/Samples/EtherDelta/contracts/contract.sol @@ -0,0 +1,267 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; +import { Call } from "./Call.sol" ; + +contract EtherDelta_Cel { + event Deposit(address, address, uint, uint); + event Withdraw(address, address, uint, uint); + event Order(address, uint, address, uint, uint, uint, address); + event Cancel(address, uint, address, uint, uint, uint, address, uint8, bytes32, bytes32); + event Trade(address, uint, address, uint, address, address); + address admin; + address feeAccount; + address accountLevelsAddr; + uint feeMake; + uint feeTake; + uint feeRebate; + mapping (address => mapping (address => uint)) tokens; + mapping (address => mapping (bytes32 => bool)) orders; + mapping (address => mapping (bytes32 => uint)) orderFills; + uint totalBalance; + bool _lock_; + using Call for address ; + + constructor (address admin_, address feeAccount_, uint feeMake_, uint feeTake_, uint feeRebate_) public { + admin = admin_; + feeAccount = feeAccount_; + feeMake = feeMake_; + feeTake = feeTake_; + feeRebate = feeRebate_; + return; + } + + fallback () external { + revert (""); + return; + } + + function changeAdmin (address admin_) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (msg.sender != admin) + { + revert (""); + } + admin = admin_; + return; + } + + function changeFeeAccount (address feeAccount_) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (msg.sender != admin) + { + revert (""); + } + feeAccount = feeAccount_; + return; + } + + function changeFeeMake (uint feeMake_) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (msg.sender != admin || feeMake_ > feeMake) + { + revert (""); + } + feeMake = feeMake_; + return; + } + + function changeFeeTake (uint feeTake_) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (msg.sender != admin || feeTake_ > feeTake || feeTake_ < feeRebate) + { + revert (""); + } + feeTake = feeTake_; + return; + } + + function changeFeeRebate (uint feeRebate_) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (msg.sender != admin || feeRebate_ < feeRebate || feeRebate_ > feeTake) + { + revert ("invalid"); + } + feeRebate = feeRebate_; + return; + } + + function deposit () public payable { + if (_lock_) + { + revert ("Reentrancy detected"); + } + totalBalance = Safe_Arith.safe_add(totalBalance, msg.value); + tokens[address(0)][msg.sender] = tokens[address(0)][msg.sender] + msg.value; + emit Deposit(address(0), msg.sender, msg.value, tokens[address(0)][msg.sender]); + return; + } + + function withdraw (uint amount) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (tokens[address(0)][msg.sender] < amount) + { + revert ("Insufficient balance"); + } + msg.sender.transfer(amount); + if (address(this).balance == totalBalance) + { + revert ("Ether sent to self"); + } + tokens[address(0)][msg.sender] = tokens[address(0)][msg.sender] - amount; + totalBalance = totalBalance - amount; + emit Withdraw(address(0), msg.sender, amount, tokens[address(0)][msg.sender]); + return; + } + + function depositToken (address token, uint amount) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (token == address(0) || amount > (~uint256(0)) - tokens[token][msg.sender]) + { + revert ("Invalid token type or overflow"); + } + _lock_ = true; + bool tokenTxStatus = token.call_bool(abi.encodeWithSignature("transferFrom(address,address,uint)", msg.sender, address(this), amount)); + _lock_ = false; + if (tokenTxStatus == false) + { + revert (""); + } + if (totalBalance != address(this).balance) + { + revert ("Unexpected Ether transferred to self"); + } + totalBalance = address(this).balance; + tokens[token][msg.sender] = tokens[token][msg.sender] + amount; + emit Deposit(token, msg.sender, amount, tokens[token][msg.sender]); + return; + } + + function withdrawToken (address token, uint amount) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + if (token == address(0) || tokens[token][msg.sender] < amount) + { + revert ("Invalid token type or overflow"); + } + _lock_ = true; + bool tokenTxStatus = token.call_bool(abi.encodeWithSignature("transfer(address,uint)", msg.sender, amount)); + _lock_ = false; + if (tokenTxStatus == false) + { + revert (""); + } + if (totalBalance != address(this).balance) + { + revert ("Unexpected Ether transferred to self"); + } + totalBalance = address(this).balance; + tokens[token][msg.sender] = tokens[token][msg.sender] - amount; + emit Withdraw(msg.sender, token, amount, tokens[token][msg.sender]); + return; + } + + function balanceOf (address token, address user) public returns (uint) { + if (_lock_) + { + revert ("Reentrancy detected"); + } + return tokens[token][user]; + } + + function order (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + orders[msg.sender][hash] = true; + emit Order(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender); + return; + } + + function availableVolume (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) public returns (uint ret) { + if (_lock_) + { + revert ("Reentrancy detected"); + } + uint available1; + uint available2; + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + if (! ((orders[user][hash] || ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s) == user) && block.number <= expires)) + { + ret = 0; + } + else + { + if (amountGive == 0) + revert ("Divide by 0"); + available1 = Safe_Arith.safe_sub(amountGet, orderFills[user][hash]); + available2 = Safe_Arith.safe_mul(tokens[tokenGive][user], amountGet) / amountGive; + if (available1 < available2) + ret = available1; + else + ret = available2; + } + return ret; + } + + function testTrade (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s, uint amount, address _sender) public returns (bool ret) { + if (_lock_) + { + revert ("Reentrancy detected"); + } + uint availableVol = availableVolume(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, user, v, r, s); + if (! (tokens[tokenGet][_sender] >= amount && availableVol >= amount)) + ret = false; + else + ret = true; + return ret; + } + + function amountFilled (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, address user, uint8 v, bytes32 r, bytes32 s) public returns (uint) { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + return orderFills[user][hash]; + } + + function cancelOrder (address tokenGet, uint amountGet, address tokenGive, uint amountGive, uint expires, uint nonce, uint8 v, bytes32 r, bytes32 s) public { + if (_lock_) + { + revert ("Reentrancy detected"); + } + bytes32 hash = sha256(abi.encodePacked(this, tokenGet, amountGet, tokenGive, amountGive, expires, nonce)); + if (! (orders[msg.sender][hash] || ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)), v, r, s) == msg.sender)) + revert (""); + orderFills[msg.sender][hash] = amountGet; + emit Cancel(tokenGet, amountGet, tokenGive, amountGive, expires, nonce, msg.sender, v, r, s); + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/fstar/EtherDelta_Cel.fst b/Celestial/Samples/EtherDelta/fstar/EtherDelta_Cel.fst new file mode 100644 index 00000000..e2114df1 --- /dev/null +++ b/Celestial/Samples/EtherDelta/fstar/EtherDelta_Cel.fst @@ -0,0 +1,1306 @@ +(*Code generated by compiler*) + +module EtherDelta_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val etherdelta_cel_Deposit : string +assume val etherdelta_cel_Withdraw : string +assume val etherdelta_cel_Order : string +assume val etherdelta_cel_Cancel : string +assume val etherdelta_cel_Trade : string + +noeq type t_etherdelta_cel = { + etherdelta_cel_admin : address; + etherdelta_cel_feeAccount : address; + etherdelta_cel_accountLevelsAddr : address; + etherdelta_cel_feeMake : uint; + etherdelta_cel_feeTake : uint; + etherdelta_cel_feeRebate : uint; + etherdelta_cel_tokens : (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}); + etherdelta_cel_orders : (m:(M.t address (m:(M.t bytes32 bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)}); + etherdelta_cel_orderFills : (m:(M.t address (m:(M.t bytes32 uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}); + etherdelta_cel_totalBalance : uint; + etherdelta_cel__lock_ : bool; +} + +(* Contract address type, liveness, and field range macros *) + +type etherdelta_cel_address = contract t_etherdelta_cel +let etherdelta_cel_live (c:etherdelta_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract EtherDelta_Cel *) + +let etherdelta_cel_get_admin (c:etherdelta_cel_address) +: StEth address + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_admin) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_admin + +let etherdelta_cel_get_feeAccount (c:etherdelta_cel_address) +: StEth address + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_feeAccount) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_feeAccount + +let etherdelta_cel_get_accountLevelsAddr (c:etherdelta_cel_address) +: StEth address + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_accountLevelsAddr) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_accountLevelsAddr + +let etherdelta_cel_get_feeMake (c:etherdelta_cel_address) +: StEth uint + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_feeMake) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_feeMake + +let etherdelta_cel_get_feeTake (c:etherdelta_cel_address) +: StEth uint + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_feeTake) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_feeTake + +let etherdelta_cel_get_feeRebate (c:etherdelta_cel_address) +: StEth uint + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_feeRebate) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_feeRebate + +let etherdelta_cel_get_tokens (c:etherdelta_cel_address) +: StEth (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}) + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_tokens) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_tokens + +let etherdelta_cel_get_orders (c:etherdelta_cel_address) +: StEth (m:(M.t address (m:(M.t bytes32 bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)}) + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_orders) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_orders + +let etherdelta_cel_get_orderFills (c:etherdelta_cel_address) +: StEth (m:(M.t address (m:(M.t bytes32 uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}) + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_orderFills) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_orderFills + +let etherdelta_cel_get_totalBalance (c:etherdelta_cel_address) +: StEth uint + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel_totalBalance) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel_totalBalance + +let etherdelta_cel_get__lock_ (c:etherdelta_cel_address) +: StEth bool + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).etherdelta_cel__lock_) += let etherdelta_cel_inst = get_contract c in + etherdelta_cel_inst.etherdelta_cel__lock_ + +(* Field setters for contract EtherDelta_Cel *) + +let etherdelta_cel_set_admin (c:etherdelta_cel_address) (_admin:address) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_admin = _admin })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_admin = _admin } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_feeAccount (c:etherdelta_cel_address) (_feeAccount:address) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_feeAccount = _feeAccount })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_feeAccount = _feeAccount } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_accountLevelsAddr (c:etherdelta_cel_address) (_accountLevelsAddr:address) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_accountLevelsAddr = _accountLevelsAddr })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_accountLevelsAddr = _accountLevelsAddr } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_feeMake (c:etherdelta_cel_address) (_feeMake:uint) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current + /\ _feeMake >= 0 /\ _feeMake <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_feeMake = _feeMake })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_feeMake = _feeMake } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_feeTake (c:etherdelta_cel_address) (_feeTake:uint) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current + /\ _feeTake >= 0 /\ _feeTake <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_feeTake = _feeTake })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_feeTake = _feeTake } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_feeRebate (c:etherdelta_cel_address) (_feeRebate:uint) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current + /\ _feeRebate >= 0 /\ _feeRebate <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_feeRebate = _feeRebate })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_feeRebate = _feeRebate } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_tokens (c:etherdelta_cel_address) (_tokens:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_tokens = _tokens })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_tokens = _tokens } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_orders (c:etherdelta_cel_address) (_orders:(m:(M.t address (m:(M.t bytes32 bool lt){M.def_of m == false}) lt){M.def_of m == M.const (false)})) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_orders = _orders })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_orders = _orders } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_orderFills (c:etherdelta_cel_address) (_orderFills:(m:(M.t address (m:(M.t bytes32 uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_orderFills = _orderFills })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_orderFills = _orderFills } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set_totalBalance (c:etherdelta_cel_address) (_totalBalance:uint) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current + /\ _totalBalance >= 0 /\ _totalBalance <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel_totalBalance = _totalBalance })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel_totalBalance = _totalBalance } in + set_contract c etherdelta_cel_inst + +let etherdelta_cel_set__lock_ (c:etherdelta_cel_address) (__lock_:bool) +: StEth unit + (fun st -> c `etherdelta_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + etherdelta_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with etherdelta_cel__lock_ = __lock_ })) += let etherdelta_cel_inst = get_contract c in + let etherdelta_cel_inst = { etherdelta_cel_inst with etherdelta_cel__lock_ = __lock_ } in + set_contract c etherdelta_cel_inst + +let eth_balances2 (self:etherdelta_cel_address) (bst:bstate{self `etherdelta_cel_live` bst}) : Type0 = + let etherdelta_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + etherdelta_cel_balance == cs.etherdelta_cel_totalBalance + +let eth_balances (self:etherdelta_cel_address) (bst:bstate{self `etherdelta_cel_live` bst}) : Type0 = + let etherdelta_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.etherdelta_cel_totalBalance >= ((sum_mapping (M.sel cs.etherdelta_cel_tokens null))) + +let etherdelta_cel_constructor (self:etherdelta_cel_address) (sender:address) (value:uint) (tx:tx) (block:block) (admin_:address) (feeAccount_:address) (feeMake_:uint) (feeTake_:uint) (feeRebate_:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.etherdelta_cel_admin == null) + /\ (cs.etherdelta_cel_feeAccount == null) + /\ (cs.etherdelta_cel_accountLevelsAddr == null) + /\ (cs.etherdelta_cel_feeMake == 0) + /\ (cs.etherdelta_cel_feeTake == 0) + /\ (cs.etherdelta_cel_feeRebate == 0) + /\ (cs.etherdelta_cel_tokens == M.const (M.const (0))) + /\ (cs.etherdelta_cel_orders == M.const (M.const (false))) + /\ (cs.etherdelta_cel_orderFills == M.const (M.const (0))) + /\ (cs.etherdelta_cel_totalBalance == 0) + /\ (cs.etherdelta_cel__lock_ == false) + /\ ((b == 0)) + ) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_admin self admin_ in +let cs = get_contract self in +let _ = etherdelta_cel_set_feeAccount self feeAccount_ in +let cs = get_contract self in +let _ = etherdelta_cel_set_feeMake self feeMake_ in +let cs = get_contract self in +let _ = etherdelta_cel_set_feeTake self feeTake_ in +let cs = get_contract self in +let _ = etherdelta_cel_set_feeRebate self feeRebate_ in +let cs = get_contract self in +() + +let fallback (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +revert ""; +() + +let changeAdmin (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (admin_:address) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((sender =!= cs.etherdelta_cel_admin)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ ((cs1.etherdelta_cel_admin == admin_)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_totalBalance == cs1.etherdelta_cel_totalBalance) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_tokens == cs1.etherdelta_cel_tokens) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.etherdelta_cel_admin) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_admin self admin_ in +let cs = get_contract self in +() + +let changeFeeAccount (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (feeAccount_:address) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((sender =!= cs.etherdelta_cel_admin)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_totalBalance == cs1.etherdelta_cel_totalBalance) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_tokens == cs1.etherdelta_cel_tokens) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (sender <> cs.etherdelta_cel_admin) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_feeAccount self feeAccount_ in +let cs = get_contract self in +() + +let changeFeeMake (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (feeMake_:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((sender =!= cs.etherdelta_cel_admin) \/ (feeMake_ > cs.etherdelta_cel_feeMake))) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (cs1.etherdelta_cel_feeMake == feeMake_) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_totalBalance == cs1.etherdelta_cel_totalBalance) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_tokens == cs1.etherdelta_cel_tokens) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((sender <> cs.etherdelta_cel_admin) || (feeMake_ > cs.etherdelta_cel_feeMake)) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_feeMake self feeMake_ in +let cs = get_contract self in +() + +let changeFeeTake (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (feeTake_:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((sender =!= cs.etherdelta_cel_admin) \/ (feeTake_ > cs.etherdelta_cel_feeTake)) \/ (feeTake_ < cs.etherdelta_cel_feeRebate))) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (cs1.etherdelta_cel_feeTake == feeTake_) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_totalBalance == cs1.etherdelta_cel_totalBalance) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_tokens == cs1.etherdelta_cel_tokens) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (((sender <> cs.etherdelta_cel_admin) || (feeTake_ > cs.etherdelta_cel_feeTake)) || (feeTake_ < cs.etherdelta_cel_feeRebate)) then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_feeTake self feeTake_ in +let cs = get_contract self in +() + +let changeFeeRebate (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (feeRebate_:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((sender =!= cs.etherdelta_cel_admin) \/ (feeRebate_ < cs.etherdelta_cel_feeRebate)) \/ (feeRebate_ > cs.etherdelta_cel_feeTake))) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (cs1.etherdelta_cel_feeRebate == feeRebate_) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_totalBalance == cs1.etherdelta_cel_totalBalance) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_tokens == cs1.etherdelta_cel_tokens) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (((sender <> cs.etherdelta_cel_admin) || (feeRebate_ < cs.etherdelta_cel_feeRebate)) || (feeRebate_ > cs.etherdelta_cel_feeTake)) then begin +revert "invalid"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set_feeRebate self feeRebate_ in +let cs = get_contract self in +() + +let deposit (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((cs.etherdelta_cel_totalBalance + value) > uint_max)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (((M.equal cs1.etherdelta_cel_tokens ( + let x1 = (cs0.etherdelta_cel_tokens) in + let x2 = (null) in + let x3 = ( + let x1 = (M.sel cs0.etherdelta_cel_tokens null) in + let x2 = (sender) in + let x3 = (((M.sel (M.sel cs0.etherdelta_cel_tokens null) sender) + value)) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ ((cs1.etherdelta_cel_totalBalance == (cs0.etherdelta_cel_totalBalance + value)))) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel__lock_ == cs1.etherdelta_cel__lock_) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if cs.etherdelta_cel_totalBalance <= uint_max - value then (cs.etherdelta_cel_totalBalance + value) else revert "Overflow error")) in +let _ = etherdelta_cel_set_totalBalance self x1 in +let cs = get_contract self in +let x5 = ((_add (M.sel (M.sel cs.etherdelta_cel_tokens null) sender) value)) in +let x4 = cs.etherdelta_cel_tokens in + +let x3 = (null) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_tokens self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Deposit (null, sender, value, M.sel (M.sel cs.etherdelta_cel_tokens null) sender) in +let cs = get_contract self in +let balance = get_balance self in +() + +let withdraw (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (amount:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((M.sel (M.sel cs.etherdelta_cel_tokens null) sender) < amount)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (((M.equal cs1.etherdelta_cel_tokens ( + let x1 = (cs0.etherdelta_cel_tokens) in + let x2 = (null) in + let x3 = ( + let x1 = (M.sel cs0.etherdelta_cel_tokens null) in + let x2 = (sender) in + let x3 = ((M.sel (M.sel cs0.etherdelta_cel_tokens null) sender) - amount) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (l1 == ((mk_event null etherdelta_cel_Withdraw (null, sender, amount, M.sel (M.sel cs1.etherdelta_cel_tokens null) sender))::(mk_event sender eTransfer amount)::l0))) + /\ (b1 <= b0) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((M.sel (M.sel cs.etherdelta_cel_tokens null) sender) < amount) then begin +revert "Insufficient balance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = transfer self sender amount in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (balance = cs.etherdelta_cel_totalBalance) in +let _ = (if x1 then begin +revert "Ether sent to self"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x5 = ((_sub (M.sel (M.sel cs.etherdelta_cel_tokens null) sender) amount)) in +let x4 = cs.etherdelta_cel_tokens in + +let x3 = (null) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_tokens self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = etherdelta_cel_set_totalBalance self (_sub cs.etherdelta_cel_totalBalance amount) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Withdraw (null, sender, amount, M.sel (M.sel cs.etherdelta_cel_tokens null) sender) in +let cs = get_contract self in +let balance = get_balance self in +() + +let depositToken (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (token:address) (amount:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((token == null) \/ (((M.sel (M.sel cs.etherdelta_cel_tokens token) sender) + amount) > uint_max)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (M.equal cs1.etherdelta_cel_tokens ( + let x1 = (cs0.etherdelta_cel_tokens) in + let x2 = (token) in + let x3 = ( + let x1 = (M.sel cs0.etherdelta_cel_tokens token) in + let x2 = (sender) in + let x3 = ((M.sel (M.sel cs0.etherdelta_cel_tokens token) sender) + amount) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1)) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((token = null) || (amount > ((_sub uint_max (M.sel (M.sel cs.etherdelta_cel_tokens token) sender))))) in +let _ = (if x1 then begin +revert "Invalid token type or overflow"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set__lock_ self true in +let cs = get_contract self in +assert ((cs.etherdelta_cel__lock_)); +let tokenTxStatus:bool = call_bool self ((abi_encodeWithSignature("transferFrom(address,address,uint)", sender, self, amount))) in +let balance = get_balance self in +let _ = etherdelta_cel_set__lock_ self false in +let cs = get_contract self in +let x1 = (tokenTxStatus = false) in +let _ = (if x1 then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel_totalBalance <> balance) then begin +revert "Unexpected Ether transferred to self"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (balance) in +let _ = etherdelta_cel_set_totalBalance self x1 in +let cs = get_contract self in +let x5 = ((_add (M.sel (M.sel cs.etherdelta_cel_tokens token) sender) amount)) in +let x4 = cs.etherdelta_cel_tokens in + +let x3 = (token) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_tokens self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Deposit (token, sender, amount, M.sel (M.sel cs.etherdelta_cel_tokens token) sender) in +let cs = get_contract self in +let balance = get_balance self in +() + +let withdrawToken (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (token:address) (amount:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((token == null) \/ ((M.sel (M.sel cs.etherdelta_cel_tokens token) sender) < amount)) + \/ (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ ((M.equal cs1.etherdelta_cel_tokens ( + let x1 = (cs0.etherdelta_cel_tokens) in + let x2 = (token) in + let x3 = ( + let x1 = (M.sel cs0.etherdelta_cel_tokens token) in + let x2 = (sender) in + let x3 = ((M.sel (M.sel cs0.etherdelta_cel_tokens token) sender) - amount) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1))) + /\ (cs0.etherdelta_cel_feeAccount == cs1.etherdelta_cel_feeAccount) + /\ (cs0.etherdelta_cel_accountLevelsAddr == cs1.etherdelta_cel_accountLevelsAddr) + /\ (cs0.etherdelta_cel_feeRebate == cs1.etherdelta_cel_feeRebate) + /\ (cs0.etherdelta_cel_feeMake == cs1.etherdelta_cel_feeMake) + /\ (cs0.etherdelta_cel_feeTake == cs1.etherdelta_cel_feeTake) + /\ (cs0.etherdelta_cel_orders == cs1.etherdelta_cel_orders) + /\ (cs0.etherdelta_cel_admin == cs1.etherdelta_cel_admin) + /\ (cs0.etherdelta_cel_orderFills == cs1.etherdelta_cel_orderFills) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((token = null) || ((M.sel (M.sel cs.etherdelta_cel_tokens token) sender) < amount)) in +let _ = (if x1 then begin +revert "Invalid token type or overflow"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = etherdelta_cel_set__lock_ self true in +let cs = get_contract self in +assert ((cs.etherdelta_cel__lock_)); +let tokenTxStatus:bool = call_bool self ((abi_encodeWithSignature("transfer(address,uint)", sender, amount))) in +let balance = get_balance self in +let _ = etherdelta_cel_set__lock_ self false in +let cs = get_contract self in +let x1 = (tokenTxStatus = false) in +let _ = (if x1 then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel_totalBalance <> balance) then begin +revert "Unexpected Ether transferred to self"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (balance) in +let _ = etherdelta_cel_set_totalBalance self x1 in +let cs = get_contract self in +let x5 = ((_sub (M.sel (M.sel cs.etherdelta_cel_tokens token) sender) amount)) in +let x4 = cs.etherdelta_cel_tokens in + +let x3 = (token) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_tokens self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Withdraw (sender, token, amount, M.sel (M.sel cs.etherdelta_cel_tokens token) sender) in +let cs = get_contract self in +let balance = get_balance self in +() + +let balanceOf (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (token:address) (user:address) +: Eth1 uint + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +M.sel (M.sel cs.etherdelta_cel_tokens token) user + +let order (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (tokenGet:address) (amountGet:uint) (tokenGive:address) (amountGive:uint) (expires:uint) (nonce:uint) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let hash:bytes32 = ((sha256 ((abi_encodePacked(self, tokenGet, amountGet, tokenGive, amountGive, expires, nonce))))) in +let x5 = (true) in +let x4 = cs.etherdelta_cel_orders in + +let x3 = (sender) in +let x2 = (M.sel x4 x3) in +let x1 = (hash) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_orders self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Order (tokenGet, amountGet, tokenGive, amountGive, expires, nonce, sender) in +let cs = get_contract self in +let balance = get_balance self in +() + +let availableVolume (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (tokenGet:address) (amountGet:uint) (tokenGive:address) (amountGive:uint) (expires:uint) (nonce:uint) (user:address) (v:uint8) (r:bytes32) (s:bytes32) +: Eth1 uint + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 ret bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let ret:uint = 0 in +let cs = get_contract self in +let balance = get_balance self in +let ret = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +ret end +else ret) in +let cs = get_contract self in +let balance = get_balance self in +let available1:uint = (0) in +let available2:uint = (0) in +let hash:bytes32 = ((sha256 ((abi_encodePacked(self, tokenGet, amountGet, tokenGive, amountGive, expires, nonce))))) in +let x1 = (op_Negation (((((M.sel (M.sel cs.etherdelta_cel_orders user) hash) || (((ecrecover ((keccak256 ((abi_encodePacked(("\x19Ethereum Signed Message:\n32"), hash))))) v r s)) = user))) && (block.number <= expires)))) in +let ret = (if x1 then begin +let ret = 0 in +let cs = get_contract self in +ret end +else begin +let x1 = (amountGive = 0) in +let ret = (if x1 then begin +revert "Divide by 0"; +ret end +else ret) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if (M.sel (M.sel cs.etherdelta_cel_orderFills user) hash) <= amountGet then (amountGet - (M.sel (M.sel cs.etherdelta_cel_orderFills user) hash)) else revert "Underflow error")) in +let available1 = x1 in +let cs = get_contract self in +let available2 = (_div ((safe_mul (M.sel (M.sel cs.etherdelta_cel_tokens tokenGive) user) amountGet)) amountGive) in +let cs = get_contract self in +let ret = (if (available1 < available2) then begin +let ret = available1 in +let cs = get_contract self in +ret end +else begin +let ret = available2 in +let cs = get_contract self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret + +let testTrade (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (tokenGet:address) (amountGet:uint) (tokenGive:address) (amountGive:uint) (expires:uint) (nonce:uint) (user:address) (v:uint8) (r:bytes32) (s:bytes32) (amount:uint) (_sender:address) +: Eth1 bool + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 ret bst1 -> + etherdelta_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (eth_balances2 self bst1) + /\ (eth_balances self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let ret:bool = false in +let cs = get_contract self in +let balance = get_balance self in +let ret = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +ret end +else ret) in +let cs = get_contract self in +let balance = get_balance self in +let availableVol:uint = ((availableVolume self self 0 tx block tokenGet amountGet tokenGive amountGive expires nonce user v r s)) in +let x1 = (op_Negation ((((M.sel (M.sel cs.etherdelta_cel_tokens tokenGet) _sender) >= amount) && (availableVol >= amount)))) in +let ret = (if x1 then begin +let ret = false in +let cs = get_contract self in +ret end +else begin +let ret = true in +let cs = get_contract self in +ret end) in +let cs = get_contract self in +let balance = get_contract self in +ret + +let amountFilled (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (tokenGet:address) (amountGet:uint) (tokenGive:address) (amountGive:uint) (expires:uint) (nonce:uint) (user:address) (v:uint8) (r:bytes32) (s:bytes32) +: Eth1 uint + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let hash:bytes32 = ((sha256 ((abi_encodePacked(self, tokenGet, amountGet, tokenGive, amountGive, expires, nonce))))) in +M.sel (M.sel cs.etherdelta_cel_orderFills user) hash + +let cancelOrder (self:etherdelta_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (tokenGet:address) (amountGet:uint) (tokenGive:address) (amountGive:uint) (expires:uint) (nonce:uint) (v:uint8) (r:bytes32) (s:bytes32) +: Eth1 unit + (fun bst -> + etherdelta_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (eth_balances2 self bst) + /\ (eth_balances self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (cs.etherdelta_cel__lock_) + ) + (fun bst0 x bst1 -> + etherdelta_cel_live self bst1 + /\ (eth_balances2 self bst1) + /\ (eth_balances self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.etherdelta_cel__lock_) then begin +revert "Reentrancy detected"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let hash:bytes32 = ((sha256 ((abi_encodePacked(self, tokenGet, amountGet, tokenGive, amountGive, expires, nonce))))) in +let x1 = (op_Negation (((M.sel (M.sel cs.etherdelta_cel_orders sender) hash) || (((ecrecover ((keccak256 ((abi_encodePacked(("\x19Ethereum Signed Message:\n32"), hash))))) v r s)) = sender)))) in +let _ = (if x1 then begin +revert ""; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x5 = (amountGet) in +let x4 = cs.etherdelta_cel_orderFills in + +let x3 = (sender) in +let x2 = (M.sel x4 x3) in +let x1 = (hash) in +let x0 = (M.sel x2 x1) in + +let _ = etherdelta_cel_set_orderFills self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit etherdelta_cel_Cancel (tokenGet, amountGet, tokenGive, amountGive, expires, nonce, sender, v, r, s) in +let cs = get_contract self in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Samples/EtherDelta/migrations/1_initial_migration.js b/Celestial/Samples/EtherDelta/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/EtherDelta/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/EtherDelta/truffle-config.js b/Celestial/Samples/EtherDelta/truffle-config.js new file mode 100644 index 00000000..7a90d768 --- /dev/null +++ b/Celestial/Samples/EtherDelta/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + // version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/Makefile b/Celestial/Samples/Makefile new file mode 100644 index 00000000..6484dfc8 --- /dev/null +++ b/Celestial/Samples/Makefile @@ -0,0 +1,172 @@ +.DEFAULT_GOAL := help +SHELL := /bin/bash + +COMPILER = python3 ../Compiler/main.py +COMPILER2 = python3 ../Compiler/main.py --v="VeriSol" +FSTAR = fstar.exe --include ../Compiler/lib +TRUFFLE = truffle test +VERISOL = VeriSol + +define TIME + TIMEFORMAT='Contract(s) verified in %Rs'; time ${FSTAR} $(1) $(2) 2>&1 1>/dev/null +endef + +help: + @echo Usage: + @echo " make" + @echo Targets: + @echo " compile experiment= Compiles the Celestial source for the specified experiment and generates the Solidity and FStar versions." + @echo " verify experiment= Verifies the generated FStar for the specified experiment." + @echo " compileV experiment= Compiles the Celestial source for the specified experiment and generates the VeriSol-compatible Solidity version." + @echo " verifyV experiment= Verifies the generated Solidity using VeriSol for the specified experiment." + @echo " perf experiment= Generates a .csv file with gas comparisions for the specified experiment." + @echo " Runs all the above targets for the specified experiment." + @echo " all Compiles, verifies and generates gas performance .csv file for all experiments." + @echo Experiments: + @echo " overview" + @echo " asset_transfer" + @echo " etherdelta" + @echo " erc20" + @echo " wrapped_ether" + @echo " multisig" + @echo " simple_auction" + @echo " binancecoin" + +all: overview asset_transfer erc20 etherdelta wrapped_ether multisig simple_auction binancecoin + +compile: + @if [ '$(experiment)' = 'overview' ]; then \ + ${COMPILER} Overview/celestial/Overview.cel --fstDir="../Samples/Overview/fstar" --solDir="../Samples/Overview/contracts/"; \ + elif [ '$(experiment)' = 'asset_transfer' ]; then \ + ${COMPILER} AssetTransfer/celestial/AssetTransfer.cel --fstDir="../Samples/AssetTransfer/fstar" --solDir="../Samples/AssetTransfer/contracts/"; \ + elif [ '$(experiment)' = 'etherdelta' ]; then \ + ${COMPILER} EtherDelta/celestial/EtherDelta.cel --fstDir="../Samples/EtherDelta/fstar" --solDir="../Samples/EtherDelta/contracts/"; \ + elif [ '$(experiment)' = 'erc20' ]; then \ + ${COMPILER} OpenZeppelin/ERC20/celestial/OpenZeppelinERC20.cel --fstDir="../Samples/OpenZeppelin/ERC20/fstar" --solDir="../Samples/OpenZeppelin/ERC20/contracts"; \ + elif [ '$(experiment)' = 'wrapped_ether' ]; then \ + ${COMPILER} WrappedEther/celestial/WrappedEther.cel --fstDir="../Samples/WrappedEther/fstar" --solDir="../Samples/WrappedEther/contracts"; \ + elif [ '$(experiment)' = 'multisig' ]; then \ + ${COMPILER} ConsenSys/MultiSig/celestial/MultiSig.cel --fstDir="../Samples/ConsenSys/MultiSig/fstar" --solDir="../Samples/ConsenSys/MultiSig/contracts"; \ + elif [ '$(experiment)' = 'simple_auction' ]; then \ + ${COMPILER} SimpleAuction/celestial/SimpleAuction.cel --fstDir="../Samples/SimpleAuction/fstar" --solDir="../Samples/SimpleAuction/contracts"; \ + elif [ '$(experiment)' = 'binancecoin' ]; then \ + ${COMPILER} BinanceCoin/celestial/BinanceCoin.cel --fstDir="../Samples/BinanceCoin/fstar" --solDir="../Samples/BinanceCoin/contracts"; \ + else \ + echo "Invalid experiment argument to target 'compile'"; \ + fi; + +verify: + @if [ '$(experiment)' = 'overview' ]; then \ + $(call TIME,--z3rlimit 50 --include Overview/fstar,Overview/fstar/SimpleMarket.fst,SimpleMarket); \ + elif [ '$(experiment)' = 'asset_transfer' ]; then \ + $(call TIME,--z3rlimit 50,AssetTransfer/fstar/MarketPlace_Cel.fst,AssetTransfer); \ + elif [ '$(experiment)' = 'etherdelta' ]; then \ + $(call TIME,--z3rlimit 150,EtherDelta/fstar/EtherDelta_Cel.fst,EtherDelta); \ + elif [ '$(experiment)' = 'erc20' ]; then \ + $(call TIME,--z3rlimit 50,OpenZeppelin/ERC20/fstar/ERC20_Cel.fst,ERC20); \ + elif [ '$(experiment)' = 'wrapped_ether' ]; then \ + $(call TIME,--z3rlimit 200,WrappedEther/fstar/WETH9_Cel.fst,Wrapped Ether); \ + elif [ '$(experiment)' = 'multisig' ]; then \ + $(call TIME,--z3rlimit 150,ConsenSys/MultiSig/fstar/MultiSigWalletWithDailyLimit_Cel.fst,ConsenSys MultiSigWallet); \ + elif [ '$(experiment)' = 'simple_auction' ]; then \ + $(call TIME,--z3rlimit 50,SimpleAuction/fstar/SimpleAuction_Cel.fst,Simple Auction); \ + elif [ '$(experiment)' = 'binancecoin' ]; then \ + $(call TIME,--z3rlimit 50,BinanceCoin/fstar/BNB_Cel.fst,BNB); \ + else \ + echo "Invalid experiment argument to target 'verify'"; \ + fi; + +compileV: + @if [ '$(experiment)' = 'overview' ]; then \ + ${COMPILER2} Overview/celestial/Overview.cel --fstDir="../Samples/Overview/fstar" --solDir="../Samples/Overview/contracts/"; \ + elif [ '$(experiment)' = 'asset_transfer' ]; then \ + ${COMPILER2} AssetTransfer/celestial/AssetTransfer.cel --fstDir="../Samples/AssetTransfer/fstar" --solDir="../Samples/AssetTransfer/contracts/"; \ + elif [ '$(experiment)' = 'etherdelta' ]; then \ + ${COMPILER2} EtherDelta/celestial/EtherDelta.cel --fstDir="../Samples/EtherDelta/fstar" --solDir="../Samples/EtherDelta/contracts/"; \ + elif [ '$(experiment)' = 'erc20' ]; then \ + ${COMPILER2} OpenZeppelin/ERC20/celestial/OpenZeppelinERC20.cel --fstDir="../Samples/OpenZeppelin/ERC20/fstar" --solDir="../Samples/OpenZeppelin/ERC20/contracts"; \ + elif [ '$(experiment)' = 'wrapped_ether' ]; then \ + ${COMPILER2} WrappedEther/celestial/WrappedEther.cel --fstDir="../Samples/WrappedEther/fstar" --solDir="../Samples/WrappedEther/contracts"; \ + elif [ '$(experiment)' = 'multisig' ]; then \ + ${COMPILER2} ConsenSys/MultiSig/celestial/MultiSig.cel --fstDir="../Samples/ConsenSys/MultiSig/fstar" --solDir="../Samples/ConsenSys/MultiSig/contracts"; \ + elif [ '$(experiment)' = 'simple_auction' ]; then \ + ${COMPILER2} SimpleAuction/celestial/SimpleAuction.cel --fstDir="../Samples/SimpleAuction/fstar" --solDir="../Samples/SimpleAuction/contracts"; \ + elif [ '$(experiment)' = 'binancecoin' ]; then \ + ${COMPILER2} BinanceCoin/celestial/BinanceCoin.cel --fstDir="../Samples/BinanceCoin/fstar" --solDir="../Samples/BinanceCoin/contracts"; \ + else \ + echo "Invalid experiment argument to target 'compile'"; \ + fi; + +verifyV: + @if [ '$(experiment)' = 'overview' ]; then \ + ${VERISOL} "Overview\contracts\contract.sol" Overview; \ + elif [ '$(experiment)' = 'asset_transfer' ]; then \ + ${VERISOL} "AssetTransfer\contracts\contract.sol" MarketPlace_Cel; \ + elif [ '$(experiment)' = 'etherdelta' ]; then \ + ${VERISOL} "EtherDelta\contracts\contract.sol" EtherDelta_Cel; \ + elif [ '$(experiment)' = 'erc20' ]; then \ + ${VERISOL} "OpenZeppelin\ERC20\contracts\contract.sol" ERC20_Cel; \ + elif [ '$(experiment)' = 'wrapped_ether' ]; then \ + ${VERISOL} "WrappedEther\contracts\contract.sol" WETH9_Cel; \ + elif [ '$(experiment)' = 'multisig' ]; then \ + ${VERISOL} "ConsenSys\MultiSig\contracts\contract.sol" MultiSigWalletWithDailyLimit_Cel; \ + elif [ '$(experiment)' = 'simple_auction' ]; then \ + ${VERISOL} "SimpleAuction\contracts\contract.sol" SimpleAuction_Cel; \ + elif [ '$(experiment)' = 'binancecoin' ]; then \ + ${VERISOL} "BinanceCoin\contracts\contract.sol" BNB_Cel; \ + else \ + echo "Invalid experiment argument to target 'verifyWithVeriSol'"; \ + fi; + +perf: + @if [ '$(experiment)' = 'asset_transfer' ]; then \ + cd AssetTransfer && ${TRUFFLE} test/assetTransfer.js; \ + elif [ '$(experiment)' = 'erc20' ]; then \ + cd OpenZeppelin/ERC20 && ${TRUFFLE} test/erc20.js; \ + elif [ '$(experiment)' = 'wrapped_ether' ]; then \ + cd WrappedEther && ${TRUFFLE} test/wrappedEther.js; \ + elif [ '$(experiment)' = 'multisig' ]; then \ + cd ConsenSys/MultiSig && ${TRUFFLE} test/multisig.js; \ + elif [ '$(experiment)' = 'simple_auction' ]; then \ + cd SimpleAuction && ${TRUFFLE} test/simpleAuction.js; \ + else \ + echo "Invalid experiment argument to target 'perf'"; \ + fi; + + +overview: + $(MAKE) compile experiment=overview + $(MAKE) verify experiment=overview + +asset_transfer : + $(MAKE) compile experiment=asset_transfer + $(MAKE) verify experiment=asset_transfer + $(MAKE) perf experiment=asset_transfer + +etherdelta: + $(MAKE) compile experiment=etherdelta + $(MAKE) verify experiment=etherdelta + +erc20: + $(MAKE) compile experiment=erc20 + $(MAKE) verify experiment=erc20 + $(MAKE) perf experiment=erc20 + +wrapped_ether: + $(MAKE) compile experiment=wrapped_ether + $(MAKE) verify experiment=wrapped_ether + $(MAKE) perf experiment=wrapped_ether + +multisig: + $(MAKE) compile experiment=multisig + $(MAKE) verify experiment=multisig + $(MAKE) perf experiment=multisig + +simple_auction: + $(MAKE) compile experiment=simple_auction + $(MAKE) verify experiment=simple_auction + $(MAKE) perf experiment=simple_auction + +binancecoin: + $(MAKE) compile experiment=binancecoin + $(MAKE) verify experiment=binancecoin \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/celestial/OpenZeppelinERC20.cel b/Celestial/Samples/OpenZeppelin/ERC20/celestial/OpenZeppelinERC20.cel new file mode 100644 index 00000000..11e50f49 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/celestial/OpenZeppelinERC20.cel @@ -0,0 +1,273 @@ +pragma solidity^0.6.8; + +contract ERC20_Cel +{ + mapping (address => uint) balances; + mapping (address => mapping (address => uint)) allowances; + uint totalSupply; + + invariant totalSupplyInv + { + totalSupply == sum_mapping (balances) + } + + spec nullCheckPre (address a1, address a2) + { + a1 != null && a2 != null + } + + function _msgSender () private view + post ret == sender + modifies [] + returns (address ret) + { + return sender; + } + + spec transferPost ( + mapping (address => uint) old_balances, mapping (address => uint) new_balances, + address _from, address _to, uint _amount) + { + (old_balances[_from] >= _amount) + && (old_balances[_to] + _amount <= uint_max) // these lines ensure this function is typechecked correctly + && ite + ( + _from == _to, + new_balances == old_balances, + new_balances == old_balances[ + _from => old_balances[_from] - _amount, + _to => old_balances[_to] + _amount + ] + ) + } + + spec _approvePost ( + mapping (address => mapping (address => uint)) old_allowances, + mapping (address => mapping (address => uint)) new_allowances, + address _owner, address _spender, uint _amount) + { + new_allowances == old_allowances[_owner => old_allowances[_owner][_spender => _amount]] + } + + spec transferFromPost ( + mapping (address => mapping (address => uint)) old_allowances, + mapping (address => mapping (address => uint)) new_allowances, + mapping (address => uint) old_balances, + mapping (address => uint) new_balances, + address _from, address _to, + address _sender, uint _amount) + { + transferPost (old_balances, new_balances, _from, _to, _amount) + && old_allowances[_from][_sender] >= _amount + && _approvePost (old_allowances, new_allowances, _from, _sender, old_allowances[_from][_sender] - _amount) + } + + function getTotalSupply () public + modifies [] + returns (uint) + { + return totalSupply; + } + + function balanceOf (address account) public + modifies [] + returns (uint) + { + return balances[account]; + } + + function _transfer (address _from, address _to, uint _amount) private + pre nullCheckPre (_from, _to) + && balances[_from] >= _amount && balances[_to] + _amount <= uint_max + post transferPost (balances, new(balances), _from, _to, _amount) + modifies [balances] + { + if (_from != _to) + { + balances[_from] = balances[_from] - (_amount); + balances[_to] = balances[_to] + (_amount); + } + return; + } + + spec mintReverts ( + address _account, uint old_totalSupply, + mapping (address => uint) old_balances, uint _amount) + { + _account == null || (old_totalSupply > uint_max - _amount || old_balances[_account] > uint_max - _amount) + } + + spec burnReverts ( + address _account, uint old_totalSupply, + mapping (address => uint) old_balances, uint _amount) + { + _account == null || (old_balances[_account] < _amount || old_totalSupply < _amount) + } + + function mint (address _account, uint _amount) public + post new(totalSupply) == totalSupply + _amount + && new(balances) == balances[_account => balances[_account] + _amount] + tx_reverts mintReverts (_account, totalSupply, balances, _amount) + modifies [totalSupply, balances] + { + if (_account == null) + { + revert ("ERC20: mint to the zero address"); + } + + if (totalSupply <= uint_max - _amount && balances[_account] <= uint_max - _amount) + { + totalSupply = totalSupply + _amount; + balances[_account] = balances[_account] + _amount; + } + else + { + revert ("Overflow"); + } + return; + } + + function burn (address _account, uint _amount) public + post new(totalSupply) == totalSupply - _amount + && new(balances) == balances[_account => balances[_account] - _amount] + tx_reverts burnReverts (_account, totalSupply, balances, _amount) + modifies [totalSupply, balances] + { + if (_account == null) + { + revert ("ERC20: burn from the zero address"); + } + + if (balances[_account] >= _amount && totalSupply >= _amount) + { + totalSupply = totalSupply - _amount; + balances[_account] = balances[_account] - _amount; + } + else + { + revert ("Underflow"); + } + return; + } + + function _approve (address _owner, address _spender, uint _amount) private + pre nullCheckPre (_owner, _spender) && _amount >=0 && _amount <= uint_max + post _approvePost (allowances, new(allowances), _owner, _spender, _amount) + modifies [allowances] + { + allowances[_owner][_spender] = _amount; + return; + } + + function burnFrom (address _account, uint _amount) public + tx_reverts burnReverts (_account, totalSupply, balances, _amount) + modifies [totalSupply, balances, allowances] + { + burn (_account, _amount); + if (_account != null && sender != null && allowances[_account][sender] >= _amount) + { + _approve(_account, sender, allowances[_account][sender] - _amount); + } + return; + } + + function transfer_ (address _to, uint _amount) public + post new(balances)[sender] <= balances[sender] && balances[_to] >= balances[_to] + tx_reverts _to == null + modifies [balances] + returns (bool) + { + if (_to == null) + { + revert ("Sender/Recipient must be non-null"); + } + + if (balances[sender] >= _amount && balances[_to] <= uint_max - _amount) + { + _transfer (sender, _to, _amount); + } + + return true; + } + + function allowance (address _owner, address _spender) public + modifies [] + returns (uint) + { + return allowances[_owner][_spender]; + } + + function approve (address _spender, uint _amount) public + modifies [allowances] + returns (bool) + { + if (_spender != null) + { + _approve(sender, _spender, _amount); + } + return true; + } + + spec transferFromReverts ( + address _to, address _from, uint _amount, mapping (address => uint) old_balances, + mapping (address => mapping (address => uint)) old_allowances, address _sender) + { + _from == null || _to == null || (old_balances[_from] < _amount + || old_balances[_to] > uint_max - _amount) || (old_allowances[_from][_sender] < _amount) + } + + function transferFrom(address _from, address _to, uint _amount) public + post transferFromPost (allowances, new(allowances), balances, new(balances), _from, _to, sender, _amount) + tx_reverts transferFromReverts (_to, _from, _amount, balances, allowances, sender) + modifies [balances, allowances] + returns (bool) + { + if (_from == null || _to == null) + { + revert (" from/to addresses are null"); + } + + if (balances[_from] >= _amount && balances[_to] <= uint_max - _amount) + { + _transfer (_from, _to, _amount); + } + else + { + revert (" Underflow/Overflow"); + } + + if (allowances[_from][sender] >= _amount) + { + _approve (_from, sender, allowances[_from][sender] - _amount); + } + else + { + revert (" Allowance insufficient"); + } + + return true; + } + + function increaseAllowance (address _spender, uint _addedValue) public + modifies [allowances] + returns (bool) + { + if (_spender != null && allowances[sender][_spender] <= uint_max - _addedValue) + { + _approve (sender, _spender, allowances[sender][_spender] + _addedValue); + } + return true; + } + + function decreaseAllowance (address _spender, uint _subtractedValue) public + modifies [allowances] + returns (bool) + { + if (_spender != null && allowances[sender][_spender] >= _subtractedValue) + { + _approve (sender, _spender, allowances[sender][_spender] - _subtractedValue); + } + return true; + } + +} \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/contracts/Call.sol b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/contracts/Migrations.sol b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/OpenZeppelin/ERC20/contracts/OpenZeppelinERC20.sol b/Celestial/Samples/OpenZeppelin/ERC20/contracts/OpenZeppelinERC20.sol new file mode 100644 index 00000000..d9b0f15b --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/contracts/OpenZeppelinERC20.sol @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: MIT + +pragma solidity >=0.5.0; + +interface IERC20 { + + function totalSupply() external view returns (uint256); + + function balanceOf(address account) external view returns (uint256); + + function transfer(address recipient, uint256 amount) external returns (bool); + + function allowance(address owner, address spender) external view returns (uint256); + + function approve(address spender, uint256 amount) external returns (bool); + + function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + + event Transfer(address indexed from, address indexed to, uint256 value); + + event Approval(address indexed owner, address indexed spender, uint256 value); +} + +abstract contract Context { + function _msgSender() internal view virtual returns (address payable) { + return msg.sender; + } + + function _msgData() internal view virtual returns (bytes memory) { + this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 + return msg.data; + } +} + +library SafeMath { + + function add(uint256 a, uint256 b) internal pure returns (uint256) { + uint256 c = a + b; + require(c >= a, "SafeMath: addition overflow"); + + return c; + } + + function sub(uint256 a, uint256 b) internal pure returns (uint256) { + return sub(a, b, "SafeMath: subtraction overflow"); + } + + function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b <= a, errorMessage); + uint256 c = a - b; + + return c; + } + + function mul(uint256 a, uint256 b) internal pure returns (uint256) { + + if (a == 0) { + return 0; + } + + uint256 c = a * b; + require(c / a == b, "SafeMath: multiplication overflow"); + + return c; + } + + function div(uint256 a, uint256 b) internal pure returns (uint256) { + return div(a, b, "SafeMath: division by zero"); + } + + function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b > 0, errorMessage); + uint256 c = a / b; + // assert(a == b * c + a % b); // There is no case in which this doesn't hold + + return c; + } + + function mod(uint256 a, uint256 b) internal pure returns (uint256) { + return mod(a, b, "SafeMath: modulo by zero"); + } + + function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + require(b != 0, errorMessage); + return a % b; + } +} + +contract ERC20 is Context, IERC20 { + using SafeMath for uint256; + + mapping (address => uint256) private _balances; + + mapping (address => mapping (address => uint256)) private _allowances; + + uint256 private _totalSupply; + + function totalSupply() public override view returns (uint256) { + return _totalSupply; + } + + function balanceOf(address account) public override view returns (uint256) { + return _balances[account]; + } + + function transfer(address recipient, uint256 amount) public override returns (bool) { + _transfer(_msgSender(), recipient, amount); + return true; + } + + function allowance(address owner, address spender) public override view returns (uint256) { + return _allowances[owner][spender]; + } + + function approve(address spender, uint256 amount) public override returns (bool) { + _approve(_msgSender(), spender, amount); + return true; + } + + function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { + _transfer(sender, recipient, amount); + _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); + return true; + } + + function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); + return true; + } + + function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { + _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); + return true; + } + + function _transfer(address sender, address recipient, uint256 amount) internal { + require(sender != address(0), "ERC20: transfer from the zero address"); + require(recipient != address(0), "ERC20: transfer to the zero address"); + + _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); + _balances[recipient] = _balances[recipient].add(amount); + emit Transfer(sender, recipient, amount); + } + + function _mint(address account, uint256 amount) public { + require(account != address(0), "ERC20: mint to the zero address"); + + _totalSupply = _totalSupply.add(amount); + _balances[account] = _balances[account].add(amount); + emit Transfer(address(0), account, amount); + } + + function _burn(address account, uint256 amount) public { + require(account != address(0), "ERC20: burn from the zero address"); + + _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); + _totalSupply = _totalSupply.sub(amount); + emit Transfer(account, address(0), amount); + } + + function _approve(address owner, address spender, uint256 amount) internal { + require(owner != address(0), "ERC20: approve from the zero address"); + require(spender != address(0), "ERC20: approve to the zero address"); + + _allowances[owner][spender] = amount; + emit Approval(owner, spender, amount); + } + + function _burnFrom(address account, uint256 amount) internal { + _burn(account, amount); + _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); + } +} \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/contracts/Safe_Arith.sol b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/contracts/contract.sol b/Celestial/Samples/OpenZeppelin/ERC20/contracts/contract.sol new file mode 100644 index 00000000..e00a6f58 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/contracts/contract.sol @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + + +contract ERC20_Cel { + mapping (address => uint) balances; + mapping (address => mapping (address => uint)) allowances; + uint totalSupply; + + function _msgSender () private view returns (address ret) { + return msg.sender; + } + + function getTotalSupply () public returns (uint) { + return totalSupply; + } + + function balanceOf (address account) public returns (uint) { + return balances[account]; + } + + function _transfer (address _from, address _to, uint _amount) private { + if (_from != _to) + { + balances[_from] = balances[_from] - (_amount); + balances[_to] = balances[_to] + (_amount); + } + return; + } + + function mint (address _account, uint _amount) public { + if (_account == address(0)) + { + revert ("ERC20: mint to the zero address"); + } + if (totalSupply <= (~uint256(0)) - _amount && balances[_account] <= (~uint256(0)) - _amount) + { + totalSupply = totalSupply + _amount; + balances[_account] = balances[_account] + _amount; + } + else + { + revert ("Overflow"); + } + return; + } + + function burn (address _account, uint _amount) public { + if (_account == address(0)) + { + revert ("ERC20: burn from the zero address"); + } + if (balances[_account] >= _amount && totalSupply >= _amount) + { + totalSupply = totalSupply - _amount; + balances[_account] = balances[_account] - _amount; + } + else + { + revert ("Underflow"); + } + return; + } + + function _approve (address _owner, address _spender, uint _amount) private { + allowances[_owner][_spender] = _amount; + return; + } + + function burnFrom (address _account, uint _amount) public { + burn(_account, _amount); + if (_account != address(0) && msg.sender != address(0) && allowances[_account][msg.sender] >= _amount) + { + _approve(_account, msg.sender, allowances[_account][msg.sender] - _amount); + } + return; + } + + function transfer_ (address _to, uint _amount) public returns (bool) { + if (_to == address(0)) + { + revert ("Sender/Recipient must be non-null"); + } + if (balances[msg.sender] >= _amount && balances[_to] <= (~uint256(0)) - _amount) + { + _transfer(msg.sender, _to, _amount); + } + return true; + } + + function allowance (address _owner, address _spender) public returns (uint) { + return allowances[_owner][_spender]; + } + + function approve (address _spender, uint _amount) public returns (bool) { + if (_spender != address(0)) + { + _approve(msg.sender, _spender, _amount); + } + return true; + } + + function transferFrom (address _from, address _to, uint _amount) public returns (bool) { + if (_from == address(0) || _to == address(0)) + { + revert (" from/to addresses are null"); + } + if (balances[_from] >= _amount && balances[_to] <= (~uint256(0)) - _amount) + { + _transfer(_from, _to, _amount); + } + else + { + revert (" Underflow/Overflow"); + } + if (allowances[_from][msg.sender] >= _amount) + { + _approve(_from, msg.sender, allowances[_from][msg.sender] - _amount); + } + else + { + revert (" Allowance insufficient"); + } + return true; + } + + function increaseAllowance (address _spender, uint _addedValue) public returns (bool) { + if (_spender != address(0) && allowances[msg.sender][_spender] <= (~uint256(0)) - _addedValue) + { + _approve(msg.sender, _spender, allowances[msg.sender][_spender] + _addedValue); + } + return true; + } + + function decreaseAllowance (address _spender, uint _subtractedValue) public returns (bool) { + if (_spender != address(0) && allowances[msg.sender][_spender] >= _subtractedValue) + { + _approve(msg.sender, _spender, allowances[msg.sender][_spender] - _subtractedValue); + } + return true; + } +} \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/fstar/ERC20_Cel.fst b/Celestial/Samples/OpenZeppelin/ERC20/fstar/ERC20_Cel.fst new file mode 100644 index 00000000..b7466b29 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/fstar/ERC20_Cel.fst @@ -0,0 +1,713 @@ +(*Code generated by compiler*) + +module ERC20_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + + +noeq type t_erc20_cel = { + erc20_cel_balances : (m:(M.t address uint lt){M.def_of m == 0}); + erc20_cel_allowances : (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}); + erc20_cel_totalSupply : uint; +} + +(* Contract address type, liveness, and field range macros *) + +type erc20_cel_address = contract t_erc20_cel +let erc20_cel_live (c:erc20_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract ERC20_Cel *) + +let erc20_cel_get_balances (c:erc20_cel_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `erc20_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).erc20_cel_balances) += let erc20_cel_inst = get_contract c in + erc20_cel_inst.erc20_cel_balances + +let erc20_cel_get_allowances (c:erc20_cel_address) +: StEth (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}) + (fun st -> c `erc20_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).erc20_cel_allowances) += let erc20_cel_inst = get_contract c in + erc20_cel_inst.erc20_cel_allowances + +let erc20_cel_get_totalSupply (c:erc20_cel_address) +: StEth uint + (fun st -> c `erc20_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).erc20_cel_totalSupply) += let erc20_cel_inst = get_contract c in + erc20_cel_inst.erc20_cel_totalSupply + +(* Field setters for contract ERC20_Cel *) + +let erc20_cel_set_balances (c:erc20_cel_address) (_balances:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `erc20_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + erc20_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with erc20_cel_balances = _balances })) += let erc20_cel_inst = get_contract c in + let erc20_cel_inst = { erc20_cel_inst with erc20_cel_balances = _balances } in + set_contract c erc20_cel_inst + +let erc20_cel_set_allowances (c:erc20_cel_address) (_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) +: StEth unit + (fun st -> c `erc20_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + erc20_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with erc20_cel_allowances = _allowances })) += let erc20_cel_inst = get_contract c in + let erc20_cel_inst = { erc20_cel_inst with erc20_cel_allowances = _allowances } in + set_contract c erc20_cel_inst + +let erc20_cel_set_totalSupply (c:erc20_cel_address) (_totalSupply:uint) +: StEth unit + (fun st -> c `erc20_cel_live` st.current + /\ _totalSupply >= 0 /\ _totalSupply <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + erc20_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with erc20_cel_totalSupply = _totalSupply })) += let erc20_cel_inst = get_contract c in + let erc20_cel_inst = { erc20_cel_inst with erc20_cel_totalSupply = _totalSupply } in + set_contract c erc20_cel_inst + +let totalSupplyInv (self:erc20_cel_address) (bst:bstate{self `erc20_cel_live` bst}) : Type0 = + let erc20_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.erc20_cel_totalSupply == ((sum_mapping cs.erc20_cel_balances)) + +let nullCheckPre (a1:address) (a2:address) += (a1 =!= null) /\ (a2 =!= null) + +let _msgSender (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 address + (fun bst -> + erc20_cel_live self bst + ) + (fun bst -> False) + (fun bst0 ret bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (ret == sender) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let ret:address = null in +let cs = get_contract self in +let balance = get_balance self in +sender + +let transferPost (old_balances:(m:(M.t address uint lt){M.def_of m == 0})) (new_balances:(m:(M.t address uint lt){M.def_of m == 0})) (_from:address) (_to:address) (_amount:uint) += ((((M.sel old_balances _from) >= _amount)) /\ ((((M.sel old_balances _to) + _amount) <= uint_max))) /\ (if (_from = _to) then + (M.equal new_balances old_balances) +else + (M.equal new_balances ( + let x1 = (old_balances) in + let x2 = (_from) in + let x3 = ((M.sel old_balances _from) - _amount) in + let x1 = (M.upd x1 x2 x3) in + let x2 = (_to) in + let x3 = ((M.sel old_balances _to) + _amount) in + let x1 = (M.upd x1 x2 x3) in + x1)) +) + +let _approvePost (old_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (new_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (_owner:address) (_spender:address) (_amount:uint) += M.equal new_allowances ( + let x1 = (old_allowances) in + let x2 = (_owner) in + let x3 = ( + let x1 = (M.sel old_allowances _owner) in + let x2 = (_spender) in + let x3 = (_amount) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1) + +let transferFromPost (old_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (new_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (old_balances:(m:(M.t address uint lt){M.def_of m == 0})) (new_balances:(m:(M.t address uint lt){M.def_of m == 0})) (_from:address) (_to:address) (_sender:address) (_amount:uint) += (((transferPost old_balances new_balances _from _to _amount)) /\ ((M.sel (M.sel old_allowances _from) _sender) >= _amount)) /\ ((_approvePost old_allowances new_allowances _from _sender ((M.sel (M.sel old_allowances _from) _sender) - _amount))) + +let getTotalSupply (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 uint + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +cs.erc20_cel_totalSupply + +let balanceOf (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (account:address) +: Eth1 uint + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +M.sel cs.erc20_cel_balances account + +let _transfer (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_from:address) (_to:address) (_amount:uint) +: Eth1 unit + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((nullCheckPre _from _to)) /\ ((M.sel cs.erc20_cel_balances _from) >= _amount)) /\ (((M.sel cs.erc20_cel_balances _to) + _amount) <= uint_max)) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((transferPost cs0.erc20_cel_balances cs1.erc20_cel_balances _from _to _amount)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + /\ (cs0.erc20_cel_allowances == cs1.erc20_cel_allowances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (_from <> _to) then begin +let x1 = ((_sub (M.sel cs.erc20_cel_balances _from) (_amount))) in +let balances = cs.erc20_cel_balances in +let _ = erc20_cel_set_balances self (M.upd balances _from x1) in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.erc20_cel_balances _to) (_amount))) in +let balances = cs.erc20_cel_balances in +let _ = erc20_cel_set_balances self (M.upd balances _to x1) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() + +let mintReverts (_account:address) (old_totalSupply:uint) (old_balances:(m:(M.t address uint lt){M.def_of m == 0})) (_amount:uint) += (_account == null) \/ (((old_totalSupply > (uint_max - _amount)) \/ ((M.sel old_balances _account) > (uint_max - _amount)))) + +let burnReverts (_account:address) (old_totalSupply:uint) (old_balances:(m:(M.t address uint lt){M.def_of m == 0})) (_amount:uint) += (_account == null) \/ ((((M.sel old_balances _account) < _amount) \/ (old_totalSupply < _amount))) + +let mint (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_account:address) (_amount:uint) +: Eth1 unit + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((mintReverts _account cs.erc20_cel_totalSupply cs.erc20_cel_balances _amount)) + ) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ ((cs1.erc20_cel_totalSupply == (cs0.erc20_cel_totalSupply + _amount)) /\ (M.equal cs1.erc20_cel_balances ( + let x1 = (cs0.erc20_cel_balances) in + let x2 = (_account) in + let x3 = ((M.sel cs0.erc20_cel_balances _account) + _amount) in + let x1 = (M.upd x1 x2 x3) in + x1))) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_allowances == cs1.erc20_cel_allowances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_account = null) in +let _ = (if x1 then begin +revert "ERC20: mint to the zero address"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((cs.erc20_cel_totalSupply <= ((_sub uint_max _amount))) && ((M.sel cs.erc20_cel_balances _account) <= ((_sub uint_max _amount)))) in +let _ = (if x1 then begin +let _ = erc20_cel_set_totalSupply self (_add cs.erc20_cel_totalSupply _amount) in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.erc20_cel_balances _account) _amount)) in +let balances = cs.erc20_cel_balances in +let _ = erc20_cel_set_balances self (M.upd balances _account x1) in +let cs = get_contract self in +() end +else begin +revert "Overflow"; +() end) in +let cs = get_contract self in +let balance = get_contract self in +() + +let burn (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_account:address) (_amount:uint) +: Eth1 unit + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((burnReverts _account cs.erc20_cel_totalSupply cs.erc20_cel_balances _amount)) + ) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ ((cs1.erc20_cel_totalSupply == (cs0.erc20_cel_totalSupply - _amount)) /\ (M.equal cs1.erc20_cel_balances ( + let x1 = (cs0.erc20_cel_balances) in + let x2 = (_account) in + let x3 = ((M.sel cs0.erc20_cel_balances _account) - _amount) in + let x1 = (M.upd x1 x2 x3) in + x1))) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_allowances == cs1.erc20_cel_allowances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_account = null) in +let _ = (if x1 then begin +revert "ERC20: burn from the zero address"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (((M.sel cs.erc20_cel_balances _account) >= _amount) && (cs.erc20_cel_totalSupply >= _amount)) in +let _ = (if x1 then begin +let _ = erc20_cel_set_totalSupply self (_sub cs.erc20_cel_totalSupply _amount) in +let cs = get_contract self in +let x1 = ((_sub (M.sel cs.erc20_cel_balances _account) _amount)) in +let balances = cs.erc20_cel_balances in +let _ = erc20_cel_set_balances self (M.upd balances _account x1) in +let cs = get_contract self in +() end +else begin +revert "Underflow"; +() end) in +let cs = get_contract self in +let balance = get_contract self in +() + +let _approve (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_owner:address) (_spender:address) (_amount:uint) +: Eth1 unit + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((nullCheckPre _owner _spender)) /\ (_amount >= 0)) /\ (_amount <= uint_max)) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((_approvePost cs0.erc20_cel_allowances cs1.erc20_cel_allowances _owner _spender _amount)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_balances == cs1.erc20_cel_balances) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x5 = (_amount) in +let x4 = cs.erc20_cel_allowances in + +let x3 = (_owner) in +let x2 = (M.sel x4 x3) in +let x1 = (_spender) in +let x0 = (M.sel x2 x1) in + +let _ = erc20_cel_set_allowances self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +() + +let burnFrom (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_account:address) (_amount:uint) +: Eth1 unit + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((burnReverts _account cs.erc20_cel_totalSupply cs.erc20_cel_balances _amount)) + ) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (burn self self 0 tx block _account _amount) in +let cs = get_contract self in +let x1 = (((_account <> null) && (sender <> null)) && ((M.sel (M.sel cs.erc20_cel_allowances _account) sender) >= _amount)) in +let _ = (if x1 then begin +let _ = (_approve self self 0 tx block _account sender (_sub (M.sel (M.sel cs.erc20_cel_allowances _account) sender) _amount)) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() + +let transfer_ (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_to:address) (_amount:uint) +: Eth1 bool + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (_to == null) + ) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (((M.sel cs1.erc20_cel_balances sender) <= (M.sel cs0.erc20_cel_balances sender)) /\ ((M.sel cs0.erc20_cel_balances _to) >= (M.sel cs0.erc20_cel_balances _to))) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + /\ (cs0.erc20_cel_allowances == cs1.erc20_cel_allowances) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_to = null) in +let _ = (if x1 then begin +revert "Sender/Recipient must be non-null"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (((M.sel cs.erc20_cel_balances sender) >= _amount) && ((M.sel cs.erc20_cel_balances _to) <= ((_sub uint_max _amount)))) in +let _ = (if x1 then begin +let _ = (_transfer self self 0 tx block sender _to _amount) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +true + +let allowance (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_owner:address) (_spender:address) +: Eth1 uint + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let cs = get_contract self in +let balance = get_balance self in +M.sel (M.sel cs.erc20_cel_allowances _owner) _spender + +let approve (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_spender:address) (_amount:uint) +: Eth1 bool + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_balances == cs1.erc20_cel_balances) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (_spender <> null) then begin +let _ = (_approve self self 0 tx block sender _spender _amount) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +true + +let transferFromReverts (_to:address) (_from:address) (_amount:uint) (old_balances:(m:(M.t address uint lt){M.def_of m == 0})) (old_allowances:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (_sender:address) += (((_from == null) \/ (_to == null)) \/ ((((M.sel old_balances _from) < _amount) \/ ((M.sel old_balances _to) > (uint_max - _amount))))) \/ (((M.sel (M.sel old_allowances _from) _sender) < _amount)) + +let transferFrom (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_from:address) (_to:address) (_amount:uint) +: Eth1 bool + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((transferFromReverts _to _from _amount cs.erc20_cel_balances cs.erc20_cel_allowances sender)) + ) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ ((transferFromPost cs0.erc20_cel_allowances cs1.erc20_cel_allowances cs0.erc20_cel_balances cs1.erc20_cel_balances _from _to sender _amount)) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((_from = null) || (_to = null)) in +let _ = (if x1 then begin +revert " from/to addresses are null"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (((M.sel cs.erc20_cel_balances _from) >= _amount) && ((M.sel cs.erc20_cel_balances _to) <= ((_sub uint_max _amount)))) in +let _ = (if x1 then begin +let _ = (_transfer self self 0 tx block _from _to _amount) in +let cs = get_contract self in +() end +else begin +revert " Underflow/Overflow"; +() end) in +let cs = get_contract self in +let balance = get_contract self in +let x1 = ((M.sel (M.sel cs.erc20_cel_allowances _from) sender) >= _amount) in +let _ = (if x1 then begin +let _ = (_approve self self 0 tx block _from sender (_sub (M.sel (M.sel cs.erc20_cel_allowances _from) sender) _amount)) in +let cs = get_contract self in +() end +else begin +revert " Allowance insufficient"; +() end) in +let cs = get_contract self in +let balance = get_contract self in +true + +let increaseAllowance (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_spender:address) (_addedValue:uint) +: Eth1 bool + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_balances == cs1.erc20_cel_balances) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((_spender <> null) && ((M.sel (M.sel cs.erc20_cel_allowances sender) _spender) <= ((_sub uint_max _addedValue)))) in +let _ = (if x1 then begin +let _ = (_approve self self 0 tx block sender _spender (_add (M.sel (M.sel cs.erc20_cel_allowances sender) _spender) _addedValue)) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +true + +let decreaseAllowance (self:erc20_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_spender:address) (_subtractedValue:uint) +: Eth1 bool + (fun bst -> + erc20_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (totalSupplyInv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + erc20_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (totalSupplyInv self bst1) + /\ (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ (cs0.erc20_cel_balances == cs1.erc20_cel_balances) + /\ (cs0.erc20_cel_totalSupply == cs1.erc20_cel_totalSupply) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((_spender <> null) && ((M.sel (M.sel cs.erc20_cel_allowances sender) _spender) >= _subtractedValue)) in +let _ = (if x1 then begin +let _ = (_approve self self 0 tx block sender _spender (_sub (M.sel (M.sel cs.erc20_cel_allowances sender) _spender) _subtractedValue)) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +true \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/migrations/1_initial_migration.js b/Celestial/Samples/OpenZeppelin/ERC20/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/OpenZeppelin/ERC20/package-lock.json b/Celestial/Samples/OpenZeppelin/ERC20/package-lock.json new file mode 100644 index 00000000..352d1933 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "csv-writer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", + "integrity": "sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==" + } + } +} diff --git a/Celestial/Samples/OpenZeppelin/ERC20/result.csv b/Celestial/Samples/OpenZeppelin/ERC20/result.csv new file mode 100644 index 00000000..eb24027a --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/result.csv @@ -0,0 +1,5 @@ +Method,Celestial Gas,Solidity Gas +Approve,42187,44092 +IncreaseAllowance,29266,30280 +TransferFrom,58590,59967 +DecreaseAllowance,29256,30336 diff --git a/Celestial/Samples/OpenZeppelin/ERC20/test/erc20.js b/Celestial/Samples/OpenZeppelin/ERC20/test/erc20.js new file mode 100644 index 00000000..8be8c180 --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/test/erc20.js @@ -0,0 +1,87 @@ +const createCsvWriter = require('csv-writer').createObjectCsvWriter; +const csvWriter = createCsvWriter({ + path: 'result.csv', + header: [ + {id: 'method', title: 'Method'}, + {id: 'cel_gas', title: 'Celestial Gas'}, + {id: 'sol_gas', title: 'Solidity Gas'}, + ] + }); +const ERC20 = artifacts.require("ERC20"); +const ERC20_cel = artifacts.require("ERC20_Cel"); + +contract("OpenZeppelin ERC20 evaluation", async accounts => { + it("Evaluating Solidity and Celestial versions of ERC20 for gas consumption", async () => { + + let sender = accounts[0]; + let receiver = accounts[1]; + let mintAmt = 100; + let approveAmt = 50; + let increaseAmt = 10; + let decreaseAmt = 10; + let transferAmt = 10; + + // get data for original ERC20 + let instance = await ERC20.new(); + let deploymentReceipt = await web3.eth.getTransactionReceipt(instance.transactionHash); + + let tx = await instance._mint(sender, mintAmt, {from:sender}); + + tx = await instance.approve(receiver, approveAmt, {from:sender}); + var approveGas = tx.receipt.gasUsed; + + tx = await instance.increaseAllowance(receiver, increaseAmt, {from:sender}); + var increaseAllowanceGas = tx.receipt.gasUsed; + + tx = await instance.transferFrom(sender, receiver, transferAmt, {from:receiver}); + var transferFromGas = tx.receipt.gasUsed; + + tx = await instance.decreaseAllowance(receiver, decreaseAmt, {from:sender}); + var decreaseAllowanceGas = tx.receipt.gasUsed; + + // get data for Celestial ERC20 + let instance_cel = await ERC20_cel.new(); + let deploymentReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + + let tx_cel = await instance_cel.mint(sender, mintAmt, {from:sender}); + + tx_cel = await instance_cel.approve(receiver, approveAmt, {from:sender}); + var approveGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.increaseAllowance(receiver, increaseAmt, {from:sender}); + var increaseAllowanceGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.transferFrom(sender, receiver, transferAmt, {from:receiver}); + var transferFromGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.decreaseAllowance(receiver, decreaseAmt, {from:sender}); + var decreaseAllowanceGas_cel = tx_cel.receipt.gasUsed; + + // dump results to csv + const data = [ + { + method: 'Approve', + cel_gas: approveGas_cel, + sol_gas: approveGas, + }, + { + method: 'IncreaseAllowance', + cel_gas: increaseAllowanceGas_cel, + sol_gas: increaseAllowanceGas, + }, + { + method: 'TransferFrom', + cel_gas: transferFromGas_cel, + sol_gas: transferFromGas, + }, + { + method: 'DecreaseAllowance', + cel_gas: decreaseAllowanceGas_cel, + sol_gas: decreaseAllowanceGas, + } + ]; + + csvWriter + .writeRecords(data) + .then(()=> console.log('The CSV file was written successfully')); + })}); \ No newline at end of file diff --git a/Celestial/Samples/OpenZeppelin/ERC20/truffle-config.js b/Celestial/Samples/OpenZeppelin/ERC20/truffle-config.js new file mode 100644 index 00000000..a6177e0d --- /dev/null +++ b/Celestial/Samples/OpenZeppelin/ERC20/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + version: "0.6.8", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/Overview/celestial/Overview.cel b/Celestial/Samples/Overview/celestial/Overview.cel new file mode 100644 index 00000000..e26f85c9 --- /dev/null +++ b/Celestial/Samples/Overview/celestial/Overview.cel @@ -0,0 +1,95 @@ +pragma solidity^0.6.8; +import {Safe_Arith} from"./Safe_Arith.sol"; + +contract Item { + address seller; uint price; address market; + + constructor (address _s, address _m, uint _p) + modifies_addresses [this] + { + seller = _s; + price = _p; + market = _m; + return; + } + + function getSeller () + post (s == seller) + modifies [] + modifies_addresses [this] + returns (address s) + { return seller; } + + function getPrice () + post (ret == price) + modifies [] + modifies_addresses [this] + returns (uint ret) + { return price; } +} + +contract SimpleMarket { + mapping(address => uint) sellerCredits; + inst_map itemsToSell; + uint totalCredits; + event eNewItem (address, address); + event eItemSold (address, address); + + invariant balanceAndSellerCredits { + balance == totalCredits && + totalCredits >= sum_mapping (sellerCredits) + } + + function sell (uint price) public + post (itemId in new(itemsToSell)) + returns (address itemId) + { + itemId = itemsToSell.add(new Item(address(this), sender, price)); + return itemId; + } + + spec buyReverts (address _itemAddress, inst_map old_itemsToSell, mapping (address => uint) old_sellerCredits, uint _value, uint old_sumCredits) + { + ! (_itemAddress in old_itemsToSell) + || (_value != old_itemsToSell[_itemAddress].price) + || (_value + old_sumCredits > uint_max) + } + + function buy (address itemId) public credit + post (!(itemId in new(itemsToSell)) + && new(sellerCredits) == sellerCredits[seller => (sellerCredits[seller] + value)] + && new(log) == (eItemSold, sender, itemId)::log) + tx_reverts buyReverts (itemId, itemsToSell, sellerCredits, value, totalCredits) + + modifies [sellerCredits, totalCredits, itemsToSell, log] + returns (address seller) + { + Item item = itemsToSell[itemId]; + if (address(item) == null) { revert ("No such item"); } + uint iPrice; + iPrice = item.getPrice(); + if (value != iPrice) + { revert ("Incorrect price"); } + seller = item.getSeller(); + totalCredits = safe_add (totalCredits, value); + sellerCredits[seller] = sellerCredits[seller] + value; + delete (itemsToSell, itemId); + emit eItemSold(sender, itemId); + return seller; + } + + function withdraw (uint amount) public debit + pre address(this) != sender + post (new(sellerCredits) == sellerCredits[sender => sellerCredits[sender] - amount]) + && new(totalCredits) == totalCredits - amount + && new(balance) == balance - amount + tx_reverts sellerCredits [sender] < amount + { + if (sellerCredits[sender] >= amount) { + sender.transfer(amount); + sellerCredits[sender] = sellerCredits[sender] - amount; + totalCredits = totalCredits - amount; + } else { revert ("Insufficient balance"); } + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/Overview/contracts/Call.sol b/Celestial/Samples/Overview/contracts/Call.sol new file mode 100644 index 00000000..43365e63 --- /dev/null +++ b/Celestial/Samples/Overview/contracts/Call.sol @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: MIT + +//pragma solidity^0.6.8; +pragma solidity >=0.5.0 <0.7.0; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/Overview/contracts/Migrations.sol b/Celestial/Samples/Overview/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/Overview/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/Overview/contracts/Safe_Arith.sol b/Celestial/Samples/Overview/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/Overview/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/Overview/contracts/contract.sol b/Celestial/Samples/Overview/contracts/contract.sol new file mode 100644 index 00000000..d120e385 --- /dev/null +++ b/Celestial/Samples/Overview/contracts/contract.sol @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract Item { + address seller; + uint price; + address market; + + constructor (address _s, address _m, uint _p) public { + seller = _s; + price = _p; + market = _m; + return; + } + + function getSeller () public returns (address s) { + return seller; + } + + function getPrice () public returns (uint ret) { + return price; + } +} + +contract SimpleMarket { + event eNewItem(address, address); + event eItemSold(address, address); + mapping (address => uint) sellerCredits; + mapping (Item => bool) itemsToSell; + + function get_from_itemsToSell (Item i) private returns (Item) { + if (itemsToSell[i]) return i; + } + + function add_to_itemsToSell (Item i) private returns (Item) { + itemsToSell[i] = true; + return i; + } + uint totalCredits; + + function sell (uint price) public returns (address itemId) { + itemId = address(add_to_itemsToSell(new Item(address(this), msg.sender, price))); + return itemId; + } + + function buy (address itemId) public payable returns (address seller) { + Item item = get_from_itemsToSell(Item(payable(itemId))); + if (address(item) == address(0)) + { + revert ("No such item"); + } + uint iPrice; + item.getPrice(); + if (msg.value != iPrice) + { + revert ("Incorrect price"); + } + item.getSeller(); + totalCredits = Safe_Arith.safe_add(totalCredits, msg.value); + sellerCredits[seller] = sellerCredits[seller] + msg.value; + emit eItemSold(msg.sender, itemId); + return seller; + } + + function withdraw (uint amount) public { + if (sellerCredits[msg.sender] >= amount) + { + msg.sender.transfer(amount); + sellerCredits[msg.sender] = sellerCredits[msg.sender] - amount; + totalCredits = totalCredits - amount; + } + else + { + revert ("Insufficient balance"); + } + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/Overview/fstar/Item.fst b/Celestial/Samples/Overview/fstar/Item.fst new file mode 100644 index 00000000..eb74826c --- /dev/null +++ b/Celestial/Samples/Overview/fstar/Item.fst @@ -0,0 +1,179 @@ +(*Code generated by compiler*) + +module Item + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + + +noeq type t_item = { + item_seller : address; + item_price : uint; + item_market : address; +} + +(* Contract address type, liveness, and field range macros *) + +type item_address = contract t_item +let item_live (c:item_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract Item *) + +let item_get_seller (c:item_address) +: StEth address + (fun st -> c `item_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).item_seller) += let item_inst = get_contract c in + item_inst.item_seller + +let item_get_price (c:item_address) +: StEth uint + (fun st -> c `item_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).item_price) += let item_inst = get_contract c in + item_inst.item_price + +let item_get_market (c:item_address) +: StEth address + (fun st -> c `item_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).item_market) += let item_inst = get_contract c in + item_inst.item_market + +(* Field setters for contract Item *) + +let item_set_seller (c:item_address) (_seller:address) +: StEth unit + (fun st -> c `item_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + item_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with item_seller = _seller })) += let item_inst = get_contract c in + let item_inst = { item_inst with item_seller = _seller } in + set_contract c item_inst + +let item_set_price (c:item_address) (_price:uint) +: StEth unit + (fun st -> c `item_live` st.current + /\ _price >= 0 /\ _price <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + item_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with item_price = _price })) += let item_inst = get_contract c in + let item_inst = { item_inst with item_price = _price } in + set_contract c item_inst + +let item_set_market (c:item_address) (_market:address) +: StEth unit + (fun st -> c `item_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + item_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with item_market = _market })) += let item_inst = get_contract c in + let item_inst = { item_inst with item_market = _market } in + set_contract c item_inst + +let item_constructor (self:item_address) (sender:address) (value:uint) (tx:tx) (block:block) (_s:address) (_m:address) (_p:uint) +: Eth1 unit + (fun bst -> + item_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.item_seller == null) + /\ (cs.item_price == 0) + /\ (cs.item_market == null) + ) + ) + (fun bst -> False) + (fun bst0 x bst1 -> + item_live self bst1 /\ ( + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (bst0.balances == bst1.balances) + /\ (l0 == l1) + /\ CM.modifies_addrs (Set.singleton self) bst0.cmap bst1.cmap + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = item_set_seller self _s in +let cs = get_contract self in +let _ = item_set_price self _p in +let cs = get_contract self in +let _ = item_set_market self _m in +let cs = get_contract self in +() + +let getSeller (self:item_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 address + (fun bst -> + item_live self bst + ) + (fun bst -> False) + (fun bst0 s bst1 -> + item_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((s == cs0.item_seller)) + /\ (bst0.balances == bst1.balances) + /\ CM.modifies_addrs (Set.singleton self) bst0.cmap bst1.cmap + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let s:address = null in +let cs = get_contract self in +let balance = get_balance self in +cs.item_seller + +let getPrice (self:item_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 uint + (fun bst -> + item_live self bst + ) + (fun bst -> False) + (fun bst0 ret bst1 -> + item_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + ((ret == cs0.item_price)) + /\ (bst0.balances == bst1.balances) + /\ CM.modifies_addrs (Set.singleton self) bst0.cmap bst1.cmap + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let ret:uint = 0 in +let cs = get_contract self in +let balance = get_balance self in +cs.item_price \ No newline at end of file diff --git a/Celestial/Samples/Overview/fstar/SimpleMarket.fst b/Celestial/Samples/Overview/fstar/SimpleMarket.fst new file mode 100644 index 00000000..37b38b8c --- /dev/null +++ b/Celestial/Samples/Overview/fstar/SimpleMarket.fst @@ -0,0 +1,273 @@ +(*Code generated by compiler*) + +module SimpleMarket + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +open Item +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val simplemarket_eNewItem : string +assume val simplemarket_eItemSold : string + +noeq type t_simplemarket = { + simplemarket_sellerCredits : (m:(M.t address uint lt){M.def_of m == 0}); + simplemarket_itemsToSell : (m:(M.t item_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}); + simplemarket_totalCredits : uint; +} + +(* Contract address type, liveness, and field range macros *) + +type simplemarket_address = contract t_simplemarket +let simplemarket_live (c:simplemarket_address) (bst:bstate) = + c `CM.live_in` bst.cmap + /\ (let cs = CM.sel c bst.cmap in + (forall (i:item_address). M.contains cs.simplemarket_itemsToSell i ==> i `CM.live_in` bst.cmap /\ i <> c) + ) + +(* Field getters for contract SimpleMarket *) + +let simplemarket_get_sellerCredits (c:simplemarket_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `simplemarket_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simplemarket_sellerCredits) += let simplemarket_inst = get_contract c in + simplemarket_inst.simplemarket_sellerCredits + +let simplemarket_get_itemsToSell (c:simplemarket_address) +: StEth (m:(M.t item_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}) + (fun st -> c `simplemarket_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simplemarket_itemsToSell) += let simplemarket_inst = get_contract c in + simplemarket_inst.simplemarket_itemsToSell + +let simplemarket_get_totalCredits (c:simplemarket_address) +: StEth uint + (fun st -> c `simplemarket_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simplemarket_totalCredits) += let simplemarket_inst = get_contract c in + simplemarket_inst.simplemarket_totalCredits + +(* Field setters for contract SimpleMarket *) + +let simplemarket_set_sellerCredits (c:simplemarket_address) (_sellerCredits:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `simplemarket_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simplemarket_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simplemarket_sellerCredits = _sellerCredits })) += let simplemarket_inst = get_contract c in + let simplemarket_inst = { simplemarket_inst with simplemarket_sellerCredits = _sellerCredits } in + set_contract c simplemarket_inst + +let simplemarket_set_itemsToSell (c:simplemarket_address) (_itemsToSell:(m:(M.t item_address bool lt){M.def_of m == false /\ ~ (M.contains m null)})) +: StEth unit + (fun st -> c `simplemarket_live` st.current + /\ (forall (i:item_address). M.contains _itemsToSell i ==> item_live i st.current /\ i <> c)) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simplemarket_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simplemarket_itemsToSell = _itemsToSell })) += let simplemarket_inst = get_contract c in + let simplemarket_inst = { simplemarket_inst with simplemarket_itemsToSell = _itemsToSell } in + set_contract c simplemarket_inst + +let simplemarket_set_totalCredits (c:simplemarket_address) (_totalCredits:uint) +: StEth unit + (fun st -> c `simplemarket_live` st.current + /\ _totalCredits >= 0 /\ _totalCredits <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simplemarket_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simplemarket_totalCredits = _totalCredits })) += let simplemarket_inst = get_contract c in + let simplemarket_inst = { simplemarket_inst with simplemarket_totalCredits = _totalCredits } in + set_contract c simplemarket_inst + +let balanceAndSellerCredits (self:simplemarket_address) (bst:bstate{self `simplemarket_live` bst}) : Type0 = + let simplemarket_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (simplemarket_balance == cs.simplemarket_totalCredits) /\ (cs.simplemarket_totalCredits >= ((sum_mapping cs.simplemarket_sellerCredits))) + +let sell (self:simplemarket_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (price:uint) +: Eth1 address + (fun bst -> + simplemarket_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (balanceAndSellerCredits self bst) + )) + (fun bst -> False) + (fun bst0 itemId bst1 -> + simplemarket_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (balanceAndSellerCredits self bst1) + /\ (((M.contains cs1.simplemarket_itemsToSell itemId))) + /\ (bst0.balances == bst1.balances) + )) += +let itemId:address = null in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (( +let contract_addr = create_contract ({item_seller = null; item_price = 0; item_market = null; }) in +let _ = item_constructor contract_addr self 0 tx block self sender price in +let _ = simplemarket_set_itemsToSell self (M.upd cs.simplemarket_itemsToSell contract_addr true) in contract_addr)) in +let itemId = x1 in +let cs = get_contract self in +itemId + +let buyReverts (_itemAddress:address) (old_itemsToSell:tuple2 (m:(M.t item_address bool lt){M.def_of m == false /\ ~ (M.contains m null)}) bstate{forall (k:item_address). M.contains (fst old_itemsToSell) k ==> k `CM.live_in` (snd old_itemsToSell).cmap}) (old_sellerCredits:(m:(M.t address uint lt){M.def_of m == 0})) (_value:uint) (old_sumCredits:uint) += ((~ (((M.contains (fst old_itemsToSell) _itemAddress)))) \/ ((_value =!= ((CM.sel _itemAddress (snd old_itemsToSell).cmap).item_price)))) \/ (((_value + old_sumCredits) > uint_max)) + +let buy (self:simplemarket_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (itemId:address) +: Eth1 address + (fun bst -> + simplemarket_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (balanceAndSellerCredits self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((buyReverts itemId (cs.simplemarket_itemsToSell, bst) cs.simplemarket_sellerCredits value cs.simplemarket_totalCredits)) + ) + (fun bst0 seller bst1 -> + simplemarket_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (balanceAndSellerCredits self bst1) + /\ ((((~ (((M.contains cs1.simplemarket_itemsToSell itemId)))) /\ (M.equal cs1.simplemarket_sellerCredits ( + let x1 = (cs0.simplemarket_sellerCredits) in + let x2 = (seller) in + let x3 = (((M.sel cs0.simplemarket_sellerCredits seller) + value)) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (l1 == ((mk_event null simplemarket_eItemSold (sender, itemId))::l0)))) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let seller:address = null in +let cs = get_contract self in +let balance = get_balance self in +let item:item_address = ( +if M.contains cs.simplemarket_itemsToSell itemId then itemId else null) in +let x1 = (item = null) in +let seller = (if x1 then begin +revert "No such item"; +seller end +else seller) in +let cs = get_contract self in +let balance = get_balance self in +let iPrice:uint = (0) in +let bst = (get ()).current in +let x1 = getPrice item self 0 tx block in +let iPrice = x1 in +let balance = get_balance self in +let seller = (if (value <> iPrice) then begin +revert "Incorrect price"; +seller end +else seller) in +let cs = get_contract self in +let balance = get_balance self in +let bst = (get ()).current in +let x1 = getSeller item self 0 tx block in +let seller = x1 in +let balance = get_balance self in +let x1 = ((if cs.simplemarket_totalCredits <= uint_max - value then (cs.simplemarket_totalCredits + value) else revert "Overflow error")) in +let _ = simplemarket_set_totalCredits self x1 in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.simplemarket_sellerCredits seller) value)) in +let sellerCredits = cs.simplemarket_sellerCredits in +let _ = simplemarket_set_sellerCredits self (M.upd sellerCredits seller x1) in +let cs = get_contract self in +let _ = simplemarket_set_itemsToSell self (M.delete cs.simplemarket_itemsToSell itemId) in +let cs = get_contract self in +let _ = emit simplemarket_eItemSold (sender, itemId) in +let cs = get_contract self in +let balance = get_balance self in +seller + +let withdraw (self:simplemarket_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (amount:uint) +: Eth1 unit + (fun bst -> + simplemarket_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (balanceAndSellerCredits self bst) + /\ (self =!= sender) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((M.sel cs.simplemarket_sellerCredits sender) < amount) + ) + (fun bst0 x bst1 -> + simplemarket_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (balanceAndSellerCredits self bst1) + /\ ((((M.equal cs1.simplemarket_sellerCredits ( + let x1 = (cs0.simplemarket_sellerCredits) in + let x2 = (sender) in + let x3 = ((M.sel cs0.simplemarket_sellerCredits sender) - amount) in + let x1 = (M.upd x1 x2 x3) in + x1))) /\ (cs1.simplemarket_totalCredits == (cs0.simplemarket_totalCredits - amount))) /\ (b1 == (b0 - amount))) + /\ (b1 <= b0) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((M.sel cs.simplemarket_sellerCredits sender) >= amount) in +let _ = (if x1 then begin +let _ = transfer self sender amount in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((_sub (M.sel cs.simplemarket_sellerCredits sender) amount)) in +let sellerCredits = cs.simplemarket_sellerCredits in +let _ = simplemarket_set_sellerCredits self (M.upd sellerCredits sender x1) in +let cs = get_contract self in +let _ = simplemarket_set_totalCredits self (_sub cs.simplemarket_totalCredits amount) in +let cs = get_contract self in +() end +else begin +revert "Insufficient balance"; +() end) in +let cs = get_contract self in +let balance = get_contract self in +() \ No newline at end of file diff --git a/Celestial/Samples/Overview/migrations/1_initial_migration.js b/Celestial/Samples/Overview/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/Overview/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/Overview/truffle-config.js b/Celestial/Samples/Overview/truffle-config.js new file mode 100644 index 00000000..7a90d768 --- /dev/null +++ b/Celestial/Samples/Overview/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + // version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/README.md b/Celestial/Samples/README.md new file mode 100644 index 00000000..b5db9691 --- /dev/null +++ b/Celestial/Samples/README.md @@ -0,0 +1,39 @@ +# Experiments + +This directory contains a subdirectory for each contract. Each subdirectory also includes a URL to the original Solidity contract. This contract has to be downloaded manually into the `contracts/` subdirectory for each experiment to run the gas comparision tests. + +This directory also contains a `Data/` subdirectory which has the `.csv` file with the gas comparisions. + +## Instructions to run the experiments + +* `make compile experiment=` + + Compiles the Celestial source for the specified experiment and generates the Solidity and F* versions. + +* `make verify experiment=` + + Verifies the generated F* code for the specified experiment. + +* `make perf experiment=` + + Generates a `.csv` file with gas comparisions for the specified experiment (except overview and binancecoin). + +* `make ` + + Runs all the above targets for the specified experiment. + +* `make all` + + Compiles, verifies and generates gas performance `.csv` file for all experiments. + + +### Experiments + +- `asset_transfer` +- `etherdelta` +- `overview` +- `erc20` +- `wrapped_ether` +- `multisig` +- `simple_auction` +- `binancecoin` \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/README.md b/Celestial/Samples/SimpleAuction/README.md new file mode 100644 index 00000000..106495e5 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/README.md @@ -0,0 +1,3 @@ +# Simple Auction + +[Original Contract](https://docs.soliditylang.org/en/v0.6.8/solidity-by-example.html#simple-open-auction) \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/celestial/SimpleAuction.cel b/Celestial/Samples/SimpleAuction/celestial/SimpleAuction.cel new file mode 100644 index 00000000..ec214308 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/celestial/SimpleAuction.cel @@ -0,0 +1,152 @@ +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract SimpleAuction_Cel { + address beneficiary; + uint auctionEndTime; + address highestBidder; + uint highestBid; + mapping (address => uint) pendingReturns; + bool ended; + + event HighestBidIncreased (address, uint); + event AuctionEnded (address, uint); + + uint totalReturns; + + invariant inv1 + { + totalReturns == balance + } + + invariant inv + { + !ended ==> (balance == sum_mapping (pendingReturns) + highestBid) + } + + // The constructor assumes that balance of the current contract = 0 + // Theoretically, it may be greater than 0 if Ether is sent to this address + // before it was deployed, but it is not probable. + constructor (uint _biddingTime, address _beneficiary) public + pre balance == 0 + tx_reverts block.timestamp + _biddingTime > uint_max + { + beneficiary = _beneficiary; + auctionEndTime = safe_add (block.timestamp, _biddingTime); + return; + } + + spec bidPost ( + uint old_highestBid, uint new_highestBid, + address old_highestBidder, address new_highestBidder, + address _sender, uint _value, + mapping (address => uint) old_pendingReturns, + mapping (address => uint) new_pendingReturns) + { + old_pendingReturns[old_highestBidder] + old_highestBid <= uint_max + && ite ( + old_highestBid != 0, + new_pendingReturns == old_pendingReturns[old_highestBidder => old_pendingReturns[old_highestBidder] + old_highestBid], + new_pendingReturns == old_pendingReturns + ) + && new_highestBidder == _sender + && new_highestBid == _value + } + + function bid () public + credit + post bidPost (highestBid, new(highestBid), highestBidder, new(highestBidder), sender, value, pendingReturns, new(pendingReturns)) + tx_reverts block.timestamp > auctionEndTime + || value <= highestBid + || pendingReturns[highestBidder] + highestBid > uint_max + || totalReturns + value > uint_max + modifies [totalReturns, highestBidder, highestBid, log, pendingReturns] + { + if (block.timestamp > auctionEndTime) + revert ("Auction already ended."); + + if (value <= highestBid) + revert ("There already is a higher bid."); + + totalReturns = safe_add (totalReturns, value); + + if (highestBid != 0) + // If the fact that ended == false can be proved here, + // the safe_add can be replaced with a normal addition + // since the invariant guarantees no overflow + pendingReturns[highestBidder] = safe_add (pendingReturns[highestBidder], highestBid); + + highestBidder = sender; + highestBid = value; + emit HighestBidIncreased (sender, value); + return; + } + + spec withdrawPost( + address _sender, eventlog old_log, eventlog new_log, + mapping (address => uint) old_pendingReturns, + mapping (address => uint) new_pendingReturns, + uint old_balance, uint new_balance) + { + ite ( + old_pendingReturns[_sender] > 0 && old_balance >= old_pendingReturns[_sender], + new_log == (_sender, eTransfer, old_pendingReturns[_sender])::old_log + && ite + ( + new_balance < old_balance, + new_pendingReturns == old_pendingReturns[_sender => 0], + new_pendingReturns == old_pendingReturns + ), + new_pendingReturns == old_pendingReturns + ) + } + + function withdraw () public + debit + post withdrawPost (sender, log, new(log), pendingReturns, new(pendingReturns), balance, new(balance)) + modifies [pendingReturns, totalReturns] + returns (bool) + { + uint amount = pendingReturns[sender]; + if (amount > 0 && balance >= pendingReturns[sender]) + { + sender.transfer(amount); + + // Check if balance did reduce (only happens in the case + // that address(this) == sender, which may be expressed + // as a precondition on this function) + if (balance < totalReturns) + { + pendingReturns[sender] = 0; + totalReturns = totalReturns - amount; + } + } + return true; + } + + function auctionEnd () public + post (new(ended) && (new(log) == (beneficiary, eTransfer, highestBid)::(AuctionEnded, highestBidder, highestBid)::log)) + debit + tx_reverts block.timestamp < auctionEndTime || ended || balance < highestBid + modifies [totalReturns, ended] + { + if (block.timestamp < auctionEndTime) + revert ("Auction not yet ended."); + if (ended) + revert ("auctionEnd has already been called."); + + ended = true; + emit AuctionEnded (highestBidder, highestBid); + + payable(beneficiary).transfer(highestBid); + + // Check if balance did reduce (only happens in the case + // that address(this) == beneficiary, which may be + // expressed as a precondition on this function) + if (balance < totalReturns) + totalReturns = totalReturns - highestBid; + + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/contracts/Call.sol b/Celestial/Samples/SimpleAuction/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/contracts/Migrations.sol b/Celestial/Samples/SimpleAuction/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/SimpleAuction/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/SimpleAuction/contracts/Safe_Arith.sol b/Celestial/Samples/SimpleAuction/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/SimpleAuction/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/contracts/contract.sol b/Celestial/Samples/SimpleAuction/contracts/contract.sol new file mode 100644 index 00000000..622f8110 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/contracts/contract.sol @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract SimpleAuction_Cel { + event HighestBidIncreased(address, uint); + event AuctionEnded(address, uint); + address beneficiary; + uint auctionEndTime; + address highestBidder; + uint highestBid; + mapping (address => uint) pendingReturns; + bool ended; + uint totalReturns; + + constructor (uint _biddingTime, address _beneficiary) public { + beneficiary = _beneficiary; + auctionEndTime = Safe_Arith.safe_add(block.timestamp, _biddingTime); + return; + } + + function bid () public payable { + if (block.timestamp > auctionEndTime) + revert ("Auction already ended."); + if (msg.value <= highestBid) + revert ("There already is a higher bid."); + totalReturns = Safe_Arith.safe_add(totalReturns, msg.value); + if (highestBid != 0) + pendingReturns[highestBidder] = Safe_Arith.safe_add(pendingReturns[highestBidder], highestBid); + highestBidder = msg.sender; + highestBid = msg.value; + emit HighestBidIncreased(msg.sender, msg.value); + return; + } + + function withdraw () public returns (bool) { + uint amount = pendingReturns[msg.sender]; + if (amount > 0 && address(this).balance >= pendingReturns[msg.sender]) + { + msg.sender.transfer(amount); + if (address(this).balance < totalReturns) + { + pendingReturns[msg.sender] = 0; + totalReturns = totalReturns - amount; + } + } + return true; + } + + function auctionEnd () public { + if (block.timestamp < auctionEndTime) + revert ("Auction not yet ended."); + if (ended) + revert ("auctionEnd has already been called."); + ended = true; + emit AuctionEnded(highestBidder, highestBid); + payable(beneficiary).transfer(highestBid); + if (address(this).balance < totalReturns) + totalReturns = totalReturns - highestBid; + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/fstar/SimpleAuction_Cel.fst b/Celestial/Samples/SimpleAuction/fstar/SimpleAuction_Cel.fst new file mode 100644 index 00000000..6bd66feb --- /dev/null +++ b/Celestial/Samples/SimpleAuction/fstar/SimpleAuction_Cel.fst @@ -0,0 +1,451 @@ +(*Code generated by compiler*) + +module SimpleAuction_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val simpleauction_cel_HighestBidIncreased : string +assume val simpleauction_cel_AuctionEnded : string + +noeq type t_simpleauction_cel = { + simpleauction_cel_beneficiary : address; + simpleauction_cel_auctionEndTime : uint; + simpleauction_cel_highestBidder : address; + simpleauction_cel_highestBid : uint; + simpleauction_cel_pendingReturns : (m:(M.t address uint lt){M.def_of m == 0}); + simpleauction_cel_ended : bool; + simpleauction_cel_totalReturns : uint; +} + +(* Contract address type, liveness, and field range macros *) + +type simpleauction_cel_address = contract t_simpleauction_cel +let simpleauction_cel_live (c:simpleauction_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract SimpleAuction_Cel *) + +let simpleauction_cel_get_beneficiary (c:simpleauction_cel_address) +: StEth address + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_beneficiary) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_beneficiary + +let simpleauction_cel_get_auctionEndTime (c:simpleauction_cel_address) +: StEth uint + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_auctionEndTime) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_auctionEndTime + +let simpleauction_cel_get_highestBidder (c:simpleauction_cel_address) +: StEth address + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_highestBidder) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_highestBidder + +let simpleauction_cel_get_highestBid (c:simpleauction_cel_address) +: StEth uint + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_highestBid) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_highestBid + +let simpleauction_cel_get_pendingReturns (c:simpleauction_cel_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_pendingReturns) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_pendingReturns + +let simpleauction_cel_get_ended (c:simpleauction_cel_address) +: StEth bool + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_ended) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_ended + +let simpleauction_cel_get_totalReturns (c:simpleauction_cel_address) +: StEth uint + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).simpleauction_cel_totalReturns) += let simpleauction_cel_inst = get_contract c in + simpleauction_cel_inst.simpleauction_cel_totalReturns + +(* Field setters for contract SimpleAuction_Cel *) + +let simpleauction_cel_set_beneficiary (c:simpleauction_cel_address) (_beneficiary:address) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_beneficiary = _beneficiary })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_beneficiary = _beneficiary } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_auctionEndTime (c:simpleauction_cel_address) (_auctionEndTime:uint) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current + /\ _auctionEndTime >= 0 /\ _auctionEndTime <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_auctionEndTime = _auctionEndTime })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_auctionEndTime = _auctionEndTime } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_highestBidder (c:simpleauction_cel_address) (_highestBidder:address) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_highestBidder = _highestBidder })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_highestBidder = _highestBidder } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_highestBid (c:simpleauction_cel_address) (_highestBid:uint) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current + /\ _highestBid >= 0 /\ _highestBid <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_highestBid = _highestBid })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_highestBid = _highestBid } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_pendingReturns (c:simpleauction_cel_address) (_pendingReturns:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_pendingReturns = _pendingReturns })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_pendingReturns = _pendingReturns } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_ended (c:simpleauction_cel_address) (_ended:bool) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_ended = _ended })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_ended = _ended } in + set_contract c simpleauction_cel_inst + +let simpleauction_cel_set_totalReturns (c:simpleauction_cel_address) (_totalReturns:uint) +: StEth unit + (fun st -> c `simpleauction_cel_live` st.current + /\ _totalReturns >= 0 /\ _totalReturns <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + simpleauction_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with simpleauction_cel_totalReturns = _totalReturns })) += let simpleauction_cel_inst = get_contract c in + let simpleauction_cel_inst = { simpleauction_cel_inst with simpleauction_cel_totalReturns = _totalReturns } in + set_contract c simpleauction_cel_inst + +let inv1 (self:simpleauction_cel_address) (bst:bstate{self `simpleauction_cel_live` bst}) : Type0 = + let simpleauction_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.simpleauction_cel_totalReturns == simpleauction_cel_balance + +let inv (self:simpleauction_cel_address) (bst:bstate{self `simpleauction_cel_live` bst}) : Type0 = + let simpleauction_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (~ (cs.simpleauction_cel_ended) ==> (simpleauction_cel_balance == (((sum_mapping cs.simpleauction_cel_pendingReturns)) + cs.simpleauction_cel_highestBid))) + +let simpleauction_cel_constructor (self:simpleauction_cel_address) (sender:address) (value:uint) (tx:tx) (block:block) (_biddingTime:uint) (_beneficiary:address) +: Eth1 unit + (fun bst -> + simpleauction_cel_live self bst /\ + (let b = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + (sender <> null) + /\ (cs.simpleauction_cel_beneficiary == null) + /\ (cs.simpleauction_cel_auctionEndTime == 0) + /\ (cs.simpleauction_cel_highestBidder == null) + /\ (cs.simpleauction_cel_highestBid == 0) + /\ (cs.simpleauction_cel_pendingReturns == M.const (0)) + /\ (cs.simpleauction_cel_ended == false) + /\ (cs.simpleauction_cel_totalReturns == 0) + /\ (b == 0) + ) + ) + (fun bst -> + ((block.timestamp + _biddingTime) > uint_max) + ) + (fun bst0 x bst1 -> + simpleauction_cel_live self bst1 + /\ (inv1 self bst1) + /\ (inv self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +let _ = simpleauction_cel_set_beneficiary self _beneficiary in +let cs = get_contract self in +let x1 = ((if block.timestamp <= uint_max - _biddingTime then (block.timestamp + _biddingTime) else revert "Overflow error")) in +let _ = simpleauction_cel_set_auctionEndTime self x1 in +let cs = get_contract self in +() + +let bidPost (old_highestBid:uint) (new_highestBid:uint) (old_highestBidder:address) (new_highestBidder:address) (_sender:address) (_value:uint) (old_pendingReturns:(m:(M.t address uint lt){M.def_of m == 0})) (new_pendingReturns:(m:(M.t address uint lt){M.def_of m == 0})) += (((((M.sel old_pendingReturns old_highestBidder) + old_highestBid) <= uint_max) /\ (if (old_highestBid <> 0) then + (M.equal new_pendingReturns ( + let x1 = (old_pendingReturns) in + let x2 = (old_highestBidder) in + let x3 = ((M.sel old_pendingReturns old_highestBidder) + old_highestBid) in + let x1 = (M.upd x1 x2 x3) in + x1)) +else + (M.equal new_pendingReturns old_pendingReturns) +)) /\ (new_highestBidder == _sender)) /\ (new_highestBid == _value) + +let bid (self:simpleauction_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + simpleauction_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (inv1 self bst) + /\ (inv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((((block.timestamp > cs.simpleauction_cel_auctionEndTime) \/ (value <= cs.simpleauction_cel_highestBid)) \/ (((M.sel cs.simpleauction_cel_pendingReturns cs.simpleauction_cel_highestBidder) + cs.simpleauction_cel_highestBid) > uint_max)) \/ ((cs.simpleauction_cel_totalReturns + value) > uint_max)) + ) + (fun bst0 x bst1 -> + simpleauction_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (inv1 self bst1) + /\ (inv self bst1) + /\ ((bidPost cs0.simpleauction_cel_highestBid cs1.simpleauction_cel_highestBid cs0.simpleauction_cel_highestBidder cs1.simpleauction_cel_highestBidder sender value cs0.simpleauction_cel_pendingReturns cs1.simpleauction_cel_pendingReturns)) + /\ (cs0.simpleauction_cel_ended == cs1.simpleauction_cel_ended) + /\ (cs0.simpleauction_cel_auctionEndTime == cs1.simpleauction_cel_auctionEndTime) + /\ (cs0.simpleauction_cel_beneficiary == cs1.simpleauction_cel_beneficiary) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (block.timestamp > cs.simpleauction_cel_auctionEndTime) then begin +revert "Auction already ended."; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (value <= cs.simpleauction_cel_highestBid) in +let _ = (if x1 then begin +revert "There already is a higher bid."; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if cs.simpleauction_cel_totalReturns <= uint_max - value then (cs.simpleauction_cel_totalReturns + value) else revert "Overflow error")) in +let _ = simpleauction_cel_set_totalReturns self x1 in +let cs = get_contract self in +let _ = (if (cs.simpleauction_cel_highestBid <> 0) then begin +let x1 = ((if (M.sel cs.simpleauction_cel_pendingReturns cs.simpleauction_cel_highestBidder) <= uint_max - cs.simpleauction_cel_highestBid then ((M.sel cs.simpleauction_cel_pendingReturns cs.simpleauction_cel_highestBidder) + cs.simpleauction_cel_highestBid) else revert "Overflow error")) in +let x2 = (cs.simpleauction_cel_highestBidder) in +let pendingReturns = cs.simpleauction_cel_pendingReturns in +let _ = simpleauction_cel_set_pendingReturns self (M.upd pendingReturns x2 x1) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = simpleauction_cel_set_highestBidder self sender in +let cs = get_contract self in +let _ = simpleauction_cel_set_highestBid self value in +let cs = get_contract self in +let _ = emit simpleauction_cel_HighestBidIncreased (sender, value) in +let cs = get_contract self in +let balance = get_balance self in +() + +let withdrawPost (_sender:address) (old_log:log) (new_log:log) (old_pendingReturns:(m:(M.t address uint lt){M.def_of m == 0})) (new_pendingReturns:(m:(M.t address uint lt){M.def_of m == 0})) (old_balance:uint) (new_balance:uint) += if (((M.sel old_pendingReturns _sender) > 0) && (old_balance >= (M.sel old_pendingReturns _sender))) then + ((new_log == ((mk_event _sender eTransfer (M.sel old_pendingReturns _sender))::old_log)) /\ (if (new_balance < old_balance) then + (M.equal new_pendingReturns ( + let x1 = (old_pendingReturns) in + let x2 = (_sender) in + let x3 = (0) in + let x1 = (M.upd x1 x2 x3) in + x1)) +else + (M.equal new_pendingReturns old_pendingReturns) +)) +else + (M.equal new_pendingReturns old_pendingReturns) + + +let withdraw (self:simpleauction_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 bool + (fun bst -> + simpleauction_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (inv1 self bst) + /\ (inv self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + simpleauction_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (inv1 self bst1) + /\ (inv self bst1) + /\ ((withdrawPost sender l0 l1 cs0.simpleauction_cel_pendingReturns cs1.simpleauction_cel_pendingReturns b0 b1)) + /\ (b1 <= b0) + /\ (cs0.simpleauction_cel_auctionEndTime == cs1.simpleauction_cel_auctionEndTime) + /\ (cs0.simpleauction_cel_ended == cs1.simpleauction_cel_ended) + /\ (cs0.simpleauction_cel_highestBidder == cs1.simpleauction_cel_highestBidder) + /\ (cs0.simpleauction_cel_highestBid == cs1.simpleauction_cel_highestBid) + /\ (cs0.simpleauction_cel_beneficiary == cs1.simpleauction_cel_beneficiary) + )) += +let cs = get_contract self in +let balance = get_balance self in +let amount:uint = (M.sel cs.simpleauction_cel_pendingReturns sender) in +let x1 = ((amount > 0) && (balance >= (M.sel cs.simpleauction_cel_pendingReturns sender))) in +let _ = (if x1 then begin +let _ = transfer self sender amount in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (balance < cs.simpleauction_cel_totalReturns) then begin +let pendingReturns = cs.simpleauction_cel_pendingReturns in +let _ = simpleauction_cel_set_pendingReturns self (M.upd pendingReturns sender 0) in +let cs = get_contract self in +let _ = simpleauction_cel_set_totalReturns self (_sub cs.simpleauction_cel_totalReturns amount) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +true + +let auctionEnd (self:simpleauction_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + simpleauction_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (inv1 self bst) + /\ (inv self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((block.timestamp < cs.simpleauction_cel_auctionEndTime) \/ cs.simpleauction_cel_ended) \/ (b < cs.simpleauction_cel_highestBid)) + ) + (fun bst0 x bst1 -> + simpleauction_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (inv1 self bst1) + /\ (inv self bst1) + /\ ((cs1.simpleauction_cel_ended /\ ((l1 == ((mk_event cs0.simpleauction_cel_beneficiary eTransfer cs0.simpleauction_cel_highestBid)::(mk_event null simpleauction_cel_AuctionEnded (cs0.simpleauction_cel_highestBidder, cs0.simpleauction_cel_highestBid))::l0))))) + /\ (b1 <= b0) + /\ (cs0.simpleauction_cel_auctionEndTime == cs1.simpleauction_cel_auctionEndTime) + /\ (cs0.simpleauction_cel_pendingReturns == cs1.simpleauction_cel_pendingReturns) + /\ (cs0.simpleauction_cel_highestBidder == cs1.simpleauction_cel_highestBidder) + /\ (cs0.simpleauction_cel_highestBid == cs1.simpleauction_cel_highestBid) + /\ (cs0.simpleauction_cel_beneficiary == cs1.simpleauction_cel_beneficiary) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (block.timestamp < cs.simpleauction_cel_auctionEndTime) then begin +revert "Auction not yet ended."; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (cs.simpleauction_cel_ended) then begin +revert "auctionEnd has already been called."; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = simpleauction_cel_set_ended self true in +let cs = get_contract self in +let _ = emit simpleauction_cel_AuctionEnded (cs.simpleauction_cel_highestBidder, cs.simpleauction_cel_highestBid) in +let cs = get_contract self in +let balance = get_balance self in +let x2 = (cs.simpleauction_cel_highestBid) in +let _ = transfer self (cs.simpleauction_cel_beneficiary) x2 in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (balance < cs.simpleauction_cel_totalReturns) then begin +let _ = simpleauction_cel_set_totalReturns self (_sub cs.simpleauction_cel_totalReturns cs.simpleauction_cel_highestBid) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/migrations/1_initial_migration.js b/Celestial/Samples/SimpleAuction/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/SimpleAuction/package-lock.json b/Celestial/Samples/SimpleAuction/package-lock.json new file mode 100644 index 00000000..352d1933 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "csv-writer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", + "integrity": "sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==" + } + } +} diff --git a/Celestial/Samples/SimpleAuction/result.csv b/Celestial/Samples/SimpleAuction/result.csv new file mode 100644 index 00000000..668dcd7a --- /dev/null +++ b/Celestial/Samples/SimpleAuction/result.csv @@ -0,0 +1,6 @@ +Method,Celestial Gas,Solidity Gas +Deployment,804197,520529 +Bid1,88726,65890 +Bid2,69235,58449 +Withdraw,27418,19813 +AuctionEnd,48338,55913 diff --git a/Celestial/Samples/SimpleAuction/test/simpleAuction.js b/Celestial/Samples/SimpleAuction/test/simpleAuction.js new file mode 100644 index 00000000..118bb247 --- /dev/null +++ b/Celestial/Samples/SimpleAuction/test/simpleAuction.js @@ -0,0 +1,104 @@ +const createCsvWriter = require('csv-writer').createObjectCsvWriter; +const csvWriter = createCsvWriter({ + path: 'result.csv', + header: [ + {id: 'method', title: 'Method'}, + {id: 'cel_gas', title: 'Celestial Gas'}, + {id: 'sol_gas', title: 'Solidity Gas'}, + ] + }); +const SimpleAuction = artifacts.require("SimpleAuction"); +const Safe_Arith = artifacts.require("Safe_Arith"); +const SimpleAuction_cel = artifacts.require("SimpleAuction_Cel"); + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +contract("SimpleAuction evaluation", async accounts => { + it("Evaluating Solidity and Celestial versions of SimpleAuction for gas consumption", async () => { + + let beneficiary = accounts[0]; + let biddingTime = 5; + let bidder1 = accounts[1]; + let bidder1bid = 10; + let bidder2 = accounts[2]; + let bidder2bid = 20; + + // get data for original SimpleAuction + let instance = await SimpleAuction.new(biddingTime, beneficiary); + let deploymentReceipt = await web3.eth.getTransactionReceipt(instance.transactionHash); + var deploymentGas = parseInt(deploymentReceipt.gasUsed); // retrieve gas needed for deployment + + let tx = await instance.bid({from:bidder1, value:bidder1bid}); + var bid1Gas = tx.receipt.gasUsed; + + tx = await instance.bid({from:bidder2, value:bidder2bid}); + var bid2Gas = tx.receipt.gasUsed; + + tx = await instance.withdraw({from:bidder1}); + var withdrawGas = tx.receipt.gasUsed; + + // doing this to ensure we go past the auctionEndTime + await sleep(biddingTime*1000); + + tx = await instance.auctionEnd(); + var auctionEndGas = tx.receipt.gasUsed; + + // get data for Celestial SimpleAuction + let instance_cel = await Safe_Arith.new(); + let libraryReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + var libraryGas_cel = parseInt(libraryReceipt_cel.gasUsed); + await SimpleAuction_cel.link("Safe_Arith", instance_cel.address); + instance_cel = await SimpleAuction_cel.new(biddingTime, beneficiary); + let deploymentReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + var deploymentGas_cel = parseInt(deploymentReceipt_cel.gasUsed) + libraryGas_cel; // retrieve gas needed for deployment + + let tx_cel = await instance_cel.bid({from:bidder1, value:bidder1bid}); + var bid1Gas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.bid({from:bidder2, value:bidder2bid}); + var bid2Gas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.withdraw({from:bidder1}); + var withdrawGas_cel = tx_cel.receipt.gasUsed; + + // doing this to ensure we go past the auctionEndTime + await sleep(biddingTime*1000); + + tx_cel = await instance_cel.auctionEnd(); + var auctionEndGas_cel = tx_cel.receipt.gasUsed; + + // dump results to csv + const data = [ + { + method: 'Deployment', + cel_gas: deploymentGas_cel, + sol_gas: deploymentGas, + }, + { + method: 'Bid1', + cel_gas: bid1Gas_cel, + sol_gas: bid1Gas, + }, + { + method: 'Bid2', + cel_gas: bid2Gas_cel, + sol_gas: bid2Gas, + }, + { + method: 'Withdraw', + cel_gas: withdrawGas_cel, + sol_gas: withdrawGas, + }, + { + method: 'AuctionEnd', + cel_gas: auctionEndGas_cel, + sol_gas: auctionEndGas, + } + ]; + + csvWriter + .writeRecords(data) + .then(()=> console.log('The CSV file was written successfully')); + })}); \ No newline at end of file diff --git a/Celestial/Samples/SimpleAuction/truffle-config.js b/Celestial/Samples/SimpleAuction/truffle-config.js new file mode 100644 index 00000000..a6177e0d --- /dev/null +++ b/Celestial/Samples/SimpleAuction/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + version: "0.6.8", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/Samples/WrappedEther/README.md b/Celestial/Samples/WrappedEther/README.md new file mode 100644 index 00000000..6869f627 --- /dev/null +++ b/Celestial/Samples/WrappedEther/README.md @@ -0,0 +1,3 @@ +# Wrapped Ether + +[Original contract](https://etherscan.io/address/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2#code) \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/celestial/WrappedEther.cel b/Celestial/Samples/WrappedEther/celestial/WrappedEther.cel new file mode 100644 index 00000000..cfcd8e8f --- /dev/null +++ b/Celestial/Samples/WrappedEther/celestial/WrappedEther.cel @@ -0,0 +1,158 @@ +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract WETH9_Cel { + string name = "Wrapped Ether"; + string symbol = "WETH"; + uint decimals = 18; + + event Approval (address, address, uint); + event Transfer (address, address, uint); + event Deposit (address, uint); + event Withdrawal (address, uint); + + mapping (address => uint) balanceOf; + mapping (address => mapping (address => uint)) allowance; + + uint totalBalance; + + invariant sumBalances + { + totalBalance == sum_mapping (balanceOf) + } + + invariant actualBalance + { + balance == totalBalance + } + + function deposit () public + post new(balanceOf) == balanceOf [sender => balanceOf[sender] + value] + && new(log) == (Deposit, sender, value)::log + credit + tx_reverts (value + totalBalance > uint_max) + modifies [balanceOf, totalBalance] + { + totalBalance = safe_add(totalBalance, value); + balanceOf[sender] = balanceOf[sender] + value; + emit Deposit (sender, value); + return; + } + + function withdraw (uint _wad) public + post new(log) == (Withdrawal, sender, _wad)::(sender, eTransfer, _wad)::log + && ite ( + new(balance) < balance, + new(balanceOf) == balanceOf[sender => balanceOf[sender] - _wad], + new(balanceOf) == balanceOf + ) + debit + tx_reverts balance < _wad || balanceOf[sender] < _wad + modifies [balanceOf, totalBalance] + { + if (balanceOf[sender] < _wad) { + revert ("Insufficient balance"); + } + sender.transfer(_wad); + emit Withdrawal (sender, _wad); + + // Check if balance did reduce (only happens in the case + // that address(this) == sender, which may be expressed + // as a precondition on this function) + if (balance < totalBalance) + { + balanceOf[sender] = balanceOf[sender] - _wad; + totalBalance = totalBalance - _wad; + } + return; + } + + function totalSupply () public + post (a == balance) + modifies [] + returns (uint a) + { + a = balance; + return a; + } + + function approve (address _guy, uint _wad) public + post new(allowance) == allowance[sender => allowance[sender][_guy => _wad]] + modifies [allowance, log] + returns (bool) + { + allowance[sender][_guy] = _wad; + emit Approval (sender, _guy, _wad); + return true; + } + + spec transferFromReverts( + mapping (address => uint) old_balanceOf, + mapping (address => mapping (address => uint)) old_allowance, + address _sender, address _src, + address _dst, uint _wad) + { + _src == _dst + || old_balanceOf[_src] < _wad + ||_src != _sender && old_allowance[_src][_sender] != uint_max + && old_allowance[_src][_sender] < _wad + } + + spec transferFromPost( + mapping (address => uint) old_balanceOf, + mapping (address => uint) new_balanceOf, + mapping (address => mapping (address => uint)) old_allowance, + mapping (address => mapping (address => uint)) new_allowance, + address _sender, address _src, + address _dst, uint _wad) + { + ite ( + _src != _sender && old_allowance[_src][_sender] != uint_max, + old_allowance[_src][_sender] >= _wad // added to let this function typecheck correctly + && new_allowance == old_allowance[_src => old_allowance[_src][_sender => (old_allowance[_src][_sender] - _wad)]], + new_allowance == old_allowance + ) + && old_balanceOf[_dst] + _wad <= uint_max + && old_balanceOf[_src] >= _wad // added to let this function typecheck correctly + && new_balanceOf == old_balanceOf[_src => old_balanceOf[_src] - _wad, _dst => old_balanceOf[_dst] + _wad] + } + + function transferFrom (address _src, address _dst, uint _wad) public + post transferFromPost (balanceOf, new(balanceOf), allowance, new(allowance), sender, _src, _dst, _wad) + tx_reverts transferFromReverts (balanceOf, allowance, sender, _src, _dst, _wad) + modifies [balanceOf, allowance, log] + returns (bool) + { + if (_src == _dst) { + revert ("Redundant transfer"); + } + if (balanceOf[_src] < _wad) { + revert ("Insufficient balance"); + } + if (_src != sender && allowance[_src][sender] != uint_max) { + if (allowance[_src][sender] < _wad) { + revert ("Insufficient allowance"); + } + allowance[_src][sender] = allowance[_src][sender] - _wad; + } + balanceOf[_src] = balanceOf[_src] - _wad; + balanceOf[_dst] = balanceOf[_dst] + _wad; + emit Transfer (_src, _dst, _wad); + return true; + } + + function _transfer (address _dst, uint _wad) public + tx_reverts transferFromReverts (balanceOf, allowance, address(this), sender, _dst, _wad) + returns (bool) + { + return transferFrom(sender, _dst, _wad); + } + + receive () credit { + totalBalance = safe_add(totalBalance, value); + balanceOf[sender] = balanceOf[sender] + value; + emit Deposit (sender, value); + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/contracts/Call.sol b/Celestial/Samples/WrappedEther/contracts/Call.sol new file mode 100644 index 00000000..0ab1c492 --- /dev/null +++ b/Celestial/Samples/WrappedEther/contracts/Call.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT + +pragma solidity^0.6.8; + +library Call +{ + function call_uint (address a, bytes memory call_data) public returns (uint) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (uint)); + } + + function call_bool (address a, bytes memory call_data) public returns (bool) + { + (bool success, bytes memory ret) = a.call(call_data); + if (!success) revert (""); + return abi.decode(ret, (bool)); + } +} \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/contracts/Migrations.sol b/Celestial/Samples/WrappedEther/contracts/Migrations.sol new file mode 100644 index 00000000..fcbe1ebc --- /dev/null +++ b/Celestial/Samples/WrappedEther/contracts/Migrations.sol @@ -0,0 +1,18 @@ +pragma solidity >=0.4.21 <0.7.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + constructor() public { + owner = msg.sender; + } + + modifier restricted() { + if (msg.sender == owner) _; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } +} diff --git a/Celestial/Samples/WrappedEther/contracts/Safe_Arith.sol b/Celestial/Samples/WrappedEther/contracts/Safe_Arith.sol new file mode 100644 index 00000000..1e2db3ce --- /dev/null +++ b/Celestial/Samples/WrappedEther/contracts/Safe_Arith.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: MIT +/* Code generated by compiler */ +library Safe_Arith { + + function safe_add (uint a, uint b) public pure returns (uint) { + if (a > a + b) revert (" Overflow Error"); + else return (a + b); + } + + function safe_sub (uint a, uint b) public pure returns (uint) { + if (a < b) revert (" Underflow Error"); + else return (a - b); + } + + function safe_mul (uint a, uint b) public pure returns (uint) { + if (b == 0) return 0; + if (a != (a * b)/b) revert (" Overflow Error"); + else return (a * b); + } + + function safe_div (uint a, uint b) public pure returns (uint) { + if (b == 0) revert (" Division by 0 error"); + else return (a / b); + } +} \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/contracts/contract.sol b/Celestial/Samples/WrappedEther/contracts/contract.sol new file mode 100644 index 00000000..d71213e2 --- /dev/null +++ b/Celestial/Samples/WrappedEther/contracts/contract.sol @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: MIT +pragma solidity^0.6.8; + +import { Safe_Arith } from "./Safe_Arith.sol" ; + +contract WETH9_Cel { + event Approval(address, address, uint); + event Transfer(address, address, uint); + event Deposit(address, uint); + event Withdrawal(address, uint); + string name = "Wrapped Ether"; + string symbol = "WETH"; + uint decimals = 18; + mapping (address => uint) balanceOf; + mapping (address => mapping (address => uint)) allowance; + uint totalBalance; + + function deposit () public payable { + totalBalance = Safe_Arith.safe_add(totalBalance, msg.value); + balanceOf[msg.sender] = balanceOf[msg.sender] + msg.value; + emit Deposit(msg.sender, msg.value); + return; + } + + function withdraw (uint _wad) public { + if (balanceOf[msg.sender] < _wad) + { + revert ("Insufficient balance"); + } + msg.sender.transfer(_wad); + emit Withdrawal(msg.sender, _wad); + if (address(this).balance < totalBalance) + { + balanceOf[msg.sender] = balanceOf[msg.sender] - _wad; + totalBalance = totalBalance - _wad; + } + return; + } + + function totalSupply () public returns (uint a) { + a = address(this).balance; + return a; + } + + function approve (address _guy, uint _wad) public returns (bool) { + allowance[msg.sender][_guy] = _wad; + emit Approval(msg.sender, _guy, _wad); + return true; + } + + function transferFrom (address _src, address _dst, uint _wad) public returns (bool) { + if (_src == _dst) + { + revert ("Redundant transfer"); + } + if (balanceOf[_src] < _wad) + { + revert ("Insufficient balance"); + } + if (_src != msg.sender && allowance[_src][msg.sender] != (~uint256(0))) + { + if (allowance[_src][msg.sender] < _wad) + { + revert ("Insufficient allowance"); + } + allowance[_src][msg.sender] = allowance[_src][msg.sender] - _wad; + } + balanceOf[_src] = balanceOf[_src] - _wad; + balanceOf[_dst] = balanceOf[_dst] + _wad; + emit Transfer(_src, _dst, _wad); + return true; + } + + function _transfer (address _dst, uint _wad) public returns (bool) { + return transferFrom(msg.sender, _dst, _wad); + } + + receive () external payable { + totalBalance = Safe_Arith.safe_add(totalBalance, msg.value); + balanceOf[msg.sender] = balanceOf[msg.sender] + msg.value; + emit Deposit(msg.sender, msg.value); + return; + } +} \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/fstar/WETH9_Cel.fst b/Celestial/Samples/WrappedEther/fstar/WETH9_Cel.fst new file mode 100644 index 00000000..3e8a7549 --- /dev/null +++ b/Celestial/Samples/WrappedEther/fstar/WETH9_Cel.fst @@ -0,0 +1,573 @@ +(*Code generated by compiler*) + +module WETH9_Cel + +open FStar.Celestial +open FStar.Celestial.Effect +module CM = FStar.Celestial.ContractsMap +open FStar.Mul +module M = FStar.Celestial.Map +module L = FStar.List.Tot +module A = FStar.Celestial.Array + +assume val weth9_cel_Approval : string +assume val weth9_cel_Transfer : string +assume val weth9_cel_Deposit : string +assume val weth9_cel_Withdrawal : string + +noeq type t_weth9_cel = { + weth9_cel_name : string; + weth9_cel_symbol : string; + weth9_cel_decimals : uint; + weth9_cel_balanceOf : (m:(M.t address uint lt){M.def_of m == 0}); + weth9_cel_allowance : (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}); + weth9_cel_totalBalance : uint; +} + +(* Contract address type, liveness, and field range macros *) + +type weth9_cel_address = contract t_weth9_cel +let weth9_cel_live (c:weth9_cel_address) (bst:bstate) = + c `CM.live_in` bst.cmap + +(* Field getters for contract WETH9_Cel *) + +let weth9_cel_get_name (c:weth9_cel_address) +: StEth string + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_name) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_name + +let weth9_cel_get_symbol (c:weth9_cel_address) +: StEth string + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_symbol) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_symbol + +let weth9_cel_get_decimals (c:weth9_cel_address) +: StEth uint + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_decimals) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_decimals + +let weth9_cel_get_balanceOf (c:weth9_cel_address) +: StEth (m:(M.t address uint lt){M.def_of m == 0}) + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_balanceOf) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_balanceOf + +let weth9_cel_get_allowance (c:weth9_cel_address) +: StEth (m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)}) + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_allowance) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_allowance + +let weth9_cel_get_totalBalance (c:weth9_cel_address) +: StEth uint + (fun st -> c `weth9_cel_live` st.current) + (fun st0 r st1 -> + st0 == st1 /\ r == (CM.sel c st0.current.cmap).weth9_cel_totalBalance) += let weth9_cel_inst = get_contract c in + weth9_cel_inst.weth9_cel_totalBalance + +(* Field setters for contract WETH9_Cel *) + +let weth9_cel_set_name (c:weth9_cel_address) (_name:string) +: StEth unit + (fun st -> c `weth9_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_name = _name })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_name = _name } in + set_contract c weth9_cel_inst + +let weth9_cel_set_symbol (c:weth9_cel_address) (_symbol:string) +: StEth unit + (fun st -> c `weth9_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_symbol = _symbol })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_symbol = _symbol } in + set_contract c weth9_cel_inst + +let weth9_cel_set_decimals (c:weth9_cel_address) (_decimals:uint) +: StEth unit + (fun st -> c `weth9_cel_live` st.current + /\ _decimals >= 0 /\ _decimals <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_decimals = _decimals })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_decimals = _decimals } in + set_contract c weth9_cel_inst + +let weth9_cel_set_balanceOf (c:weth9_cel_address) (_balanceOf:(m:(M.t address uint lt){M.def_of m == 0})) +: StEth unit + (fun st -> c `weth9_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_balanceOf = _balanceOf })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_balanceOf = _balanceOf } in + set_contract c weth9_cel_inst + +let weth9_cel_set_allowance (c:weth9_cel_address) (_allowance:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) +: StEth unit + (fun st -> c `weth9_cel_live` st.current) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_allowance = _allowance })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_allowance = _allowance } in + set_contract c weth9_cel_inst + +let weth9_cel_set_totalBalance (c:weth9_cel_address) (_totalBalance:uint) +: StEth unit + (fun st -> c `weth9_cel_live` st.current + /\ _totalBalance >= 0 /\ _totalBalance <= uint_max) + (fun st0 _ st1 -> + modifies_cmap_only (Set.singleton c) st0.current st1.current /\ + weth9_cel_live c st1.current /\ + (let instance0 = CM.sel c st0.current.cmap in + let instance1 = CM.sel c st1.current.cmap in + instance1 == { instance0 with weth9_cel_totalBalance = _totalBalance })) += let weth9_cel_inst = get_contract c in + let weth9_cel_inst = { weth9_cel_inst with weth9_cel_totalBalance = _totalBalance } in + set_contract c weth9_cel_inst + +let sumBalances (self:weth9_cel_address) (bst:bstate{self `weth9_cel_live` bst}) : Type0 = + let weth9_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + cs.weth9_cel_totalBalance == ((sum_mapping cs.weth9_cel_balanceOf)) + +let actualBalance (self:weth9_cel_address) (bst:bstate{self `weth9_cel_live` bst}) : Type0 = + let weth9_cel_balance = pure_get_balance_bst self bst in + let cs = CM.sel self bst.cmap in + weth9_cel_balance == cs.weth9_cel_totalBalance + +let deposit (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (((value + cs.weth9_cel_totalBalance) > uint_max)) + ) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + /\ ((M.equal cs1.weth9_cel_balanceOf ( + let x1 = (cs0.weth9_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.weth9_cel_balanceOf sender) + value) in + let x1 = (M.upd x1 x2 x3) in + x1)) /\ (l1 == ((mk_event null weth9_cel_Deposit (sender, value))::l0))) + /\ (cs0.weth9_cel_decimals == cs1.weth9_cel_decimals) + /\ (cs0.weth9_cel_allowance == cs1.weth9_cel_allowance) + /\ (cs0.weth9_cel_name == cs1.weth9_cel_name) + /\ (cs0.weth9_cel_symbol == cs1.weth9_cel_symbol) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if cs.weth9_cel_totalBalance <= uint_max - value then (cs.weth9_cel_totalBalance + value) else revert "Overflow error")) in +let _ = weth9_cel_set_totalBalance self x1 in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.weth9_cel_balanceOf sender) value)) in +let balanceOf = cs.weth9_cel_balanceOf in +let _ = weth9_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let _ = emit weth9_cel_Deposit (sender, value) in +let cs = get_contract self in +let balance = get_balance self in +() + +let withdraw (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_wad:uint) +: Eth1 unit + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((b < _wad) \/ ((M.sel cs.weth9_cel_balanceOf sender) < _wad)) + ) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + /\ ((l1 == ((mk_event null weth9_cel_Withdrawal (sender, _wad))::(mk_event sender eTransfer _wad)::l0)) /\ (if (b1 < b0) then + (M.equal cs1.weth9_cel_balanceOf ( + let x1 = (cs0.weth9_cel_balanceOf) in + let x2 = (sender) in + let x3 = ((M.sel cs0.weth9_cel_balanceOf sender) - _wad) in + let x1 = (M.upd x1 x2 x3) in + x1)) +else + (M.equal cs1.weth9_cel_balanceOf cs0.weth9_cel_balanceOf) +)) + /\ (b1 <= b0) + /\ (cs0.weth9_cel_decimals == cs1.weth9_cel_decimals) + /\ (cs0.weth9_cel_allowance == cs1.weth9_cel_allowance) + /\ (cs0.weth9_cel_name == cs1.weth9_cel_name) + /\ (cs0.weth9_cel_symbol == cs1.weth9_cel_symbol) + )) += +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((M.sel cs.weth9_cel_balanceOf sender) < _wad) then begin +revert "Insufficient balance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = transfer self sender _wad in +let cs = get_contract self in +let balance = get_balance self in +let _ = emit weth9_cel_Withdrawal (sender, _wad) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if (balance < cs.weth9_cel_totalBalance) then begin +let x1 = ((_sub (M.sel cs.weth9_cel_balanceOf sender) _wad)) in +let balanceOf = cs.weth9_cel_balanceOf in +let _ = weth9_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let _ = weth9_cel_set_totalBalance self (_sub cs.weth9_cel_totalBalance _wad) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +() + +let totalSupply (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 uint + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> False) + (fun bst0 a bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + /\ ((a == b0)) + /\ (bst0.balances == bst1.balances) + /\ (cs0 == cs1) + /\ (l0 == l1) + )) += +let a:uint = 0 in +let cs = get_contract self in +let balance = get_balance self in +let x1 = (balance) in +let a = x1 in +let cs = get_contract self in +a + +let approve (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_guy:address) (_wad:uint) +: Eth1 bool + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> False) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + /\ (M.equal cs1.weth9_cel_allowance ( + let x1 = (cs0.weth9_cel_allowance) in + let x2 = (sender) in + let x3 = ( + let x1 = (M.sel cs0.weth9_cel_allowance sender) in + let x2 = (_guy) in + let x3 = (_wad) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.weth9_cel_decimals == cs1.weth9_cel_decimals) + /\ (cs0.weth9_cel_symbol == cs1.weth9_cel_symbol) + /\ (cs0.weth9_cel_balanceOf == cs1.weth9_cel_balanceOf) + /\ (cs0.weth9_cel_totalBalance == cs1.weth9_cel_totalBalance) + /\ (cs0.weth9_cel_name == cs1.weth9_cel_name) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x5 = (_wad) in +let x4 = cs.weth9_cel_allowance in + +let x3 = (sender) in +let x2 = (M.sel x4 x3) in +let x1 = (_guy) in +let x0 = (M.sel x2 x1) in + +let _ = weth9_cel_set_allowance self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +let _ = emit weth9_cel_Approval (sender, _guy, _wad) in +let cs = get_contract self in +let balance = get_balance self in +true + +let transferFromReverts (old_balanceOf:(m:(M.t address uint lt){M.def_of m == 0})) (old_allowance:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (_sender:address) (_src:address) (_dst:address) (_wad:uint) += ((_src == _dst) \/ ((M.sel old_balanceOf _src) < _wad)) \/ (((_src =!= _sender) /\ ((M.sel (M.sel old_allowance _src) _sender) =!= uint_max)) /\ ((M.sel (M.sel old_allowance _src) _sender) < _wad)) + +let transferFromPost (old_balanceOf:(m:(M.t address uint lt){M.def_of m == 0})) (new_balanceOf:(m:(M.t address uint lt){M.def_of m == 0})) (old_allowance:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (new_allowance:(m:(M.t address (m:(M.t address uint lt){M.def_of m == 0}) lt){M.def_of m == M.const (0)})) (_sender:address) (_src:address) (_dst:address) (_wad:uint) += (((if ((_src <> _sender) && ((M.sel (M.sel old_allowance _src) _sender) <> uint_max)) then + (((M.sel (M.sel old_allowance _src) _sender) >= _wad) /\ (M.equal new_allowance ( + let x1 = (old_allowance) in + let x2 = (_src) in + let x3 = ( + let x1 = (M.sel old_allowance _src) in + let x2 = (_sender) in + let x3 = (((M.sel (M.sel old_allowance _src) _sender) - _wad)) in + let x1 = (M.upd x1 x2 x3) in + x1) in + let x1 = (M.upd x1 x2 x3) in + x1))) +else + (M.equal new_allowance old_allowance) +) /\ (((M.sel old_balanceOf _dst) + _wad) <= uint_max)) /\ ((M.sel old_balanceOf _src) >= _wad)) /\ (M.equal new_balanceOf ( + let x1 = (old_balanceOf) in + let x2 = (_src) in + let x3 = ((M.sel old_balanceOf _src) - _wad) in + let x1 = (M.upd x1 x2 x3) in + let x2 = (_dst) in + let x3 = ((M.sel old_balanceOf _dst) + _wad) in + let x1 = (M.upd x1 x2 x3) in + x1)) + +let transferFrom (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_src:address) (_dst:address) (_wad:uint) +: Eth1 bool + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((transferFromReverts cs.weth9_cel_balanceOf cs.weth9_cel_allowance sender _src _dst _wad)) + ) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + /\ ((transferFromPost cs0.weth9_cel_balanceOf cs1.weth9_cel_balanceOf cs0.weth9_cel_allowance cs1.weth9_cel_allowance sender _src _dst _wad)) + /\ (bst0.balances == bst1.balances) + /\ (cs0.weth9_cel_decimals == cs1.weth9_cel_decimals) + /\ (cs0.weth9_cel_totalBalance == cs1.weth9_cel_totalBalance) + /\ (cs0.weth9_cel_name == cs1.weth9_cel_name) + /\ (cs0.weth9_cel_symbol == cs1.weth9_cel_symbol) + )) += +let cs = get_contract self in +let balance = get_balance self in +let x1 = (_src = _dst) in +let _ = (if x1 then begin +revert "Redundant transfer"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((M.sel cs.weth9_cel_balanceOf _src) < _wad) then begin +revert "Insufficient balance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let _ = (if ((_src <> sender) && ((M.sel (M.sel cs.weth9_cel_allowance _src) sender) <> uint_max)) then begin +let _ = (if ((M.sel (M.sel cs.weth9_cel_allowance _src) sender) < _wad) then begin +revert "Insufficient allowance"; +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x5 = ((_sub (M.sel (M.sel cs.weth9_cel_allowance _src) sender) _wad)) in +let x4 = cs.weth9_cel_allowance in + +let x3 = (_src) in +let x2 = (M.sel x4 x3) in +let x1 = (sender) in +let x0 = (M.sel x2 x1) in + +let _ = weth9_cel_set_allowance self (M.upd x4 x3 (M.upd x2 x1 x5)) in +let cs = get_contract self in +() end +else ()) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((_sub (M.sel cs.weth9_cel_balanceOf _src) _wad)) in +let balanceOf = cs.weth9_cel_balanceOf in +let _ = weth9_cel_set_balanceOf self (M.upd balanceOf _src x1) in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.weth9_cel_balanceOf _dst) _wad)) in +let balanceOf = cs.weth9_cel_balanceOf in +let _ = weth9_cel_set_balanceOf self (M.upd balanceOf _dst x1) in +let cs = get_contract self in +let _ = emit weth9_cel_Transfer (_src, _dst, _wad) in +let cs = get_contract self in +let balance = get_balance self in +true + +let _transfer (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) (_dst:address) (_wad:uint) +: Eth1 bool + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + ((transferFromReverts cs.weth9_cel_balanceOf cs.weth9_cel_allowance self sender _dst _wad)) + ) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 + /\ (sumBalances self bst1) + /\ (actualBalance self bst1) + ) += +let cs = get_contract self in +let balance = get_balance self in +(transferFrom self self 0 tx block sender _dst _wad) + +let receive (self:weth9_cel_address) (sender:address{sender <> null}) (value:uint) (tx:tx) (block:block) +: Eth1 unit + (fun bst -> + weth9_cel_live self bst /\ ( + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + (sumBalances self bst) + /\ (actualBalance self bst) + )) + (fun bst -> + let cs = CM.sel self bst.cmap in + let b = pure_get_balance_bst self bst in + let l = bst.log in + False) + (fun bst0 x bst1 -> + weth9_cel_live self bst1 /\ ( + let cs0 = CM.sel self bst0.cmap in + let cs1 = CM.sel self bst1.cmap in + let b0 = pure_get_balance_bst self bst0 in + let b1 = pure_get_balance_bst self bst1 in + let l0 = bst0.log in + let l1 = bst1.log in + (sumBalances self bst1) + /\ (actualBalance self bst1) + )) += +let b = get_balance self in +let _ = set_balance self ( + if (b + value > uint_max) then (b + value - uint_max) + else (b + value)) in +let cs = get_contract self in +let balance = get_balance self in +let x1 = ((if cs.weth9_cel_totalBalance <= uint_max - value then (cs.weth9_cel_totalBalance + value) else revert "Overflow error")) in +let _ = weth9_cel_set_totalBalance self x1 in +let cs = get_contract self in +let x1 = ((_add (M.sel cs.weth9_cel_balanceOf sender) value)) in +let balanceOf = cs.weth9_cel_balanceOf in +let _ = weth9_cel_set_balanceOf self (M.upd balanceOf sender x1) in +let cs = get_contract self in +let _ = emit weth9_cel_Deposit (sender, value) in +let cs = get_contract self in +let balance = get_balance self in +() \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/migrations/1_initial_migration.js b/Celestial/Samples/WrappedEther/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/Celestial/Samples/WrappedEther/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/Celestial/Samples/WrappedEther/package-lock.json b/Celestial/Samples/WrappedEther/package-lock.json new file mode 100644 index 00000000..352d1933 --- /dev/null +++ b/Celestial/Samples/WrappedEther/package-lock.json @@ -0,0 +1,11 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "csv-writer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", + "integrity": "sha512-NOx7YDFWEsM/fTRAJjRpPp8t+MKRVvniAg9wQlUKx20MFrPs73WLJhFf5iteqrxNYnsy924K3Iroh3yNHeYd2g==" + } + } +} diff --git a/Celestial/Samples/WrappedEther/result.csv b/Celestial/Samples/WrappedEther/result.csv new file mode 100644 index 00000000..1fe6848c --- /dev/null +++ b/Celestial/Samples/WrappedEther/result.csv @@ -0,0 +1,6 @@ +Method,Celestial Gas,Solidity Gas +Deployment,1200605,826118 +Deposit,66484,43642 +Withdraw,43897,37311 +Approve,43732,43963 +TransferFrom,60180,60050 diff --git a/Celestial/Samples/WrappedEther/test/wrappedEther.js b/Celestial/Samples/WrappedEther/test/wrappedEther.js new file mode 100644 index 00000000..757d2ba8 --- /dev/null +++ b/Celestial/Samples/WrappedEther/test/wrappedEther.js @@ -0,0 +1,95 @@ +const createCsvWriter = require('csv-writer').createObjectCsvWriter; +const csvWriter = createCsvWriter({ + path: 'result.csv', + header: [ + {id: 'method', title: 'Method'}, + {id: 'cel_gas', title: 'Celestial Gas'}, + {id: 'sol_gas', title: 'Solidity Gas'}, + ] + }); +const Weth9 = artifacts.require("WETH9"); +const Safe_Arith = artifacts.require("Safe_Arith"); +const Weth9_cel = artifacts.require("WETH9_Cel"); + +contract("WrappedEther evaluation", async accounts => { + it("Evaluating Solidity and Celestial versions of WrappedEther for gas consumption", async () => { + + let sender = accounts[0]; + let spender = accounts[1]; + let receiver = accounts[2]; + let depositAmt = 100; + let withdrawAmt = 50; + let approveAmt = 20; + let transferAmt = 10; + + // get data for original WrappedEther + let instance = await Weth9.new(); + let deploymentReceipt = await web3.eth.getTransactionReceipt(instance.transactionHash); + var deploymentGas = parseInt(deploymentReceipt.gasUsed); + + let tx = await instance.deposit({from:sender, value:depositAmt}); + var depositGas = tx.receipt.gasUsed; + + tx = await instance.withdraw(withdrawAmt, {from:sender}); + var withdrawGas = tx.receipt.gasUsed; + + tx = await instance.approve(spender, approveAmt, {from:sender}); + var approveGas = tx.receipt.gasUsed; + + tx = await instance.transferFrom(sender, receiver, transferAmt, {from:spender}); + var transferFromGas = tx.receipt.gasUsed; + + // get data for Celestial WrappedEther + let libraryInstance_cel = await Safe_Arith.new(); + let libraryReceipt_cel = await web3.eth.getTransactionReceipt(libraryInstance_cel.transactionHash); + var libraryGas_cel = parseInt(libraryReceipt_cel.gasUsed); + await Weth9_cel.link("Safe_Arith", libraryInstance_cel.address); + let instance_cel = await Weth9_cel.new(); + let deploymentReceipt_cel = await web3.eth.getTransactionReceipt(instance_cel.transactionHash); + var deploymentGas_cel = parseInt(deploymentReceipt_cel.gasUsed) + libraryGas_cel; + + let tx_cel = await instance_cel.deposit({from:sender, value:depositAmt}); + var depositGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.withdraw(withdrawAmt, {from:sender}); + var withdrawGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.approve(spender, approveAmt, {from:sender}); + var approveGas_cel = tx_cel.receipt.gasUsed; + + tx_cel = await instance_cel.transferFrom(sender, receiver, transferAmt, {from:spender}); + var transferFromGas_cel = tx_cel.receipt.gasUsed; + + // dump results to csv + const data = [ + { + method: 'Deployment', + cel_gas: deploymentGas_cel, + sol_gas: deploymentGas, + }, + { + method: 'Deposit', + cel_gas: depositGas_cel, + sol_gas: depositGas, + }, + { + method: 'Withdraw', + cel_gas: withdrawGas_cel, + sol_gas: withdrawGas, + }, + { + method: 'Approve', + cel_gas: approveGas_cel, + sol_gas: approveGas, + }, + { + method: 'TransferFrom', + cel_gas: transferFromGas_cel, + sol_gas: transferFromGas, + } + ]; + + csvWriter + .writeRecords(data) + .then(()=> console.log('The CSV file was written successfully')); + })}); \ No newline at end of file diff --git a/Celestial/Samples/WrappedEther/truffle-config.js b/Celestial/Samples/WrappedEther/truffle-config.js new file mode 100644 index 00000000..a6177e0d --- /dev/null +++ b/Celestial/Samples/WrappedEther/truffle-config.js @@ -0,0 +1,99 @@ +/** + * Use this file to configure your truffle project. It's seeded with some + * common settings for different networks and features like migrations, + * compilation and testing. Uncomment the ones you need or modify + * them to suit your project as necessary. + * + * More information about configuration can be found at: + * + * truffleframework.com/docs/advanced/configuration + * + * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) + * to sign your transactions before they're sent to a remote public node. Infura accounts + * are available for free at: infura.io/register. + * + * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate + * public/private key pairs. If you're publishing your code to GitHub make sure you load this + * phrase from a file you've .gitignored so it doesn't accidentally become public. + * + */ + +// const HDWalletProvider = require('@truffle/hdwallet-provider'); +// const infuraKey = "fj4jll3k....."; +// +// const fs = require('fs'); +// const mnemonic = fs.readFileSync(".secret").toString().trim(); + +module.exports = { + /** + * Networks define how you connect to your ethereum client and let you set the + * defaults web3 uses to send transactions. If you don't specify one truffle + * will spin up a development blockchain for you on port 9545 when you + * run `develop` or `test`. You can ask a truffle command to use a specific + * network from the command line, e.g + * + * $ truffle test --network + */ + + networks: { + // Useful for testing. The `development` name is special - truffle uses it by default + // if it's defined here and no other network is specified at the command line. + // You should run a client (like ganache-cli, geth or parity) in a separate terminal + // tab if you use this network and you must also set the `host`, `port` and `network_id` + // options below to some value. + // + // development: { + // host: "127.0.0.1", // Localhost (default: none) + // port: 8545, // Standard Ethereum port (default: none) + // network_id: "*", // Any network (default: none) + // }, + + // Another network with more advanced options... + // advanced: { + // port: 8777, // Custom port + // network_id: 1342, // Custom network + // gas: 8500000, // Gas sent with each transaction (default: ~6700000) + // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) + // from:
, // Account to send txs from (default: accounts[0]) + // websockets: true // Enable EventEmitter interface for web3 (default: false) + // }, + + // Useful for deploying to a public network. + // NB: It's important to wrap the provider as a function. + // ropsten: { + // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), + // network_id: 3, // Ropsten's id + // gas: 5500000, // Ropsten has a lower block limit than mainnet + // confirmations: 2, // # of confs to wait between deployments. (default: 0) + // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) + // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) + // }, + + // Useful for private networks + // private: { + // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), + // network_id: 2111, // This network is yours, in the cloud. + // production: true // Treats this network as if it was a public net. (default: false) + // } + }, + + // Set default mocha options here, use special reporters etc. + mocha: { + // timeout: 100000 + }, + + // Configure your compilers + compilers: { + solc: { + version: "0.6.8", // Fetch exact version from solc-bin (default: truffle's version) + // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) + // settings: { // See the solidity docs for advice about optimization and evmVersion + // optimizer: { + // enabled: false, + // runs: 200 + // }, + // evmVersion: "byzantium" + // } + } + } +} diff --git a/Celestial/readme.md b/Celestial/readme.md new file mode 100644 index 00000000..53d89011 --- /dev/null +++ b/Celestial/readme.md @@ -0,0 +1,63 @@ +# Celestial + +Celestial is a framework to develop formally verified smart contracts written in the Solidity language for the Ethereum blockchain. Celestial allows programmers to annotate smart contracts with expressive functional specifications. It translates the contracts and their specifications to F\* and (automatically) formally verifies that the contract meets these specifications, against an F\* model of the blockchain semantics. Once the verification succeeds, Celestial erases these specifications to generate Solidity code for execution on the Ethereum blockchain. The image shows the architecture of the Celestial framework: + +![Celestial's Architecture](CelestialArchitecture.png) + +We demonstrate Celestial by verifying several real-world smart contracts from different application domains such as tokens, digital wallets, etc. + +
+ +## Repository Structure + +The repository consists of the following directories: +* `Compiler/`: Contains the source for the prettyprinters +* `Compiler/lib/`: Contains F* and Solidity libraries +* `Samples/`: Contains the contracts we verified, with a subdirectory for each contract +* `Contract_Telemetry/`: Contains scripts used to obtain contract telemetry + +
+ +## Installation + +Celestial requires the following tools: +* **F***: See [this](https://github.com/FStarLang/FStar/blob/master/INSTALL.md) to install F*. +* **Python 3**: See [this](https://www.python.org/downloads/) to install Python 3 +* **ANTLR 4**: See [this](https://www.antlr.org/download.html) to install ANTLR + +The Celestial prettyprinters require the following python packages to be installed: +* **antlr4**: `pip install antlr4-python3-runtime` +* **prettytable**: `pip install PrettyTable` +* **argparse**: `pip install argparse` + +
+ +## Usage +### Instructions to compile a Celestial source: +```sh +$ python3 ./main.py [--fstDir="path_to_output_directory_for_FStar_code"] +[--solDir="path_to_output_directory_for_Solidity_code"] +``` + +The F\* code will be generated in the current directory (if `fstDir` is not specified) with the same name as the contract. The Solidity file will be named `contract.sol`. + +### Instructions to verify the generated code using F\* +``` +fstar --include ../Compiler/lib [--z3rlimit 50] +``` +One can increase ```z3rlimit``` if required. More details about F* can be found [here](https://github.com/FStarLang/FStar). + +### Platform + +We have tested Celestial on Ubuntu running on Windows 10, via the Windows Subsystem for Linux. The tool should run as intended on other flavors of Linux, and MacOS. + +
+ +## Contribution / Issues + +Celestial is under development. Please contact [Suvam](mailto:sumukherjee@microsoft.com) or [Samvid](mailto:t-sadha@microsoft.com) in case of any bugs or feature requests. + +
+ +## License +Celestial is released under the MIT license. \ No newline at end of file