Skip to content

Commit fd9bd9f

Browse files
committed
Run zig fmt
1 parent 9668b14 commit fd9bd9f

File tree

3 files changed

+46
-46
lines changed

3 files changed

+46
-46
lines changed

token/zig/src/instruction.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ pub fn IxOption(T: type) type {
5454
}
5555
}
5656
pub fn fromValue(value: T) Self {
57-
return Self {
57+
return Self{
5858
.is_some = 1,
5959
.value = value,
6060
};
6161
}
6262
pub fn fromNull() Self {
63-
return Self {
63+
return Self{
6464
.is_some = 0,
6565
.value = std.mem.zeroes(T),
6666
};
@@ -73,7 +73,7 @@ pub fn IxOption(T: type) type {
7373
}
7474
}
7575
pub fn toCOption(self: Self) COption(T) {
76-
return COption(T) {
76+
return COption(T){
7777
.is_some = self.is_some,
7878
.value = self.value,
7979
};
@@ -92,7 +92,7 @@ pub const InitializeMintData = packed struct {
9292

9393
pub const AmountData = packed struct {
9494
/// The amount of tokens to process.
95-
amount: u64
95+
amount: u64,
9696
};
9797

9898
pub const Instruction = union(InstructionDiscriminant) {

token/zig/src/main.zig

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -316,27 +316,27 @@ fn processInstruction(program_id: *align(1) PublicKey, accounts: []sol.Account,
316316
//}
317317

318318
//if !source_account.is_owned_by_system_program_or_incinerator() {
319-
//match source_account.delegate {
320-
//COption::Some(ref delegate) if Self::cmp_pubkeys(authority_info.key, delegate) => {
321-
//Self::validate_owner(
322-
//program_id,
323-
//delegate,
324-
//authority_info,
325-
//account_info_iter.as_slice(),
326-
//)?;
327-
328-
//if source_account.delegated_amount < amount {
329-
//return Err(TokenError::InsufficientFunds.into());
330-
//}
331-
//source_account.delegated_amount = source_account
332-
//.delegated_amount
333-
//.checked_sub(amount)
334-
//.ok_or(TokenError::Overflow)?;
335-
//if source_account.delegated_amount == 0 {
336-
//source_account.delegate = COption::None;
337-
//}
338-
//}
339-
//}
319+
//match source_account.delegate {
320+
//COption::Some(ref delegate) if Self::cmp_pubkeys(authority_info.key, delegate) => {
321+
//Self::validate_owner(
322+
//program_id,
323+
//delegate,
324+
//authority_info,
325+
//account_info_iter.as_slice(),
326+
//)?;
327+
328+
//if source_account.delegated_amount < amount {
329+
//return Err(TokenError::InsufficientFunds.into());
330+
//}
331+
//source_account.delegated_amount = source_account
332+
//.delegated_amount
333+
//.checked_sub(amount)
334+
//.ok_or(TokenError::Overflow)?;
335+
//if source_account.delegated_amount == 0 {
336+
//source_account.delegate = COption::None;
337+
//}
338+
//}
339+
//}
340340
//}
341341
try validateOwner(
342342
program_id,
@@ -383,17 +383,19 @@ fn processInstruction(program_id: *align(1) PublicKey, accounts: []sol.Account,
383383
}
384384

385385
const authority = if (source.close_authority.is_some != 0)
386-
source.close_authority.value else source.owner;
386+
source.close_authority.value
387+
else
388+
source.owner;
387389

388390
//if !source_account.is_owned_by_system_program_or_incinerator() {
389-
//Self::validate_owner(
390-
//program_id,
391-
//&authority,
392-
//authority_info,
393-
//account_info_iter.as_slice(),
394-
//)?;
391+
//Self::validate_owner(
392+
//program_id,
393+
//&authority,
394+
//authority_info,
395+
//account_info_iter.as_slice(),
396+
//)?;
395397
//} else if !solana_program::incinerator::check_id(destination_account_info.key) {
396-
//return Err(ProgramError::InvalidAccountData);
398+
//return Err(ProgramError::InvalidAccountData);
397399
//}
398400

399401
try validateOwner(
@@ -465,8 +467,7 @@ fn validateOwner(
465467
if (!expected_owner.equals(owner_account.id())) {
466468
return TokenError.OwnerMismatch;
467469
}
468-
if (program_id.equals(owner_account.ownerId()) and owner_account.dataLen() == state.Multisig.len)
469-
{
470+
if (program_id.equals(owner_account.ownerId()) and owner_account.dataLen() == state.Multisig.len) {
470471
//let multisig = Multisig::unpack(&owner_account_info.data.borrow())?;
471472
//let mut num_signers = 0;
472473
//let mut matched = [false; MAX_SIGNERS];
@@ -482,7 +483,7 @@ fn validateOwner(
482483
// }
483484
//}
484485
//if num_signers < multisig.m {
485-
return TokenError.MissingRequiredSignature;
486+
return TokenError.MissingRequiredSignature;
486487
//}
487488
} else if (!owner_account.isSigner()) {
488489
return TokenError.MissingRequiredSignature;

token/zig/src/state.zig

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ pub fn COption(T: type) type {
4747
}
4848
}
4949
pub fn fromValue(value: T) Self {
50-
return Self {
50+
return Self{
5151
.is_some = 1,
5252
.value = value,
5353
};
5454
}
5555
pub fn asNull() Self {
56-
return Self {
56+
return Self{
5757
.is_some = 0,
5858
.value = std.mem.zeroes(T),
5959
};
@@ -73,36 +73,35 @@ pub const Multisig = packed struct {
7373
};
7474

7575
test "Mint: bitCast" {
76-
const mint = Mint {
76+
const mint = Mint{
7777
.authority = COption(PublicKey).fromOptional(std.mem.bytesToValue(PublicKey, &[_]u8{1} ** 32)),
7878
.supply = 42,
7979
.decimals = 7,
8080
.is_initialized = 1,
8181
.freeze_authority = COption(PublicKey).fromOptional(std.mem.bytesToValue(PublicKey, &[_]u8{2} ** 32)),
8282
};
8383
const mint_buffer = [_]u8{
84-
1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
84+
1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
8585
1, 1, 1, 1, 1, 1, 42, 0, 0, 0, 0, 0, 0, 0, 7, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
8787
};
8888
try std.testing.expectEqualSlices(u8, &mint_buffer, std.mem.asBytes(&mint)[0..82]);
8989
const cast_mint: Mint = @bitCast(mint_buffer);
9090
try std.testing.expectEqual(cast_mint, mint);
9191
}
9292

9393
test "Mint: cast with padding" {
94-
const mint = Mint {
94+
const mint = Mint{
9595
.authority = COption(PublicKey).new(std.mem.bytesToValue(PublicKey, &[_]u8{1} ** 32)),
9696
.supply = 42,
9797
.decimals = 7,
9898
.is_initialized = 1,
9999
.freeze_authority = COption(PublicKey).new(std.mem.bytesToValue(PublicKey, &[_]u8{2} ** 32)),
100100
};
101101
const mint_buffer = [_]u8{
102-
0,
103-
1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
104-
1, 1, 1, 1, 1, 1, 42, 0, 0, 0, 0, 0, 0, 0, 7, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
105-
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102+
0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
103+
1, 1, 1, 1, 1, 1, 42, 0, 0, 0, 0, 0, 0, 0, 7, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
106105
};
107106
try std.testing.expectEqualSlices(u8, mint_buffer[1..], std.mem.asBytes(&mint)[0..82]);
108107
const cast_mint: *const Mint = @alignCast(@ptrCast(mint_buffer[1..]));

0 commit comments

Comments
 (0)