-
Notifications
You must be signed in to change notification settings - Fork 85
feat(web-client, react-sdk): contract creation, CompilerResource, transactions.execute(), and API improvements #1828
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
Open
WiktorStarczewski
wants to merge
38
commits into
next
Choose a base branch
from
wiktor-fpi-new-client
base: next
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.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
0272328
feat(web-client): add ImmutableContract/MutableContract account creation
WiktorStarczewski 5cff9a3
feat(web-client): add CompilerResource (client.compile)
WiktorStarczewski c9e4aee
feat(web-client): add transactions.execute() for custom script execution
WiktorStarczewski c2d46b1
types(web-client): add TypeScript declarations for new API surface
WiktorStarczewski dc9a597
test(web-client): add tests for compile and contract creation API
WiktorStarczewski 70674b5
chore: add changelog entries for #1828
WiktorStarczewski 42b2765
docs(web-client): document contract creation, compiler resource, and …
WiktorStarczewski 4454100
chore: apply prettier formatting
WiktorStarczewski 3e1e78f
chore: regenerate TypeDoc web-client reference
WiktorStarczewski b75a9ea
fix(web-client): match procedure by local name in getProcedureHash
WiktorStarczewski 90d966d
fix(web-client): use is_some_and to satisfy clippy
WiktorStarczewski 29c9adb
fix(web-client): update procedure hash length assertion for 0x prefix
WiktorStarczewski 0b1ce57
feat(sdk): add NoteVisibility and StorageMode enum constants
WiktorStarczewski 793d9ca
feat(sdk): accept object types directly in API calls (TransactionId, …
WiktorStarczewski 1063242
feat(react-sdk): accept Account/AccountHeader objects in hook options…
WiktorStarczewski a25bc53
fix(format): run prettier on JS/TS files
WiktorStarczewski 26a6456
fix(react-sdk): widen resolveAccountId to accept AccountRef type
WiktorStarczewski fef5cfc
fix(web-client): harden SDK dispatch, duck-typing, and error handling
WiktorStarczewski 42590f5
fix(web-client): use StorageMode type alias for storage fields in API…
WiktorStarczewski 688fa6e
chore(web-client): regenerate TypeDoc and add comment to txScript get…
WiktorStarczewski 3bd4468
chore: consolidate changelog entries for #1828
WiktorStarczewski e736029
docs(web-client): add missing JSDoc comments to MintOptions fields
WiktorStarczewski 85f135e
chore(web-client): regenerate TypeDoc for MintOptions JSDoc changes
WiktorStarczewski 4d78666
fix(web-client): fix 4 failing integration tests in compile_and_contract
WiktorStarczewski 7c74fd7
feat(web-client): extend send() for unauthenticated P2ID notes; remov…
WiktorStarczewski acee6bc
chore(web-client): regenerate TypeDoc for unauthenticated send API ch…
WiktorStarczewski 4895a5e
fix: run prettier on unformatted files
WiktorStarczewski 194a547
fix(react-sdk): update useSend test to match new SendResult type
WiktorStarczewski ffb4867
feat(web-client): add prover shorthand resolution to MidenClient.create
WiktorStarczewski 91dc1f7
feat(web-client): add rpcUrl shorthand resolution to MidenClient.create
WiktorStarczewski 8232a53
chore(web-client): regenerate TypeDoc for rpcUrl/proverUrl shorthand …
WiktorStarczewski cc069e3
refactor(web-client, react-sdk): simplify notes API surface
WiktorStarczewski 5407acb
refactor(web-client, react-sdk): rename authenticated send option to …
WiktorStarczewski b59d851
refactor(web-client): extract isDirectNote helper to remove duplicate…
WiktorStarczewski 0c922ca
docs(web-client): clarify when to use getOrImport vs get for accounts
WiktorStarczewski c0e024e
fix(web-client): store secret key after account creation, not before
WiktorStarczewski 031c649
fix: merge use statements for nightly fmt and remove stale Consumable…
WiktorStarczewski 69a46de
chore: run prettier on transactions.js and useConsume.test.tsx
WiktorStarczewski 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| export class CompilerResource { | ||
| #inner; | ||
| #getWasm; | ||
| #client; | ||
|
|
||
| constructor(inner, getWasm, client) { | ||
| this.#inner = inner; | ||
| this.#getWasm = getWasm; | ||
| this.#client = client; | ||
| } | ||
|
|
||
| /** | ||
| * Compiles MASM code + slots into an AccountComponent ready for accounts.create(). | ||
| * | ||
| * @param {{ code: string, slots: StorageSlot[] }} opts | ||
| * @returns {Promise<AccountComponent>} | ||
| */ | ||
| async component({ code, slots }) { | ||
| this.#client.assertNotTerminated(); | ||
| const wasm = await this.#getWasm(); | ||
| const builder = this.#inner.createCodeBuilder(); | ||
| const compiled = builder.compileAccountComponentCode(code); | ||
| return wasm.AccountComponent.compile( | ||
| compiled, | ||
| slots | ||
| ).withSupportsAllTypes(); | ||
|
Collaborator
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. should this be opt-out? |
||
| } | ||
|
|
||
| /** | ||
| * Compiles a transaction script, optionally linking named libraries inline. | ||
| * | ||
| * @param {{ code: string, libraries?: Array<{ namespace: string, code: string, linking?: "dynamic" | "static" }> }} opts | ||
| * @returns {Promise<TransactionScript>} | ||
| */ | ||
| async txScript({ code, libraries = [] }) { | ||
| this.#client.assertNotTerminated(); | ||
| // Ensure WASM is initialized (result unused — only #inner needs it) | ||
| await this.#getWasm(); | ||
| const builder = this.#inner.createCodeBuilder(); | ||
| for (const lib of libraries) { | ||
| if (lib && typeof lib.namespace === "string") { | ||
| // Inline { namespace, code, linking? } — build and link automatically | ||
| const built = builder.buildLibrary(lib.namespace, lib.code); | ||
| if (lib.linking === "static") { | ||
| builder.linkStaticLibrary(built); | ||
| } else { | ||
| // Default: "dynamic" — matches existing tutorial behavior | ||
| builder.linkDynamicLibrary(built); | ||
| } | ||
| } else { | ||
| // Pre-built library object — link dynamically | ||
| builder.linkDynamicLibrary(lib); | ||
| } | ||
| } | ||
| return builder.compileTxScript(code); | ||
| } | ||
| } | ||
This file contains hidden or 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.
client.trnsaction.send({...})changed its return type so this changes should be marked as[BREAKING]too.