flamingo-finance / flamingo-contract-swap

7 stars 5 forks source link

manifest: describe all notifications emitted by the contract #11

Open AnnaShaleva opened 3 years ago

AnnaShaleva commented 3 years ago

Describe the bug

getcontractstate RPC call for the Flamingo Swap-Pair Contract deployed on the current RC1 testnet gives me the following answer:

curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getcontractstate", "params": ["0x9aa489eb224778d77214b888dec33a811fbabd63"] }' seed1t.neo.org:20332 | json_pp

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  9095    0  8978  100   117  23626    307 --:--:-- --:--:-- --:--:-- 23934
{
   "id" : 1,
   "result" : {
      "id" : 8,
      "nef" : {
         "compiler" : "neon-3.0.0.0",
         "tokens" : [
            {
               "hasreturnvalue" : false,
               "hash" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
               "method" : "update",
               "callflags" : "All",
               "paramcount" : 3
            },
            {
               "paramcount" : 1,
               "callflags" : "All",
               "method" : "deserialize",
               "hasreturnvalue" : true,
               "hash" : "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
            },
            {
               "method" : "serialize",
               "callflags" : "All",
               "paramcount" : 1,
               "hasreturnvalue" : true,
               "hash" : "0xacce6fd80d44e1796aa0c2c625e9e4e0ce39efc0"
            },
            {
               "hash" : "0xfffdc93764dbaddd97c48f252a53ea4643faa3fd",
               "hasreturnvalue" : true,
               "paramcount" : 1,
               "method" : "getContract",
               "callflags" : "All"
            }
         ],
         "checksum" : 1442561715,
         "magic" : 860243278,
         "script" : "VwECDBTPduKL0AYsSkeO41VhARMZ88+k0gwBAIvbIQwUwYCMqLCTIUiax57E8Zd/O9xN3l8MAQCL2yG1cGgmOgwUz3bii9AGLEpHjuNVYQETGfPPpNI1ZwcAAAwUwYCMqLCTIUiax57E8Zd/O9xN3l81XwcAACI5IQwUwYCMqLCTIUiax57E8Zd/O9xN3l81LgcAAAwUz3bii9AGLEpHjuNVYQETGfPPpNI1Jg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3cMbwwmEDUA+v//aXp5VDX7/P//ITXd+f//aVA1zvj//3U15Pn//2lQNcH4//92bWt4n7ckBRAiB21reJ+fdwdubHmftyQFECIHbmx5n593CG8HELckCG8IELciAxEMGUlOU1VGRklDSUVOVF9JTlBVVF9BTU9VTlRQNZr2//9tDALoA9shoG8HE6CfdwluDALoA9shoG8IE6CfdwpvCW8KoGtsoAwDQEIP2yGguAwBS1A1Yvb//21ualM1kgEAAGhvB28IeHl6FlUWwAwHU3dhcHBlZEGVAW9hEXcNbw1ADAhMUC1CLUdBU0A1Rfj//0BXCAR6ELZxaSYxDCxUaGUgcGFyYW1ldGVyIGFtb3VudCBNVVNUIGJlIGdyZWF0ZXIgdGhhbiAwLjp4Qfgn7IwkDXhBOVNuPJcQsyIDEHJqJhYMEU5vIGF1dGhvcml6YXRpb24uOiFB2/6odHB5aLNzayY5QTlTbjw1Aff//wwlT25seSBzdXBwb3J0IHRyYW5zZmVyIHRvIG1lIGJ5IFJvdXRlclA1fvX//3g10Pf//3q1dGwmGgwVSW5zdWZmaWNpZW50IGJhbGFuY2UuOnh5s3VtJgYRdiJceHpQNQL7//95elA1KPn//3h5elMTwAwIVHJhbnNmZXJBlQFvYXk3AwDYqncHbwcmKXkMDm9uTkVQMTdQYXltZW50HxPDShB40EoRetBKEnvQVEFifVtSRRF2bkBXAQI0UxCzcGgmFgwRTm8gYXV0aG9yaXphdGlvbi46eHkLUzcAAEBXAAN6eBBQ0Hp5EVDQekG3w4gDElDQejUA+///eHlQEsAMBlN5bmNlZEGVAW9hQDWe9///Qfgn7IxA"
      },
      "hash" : "0x9aa489eb224778d77214b888dec33a811fbabd63",
      "manifest" : {
         "name" : "Flamingo Swap-Pair Contract",
         "abi" : {
            "events" : [
               {
                  "name" : "Synced",
                  "parameters" : [
                     {
                        "name" : "balance0",
                        "type" : "Integer"
                     },
                     {
                        "name" : "balance1",
                        "type" : "Integer"
                     }
                  ]
               },
               {
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "caller"
                     },
                     {
                        "name" : "amount0",
                        "type" : "Integer"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount1"
                     },
                     {
                        "name" : "liquidity",
                        "type" : "Integer"
                     }
                  ],
                  "name" : "Minted"
               },
               {
                  "name" : "Burned",
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "caller"
                     },
                     {
                        "type" : "Integer",
                        "name" : "liquidity"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount0"
                     },
                     {
                        "name" : "amount1",
                        "type" : "Integer"
                     },
                     {
                        "type" : "Hash160",
                        "name" : "to"
                     }
                  ]
               },
               {
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "caller"
                     },
                     {
                        "name" : "amount0In",
                        "type" : "Integer"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount1In"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount0Out"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount1Out"
                     },
                     {
                        "name" : "to",
                        "type" : "Hash160"
                     }
                  ],
                  "name" : "Swapped"
               },
               {
                  "parameters" : [
                     {
                        "name" : "token0",
                        "type" : "Hash160"
                     },
                     {
                        "type" : "Hash160",
                        "name" : "token1"
                     }
                  ],
                  "name" : "Deployed"
               },
               {
                  "parameters" : [
                     {
                        "name" : "from",
                        "type" : "Hash160"
                     },
                     {
                        "type" : "Hash160",
                        "name" : "to"
                     },
                     {
                        "name" : "amount",
                        "type" : "Integer"
                     }
                  ],
                  "name" : "Transfer"
               }
            ],
            "methods" : [
               {
                  "name" : "_deploy",
                  "offset" : 0,
                  "safe" : false,
                  "returntype" : "Void",
                  "parameters" : [
                     {
                        "type" : "Any",
                        "name" : "data"
                     },
                     {
                        "name" : "update",
                        "type" : "Boolean"
                     }
                  ]
               },
               {
                  "safe" : false,
                  "returntype" : "Void",
                  "parameters" : [],
                  "offset" : 205,
                  "name" : "_initialize"
               },
               {
                  "offset" : 366,
                  "name" : "balanceOf",
                  "safe" : false,
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "account"
                     }
                  ],
                  "returntype" : "Integer"
               },
               {
                  "safe" : false,
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "toAddress"
                     }
                  ],
                  "returntype" : "Any",
                  "offset" : 376,
                  "name" : "burn"
               },
               {
                  "returntype" : "Boolean",
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "callScript"
                     }
                  ],
                  "safe" : false,
                  "name" : "checkIsRouter",
                  "offset" : 678
               },
               {
                  "offset" : 753,
                  "name" : "decimals",
                  "parameters" : [],
                  "returntype" : "Integer",
                  "safe" : false
               },
               {
                  "offset" : 1110,
                  "name" : "getAdmin",
                  "safe" : false,
                  "parameters" : [],
                  "returntype" : "Hash160"
               },
               {
                  "parameters" : [],
                  "returntype" : "Any",
                  "safe" : false,
                  "name" : "getReserves",
                  "offset" : 1213
               },
               {
                  "offset" : 1224,
                  "name" : "getToken0",
                  "parameters" : [],
                  "returntype" : "Hash160",
                  "safe" : false
               },
               {
                  "offset" : 1235,
                  "name" : "getToken1",
                  "returntype" : "Hash160",
                  "parameters" : [],
                  "safe" : false
               },
               {
                  "safe" : false,
                  "parameters" : [],
                  "returntype" : "Hash160",
                  "offset" : 1246,
                  "name" : "getWhiteListContract"
               },
               {
                  "parameters" : [
                     {
                        "name" : "toAddress",
                        "type" : "Hash160"
                     }
                  ],
                  "returntype" : "Integer",
                  "safe" : false,
                  "name" : "mint",
                  "offset" : 1356
               },
               {
                  "safe" : false,
                  "parameters" : [
                     {
                        "name" : "from",
                        "type" : "Hash160"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount"
                     },
                     {
                        "name" : "data",
                        "type" : "Any"
                     }
                  ],
                  "returntype" : "Void",
                  "name" : "onNEP17Payment",
                  "offset" : 1696
               },
               {
                  "name" : "setAdmin",
                  "offset" : 2019,
                  "returntype" : "Boolean",
                  "parameters" : [
                     {
                        "name" : "admin",
                        "type" : "Hash160"
                     }
                  ],
                  "safe" : false
               },
               {
                  "name" : "setWhiteListContract",
                  "offset" : 2072,
                  "returntype" : "Boolean",
                  "parameters" : [
                     {
                        "type" : "Hash160",
                        "name" : "whiteList"
                     }
                  ],
                  "safe" : false
               },
               {
                  "parameters" : [
                     {
                        "type" : "Integer",
                        "name" : "amount0Out"
                     },
                     {
                        "name" : "amount1Out",
                        "type" : "Integer"
                     },
                     {
                        "type" : "Hash160",
                        "name" : "toAddress"
                     }
                  ],
                  "returntype" : "Boolean",
                  "safe" : false,
                  "offset" : 2396,
                  "name" : "swap"
               },
               {
                  "name" : "symbol",
                  "offset" : 2844,
                  "returntype" : "String",
                  "parameters" : [],
                  "safe" : false
               },
               {
                  "safe" : false,
                  "parameters" : [],
                  "returntype" : "Integer",
                  "name" : "totalSupply",
                  "offset" : 2855
               },
               {
                  "returntype" : "Boolean",
                  "parameters" : [
                     {
                        "name" : "from",
                        "type" : "Hash160"
                     },
                     {
                        "name" : "to",
                        "type" : "Hash160"
                     },
                     {
                        "type" : "Integer",
                        "name" : "amount"
                     },
                     {
                        "name" : "data",
                        "type" : "Any"
                     }
                  ],
                  "safe" : false,
                  "name" : "transfer",
                  "offset" : 2861
               },
               {
                  "name" : "update",
                  "offset" : 3170,
                  "returntype" : "Void",
                  "parameters" : [
                     {
                        "type" : "ByteArray",
                        "name" : "nefFile"
                     },
                     {
                        "type" : "String",
                        "name" : "manifest"
                     }
                  ],
                  "safe" : false
               },
               {
                  "name" : "verify",
                  "offset" : 3256,
                  "parameters" : [],
                  "returntype" : "Boolean",
                  "safe" : false
               }
            ]
         },
         "groups" : [],
         "extra" : {
            "Email" : "developer@flamingo.finance",
            "Author" : "Flamingo Finance",
            "Description" : "This is a Flamingo Contract"
         },
         "supportedstandards" : [
            "NEP-17"
         ],
         "trusts" : [],
         "permissions" : [
            {
               "methods" : "*",
               "contract" : "*"
            }
         ]
      },
      "updatecounter" : 0
   },
   "jsonrpc" : "2.0"
}

