Comments (3)
Hi, thanks for the feedback!
First in EncodeInput, it will always put tuple's content at the end of currently constructed data block using $input->hash. For non-dynamic parameters it should be put in-place as far as i understand the specs so that's the first error which will prevent correctly encoding some tuples.
Check the $round parameter on EncodeInput(). Static types ignore round=2 and attach the encoded value directly on first round, as you say.
In EncodeGroup
$currentDynamicIndex = count($inputs) * self::NUM_ZEROS / 2;
This is probably not correct as well as single tuple can have several non-dynamic fields only, eg. 3 UINTs, so the assumption that first dynamic 32b data block starts at position which is just a number of inputs is not always correct (we need to process all tuples before we know first dynamic block number).
Yes, you are right. One of the latest commits fixes the same issue, but on the "decode" process.
Throught experimentation, we saw that a tuple with only static attribute types behave like a static type itself. So, it's not encoded using a offset index, it just encodes all its parameters in place. I haven't been able to find any docs with info about this "feature"... If you find it, I will be pleased to check it and make sure our code adjusts to the docs.
August is complicated... But I'll update it as soon as possible.
Make sure you are on main branch for most recent changes.
from simple-web3-php.
Hey, thanks for the message... for decoding yes seems to work 100% correct. As for first point i think there's an issue with this code (the issue is here only for tuple)
else if ($varType == VariableType::Tuple) {
$input->hash = self::EncodeGroup($input->components, $inputData);
$res = '';
if (self::ExistsDynamicParameter($input->components)) {
$res = self::EncodeInput_UInt($currentDynamicIndex);
}
return $res;
So what i think it does is it'll always put the tuple content as last data in the block ( $input->hash ). If content is dynamic it'll also put an offset in-place.
It should work this way (i think)
$res = self::EncodeGroup($input->components, $inputData);
// if the tuple is dynamic, we return offset and add tuple's data at the end
if (self::ExistsDynamicParameter($input->components)) {
$input->hash = $res;
return self::EncodeInput_UInt($currentDynamicIndex);
}
return $res;
So for static it'll return $res in-place, and for dynamic it'll return offset and put data in input->hash to be added in phase 2.
Throught experimentation, we saw that a tuple with only static attribute types behave like a static type itself.
Yes, correct... if all attribs are static the tuple is treated as static type. Attached the structure desc at the bottom...
Will prepare a fix and submit tomorrow i think, need to test it more wanted to make sure it won't break other things but it seems ok, just need to encode/decode more contract parameters, unless there's some test suite...
(
[0] => Array
(
[internalType] => address[]
[name] => path
[type] => address[]
)
[1] => Array
(
[internalType] => string[]
[name] => poolVersion
[type] => string[]
)
[2] => Array
(
[internalType] => uint256[]
[name] => versionLen
[type] => uint256[]
)
[3] => Array
(
[internalType] => uint24[]
[name] => fees
[type] => uint24[]
)
[4] => Array
(
[components] => Array
(
[0] => Array
(
[internalType] => uint256
[name] => amountIn
[type] => uint256
)
[1] => Array
(
[internalType] => uint256
[name] => amountOutMin
[type] => uint256
)
[2] => Array
(
[internalType] => address
[name] => to
[type] => address
)
[3] => Array
(
[internalType] => uint256
[name] => deadline
[type] => uint256
)
)
[internalType] => struct SmartExchangeRouter.SwapData
[name] => data
[type] => tuple
)
)```
from simple-web3-php.
from simple-web3-php.
Related Issues (20)
- Split ABIv2 encoding/decoding HOT 1
- substr(): Argument #3 ($length) must be of type ?int, float given HOT 3
- Add blockTag to the SWeb3_Contract.php HOT 1
- why is there a memory shortage during the Call contract command? HOT 1
- The output data of the read contract command is missing [solved] HOT 7
- can I get the Latest 25 BEP-20 Token Transfer Events on a specified contract through Simple-Web3-Php? HOT 2
- how to call the interface functions of contract? HOT 1
- How to query the number of Token holdings on a specified contract? [Solved] HOT 7
- Stargate finance tuple issue HOT 1
- Please upgrade kornrunner/ethereum-offline-raw-tx ^0.4.0 to ^0.6.0
- Seems fixed size array inside struct (tuple) breaks encoding. HOT 2
- How to obtain correct bytes32 string? HOT 2
- ABI Encoding, Keccak256 Hashing HOT 2
- Error sending wallet address different from contract HOT 3
- unable to decode data via DecodeData method HOT 1
- Core/ABI->GetEventFromHash throws exception on invalid index. HOT 1
- Custom blockchain ID HOT 1
- How to use that library in a server without Composer?
- How to encode address[] and uint256[] arrays
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-web3-php.