essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 3 forks source link

ABI gen not handling anon namespace #771

Closed freesig closed 3 months ago

freesig commented 3 months ago

image This PR shows the issue https://github.com/essential-contributions/essential-integration/pull/49

This is the abi:

{
  "predicates": [
    {
      "name": "::Burn",
      "vars": [
        {
          "name": "__::I_pathway",
          "ty": "Int"
        },
        {
          "name": "::anon@0::sig",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::anon@0::public_key",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        }
      ],
      "pub_vars": [
        {
          "name": "::token",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": {
                  "B256": [
                    0,
                    0
                  ]
                }
              },
              {
                "name": "addr",
                "ty": {
                  "B256": [
                    0,
                    1
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    {
      "name": "::Cancel",
      "vars": [
        {
          "name": "__::I_pathway",
          "ty": "Int"
        },
        {
          "name": "::anon@1::sig",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::anon@1::public_key",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        }
      ],
      "pub_vars": [
        {
          "name": "::token",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": {
                  "B256": [
                    0,
                    0
                  ]
                }
              },
              {
                "name": "addr",
                "ty": {
                  "B256": [
                    0,
                    1
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    {
      "name": "::Mint",
      "vars": [
        {
          "name": "__::I_pathway",
          "ty": "Int"
        },
        {
          "name": "::anon@2::sig",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::anon@2::public_key",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        }
      ],
      "pub_vars": [
        {
          "name": "::token",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": {
                  "B256": [
                    0,
                    0
                  ]
                }
              },
              {
                "name": "addr",
                "ty": {
                  "B256": [
                    0,
                    1
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    {
      "name": "::Transfer",
      "vars": [
        {
          "name": "__::I_pathway",
          "ty": "Int"
        },
        {
          "name": "::anon@3::sig",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::anon@3::public_key",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        }
      ],
      "pub_vars": [
        {
          "name": "::token",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": {
                  "B256": [
                    0,
                    0
                  ]
                }
              },
              {
                "name": "addr",
                "ty": {
                  "B256": [
                    0,
                    1
                  ]
                }
              }
            ]
          }
        }
      ]
    },
    {
      "name": "::TransferWith",
      "vars": [
        {
          "name": "::mode",
          "ty": "Int"
        },
        {
          "name": "__::I_pathway",
          "ty": "Int"
        },
        {
          "name": "::sig",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::public_key",
          "ty": {
            "Tuple": [
              {
                "name": null,
                "ty": "B256"
              },
              {
                "name": null,
                "ty": "Int"
              }
            ]
          }
        },
        {
          "name": "::constraints",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": "B256"
              },
              {
                "name": "addr",
                "ty": "B256"
              }
            ]
          }
        },
        {
          "name": "__::O_pathway",
          "ty": "Int"
        }
      ],
      "pub_vars": [
        {
          "name": "::token",
          "ty": {
            "Tuple": [
              {
                "name": "contract",
                "ty": {
                  "B256": [
                    0,
                    0
                  ]
                }
              },
              {
                "name": "addr",
                "ty": {
                  "B256": [
                    0,
                    1
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  ],
  "storage": []
}
freesig commented 3 months ago

The anon@0 namespace is usually created when things are declared inside a macro. I'd say that's what is happening here

freesig commented 3 months ago

I'm going to have a look into this

otrho commented 3 months ago

The anon@0 namespace is usually created when things are declared inside a macro. I'd say that's what is happening here

That's definitely what is happening. I'm not sure what you can do about it though.