Skip to content
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

feat: create a script generator #65

Open
tdelabro opened this issue Sep 18, 2024 · 7 comments
Open

feat: create a script generator #65

tdelabro opened this issue Sep 18, 2024 · 7 comments
Assignees

Comments

@tdelabro
Copy link
Collaborator

Currently we create scripts in order to test our opcodes implementation.
It is done with a []u8 looking like this:

const bytes: [?]u8 = [_]u8{ 0x12, 0x34, 0x56, 0x78 };

Where everything (opcode and data) is written as u8.
This is unreadable and unmaintainable.

I want it to look like this:

const my_script = ScriptBuilder.new().pushOpcode(Opcode.OP_ADD).pushInt(1).pushInt(1).addOpcode(Opcode.OP_NUMEQUAL).addInt(2).build();

Create in as an independent lib, script/

@89oso
Copy link

89oso commented Sep 18, 2024

Hello, can i do this?

Copy link

onlydustapp bot commented Sep 18, 2024

Hey @89oso!
Thanks for showing interest.
We've created an application for you to contribute to btczee.
Go check it out on OnlyDust!

@varun-doshi
Copy link
Contributor

Hey @tdelabro
I can take this up. Been working with Zig the past few weeks.
I probably have a good idea how to get this done

Copy link

onlydustapp bot commented Sep 18, 2024

Hey @varun-doshi!
Thanks for showing interest.
We've created an application for you to contribute to btczee.
Go check it out on OnlyDust!

@tdelabro
Copy link
Collaborator Author

Hey @89oso, as this is an advanced issue and you have not contributed yet to the project, I will assign it to @varun-doshi and ask you to start with an easier, smaller issue.

@varun-doshi
Copy link
Contributor

I see this

const MAX_OPS_PER_SCRIPT = 201;

Would it be right to assume our ScriptBuilder will only hold max of 201 opcodes at any given time?

@varun-doshi
Copy link
Contributor

Also something to note @tdelabro
Zig seems to have an inherent issue with function chaining:
ziglang/zig#5705

I've come up with 2 ways to use the ScriptBuilder. Will clarify in my PR.
We can choose whichever seems to be simpler syntax wise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants