46 lines
1.4 KiB
Rust
Raw Normal View History

use authenticated_transfer_core::Instruction as AuthTransferInstruction;
2026-05-18 13:44:03 +03:00
use common::HashType;
use nssa::{AccountId, program::Program};
2025-09-22 16:38:25 +03:00
use super::NativeTokenTransfer;
2026-05-18 13:44:03 +03:00
use crate::{
2026-05-20 18:55:39 +03:00
AccountIdentity, ExecutionFailureKind,
2026-05-18 13:44:03 +03:00
program_facades::native_token_transfer::auth_transfer_preparation,
};
2025-09-22 16:38:25 +03:00
impl NativeTokenTransfer<'_> {
pub async fn send_public_transfer(
2025-09-22 16:38:25 +03:00
&self,
from: AccountId,
to: AccountId,
2025-09-22 16:38:25 +03:00
balance_to_move: u128,
) -> Result<HashType, ExecutionFailureKind> {
2026-05-18 13:44:03 +03:00
let (instruction_data, program, tx_pre_check) = auth_transfer_preparation(balance_to_move);
self.0
.send_pub_tx_with_pre_check(
2026-05-20 18:55:39 +03:00
vec![AccountIdentity::Public(from), AccountIdentity::Public(to)],
2026-05-18 13:44:03 +03:00
instruction_data,
&program.into(),
tx_pre_check,
)
2026-05-18 13:44:03 +03:00
.await
2025-09-22 16:38:25 +03:00
}
2025-10-10 17:47:23 -03:00
pub async fn register_account(
2025-10-10 17:47:23 -03:00
&self,
from: AccountId,
) -> Result<HashType, ExecutionFailureKind> {
2026-05-18 13:44:03 +03:00
let instruction_data = Program::serialize_instruction(AuthTransferInstruction::Initialize)?;
let program = Program::authenticated_transfer_program();
self.0
.send_pub_tx(
2026-05-20 18:55:39 +03:00
vec![AccountIdentity::Public(from)],
2026-05-18 13:44:03 +03:00
instruction_data,
&program.into(),
)
2026-03-04 18:42:33 +03:00
.await
2025-10-10 17:47:23 -03:00
}
2025-09-22 16:38:25 +03:00
}