Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
just-do-halee committed Feb 19, 2023
1 parent 10bd421 commit da2777f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/build/*
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
accountId =
contractId =
accountId =
contractId =
# ------------------------------------------------------
#
# set : Sets the account and contract id
Expand Down Expand Up @@ -28,6 +28,7 @@ contractId =
#
# ------------------------------------------------------
MKPATH = $(abspath $(lastword $(MAKEFILE_LIST)))
BUILDPATH = build

C=cargo
R=rustup
Expand Down Expand Up @@ -100,11 +101,12 @@ test:
build: test
@$(R) target add $(CTARGET)
@$(CFLAG)='-C link-arg=-s' $(C) build --release --target=$(CTARGET)
@cp ./target/$(CTARGET)/release/*.wasm ./res/
@if [ ! -d "$(BUILDPATH)" ]; then mkdir $(BUILDPATH); fi
@cp ./target/$(CTARGET)/release/*.wasm ./$(BUILDPATH)/

deploy: checkAccount test build
@echo "deploying ${contractId} with ${accountId} \ninitFunction = ${initFunction}\ninitArgs = ${initArgs}\ninitGas = ${initGas}\ninitDeposit = ${initDeposit}\n"
@$(N) deploy $(contractId) --wasmFile ./res/*.wasm \
@$(N) deploy $(contractId) --wasmFile ./$(BUILDPATH)/*.wasm \
$(if $(initFunction), --initFunction=$(initFunction)) \
$(if $(initArgs), --initArgs='$(initArgs)') \
$(if $(initGas), --initGas=$(initGas)) \
Expand All @@ -127,7 +129,7 @@ view: checkAccount checkMethod
# ------------------------------------------------------

clean:
@rm -rf ./res/*.wasm
@rm -rf ./$(BUILDPATH)/*
@$(C) clean


Expand Down
2 changes: 2 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -e # if any command fails, exit the script


git clone https://github.com/just-do-halee/near-contract

Expand Down
Empty file removed res/.gitkeep
Empty file.
10 changes: 8 additions & 2 deletions src/cmn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
pub use near_sdk::{
borsh::{self, BorshDeserialize, BorshSerialize},
env, log, near_bindgen, require,
PanicOnDefault,
};
pub use near_sdk::{
collections::{self, LazyOption, LegacyTreeMap, TreeMap},
store::*,
};
pub use near_sdk::{env, log, near_bindgen, require};
pub use near_sdk::{json_types::*, AccountId, Balance, Promise};

/// Hex encoding/decoding: .encode_hex() and .decode_hex()
pub use uint::hex::{FromHex, FromHexError, ToHex};
Expand Down Expand Up @@ -133,7 +139,7 @@ pub mod test_utils {
}
pub use vm;

/// Create a container for logs.
/// Create a container for logs mocks.
///
/// # Example
/// ```
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ mod cmn;
use cmn::*;

#[near_bindgen]
#[derive(Default, BorshDeserialize, BorshSerialize)]
#[derive(PanicOnDefault, BorshDeserialize, BorshSerialize)]
pub struct Contract {
// contract state
solution: String,
}

#[near_bindgen]
impl Contract {
fn hash(s: String) -> String {
hash(s, env::sha256).encode_hex::<String>()
}
}

#[near_bindgen]
impl Contract {
// contract methods
#[init]
pub fn new(solution: String) -> Self {
Expand Down

0 comments on commit da2777f

Please sign in to comment.