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

Create galaxy.md #1642

Merged
merged 1 commit into from
Apr 19, 2023
Merged

Create galaxy.md #1642

merged 1 commit into from
Apr 19, 2023

Conversation

7flash
Copy link
Contributor

@7flash 7flash commented Mar 30, 2023

Project Abstract

We aspire to create a canvas-based browser that allows Polkadot users to utilize a three-dimensional Stretch Text space for creating, organizing, and sharing knowledge. The browser app, built upon Excalidraw frontend, Polkadot network, and Chiselstrike backend, will provide a better way of browsing, enabling users to explore the interwoven nature of knowledge and better comprehend complex information.

Grant level

  • Level 1: Up to $10,000, 2 approvals
  • Level 2: Up to $30,000, 3 approvals
  • Level 3: Unlimited, 5 approvals (for >$100k: Web3 Foundation Council approval)

Application Checklist

  • The application template has been copied and aptly renamed (project_name.md).
  • I have read the application guidelines.
  • Payment details have been provided (bank details via email or BTC, Ethereum (USDC/DAI) or Polkadot/Kusama (USDT) address in the application).
  • The software delivered for this grant will be released under an open-source license specified in the application.
  • The initial PR contains only one commit (squash and force-push if needed).
  • The grant will only be announced once the first milestone has been accepted (see the announcement guidelines).
  • I prefer the discussion of this application to take place in a private Element/Matrix channel. My username is: @_______:matrix.org (change the homeserver if you use a different one)

@CLAassistant
Copy link

CLAassistant commented Mar 30, 2023

CLA assistant check
All committers have signed the CLA.

@keeganquigley
Copy link
Contributor

Thanks for the application @7flash a couple of initial comments:

  • Can you refer to our application template in order to fix the top so that the payment address and currency is included?
  • We typically ask for wireframes or mockups for front-end focused milestones. Do you have any you can provide?
  • Can you please add more technical specifics into the deliverables, such as the tech stack you will be using and what languages? For example, will the smart contract be written in ink!?
  • Is the Galaxy browser only meant to be for Polkadot/Kusama users? Or users of all Dapps?

@keeganquigley keeganquigley added the changes requested The team needs to clarify a few things first. label Mar 30, 2023
@7flash
Copy link
Contributor Author

7flash commented Mar 31, 2023

@keeganquigley

  • Can you refer to our application template in order to fix the top so that the payment address and currency is included?

force-pushed

  • We typically ask for wireframes or mockups for front-end focused milestones. Do you have any you can provide?

It's based on Layer UI

image
At the top left you have an UI island with button tools, and at the top right an island with connect wallet button.

Mentioning "Layer" UI, I must clarify it's not related to the concept of "Layer Links" described in application.

  • Can you please add more technical specifics into the deliverables, such as the tech stack you will be using and what languages? For example, will the smart contract be written in ink!?

That's right, smart contract will be written in ink!
As mentioned, frontend in React, and backend in Deno/Rust stack.

  • Is the Galaxy browser only meant to be for Polkadot/Kusama users? Or users of all Dapps?

Anyone can open galaxy links in read-only mode, but in order to save a new document/layer, user have to sign a transaction in Kusama network.

Can you explain what Stretch Text space is? What kind of knowledge will be shared? Is it similar to a forum?

Imagine it's a like a forum where next to every message you can see all the relevant information about the concepts mentioned in the message. Hopefully that makes sense.

Layer Link Example: https://galaxy.do/maps/?name=books

@keeganquigley
Copy link
Contributor

keeganquigley commented Apr 6, 2023

Thanks for your reply @7flash it makes more sense after checking out the various examples.

  • If I understand correctly, it is the layer link that is being stored on-chain? While the canvases utilize IPFS storage?
  • You mentioned that microtransactions/transclusion won't be included in this PoC. Does this mean you plan mock scenarios for testing?
  • What function(s) will be included in the smart contract?

Thanks! I also added some questions below. Apart from that, I will mark your application as ready for review and share it internally with the committee.

applications/galaxy.md Outdated Show resolved Hide resolved
applications/galaxy.md Outdated Show resolved Hide resolved
applications/galaxy.md Outdated Show resolved Hide resolved
@keeganquigley keeganquigley added ready for review The project is ready to be reviewed by the committee members. and removed changes requested The team needs to clarify a few things first. labels Apr 6, 2023
@7flash
Copy link
Contributor Author

