2026-04-10 20:23:25 +03:00
|
|
|
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
|
|
|
|
2025-11-30 01:57:59 +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
|
|
|
|
2025-11-30 01:57:59 +03:00
|
|
|
impl NativeTokenTransfer<'_> {
|
|
|
|
|
pub async fn send_public_transfer(
|
2025-09-22 16:38:25 +03:00
|
|
|
&self,
|
2025-11-24 17:09:30 +03:00
|
|
|
from: AccountId,
|
|
|
|
|
to: AccountId,
|
2025-09-22 16:38:25 +03:00
|
|
|
balance_to_move: u128,
|
2026-03-13 22:38:23 +03:00
|
|
|
) -> 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-04-10 20:23:25 +03:00
|
|
|
)
|
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
|
|
|
|
2025-11-30 01:57:59 +03:00
|
|
|
pub async fn register_account(
|
2025-10-10 17:47:23 -03:00
|
|
|
&self,
|
2025-11-24 17:09:30 +03:00
|
|
|
from: AccountId,
|
2026-03-13 22:38:23 +03:00
|
|
|
) -> 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
|
|
|
}
|