As you can see, there are only six events described in the contract manifest (Synced, Minted, Burned, Swapped, Deployed and Transfer). However, the contract is able to emit a lot of other notifications, e.g. notification with name Fault:Cannot Find PairContract, see the application log for 0xf175a19a706d2a35910f686d08e188e0f5220851584fdb9fe89eed0a216eefb3 transaction in the current RC1 testnet:

curl -d '{ "jsonrpc": "2.0", "id": 1, "method": "getapplicationlog", "params": ["0xf175a19a706d2a35910f686d08e188e0f5220851584fdb9fe89eed0a216eefb3"] }' seed1t.neo.org:20332 | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   699    0   557  100   142    297     75  0:00:01  0:00:01 --:--:--   372
{
   "jsonrpc" : "2.0",
   "id" : 1,
   "result" : {
      "txid" : "0xf175a19a706d2a35910f686d08e188e0f5220851584fdb9fe89eed0a216eefb3",
      "executions" : [
         {
            "vmstate" : "FAULT",
            "exception" : "An unhandled exception was thrown. Cannot Find PairContract",
            "stack" : [],
            "notifications" : [
               {
                  "contract" : "0x50fd49130ec1ff0d3208b6f6abfb24d0525b0411",
                  "state" : {
                     "value" : [
                        {
                           "value" : "z3bii9AGLEpHjuNVYQETGfPPpNI=",
                           "type" : "ByteString"
                        },
                        {
                           "value" : "wYCMqLCTIUiax57E8Zd/O9xN3l8=",
                           "type" : "ByteString"
                        }
                     ],
                     "type" : "Array"
                  },
                  "eventname" : "Fault:Cannot Find PairContract"
               }
            ],
            "gasconsumed" : "6253080",
            "trigger" : "Application"
         }
      ]
   }
}

This event and several similar events are not described in the contract manifest.

Expected behavior All notifications emitted by the contract should be described in the contract manifest.

Platform: