Skip to content

Commit

Permalink
Merge pull request #3 from FloorLamp/cycle-balance
Browse files Browse the repository at this point in the history
Fix cycle balance
  • Loading branch information
rckprtr authored Sep 15, 2021
2 parents 5710c79 + 0ae9e43 commit a8aec9d
Show file tree
Hide file tree
Showing 10 changed files with 456 additions and 73 deletions.
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "vite build",
"dev": "vite",
"dfx:install": "dfx canister --network=ic ic_loot_rs --all --mode reinstall",
"dfx:install": "dfx canister install ic_loot_rs --all",
"dfx:rebuild": "dfx build && npm run dfx:install",
"dfx:setup": "dfx canister create --all && dfx build && npm run dfx:install"
},
Expand Down
8 changes: 4 additions & 4 deletions src/ic_loot_assets/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
<div class="md:flex grid justify-center mb-10">
<img
class="w-96 md:px-6 mb-5"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=1"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=95"
/>
<img
class="w-96 md:px-6 mb-5"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=2"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=294"
/>
<img
class="w-96 md:px-6"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=3"
src="https://d3ttm-qaaaa-aaaai-qam4a-cai.raw.ic0.app/?tokenId=811"
/>
</div>

Expand All @@ -29,7 +29,7 @@
<a target="_blank" href="https://internetcomputer.org/" class="underline"
>Internet Computer</a
>
project based on the
project inspired by
<a target="_blank" href="https://www.lootproject.com/" class="underline"
>Loot Project</a
>
Expand Down
6 changes: 6 additions & 0 deletions src/ic_loot_assets/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createApp } from "vue";
import App from "./App.vue";
import "virtual:windi.css";
import VueGtag from "vue-gtag-next";

/**
* @dfinity/agent requires this. Can be removed once it's fixed
Expand All @@ -9,5 +10,10 @@ window.global = window;

const app = createApp(App);

app.use(VueGtag, {
property: {
id: "G-KE88EVJHWW",
},
});

app.mount("#app");
4 changes: 2 additions & 2 deletions src/ic_loot_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ crate-type = ["cdylib"]

[dependencies]
ic-types = "0.2.1"
ic-cdk = "0.2.4"
ic-cdk = "0.3.1"
base64 = "0.13.0"
ic-cdk-macros = "0.3.0"
ic-certified-map = "0.1.0"
Expand All @@ -21,4 +21,4 @@ num-traits = "0.2.14"
serde = "1.0.116"
serde_cbor = "0.11"
serde_bytes = "0.11"
serde_with = "1.6.2"
serde_with = "1.6.2"
10 changes: 10 additions & 0 deletions src/ic_loot_rs/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ impl AddressBook {
return false;
}

pub fn undo_transfer(&mut self, user_id: Principal, token_id: u64) -> bool {
if let Some(token_owner) = self.tokens.get(&token_id) {
if &user_id == token_owner {
self.tokens.insert(token_id, ic_cdk::caller());
return true;
}
}
return false;
}

pub fn transfer_to(&mut self, user: Principal, token_id: u64) -> bool {
if let Some(token_owner) = self.tokens.get(&token_id) {
if token_owner == &ic_cdk::caller() {
Expand Down
42 changes: 42 additions & 0 deletions src/ic_loot_rs/ic_loot.did
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// http://icdrip.io

// ██▓ ▄████▄ ▓█████▄ ██▀███ ██▓ ██▓███
// ▓██▒▒██▀ ▀█ ▒██▀ ██▌▓██ ▒ ██▒▓██▒▓██░ ██▒
// ▒██▒▒▓█ ▄ ░██ █▌▓██ ░▄█ ▒▒██▒▓██░ ██▓▒
// ░██░▒▓▓▄ ▄██▒ ░▓█▄ ▌▒██▀▀█▄ ░██░▒██▄█▓▒ ▒
// ░██░▒ ▓███▀ ░ ░▒████▓ ░██▓ ▒██▒░██░▒██▒ ░ ░
// ░▓ ░ ░▒ ▒ ░ ▒▒▓ ▒ ░ ▒▓ ░▒▓░░▓ ▒▓▒░ ░ ░
// ▒ ░ ░ ▒ ░ ▒ ▒ ░▒ ░ ▒░ ▒ ░░▒ ░
// ▒ ░░ ░ ░ ░ ░░ ░ ▒ ░░░
// ░ ░ ░ ░ ░ ░
// ░ ░


type HeaderField = record { text; text; };

type HttpRequest = record {
Expand Down Expand Up @@ -26,19 +40,47 @@ type ClaimResult = variant {
Err: text;
};

type LootData = record {
slot: text;
name: text;

prefix: text;
name_prefix: text;
name_suffix: text;
special: bool;
};

type DataOfQuery = variant {
Range: record {nat64; nat64};
List: vec nat64;
};

type TransferNotification = record {
to: principal;
from: principal;
token_id: nat64;
amount: nat64;
};

service : {
http_request: (request: HttpRequest) -> (HttpResponse) query;

get_address_book: () -> (AddressBook) query;
get_token_properties: (nat64) -> (vec record { text; text}) query;
get_token_properties_range: (nat64, nat64) -> (vec vec record { text; text}) query;

data_of: (nat64) -> (vec LootData) query;
data_of_many: (DataOfQuery) -> (vec record {nat64; vec LootData;}) query;

get_cycles: () -> (int64);
get_airdrops: () -> (vec record { nat64; bool }) query;
add_airdrops: (vec principal) -> (bool);
name: () -> (text) query;
symbol: () -> (text) query;
user_tokens: (principal) -> (vec nat64) query;
owner_of: (nat64) -> (opt principal) query;
transfer_to: (principal, nat64) -> (bool);
transfer_with_notify: (principal, nat64) -> (bool);
claim: () -> (ClaimResult);
remaining: () -> (nat64);
supply: () -> (nat64);
Expand Down
Loading

0 comments on commit a8aec9d

Please sign in to comment.