Skip to content

Commit

Permalink
Merge pull request #66 from TaggrNetwork/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
taggrx authored Sep 23, 2024
2 parents 1293dc9 + ccbc25c commit 3fa0e7f
Show file tree
Hide file tree
Showing 37 changed files with 1,752 additions and 886 deletions.
975 changes: 575 additions & 400 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
start:
dfx start --background -qqqq 2> /dev/null
dfx start --background -qqqq 2>&1 | grep -v sgymv &

staging_deploy:
NODE_ENV=production DFX_NETWORK=staging make fe
Expand Down
5 changes: 2 additions & 3 deletions dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
"metadata": [
{
"name": "candid:service",
"networks": ["local", "ic"],
"visibility": "public"
"visibility": "public",
"networks": ["local", "ic", "staging"]
}
]
}
},
"networks": {
"staging": {
"config": {
"FETCH_ROOT_KEY": true,
"API_HOST": "https://icp-api.io",
"STATIC_HOST": "https://icp0.io"
},
Expand Down
8 changes: 6 additions & 2 deletions e2e/test2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ test.describe("Regular users flow", () => {
await expect(
page.locator("article", { hasText: /Hello world/ }),
).toBeVisible();
await expect(page.locator("img")).toBeVisible();
await expect(
page.getByRole("img", { name: "512x512, 2kb" }),
).toBeVisible();

// Edit the post
await page.getByTestId("post-info-toggle").click();
Expand All @@ -113,7 +115,9 @@ test.describe("Regular users flow", () => {
hasText: "Hello world!\n" + "Edit: this is a post-scriptum",
}),
).toBeVisible();
await expect(page.locator("img")).toBeVisible();
await expect(
page.getByRole("img", { name: "512x512, 2kb" }),
).toBeVisible();
});

test("Wallet", async () => {
Expand Down
342 changes: 180 additions & 162 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "frontend",
"name": "taggr",
"version": "0.1.0",
"description": "Internet Computer starter application",
"keywords": [
Expand Down Expand Up @@ -40,12 +40,12 @@
"last 2 edge version"
],
"dependencies": {
"@dfinity/agent": "1.4.0",
"@dfinity/auth-client": "1.4.0",
"@dfinity/candid": "1.4.0",
"@dfinity/identity": "1.4.0",
"@dfinity/ledger-icrc": "2.4.0",
"@dfinity/principal": "1.4.0",
"@dfinity/agent": "2.0.0",
"@dfinity/auth-client": "2.0.0",
"@dfinity/candid": "2.0.0",
"@dfinity/identity": "2.0.0",
"@dfinity/ledger-icrc": "2.5.0",
"@dfinity/principal": "2.0.0",
"assert": "2.1.0",
"diff-match-patch": "1.0.5",
"react": "18.3.1",
Expand Down
4 changes: 3 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
export PATH=${HOME}/.local/share/dfx/bin:${PATH}

make build
make start
dfx start --background
dfx deploy
dfx canister info taggr
OUTPUT=$(dfx canister call taggr prod_release)
if [ "$OUTPUT" != "(true)" ]; then
echo "Error: dev feature is enabled!"
exit 1
fi
dfx stop
cp .dfx/local/canisters/taggr/taggr.wasm.gz target/wasm32-unknown-unknown/release/taggr.wasm.gz
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.76.0"
channel = "1.79.0"
components = ["rustfmt", "clippy"]
targets = ["wasm32-unknown-unknown"]
3 changes: 3 additions & 0 deletions src/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ ic-cdk-macros = "0.16.0"
ic-cdk-timers = "0.9.0"
ic-certified-map = "0.4.0"
ic-ledger-types = "0.9.0"
icrc-ledger-types = "0.1.6"
png = "0.17"
serde = { version = "1.0.192", features = ["derive"] }
serde_bytes = "0.11.15"
serde_cbor = "0.11.2"
serde_json = "1.0.125"
sha2 = "0.10.8"
tiny-skia = "0.7"

[dev-dependencies]
actix-rt = "*"
Expand Down
19 changes: 14 additions & 5 deletions src/backend/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,23 +122,32 @@ pub fn load() {
domains.join("\n").as_bytes().to_vec(),
);

set_certified_data(&labeled_hash(LABEL, &asset_hashes().root_hash()));
certify();
}

pub fn root_hash() -> [u8; 32] {
asset_hashes().root_hash()
}

#[allow(unused_variables)]
pub fn set_certified_data(data: &[u8]) {
pub fn certify() {
let value = &labeled_hash(LABEL, &asset_hashes().root_hash());
#[cfg(test)]
return;
#[cfg(not(test))]
ic_cdk::api::set_certified_data(&labeled_hash(LABEL, &asset_hashes().root_hash()));
ic_cdk::api::set_certified_data(value)
}

pub fn add_value_to_certify(label: &str, hash: [u8; 32]) {
asset_hashes().insert(label.as_bytes().to_vec(), hash);
}

fn add_asset(paths: &[&str], headers: Headers, bytes: Vec<u8>) {
let mut hasher = Sha256::new();
hasher.update(&bytes);
let hash = hasher.finalize().into();
for path in paths {
asset_hashes().insert(path.as_bytes().to_vec(), hash);
add_value_to_certify(path, hash);
assets().insert(path.to_string(), (headers.clone(), bytes.clone()));
}
}
Expand Down Expand Up @@ -167,7 +176,7 @@ pub fn export_token_supply(total_supply: u128) {
.to_vec(),
)
}
set_certified_data(&labeled_hash(LABEL, &asset_hashes().root_hash()));
certify();
}

fn certificate_header(path: &str) -> (String, String) {
Expand Down
6 changes: 4 additions & 2 deletions src/backend/env/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ pub struct Config {
pub blob_cost: Credits,
pub poll_cost: Credits,
pub realm_cost: Credits,
pub tipping_cost: Credits,

pub poll_revote_deadline_hours: u64,

pub name_change_cost: Credits,
pub identity_change_cost: Credits,

pub max_realm_name: usize,
pub max_realm_logo_len: usize,
Expand Down Expand Up @@ -263,10 +264,11 @@ pub const CONFIG: &Config = &Config {
blob_cost: 20,
poll_cost: 3,
realm_cost: 1000,
tipping_cost: 5,

poll_revote_deadline_hours: 4,

name_change_cost: 1000,
identity_change_cost: 1000,

max_realm_name: 25,
max_realm_logo_len: 16 * 1024,
Expand Down
16 changes: 8 additions & 8 deletions src/backend/env/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ pub struct Feature {
}

/// Returns a list of all feature ids and current collective voting power of all supporters.
pub fn features(
state: &State,
ids: Vec<PostId>,
) -> Box<dyn DoubleEndedIterator<Item = (PostId, Token, Feature)> + '_> {
let count_support = move |(post_id, feature): (PostId, Feature)| {
pub fn features<'a>(
state: &'a State,
ids: &'a [PostId],
) -> Box<dyn DoubleEndedIterator<Item = (PostId, Token, Feature)> + 'a> {
let count_support = move |(post_id, feature): (&PostId, Feature)| {
(
post_id,
*post_id,
feature
.supporters
.iter()
Expand All @@ -44,8 +44,8 @@ pub fn features(
};
if !ids.is_empty() {
return Box::new(
ids.into_iter()
.filter_map(move |id| state.memory.features.get(&id).map(|feature| (id, feature)))
ids.iter()
.filter_map(move |id| state.memory.features.get(id).map(|feature| (id, feature)))
.map(count_support),
);
}
Expand Down
12 changes: 8 additions & 4 deletions src/backend/env/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ impl Memory {

#[cfg(test)]
pub fn init_test_api(&mut self) {
// Skip if memory is initialized
if self.posts.initialized {
return;
}

static mut MEM_END: u64 = 16;
static mut MEMORY: Option<Vec<u8>> = None;
unsafe {
Expand Down Expand Up @@ -357,7 +362,7 @@ impl<K: Ord + Eq, T: Serialize + DeserializeOwned> Default for ObjectManager<K,
}
}

impl<K: Eq + Ord + Clone + Copy + Display, T: Serialize + DeserializeOwned> ObjectManager<K, T> {
impl<K: Eq + Ord + Clone + Display, T: Serialize + DeserializeOwned> ObjectManager<K, T> {
pub fn len(&self) -> usize {
self.index.len()
}
Expand All @@ -377,14 +382,13 @@ impl<K: Eq + Ord + Clone + Copy + Display, T: Serialize + DeserializeOwned> Obje
.map(|(offset, len)| self.api.borrow().read(*offset, *len))
}

pub fn iter(&self) -> Box<dyn DoubleEndedIterator<Item = (K, T)> + '_> {
pub fn iter(&self) -> Box<dyn DoubleEndedIterator<Item = (&'_ K, T)> + '_> {
Box::new(
self.index
.keys()
.cloned()
.collect::<Vec<_>>()
.into_iter()
.map(move |id| (id, self.get(&id).expect("couldn't retrieve value"))),
.map(move |id| (id, self.get(id).expect("couldn't retrieve value"))),
)
}

Expand Down
Loading

0 comments on commit 3fa0e7f

Please sign in to comment.