Skip to content

Commit d1d6581

Browse files
feat(sdk-coin-sol): token 2022 transfer hook implementation
transfer hook implementation for tbill, passing hookProgramId and authority Ticket: WIN-7258
1 parent dae78c4 commit d1d6581

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

modules/sdk-coin-sol/src/lib/solInstructionFactory.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,21 @@ function tokenTransferInstruction(data: TokenTransfer): TransactionInstruction[]
212212
// Check if this token has a transfer hook configuration
213213
const tokenConfig = getToken2022Config(tokenAddress);
214214
if (tokenConfig?.transferHook) {
215+
const hookProgramId = new PublicKey(tokenConfig.transferHook.programId);
216+
const hookAuthority = new PublicKey(tokenConfig.transferHook.authority);
217+
transferInstruction = createTransferCheckedInstruction(
218+
new PublicKey(sourceAddress),
219+
new PublicKey(tokenAddress),
220+
new PublicKey(toAddress),
221+
new PublicKey(fromAddress),
222+
BigInt(amount),
223+
decimalPlaces,
224+
[
225+
{ pubkey: hookProgramId, isSigner: false, isWritable: false },
226+
{ pubkey: hookAuthority, isSigner: false, isWritable: false },
227+
],
228+
TOKEN_2022_PROGRAM_ID
229+
);
215230
addTransferHookAccounts(transferInstruction, tokenConfig.transferHook);
216231
}
217232
} else {

0 commit comments

Comments
 (0)