-
Notifications
You must be signed in to change notification settings - Fork 575
Expand file tree
/
Copy pathtoken-extension.ts
More file actions
277 lines (274 loc) · 11.1 KB
/
token-extension.ts
File metadata and controls
277 lines (274 loc) · 11.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
import { ParsedTokenExtension } from '@/app/components/account/types';
import { TokenExtensionType } from '@/app/validators/accounts/token-extension';
function populateSolanaDevelopersLink(component: string) {
return `https://solana.com/developers/guides/token-extensions/${component}`;
}
export function populatePartialParsedTokenExtension(
extension: TokenExtensionType
): Omit<ParsedTokenExtension, 'parsed' | 'extension'> {
function populateExternalLinks(url: string) {
return [{ label: 'Docs', url }];
}
switch (extension) {
case 'transferFeeAmount': {
const description =
"Every transfer sets aside a fee in the recipient's Token Account that can only be withdrawn by the Withdraw Authority";
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('transfer-fee')),
name: 'Transfer Fee Amount',
status: 'active',
tooltip: description,
};
}
case 'mintCloseAuthority': {
const description = 'Allows a designated Close Authority to close the mint account if the supply is 0';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('mint-close-authority')),
name: 'Mint Close Authority',
status: 'active',
tooltip: description,
};
}
case 'defaultAccountState': {
const description = 'Enables the authority to make new token accounts as frozen by default upon creation';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('default-account-state')),
name: 'Default Account State',
status: 'active',
tooltip: description,
};
}
case 'immutableOwner': {
const description = 'Prevents the owner from being changed';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('immutable-owner')),
name: 'Immutable Owner',
status: 'active',
tooltip: description,
};
}
case 'memoTransfer': {
const description = 'Requires all incoming transfers to a token account include a memo';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('required-memo')),
name: 'Required Memo',
status: 'active',
tooltip: description,
};
}
case 'nonTransferable': {
return {
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('non-transferable-token')),
name: 'Non-Transferable Token',
status: 'active',
};
}
case 'nonTransferableAccount': {
return {
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('non-transferable-token')),
name: 'Non-Transferable Token Account',
status: 'active',
};
}
case 'cpiGuard': {
const description = 'Prohibits certain actions inside cross-program invocations';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('cpi-guard')),
name: 'CPI Guard',
status: 'active',
tooltip: description,
};
}
case 'permanentDelegate': {
const description =
'Delegates permanent authority to a specific address that can transfer or burn tokens from any account holding this token';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('permanent-delegate')),
name: 'Permanent Delegate',
status: 'active',
tooltip: description,
};
}
case 'transferHook': {
const description = 'Allow the token program to execute custom instruction logic on every token transfer';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('transfer-hook')),
name: 'Transfer Hook',
status: 'active',
tooltip: description,
};
}
case 'transferHookAccount': {
return {
description: "This is only set to 'transferring' inside the transferHook CPI",
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('transfer-hook')),
name: 'Transfer Hook Account Info',
status: 'active',
};
}
case 'metadataPointer': {
const description = 'Describes the location of the token metadata';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('metadata-pointer')),
name: 'Metadata Pointer',
status: 'active',
tooltip: description,
};
}
case 'groupPointer': {
return {
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('group-member')),
name: 'Group Pointer',
status: 'active',
};
}
case 'groupMemberPointer': {
return {
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('group-member')),
name: 'Group Member Pointer',
status: 'active',
};
}
case 'confidentialTransferAccount': {
const description = 'Token amount is only able to be unencrypted by the token holder or auditor key';
return {
description,
externalLinks: populateExternalLinks('https://spl.solana.com/confidential-token/quickstart'),
name: 'Confidential Transfer Token Info',
status: 'active',
tooltip: description,
};
}
case 'confidentialTransferFeeConfig': {
return {
externalLinks: populateExternalLinks('https://spl.solana.com/confidential-token/quickstart'),
name: 'Confidential Transfer Fee Config',
status: 'active',
};
}
case 'confidentialTransferFeeAmount': {
return {
externalLinks: populateExternalLinks('https://spl.solana.com/confidential-token/quickstart'),
name: 'Confidential Transfer Fee Amount',
status: 'active',
};
}
case 'confidentialTransferMint': {
const description =
'Allow token holders to opt-in to encrypted balances that are accessible only to them and the auditor';
return {
description,
externalLinks: populateExternalLinks('https://spl.solana.com/confidential-token/quickstart'),
name: 'Confidential Transfer',
status: 'active',
tooltip: description,
};
}
case 'confidentialMintBurn': {
const description =
'Allow token issuers to opt in to encrypted mint and burn operations, along with encrypted total supply';
return {
description,
externalLinks: populateExternalLinks('https://spl.solana.com/confidential-token/quickstart'),
name: 'Confidential Mint/Burn',
status: 'active',
tooltip: description,
};
}
case 'interestBearingConfig': {
const description = 'Allows the token balance to be displayed with accumulated interest';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('interest-bearing-token')),
name: 'Interest Bearing Token Configuration',
status: 'active',
tooltip: description,
};
}
case 'transferFeeConfig': {
const description =
'Allows a fee to be set aside on every transfer that can only be withdrawn by the Withdraw Authority';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('transfer-fee')),
name: 'Transfer Fee',
status: 'active',
tooltip: description,
};
}
case 'tokenGroup': {
return {
externalLinks: [],
name: 'Token Group',
status: 'active',
};
}
case 'tokenGroupMember': {
return {
externalLinks: [],
name: 'Token Group Member',
status: 'active',
};
}
case 'tokenMetadata': {
const description = 'Allows metadata to be written directly to the mint account';
return {
description,
externalLinks: populateExternalLinks(populateSolanaDevelopersLink('metadata-pointer')),
name: 'Token Metadata',
status: 'active',
tooltip: description,
};
}
case 'scaledUiAmountConfig': {
const description =
'Allows the token program to scale the UI amount of the token by an updatable multiplier';
return {
description,
externalLinks: [{ label: 'Docs', url: 'https://solana.com/docs/tokens/extensions/scaled-ui-amount' }],
name: 'Scaled UI Amount',
status: 'active',
tooltip: description,
};
}
case 'pausableAccount': {
return {
externalLinks: [
{ label: 'Docs', url: 'https://www.solana-program.com/docs/token-2022/extensions#pausable' },
],
name: 'Pausable Account',
status: 'active',
tooltip: 'This account can be paused by the Pausable extension',
};
}
case 'pausableConfig': {
const description =
'Allows the token program to pause all interactions including transfers, mints, and burns';
return {
description,
externalLinks: [
{ label: 'Docs', url: 'https://www.solana-program.com/docs/token-2022/extensions#pausable' },
],
name: 'Pausable',
status: 'active',
tooltip: description,
};
}
case 'unparseableExtension':
default:
return {
externalLinks: [],
name: 'Unknown Extension',
status: 'active',
};
}
}