gofractally / demo-clsdk

Demonstration of using the clsdk to build and test contracts
13 stars 2 forks source link

eosio::on_notify #9

Open 7flash opened 2 years ago

7flash commented 2 years ago

When I want to accept token transfers to my contract, I am usually doing this while using eosio.cdt, what's the alternative using clsdk?

[[eosio::on_notify("atomicassets::transfer")]]
7flash commented 2 years ago

Its giving me this warning when compiling with clsdk

unknown attribute 'on_notify' ignored

image

7flash commented 2 years ago

I have found solution as following:

  1. notify in EOSIO_ACTIONS
notify(atomicassets_contract_account, transfer)
  1. notify_transfer in contract class
void notify_transfer(
            name from,
            name to,
            vector<uint64_t> asset_ids,
            string memo
        )
7flash commented 2 years ago

It seems like action name should be in format of "notify_" concatenated with original action name, I wonder if there is a way to choose custom one?

tbfleming commented 2 years ago

not currently

7flash commented 2 years ago

@tbfleming I have a contract where I want to be notified both for transfer of EOS and transfer of NFT, but action name is the same, - transfer, - in eosio.token and atomicassets contract, - any ideas how to approach this case?