-
Notifications
You must be signed in to change notification settings - Fork 58
Description
As of right now, the NoteScript.compile()
function does not accept an Assembler
parameter, which means that users have to use a workaround to be able to compile notes with libraries.
TransactionScript
compilation already works with an Assembler parameter, also the Rust crate allows devs to specify an Assembler
parameter (see here).
In order to compile note scripts with a library, we therefore currently have to use a different method, which can be seen here:
miden-client/crates/web-client/test/new_transactions.test.ts
Lines 1171 to 1202 in 9416d73
// Deploy counter account | |
let accountComponentLib = | |
window.AssemblerUtils.createAccountComponentLibrary( | |
assembler, | |
"external_contract::counter_contract", | |
accountCode | |
); | |
let txScript = window.TransactionScript.compile( | |
scriptCode, | |
assembler.withLibrary(accountComponentLib) | |
); | |
let txIncrementRequest = new window.TransactionRequestBuilder() | |
.withCustomScript(txScript) | |
.build(); | |
let txResult = await client.newTransaction( | |
accountBuilderResult.account.id(), | |
txIncrementRequest | |
); | |
await client.submitTransaction(txResult); | |
await window.helpers.waitForTransaction( | |
txResult.executedTransaction().id().toHex() | |
); | |
// Create transaction with network note | |
assembler = window.TransactionKernel.assembler() | |
.withDebugMode(true) | |
.withLibrary(accountComponentLib); | |
let compiledNoteScript = await assembler.compileNoteScript(scriptCode); |
In order to align the web SDK with the Rust crate, and the rest of the development workflow, I propose adding this functionality to the NoteScript.compile()
function.