7flash commented Apr 6, 2023

If I understand correctly, it is the layer link that is being stored on-chain? While the canvases utilize IPFS storage?

It's the IPFS link stored on-chain, as well layer names. It allows frontend to download canvas content from IPFS given layer name and creator account.

You mentioned that microtransactions/transclusion won't be included in this PoC. Does this mean you plan mock scenarios for testing?

Microtransactions and transclusion are two features which might take time to get done the right way.

Current deliverable is focused on more fundamental scenarios described in milestone 1 & 2.

That said, deliverable might include partial implementation of scenarios described in "next milestones", as possible within timeframe.

What function(s) will be included in the smart contract?

  1. "create_layer" is a mutation called by user to claim his layer saved on IPFS and associate it with chosen name.

  2. "resolve_link" is read-only function which accepts a string like "galaxy:///" and returns string link "ipfs://"

Following is a minimal implementation of the contract, it's not tested and has missing validations.

use ink_lang::contract;

#[contract]
mod galaxy_contract {
    use ink_storage::collections::{HashMap, Vec};

    #[ink(storage)]
    pub struct GalaxyContract {
        user_layers: HashMap<AccountId, Vec<String>>,
        layer_links: HashMap<(AccountId, String), String>,
    }

    impl GalaxyContract {
        #[ink(constructor)]
        pub fn new() -> Self {
            Self {
                user_layers: HashMap::new(),
                layer_links: HashMap::new(),
            }
        }

        #[ink(message)]
        pub fn create_layer(&mut self, layer_name: String, ipfs_link: String) {
            let user = self.env().caller();
            let layers = self.user_layers.entry(user).or_insert_with(Vec::new);
            layers.push(layer_name.clone());
            self.layer_links.insert((user, layer_name), ipfs_link);
        }

        #[ink(message)]
        pub fn resolve_link(&self, user: AccountId, layer_name: String) -> Option<&String> {
            if let Some(layers) = self.user_layers.get(&user) {
                if layers.contains(&layer_name) {
                    return self.layer_links.get(&(user, layer_name));
                }
            }
            None
        }
    }
}

I've never heard this term used. Is this another term for a DAO (Decentralized Autonomous Organization)?

Think DAO without ability to purchase voting power. Added link to reference implementation on polkadot.

I think this link is wrong :)

Fixed both video links.

Do you mean transclusion here?

Yes, - transclusion, - meaning embedding text by reference instead of copying the duplicate.

Copy link
Contributor

@keeganquigley keeganquigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks for your replies @7flash I'm happy to go ahead and approve it. Other committee members might have more questions during the review process.

@randombishop
Copy link
Contributor

Hi @7flash thanks for this application!

One question from my end: how do you make sure the user who registers the ipfs asset inchain "owns", or at least was the one who uploaded the ipfs asset? Can anyone register any ipfs link regardless of who uploaded it?

@7flash
Copy link
Contributor Author

7flash commented Apr 15, 2023

Hi @7flash thanks for this application!

One question from my end: how do you make sure the user who registers the ipfs asset inchain "owns", or at least was the one who uploaded the ipfs asset? Can anyone register any ipfs link regardless of who uploaded it?

User can register only galaxy layers, and only those which are created by himself.

Here a minimal example of layer, compatible with excalidraw definition of scene data:

{
  type: "excalidraw",
  version: 2,
  source: "<Wallet Address>",
  elements: [],
  appState: {},
  files: {},
}

