-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: remove offset from decodeLog
and decodeFunctionResult
methods
#2308
fix!: remove offset from decodeLog
and decodeFunctionResult
methods
#2308
Conversation
Hey @DZakh, thanks for taking an interest in helping us to improve the TS SDK, we appreciate it 🙏. Could you please elaborate on why you believe these changes are necessary? Understanding your reasoning will help us assess the impact and benefits of this modification. |
I don't have a strong feeling about the change, and it's not required for my project.
If you say it's intentional, it would be nice to change the return type from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DZakh, after investigation I do agree with you and I think it was oversight that these entry points for function and log value decoding would include the offset. Most SDK consumers will utilise the TransactionResponse
or FunctionInvocationResult
classes that we return on sendTransaction()
or call()
respectively that internally will pick off the decoded values rather than returning the tuple.
To get this over the line, it'd be great if you can add a changeset (run pnpm changeset
on the monorepo and it would also be great to get some tests so this is not missed in the future, I would reccomend adding them to packages/abi-coder/test/Interface.test.ts
. Let me know if I can help with either of these.
I'll try to find some time during the week 👌 |
a32515f
to
99aa766
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you take a look, please
`function ${nameOrSignatureOrSelector} not found: ${JSON.stringify(fn)}.` | ||
`Function ${nameOrSignatureOrSelector} not found.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn
is undefined here
I'm done with my changes. Ready for re-review |
|
||
describe('decodeLog', () => { | ||
it('should return decoded log by id', () => { | ||
const data = exhaustiveExamplesInterface.decodeLog('0x01000000000000000000000000000020', '0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logId
passed here should be "8500535089865083573"
when the sway program is built with forc 0.59.0
.
Also, passing in Uint8Array.from([1, 0, 0, 0, 32])
here works.
it('should throw an error when log does not exist', () => { | ||
expect(() => | ||
exhaustiveExamplesInterface.decodeLog('0x01000000000000000000000000000020', '1') | ||
).toThrowError(`Log type with logId '1' doesn't exist in the ABI.`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the expectToThrowFuelError
utility here (example).
'doesnt_exist', | ||
'0x01000000000000000000000000000020' | ||
); | ||
}).toThrowError(/^Function doesnt_exist not found\.$/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the expectToThrowFuelError
utility here (example).
.changeset/perfect-kings-camp.md
Outdated
"@fuel-ts/abi-coder": minor | ||
--- | ||
|
||
Changed decodeLog and decodeFunctionResult return types to have only decoded value without an offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed decodeLog and decodeFunctionResult return types to have only decoded value without an offset | |
fix!: don't return offset from public decode functions |
We have some CI logic that mandates that this text is equal to the pr title.
@DZakh Thanks for the work! I agree that the offset shouldn't be returned. |
"@fuel-ts/abi-coder": minor | ||
--- | ||
|
||
fix: Changed decodeLog and decodeFunctionResult return types to have only decoded value without an offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix: Changed decodeLog and decodeFunctionResult return types to have only decoded value without an offset | |
fix!: changed `decodeLog` and `decodeFunctionResult` return types to have only decoded value without an offset |
I believe this is a breaking change, as @nedsalk mentioned, this will need to be in sync with the title 😄
decodeLog
and decodeFunctionResult
methods
I've just returned from a one-week vacation. I didn't touch my laptop at all, and now I'm a little bit lost on what's left for the PR 😅 Could somebody summarize it for me, please? |
This comment was marked as outdated.
This comment was marked as outdated.
@DZakh Thanks for the work here, I've also assigned myself to the PR and will take this over the line. |
Thanks |
decodeLog
and decodeFunctionResult
methodsdecodeLog
and decodeFunctionResult
methods
@DZakh I don't have the rights to push to your fork. You can find my changes on this branch. Please merge them into your fork so that we can continue with the review. |
@nedsalk, I don't mind if we continue with your PR. Let's just close this one and reference yours. |
Superseded by #2514 |
It feels like public
decode
functions should return the decoded value itself. Not a tuple with an internal offset.