Skip to content

Commit

Permalink
rust compiler errors fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matt5346 committed Mar 13, 2022
1 parent 2902764 commit d116a42
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 30 deletions.
2 changes: 1 addition & 1 deletion crypto/near/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"build": "bash build.sh",
"deploy": "bash deploy.sh"
}
}
}
22 changes: 10 additions & 12 deletions crypto/near/src/bundle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use near_sdk::collections::Vector;
use crate::*;

#[near_bindgen]
Expand All @@ -11,8 +10,8 @@ impl Contract {
receiver_id: AccountId,
//we add an optional parameter for perpetual royalties
perpetual_royalties: Option<HashMap<AccountId, u32>>,
bundles: Option<Vector<TokenId>>,
transferOwnership: bool,
bundles: Vec<TokenId>,
transfer_ownership: bool,
) {
//measure the initial storage being used on the contract
let initial_storage_usage = env::storage_usage();
Expand Down Expand Up @@ -42,17 +41,16 @@ impl Contract {
//the map of perpetual royalties for the token (The owner will get 100% - total perpetual royalties)
royalty,
bundles,
isOwned: true,
is_owned: true,
};

for bundle in bundles {
//check ownerships
if transferOwnership {

bundle::nft_transfer(receiver_id, bundle.token_id);
bundle.isOwned = true;
}
}
// for bundle in bundles {
// //check ownerships
// if transfer_ownership {
// bundle::nft_transfer(receiver_id, bundle.token_id);
// bundle.is_owned = true;
// }
// }

//insert the token ID and token struct and make sure that the token doesn't exist
assert!(
Expand Down
4 changes: 2 additions & 2 deletions crypto/near/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ impl Contract {
next_approval_id: token.next_approval_id,
//we copy over the royalties from the previous token
royalty: token.royalty.clone(),
bundles: None,
isOwned: false
bundles: Vec::new(),
is_owned: false
};
//insert that new token into the tokens_by_id, replacing the old entry
self.tokens_by_id.insert(token_id, &new_token);
Expand Down
3 changes: 1 addition & 2 deletions crypto/near/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::{LazyOption, LookupMap, UnorderedMap, UnorderedSet};
use near_sdk::json_types::{Base64VecU8, U128};
use near_sdk::serde::{Deserialize, Serialize};
use serde_derive::{Serialize, Deserialize};
use near_sdk::{
env, near_bindgen, AccountId, Balance, CryptoHash, PanicOnDefault, Promise, PromiseOrValue
};
Expand Down Expand Up @@ -81,7 +80,7 @@ impl Contract {
name: "DoNFT Contract".to_string(),
symbol: "DONFT".to_string(),
icon: None,
base_uri: None,
base_uri: Some(String::from("donft.io")),
reference: None,
reference_hash: None,
},
Expand Down
10 changes: 4 additions & 6 deletions crypto/near/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use near_sdk::collections::Vector;
use serde_derive::{Serialize, Deserialize};
use crate::*;

pub type TokenId = String;
Expand Down Expand Up @@ -50,9 +48,9 @@ pub struct Token {
//keep track of the royalty percentages for the token in a hash map
pub royalty: HashMap<AccountId, u32>,
//set of tokens bundeled in this token
pub bundles: Option<Vector<Token>>,
pub bundles: Vec<TokenId>,
//flag which showed is token transfered to smart contract or not
pub isOwned: bool,
pub is_owned: bool,
}

//The Json token is what will be returned from view calls.
Expand All @@ -70,9 +68,9 @@ pub struct JsonToken {
//keep track of the royalty percentages for the token in a hash map
pub royalty: HashMap<AccountId, u32>,
//set of tokens bundeled in this token
pub bundles: Option<Vector<Token>>,
pub bundles: Vec<TokenId>,
//flag which showed is token transfered to smart contract or not
pub isOwned: bool,
pub is_owned: bool,
}

pub trait NonFungibleTokenMetadata {
Expand Down
5 changes: 2 additions & 3 deletions crypto/near/src/mint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use serde_derive::{Serialize, Deserialize};
use crate::*;

#[near_bindgen]
Expand Down Expand Up @@ -39,8 +38,8 @@ impl Contract {
next_approval_id: 0,
//the map of perpetual royalties for the token (The owner will get 100% - total perpetual royalties)
royalty,
bundles: None,
isOwned: true,
bundles: Vec::new(),
is_owned: true,
};

//insert the token ID and token struct and make sure that the token doesn't exist
Expand Down
4 changes: 2 additions & 2 deletions crypto/near/src/nft_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ impl NonFungibleTokenCore for Contract {
metadata,
approved_account_ids: token.approved_account_ids,
royalty: token.royalty,
bundles: None,
isOwned: true
bundles: Vec::new(),
is_owned: true
})
} else { //if there wasn't a token ID in the tokens_by_id collection, we return None
None
Expand Down
4 changes: 2 additions & 2 deletions crypto/near/src/unbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ impl Contract {
next_approval_id: 0,
//the map of perpetual royalties for the token (The owner will get 100% - total perpetual royalties)
royalty,
bundles
bundles,
};

for (int i = 0; i < bundles.len(); i++) {
//check ownerships
if(transferOwnership) {
if transfer_ownership {
bundles[i].
}
}
Expand Down

0 comments on commit d116a42

Please sign in to comment.