four-flap-meme-sdk 1.5.6 → 1.5.8

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.
Files changed (158) hide show
  1. package/README.zh-CN.pdf +0 -0
  2. package/dist/abis/common.js +2 -0
  3. package/dist/contracts/tm-bundle-merkle/config.d.ts +0 -1
  4. package/dist/contracts/tm-bundle-merkle/config.js +0 -1
  5. package/dist/contracts/tm-bundle-merkle/core.js +13 -9
  6. package/dist/flap/portal-bundle-merkle/config.d.ts +0 -1
  7. package/dist/flap/portal-bundle-merkle/config.js +0 -1
  8. package/dist/flap/portal-bundle-merkle/create-to-dex.d.ts +8 -2
  9. package/dist/flap/portal-bundle-merkle/create-to-dex.js +170 -128
  10. package/dist/flap/portal-bundle-merkle/encryption.d.ts +16 -0
  11. package/dist/flap/portal-bundle-merkle/encryption.js +146 -0
  12. package/dist/index.d.ts +0 -1
  13. package/dist/index.js +1 -1
  14. package/package.json +5 -41
  15. package/dist/sol/constants.d.ts +0 -150
  16. package/dist/sol/constants.js +0 -188
  17. package/dist/sol/dex/blockrazor/client.d.ts +0 -51
  18. package/dist/sol/dex/blockrazor/client.js +0 -96
  19. package/dist/sol/dex/blockrazor/constants.d.ts +0 -34
  20. package/dist/sol/dex/blockrazor/constants.js +0 -55
  21. package/dist/sol/dex/blockrazor/geyser.d.ts +0 -128
  22. package/dist/sol/dex/blockrazor/geyser.js +0 -530
  23. package/dist/sol/dex/blockrazor/index.d.ts +0 -18
  24. package/dist/sol/dex/blockrazor/index.js +0 -23
  25. package/dist/sol/dex/blockrazor/send.d.ts +0 -135
  26. package/dist/sol/dex/blockrazor/send.js +0 -254
  27. package/dist/sol/dex/blockrazor/types.d.ts +0 -191
  28. package/dist/sol/dex/blockrazor/types.js +0 -5
  29. package/dist/sol/dex/index.d.ts +0 -10
  30. package/dist/sol/dex/index.js +0 -16
  31. package/dist/sol/dex/jup/client.d.ts +0 -33
  32. package/dist/sol/dex/jup/client.js +0 -110
  33. package/dist/sol/dex/jup/index.d.ts +0 -16
  34. package/dist/sol/dex/jup/index.js +0 -148
  35. package/dist/sol/dex/jup/legacy.d.ts +0 -623
  36. package/dist/sol/dex/jup/legacy.js +0 -416
  37. package/dist/sol/dex/jup/lend.d.ts +0 -640
  38. package/dist/sol/dex/jup/lend.js +0 -603
  39. package/dist/sol/dex/jup/portfolio.d.ts +0 -362
  40. package/dist/sol/dex/jup/portfolio.js +0 -367
  41. package/dist/sol/dex/jup/price.d.ts +0 -173
  42. package/dist/sol/dex/jup/price.js +0 -220
  43. package/dist/sol/dex/jup/recurring.d.ts +0 -437
  44. package/dist/sol/dex/jup/recurring.js +0 -320
  45. package/dist/sol/dex/jup/send.d.ts +0 -282
  46. package/dist/sol/dex/jup/send.js +0 -295
  47. package/dist/sol/dex/jup/studio.d.ts +0 -457
  48. package/dist/sol/dex/jup/studio.js +0 -488
  49. package/dist/sol/dex/jup/tokens.d.ts +0 -767
  50. package/dist/sol/dex/jup/tokens.js +0 -697
  51. package/dist/sol/dex/jup/trigger.d.ts +0 -511
  52. package/dist/sol/dex/jup/trigger.js +0 -397
  53. package/dist/sol/dex/jup/types.d.ts +0 -433
  54. package/dist/sol/dex/jup/types.js +0 -5
  55. package/dist/sol/dex/jup/ultra.d.ts +0 -646
  56. package/dist/sol/dex/jup/ultra.js +0 -853
  57. package/dist/sol/dex/meteora/client.d.ts +0 -76
  58. package/dist/sol/dex/meteora/client.js +0 -219
  59. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +0 -61
  60. package/dist/sol/dex/meteora/damm-v1-bundle.js +0 -112
  61. package/dist/sol/dex/meteora/damm-v1.d.ts +0 -118
  62. package/dist/sol/dex/meteora/damm-v1.js +0 -315
  63. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +0 -82
  64. package/dist/sol/dex/meteora/damm-v2-bundle.js +0 -242
  65. package/dist/sol/dex/meteora/damm-v2.d.ts +0 -172
  66. package/dist/sol/dex/meteora/damm-v2.js +0 -632
  67. package/dist/sol/dex/meteora/dbc-bundle.d.ts +0 -123
  68. package/dist/sol/dex/meteora/dbc-bundle.js +0 -304
  69. package/dist/sol/dex/meteora/dbc.d.ts +0 -192
  70. package/dist/sol/dex/meteora/dbc.js +0 -619
  71. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +0 -39
  72. package/dist/sol/dex/meteora/dlmm-bundle.js +0 -189
  73. package/dist/sol/dex/meteora/dlmm.d.ts +0 -157
  74. package/dist/sol/dex/meteora/dlmm.js +0 -671
  75. package/dist/sol/dex/meteora/index.d.ts +0 -25
  76. package/dist/sol/dex/meteora/index.js +0 -65
  77. package/dist/sol/dex/meteora/types.d.ts +0 -787
  78. package/dist/sol/dex/meteora/types.js +0 -110
  79. package/dist/sol/dex/orca/index.d.ts +0 -10
  80. package/dist/sol/dex/orca/index.js +0 -16
  81. package/dist/sol/dex/orca/orca-bundle.d.ts +0 -41
  82. package/dist/sol/dex/orca/orca-bundle.js +0 -173
  83. package/dist/sol/dex/orca/orca.d.ts +0 -65
  84. package/dist/sol/dex/orca/orca.js +0 -474
  85. package/dist/sol/dex/orca/types.d.ts +0 -263
  86. package/dist/sol/dex/orca/types.js +0 -38
  87. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +0 -34
  88. package/dist/sol/dex/orca/wavebreak-bundle.js +0 -198
  89. package/dist/sol/dex/orca/wavebreak-types.d.ts +0 -227
  90. package/dist/sol/dex/orca/wavebreak-types.js +0 -23
  91. package/dist/sol/dex/orca/wavebreak.d.ts +0 -78
  92. package/dist/sol/dex/orca/wavebreak.js +0 -497
  93. package/dist/sol/dex/pump/index.d.ts +0 -9
  94. package/dist/sol/dex/pump/index.js +0 -14
  95. package/dist/sol/dex/pump/pump-bundle.d.ts +0 -92
  96. package/dist/sol/dex/pump/pump-bundle.js +0 -383
  97. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +0 -103
  98. package/dist/sol/dex/pump/pump-swap-bundle.js +0 -380
  99. package/dist/sol/dex/pump/pump-swap.d.ts +0 -46
  100. package/dist/sol/dex/pump/pump-swap.js +0 -199
  101. package/dist/sol/dex/pump/pump.d.ts +0 -35
  102. package/dist/sol/dex/pump/pump.js +0 -352
  103. package/dist/sol/dex/pump/types.d.ts +0 -215
  104. package/dist/sol/dex/pump/types.js +0 -5
  105. package/dist/sol/dex/raydium/index.d.ts +0 -8
  106. package/dist/sol/dex/raydium/index.js +0 -12
  107. package/dist/sol/dex/raydium/launchlab.d.ts +0 -68
  108. package/dist/sol/dex/raydium/launchlab.js +0 -210
  109. package/dist/sol/dex/raydium/raydium-bundle.d.ts +0 -64
  110. package/dist/sol/dex/raydium/raydium-bundle.js +0 -324
  111. package/dist/sol/dex/raydium/raydium.d.ts +0 -40
  112. package/dist/sol/dex/raydium/raydium.js +0 -366
  113. package/dist/sol/dex/raydium/types.d.ts +0 -240
  114. package/dist/sol/dex/raydium/types.js +0 -5
  115. package/dist/sol/index.d.ts +0 -11
  116. package/dist/sol/index.js +0 -18
  117. package/dist/sol/jito/bundle.d.ts +0 -90
  118. package/dist/sol/jito/bundle.js +0 -263
  119. package/dist/sol/jito/index.d.ts +0 -7
  120. package/dist/sol/jito/index.js +0 -7
  121. package/dist/sol/jito/tip.d.ts +0 -51
  122. package/dist/sol/jito/tip.js +0 -83
  123. package/dist/sol/jito/types.d.ts +0 -100
  124. package/dist/sol/jito/types.js +0 -5
  125. package/dist/sol/nozomi/client.d.ts +0 -63
  126. package/dist/sol/nozomi/client.js +0 -222
  127. package/dist/sol/nozomi/index.d.ts +0 -8
  128. package/dist/sol/nozomi/index.js +0 -8
  129. package/dist/sol/nozomi/tip.d.ts +0 -50
  130. package/dist/sol/nozomi/tip.js +0 -80
  131. package/dist/sol/nozomi/types.d.ts +0 -96
  132. package/dist/sol/nozomi/types.js +0 -5
  133. package/dist/sol/token/create-complete.d.ts +0 -115
  134. package/dist/sol/token/create-complete.js +0 -235
  135. package/dist/sol/token/create-token.d.ts +0 -57
  136. package/dist/sol/token/create-token.js +0 -230
  137. package/dist/sol/token/index.d.ts +0 -9
  138. package/dist/sol/token/index.js +0 -14
  139. package/dist/sol/token/metadata-upload.d.ts +0 -86
  140. package/dist/sol/token/metadata-upload.js +0 -173
  141. package/dist/sol/token/metadata.d.ts +0 -92
  142. package/dist/sol/token/metadata.js +0 -274
  143. package/dist/sol/token/types.d.ts +0 -153
  144. package/dist/sol/token/types.js +0 -5
  145. package/dist/sol/types.d.ts +0 -176
  146. package/dist/sol/types.js +0 -7
  147. package/dist/sol/utils/balance.d.ts +0 -160
  148. package/dist/sol/utils/balance.js +0 -638
  149. package/dist/sol/utils/connection.d.ts +0 -78
  150. package/dist/sol/utils/connection.js +0 -168
  151. package/dist/sol/utils/index.d.ts +0 -9
  152. package/dist/sol/utils/index.js +0 -9
  153. package/dist/sol/utils/lp-inspect.d.ts +0 -129
  154. package/dist/sol/utils/lp-inspect.js +0 -900
  155. package/dist/sol/utils/transfer.d.ts +0 -196
  156. package/dist/sol/utils/transfer.js +0 -307
  157. package/dist/sol/utils/wallet.d.ts +0 -107
  158. package/dist/sol/utils/wallet.js +0 -210
@@ -1,222 +0,0 @@
1
- /**
2
- * Nozomi 客户端
3
- * 用于发送交易到 Temporal Nozomi 服务
4
- * @module sol/nozomi/client
5
- */
6
- import { Transaction, ComputeBudgetProgram, } from '@solana/web3.js';
7
- import { NOZOMI_CONFIG } from '../constants.js';
8
- import { buildNozomiTipInstruction, getRandomNozomiTipAccount } from './tip.js';
9
- /**
10
- * Nozomi 客户端
11
- * 用于发送交易到 Temporal Nozomi 服务
12
- */
13
- export class NozomiClient {
14
- constructor(config) {
15
- this.apiKeyFast = config.apiKeyFast;
16
- this.apiKeyMev = config.apiKeyMev || config.apiKeyFast;
17
- this.defaultRegion = config.defaultRegion || 'auto';
18
- this.defaultUseMevProtection = config.defaultUseMevProtection || false;
19
- this.timeout = config.timeout || 30000;
20
- }
21
- /**
22
- * 获取 Nozomi 端点 URL
23
- * @param useMevProtection 是否使用 MEV 保护
24
- * @param region 区域
25
- */
26
- getEndpoint(useMevProtection = false, region = 'auto') {
27
- const apiKey = useMevProtection ? this.apiKeyMev : this.apiKeyFast;
28
- const host = NOZOMI_CONFIG.REGIONS[region] || NOZOMI_CONFIG.REGIONS.auto;
29
- return `https://${host}/?c=${apiKey}`;
30
- }
31
- /**
32
- * 发送单笔交易
33
- * @param transaction 交易(Transaction 或 VersionedTransaction)
34
- * @param options 发送选项
35
- */
36
- async sendTransaction(transaction, options) {
37
- const useMevProtection = options?.useMevProtection ?? this.defaultUseMevProtection;
38
- const region = options?.region ?? this.defaultRegion;
39
- const endpoint = this.getEndpoint(useMevProtection, region);
40
- const startTime = Date.now();
41
- try {
42
- // 序列化交易
43
- const serialized = transaction.serialize();
44
- const base64Tx = Buffer.from(serialized).toString('base64');
45
- // 发送请求
46
- const response = await fetch(endpoint, {
47
- method: 'POST',
48
- headers: { 'Content-Type': 'application/json' },
49
- body: JSON.stringify({
50
- jsonrpc: '2.0',
51
- id: 1,
52
- method: 'sendTransaction',
53
- params: [
54
- base64Tx,
55
- {
56
- encoding: 'base64',
57
- skipPreflight: options?.skipPreflight ?? true,
58
- maxRetries: options?.maxRetries ?? 0,
59
- },
60
- ],
61
- }),
62
- signal: AbortSignal.timeout(this.timeout),
63
- });
64
- const result = await response.json();
65
- const latency = Date.now() - startTime;
66
- if (result.error) {
67
- return {
68
- success: false,
69
- error: `${result.error.message}${result.error.data ? `: ${result.error.data}` : ''}`,
70
- latency,
71
- };
72
- }
73
- return {
74
- success: true,
75
- signature: result.result,
76
- latency,
77
- };
78
- }
79
- catch (error) {
80
- const latency = Date.now() - startTime;
81
- return {
82
- success: false,
83
- error: error instanceof Error ? error.message : String(error),
84
- latency,
85
- };
86
- }
87
- }
88
- /**
89
- * 批量发送交易(并行发送,非 Bundle)
90
- * @param transactions 交易列表
91
- * @param options 发送选项
92
- */
93
- async sendTransactions(transactions, options) {
94
- const startTime = Date.now();
95
- const results = await Promise.all(transactions.map((tx) => this.sendTransaction(tx, options)));
96
- const successCount = results.filter((r) => r.success).length;
97
- const failCount = results.length - successCount;
98
- return {
99
- total: transactions.length,
100
- successCount,
101
- failCount,
102
- results,
103
- totalLatency: Date.now() - startTime,
104
- };
105
- }
106
- /**
107
- * 构建并发送交易
108
- * @param connection Solana 连接(用于获取 blockhash)
109
- * @param instructions 指令列表
110
- * @param signers 签名者列表(第一个为 feePayer)
111
- * @param buildOptions 构建选项
112
- * @param sendOptions 发送选项
113
- */
114
- async buildAndSendTransaction(connection, instructions, signers, buildOptions, sendOptions) {
115
- if (signers.length === 0) {
116
- return {
117
- success: false,
118
- error: 'At least one signer (feePayer) is required',
119
- };
120
- }
121
- const feePayer = signers[0];
122
- const { blockhash } = await connection.getLatestBlockhash('finalized');
123
- const transaction = new Transaction();
124
- // 添加计算预算指令
125
- if (buildOptions?.computeUnitPrice) {
126
- transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
127
- microLamports: buildOptions.computeUnitPrice,
128
- }));
129
- }
130
- else {
131
- // 使用默认推荐值
132
- transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
133
- microLamports: NOZOMI_CONFIG.RECOMMENDED_PRIORITY_FEE,
134
- }));
135
- }
136
- if (buildOptions?.computeUnitLimit) {
137
- transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
138
- units: buildOptions.computeUnitLimit,
139
- }));
140
- }
141
- // 添加 Nozomi Tip(必须在业务指令之前)
142
- if (buildOptions?.addTip !== false) {
143
- const tipLamports = buildOptions?.tipLamports || BigInt(NOZOMI_CONFIG.DEFAULT_TIP_LAMPORTS);
144
- transaction.add(buildNozomiTipInstruction(feePayer.publicKey, tipLamports, buildOptions?.tipAccount));
145
- }
146
- // 添加业务指令
147
- transaction.add(...instructions);
148
- // 设置交易属性
149
- transaction.recentBlockhash = blockhash;
150
- transaction.feePayer = feePayer.publicKey;
151
- // 签名
152
- transaction.sign(...signers);
153
- // 发送
154
- return this.sendTransaction(transaction, sendOptions);
155
- }
156
- }
157
- /**
158
- * 构建带 Nozomi Tip 的交易
159
- * @param connection Solana 连接
160
- * @param instructions 指令列表
161
- * @param feePayer 手续费支付者
162
- * @param options 构建选项
163
- */
164
- export async function buildNozomiTransaction(connection, instructions, feePayer, options) {
165
- const { blockhash } = await connection.getLatestBlockhash('finalized');
166
- const transaction = new Transaction();
167
- // 添加计算预算指令
168
- if (options?.computeUnitPrice) {
169
- transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
170
- microLamports: options.computeUnitPrice,
171
- }));
172
- }
173
- else {
174
- transaction.add(ComputeBudgetProgram.setComputeUnitPrice({
175
- microLamports: NOZOMI_CONFIG.RECOMMENDED_PRIORITY_FEE,
176
- }));
177
- }
178
- if (options?.computeUnitLimit) {
179
- transaction.add(ComputeBudgetProgram.setComputeUnitLimit({
180
- units: options.computeUnitLimit,
181
- }));
182
- }
183
- // 添加 Nozomi Tip(必须在业务指令之前)
184
- if (options?.addTip !== false) {
185
- const tipLamports = options?.tipLamports || BigInt(NOZOMI_CONFIG.DEFAULT_TIP_LAMPORTS);
186
- transaction.add(buildNozomiTipInstruction(feePayer.publicKey, tipLamports, options?.tipAccount));
187
- }
188
- // 添加业务指令
189
- transaction.add(...instructions);
190
- // 设置交易属性
191
- transaction.recentBlockhash = blockhash;
192
- transaction.feePayer = feePayer.publicKey;
193
- return transaction;
194
- }
195
- /**
196
- * 将现有交易添加 Nozomi Tip
197
- * 注意:这会在交易开头添加 Tip 指令
198
- * @param transaction 原始交易
199
- * @param feePayer 手续费支付者
200
- * @param tipLamports Tip 金额
201
- * @param tipAccount Tip 账户
202
- */
203
- export function addNozomiTipToTransaction(transaction, feePayer, tipLamports = BigInt(NOZOMI_CONFIG.DEFAULT_TIP_LAMPORTS), tipAccount) {
204
- const tipInstruction = buildNozomiTipInstruction(feePayer.publicKey, tipLamports, tipAccount || getRandomNozomiTipAccount());
205
- // 创建新交易,先添加 tip,再添加原有指令
206
- const newTransaction = new Transaction();
207
- // 复制计算预算指令(如果有)
208
- const computeBudgetInstructions = transaction.instructions.filter((ix) => ix.programId.toBase58() === 'ComputeBudget111111111111111111111111111111');
209
- const otherInstructions = transaction.instructions.filter((ix) => ix.programId.toBase58() !== 'ComputeBudget111111111111111111111111111111');
210
- // 先添加计算预算,再添加 tip,最后添加其他指令
211
- newTransaction.add(...computeBudgetInstructions);
212
- newTransaction.add(tipInstruction);
213
- newTransaction.add(...otherInstructions);
214
- // 复制交易属性
215
- if (transaction.recentBlockhash) {
216
- newTransaction.recentBlockhash = transaction.recentBlockhash;
217
- }
218
- if (transaction.feePayer) {
219
- newTransaction.feePayer = transaction.feePayer;
220
- }
221
- return newTransaction;
222
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Nozomi 交易加速服务
3
- * Temporal Nozomi - 快速提交 Solana 交易
4
- * @module sol/nozomi
5
- */
6
- export * from './types.js';
7
- export * from './tip.js';
8
- export * from './client.js';
@@ -1,8 +0,0 @@
1
- /**
2
- * Nozomi 交易加速服务
3
- * Temporal Nozomi - 快速提交 Solana 交易
4
- * @module sol/nozomi
5
- */
6
- export * from './types.js';
7
- export * from './tip.js';
8
- export * from './client.js';
@@ -1,50 +0,0 @@
1
- /**
2
- * Nozomi Tip 相关功能
3
- * @module sol/nozomi/tip
4
- */
5
- import { PublicKey, TransactionInstruction } from '@solana/web3.js';
6
- /**
7
- * 随机选择一个 Tip 账户
8
- * @returns Tip 账户地址
9
- */
10
- export declare function getRandomNozomiTipAccount(): string;
11
- /**
12
- * 获取所有 Tip 账户
13
- * @returns Tip 账户列表
14
- */
15
- export declare function getAllNozomiTipAccounts(): string[];
16
- /**
17
- * 验证是否是有效的 Nozomi Tip 账户
18
- * @param address 地址
19
- */
20
- export declare function isValidNozomiTipAccount(address: string): boolean;
21
- /**
22
- * 构建 Nozomi Tip 指令
23
- * @param fromPubkey 付款者公钥
24
- * @param tipLamports Tip 金额(lamports),默认 0.001 SOL
25
- * @param tipAccount 可选:指定 Tip 账户,默认随机选择
26
- * @returns TransactionInstruction
27
- */
28
- export declare function buildNozomiTipInstruction(fromPubkey: PublicKey, tipLamports?: bigint, tipAccount?: string): TransactionInstruction;
29
- /**
30
- * 计算推荐的 Tip 金额
31
- * 根据优先级计算
32
- * @param priority 优先级 (1-10,10 最高)
33
- * @returns 推荐的 Tip 金额(lamports)
34
- */
35
- export declare function calculateRecommendedNozomiTip(priority?: number): bigint;
36
- /**
37
- * Nozomi Tip 金额预设
38
- */
39
- export declare const NOZOMI_TIP_PRESETS: {
40
- /** 最低 tip (0.001 SOL) */
41
- readonly LOW: bigint;
42
- /** 标准 tip (0.001 SOL) */
43
- readonly STANDARD: bigint;
44
- /** 中等 tip (0.002 SOL) */
45
- readonly MEDIUM: bigint;
46
- /** 高 tip (0.005 SOL) */
47
- readonly HIGH: bigint;
48
- /** 紧急 tip (0.01 SOL) */
49
- readonly URGENT: bigint;
50
- };
@@ -1,80 +0,0 @@
1
- /**
2
- * Nozomi Tip 相关功能
3
- * @module sol/nozomi/tip
4
- */
5
- import { PublicKey, SystemProgram, } from '@solana/web3.js';
6
- import { NOZOMI_CONFIG } from '../constants.js';
7
- /**
8
- * 随机选择一个 Tip 账户
9
- * @returns Tip 账户地址
10
- */
11
- export function getRandomNozomiTipAccount() {
12
- const accounts = NOZOMI_CONFIG.TIP_ACCOUNTS;
13
- const index = Math.floor(Math.random() * accounts.length);
14
- return accounts[index];
15
- }
16
- /**
17
- * 获取所有 Tip 账户
18
- * @returns Tip 账户列表
19
- */
20
- export function getAllNozomiTipAccounts() {
21
- return [...NOZOMI_CONFIG.TIP_ACCOUNTS];
22
- }
23
- /**
24
- * 验证是否是有效的 Nozomi Tip 账户
25
- * @param address 地址
26
- */
27
- export function isValidNozomiTipAccount(address) {
28
- return NOZOMI_CONFIG.TIP_ACCOUNTS.includes(address);
29
- }
30
- /**
31
- * 构建 Nozomi Tip 指令
32
- * @param fromPubkey 付款者公钥
33
- * @param tipLamports Tip 金额(lamports),默认 0.001 SOL
34
- * @param tipAccount 可选:指定 Tip 账户,默认随机选择
35
- * @returns TransactionInstruction
36
- */
37
- export function buildNozomiTipInstruction(fromPubkey, tipLamports = BigInt(NOZOMI_CONFIG.DEFAULT_TIP_LAMPORTS), tipAccount) {
38
- const tipAccountAddress = tipAccount || getRandomNozomiTipAccount();
39
- // 确保 tip 金额不低于最小值
40
- const finalTip = tipLamports < BigInt(NOZOMI_CONFIG.MIN_TIP_LAMPORTS)
41
- ? BigInt(NOZOMI_CONFIG.MIN_TIP_LAMPORTS)
42
- : tipLamports;
43
- return SystemProgram.transfer({
44
- fromPubkey,
45
- toPubkey: new PublicKey(tipAccountAddress),
46
- lamports: finalTip,
47
- });
48
- }
49
- /**
50
- * 计算推荐的 Tip 金额
51
- * 根据优先级计算
52
- * @param priority 优先级 (1-10,10 最高)
53
- * @returns 推荐的 Tip 金额(lamports)
54
- */
55
- export function calculateRecommendedNozomiTip(priority = 5) {
56
- // 基础 tip 0.001 SOL
57
- const baseTip = BigInt(NOZOMI_CONFIG.DEFAULT_TIP_LAMPORTS);
58
- // 根据优先级增加(1-10 映射到 1x - 3x)
59
- const priorityMultiplier = 1 + (priority / 10) * 2;
60
- const tip = BigInt(Math.floor(Number(baseTip) * priorityMultiplier));
61
- // 确保不低于最小值
62
- return tip < BigInt(NOZOMI_CONFIG.MIN_TIP_LAMPORTS)
63
- ? BigInt(NOZOMI_CONFIG.MIN_TIP_LAMPORTS)
64
- : tip;
65
- }
66
- /**
67
- * Nozomi Tip 金额预设
68
- */
69
- export const NOZOMI_TIP_PRESETS = {
70
- /** 最低 tip (0.001 SOL) */
71
- LOW: BigInt(1000000),
72
- /** 标准 tip (0.001 SOL) */
73
- STANDARD: BigInt(1000000),
74
- /** 中等 tip (0.002 SOL) */
75
- MEDIUM: BigInt(2000000),
76
- /** 高 tip (0.005 SOL) */
77
- HIGH: BigInt(5000000),
78
- /** 紧急 tip (0.01 SOL) */
79
- URGENT: BigInt(10000000),
80
- };
@@ -1,96 +0,0 @@
1
- /**
2
- * Nozomi 类型定义
3
- * @module sol/nozomi/types
4
- */
5
- /**
6
- * Nozomi 区域
7
- */
8
- export type NozomiRegion = 'auto' | 'pit' | 'tyo' | 'sgp' | 'ewr' | 'ams' | 'fra';
9
- /**
10
- * Nozomi 客户端配置
11
- */
12
- export interface NozomiClientConfig {
13
- /** 最快提交 API Key */
14
- apiKeyFast: string;
15
- /** MEV 保护 API Key (可选,如果不提供则使用 apiKeyFast) */
16
- apiKeyMev?: string;
17
- /** 默认区域 */
18
- defaultRegion?: NozomiRegion;
19
- /** 默认是否使用 MEV 保护 */
20
- defaultUseMevProtection?: boolean;
21
- /** 请求超时(毫秒) */
22
- timeout?: number;
23
- }
24
- /**
25
- * Nozomi 发送选项
26
- */
27
- export interface NozomiSendOptions {
28
- /** 是否使用 MEV 保护 */
29
- useMevProtection?: boolean;
30
- /** 区域节点 */
31
- region?: NozomiRegion;
32
- /** 是否跳过预检 */
33
- skipPreflight?: boolean;
34
- /** 最大重试次数(Nozomi 内部重试) */
35
- maxRetries?: number;
36
- }
37
- /**
38
- * Nozomi 发送结果
39
- */
40
- export interface NozomiSendResult {
41
- /** 是否成功 */
42
- success: boolean;
43
- /** 交易签名 */
44
- signature?: string;
45
- /** 错误信息 */
46
- error?: string;
47
- /** 延迟(毫秒) */
48
- latency?: number;
49
- }
50
- /**
51
- * Nozomi 批量发送结果
52
- */
53
- export interface NozomiBatchSendResult {
54
- /** 总数 */
55
- total: number;
56
- /** 成功数 */
57
- successCount: number;
58
- /** 失败数 */
59
- failCount: number;
60
- /** 各交易结果 */
61
- results: NozomiSendResult[];
62
- /** 总耗时(毫秒) */
63
- totalLatency: number;
64
- }
65
- /**
66
- * 交易构建选项
67
- */
68
- export interface NozomiTransactionBuildOptions {
69
- /** 是否添加 Nozomi Tip */
70
- addTip?: boolean;
71
- /** Tip 金额(lamports),默认 0.001 SOL */
72
- tipLamports?: bigint;
73
- /** 指定 Tip 账户,默认随机选择 */
74
- tipAccount?: string;
75
- /** 计算单元限制 */
76
- computeUnitLimit?: number;
77
- /** 计算单元价格(microlamports),建议 1,000,000 */
78
- computeUnitPrice?: number;
79
- }
80
- /**
81
- * Nozomi RPC 错误
82
- */
83
- export interface NozomiRpcError {
84
- code: number;
85
- message: string;
86
- data?: string;
87
- }
88
- /**
89
- * Nozomi RPC 响应
90
- */
91
- export interface NozomiRpcResponse<T = string> {
92
- jsonrpc: string;
93
- id: number;
94
- result?: T;
95
- error?: NozomiRpcError;
96
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Nozomi 类型定义
3
- * @module sol/nozomi/types
4
- */
5
- export {};
@@ -1,115 +0,0 @@
1
- /**
2
- * 完整代币创建流程
3
- * 包括:上传元数据 → 创建 Mint → 创建 Metadata → Mint 初始供应
4
- * @module sol/token/create-complete
5
- */
6
- import { Connection, Keypair, PublicKey } from '@solana/web3.js';
7
- import type { TokenStandard } from './types.js';
8
- /**
9
- * 完整代币创建参数
10
- */
11
- export interface CreateTokenCompleteParams {
12
- /** 代币名称 */
13
- name: string;
14
- /** 代币符号 */
15
- symbol: string;
16
- /** 代币描述 */
17
- description: string;
18
- /** 精度(小数位数) */
19
- decimals: number;
20
- /** 初始供应量(不含精度,如 1000000 表示 100万) */
21
- initialSupply: bigint;
22
- /** 图片 Buffer(用于上传 IPFS) */
23
- imageBuffer?: Buffer | Uint8Array;
24
- /** 图片 File 对象(浏览器环境) */
25
- imageFile?: File;
26
- /** 已上传的元数据 CID(如果已有,则不需要上传) */
27
- metadataCid?: string;
28
- /** 创建者 Keypair */
29
- creator: Keypair;
30
- /** Mint 权限(默认为 creator) */
31
- mintAuthority?: PublicKey;
32
- /** 冻结权限(null 表示不可冻结) */
33
- freezeAuthority?: PublicKey | null;
34
- /** 代币标准(默认 TOKEN_2022) */
35
- tokenStandard?: TokenStandard;
36
- /** 社交链接 */
37
- social?: {
38
- telegram?: string;
39
- twitter?: string;
40
- website?: string;
41
- };
42
- }
43
- /**
44
- * 完整代币创建结果
45
- */
46
- export interface CreateTokenCompleteResult {
47
- success: boolean;
48
- /** Mint 地址 */
49
- mint?: string;
50
- /** Mint Keypair(需要保存用于后续操作) */
51
- mintKeypair?: Keypair;
52
- /** Metadata 账户地址 */
53
- metadataAddress?: string;
54
- /** 元数据 URI(IPFS) */
55
- metadataUri?: string;
56
- /** 创建者 ATA 地址 */
57
- creatorAta?: string;
58
- /** 签名后的交易列表(按顺序提交) */
59
- signedTransactions?: Array<{
60
- data: string;
61
- signature: string;
62
- description: string;
63
- }>;
64
- /** blockhash */
65
- recentBlockhash?: string;
66
- /** 最后有效区块高度 */
67
- lastValidBlockHeight?: number;
68
- /** 错误信息 */
69
- error?: string;
70
- }
71
- /**
72
- * 创建完整代币(上传元数据 + 创建 Mint + 创建 Metadata + Mint 初始供应)
73
- *
74
- * 流程:
75
- * 1. 上传图片和元数据到 IPFS(使用 Flap 官方接口)
76
- * 2. 创建 Mint 账户 + Mint 初始供应量
77
- * 3. 创建 Metaplex Metadata 账户
78
- *
79
- * @param connection Solana 连接
80
- * @param params 创建参数
81
- */
82
- export declare function createTokenComplete(connection: Connection, params: CreateTokenCompleteParams): Promise<CreateTokenCompleteResult>;
83
- /**
84
- * 创建代币(不上传元数据,使用已有 URI)
85
- * 适用于元数据已经上传的情况
86
- */
87
- export declare function createTokenWithUri(connection: Connection, params: {
88
- name: string;
89
- symbol: string;
90
- metadataUri: string;
91
- decimals: number;
92
- initialSupply: bigint;
93
- creator: Keypair;
94
- mintAuthority?: PublicKey;
95
- freezeAuthority?: PublicKey | null;
96
- tokenStandard?: TokenStandard;
97
- }): Promise<CreateTokenCompleteResult>;
98
- /**
99
- * 将创建结果转换为后端 API 格式
100
- */
101
- export declare function toBackendCreateTokenRequest(result: CreateTokenCompleteResult): {
102
- mint: string;
103
- metadataAddress: string;
104
- metadataUri: string;
105
- imageUri?: string;
106
- creatorAta: string;
107
- transactions: Array<{
108
- data: string;
109
- signature: string;
110
- description: string;
111
- }>;
112
- recentBlockhash: string;
113
- lastValidBlockHeight: number;
114
- timestamp: number;
115
- } | null;