Skip to content

Commit

Permalink
Merge pull request #5 from letmejustputthishere/fix/update-dependencies
Browse files Browse the repository at this point in the history
🩹 fixed frontend build issues
  • Loading branch information
letmejustputthishere authored Sep 25, 2024
2 parents eea02a5 + ad9aca0 commit d7cb25f
Show file tree
Hide file tree
Showing 11 changed files with 2,309 additions and 2,297 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
ecmaVersion: 2022,
extraFileExtensions: ['.svelte']
},
env: {
Expand Down
33 changes: 10 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,23 @@
# Vite + SvelteKit + Motoko
# ICRC-7 Launchpad

### Get started directly:

> [!WARNING]
> Due to current limitations, this template does not work in a Browser Editor when using gitpod or codespaces. Please use VS Code for desktop instead.
> <img width="633" alt="Screenshot 2024-01-29 at 12 44 57" src="https://github.com/letmejustputthishere/vite-sveltekit-motoko/assets/32162112/2f2c025d-354b-47ca-9303-56bce180f6e7">
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/letmejustputthishere/vite-sveltekit-motoko)

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/letmejustputthishere/vite-sveltekit-motoko?quickstart=1)

This template gives you everything you need to build a full-stack Web3 application on the [Internet Computer](https://internetcomputer.org/).

For an example of a real-world dapp built using this starter project, check out the [source code](https://github.com/dfinity/feedback) for DFINITY's [Developer Experience Feedback Board](https://dx.internetcomputer.org/).

## 📦 Create a New Project
## Quickstart

> [!IMPORTANT]
> Make sure that [Node.js](https://nodejs.org/en/) `>= 18`, [mops](https://docs.mops.one/quick-start) `>=0.39.2` and [`dfx`](https://internetcomputer.org/docs/current/references/dfxvm/) `>= 0.16.1` are installed on your system.
> Make sure that [Node.js](https://nodejs.org/en/) `>= 20`, [mops](https://docs.mops.one/quick-start) `>=1.0.0` and [`dfx`](https://internetcomputer.org/docs/current/references/dfxvm/) `>= 0.23.0` are installed on your system.
Run the following commands in a new, empty project directory:
> [!WARNING]
> Make sure to have a `identity.pem` at the root of the project. Provide the account identifier of this identity in the `init_args` of the `dfx.json` file for the ledger and cmc canister deployments.
```sh
npx degit letmejustputthishere/vite-sveltekit-motoko vite-sveltekit-motoko # Download this starter project
cd vite-sveltekit-motoko # Navigate to the project directory
```bash
dfx start --clean --background # Run dfx in the background
npm run setup # Install packages, deploy canisters, and generate type bindings

npm start # Start the development server
```

When ready, run `dfx deploy --network ic` to deploy your application to the Internet Computer.
# in a new terminal run
npm run upload-canisters # upload the wasm files for the icrc7 ledger and asset canister to the launchpad canister
npm run create-collections # create a number of dummy collections on the launchpad
```

## 🛠️ Technology Stack

Expand Down
27 changes: 14 additions & 13 deletions backend/factory.mo
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Ic "ic:aaaaa-aa";
import Icp "canister:icp_ledger";
import Management "ic:aaaaa-aa";
import Cmc "canister:cmc";
import Cycles "mo:base/ExperimentalCycles";
import IcpLedger "canister:icp_ledger";
Expand All @@ -9,38 +8,40 @@ import Result "mo:base/Result";
import Nat64 "mo:base/Nat64";
import Blob "mo:base/Blob";
import Error "mo:base/Error";
import Types "types";

module Factory {

public func installCode(args : Types.install_code_args) : async () {
let canisterId = await Ic.install_code(args);
public func installCode(args : Management.install_code_args) : async () {
let _canisterId = await Management.install_code(args);
};

public func updateControllers(controllers : [Principal], canisterId : Principal) : async () {
await Ic.update_settings({
await Management.update_settings({
canister_id = canisterId;
settings = {
controllers = ?controllers;
compute_allocation = null;
freezing_threshold = null;
memory_allocation = null;
reserved_cycles_limit = null;
log_visibility = null;
wasm_memory_limit = null;
};
sender_canister_version = null;
});
};

public func createCanisterWithIcp(args : Cmc.NotifyCreateCanisterArg) : async Cmc.NotifyCreateCanisterResult {
let canisterId = await Cmc.notify_create_canister(args);
let _canisterId = await Cmc.notify_create_canister(args);
};

public func createCanisterWithCycles(args : Types.create_canister_args, cycles : Nat) : async Types.create_canister_result {
Cycles.add(cycles);
let result = await Ic.create_canister(args);
public func createCanisterWithCycles(args : Management.create_canister_args, cycles : Nat) : async Management.create_canister_result {
Cycles.add<system>(cycles);
let _result = await Management.create_canister(args);
};

public func topUpCanister(args : Cmc.NotifyTopUpArg) : async Cmc.NotifyTopUpResult {
let result = await Cmc.notify_top_up(args);
let _result = await Cmc.notify_top_up(args);
};

public func deployCanister(wasm_module : Blob, init_args : Blob, cycles : Nat) : async Principal {
Expand Down Expand Up @@ -69,7 +70,7 @@ module Factory {
let transferResult = await IcpLedger.transfer({
amount = { e8s = Nat64.fromNat(balance) - 10_000 : Nat64 };
// we move the funds from the caller dedicated subacccount
from_subaccount = ?Blob.toArray(principalToSubaccount(caller));
from_subaccount = ?principalToSubaccount(caller);
created_at_time = null;
fee = { e8s = 10_000 : Nat64 };
// the memo is important for the CMC to confirm the operation
Expand All @@ -78,7 +79,7 @@ module Factory {
memo = 0x50555054;
// we move the funds to the canister dedicated subaccount for the CMC
// the CMC only checks the caller dedicated subaccount when topping up
to = Blob.toArray(accountIdentifier(Principal.fromActor(Cmc), principalToSubaccount(canister)));
to = accountIdentifier(Principal.fromActor(Cmc), principalToSubaccount(canister));
});

let blockIndex = switch (transferResult) {
Expand Down
4 changes: 2 additions & 2 deletions backend/main.mo
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ actor Main {
public shared ({ caller }) func getUserAccount() : async IcpLedger.Account {
{
owner = Principal.fromActor(Main);
subaccount = ?Blob.toArray(principalToSubaccount(caller));
subaccount = ?principalToSubaccount(caller);
};
};

Expand All @@ -60,7 +60,7 @@ actor Main {
// check ICP balance of the callers dedicated account
let balance = await IcpLedger.icrc1_balance_of({
owner = Principal.fromActor(Main);
subaccount = ?Blob.toArray(principalToSubaccount(caller));
subaccount = ?principalToSubaccount(caller);
});

if (balance < 200_000_000) {
Expand Down
25 changes: 0 additions & 25 deletions backend/types.mo
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module {
public type wasm_module = Blob;

public type canister_id = Principal;

public type Collection = {
assetsCanister : Principal;
Expand All @@ -16,26 +13,4 @@ module {
symbol : ?Text;
};

public type install_code_args = {
arg : Blob;
wasm_module : wasm_module;
mode : { #reinstall; #upgrade; #install };
canister_id : canister_id;
sender_canister_version : ?Nat64;
};

public type create_canister_args = {
settings : ?canister_settings;
sender_canister_version : ?Nat64;
};

public type create_canister_result = { canister_id : canister_id };

public type canister_settings = {
freezing_threshold : ?Nat;
controllers : ?[Principal];
reserved_cycles_limit : ?Nat;
memory_allocation : ?Nat;
compute_allocation : ?Nat;
};
};
Loading

0 comments on commit d7cb25f

Please sign in to comment.