1
1
import { struct , u16 , u8 } from '@solana/buffer-layout' ;
2
- import { publicKey , u64 } from '@solana/buffer-layout-utils' ;
3
- import type { AccountMeta , Signer } from '@solana/web3.js' ;
4
- import { PublicKey , TransactionInstruction } from '@solana/web3.js' ;
2
+ import { u64 } from '@solana/buffer-layout-utils' ;
3
+ import type { AccountMeta , Signer , PublicKey } from '@solana/web3.js' ;
4
+ import { TransactionInstruction } from '@solana/web3.js' ;
5
5
import { programSupportsExtensions , TOKEN_2022_PROGRAM_ID } from '../../constants.js' ;
6
6
import {
7
7
TokenInvalidInstructionDataError ,
@@ -12,6 +12,7 @@ import {
12
12
} from '../../errors.js' ;
13
13
import { addSigners } from '../../instructions/internal.js' ;
14
14
import { TokenInstruction } from '../../instructions/types.js' ;
15
+ import { COptionPublicKeyLayout } from '../../serialization.js' ;
15
16
16
17
export enum TransferFeeInstruction {
17
18
InitializeTransferFeeConfig = 0 ,
@@ -28,10 +29,8 @@ export enum TransferFeeInstruction {
28
29
export interface InitializeTransferFeeConfigInstructionData {
29
30
instruction : TokenInstruction . TransferFeeExtension ;
30
31
transferFeeInstruction : TransferFeeInstruction . InitializeTransferFeeConfig ;
31
- transferFeeConfigAuthorityOption : 1 | 0 ;
32
- transferFeeConfigAuthority : PublicKey ;
33
- withdrawWithheldAuthorityOption : 1 | 0 ;
34
- withdrawWithheldAuthority : PublicKey ;
32
+ transferFeeConfigAuthority : PublicKey | null ;
33
+ withdrawWithheldAuthority : PublicKey | null ;
35
34
transferFeeBasisPoints : number ;
36
35
maximumFee : bigint ;
37
36
}
@@ -40,10 +39,8 @@ export interface InitializeTransferFeeConfigInstructionData {
40
39
export const initializeTransferFeeConfigInstructionData = struct < InitializeTransferFeeConfigInstructionData > ( [
41
40
u8 ( 'instruction' ) ,
42
41
u8 ( 'transferFeeInstruction' ) ,
43
- u8 ( 'transferFeeConfigAuthorityOption' ) ,
44
- publicKey ( 'transferFeeConfigAuthority' ) ,
45
- u8 ( 'withdrawWithheldAuthorityOption' ) ,
46
- publicKey ( 'withdrawWithheldAuthority' ) ,
42
+ new COptionPublicKeyLayout ( 'transferFeeConfigAuthority' ) ,
43
+ new COptionPublicKeyLayout ( 'withdrawWithheldAuthority' ) ,
47
44
u16 ( 'transferFeeBasisPoints' ) ,
48
45
u64 ( 'maximumFee' ) ,
49
46
] ) ;
@@ -78,10 +75,8 @@ export function createInitializeTransferFeeConfigInstruction(
78
75
{
79
76
instruction : TokenInstruction . TransferFeeExtension ,
80
77
transferFeeInstruction : TransferFeeInstruction . InitializeTransferFeeConfig ,
81
- transferFeeConfigAuthorityOption : transferFeeConfigAuthority ? 1 : 0 ,
82
- transferFeeConfigAuthority : transferFeeConfigAuthority || new PublicKey ( 0 ) ,
83
- withdrawWithheldAuthorityOption : withdrawWithheldAuthority ? 1 : 0 ,
84
- withdrawWithheldAuthority : withdrawWithheldAuthority || new PublicKey ( 0 ) ,
78
+ transferFeeConfigAuthority : transferFeeConfigAuthority ,
79
+ withdrawWithheldAuthority : withdrawWithheldAuthority ,
85
80
transferFeeBasisPoints : transferFeeBasisPoints ,
86
81
maximumFee : maximumFee ,
87
82
} ,
@@ -174,9 +169,7 @@ export function decodeInitializeTransferFeeConfigInstructionUnchecked({
174
169
const {
175
170
instruction,
176
171
transferFeeInstruction,
177
- transferFeeConfigAuthorityOption,
178
172
transferFeeConfigAuthority,
179
- withdrawWithheldAuthorityOption,
180
173
withdrawWithheldAuthority,
181
174
transferFeeBasisPoints,
182
175
maximumFee,
@@ -190,8 +183,8 @@ export function decodeInitializeTransferFeeConfigInstructionUnchecked({
190
183
data : {
191
184
instruction,
192
185
transferFeeInstruction,
193
- transferFeeConfigAuthority : transferFeeConfigAuthorityOption ? transferFeeConfigAuthority : null ,
194
- withdrawWithheldAuthority : withdrawWithheldAuthorityOption ? withdrawWithheldAuthority : null ,
186
+ transferFeeConfigAuthority,
187
+ withdrawWithheldAuthority,
195
188
transferFeeBasisPoints,
196
189
maximumFee,
197
190
} ,
0 commit comments