Skip to content

Commit 0aabda7

Browse files
Merge pull request #7199 from BitGo/WIN-7258_sol_token_tranfer_hook-1
refactor(sdk-coin-sol): token 2022 transfer hook config cleanup
2 parents 12456cf + 197afe5 commit 0aabda7

File tree

3 files changed

+5
-46
lines changed

3 files changed

+5
-46
lines changed

modules/sdk-coin-sol/src/config/token2022StaticConfig.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import type { Token2022Config } from '../lib/token2022Config';
33
export const TOKEN_2022_STATIC_CONFIGS: Token2022Config[] = [
44
{
55
mintAddress: '4MmJVdwYN8LwvbGeCowYjSx7KoEi6BJWg8XXnW4fDDp6',
6-
symbol: 'tbill',
7-
name: 'OpenEden T-Bills',
8-
decimals: 6,
9-
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
106
transferHook: {
11-
programId: '48n7YGEww7fKMfJ5gJ3sQC3rM6RWGjpUsghqVfXVkR5A',
12-
authority: 'CPNEkz5SaAcWqGMezXTti39ekErzMpDCtuPMGw9tt4CZ',
137
extraAccountMetas: [
148
{
159
pubkey: '98wFF5MpMjMQbfDF2MPzo8LCGX37unZR1ohRA1mU9GmJ',
@@ -31,13 +25,7 @@ export const TOKEN_2022_STATIC_CONFIGS: Token2022Config[] = [
3125
},
3226
{
3327
mintAddress: '3BW95VLH2za2eUQ1PGfjxwMbpsnDFnmkA7m5LDgMKbX7',
34-
symbol: 't1test',
35-
name: 'T1TEST',
36-
decimals: 6,
37-
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
3828
transferHook: {
39-
programId: '2Te6MFDwstRP2sZi6DLbkhVcSfaQVffmpbudN6pmvAXo',
40-
authority: 'BLZvvaQgPUvL2RWoJeovudbHMhqH4S3kdenN5eg1juDr',
4129
extraAccountMetas: [
4230
{
4331
pubkey: 'GbQ8ZiEFzGGTeYoXwtZtcoxwPcMyUcmZDduMVNdUPKpX',

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

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,14 @@ export interface ExtraAccountMeta {
1616
isSigner: boolean;
1717
/** Whether the account is writable */
1818
isWritable: boolean;
19-
/** Optional seed for PDA derivation */
20-
seeds?: Array<{
21-
/** Literal seed value or instruction account index reference */
22-
value: string | number;
23-
/** Type of seed: 'literal' for string/buffer, 'accountKey' for instruction account index */
24-
type: 'literal' | 'accountKey';
25-
}>;
2619
}
2720

2821
/**
2922
* Interface for transfer hook configuration
3023
*/
3124
export interface TransferHookConfig {
32-
/** The transfer hook program ID */
33-
programId: string;
34-
/** The transfer hook authority */
35-
authority: string;
3625
/** Extra account metas required by the transfer hook */
3726
extraAccountMetas: ExtraAccountMeta[];
38-
/** The PDA address for extra account metas (cached) */
39-
extraAccountMetasPDA?: string;
4027
}
4128

4229
/**
@@ -45,34 +32,18 @@ export interface TransferHookConfig {
4532
export interface Token2022Config {
4633
/** The mint address of the token */
4734
mintAddress: string;
48-
/** Token symbol */
49-
symbol: string;
50-
/** Token name */
51-
name: string;
52-
/** Number of decimal places */
53-
decimals: number;
54-
/** Program ID (TOKEN_2022_PROGRAM_ID) */
55-
programId: string;
5635
/** Transfer hook configuration if applicable */
5736
transferHook?: TransferHookConfig;
58-
/** Whether the token has transfer fees */
59-
hasTransferFees?: boolean;
6037
}
6138

6239
/**
6340
* Token configurations map
64-
* Key: mintAddress or symbol
41+
* Key: mintAddress
6542
*/
6643
export const TOKEN_2022_CONFIGS: Record<string, Token2022Config> = {};
6744

6845
TOKEN_2022_STATIC_CONFIGS.forEach((config) => {
6946
TOKEN_2022_CONFIGS[config.mintAddress] = config;
70-
TOKEN_2022_CONFIGS[config.symbol] = config;
71-
});
72-
73-
// Create symbol mappings for convenience
74-
Object.values(TOKEN_2022_CONFIGS).forEach((config) => {
75-
TOKEN_2022_CONFIGS[config.symbol] = config;
7647
});
7748

7849
/**

modules/sdk-coin-sol/test/unit/solInstructionFactory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ describe('Instruction Builder Tests: ', function () {
167167
fromAddress,
168168
toAddress,
169169
amount,
170-
tokenName: tokenConfig!.symbol,
170+
tokenName: 'tbill',
171171
sourceAddress,
172172
tokenAddress: tokenConfig!.mintAddress,
173-
decimalPlaces: tokenConfig!.decimals,
174-
programId: tokenConfig!.programId,
173+
decimalPlaces: 6,
174+
programId: TOKEN_2022_PROGRAM_ID.toString(),
175175
},
176176
};
177177

@@ -187,7 +187,7 @@ describe('Instruction Builder Tests: ', function () {
187187
new PublicKey(toAddress),
188188
new PublicKey(fromAddress),
189189
BigInt(amount),
190-
tokenConfig!.decimals,
190+
6,
191191
[],
192192
TOKEN_2022_PROGRAM_ID
193193
);

0 commit comments

Comments
 (0)