Skip to content

Commit

Permalink
rename function name.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckshitij committed Jun 6, 2024
1 parent f50d777 commit 43abccf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
28 changes: 10 additions & 18 deletions near-accounts/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,14 @@ impl Account {
) -> Result<FinalExecutionOutcomeView, Box<dyn std::error::Error>> {
let mut actions = ActionBuilder::new();
actions
.set_create_account()
.set_transfer(amount)
.set_add_key(public_key.clone(), full_access_key());
.create_account()
.transfer(amount)
.add_key(public_key.clone(), full_access_key());

let signed_txn = self
.build_signed_transaction(TransactionRequest::new(
new_account_id.clone(),
actions.clone_builder(),
actions.build(),
))
.await?;
// Use TransactionBuilder to construct the transaction
Expand Down Expand Up @@ -333,9 +333,7 @@ impl Account {
let signed_tx = self
.build_signed_transaction(TransactionRequest::new(
self.account_id.clone(),
ActionBuilder::new()
.set_add_key(public_key, access_key)
.clone_builder(),
ActionBuilder::new().add_key(public_key, access_key).build(),
))
.await?; // Sign the transaction

Expand Down Expand Up @@ -363,9 +361,7 @@ impl Account {
let signed_tx = self
.build_signed_transaction(TransactionRequest::new(
self.account_id.clone(),
ActionBuilder::new()
.set_delete_key(public_key)
.clone_builder(),
ActionBuilder::new().delete_key(public_key).build(),
))
.await?; // Sign the transaction

Expand Down Expand Up @@ -393,9 +389,7 @@ impl Account {
let signed_tx = self
.build_signed_transaction(TransactionRequest::new(
self.account_id.clone(),
ActionBuilder::new()
.set_deploy_contract(byte_code)
.clone_builder(),
ActionBuilder::new().deploy_contract(byte_code).build(),
))
.await?; // Sign the transaction

Expand Down Expand Up @@ -423,9 +417,7 @@ impl Account {
let signed_tx = self
.build_signed_transaction(TransactionRequest::new(
self.account_id.clone(),
ActionBuilder::new()
.set_delete_account(beneficiary_id)
.clone_builder(),
ActionBuilder::new().delete_account(beneficiary_id).build(),
))
.await?; // Sign the transaction

Expand Down Expand Up @@ -456,7 +448,7 @@ impl Account {
let signed_tx = self
.build_signed_transaction(TransactionRequest::new(
receiver_id.clone(),
ActionBuilder::new().set_transfer(amount).clone_builder(),
ActionBuilder::new().transfer(amount).build(),
))
.await?; // Sign the transaction

Expand Down Expand Up @@ -497,7 +489,7 @@ impl Account {
contract_id.clone(),
ActionBuilder::new()
.function_call(method_name, args, gas, deposit)
.clone_builder(),
.build(),
))
.await?; // Sign the transaction

Expand Down
16 changes: 8 additions & 8 deletions near-transactions/src/action_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ impl ActionBuilder {
}

// Methods to add various actions to the builder
pub fn set_create_account(&mut self) -> &mut Self {
pub fn create_account(&mut self) -> &mut Self {
self.actions
.push(Action::CreateAccount(CreateAccountAction {}));
self
}

pub fn set_deploy_contract(&mut self, code: &[u8]) -> &mut Self {
pub fn deploy_contract(&mut self, code: &[u8]) -> &mut Self {
self.actions
.push(Action::DeployContract(DeployContractAction {
code: code.to_vec(),
Expand All @@ -75,33 +75,33 @@ impl ActionBuilder {
self
}

pub fn set_transfer(&mut self, deposit: Balance) -> &mut Self {
pub fn transfer(&mut self, deposit: Balance) -> &mut Self {
self.actions
.push(Action::Transfer(TransferAction { deposit }));
self
}

pub fn set_stake(&mut self, stake: Balance, public_key: PublicKey) -> &mut Self {
pub fn stake(&mut self, stake: Balance, public_key: PublicKey) -> &mut Self {
self.actions
.push(Action::Stake(Box::new(StakeAction { stake, public_key })));
self
}

pub fn set_add_key(&mut self, public_key: PublicKey, access_key: AccessKey) -> &mut Self {
pub fn add_key(&mut self, public_key: PublicKey, access_key: AccessKey) -> &mut Self {
self.actions.push(Action::AddKey(Box::new(AddKeyAction {
public_key,
access_key,
})));
self
}

pub fn set_delete_key(&mut self, public_key: PublicKey) -> &mut Self {
pub fn delete_key(&mut self, public_key: PublicKey) -> &mut Self {
self.actions
.push(Action::DeleteKey(Box::new(DeleteKeyAction { public_key })));
self
}

pub fn set_delete_account(&mut self, beneficiary_id: AccountId) -> &mut Self {
pub fn delete_account(&mut self, beneficiary_id: AccountId) -> &mut Self {
self.actions
.push(Action::DeleteAccount(DeleteAccountAction {
beneficiary_id,
Expand All @@ -110,7 +110,7 @@ impl ActionBuilder {
}

// Build method to finalize and retrieve the actions
pub fn clone_builder(&self) -> Vec<Action> {
pub fn build(&self) -> Vec<Action> {
self.clone().actions
}
}

0 comments on commit 43abccf

Please sign in to comment.