Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Wasm-ql Query Lumps Strings Into Last Structs Key #84

Open
baxterjfinch opened this issue Apr 28, 2020 · 0 comments
Open

Wasm-ql Query Lumps Strings Into Last Structs Key #84

baxterjfinch opened this issue Apr 28, 2020 · 0 comments

Comments

@baxterjfinch
Copy link

Here is what my contracts table looks like:

ACTION issuepaid(const name& to,
                         const name& category,
                         const name& token_name,
                         const asset& quantity,
                         const string& relative_uri,
                         const float& amt_paid,
                         const string& currency_paid,
                         const string& memo);

And here is the data on chain:

 "data": {
        "to": "zfqsy2gdthnf",
        "category": "c1",
        "token_name": "t1",
        "quantity": "1 COINS",
        "relative_uri": "",
        "amt_paid": "7.50000000000000000",
        "currency_paid": "USD",
        "memo": "string"
  },

Here is the struct my wasm-ql server is unpacking into:

struct issuepaid_action {
    eosio::name                            to               = {};
    eosio::name                            category         = {};
    eosio::name                            token_name       = {};
    eosio::asset                           quantity         = {};
    eosio::shared_memory<std::string_view> relative_uri     = {};
    eosio::shared_memory<std::string_view> amt_paid         = {};
    eosio::shared_memory<std::string_view> currency_paid    = {};
    eosio::shared_memory<std::string_view> memo             = {};
};

and here is the struct that my server returns the data to the client in:

struct tx_issuepaid_action {
  tx_action_key                           key            = {};
  eosio::name                             to             = {};
  eosio::name                             category       = {};
  eosio::name                             token_name     = {};
  eosio::extended_asset                   quantity       = {};
  eosio::shared_memory<std::string_view>  relative_uri   = {};
  eosio::shared_memory<std::string_view>  amt_paid       = {};
  eosio::shared_memory<std::string_view>  currency_paid  = {};
  eosio::shared_memory<std::string_view>  memo           = {};

  EOSLIB_SERIALIZE(tx_issuepaid_action, (key)(to)(category)(token_name)(quantity)(relative_uri)(amt_paid)(currency_paid)(memo))
};

As you can see, I am unpacking all of the string items as a eosio::shared_memory<std::string_view>. Additionally, I am unpacking the float value amt_paid as a string as well. If I try unpacking as a float the code does not compile.

Here is the response I receive when I initiate the query:

Tx:  { key:
   { receiver: 'ekkub.d.144',
     account: 'ekkub.d.144',
     block: [ 'absolute', 6207062 ],
     transaction_id:
      'C3075EEED56EB019C224EF32F3AD1E5A39B5F13DB4B97A03B318C0085CF9A828',
     action_ordinal: 1 },
  to: 'lonfttyiowk2',
  category: 'blanko',
  token_name: 'altidude.da',
  quantity:
   { contract: 'ekkub.d.144',
     symbol: 'BLANK',
     precision: 0,
     amount: '1' },
  relative_uri: '',
  currency_paid: '',
  amt_paid: '',
  memo:
   '\u0003USD\u0015Bought from gamestore\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�( \u0001A�=\u0000�( \u0001A�=��\u0012\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�#�ŌM���[)\u000e?l��e��gƞۀN\u0010P;zA�\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�( \u0001A�=\u0000\u0000\u0000\u0000S8M<\u0000\u0000�Qa\u001f�;\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000BLANK\u0000\u0000\u0000�( \u0001A�=G#\u0000\u0000\u0000\u0000\u0000\u0000H#\u0000\u0000\u0000\u0000\u0000\u0000I#\u0000\u0000\u0000\u0000\u0000\u0000J#\u0000\u0000\u0000\u0000\u0000\u0000\u0000�( \u0001A�=\u0000�( \u0001A�=��\u0012\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�#�ŌM���[)\u000e?l��e��gƞۀN\u0010P;zA�\u0000\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u00

The things to note here:

  • The currency_paid field is empty however, the value that should be there (USD) appears to have bled over into the memo field in the first line \u0003USD
  • The amt_paid value is empty even though it is present in on-chain data
  • The memo appears to be a huge chunk of unicode encoded characters with data that appears to have bled over from the other fields.

I am sure this is an issue with how I am unpacking the data, I am just not sure how to unpack it properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant