l00k / devphase

Development tool for Phala Phat contracts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle trait definitions in TypeBind

h4x3rotab opened this issue · comments

The current type generator doesn't handle trait definitions.

Normally, if a contract ContractA has a tx method func1, we call it by:

const a = new ContractPromise(api, metadata, address);
await a.tx.func1().signAndSubmit(...);

However if ContractA implements a trait definition (TraitX) that implements a tx method trait_x_func2, it must be called by:

const a = new ContractPromise(api, metadata, address);
await a.tx['traitX::traitXFunc2']().signAndSubmit(...);

(Note that the key is also converted to camelCase)

For the trait definition, here's the generate metadata as a reference:

        {
          "args": [],
          "docs": [],
          "label": "TraitX::trait_x_func2",
          "mutates": false,
          "payable": false,
          "returnType": {
            "displayName": [
              "core",
              "result",
              "Result"
            ],
            "type": 9
          },
          "selector": "0xABCDABCD"
        }
commented

Implemented in ^0.0.15