create_layer then can receive layer content along with IPFS hash:

        pub fn create_layer(
            &mut self,
            layer_name: String,
            layer_content: String,
            ipfs_hash: String,
        ) -> Result<(), String> {

first, it needs to calculate hash of the content to make sure that's what uploaded at given link:

            use multihash::{Code, MultihashDigest};

            // ...

            let computed_hash = Code::Sha2_256.digest(layer_content.as_bytes());
            let computed_hash_base58 = bs58::encode(computed_hash).into_string();

            if computed_hash_base58 != ipfs_hash {
                return Err("Provided IPFS hash does not match content hash.".to_string());
            }

then it needs to deserialize content to make sure it corresponds the schema:

        use serde::{Deserialize, Serialize};

        pub struct LayerSchema {
            pub type: String,
            pub version: u32,
            pub source: String,
            // ...
        }

        // ...

        let parsed: Result<LayerSchema, _> =
            serde_json::from_str(&layer_content);

and finally, it can check that wallet address of transaction caller is mentioned as a source in the uploaded document

#[inline]
fn account_to_string(account_id: &AccountId) -> String {
    let account_id_bytes = account_id.as_ref();
    let mut output = vec![0xFF];
    output.extend_from_slice(account_id_bytes);
    let account_str = bs58::encode(output).into_string();
    account_str
}

// ...

let caller = self.env().caller();

match parsed {
    Ok(document) => {
        if (document.source != account_to_string(caller)) {
            return Err("Only Created by Yourself!");
        }
    }
    Err(_) => Err("Only Galaxy Layers Allowed!"),
}

@randombishop
Copy link
Contributor

Gotcha @7flash , thank you!

Copy link
Collaborator

@Noc2 Noc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the application looks good to me, and I'm happy to support it.

@Noc2 Noc2 merged commit 6a5f9b0 into w3f:master Apr 19, 2023
@github-actions
Copy link
Contributor

Congratulations and welcome to the Web3 Foundation Grants Program! Please refer to our Milestone Delivery repository for instructions on how to submit milestones and invoices, our FAQ for frequently asked questions and the support section of our README for more ways to find answers to your questions.

Before you start, take a moment to read through our announcement guidelines for all communications related to the grant or make them known to the right person in your organisation. In particular, please don't announce the grant publicly before at least the first milestone of your project has been approved. At that point or shortly before, you can get in touch with us at [email protected] and we'll be happy to collaborate on an announcement about the work you’re doing.

Lastly, please remember to let us know in case you run into any delays or deviate from the deliverables in your application. You can either leave a comment here or directly request to amend your application via PR. We wish you luck with your project! 🚀

@keeganquigley
Copy link
Contributor

Hi @7flash can you provide an update on milestone 1?

@7flash
Copy link
Contributor Author

7flash commented Sep 14, 2023

Hi @7flash can you provide an update on milestone 1?

Thanks for asking @keeganquigley

Hopefully will publish second milestone next week!

Sorry for delay, it was necessary to have all things coming together, specifically in short:

  1. excalidraw "frames" representing galaxy "layers" feat: introduce frames excalidraw/excalidraw#6123
  2. WebUI instead of tauri/electron Reshape the whole API to improve dev experience webui-dev/deno-webui#4
  3. Deno.KV instead of chiselstrike (both are based on sqlite)
  4. Macros Engine at the core, enables scenarios described in grant, plus any custom user functions can be written in js/ts/python

Please let me know if those upgrades are acceptable, and also if you could recommend a preferred parachain, which one should I deploy contract into.

@keeganquigley
Copy link
Contributor

@7flash thanks for the update!

Regarding the changes, I think these are minor enough that they don't require an amendment, seeing as you mention using Deno and Excalidraw in the application, and don't mention Tauri or Electron at all. So these should be fine, thanks for checking.

We try to stay agnostic when it comes to parachains, and since we don't fund production-ready software anyway, we don't have a preference as to which parachain you deploy to. For the sake of testing, a local node is fine. Or if you want to use a parachain testnet that's fine too. I hope that helps!

@7flash
Copy link
Contributor Author

7flash commented Sep 28, 2023

I have updated deliverables with permanent links, it's ready for review now.

@7flash
Copy link
Contributor Author

7flash commented Sep 28, 2023

Recommended steps for evaluation would be to follow below User Guide, then after to follow README.

User Guide

  1. Download:

  2. Polkadot Wallet:

    • Ensure your default browser has the Polkadot wallet installed in its default profile.
  3. Run Unsigned App:

    • Right-click the app icon and select 'Open'.
    • When prompted, confirm you want to run the unsigned app.
  4. Functionality Test:

    • Follow visual instructions in demo video to test:
      • Open
      • Save
      • Publish functions.

@7flash
Copy link
Contributor Author

7flash commented Sep 28, 2023

Macros

GalaxyAPI implements Macros Engine as described in the article. Save, Open, and Publish are three macros which are enabled by default, as these three are relevant to the current milestone. Users can create, share and execute their own scripts directly on the canvas, to implement different use cases, as shown in original prototype:
obsidian-excalidraw-plugin#1252

@keeganquigley
Copy link
Contributor

Thanks for the notice @7flash @dsm-w3f will be evaluating your delivery so I will ping him here for these instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review The project is ready to be reviewed by the committee members.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants