web3swift
web3swift copied to clipboard
Fix for EIP681: parsing of arrays and encoding of EIP681Code into URL
Authors: @JeneaVranceanu, @a-tkchnk
The problem
Having EIP681 link like this one:
ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828/functionName123?string[]=[123,2,5000,wwweer2-=!]
during parsing will result in loss of query parameters and function name and the result would be the following link:
ethereum:0x9aBbDB06A61cC686BD635484439549D45c2449cc@2828
What is introduced in this PR?
- EIP681 parsing of arrays in query parameters. Tuples are not yet handled.
- Encoding of
EIP681Code.parametersparameters usable in URL. - Added
func makeEIP681Link(urlEncoded: Bool) -> String?to create EIP681 link fromEIP681Code.EIP681Codestructure is used to create an EIP681 URL in aStringrepresentation with an option to URL encode the EIP681 link before it's returned so it's an actually valid URL. - Fixed old test cases for EIP681 and added new ones.
Previously, both array and tuple types weren't supported during parsing.
Support for array parsing/decoding was added. Covered with multiple test cases.
Support for tuples will come soon.
Also, support for creating a URL (a String is actually returned) back from EIP681Code instance was added. So now we can create EIP681Code by hand, by assigning values to its properties and call func makeEIP681Link() to get back a valid URL. There is still some work to do to support value, gas and other such parameters in encoding.
This PR is the first in the sequence of improvements.