Skip to content

Commit

Permalink
refactor: rename whale to pophin
Browse files Browse the repository at this point in the history
  • Loading branch information
kmlee307 committed Sep 5, 2022
1 parent d08b605 commit b0df086
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ members = [
"colony-chain",
"treasury",
"light-client",
"whale"
"pophin"
]
2 changes: 1 addition & 1 deletion whale/Cargo.toml → pophin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pdao-near-whale"
name = "pdao-near-pophin"
version = "0.0.1"
authors = ["PDAO Team <hello@postech-dao.xyz>"]
edition = '2021'
Expand Down
62 changes: 31 additions & 31 deletions whale/src/lib.rs → pophin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ use near_sdk::{env, near_bindgen, AccountId, PanicOnDefault, PromiseOrValue};

#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
pub struct WhaleContract {
pub struct PophinContract {
token: FungibleToken,
decimals: u8,
name: String,
symbol: String,
icon: Option<String>,
}

near_contract_standards::impl_fungible_token_core!(WhaleContract, token);
near_contract_standards::impl_fungible_token_storage!(WhaleContract, token);
near_contract_standards::impl_fungible_token_core!(PophinContract, token);
near_contract_standards::impl_fungible_token_storage!(PophinContract, token);

/// TODO: replace PDAO's whale icon
const PDAO_WHALE_ICON: &str = "PDAO WHALE ICON ADRESSS";
/// TODO: replace PDAO's pophin icon
const PDAO_POPHIN_ICON: &str = "PDAO pophin ICON ADRESSS";

#[near_bindgen]
impl WhaleContract {
/// Initializes the contract with PDAO whale spec
impl PophinContract {
/// Initializes the contract with PDAO pophin spec
#[init]
pub fn new() -> Self {
Self {
token: FungibleToken::new(b"w".to_vec()),
decimals: 24,
name: "PDAO_meme_token_Whale".to_string(),
symbol: "PDAO-WHALE".to_string(),
icon: Some(PDAO_WHALE_ICON.to_string()),
name: "PDAO_meme_token_Pophin".to_string(),
symbol: "PDAO-POPHIN".to_string(),
icon: Some(PDAO_POPHIN_ICON.to_string()),
}
}

Expand All @@ -47,7 +47,7 @@ impl WhaleContract {
self.token.ft_balance_of(owner_id)
}

pub fn mint_whale(&mut self, receiver_id: AccountId, amount: U128) {
pub fn mint_pophin(&mut self, receiver_id: AccountId, amount: U128) {
// before minting validate with lightclient
self.validate_with_lightclient();

Expand All @@ -62,12 +62,12 @@ impl WhaleContract {
events::FtMint {
owner_id: &receiver_id,
amount: &amount,
memo: Some("PDAO Whale token newly minted"),
memo: Some("PDAO Pophin token newly minted"),
}
.emit()
}

pub fn transfer_whale(&mut self, receiver_id: AccountId, amount: U128, memo: Option<String>) {
pub fn transfer_pophin(&mut self, receiver_id: AccountId, amount: U128, memo: Option<String>) {
// check enough amout to transfer
let owner_id = env::predecessor_account_id();
let owner_balance = self.token.ft_balance_of(owner_id);
Expand All @@ -80,7 +80,7 @@ impl WhaleContract {
}

#[payable]
pub fn transfer_whale_call(
pub fn transfer_pophin_call(
&mut self,
receiver_id: AccountId,
amount: U128,
Expand Down Expand Up @@ -115,20 +115,20 @@ impl WhaleContract {
events::FtBurn {
owner_id: &account_id,
amount: &amount,
memo: Some("PDAO Whale token burned"),
memo: Some("PDAO Pophin token burned"),
}
.emit()
}
}

impl WhaleContract {
impl PophinContract {
fn validate_with_lightclient(&self) {
// todo
}
}

#[near_bindgen]
impl FungibleTokenMetadataProvider for WhaleContract {
impl FungibleTokenMetadataProvider for PophinContract {
fn ft_metadata(&self) -> FungibleTokenMetadata {
FungibleTokenMetadata {
spec: "ft-1.0.0".to_string(),
Expand Down Expand Up @@ -163,57 +163,57 @@ mod tests {
fn test_default() {
let context = get_context(accounts(1));
testing_env!(context.build());
let _contract = WhaleContract::default();
let _contract = PophinContract::default();
}

#[test]
fn get_total_supply() {
let mut context = VMContextBuilder::new();
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.attached_deposit(125 * env::storage_byte_cost())
.build());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
assert_eq!(contract.query_total_supply(), 1_000_000.into());
}

#[test]
fn get_balance() {
let mut context = get_context(accounts(0));
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.attached_deposit(125 * env::storage_byte_cost())
.build());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
assert_eq!(contract.query_balance(), 1_000_000.into());
}

#[test]
fn mint_token() {
let mut context = VMContextBuilder::new();
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.attached_deposit(125 * env::storage_byte_cost())
.build());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
assert_eq!(contract.ft_balance_of(accounts(0)), 1_000_000.into());
}

#[test]
fn transfer_token() {
let mut context = get_context(accounts(2));
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.storage_usage(env::storage_usage())
.attached_deposit(contract.storage_balance_bounds().min.into())
.predecessor_account_id(accounts(1))
.build());

contract.mint_whale(accounts(2), 1_000_000.into());
contract.mint_pophin(accounts(2), 1_000_000.into());

// Paying for account registration, aka storage deposit
contract.storage_deposit(None, None);
Expand Down Expand Up @@ -243,11 +243,11 @@ mod tests {
fn burn_token() {
let mut context = VMContextBuilder::new();
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.attached_deposit(125 * env::storage_byte_cost())
.build());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
assert_eq!(contract.query_total_supply(), 1_000_000.into());

contract.burn(accounts(0), 500_000.into());
Expand All @@ -261,12 +261,12 @@ mod tests {
fn mint_twice() {
let mut context = VMContextBuilder::new();
testing_env!(context.build());
let mut contract = WhaleContract::new();
let mut contract = PophinContract::new();
testing_env!(context
.attached_deposit(125 * env::storage_byte_cost())
.build());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_whale(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
contract.mint_pophin(accounts(0), 1_000_000.into());
assert_eq!(contract.ft_balance_of(accounts(0)), 2_000_000.into());
}
}

0 comments on commit b0df086

Please sign in to comment.