-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
chore: added method to duplicate predicate #3395
Open
YaTut1901
wants to merge
10
commits into
FuelLabs:master
Choose a base branch
from
YaTut1901:YaTut1901/chore/predicate-duplication
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−5
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a82f744
chore(): added emthod to duplicate predicate
YaTut1901 09f40e6
chore(): added method to duplicate predicate
YaTut1901 78a14b6
chore(): added method to duplicate predicate
YaTut1901 da50ac7
Merge branch 'master' into YaTut1901/chore/predicate-duplication
YaTut1901 6441b2d
Merge branch 'master' into YaTut1901/chore/predicate-duplication
YaTut1901 df8848b
Merge branch 'master' into YaTut1901/chore/predicate-duplication
YaTut1901 f257ac2
Merge branch 'YaTut1901/chore/predicate-duplication' of https://githu…
YaTut1901 15e66a1
chore: removed loaderBytecode, added initial check in test
YaTut1901 e81b9f1
chore: added type to function
YaTut1901 ce466cf
Merge branch 'master' into YaTut1901/chore/predicate-duplication
arboleya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YaTut1901 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,5 +64,32 @@ describe('Predicate', () => { | |
}); | ||
}).toThrow('Cannot use ABI without "main" function'); | ||
}); | ||
|
||
it('creates a new instance with updated parameters', async () => { | ||
using launched = await setupTestProviderAndWallets(); | ||
const { provider } = launched; | ||
|
||
const predicate = new Predicate({ | ||
bytecode: predicateBytecode, | ||
abi: predicateAbi, | ||
provider, | ||
configurableConstants: { value: false }, | ||
data: ['DADA'], | ||
}); | ||
|
||
expect(predicate.predicateData).toEqual(['DADA']); | ||
expect(predicate.bytes[0]).toEqual(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check seems redundant, can we check the entire bytecode? |
||
|
||
const newPredicate = predicate.toNewInstance({ | ||
configurableConstants: { value: true }, | ||
data: ['NADA'], | ||
}); | ||
|
||
expect(newPredicate.predicateData).toEqual(['NADA']); | ||
expect(newPredicate.bytes.slice(1)).toEqual(predicate.bytes.slice(1)); | ||
expect(newPredicate.bytes[0]).not.toEqual(predicate.bytes[0]); | ||
expect(newPredicate.interface?.jsonAbi).toEqual(predicate.interface?.jsonAbi); | ||
expect(newPredicate.provider).toEqual(predicate.provider); | ||
}); | ||
}); | ||
}); |
7 changes: 5 additions & 2 deletions
7
packages/fuel-gauge/src/predicate/utils/predicate/fundPredicate.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe this can be a static method on the
Predicate
class like so:Feels like a better API to me. Thoughts? @FuelLabs/sdk-ts