Skip to content

Commit d752c7c

Browse files
authored
refactor: removed prelude and filtered entries. (#29)
* refactor: removed prelude and filtered entries. * disabled fast-near for now * renamed Tokens::of to Tokens::acount
1 parent 1ad1db1 commit d752c7c

17 files changed

+128
-136
lines changed

examples/account_key_pooling.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
///
44
/// This is an example of how to use account key pooling to send multiple transactions
55
/// using different keys.
6-
use near_api::prelude::*;
6+
use near_api::*;
77
use near_token::NearToken;
8+
use signer::generate_secret_key;
89

910
use std::sync::Arc;
1011

@@ -42,7 +43,7 @@ async fn main() {
4243
.unwrap();
4344

4445
let txs = (0..2).map(|_| {
45-
Tokens::of(account.id().clone())
46+
Tokens::account(account.id().clone())
4647
.send_to(second_account.id().clone())
4748
.near(NearToken::from_near(1))
4849
.with_signer(Arc::clone(&signer))

examples/create_account_and_send_near.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use near_account_id::AccountId;
2-
use near_api::prelude::*;
1+
use near_api::*;
32

43
use near_token::NearToken;
4+
use signer::generate_secret_key;
55

66
#[tokio::main]
77
async fn main() {
88
let network = near_workspaces::sandbox().await.unwrap();
99
let account = network.dev_create_account().await.unwrap();
1010
let network = NetworkConfig::from(network);
1111

12-
let balance = Tokens::of(account.id().clone())
12+
let balance = Tokens::account(account.id().clone())
1313
.near_balance()
1414
.fetch_from(&network)
1515
.await
@@ -29,20 +29,20 @@ async fn main() {
2929
.await
3030
.unwrap();
3131

32-
Tokens::of(account.id().clone())
32+
Tokens::account(account.id().clone())
3333
.send_to(new_account.clone())
3434
.near(NearToken::from_near(1))
3535
.with_signer(signer)
3636
.send_to(&network)
3737
.await
3838
.unwrap();
3939

40-
let new_acccount_balance = Tokens::of(account.id().clone())
40+
let new_acccount_balance = Tokens::account(account.id().clone())
4141
.near_balance()
4242
.fetch_from(&network)
4343
.await
4444
.unwrap();
45-
let bob_balance = Tokens::of(new_account)
45+
let bob_balance = Tokens::account(new_account)
4646
.near_balance()
4747
.fetch_from(&network)
4848
.await

examples/deploy_and_call_method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use near_api::{prelude::*, types::Data};
1+
use near_api::*;
22

33
#[tokio::main]
44
async fn main() {

examples/ft.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use near_api::prelude::*;
1+
use near_api::*;
22

33
use serde_json::json;
44

@@ -29,7 +29,7 @@ async fn main() {
2929
.unwrap();
3030

3131
// Verifying that user has 1000 tokens
32-
let tokens = Tokens::of(token.id().clone())
32+
let tokens = Tokens::account(token.id().clone())
3333
.ft_balance(token.id().clone())
3434
.unwrap()
3535
.fetch_from(&network)
@@ -40,7 +40,7 @@ async fn main() {
4040

4141
// Transfer 100 tokens to the account
4242
// We handle internally the storage deposit for the receiver account
43-
Tokens::of(token.id().clone())
43+
Tokens::account(token.id().clone())
4444
.send_to(account.id().clone())
4545
.ft(
4646
token.id().clone(),
@@ -54,7 +54,7 @@ async fn main() {
5454
.unwrap()
5555
.assert_success();
5656

57-
let tokens = Tokens::of(account.id().clone())
57+
let tokens = Tokens::account(account.id().clone())
5858
.ft_balance(token.id().clone())
5959
.unwrap()
6060
.fetch_from(&network)
@@ -63,7 +63,7 @@ async fn main() {
6363

6464
println!("Account has {}", tokens);
6565

66-
let tokens = Tokens::of(token.id().clone())
66+
let tokens = Tokens::account(token.id().clone())
6767
.ft_balance(token.id().clone())
6868
.unwrap()
6969
.fetch_from(&network)
@@ -73,7 +73,7 @@ async fn main() {
7373
println!("Owner has {}", tokens);
7474

7575
// We validate decimals at the network level so this should fail with a validation error
76-
let token = Tokens::of(token.id().clone())
76+
let token = Tokens::account(token.id().clone())
7777
.send_to(account.id().clone())
7878
.ft(
7979
token.id().clone(),

examples/nft.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use near_api::prelude::*;
1+
use near_api::*;
22

33
use near_contract_standards::non_fungible_token::metadata::TokenMetadata;
4-
use near_token::NearToken;
54
use serde_json::json;
65

76
#[tokio::main]
@@ -55,7 +54,7 @@ async fn main() {
5554
.unwrap();
5655

5756
// Verifying that account has our nft token
58-
let tokens = Tokens::of(account.id().clone())
57+
let tokens = Tokens::account(account.id().clone())
5958
.nft_assets(nft.id().clone())
6059
.unwrap()
6160
.fetch_from(&network)
@@ -65,7 +64,7 @@ async fn main() {
6564
assert_eq!(tokens.data.len(), 1);
6665
println!("Account has {}", tokens.data.first().unwrap().token_id);
6766

68-
Tokens::of(account.id().clone())
67+
Tokens::account(account.id().clone())
6968
.send_to(nft.id().clone())
7069
.nft(nft.id().clone(), "1".to_string())
7170
.unwrap()
@@ -75,7 +74,7 @@ async fn main() {
7574
.unwrap();
7675

7776
// Verifying that account doesn't have nft anymore
78-
let tokens = Tokens::of(account.id().clone())
77+
let tokens = Tokens::account(account.id().clone())
7978
.nft_assets(nft.id().clone())
8079
.unwrap()
8180
.fetch_from(&network)
@@ -84,7 +83,7 @@ async fn main() {
8483

8584
assert!(tokens.data.is_empty());
8685

87-
let tokens = Tokens::of(nft.id().clone())
86+
let tokens = Tokens::account(nft.id().clone())
8887
.nft_assets(nft.id().clone())
8988
.unwrap()
9089
.fetch_from(&network)

examples/sign_options.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use near_api::prelude::*;
1+
use near_api::*;
22
use near_crypto::SecretKey;
33
use near_primitives::account::AccessKeyPermission;
4+
use signer::generate_seed_phrase;
45

56
#[tokio::main]
67
async fn main() {

examples/specify_backup_rpc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use near_api::{prelude::*, types::reference::Reference};
1+
use near_api::*;
22

33
#[tokio::main]
44
async fn main() {

examples/specifying_block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use near_api::{prelude::*, types::reference::Reference};
1+
use near_api::*;
22

33
#[tokio::main]
44
async fn main() {

src/account/create.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use url::Url;
1111
use crate::{
1212
common::send::Transactionable,
1313
errors::{AccountCreationError, FaucetError, ValidationError},
14-
prelude::*,
1514
transactions::{ConstructTransaction, TransactionWithSign},
1615
types::transactions::PrepopulateTransaction,
16+
Contract, NetworkConfig,
1717
};
1818

1919
#[derive(Clone, Debug)]

src/common/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use near_primitives::types::BlockHeight;
33
const META_TRANSACTION_VALID_FOR_DEFAULT: BlockHeight = 1000;
44

55
pub mod query;
6-
pub mod secret;
76
pub mod send;
87
pub mod signed_delegate_action;
98
pub mod utils;

src/common/secret.rs

-70
This file was deleted.

src/lib.rs

+22-24
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,33 @@ mod stake;
66
mod storage;
77
mod tokens;
88
mod transactions;
9+
// TODO: to be honest, there is almost nothing in this file
10+
// we should maybe intergrate with them more tightly
11+
// for now, i comment it out
12+
// mod fastnear;
913

1014
mod common;
11-
mod fastnear;
1215

1316
pub mod errors;
1417
pub mod signer;
1518
pub mod types;
1619

17-
pub mod prelude {
18-
pub use crate::{
19-
account::Account,
20-
chain::Chain,
21-
common::secret::*,
22-
config::{retry, NetworkConfig, RPCEndpoint, RetryResponse},
23-
contract::Contract,
24-
fastnear::FastNear,
25-
signer::{Signer, SignerTrait},
26-
stake::Delegation,
27-
stake::Staking,
28-
storage::StorageDeposit,
29-
tokens::Tokens,
30-
transactions::Transaction,
31-
types::{
32-
reference::{EpochReference, Reference},
33-
tokens::{FTBalance, USDT_BALANCE, W_NEAR_BALANCE},
34-
Data,
35-
},
36-
};
20+
pub use crate::{
21+
account::Account,
22+
chain::Chain,
23+
config::{NetworkConfig, RPCEndpoint},
24+
contract::Contract,
25+
signer::{Signer, SignerTrait},
26+
stake::Staking,
27+
storage::StorageDeposit,
28+
tokens::Tokens,
29+
transactions::Transaction,
30+
types::{
31+
reference::{EpochReference, Reference},
32+
tokens::{FTBalance, USDT_BALANCE, W_NEAR_BALANCE},
33+
Data,
34+
},
35+
};
3736

38-
pub use near_account_id::AccountId;
39-
pub use near_token::NearToken;
40-
}
37+
pub use near_account_id::AccountId;
38+
pub use near_token::NearToken;

0 commit comments

Comments
 (0)