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
Unable to see methods #21
Comments
Hmm strange. I'll take a look at your Wasm,but the source would be the most helpful. |
Can you also share the files in your |
orderly_dex.zip One idea that might cause the issue, but haven't tested it: [lib]
crate-type = ["rlib"] My actual contract has this lib as dependency: [package]
name = "orderly-dex"
...
[lib]
crate-type = ["cdylib"]
[dependencies]
orderly-dex-lib = { path = "../contract-lib" } and has cdylib enabled for wasm compilation. I do this to reduce code size from the wasm file, since enabling rlib makes the file quite a lot larger. |
Ah I see! I need to update the readme and documentation, but currently you need to add the following to the [package.metadata.witgen]
export = true |
Thx this works! However I have another unrelated problem I assume:
I've been trying to fix this by slamming the My contract struct is on #[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
#[witgen]
pub struct OrderlyDex {
// ...
} but I also have several other files with impls for that contract, that I added as modules. I've been trying to track this down by installing cargo-witgen and running ❯ cargo witgen generate
Error: no type named `u128`
--> index.wit:34:16
|
34 | limit-price: u128,
| ^--- Where u128 is the #[witgen]
use near_sdk::json_types::U128; but then I get an error:
|
What is the rust of the return type of this:
Raen didn't update to use the newest dependency logic for the sdk types. Instead it still drops in the needed sdk types. And as witgen says it currently doesn't support decorating imports, this is why I used the Cargo.toml trick. This dependency logic currently lives in raen should be in witgen (I'm working on upgrading it to the newest wit). |
it looks like this: #[near_bindgen]
#[witgen]
impl OrderlyDex {
#[payable]
#[handle_result]
#[witgen]
pub fn register_account(&mut self, account_id: Option<AccountId>) -> Result<()> {
// ...
} It seems to interfere with the |
forgot something. This is my Result type: pub type Result<T> = std::result::Result<T, error::ContractError>;
#[derive(BorshSerialize, Debug, Error, FunctionError)]
pub enum ContractError {
// ...
} |
Hmm yeah currently wit supports result types, however, the issue here is that witgen can't resolve your type. E.g. use error::ContractError;
Result<(), ContractError> // Note currently you can only use the last part of a path If this does work let me know, I'd be interested to know what the final json schema looks like. I've wanted to improve it's enum support, but I think it shouldn't matter as much since it's not an input. Also you should only add
Currently there is a special case for |
Ok so I made it work. Here are the steps to make it work:
I had a couple more problems: I had a naming conflict in the resulting The witgen compiler didn't seem to notice changes. If I compiled it once and it failed and then fixed that error, it displayed the same error again. I worked around this by running The Here's the target/wit output: Also one question: |
Glad it's working! One note in case you missed it: you can add documentation to your functions and types and they'll show up on the admin panel! Unfortunately we had support for generating JS/TS class, but removed it as it meant a dependency on the sdk and we were more focused on getting the admin panel working. The ts types are generated but each function arg is a type. So I think it would involve a little be of manual effort to add the types, but the sdk already supports creating a class given the function names. You can also an old version of witme to generate the TS. See tenk for an example of this: https://github.com/TENK-DAO/tenk/blob/main/package.json#L49 Eventually we hope to generate the TS again, but we need to update to the newest version of WIT. Also the |
Exactly, Will also add some doc comments soon :D For now the json schema should be good enough. We'll maybe check later into automating this further for the TypeScript types, but I think I will use the latest version from witme. Thx for the info! |
Hey,
I tried out Raen, but it seems like I'm unable to see methods. It seems like it's not working at all.
Deployed contract:
https://raen.dev/admin/#/dex-test.shrm.testnet
I tried out both your frontend and also nearblocks.io, which supports displaying contract methods, but no luck either.
Here is the contract file:
https://drive.proton.me/urls/9N1K8RN0Q0#3KigN0oIWnAF
Let me know, if you need any more information.
The text was updated successfully, but these errors were encountered: