@bonfida/spl-name-service 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bindings.d.ts +1 -0
- package/dist/deprecated/utils.d.ts +1 -0
- package/dist/favorite-domain.d.ts +40 -0
- package/dist/index.cjs +1 -0
- package/dist/index.mjs +1 -0
- package/dist/instructions.d.ts +1 -0
- package/dist/int.d.ts +1 -0
- package/dist/nft.d.ts +1 -0
- package/dist/state.d.ts +1 -0
- package/dist/twitter_bindings.d.ts +1 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +41 -35
- package/dist/index.js +0 -1
- package/src/bindings.ts +0 -445
- package/src/constants.ts +0 -101
- package/src/deprecated/index.ts +0 -1
- package/src/deprecated/record.ts +0 -14
- package/src/deprecated/tokens.ts +0 -52
- package/src/deprecated/utils.ts +0 -186
- package/src/favorite-domain.ts +0 -25
- package/src/index.ts +0 -14
- package/src/instructions.ts +0 -585
- package/src/int.ts +0 -75
- package/src/nft.ts +0 -95
- package/src/record.ts +0 -256
- package/src/resolve.ts +0 -77
- package/src/state.ts +0 -163
- package/src/twitter_bindings.ts +0 -439
- package/src/types/record.ts +0 -24
- package/src/utils.ts +0 -246
package/src/bindings.ts
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Connection,
|
|
3
|
-
PublicKey,
|
|
4
|
-
SystemProgram,
|
|
5
|
-
TransactionInstruction,
|
|
6
|
-
SYSVAR_RENT_PUBKEY,
|
|
7
|
-
} from "@solana/web3.js";
|
|
8
|
-
import {
|
|
9
|
-
createInstruction,
|
|
10
|
-
deleteInstruction,
|
|
11
|
-
transferInstruction,
|
|
12
|
-
updateInstruction,
|
|
13
|
-
createReverseInstruction,
|
|
14
|
-
createInstructionV3,
|
|
15
|
-
} from "./instructions";
|
|
16
|
-
import { NameRegistryState } from "./state";
|
|
17
|
-
import { Numberu64, Numberu32 } from "./int";
|
|
18
|
-
import {
|
|
19
|
-
getHashedName,
|
|
20
|
-
getNameAccountKey,
|
|
21
|
-
getNameOwner,
|
|
22
|
-
} from "./deprecated/utils";
|
|
23
|
-
import {
|
|
24
|
-
NAME_PROGRAM_ID,
|
|
25
|
-
ROOT_DOMAIN_ACCOUNT,
|
|
26
|
-
REGISTER_PROGRAM_ID,
|
|
27
|
-
REFERRERS,
|
|
28
|
-
USDC_MINT,
|
|
29
|
-
TOKENS_SYM_MINT,
|
|
30
|
-
PYTH_MAPPING_ACC,
|
|
31
|
-
VAULT_OWNER,
|
|
32
|
-
} from "./constants";
|
|
33
|
-
import {
|
|
34
|
-
getPythProgramKeyForCluster,
|
|
35
|
-
PythHttpClient,
|
|
36
|
-
} from "@pythnetwork/client";
|
|
37
|
-
import {
|
|
38
|
-
getDomainKeySync,
|
|
39
|
-
getHashedNameSync,
|
|
40
|
-
getNameAccountKeySync,
|
|
41
|
-
} from "./utils";
|
|
42
|
-
import {
|
|
43
|
-
TOKEN_PROGRAM_ID,
|
|
44
|
-
getAssociatedTokenAddressSync,
|
|
45
|
-
createAssociatedTokenAccountInstruction,
|
|
46
|
-
} from "@solana/spl-token";
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Creates a name account with the given rent budget, allocated space, owner and class.
|
|
50
|
-
*
|
|
51
|
-
* @param connection The solana connection object to the RPC node
|
|
52
|
-
* @param name The name of the new account
|
|
53
|
-
* @param space The space in bytes allocated to the account
|
|
54
|
-
* @param payerKey The allocation cost payer
|
|
55
|
-
* @param nameOwner The pubkey to be set as owner of the new name account
|
|
56
|
-
* @param lamports The budget to be set for the name account. If not specified, it'll be the minimum for rent exemption
|
|
57
|
-
* @param nameClass The class of this new name
|
|
58
|
-
* @param parentName The parent name of the new name. If specified its owner needs to sign
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
export async function createNameRegistry(
|
|
62
|
-
connection: Connection,
|
|
63
|
-
name: string,
|
|
64
|
-
space: number,
|
|
65
|
-
payerKey: PublicKey,
|
|
66
|
-
nameOwner: PublicKey,
|
|
67
|
-
lamports?: number,
|
|
68
|
-
nameClass?: PublicKey,
|
|
69
|
-
parentName?: PublicKey
|
|
70
|
-
): Promise<TransactionInstruction> {
|
|
71
|
-
const hashed_name = await getHashedName(name);
|
|
72
|
-
const nameAccountKey = await getNameAccountKey(
|
|
73
|
-
hashed_name,
|
|
74
|
-
nameClass,
|
|
75
|
-
parentName
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const balance = lamports
|
|
79
|
-
? lamports
|
|
80
|
-
: await connection.getMinimumBalanceForRentExemption(space);
|
|
81
|
-
|
|
82
|
-
let nameParentOwner: PublicKey | undefined;
|
|
83
|
-
if (parentName) {
|
|
84
|
-
const { registry: parentAccount } = await getNameOwner(
|
|
85
|
-
connection,
|
|
86
|
-
parentName
|
|
87
|
-
);
|
|
88
|
-
nameParentOwner = parentAccount.owner;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const createNameInstr = createInstruction(
|
|
92
|
-
NAME_PROGRAM_ID,
|
|
93
|
-
SystemProgram.programId,
|
|
94
|
-
nameAccountKey,
|
|
95
|
-
nameOwner,
|
|
96
|
-
payerKey,
|
|
97
|
-
hashed_name,
|
|
98
|
-
//@ts-ignore
|
|
99
|
-
new Numberu64(balance),
|
|
100
|
-
//@ts-ignore
|
|
101
|
-
new Numberu32(space),
|
|
102
|
-
nameClass,
|
|
103
|
-
parentName,
|
|
104
|
-
nameParentOwner
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
return createNameInstr;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Overwrite the data of the given name registry.
|
|
112
|
-
*
|
|
113
|
-
* @param connection The solana connection object to the RPC node
|
|
114
|
-
* @param name The name of the name registry to update
|
|
115
|
-
* @param offset The offset to which the data should be written into the registry
|
|
116
|
-
* @param input_data The data to be written
|
|
117
|
-
* @param nameClass The class of this name, if it exsists
|
|
118
|
-
* @param nameParent The parent name of this name, if it exists
|
|
119
|
-
*/
|
|
120
|
-
export async function updateNameRegistryData(
|
|
121
|
-
connection: Connection,
|
|
122
|
-
name: string,
|
|
123
|
-
offset: number,
|
|
124
|
-
input_data: Buffer,
|
|
125
|
-
nameClass?: PublicKey,
|
|
126
|
-
nameParent?: PublicKey
|
|
127
|
-
): Promise<TransactionInstruction> {
|
|
128
|
-
const hashed_name = await getHashedName(name);
|
|
129
|
-
const nameAccountKey = await getNameAccountKey(
|
|
130
|
-
hashed_name,
|
|
131
|
-
nameClass,
|
|
132
|
-
nameParent
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
let signer: PublicKey;
|
|
136
|
-
if (nameClass) {
|
|
137
|
-
signer = nameClass;
|
|
138
|
-
} else {
|
|
139
|
-
signer = (await NameRegistryState.retrieve(connection, nameAccountKey))
|
|
140
|
-
.registry.owner;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const updateInstr = updateInstruction(
|
|
144
|
-
NAME_PROGRAM_ID,
|
|
145
|
-
nameAccountKey,
|
|
146
|
-
//@ts-ignore
|
|
147
|
-
new Numberu32(offset),
|
|
148
|
-
input_data,
|
|
149
|
-
signer
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
return updateInstr;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Change the owner of a given name account.
|
|
157
|
-
*
|
|
158
|
-
* @param connection The solana connection object to the RPC node
|
|
159
|
-
* @param name The name of the name account
|
|
160
|
-
* @param newOwner The new owner to be set
|
|
161
|
-
* @param curentNameOwner the current name Owner
|
|
162
|
-
* @param nameClass The class of this name, if it exsists
|
|
163
|
-
* @param nameParent The parent name of this name, if it exists
|
|
164
|
-
* @param parentOwner Parent name owner
|
|
165
|
-
* @returns
|
|
166
|
-
*/
|
|
167
|
-
export async function transferNameOwnership(
|
|
168
|
-
connection: Connection,
|
|
169
|
-
name: string,
|
|
170
|
-
newOwner: PublicKey,
|
|
171
|
-
nameClass?: PublicKey,
|
|
172
|
-
nameParent?: PublicKey,
|
|
173
|
-
parentOwner?: PublicKey
|
|
174
|
-
): Promise<TransactionInstruction> {
|
|
175
|
-
const hashed_name = await getHashedName(name);
|
|
176
|
-
const nameAccountKey = await getNameAccountKey(
|
|
177
|
-
hashed_name,
|
|
178
|
-
nameClass,
|
|
179
|
-
nameParent
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
let curentNameOwner: PublicKey;
|
|
183
|
-
if (nameClass) {
|
|
184
|
-
curentNameOwner = nameClass;
|
|
185
|
-
} else {
|
|
186
|
-
curentNameOwner = (
|
|
187
|
-
await NameRegistryState.retrieve(connection, nameAccountKey)
|
|
188
|
-
).registry.owner;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const transferInstr = transferInstruction(
|
|
192
|
-
NAME_PROGRAM_ID,
|
|
193
|
-
nameAccountKey,
|
|
194
|
-
newOwner,
|
|
195
|
-
curentNameOwner,
|
|
196
|
-
nameClass,
|
|
197
|
-
nameParent,
|
|
198
|
-
parentOwner
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
return transferInstr;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Delete the name account and transfer the rent to the target.
|
|
206
|
-
*
|
|
207
|
-
* @param connection The solana connection object to the RPC node
|
|
208
|
-
* @param name The name of the name account
|
|
209
|
-
* @param refundTargetKey The refund destination address
|
|
210
|
-
* @param nameClass The class of this name, if it exsists
|
|
211
|
-
* @param nameParent The parent name of this name, if it exists
|
|
212
|
-
* @returns
|
|
213
|
-
*/
|
|
214
|
-
export async function deleteNameRegistry(
|
|
215
|
-
connection: Connection,
|
|
216
|
-
name: string,
|
|
217
|
-
refundTargetKey: PublicKey,
|
|
218
|
-
nameClass?: PublicKey,
|
|
219
|
-
nameParent?: PublicKey
|
|
220
|
-
): Promise<TransactionInstruction> {
|
|
221
|
-
const hashed_name = await getHashedName(name);
|
|
222
|
-
const nameAccountKey = await getNameAccountKey(
|
|
223
|
-
hashed_name,
|
|
224
|
-
nameClass,
|
|
225
|
-
nameParent
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
let nameOwner: PublicKey;
|
|
229
|
-
if (nameClass) {
|
|
230
|
-
nameOwner = nameClass;
|
|
231
|
-
} else {
|
|
232
|
-
nameOwner = (await NameRegistryState.retrieve(connection, nameAccountKey))
|
|
233
|
-
.registry.owner;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
const changeAuthoritiesInstr = deleteInstruction(
|
|
237
|
-
NAME_PROGRAM_ID,
|
|
238
|
-
nameAccountKey,
|
|
239
|
-
refundTargetKey,
|
|
240
|
-
nameOwner
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
return changeAuthoritiesInstr;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* This function can be used to register a .sol domain
|
|
248
|
-
* @param connection The Solana RPC connection object
|
|
249
|
-
* @param name The domain name to register e.g bonfida if you want to register bonfida.sol
|
|
250
|
-
* @param space The domain name account size (max 10kB)
|
|
251
|
-
* @param buyer The public key of the buyer
|
|
252
|
-
* @param buyerTokenAccount The buyer token account (USDC)
|
|
253
|
-
* @param mint Optional mint used to purchase the domain, defaults to USDC
|
|
254
|
-
* @param referrerKey Optional referrer key
|
|
255
|
-
* @returns
|
|
256
|
-
*/
|
|
257
|
-
export const registerDomainName = async (
|
|
258
|
-
connection: Connection,
|
|
259
|
-
name: string,
|
|
260
|
-
space: number,
|
|
261
|
-
buyer: PublicKey,
|
|
262
|
-
buyerTokenAccount: PublicKey,
|
|
263
|
-
mint = USDC_MINT,
|
|
264
|
-
referrerKey?: PublicKey
|
|
265
|
-
) => {
|
|
266
|
-
const [cs] = PublicKey.findProgramAddressSync(
|
|
267
|
-
[REGISTER_PROGRAM_ID.toBuffer()],
|
|
268
|
-
REGISTER_PROGRAM_ID
|
|
269
|
-
);
|
|
270
|
-
|
|
271
|
-
const hashed = getHashedNameSync(name);
|
|
272
|
-
const nameAccount = getNameAccountKeySync(
|
|
273
|
-
hashed,
|
|
274
|
-
undefined,
|
|
275
|
-
ROOT_DOMAIN_ACCOUNT
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const hashedReverseLookup = getHashedNameSync(nameAccount.toBase58());
|
|
279
|
-
const reverseLookupAccount = getNameAccountKeySync(hashedReverseLookup, cs);
|
|
280
|
-
|
|
281
|
-
const [derived_state] = PublicKey.findProgramAddressSync(
|
|
282
|
-
[nameAccount.toBuffer()],
|
|
283
|
-
REGISTER_PROGRAM_ID
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
const refIdx = REFERRERS.findIndex((e) => referrerKey?.equals(e));
|
|
287
|
-
let refTokenAccount: PublicKey | undefined = undefined;
|
|
288
|
-
|
|
289
|
-
const ixs: TransactionInstruction[] = [];
|
|
290
|
-
|
|
291
|
-
if (refIdx !== -1 && !!referrerKey) {
|
|
292
|
-
refTokenAccount = getAssociatedTokenAddressSync(mint, referrerKey, true);
|
|
293
|
-
const acc = await connection.getAccountInfo(refTokenAccount);
|
|
294
|
-
if (!acc?.data) {
|
|
295
|
-
const ix = createAssociatedTokenAccountInstruction(
|
|
296
|
-
buyer,
|
|
297
|
-
refTokenAccount,
|
|
298
|
-
referrerKey,
|
|
299
|
-
mint
|
|
300
|
-
);
|
|
301
|
-
ixs.push(ix);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const pythConnection = new PythHttpClient(
|
|
306
|
-
connection,
|
|
307
|
-
getPythProgramKeyForCluster("mainnet-beta")
|
|
308
|
-
);
|
|
309
|
-
const data = await pythConnection.getData();
|
|
310
|
-
|
|
311
|
-
const symbol = TOKENS_SYM_MINT.get(mint.toBase58());
|
|
312
|
-
|
|
313
|
-
if (!symbol) {
|
|
314
|
-
throw new Error("Symbol not found");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const priceData = data.productPrice.get("Crypto." + symbol + "/USD")!;
|
|
318
|
-
const productData = data.productFromSymbol.get("Crypto." + symbol + "/USD")!;
|
|
319
|
-
|
|
320
|
-
const vault = getAssociatedTokenAddressSync(mint, VAULT_OWNER);
|
|
321
|
-
|
|
322
|
-
const ix = new createInstructionV3({
|
|
323
|
-
name,
|
|
324
|
-
space,
|
|
325
|
-
referrerIdxOpt: refIdx != -1 ? refIdx : null,
|
|
326
|
-
}).getInstruction(
|
|
327
|
-
REGISTER_PROGRAM_ID,
|
|
328
|
-
NAME_PROGRAM_ID,
|
|
329
|
-
ROOT_DOMAIN_ACCOUNT,
|
|
330
|
-
nameAccount,
|
|
331
|
-
reverseLookupAccount,
|
|
332
|
-
SystemProgram.programId,
|
|
333
|
-
cs,
|
|
334
|
-
buyer,
|
|
335
|
-
buyerTokenAccount,
|
|
336
|
-
PYTH_MAPPING_ACC,
|
|
337
|
-
priceData.productAccountKey,
|
|
338
|
-
new PublicKey(productData.price_account),
|
|
339
|
-
vault,
|
|
340
|
-
TOKEN_PROGRAM_ID,
|
|
341
|
-
SYSVAR_RENT_PUBKEY,
|
|
342
|
-
derived_state,
|
|
343
|
-
refTokenAccount
|
|
344
|
-
);
|
|
345
|
-
ixs.push(ix);
|
|
346
|
-
|
|
347
|
-
return [[], ixs];
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
*
|
|
352
|
-
* @param nameAccount The name account to create the reverse account for
|
|
353
|
-
* @param name The name of the domain
|
|
354
|
-
* @param feePayer The fee payer of the transaction
|
|
355
|
-
* @param parentName The parent name account
|
|
356
|
-
* @param parentNameOwner The parent name owner
|
|
357
|
-
* @returns
|
|
358
|
-
*/
|
|
359
|
-
export const createReverseName = async (
|
|
360
|
-
nameAccount: PublicKey,
|
|
361
|
-
name: string,
|
|
362
|
-
feePayer: PublicKey,
|
|
363
|
-
parentName?: PublicKey,
|
|
364
|
-
parentNameOwner?: PublicKey
|
|
365
|
-
) => {
|
|
366
|
-
let [centralState] = await PublicKey.findProgramAddress(
|
|
367
|
-
[REGISTER_PROGRAM_ID.toBuffer()],
|
|
368
|
-
REGISTER_PROGRAM_ID
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
let hashedReverseLookup = await getHashedName(nameAccount.toBase58());
|
|
372
|
-
let reverseLookupAccount = await getNameAccountKey(
|
|
373
|
-
hashedReverseLookup,
|
|
374
|
-
centralState,
|
|
375
|
-
parentName
|
|
376
|
-
);
|
|
377
|
-
|
|
378
|
-
let initCentralStateInstruction = new createReverseInstruction({
|
|
379
|
-
name,
|
|
380
|
-
}).getInstruction(
|
|
381
|
-
REGISTER_PROGRAM_ID,
|
|
382
|
-
SYSVAR_RENT_PUBKEY,
|
|
383
|
-
NAME_PROGRAM_ID,
|
|
384
|
-
ROOT_DOMAIN_ACCOUNT,
|
|
385
|
-
reverseLookupAccount,
|
|
386
|
-
centralState,
|
|
387
|
-
feePayer,
|
|
388
|
-
parentName,
|
|
389
|
-
parentNameOwner
|
|
390
|
-
);
|
|
391
|
-
|
|
392
|
-
let instructions = [initCentralStateInstruction];
|
|
393
|
-
|
|
394
|
-
return [[], instructions];
|
|
395
|
-
};
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* This function can be used to create a subdomain
|
|
399
|
-
* @param connection The Solana RPC connection object
|
|
400
|
-
* @param subdomain The subdomain to create with or without .sol e.g something.bonfida.sol or something.bonfida
|
|
401
|
-
* @param owner The owner of the parent domain creating the subdomain
|
|
402
|
-
* @param space The space to allocate to the subdomain (defaults to 2kb)
|
|
403
|
-
*/
|
|
404
|
-
export const createSubdomain = async (
|
|
405
|
-
connection: Connection,
|
|
406
|
-
subdomain: string,
|
|
407
|
-
owner: PublicKey,
|
|
408
|
-
space = 2_000
|
|
409
|
-
) => {
|
|
410
|
-
const ixs: TransactionInstruction[] = [];
|
|
411
|
-
const sub = subdomain.split(".")[0];
|
|
412
|
-
if (!sub) {
|
|
413
|
-
throw new Error("Invalid subdomain input");
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
const { parent, pubkey } = getDomainKeySync(subdomain);
|
|
417
|
-
|
|
418
|
-
// Space allocated to the subdomains
|
|
419
|
-
const lamports = await connection.getMinimumBalanceForRentExemption(
|
|
420
|
-
space + NameRegistryState.HEADER_LEN
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
const ix_create = await createNameRegistry(
|
|
424
|
-
connection,
|
|
425
|
-
"\0".concat(sub),
|
|
426
|
-
space, // Hardcode space to 2kB
|
|
427
|
-
owner,
|
|
428
|
-
owner,
|
|
429
|
-
lamports,
|
|
430
|
-
undefined,
|
|
431
|
-
parent
|
|
432
|
-
);
|
|
433
|
-
ixs.push(ix_create);
|
|
434
|
-
|
|
435
|
-
// Create the reverse name
|
|
436
|
-
const [, ix_reverse] = await createReverseName(
|
|
437
|
-
pubkey,
|
|
438
|
-
"\0".concat(sub),
|
|
439
|
-
owner,
|
|
440
|
-
parent,
|
|
441
|
-
owner
|
|
442
|
-
);
|
|
443
|
-
ixs.push(...ix_reverse);
|
|
444
|
-
return [[], ixs];
|
|
445
|
-
};
|
package/src/constants.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { PublicKey } from "@solana/web3.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The Solana Name Service program ID
|
|
5
|
-
*/
|
|
6
|
-
export const NAME_PROGRAM_ID = new PublicKey(
|
|
7
|
-
"namesLPneVptA9Z5rqUDD9tMTWEJwofgaYwp8cawRkX"
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Hash prefix used to derive domain name addresses
|
|
12
|
-
*/
|
|
13
|
-
export const HASH_PREFIX = "SPL Name Service";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The `.sol` TLD
|
|
17
|
-
*/
|
|
18
|
-
export const ROOT_DOMAIN_ACCOUNT = new PublicKey(
|
|
19
|
-
"58PwtjSDuFHuUkYjH9BYnnQKHfwo9reZhC2zMJv9JPkx"
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The Registry program ID
|
|
24
|
-
*/
|
|
25
|
-
export const REGISTER_PROGRAM_ID = new PublicKey(
|
|
26
|
-
"jCebN34bUfdeUYJT13J1yG16XWQpt5PDx6Mse9GUqhR"
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The FIDA Pyth price feed
|
|
31
|
-
*/
|
|
32
|
-
export const PYTH_FIDA_PRICE_ACC = new PublicKey(
|
|
33
|
-
"ETp9eKXVv1dWwHSpsXRUuXHmw24PwRkttCGVgpZEY9zF"
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The FIDA buy and burn address
|
|
38
|
-
*/
|
|
39
|
-
export const BONFIDA_FIDA_BNB = new PublicKey(
|
|
40
|
-
"AUoZ3YAhV3b2rZeEH93UMZHXUZcTramBvb4d9YEVySkc"
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The reverse look up class
|
|
45
|
-
*/
|
|
46
|
-
export const REVERSE_LOOKUP_CLASS = new PublicKey(
|
|
47
|
-
"33m47vH6Eav6jr5Ry86XjhRft2jRBLDnDgPSHoquXi2Z"
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The `.twitter` TLD authority
|
|
52
|
-
*/
|
|
53
|
-
export const TWITTER_VERIFICATION_AUTHORITY = new PublicKey(
|
|
54
|
-
"FvPH7PrVrLGKPfqaf3xJodFTjZriqrAXXLTVWEorTFBi"
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The `.twitter` TLD
|
|
59
|
-
*/
|
|
60
|
-
export const TWITTER_ROOT_PARENT_REGISTRY_KEY = new PublicKey(
|
|
61
|
-
"4YcexoW3r78zz16J2aqmukBLRwGq6rAvWzJpkYAXqebv"
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The length of the SOL record signature
|
|
66
|
-
*/
|
|
67
|
-
export const SOL_RECORD_SIG_LEN = 96;
|
|
68
|
-
|
|
69
|
-
export const BONFIDA_USDC_BNB = new PublicKey(
|
|
70
|
-
"DmSyHDSM9eSLyvoLsPvDr5fRRFZ7Bfr3h3ULvWpgQaq7"
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
export const USDC_MINT = new PublicKey(
|
|
74
|
-
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
export const REFERRERS: PublicKey[] = [
|
|
78
|
-
new PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"), // Test wallet,
|
|
79
|
-
new PublicKey("DM1jJCkZZEwY5tmWbgvKRxsDFzXCdbfrYCCH1CtwguEs"), // 4Everland
|
|
80
|
-
];
|
|
81
|
-
|
|
82
|
-
export const TOKENS_SYM_MINT = new Map<string, string>([
|
|
83
|
-
["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "USDC"],
|
|
84
|
-
["Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", "USDT"],
|
|
85
|
-
["So11111111111111111111111111111111111111112", "SOL"],
|
|
86
|
-
["EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp", "FIDA"],
|
|
87
|
-
["FeGn77dhg1KXRRFeSwwMiykZnZPw5JXW6naf2aQgZDQf", "ETH"],
|
|
88
|
-
["7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx", "GMT"],
|
|
89
|
-
["AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB", "GST"],
|
|
90
|
-
["mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So", "MSOL"],
|
|
91
|
-
["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263", "BONK"],
|
|
92
|
-
["EPeUFDgHRxs9xxEPVaL6kfGQvCon7jmAWKVUHuux1Tpz", "BAT"],
|
|
93
|
-
]);
|
|
94
|
-
|
|
95
|
-
export const PYTH_MAPPING_ACC = new PublicKey(
|
|
96
|
-
"AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J"
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
export const VAULT_OWNER = new PublicKey(
|
|
100
|
-
"GcWEQ9K78FV7LEHteFVciYApERk5YvQuFDQPk1yYJVXi"
|
|
101
|
-
);
|
package/src/deprecated/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./utils";
|
package/src/deprecated/record.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Record } from "../types/record";
|
|
2
|
-
import { getDomainKey } from "./utils";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use {@link getRecordKeySync} instead
|
|
6
|
-
* This function can be used to derive a record key
|
|
7
|
-
* @param domain The .sol domain name
|
|
8
|
-
* @param record The record to derive the key for
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export const getRecordKey = async (domain: string, record: Record) => {
|
|
12
|
-
const { pubkey } = await getDomainKey(record + "." + domain, true);
|
|
13
|
-
return pubkey;
|
|
14
|
-
};
|
package/src/deprecated/tokens.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { PublicKey, Connection } from "@solana/web3.js";
|
|
2
|
-
import { getHashedName, getNameAccountKey } from "./utils";
|
|
3
|
-
import { NameRegistryState, TokenData, Mint } from "../state";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
export const TOKEN_TLD = new PublicKey(
|
|
9
|
-
"6NSu2tci4apRKQtt257bAVcvqYjB3zV2H1dWo56vgpa6"
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated
|
|
14
|
-
*/
|
|
15
|
-
export const getTokenInfoFromMint = async (
|
|
16
|
-
connection: Connection,
|
|
17
|
-
mint: PublicKey
|
|
18
|
-
) => {
|
|
19
|
-
const nameKey = await getNameAccountKey(
|
|
20
|
-
await getHashedName(mint.toBase58()),
|
|
21
|
-
undefined,
|
|
22
|
-
TOKEN_TLD
|
|
23
|
-
);
|
|
24
|
-
const { registry } = await NameRegistryState.retrieve(connection, nameKey);
|
|
25
|
-
if (!registry.data) {
|
|
26
|
-
throw new Error("Invalid account data");
|
|
27
|
-
}
|
|
28
|
-
return TokenData.deserialize(registry.data);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated
|
|
33
|
-
*/
|
|
34
|
-
export const getTokenInfoFromName = async (
|
|
35
|
-
connection: Connection,
|
|
36
|
-
name: string
|
|
37
|
-
) => {
|
|
38
|
-
const reverseNameKey = await getNameAccountKey(
|
|
39
|
-
await getHashedName(name),
|
|
40
|
-
undefined,
|
|
41
|
-
TOKEN_TLD
|
|
42
|
-
);
|
|
43
|
-
const { registry: reverseRegistry } = await NameRegistryState.retrieve(
|
|
44
|
-
connection,
|
|
45
|
-
reverseNameKey
|
|
46
|
-
);
|
|
47
|
-
if (!reverseRegistry.data) {
|
|
48
|
-
throw new Error("Invalid account data");
|
|
49
|
-
}
|
|
50
|
-
const mint = new PublicKey(Mint.deserialize(reverseRegistry.data).mint);
|
|
51
|
-
return await getTokenInfoFromMint(connection, mint);
|
|
52
|
-
};
|