Skip to content

Commit

Permalink
compile and deploy contract in workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Dec 24, 2023
1 parent 018ec17 commit ffe16fa
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
23 changes: 13 additions & 10 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"image": "mcr.microsoft.com/devcontainers/universal",
"features": {
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"vscode": {
"extensions": ["rust-lang.rust-analyzer"]
}
},
"image": "mcr.microsoft.com/devcontainers/universal",
"features": {
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer"
]
}
},
"postCreateCommand": ".devcontainer/post-create.sh"
}
2 changes: 2 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
rustup target add wasm32-unknown-unknown
1 change: 0 additions & 1 deletion nearcontract/Cargo.lock

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

1 change: 0 additions & 1 deletion nearcontract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2018"
crate-type = ["cdylib", "rlib"]

[dependencies]
wee_alloc = "0.4.5"
byteorder= "1.4.2"
near-sdk = "4.1.1"
ed25519-dalek = "1.0.1"
Expand Down
7 changes: 2 additions & 5 deletions nearcontract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ use ed25519_dalek::Signature as DalekSig;
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::LookupMap;
use near_sdk::PublicKey;
use near_sdk::{base64, env, near_bindgen};
use near_sdk::{base64, env, near_bindgen,PanicOnDefault};
use std::collections::HashMap;

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

pub type Permission = u32;
const PERMISSION_OWNER: Permission = 0x01; // Can create
const PERMISSION_CONTRIBUTOR: Permission = 0x02;
Expand Down Expand Up @@ -41,7 +38,7 @@ pub struct RepositoryPermission {
}

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
#[derive(PanicOnDefault,BorshDeserialize, BorshSerialize)]
pub struct RepositoryPermissionV2 {
permission: LookupMap<String, HashMap<String, Permission>>,
}
Expand Down
5 changes: 1 addition & 4 deletions nearcontract/tests/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ pub async fn init_contracts() -> anyhow::Result<near_workspaces::Contract> {
let contract_id: AccountId = WASMGIT_CONTRACT.parse()?;
let contract = worker
.import_contract(&contract_id, &mainnet)
.initial_balance(NearToken::from_near(parse_near!("1000 N")))
.initial_balance(NearToken::from_near(1000))
.transact()
.await?;
let outcome = contract.call("new").args_json(json!({})).transact().await?;
assert!(outcome.is_success());
assert!(format!("{:?}", outcome).contains("Migrated to version:"));

Ok(contract)
}

0 comments on commit ffe16fa

Please sign in to comment.