AlexandriaDAO / core

https://xo3nl-yaaaa-aaaap-abl4q-cai.icp0.io/
MIT License
5 stars 3 forks source link

Deploy locally

We have reporoducable builds coming soon. Sorry for this mess.

Latest network deploy: 08/10/24

run ./scripts/build.sh

For frontend only: npm run dev

Or on mainnet: Switch canister_ids.json with your own canisters and run ./scripts/network_build.sh

Common Prerequisites if this fails:

(Linux)

Patterns and Standards (for contributions)

Please follow these if you add stuff.

Adding a New Canister.

Please use the existing Typescript or Rust patterns in dfx.json.

Always name the folder, and .did file the same canister name, e.g.,

Accessing a new Canister from the Frontend.

Add it to the following files with the existing patterns: (1) src/alex_frontend/src/contexts/SessionContext.tsx (2) src/alex_frontend/src/features/auth/utils/authUtils.tsx (3) src/alex_frontend/src/providers/SessionProvider.tsx

We use 2 patterns when calling actor functions: Implemented with const { actor } = useSession(); via SessionContext.tsx or createAsyncThunk... via Redux? When should we use which?

todo before next push: Fix fetchBooks.ts, fetchEngineBooks.ts, and irys.tsx

Referencing canisters on the backend.

The registry canister handles all canister ids so they shouldn't be hardcoded anywhere.

Use this pattern:

pub const REGISTRY_CANISTER_ID: &str = "uxyan-oyaaa-aaaap-qhezq-cai";

pub async fn get_canister_id(canister_name: &str) -> Principal {
    // Call get_registry_principal from registry canister
    ic_cdk::call::<(String,), (Principal,)>(
        Principal::from_text(REGISTRY_CANISTER_ID).unwrap(),
        "get_registry_principal",
        (canister_name.to_string(),),
    )
    .await
    .expect("Failed to get canister ID")
    .0
}

get_canister_id("TOKENOMICS").await

This way the only hardcoded canister id is the registry canister id, which will never change.

It's preferable to put this in the lib.rs file so we know what canisters each canister interacts with very easily.

Rationale: This methodology is the most consise, and having all the canister ids in each Lib.rs immediately tells you what canisters it interacts with.

Dynamic Imports (webpack chunking)

Use the pattern in nsfwjs/nsfwImports.tsx. It was used to dynamically import TensorFlow with much success.

Adding an app.

Add a `src/apps/your_app_name/index.tsx, and keep all supporting components in the apps folder. Eventually the good apps may move to different repos/subdomains, so the logic must be standalone. For this reason it's better to have duplicate code, that reusing/relying on parts of the main app which might have to be moved.

Distinguishing Blocks/Channels, NFTs & SBTs.

Looks like we've actually already figured this out.

Blocks are NFTs, Channels are SBTs.

So we'll have to make the Arweave Uploads more Generic. The app has to handle lots of different rendering methods, so we'll have the uploader preview how it displays in the block before uploading.

It's free to create a channel and you can make money from it, but to add a block to the channel you must pay that block.

Next steps - Let's just worry about making blocks and channels, not the experience yet.

Primatives for Uploader in Main Pager:

Minting NFTs:

Rules of engaagment for experience stuff: