B3Pay / b3_utils

B3Utils Library is a Rust library designed to simplify the development of applications and wallets on the Internet Computer. It provides utility functions and types for handling various operations such as transfers, tokens, timestamps, and more.
4 stars 1 forks source link

Documentation #2

Open sadernalwis opened 5 months ago

sadernalwis commented 5 months ago

I know what u meant by this needing documentation .. ๐Ÿ˜… been studying this. did a full reformat. (super-tight no-quarter for lines format ๐Ÿ˜) doubt you'll like it. pretty sure no rust pro would like it.๐Ÿ˜… beautiful code tho.. image

b3hr4d commented 5 months ago

Hi @sadernalwis ,

Thank you for taking the time to review and reformat the code in the library. I appreciate your effort in making it more readable.

Since you have a good understanding of the code and have shown interest in improving it, would you be willing to help further? I would be happy to give you full access to make the code more readable and to enhance the documentation. Your insights and contributions would be incredibly valuable in making the library more accessible and user-friendly for everyone, including professionals.

If youโ€™re interested, please let me know, and we can set up the necessary permissions and discuss how best to collaborate.

Thanks again for your contribution and for considering this!

sadernalwis commented 5 months ago

code more readable and to enhance the documentation Absolutely, I'd love to help. Its a bit ocd of me i guess, but this format is the only way that i can read and understand code faster. also i could later expand some advantages of the format.

sadernalwis commented 5 months ago

Honestly I believe the back-end should belong in the ic_cdk; maybe one day either-case, I see 4 context separation for docs:

b3hr4d commented 5 months ago

The four contexts you proposed make a lot of sense and will definitely make the documentation more comprehensive and user-friendly.

Let's proceed with this plan:

  1. Canister dev (technical)
  2. Wallet Maker (half n half)
  3. Using JS (technical)
  4. Using UI (user guide)

I'll set up the necessary permissions for you to start contributing directly to the repository. Once that's done, we can begin by outlining the documentation for each context. Feel free to share any additional thoughts or examples you have on the advantages of the format you prefer.

Looking forward to collaborating with you!

sadernalwis commented 5 months ago
  1. Canister dev (technical)

    • App
    • Operation
    • Timer
    • Task
    • Memory Map, Heap, Partitions, maybe DHT at some point?
    • WASM kit
    • Bugs
    • Logs
  2. Wallet Maker (half n half)

    • Users
    • Owner
    • Roles
    • Signature
    • Subaccount
    • Ledger
  3. Using JS (technical)

    • ic-reactor
  4. Using UI (user guide)

    • Conversions
      • ICP to Cycles
      • Cycles to ICP
      • ICP to ETH
      • ETH to ICP
      • ICP to BTC
      • BTC to ICP
      • ICP to ICRC
      • ICRC to ICP

Advatages of wide-line formatting, otherthan visibility and readability;

  1. Easier to identify recurring patterns in code.
  2. Easier to convert identified patterns in modules to macro_rules! and proc_macros
  3. helps Create op_stack rule layer for operations like
    
    ...(     |user_map|{let mut user_ids = UserIds::new();for (user_id, user) in user_map.iter() {if user.can_operate(operation) {user_ids.push(user_id.to_owned());}}callback(&user_ids)})}
    //becomes a generic copy/concat/move macro/command
2. Easier to convert identified patterns and build a wallet rules heuristic layer for dynamic wallet generation.
this will essentially make the `b3wallet` repo an autobuild product.
4. Can build a python module to extract sections or generate various template/boilerplate project files for a dev.
example:easy Python parsing of `.rs` files broken by line separated block. without complex parsing. I use the below method for NLP data preprocessing of adocs and code blocks.
```python

    def selected_block(script): 
        script = TextOps.pull(script,force=False) if type(script) is str else script
        line_begin = script.current_line_index
        lines = script.lines
        def trace(iter,index,op):
            out_lines = []
            if op=='FORWARD':
                while index < len(script.lines):
                    line = iter[index].body.split('#')[0].strip()
                    if line.strip(): out_lines.append(line)
                    else: return out_lines
                    index+=1
            elif op=='BACKWARD':
                while index > -1:
                    line = iter[index].body.split('#')[0].strip()
                    if line.strip(): out_lines.append(line)
                    else: return list(reversed(out_lines))
                    index-=1
            return out_lines
        return trace(lines, line_begin, 'BACKWARD')+trace(lines, line_begin, 'FORWARD')[1:]

async def process_adoc_file(self, file_path, channel, folder_path=''):
    try:
        with open(file_path, "r", encoding="utf-8") as file:
            content = file.readlines()
            for line in content:
                sline = line.strip()
                if sline:
                    if sline.startswith("image::"):
                        image_url, alt_text = self.extract_image_info(sline)
                        image_url = join(folder_path,image_url)
                    elif "link:" in line:
                        link_parts = line.split("link:", 1)[1].strip().split("[", 1)
                        link_url = link_parts[0].strip()
                        link_text = link_parts[1].split("]", 1)[0].strip() if len(link_parts) > 1 else ""
                        # print(f"Link detected: {link_url} (Link text: {link_text})")
                    elif sline.startswith("video::") or sline.startswith("audio::"):
                        media_url = sline.split("::")[1].strip()
                        media_url = join(folder_path,media_url)
                        print(media_url)
                    else: print(line.strip())  # Send other lines as text
                else: break
    except Exception as e:
        print(f"Error processing file: {str(e)}")

generally first code block being the use, last being the documentation bit. u can generate docs like autobuild.py generate doc <module_names>

  1. I belive the devs do more scrolling than coding. with this u could just study an entire commit/module with a single screenshot on a mobile even. helps me when I'm AFK.
b3hr4d commented 5 months ago

Thank you for your insights and the detailed explanation of wide-line formatting and its advantages. Your input is incredibly valuable.

Your idea to mix things up with backend code generation using your Python autobuilder code is super interesting and something I hadn't thought of. I was considering a project called B3Forge that generates user interface code based on each function, making it easily editable. image

Additionally, it would later generate backend code based on user function selection. Your idea is exactly what I needed.

Have you heard about my B3Forge project on the forum?

So, basically, we can add the backend builder on the interface with your autobuilder, right? Is that doable? I'd love to work with you on this. Your expertise and ideas could significantly enhance the B3Forge project. Let's make this conversation public on the B3Forge post or in a separate post to engage more developers and get broader feedback.

sadernalwis commented 4 months ago

Sorry about the delay. Have to do the rounds..๐Ÿ˜…

  1. I remember coming across B3Forge but hadn't the time to look into it, but I'm on it and will get back to you soon on that. by the initial looks of it looks good. I will join the discusssion.
  2. Yes, we can do the autobuilder: I have 2 ideas of how we can figure out WASM/Rust compilation of the dynamic wallet. Doable!
  3. One of my colleagues, @usama9500 has agreed to help us out with the Docs. More Hands!
b3hr4d commented 4 months ago

No problem, I had some off-days lately too.

  1. I will join the discusssion.

I love to have you there!

2. I have 2 ideas of how we can figure out WASM/Rust compilation of the dynamic wallet. Doable!

I cannot wait to hear about your ideas.

3. One of my colleagues, @usama9500 has agreed to help us out with the Docs. More Hands!

Thank you, that should be perfect.

usama9500 commented 4 months ago

Thank you ๐Ÿ˜…

I think we might approach organizing and explaining based on this structure and will refine further based on the features:

Canister Development (Technical)

App:

Operation:

Timer and Task:

Memory Map, Heap, Partitions:

WASM Kit:

Bugs and Logs:

Wallet Maker (Half Technical, Half User-Friendly)

Using JavaScript (Technical)

Using UI (User Guide)

Regarding the Python Module for document automation, my prior experience is with document management tools, including Notion, Gitbook, Readme, and Github, and some static website generators like Hugo and Sphinx. I am not sure how it works, will need help setting it up.

Some of the concerns regarding the module:

b3hr4d commented 4 months ago

Hi Usama,

Thank you for your responses and your willingness to help.

Itโ€™s great to have you here! Iโ€™m impressed by your approach to evolving the code and documentation. However, I must admit that I have no experience in Python and these types of tasks. Your structured plan for organizing the documentation is very thorough and aligns well with our goals.

The goal here is to have a decentralized and open-source set of tools that simplifies the process of creating dApps on the Internet Computer. You guys pretty much know what youโ€™re doing, and your expertise is invaluable.

Please let me know if thereโ€™s anything you need from me or any tasks that you think I should handle to support this effort. Iโ€™m here to help and ensure we move forward smoothly.

Looking forward to collaborating with you both!

Best regards, Behrad

usama9500 commented 4 months ago

Thank you, Berhad.

I had some unavailability the past week; however, I am fully available now and ready to get started!

For the documentation, let's use GitHub. We can set up a repository specifically for B3Pay Documentation.

Concerning the code, could we arrange a meeting to discuss how the codebase is organized on GitHub? I'd appreciate an overview of the directory/file structure for each feature, based on the outline provided here: https://github.com/B3Pay/b3_utils/issues/2#issuecomment-2148861399

b3hr4d commented 4 months ago

Hi @usama9500,

Thank you for getting back to me. I'm glad to hear that you're available now and ready to get started!

Using GitHub for the B3Pay Documentation sounds perfect. I'll set up a repository specifically for that purpose.

I also wanted to mention that we have a new project coming to the organization called Scaffold-IC. It's essentially a clone of Scaffold-ETH for the Internet Computer network. This project combines all the libraries and features available inside B3Pay, allowing developers to interact with pre-built apps created with those libraries and customize them for their specific use cases.

Regarding the code, let's arrange a meeting to discuss the organization of the codebase on GitHub. Iโ€™ll provide an overview of the directory and file structure for each feature based on the outline you provided.

Please let me know your availability for the meeting, and we can schedule a time that works for both of us. Here are a few time slots that work for me:

Looking forward to our discussion!

usama9500 commented 4 months ago

Thank you, Behrad, for your time!

I am available tomorrow, 23 June, between 4 PM and 6 PM CET.

My email: usama.ahmed95@gmail.com

Could you please send me an invite or provide me with your email address so I can send a Google Meet invite?

b3hr4d commented 4 months ago

I have sent you the invitation for a Zoom call tomorrow starting at 5 PM CET. Does that work for you?

usama9500 commented 4 months ago

Yes works for me!! Thank you!

See you soon.

sadernalwis commented 3 months ago

So back at it Gents!

@b3hr4d So the 2 ideas:

  1. combine rust template code files from UI/UX and redirect to Android App and the App compiles rust to wasm in jvm or native
  2. assemble prebuilt WKT or WKB(monolithic if possible??) or wasm blocks and upload to a system canister directly on frontend.

Screenshot from 2024-07-12 21-06-33 shall we schedule a call next week?

b3hr4d commented 3 months ago

Hi @sadernalwis,

Thank you for getting back to us!

Regarding your first idea about combining Rust template code files from UI/UX and redirecting to an Android App that compiles Rust to Wasm in JVM or native, Iโ€™m a bit unclear on how this process would work. Could you please provide more details or an example to help me understand it better?

Additionally, I wanted to let you know that I'm currently on a trip and will be back in 2 weeks. Would it be possible to schedule a call after I return to discuss these ideas in more detail?

Looking forward to our collaboration!