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

WIP: Multi Contract and debugging support for Advanced Transaction Builder #257

Open
wants to merge 21 commits into
base: next
Choose a base branch
from

Conversation

kiok46
Copy link
Contributor

@kiok46 kiok46 commented Jan 12, 2025

Hello! I'm excited to submit this WIP PR and hope it proves helpful to the community.

Due to a few potential breaking changes, most of the new code has been implemented under the src/advanced/ folder. This allows for clear distinction and facilitates discussion and potential refactoring. For new methods or those responsible for the breaking changes, this folder serves as a separate isloated space.

LibauthTemplate

Naming convention and structure for template follow: https://ide.bitauth.com/authentication-template-v0.schema.json

  • Scenarios:
    Generates new scenarios for each new Input (Earlier discussions: CashScript debugger (@mainnet-pat's flipstarter) #172 & Implement debugging support for the Advanced Transaction Builder #230 )

  • Lock and unlock
    Uses the contract's name as a prefix, followed by the function name.

  • Entities
    P2PKH entities use Signer {index} (index increments by 1)
    P2SH entities use Contract's Name i.e artifact.contractName

  • Scripts
    Each lock and unlock script is assigned an identifier and later replaced in the scenarios where the current source output is not being tested. The source output being tested is assigned ['slot'] [Assigning a name to the script's reference: JEDEX]

Advanced Transaction Builder

The new implementation isn't ideal, but it was the quickest way for me to push it through. The InputOptions has been extended from only expecting sequence to now also include contract, params, and template.

  • template suggests a P2PKH type input.
  • contract directly references the contract instance used for the input.
  • params are the function arguments.
    Later on, Reference Comparison is used to determine the index of the unlocker and generate the locking and unlocking bytecode.

Tests

Not written yet.

Example

Transactions using multiple contracts and logs are functioning correctly, but thorough testing is still required.

  • examples/Foo.cash
  • examples/Bar.cash
  • examples/develop.js includes functions for runMock and runMainnet

Broadcasted transactions during development and testing before creating this PR:

  1. BCH transfer with OP_RETURN in Multi Contract setup
  2. Burn Tokens with OP_RETURN in No Contract setup
  3. BitAuthURI from the demo in develop.js

Copy link

vercel bot commented Jan 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cashscript ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 10:28am

@rkalis
Copy link
Member

rkalis commented Jan 14, 2025

Hey @kiok46, thanks for raising this PR, we will spend the coming weeks going over it and making changes where necessary. We will document this process in the comments at #230.

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

Successfully merging this pull request may close these issues.

2 participants