-
Notifications
You must be signed in to change notification settings - Fork 314
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
modified the AssembledTransaction and it's tests #1075
Conversation
@Shaptic PTAL |
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.
I didn't finish reviewing the tests, but there's a lot to fix up here. I can come back and review again after your next pass.
Sorry you didn't have more context for how Stellar works and the real need here before you got started the first time 😞
@chadoh PTAL, sorry i was going through some rough time, my tg and metamask wallet got hacked, lost around 200 dollars... So it took a little time |
// Ensure publicKey is provided for non-read calls | ||
if (!this.options.publicKey) { | ||
throw new Error( | ||
"Public key not provided. Have you forgotten to set the `publicKey` in AssembledTransactionOptions?" |
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.
It looks like this is the only needed change here. Everything except this block seems either like anti-linting or outright error. Maybe there's a test of this specific logic that should stay; I again didn't get that far.
Can you please force-push a single commit to this branch with only these specific changes? We do not want to merge anything else.
I see you pushed right to your master
branch so it might be a little more complicated and error-prone, but here's a way you can do it:
log --pretty=oneline -n 10 --graph
– this should show you the commit, eight commits ago, where you branched off what was thenmaster
on the upstream remote (not sure how your local remotes are named). Copy that commit hash.git reset --hard [pasted commit hash]
– this will reset all local changes to your branchgit pull upstream master
– may as well update to the tip of the upstream branch to avoid as many conflicts as possible. Again, not sure what your local remotes are called. You can usegit remote -v
to see all remotes and make sure you have the name of thestellar/js-stellar-sdk
one, and slot it in where I put theupstream
.- Now you can copy-paste specific changes from this PR back into your local changes and commit them with a sensible commit message.
git push --force origin master
– one more time, not sure what your remotes are called. Make sure to use whatever name you gave your remote, rather thanorigin
.
1dc5f97
to
0c556e7
Compare
@chadoh do take a look now |
if (!options.publicKey) { | ||
throw new Error("Public key not provided. Have you forgotten to set the `publicKey` in AssembledTransactionOptions?"); |
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.
Still a lot of anti-lint noise and erroneous code like this
@chadoh I have run the yarn fmt and yarn build and then pushed. are there any more blockages? |
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.
Here I've marked eight areas that need improvement; just about the limit for what will show without GitHub collapsing it. Please don't make me go through the rest of the PR and comment on every single line. Please git reset
to the point you branched of master and create ONE new commit, as I previously advised, and ONLY copy-paste in the correct changes. Thank you.
if(!this.built) throw new Error( | ||
"Transaction has not yet been simulated; " + | ||
"call `AssembledTransaction.simulate` first.", | ||
); | ||
if (!this.built) throw new Error( | ||
"Transaction has not yet been simulated; " + | ||
"call `AssembledTransaction.simulate` first.", | ||
); |
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.
None of these changes should be included
{ ...options, | ||
{ | ||
...options, |
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.
Nor these
); | ||
); |
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.
Nor this
if (!options.publicKey) { | ||
throw new Error("Public key not provided"); | ||
} |
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.
See previous comments about this. The logic is wrong. We do not want this.
// AssembledTransaction.ts | ||
|
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.
This is noise
if (!options.publicKey) { | ||
throw new Error("Public key not provided. Have you forgotten to set the `publicKey` in AssembledTransactionOptions?"); | ||
} | ||
|
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.
This is wrong
const account = await getAccount( | ||
options, | ||
tx.server | ||
); | ||
const account = await getAccount(options, tx.server); |
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.
This is wrong
@@ -464,6 +471,7 @@ export class AssembledTransaction<T> { | |||
return tx; | |||
} | |||
|
|||
|
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.
This is noise
Fixes #1059
Description:
Corrected
isReadOnly
Method Invocation:isReadOnly
method was incorrectly invoked on an instance ofScSpecFunctionV0
, which does not possess this method.Spec
instance (this.spec.isReadOnly(method)
) ensuring proper type safety and functionality.Enhanced
AssembledTransaction
Class:sign
method within theAssembledTransaction
class to fail fast if nopublicKey
is provided.NULL_ACCOUNT
, thesign
method now throws a descriptive error:publicKey
, enhancing the developer experience and preventing unintended transaction behaviors.Updated Test Files to Reflect Changes:
assembled_transaction_test.js
:Spec
class with the contract's specification entries.buildFootprintRestoreTransaction
method to pass theSpec
instance.StellarSdk.Account
toxdr.Account
to align with expected types.test-swap.js
:Spec
class with the appropriate contract specifications.Spec
instance.Enhanced
Spec
Class (spec.ts
):isReadOnly
method to accurately determine if a contract function is read-only based on naming conventions or metadata.General Improvements:
Benefits:
Property 'isReadOnly' does not exist on type 'ScSpecFunctionV0'.ts(2339)
error by correctly invokingisReadOnly
on theSpec
instance.Testing:
publicKey
is omitted, ensuring thesign
method behaves correctly.publicKey
fail gracefully when omitted and succeed when provided.