solforge 0.1.6 → 0.2.0

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 (194) hide show
  1. package/.agi/agi.sqlite +0 -0
  2. package/.claude/settings.local.json +9 -0
  3. package/.github/workflows/release-binaries.yml +133 -0
  4. package/.tmp/.787ebcdbf7b8fde8-00000000.hm +0 -0
  5. package/.tmp/.bffe6efebdf8aedc-00000000.hm +0 -0
  6. package/AGENTS.md +271 -0
  7. package/CLAUDE.md +106 -0
  8. package/PROJECT_STRUCTURE.md +124 -0
  9. package/README.md +367 -393
  10. package/SOLANA_KIT_GUIDE.md +251 -0
  11. package/SOLFORGE.md +119 -0
  12. package/biome.json +34 -0
  13. package/bun.lock +743 -0
  14. package/docs/bun-single-file-executable.md +585 -0
  15. package/docs/cli-plan.md +154 -0
  16. package/docs/data-indexing-plan.md +214 -0
  17. package/docs/gui-roadmap.md +202 -0
  18. package/drizzle/0000_friendly_millenium_guard.sql +53 -0
  19. package/drizzle/0001_stale_sentinels.sql +2 -0
  20. package/drizzle/meta/0000_snapshot.json +329 -0
  21. package/drizzle/meta/0001_snapshot.json +345 -0
  22. package/drizzle/meta/_journal.json +20 -0
  23. package/drizzle.config.ts +12 -0
  24. package/index.ts +21 -0
  25. package/mint.sh +47 -0
  26. package/package.json +45 -69
  27. package/postcss.config.js +6 -0
  28. package/rpc-server.ts.backup +519 -0
  29. package/server/index.ts +5 -0
  30. package/server/lib/base58.ts +33 -0
  31. package/server/lib/faucet.ts +110 -0
  32. package/server/lib/spl-token.ts +57 -0
  33. package/server/methods/TEMPLATE.md +117 -0
  34. package/server/methods/account/get-account-info.ts +90 -0
  35. package/server/methods/account/get-balance.ts +27 -0
  36. package/server/methods/account/get-multiple-accounts.ts +83 -0
  37. package/server/methods/account/get-parsed-account-info.ts +21 -0
  38. package/server/methods/account/index.ts +12 -0
  39. package/server/methods/account/parsers/index.ts +52 -0
  40. package/server/methods/account/parsers/loader-upgradeable.ts +66 -0
  41. package/server/methods/account/parsers/spl-token.ts +237 -0
  42. package/server/methods/account/parsers/system.ts +4 -0
  43. package/server/methods/account/request-airdrop.ts +219 -0
  44. package/server/methods/admin/adopt-mint-authority.ts +94 -0
  45. package/server/methods/admin/clone-program-accounts.ts +55 -0
  46. package/server/methods/admin/clone-program.ts +152 -0
  47. package/server/methods/admin/clone-token-accounts.ts +117 -0
  48. package/server/methods/admin/clone-token-mint.ts +82 -0
  49. package/server/methods/admin/create-mint.ts +114 -0
  50. package/server/methods/admin/create-token-account.ts +137 -0
  51. package/server/methods/admin/helpers.ts +70 -0
  52. package/server/methods/admin/index.ts +10 -0
  53. package/server/methods/admin/list-mints.ts +21 -0
  54. package/server/methods/admin/load-program.ts +52 -0
  55. package/server/methods/admin/mint-to.ts +278 -0
  56. package/server/methods/block/get-block-height.ts +5 -0
  57. package/server/methods/block/get-block.ts +35 -0
  58. package/server/methods/block/get-blocks-with-limit.ts +23 -0
  59. package/server/methods/block/get-latest-blockhash.ts +12 -0
  60. package/server/methods/block/get-slot.ts +5 -0
  61. package/server/methods/block/index.ts +6 -0
  62. package/server/methods/block/is-blockhash-valid.ts +23 -0
  63. package/server/methods/epoch/get-cluster-nodes.ts +17 -0
  64. package/server/methods/epoch/get-epoch-info.ts +16 -0
  65. package/server/methods/epoch/get-epoch-schedule.ts +15 -0
  66. package/server/methods/epoch/get-highest-snapshot-slot.ts +9 -0
  67. package/server/methods/epoch/get-leader-schedule.ts +8 -0
  68. package/server/methods/epoch/get-max-retransmit-slot.ts +9 -0
  69. package/server/methods/epoch/get-max-shred-insert-slot.ts +9 -0
  70. package/server/methods/epoch/get-slot-leader.ts +6 -0
  71. package/server/methods/epoch/get-slot-leaders.ts +9 -0
  72. package/server/methods/epoch/get-stake-activation.ts +9 -0
  73. package/server/methods/epoch/get-stake-minimum-delegation.ts +9 -0
  74. package/server/methods/epoch/get-vote-accounts.ts +19 -0
  75. package/server/methods/epoch/index.ts +13 -0
  76. package/server/methods/epoch/minimum-ledger-slot.ts +5 -0
  77. package/server/methods/fee/get-fee-calculator-for-blockhash.ts +12 -0
  78. package/server/methods/fee/get-fee-for-message.ts +8 -0
  79. package/server/methods/fee/get-fee-rate-governor.ts +16 -0
  80. package/server/methods/fee/get-fees.ts +14 -0
  81. package/server/methods/fee/get-recent-prioritization-fees.ts +22 -0
  82. package/server/methods/fee/index.ts +5 -0
  83. package/server/methods/get-address-lookup-table.ts +31 -0
  84. package/server/methods/index.ts +265 -0
  85. package/server/methods/performance/get-recent-performance-samples.ts +25 -0
  86. package/server/methods/performance/get-transaction-count.ts +5 -0
  87. package/server/methods/performance/index.ts +2 -0
  88. package/server/methods/program/get-block-commitment.ts +9 -0
  89. package/server/methods/program/get-block-production.ts +14 -0
  90. package/server/methods/program/get-block-time.ts +21 -0
  91. package/server/methods/program/get-blocks.ts +11 -0
  92. package/server/methods/program/get-first-available-block.ts +9 -0
  93. package/server/methods/program/get-genesis-hash.ts +6 -0
  94. package/server/methods/program/get-identity.ts +6 -0
  95. package/server/methods/program/get-inflation-governor.ts +15 -0
  96. package/server/methods/program/get-inflation-rate.ts +10 -0
  97. package/server/methods/program/get-inflation-reward.ts +12 -0
  98. package/server/methods/program/get-largest-accounts.ts +8 -0
  99. package/server/methods/program/get-parsed-program-accounts.ts +12 -0
  100. package/server/methods/program/get-parsed-token-accounts-by-delegate.ts +12 -0
  101. package/server/methods/program/get-parsed-token-accounts-by-owner.ts +12 -0
  102. package/server/methods/program/get-program-accounts.ts +221 -0
  103. package/server/methods/program/get-supply.ts +13 -0
  104. package/server/methods/program/get-token-account-balance.ts +64 -0
  105. package/server/methods/program/get-token-accounts-by-delegate.ts +81 -0
  106. package/server/methods/program/get-token-accounts-by-owner.ts +390 -0
  107. package/server/methods/program/get-token-largest-accounts.ts +80 -0
  108. package/server/methods/program/get-token-supply.ts +38 -0
  109. package/server/methods/program/index.ts +21 -0
  110. package/server/methods/solforge/index.ts +155 -0
  111. package/server/methods/system/get-health.ts +5 -0
  112. package/server/methods/system/get-minimum-balance-for-rent-exemption.ts +13 -0
  113. package/server/methods/system/get-version.ts +9 -0
  114. package/server/methods/system/index.ts +3 -0
  115. package/server/methods/transaction/get-confirmed-transaction.ts +11 -0
  116. package/server/methods/transaction/get-parsed-transaction.ts +21 -0
  117. package/server/methods/transaction/get-signature-statuses.ts +72 -0
  118. package/server/methods/transaction/get-signatures-for-address.ts +45 -0
  119. package/server/methods/transaction/get-transaction.ts +428 -0
  120. package/server/methods/transaction/index.ts +7 -0
  121. package/server/methods/transaction/send-transaction.ts +232 -0
  122. package/server/methods/transaction/simulate-transaction.ts +56 -0
  123. package/server/rpc-server.ts +474 -0
  124. package/server/types.ts +74 -0
  125. package/server/ws-server.ts +171 -0
  126. package/sf.config.json +38 -0
  127. package/src/cli/bootstrap.ts +67 -0
  128. package/src/cli/commands/airdrop.ts +37 -0
  129. package/src/cli/commands/config.ts +39 -0
  130. package/src/cli/commands/mint.ts +187 -0
  131. package/src/cli/commands/program-clone.ts +124 -0
  132. package/src/cli/commands/program-load.ts +64 -0
  133. package/src/cli/commands/rpc-start.ts +46 -0
  134. package/src/cli/commands/token-adopt-authority.ts +37 -0
  135. package/src/cli/commands/token-clone.ts +113 -0
  136. package/src/cli/commands/token-create.ts +81 -0
  137. package/src/cli/main.ts +130 -0
  138. package/src/cli/run-solforge.ts +98 -0
  139. package/src/cli/setup-utils.ts +54 -0
  140. package/src/cli/setup-wizard.ts +256 -0
  141. package/src/cli/utils/args.ts +15 -0
  142. package/src/config/index.ts +130 -0
  143. package/src/db/index.ts +83 -0
  144. package/src/db/schema/accounts.ts +23 -0
  145. package/src/db/schema/address-signatures.ts +31 -0
  146. package/src/db/schema/index.ts +5 -0
  147. package/src/db/schema/meta-kv.ts +9 -0
  148. package/src/db/schema/transactions.ts +29 -0
  149. package/src/db/schema/tx-accounts.ts +33 -0
  150. package/src/db/tx-store.ts +229 -0
  151. package/src/gui/public/app.css +1 -0
  152. package/src/gui/public/index.html +19 -0
  153. package/src/gui/server.ts +297 -0
  154. package/src/gui/src/api.ts +127 -0
  155. package/src/gui/src/app.tsx +390 -0
  156. package/src/gui/src/components/airdrop-mint-form.tsx +216 -0
  157. package/src/gui/src/components/clone-program-modal.tsx +183 -0
  158. package/src/gui/src/components/clone-token-modal.tsx +211 -0
  159. package/src/gui/src/components/modal.tsx +127 -0
  160. package/src/gui/src/components/programs-panel.tsx +112 -0
  161. package/src/gui/src/components/status-panel.tsx +122 -0
  162. package/src/gui/src/components/tokens-panel.tsx +116 -0
  163. package/src/gui/src/hooks/use-interval.ts +17 -0
  164. package/src/gui/src/index.css +529 -0
  165. package/src/gui/src/main.tsx +17 -0
  166. package/src/migrations-bundled.ts +17 -0
  167. package/src/rpc/start.ts +44 -0
  168. package/tailwind.config.js +27 -0
  169. package/test-client.ts +120 -0
  170. package/tmp/inspect-html.ts +4 -0
  171. package/tmp/response-test.ts +5 -0
  172. package/tmp/test-html.ts +5 -0
  173. package/tmp/test-server.ts +13 -0
  174. package/tsconfig.json +24 -23
  175. package/LICENSE +0 -21
  176. package/scripts/postinstall.cjs +0 -103
  177. package/src/api-server-entry.ts +0 -109
  178. package/src/commands/add-program.ts +0 -337
  179. package/src/commands/init.ts +0 -122
  180. package/src/commands/list.ts +0 -136
  181. package/src/commands/mint.ts +0 -336
  182. package/src/commands/start.ts +0 -878
  183. package/src/commands/status.ts +0 -99
  184. package/src/commands/stop.ts +0 -406
  185. package/src/config/manager.ts +0 -157
  186. package/src/index.ts +0 -188
  187. package/src/services/api-server.ts +0 -532
  188. package/src/services/port-manager.ts +0 -177
  189. package/src/services/process-registry.ts +0 -154
  190. package/src/services/program-cloner.ts +0 -317
  191. package/src/services/token-cloner.ts +0 -809
  192. package/src/services/validator.ts +0 -295
  193. package/src/types/config.ts +0 -110
  194. package/src/utils/shell.ts +0 -110
