Skip to content

WebClient: NoteScript cannot be directly compiled with assembler library (for FPI) #1278

@Keinberger

Description

@Keinberger

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:

// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    web clientRelated to the Web Client

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions