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

Improve Dev Experience #301

Open
polarker opened this issue Jan 14, 2024 · 4 comments
Open

Improve Dev Experience #301

polarker opened this issue Jan 14, 2024 · 4 comments

Comments

@polarker
Copy link
Member

Feel free to share any specific suggestions to enhance the overall experience, especially with examples. The dev team is currently busy, but we'll soon have more time to fine-tune things. Your input is valuable!

@polarker
Copy link
Member Author

Error message lacks clarity when function parameters are not provided: https://discord.com/channels/747741246667227157/948144672402972682/1196050728909807716

@ross-weir
Copy link
Contributor

Suggest fixes for errors

Not sure how tricky to implement but maybe some low hanging fruit, i.e incorrectly naming builtin funcs, etc:

assert(1 == 1, 5)

Current error:

Failed to compile, error: Error: [API Error] - org.alephium.ralph.Compiler$Error: Function assert does not exist

With suggestion:

Failed to compile, error: Error: [API Error] - org.alephium.ralph.Compiler$Error: Function assert does not exist, did you mean to use builtin function "assert!"?

Clearer error when declaring contract attributes in wrong order

For example declaring enum before event with this contract:

Contract Example() {
  enum Error {
    Assert = 0
  }

  event StateChanged(old: U256, new: U256)

  pub fn helloWorld() -> () {
    assert!(1 == 1, Error.Assert)
  }
}

Throws this error that doesn't indicate the issue:

Failed to compile, error: Error: [API Error] - org.alephium.ralph.Compiler$Error: -- error (6:3): Syntax error
6 |  event StateChanged(old: U256, new: U256)
  |  ^^^^^^^^^^
  |  Expected "}"
  |-------------------------------------------------------------------------------------
  |Trace log: Expected multiContract:1:1 / rawContract:1:1 / "}":6:3, found "event Stat"

@ross-weir
Copy link
Contributor

ross-weir commented Jan 14, 2024

Implement user friendly error reporting

This is probably a CLI thing but putting it here

Currently raw errors are shown including stacktraces, etc which likely isn't useful to contract devs most of the time, consider making error reporting more user friendly/concise.

Current error:

Error output
Failed to compile, error: Error: [API Error] - org.alephium.ralph.Compiler$Error: -- error (6:3): Syntax error
6 |  event StateChanged(old: U256, new: U256)
  |  ^^^^^^^^^^
  |  Expected "}"
  |-------------------------------------------------------------------------------------
  |Trace log: Expected multiContract:1:1 / rawContract:1:1 / "}":6:3, found "event Stat"

    at convertHttpResponse (/home/ross/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/web3/dist/src/api/utils.js:25:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Function.compile (/home/ross/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/web3/dist/src/contract/contract.js:313:24)
    at async Function.build (/home/ross/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/web3/dist/src/contract/contract.js:460:38)
    at async Command.<anonymous> (/home/ross/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/cli/cli_internal.ts:87:7)
    at async Command.parseAsync (/home/ross/.npm/_npx/f1b120e1b513c04c/node_modules/commander/lib/command.js:935:5)
node:child_process:962
    throw err;
    ^

Error: Command failed: npx --yes ts-node --transpile-only /home/user/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/cli/cli_internal.ts compile
    at checkExecSyncError (node:child_process:887:11)
    at execSync (node:child_process:959:15)
    at Object.<anonymous> (/home/user/.npm/_npx/f1b120e1b513c04c/node_modules/@alephium/cli/cli.js:34:1)
    at Module._compile (node:internal/modules/cjs/loader:1233:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 25594,
  stdout: null,
  stderr: null
}

Instead only show whats useful to contract devs, something along the lines of:

Failed to compile
Syntax error at (6:3)
6 |  event StateChanged(old: U256, new: U256)
  |  ^^^^^^^^^^
  |  Expected "}"
  |-------------------------------------------------------------------------------------
  |Trace log: Expected multiContract:1:1 / rawContract:1:1 / "}":6:3, found "event Stat"

@akkien
Copy link

akkien commented May 21, 2024

There should be a section in documentation that guides developers how to interact with contract from client.
I want to know more about parameters we use when create transaction.
I follow alephium-tutorial code, but and failed when call Withdraw TxScript: Error: [API Error] - No UTXO found.
image

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