@@ -0,0 +1,22 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getRecentPrioritizationFees: RpcMethodHandler = (
4
+ id,
5
+ params,
6
+ context,
7
+ ) => {
8
+ const addresses = params?.[0] || [];
9
+ const fees =
10
+ addresses.length > 0
11
+ ? addresses.map(() => ({
12
+ slot: Number(context.slot),
13
+ prioritizationFee: 0,
14
+ }))
15
+ : Array(150)
16
+ .fill(null)
17
+ .map((_, i) => ({
18
+ slot: Math.max(0, Number(context.slot) - i),
19
+ prioritizationFee: 0,
20
+ }));
21
+ return context.createSuccessResponse(id, fees);
22
+ };
@@ -0,0 +1,5 @@
1
+ export { getFeeCalculatorForBlockhash } from "./get-fee-calculator-for-blockhash";
2
+ export { getFeeForMessage } from "./get-fee-for-message";
3
+ export { getFeeRateGovernor } from "./get-fee-rate-governor";
4
+ export { getFees } from "./get-fees";
5
+ export { getRecentPrioritizationFees } from "./get-recent-prioritization-fees";
@@ -0,0 +1,31 @@
1
+ import type { RpcMethodHandler } from "../types";
2
+
3
+ export const getAddressLookupTable: RpcMethodHandler = (
4
+ id,
5
+ params,
6
+ context,
7
+ ) => {
8
+ try {
9
+ const [arg] = params || [];
10
+ const address: string =
11
+ typeof arg === "string" ? arg : arg?.accountKey || arg?.address;
12
+ if (!address || typeof address !== "string") {
13
+ throw new Error("Missing address");
14
+ }
15
+ const bytes = context.decodeBase58(address);
16
+ if (!(bytes instanceof Uint8Array) || bytes.length !== 32) {
17
+ throw new Error("Invalid address length");
18
+ }
19
+ return context.createSuccessResponse(id, {
20
+ context: { slot: Number(context.slot) },
21
+ value: null,
22
+ });
23
+ } catch (error: any) {
24
+ return context.createErrorResponse(
25
+ id,
26
+ -32602,
27
+ "Invalid params",
28
+ error.message,
29
+ );
30
+ }
31
+ };
@@ -0,0 +1,265 @@
1
+ import type { RpcMethodHandler } from "../types";
2
+
3
+ // Account methods are now in a subdirectory for better organization
4
+ import {
5
+ getAccountInfo,
6
+ getBalance,
7
+ getMultipleAccounts,
8
+ getParsedAccountInfo,
9
+ requestAirdrop,
10
+ } from "./account";
11
+ import {
12
+ solforgeAdminCloneProgram,
13
+ solforgeAdminCloneProgramAccounts,
14
+ solforgeAdminCloneTokenAccounts,
15
+ solforgeAdminCloneTokenMint,
16
+ solforgeAdoptMintAuthority,
17
+ solforgeCreateMint,
18
+ solforgeCreateTokenAccount,
19
+ solforgeListMints,
20
+ solforgeLoadProgram,
21
+ solforgeMintTo,
22
+ } from "./admin";
23
+
24
+ import {
25
+ getBlock,
26
+ getBlockHeight,
27
+ getBlocksWithLimit,
28
+ getLatestBlockhash,
29
+ getSlot,
30
+ isBlockhashValid,
31
+ } from "./block";
32
+ import {
33
+ getClusterNodes,
34
+ getEpochInfo,
35
+ getEpochSchedule,
36
+ getHighestSnapshotSlot,
37
+ getLeaderSchedule,
38
+ getMaxRetransmitSlot,
39
+ getMaxShredInsertSlot,
40
+ getSlotLeader,
41
+ getSlotLeaders,
42
+ getStakeActivation,
43
+ getStakeMinimumDelegation,
44
+ getVoteAccounts,
45
+ minimumLedgerSlot,
46
+ } from "./epoch";
47
+ import {
48
+ getFeeCalculatorForBlockhash,
49
+ getFeeForMessage,
50
+ getFeeRateGovernor,
51
+ getFees,
52
+ getRecentPrioritizationFees,
53
+ } from "./fee";
54
+ import { getAddressLookupTable } from "./get-address-lookup-table";
55
+ import {
56
+ getRecentPerformanceSamples,
57
+ getTransactionCount,
58
+ } from "./performance";
59
+ import {
60
+ getBlockCommitment,
61
+ getBlockProduction,
62
+ getBlocks,
63
+ getBlockTime,
64
+ getFirstAvailableBlock,
65
+ getGenesisHash,
66
+ getIdentity,
67
+ getInflationGovernor,
68
+ getInflationRate,
69
+ getInflationReward,
70
+ getLargestAccounts,
71
+ getParsedProgramAccounts,
72
+ getParsedTokenAccountsByDelegate,
73
+ getParsedTokenAccountsByOwner,
74
+ getProgramAccounts,
75
+ getSupply,
76
+ getTokenAccountBalance,
77
+ getTokenAccountsByDelegate,
78
+ getTokenAccountsByOwner,
79
+ getTokenLargestAccounts,
80
+ getTokenSupply,
81
+ } from "./program";
82
+ import {
83
+ solforgeGetStatus,
84
+ solforgeListPrograms,
85
+ solforgeListTokensDetailed,
86
+ } from "./solforge";
87
+ import {
88
+ getHealth,
89
+ getMinimumBalanceForRentExemption,
90
+ getVersion,
91
+ } from "./system";
92
+ import {
93
+ getConfirmedTransaction,
94
+ getParsedTransaction,
95
+ getSignatureStatuses,
96
+ getSignaturesForAddress,
97
+ getTransaction,
98
+ sendTransaction,
99
+ simulateTransaction,
100
+ } from "./transaction";
101
+
102
+ export const rpcMethods: Record<string, RpcMethodHandler> = {
103
+ // Account methods
104
+ getAccountInfo,
105
+ getBalance,
106
+ getMultipleAccounts,
107
+ requestAirdrop,
108
+ getParsedAccountInfo,
109
+
110
+ // Transaction methods
111
+ sendTransaction,
112
+ simulateTransaction,
113
+ getTransaction,
114
+ getParsedTransaction,
115
+ getSignatureStatuses,
116
+ getSignaturesForAddress,
117
+ getConfirmedTransaction,
118
+
119
+ // Block methods
120
+ getLatestBlockhash,
121
+ getSlot,
122
+ getBlockHeight,
123
+ isBlockhashValid,
124
+ getBlock,
125
+ getBlocksWithLimit,
126
+
127
+ // System methods
128
+ getMinimumBalanceForRentExemption,
129
+ getHealth,
130
+ getVersion,
131
+ // Program/network info methods
132
+ getBlockTime,
133
+ getBlocks,
134
+ getFirstAvailableBlock,
135
+ getGenesisHash,
136
+ getIdentity,
137
+ getInflationGovernor,
138
+ getInflationRate,
139
+ getInflationReward,
140
+ getSupply,
141
+ getBlockProduction,
142
+ getParsedProgramAccounts,
143
+ getProgramAccounts,
144
+ getTokenAccountBalance,
145
+ getTokenAccountsByOwner,
146
+ getTokenAccountsByDelegate,
147
+ getParsedTokenAccountsByOwner,
148
+ getParsedTokenAccountsByDelegate,
149
+ getTokenLargestAccounts,
150
+ getTokenSupply,
151
+ getBlockCommitment,
152
+ getLargestAccounts,
153
+
154
+ // Epoch/cluster methods
155
+ getEpochSchedule,
156
+ getEpochInfo,
157
+ getLeaderSchedule,
158
+ getSlotLeader,
159
+ getSlotLeaders,
160
+ getVoteAccounts,
161
+ getClusterNodes,
162
+ getStakeActivation,
163
+ getMaxRetransmitSlot,
164
+ getHighestSnapshotSlot,
165
+ minimumLedgerSlot,
166
+ getStakeMinimumDelegation,
167
+ getMaxShredInsertSlot,
168
+ // Performance metrics
169
+ getRecentPerformanceSamples,
170
+ getTransactionCount,
171
+ getAddressLookupTable,
172
+
173
+ // Fee methods
174
+ getRecentPrioritizationFees,
175
+ getFeeForMessage,
176
+ getFees,
177
+ getFeeCalculatorForBlockhash,
178
+ getFeeRateGovernor,
179
+
180
+ // Solforge helpers
181
+ solforgeGetStatus,
182
+ solforgeListPrograms,
183
+ solforgeListTokensDetailed,
184
+ };
185
+
186
+ // Admin methods (gated by SOLFORGE_ADMIN=1)
187
+ export const adminMethods: Record<string, RpcMethodHandler> = {
188
+ solforgeAdminCloneProgram,
189
+ solforgeAdminCloneProgramAccounts,
190
+ solforgeAdminCloneTokenMint,
191
+ solforgeAdminCloneTokenAccounts,
192
+ solforgeCreateTokenAccount,
193
+ solforgeLoadProgram,
194
+ solforgeCreateMint,
195
+ solforgeListMints,
196
+ solforgeMintTo,
197
+ solforgeAdoptMintAuthority,
198
+ };
199
+
200
+ Object.assign(rpcMethods, adminMethods);
201
+
202
+ export {
203
+ getAccountInfo,
204
+ getBalance,
205
+ getMultipleAccounts,
206
+ requestAirdrop,
207
+ sendTransaction,
208
+ simulateTransaction,
209
+ getTransaction,
210
+ getSignatureStatuses,
211
+ getSignaturesForAddress,
212
+ getConfirmedTransaction,
213
+ getLatestBlockhash,
214
+ getSlot,
215
+ getBlockHeight,
216
+ isBlockhashValid,
217
+ getBlock,
218
+ getBlocksWithLimit,
219
+ getMinimumBalanceForRentExemption,
220
+ getHealth,
221
+ getVersion,
222
+ getBlockTime,
223
+ getBlocks,
224
+ getFirstAvailableBlock,
225
+ getGenesisHash,
226
+ getIdentity,
227
+ getInflationGovernor,
228
+ getInflationRate,
229
+ getInflationReward,
230
+ getSupply,
231
+ getBlockProduction,
232
+ getParsedProgramAccounts,
233
+ getProgramAccounts,
234
+ getTokenAccountBalance,
235
+ getTokenAccountsByOwner,
236
+ getTokenAccountsByDelegate,
237
+ getTokenLargestAccounts,
238
+ getTokenSupply,
239
+ getBlockCommitment,
240
+ getLargestAccounts,
241
+ getEpochSchedule,
242
+ getEpochInfo,
243
+ getLeaderSchedule,
244
+ getSlotLeader,
245
+ getSlotLeaders,
246
+ getVoteAccounts,
247
+ getClusterNodes,
248
+ getStakeActivation,
249
+ getMaxRetransmitSlot,
250
+ getHighestSnapshotSlot,
251
+ minimumLedgerSlot,
252
+ getStakeMinimumDelegation,
253
+ getMaxShredInsertSlot,
254
+ getRecentPerformanceSamples,
255
+ getTransactionCount,
256
+ getAddressLookupTable,
257
+ solforgeGetStatus,
258
+ solforgeListPrograms,
259
+ solforgeListTokensDetailed,
260
+ getRecentPrioritizationFees,
261
+ getFeeForMessage,
262
+ getFees,
263
+ getFeeCalculatorForBlockhash,
264
+ getFeeRateGovernor,
265
+ };
@@ -0,0 +1,25 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ const SLOTS_PER_60S_SAMPLE = 150;
4
+
5
+ export const getRecentPerformanceSamples: RpcMethodHandler = (
6
+ id,
7
+ params,
8
+ context,
9
+ ) => {
10
+ const [limitRaw] = params || [];
11
+ const limit = Math.max(1, Math.min(Number(limitRaw ?? 1), 720));
12
+ const samples = Array.from({ length: limit }, (_v, i) => {
13
+ const slot = Math.max(0, Number(context.slot) - i * SLOTS_PER_60S_SAMPLE);
14
+ const numSlots = SLOTS_PER_60S_SAMPLE;
15
+ const totalTx = Number(context.getTxCount());
16
+ const estPerSample = Math.max(0, Math.min(totalTx, 5000));
17
+ return {
18
+ numSlots,
19
+ numTransactions: estPerSample,
20
+ samplePeriodSecs: 60,
21
+ slot,
22
+ };
23
+ });
24
+ return context.createSuccessResponse(id, samples);
25
+ };
@@ -0,0 +1,5 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getTransactionCount: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, Number(context.getTxCount()));
5
+ };
@@ -0,0 +1,2 @@
1
+ export { getRecentPerformanceSamples } from "./get-recent-performance-samples";
2
+ export { getTransactionCount } from "./get-transaction-count";
@@ -0,0 +1,9 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getBlockCommitment: RpcMethodHandler = (id, params, context) => {
4
+ const [_slot] = params || [];
5
+ return context.createSuccessResponse(id, {
6
+ commitment: [Number(context.slot), 0],
7
+ totalStake: 1000000000,
8
+ });
9
+ };
@@ -0,0 +1,14 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getBlockProduction: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ context: { slot: Number(context.slot) },
6
+ value: {
7
+ byIdentity: {},
8
+ range: {
9
+ firstSlot: 0,
10
+ lastSlot: Number(context.slot),
11
+ },
12
+ },
13
+ });
14
+ };
@@ -0,0 +1,21 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getBlockTime: RpcMethodHandler = async (id, params, context) => {
4
+ const [slot] = params || [];
5
+ // Prefer persisted time if available
6
+ try {
7
+ const fromDb = await context.store?.getBlockTimeForSlot(Number(slot));
8
+ if (typeof fromDb === "number") {
9
+ return context.createSuccessResponse(id, fromDb);
10
+ }
11
+ } catch {}
12
+
13
+ if (Number(slot) > Number(context.slot)) {
14
+ return context.createSuccessResponse(id, null);
15
+ }
16
+ const SLOT_TIME_MS = 400;
17
+ const currentTime = Math.floor(Date.now() / 1000);
18
+ const slotDiff = Number(context.slot) - Number(slot);
19
+ const blockTime = currentTime - Math.floor((slotDiff * SLOT_TIME_MS) / 1000);
20
+ return context.createSuccessResponse(id, blockTime);
21
+ };
@@ -0,0 +1,11 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getBlocks: RpcMethodHandler = (id, params, context) => {
4
+ const [startSlot, endSlot] = params || [];
5
+ const start = Number(startSlot || 0);
6
+ const end = Number(endSlot || context.slot);
7
+ const blocks: number[] = [];
8
+ for (let i = start; i <= end && i <= Number(context.slot); i++)
9
+ blocks.push(i);
10
+ return context.createSuccessResponse(id, blocks);
11
+ };
@@ -0,0 +1,9 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getFirstAvailableBlock: RpcMethodHandler = (
4
+ id,
5
+ _params,
6
+ _context,
7
+ ) => {
8
+ return { jsonrpc: "2.0", id, result: 0 };
9
+ };
@@ -0,0 +1,6 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getGenesisHash: RpcMethodHandler = (id, _params, _context) => {
4
+ const GENESIS_HASH = "11111111111111111111111111111111";
5
+ return { jsonrpc: "2.0", id, result: GENESIS_HASH };
6
+ };
@@ -0,0 +1,6 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getIdentity: RpcMethodHandler = (id, _params, _context) => {
4
+ const IDENTITY_PUBKEY = "11111111111111111111111111111111";
5
+ return { jsonrpc: "2.0", id, result: { identity: IDENTITY_PUBKEY } };
6
+ };
@@ -0,0 +1,15 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getInflationGovernor: RpcMethodHandler = (
4
+ id,
5
+ _params,
6
+ context,
7
+ ) => {
8
+ return context.createSuccessResponse(id, {
9
+ foundation: 0.05,
10
+ foundationTerm: 7,
11
+ initial: 0.15,
12
+ taper: 0.15,
13
+ terminal: 0.015,
14
+ });
15
+ };
@@ -0,0 +1,10 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getInflationRate: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ epoch: 0,
6
+ foundation: 0.05,
7
+ total: 0.15,
8
+ validator: 0.1,
9
+ });
10
+ };
@@ -0,0 +1,12 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getInflationReward: RpcMethodHandler = (id, params, context) => {
4
+ const [addresses] = params || [[]];
5
+ const rewards = (addresses || []).map(() => ({
6
+ amount: 0,
7
+ effectiveSlot: Number(context.slot),
8
+ epoch: 0,
9
+ postBalance: 1000000000,
10
+ }));
11
+ return context.createSuccessResponse(id, rewards);
12
+ };
@@ -0,0 +1,8 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getLargestAccounts: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ context: { slot: Number(context.slot) },
6
+ value: [],
7
+ });
8
+ };
@@ -0,0 +1,12 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+ import { getProgramAccounts } from "./get-program-accounts";
3
+
4
+ export const getParsedProgramAccounts: RpcMethodHandler = (
5
+ id,
6
+ params,
7
+ context,
8
+ ) => {
9
+ const [programId, config] = params || [];
10
+ const cfg = { ...(config || {}), encoding: "jsonParsed" };
11
+ return getProgramAccounts(id, [programId, cfg], context);
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+ import { getTokenAccountsByDelegate } from "./get-token-accounts-by-delegate";
3
+
4
+ export const getParsedTokenAccountsByDelegate: RpcMethodHandler = (
5
+ id,
6
+ params,
7
+ context,
8
+ ) => {
9
+ const [delegate, filter, config] = params || [];
10
+ const cfg = { ...(config || {}), encoding: "jsonParsed" };
11
+ return getTokenAccountsByDelegate(id, [delegate, filter, cfg], context);
12
+ };
@@ -0,0 +1,12 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+ import { getTokenAccountsByOwner } from "./get-token-accounts-by-owner";
3
+
4
+ export const getParsedTokenAccountsByOwner: RpcMethodHandler = (
5
+ id,
6
+ params,
7
+ context,
8
+ ) => {
9
+ const [owner, filter, config] = params || [];
10
+ const cfg = { ...(config || {}), encoding: "jsonParsed" };
11
+ return getTokenAccountsByOwner(id, [owner, filter, cfg], context);
12
+ };