-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple Counter without auth #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
처음으로 깃 사용해서 작업해보시느라 수고 많으셨습니다
커밋 메세지와 무관한 내용이 커밋에 담겨있습니다. interactive rebase 와 force push 를 이용해서 한 번 고쳐봅니다.
p.s. cli 로 이걸 하려면 굉장히 어렵습니다. fork
와 같은 버전관리 툴을 한번 사용해봅시다. 만약 도움이 필요하다면, 핑을 찍거나 저녁에 제가 디코에 있는 거 같을때 보이스챗으로 도와드리겠습니다
simple-counter/src/lib.rs
Outdated
pub fn increment(&mut self) { | ||
//let caller = env::signer_account_id(); | ||
//use below line instead of below for test | ||
let caller = "kmlee".to_string(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
caller 가 어떠한 임의의 계정으로 고정이 되어있습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env의 signer account로 변경했습니다!
simple-counter/src/lib.rs
Outdated
let caller = "kmlee".to_string(); | ||
let current_val = match self.user_counters.get(&caller) { //get previous value | ||
Some(val) => val, | ||
None => 0i16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get을 했는데, 어떠한 값도 찾을 수 없다면, 0을 리턴하는 게 좋을까요? 아니면, panic 으로 터트리는게 더 좋을까요?
만약에 존재하지 않는 계정을 increase 하려고 하면 뭐가 문제일지 함수 명과 함께 생각해봅니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None의 경우 panic으로 수정했습니다
simple-counter/src/lib.rs
Outdated
let caller = "kmlee".to_string(); | ||
let current_val = match self.user_counters.get(&caller) { //get previous value | ||
Some(val) => val, | ||
None => 0i16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위 코멘트와 비슷한 맥락이지만, 이쪽은 더 위험합니다. 다행히 지금은 자료형이 i16
signed 이지만, u64
에서는 무슨 일이 벌어질까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
자료형을 수정하고 이 또한 decrease 함수 또한 panic으로 수정했습니다
//logging | ||
env::log(b"Reset counter to zero"); | ||
} | ||
pub fn delete(&mut self, k: String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use fommatter
previously function upload_modify_and_query have to deploy, interact with smart contract. Now, changed to simply interact with pre-deployed contract.
since two features are tested in single test, split it into seperate tests
Type of this PR
Describe your changes
Using UnordereMap to generate simple counter without auth
Used designated account name(kmlee) for test
Reference
https://github.com/near-examples/rust-status-message/blob/master/src/lib.rs
https://github.com/near-examples/rust-counter/blob/01-use-hashmap/contract/src/lib.rs
https://www.near-sdk.io/testing/unit-tests
Issue ticket number and other helpful resource
Checklist before requesting a review
Checklist after creating a pull request