0

I have a library which has the following function:

function strConcat(
    string memory _a,
    string memory _b
)
    internal pure
    returns (string memory)

My contract implements the library and uses the following:

using StringConverter for *;
...
uint minLevel = getStorageUint(
    r,
    ("_conf_").strConcat(pSetting),
    pSettingIndex,
    0
);

This is working, but if I change:

using StringConverter for string;

I can see the error:

TypeError: Member "strConcat" not found or not visible after argument-dependent lookup in literal_string "_conf_".
        ("_conf_").strConcat(pSetting),

What can I type at using to make it working correctly?

Radek_pl
  • 791
  • 7
  • 18
  • Can you try with for bytes32 – cqx Sep 03 '19 at 18:38
  • Just tried, unfortunately, no effect, same error. – Radek_pl Sep 03 '19 at 18:40
  • Can you link the library you are using? – cqx Sep 03 '19 at 18:45
  • Sure, but library is working perfectly, the problem is with using. Took it from here: https://ethereum.stackexchange.com/questions/729/how-to-concatenate-strings-in-solidity

    It's kinda outdated, so you have to change string to string memory everywhere and i to uint i in loops (just tested on remix).

    – Radek_pl Sep 03 '19 at 18:49

1 Answers1

3

Try this solution:

First declare string variable:

string memory myVariable = "_conf_";

Then execute the concat.

myVariable.strConcat(pSetting);

I hope this works.

The problem you have comes arises, because

("_conf_").strConcat(pSetting)

doesn't explicitly create "_conf_" as a memory string.

cqx
  • 3,462
  • 4
  • 11
  • 34
  • 1
    This solves the problem but, to be honest, it's an ugly solution and probably more gas expensive. There must be a better way... Btw. It's not me who gave you minus. – Radek_pl Sep 03 '19 at 19:01
  • 1
    Good to know. I update my answer. Maybe you try with this one: using StringConverter for bytes; – cqx Sep 03 '19 at 19:04
  • 1
    Bytes didn't help either. :( I'm wondering what type does represent syntax ("anything"). It says it's literal_string but there isn't so much to read about it in solidity documentation, also can't put that at "using". – Radek_pl Sep 03 '19 at 19:09
  • 1
    If you are just after keeping gas at a minimum you are best off sticking with for *. In my opinion it doesn't hurt that much. – cqx Sep 03 '19 at 19:13