solforge 0.1.7 → 0.2.1

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 (151) hide show
  1. package/README.md +367 -393
  2. package/docs/API.md +379 -0
  3. package/docs/CONFIGURATION.md +407 -0
  4. package/docs/bun-single-file-executable.md +585 -0
  5. package/docs/cli-plan.md +154 -0
  6. package/docs/data-indexing-plan.md +214 -0
  7. package/docs/gui-roadmap.md +202 -0
  8. package/package.json +38 -51
  9. package/server/index.ts +5 -0
  10. package/server/lib/base58.ts +33 -0
  11. package/server/lib/faucet.ts +110 -0
  12. package/server/lib/spl-token.ts +57 -0
  13. package/server/methods/TEMPLATE.md +117 -0
  14. package/server/methods/account/get-account-info.ts +90 -0
  15. package/server/methods/account/get-balance.ts +27 -0
  16. package/server/methods/account/get-multiple-accounts.ts +83 -0
  17. package/server/methods/account/get-parsed-account-info.ts +21 -0
  18. package/server/methods/account/index.ts +12 -0
  19. package/server/methods/account/parsers/index.ts +52 -0
  20. package/server/methods/account/parsers/loader-upgradeable.ts +66 -0
  21. package/server/methods/account/parsers/spl-token.ts +237 -0
  22. package/server/methods/account/parsers/system.ts +4 -0
  23. package/server/methods/account/request-airdrop.ts +219 -0
  24. package/server/methods/admin/adopt-mint-authority.ts +94 -0
  25. package/server/methods/admin/clone-program-accounts.ts +55 -0
  26. package/server/methods/admin/clone-program.ts +152 -0
  27. package/server/methods/admin/clone-token-accounts.ts +117 -0
  28. package/server/methods/admin/clone-token-mint.ts +82 -0
  29. package/server/methods/admin/create-mint.ts +114 -0
  30. package/server/methods/admin/create-token-account.ts +137 -0
  31. package/server/methods/admin/helpers.ts +70 -0
  32. package/server/methods/admin/index.ts +10 -0
  33. package/server/methods/admin/list-mints.ts +21 -0
  34. package/server/methods/admin/load-program.ts +52 -0
  35. package/server/methods/admin/mint-to.ts +278 -0
  36. package/server/methods/block/get-block-height.ts +5 -0
  37. package/server/methods/block/get-block.ts +35 -0
  38. package/server/methods/block/get-blocks-with-limit.ts +23 -0
  39. package/server/methods/block/get-latest-blockhash.ts +12 -0
  40. package/server/methods/block/get-slot.ts +5 -0
  41. package/server/methods/block/index.ts +6 -0
  42. package/server/methods/block/is-blockhash-valid.ts +23 -0
  43. package/server/methods/epoch/get-cluster-nodes.ts +17 -0
  44. package/server/methods/epoch/get-epoch-info.ts +16 -0
  45. package/server/methods/epoch/get-epoch-schedule.ts +15 -0
  46. package/server/methods/epoch/get-highest-snapshot-slot.ts +9 -0
  47. package/server/methods/epoch/get-leader-schedule.ts +8 -0
  48. package/server/methods/epoch/get-max-retransmit-slot.ts +9 -0
  49. package/server/methods/epoch/get-max-shred-insert-slot.ts +9 -0
  50. package/server/methods/epoch/get-slot-leader.ts +6 -0
  51. package/server/methods/epoch/get-slot-leaders.ts +9 -0
  52. package/server/methods/epoch/get-stake-activation.ts +9 -0
  53. package/server/methods/epoch/get-stake-minimum-delegation.ts +9 -0
  54. package/server/methods/epoch/get-vote-accounts.ts +19 -0
  55. package/server/methods/epoch/index.ts +13 -0
  56. package/server/methods/epoch/minimum-ledger-slot.ts +5 -0
  57. package/server/methods/fee/get-fee-calculator-for-blockhash.ts +12 -0
  58. package/server/methods/fee/get-fee-for-message.ts +8 -0
  59. package/server/methods/fee/get-fee-rate-governor.ts +16 -0
  60. package/server/methods/fee/get-fees.ts +14 -0
  61. package/server/methods/fee/get-recent-prioritization-fees.ts +22 -0
  62. package/server/methods/fee/index.ts +5 -0
  63. package/server/methods/get-address-lookup-table.ts +31 -0
  64. package/server/methods/index.ts +265 -0
  65. package/server/methods/performance/get-recent-performance-samples.ts +25 -0
  66. package/server/methods/performance/get-transaction-count.ts +5 -0
  67. package/server/methods/performance/index.ts +2 -0
  68. package/server/methods/program/get-block-commitment.ts +9 -0
  69. package/server/methods/program/get-block-production.ts +14 -0
  70. package/server/methods/program/get-block-time.ts +21 -0
  71. package/server/methods/program/get-blocks.ts +11 -0
  72. package/server/methods/program/get-first-available-block.ts +9 -0
  73. package/server/methods/program/get-genesis-hash.ts +6 -0
  74. package/server/methods/program/get-identity.ts +6 -0
  75. package/server/methods/program/get-inflation-governor.ts +15 -0
  76. package/server/methods/program/get-inflation-rate.ts +10 -0
  77. package/server/methods/program/get-inflation-reward.ts +12 -0
  78. package/server/methods/program/get-largest-accounts.ts +8 -0
  79. package/server/methods/program/get-parsed-program-accounts.ts +12 -0
  80. package/server/methods/program/get-parsed-token-accounts-by-delegate.ts +12 -0
  81. package/server/methods/program/get-parsed-token-accounts-by-owner.ts +12 -0
  82. package/server/methods/program/get-program-accounts.ts +221 -0
  83. package/server/methods/program/get-supply.ts +13 -0
  84. package/server/methods/program/get-token-account-balance.ts +64 -0
  85. package/server/methods/program/get-token-accounts-by-delegate.ts +81 -0
  86. package/server/methods/program/get-token-accounts-by-owner.ts +390 -0
  87. package/server/methods/program/get-token-largest-accounts.ts +80 -0
  88. package/server/methods/program/get-token-supply.ts +38 -0
  89. package/server/methods/program/index.ts +21 -0
  90. package/server/methods/solforge/index.ts +155 -0
  91. package/server/methods/system/get-health.ts +5 -0
  92. package/server/methods/system/get-minimum-balance-for-rent-exemption.ts +13 -0
  93. package/server/methods/system/get-version.ts +9 -0
  94. package/server/methods/system/index.ts +3 -0
  95. package/server/methods/transaction/get-confirmed-transaction.ts +11 -0
  96. package/server/methods/transaction/get-parsed-transaction.ts +21 -0
  97. package/server/methods/transaction/get-signature-statuses.ts +72 -0
  98. package/server/methods/transaction/get-signatures-for-address.ts +45 -0
  99. package/server/methods/transaction/get-transaction.ts +428 -0
  100. package/server/methods/transaction/index.ts +7 -0
  101. package/server/methods/transaction/send-transaction.ts +232 -0
  102. package/server/methods/transaction/simulate-transaction.ts +56 -0
  103. package/server/rpc-server.ts +474 -0
  104. package/server/types.ts +74 -0
  105. package/server/ws-server.ts +171 -0
  106. package/src/cli/bootstrap.ts +67 -0
  107. package/src/cli/commands/airdrop.ts +37 -0
  108. package/src/cli/commands/config.ts +39 -0
  109. package/src/cli/commands/mint.ts +187 -0
  110. package/src/cli/commands/program-clone.ts +124 -0
  111. package/src/cli/commands/program-load.ts +64 -0
  112. package/src/cli/commands/rpc-start.ts +46 -0
  113. package/src/cli/commands/token-adopt-authority.ts +37 -0
  114. package/src/cli/commands/token-clone.ts +113 -0
  115. package/src/cli/commands/token-create.ts +81 -0
  116. package/src/cli/main.ts +130 -0
  117. package/src/cli/run-solforge.ts +98 -0
  118. package/src/cli/setup-utils.ts +54 -0
  119. package/src/cli/setup-wizard.ts +256 -0
  120. package/src/cli/utils/args.ts +15 -0
  121. package/src/config/index.ts +130 -0
  122. package/src/db/index.ts +83 -0
  123. package/src/db/schema/accounts.ts +23 -0
  124. package/src/db/schema/address-signatures.ts +31 -0
  125. package/src/db/schema/index.ts +5 -0
  126. package/src/db/schema/meta-kv.ts +9 -0
  127. package/src/db/schema/transactions.ts +29 -0
  128. package/src/db/schema/tx-accounts.ts +33 -0
  129. package/src/db/tx-store.ts +229 -0
  130. package/src/gui/public/app.css +1 -0
  131. package/src/gui/public/build/main.css +1 -0
  132. package/src/gui/public/build/main.js +303 -0
  133. package/src/gui/public/build/main.js.txt +231 -0
  134. package/src/gui/public/index.html +19 -0
  135. package/src/gui/server.ts +297 -0
  136. package/src/gui/src/api.ts +127 -0
  137. package/src/gui/src/app.tsx +390 -0
  138. package/src/gui/src/components/airdrop-mint-form.tsx +216 -0
  139. package/src/gui/src/components/clone-program-modal.tsx +183 -0
  140. package/src/gui/src/components/clone-token-modal.tsx +211 -0
  141. package/src/gui/src/components/modal.tsx +127 -0
  142. package/src/gui/src/components/programs-panel.tsx +112 -0
  143. package/src/gui/src/components/status-panel.tsx +122 -0
  144. package/src/gui/src/components/tokens-panel.tsx +116 -0
  145. package/src/gui/src/hooks/use-interval.ts +17 -0
  146. package/src/gui/src/index.css +529 -0
  147. package/src/gui/src/main.tsx +17 -0
  148. package/src/migrations-bundled.ts +17 -0
  149. package/src/rpc/start.ts +44 -0
  150. package/scripts/postinstall.cjs +0 -103
  151. package/tsconfig.json +0 -28
@@ -0,0 +1,19 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getVoteAccounts: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ current: [
6
+ {
7
+ votePubkey: "11111111111111111111111111111111",
8
+ nodePubkey: "11111111111111111111111111111111",
9
+ activatedStake: 1000000000,
10
+ epochVoteAccount: true,
11
+ commission: 0,
12
+ lastVote: Number(context.slot),
13
+ epochCredits: [[0, 1000, 0]],
14
+ rootSlot: Number(context.slot) - 1,
15
+ },
16
+ ],
17
+ delinquent: [],
18
+ });
19
+ };
@@ -0,0 +1,13 @@
1
+ export { getClusterNodes } from "./get-cluster-nodes";
2
+ export { getEpochInfo } from "./get-epoch-info";
3
+ export { getEpochSchedule } from "./get-epoch-schedule";
4
+ export { getHighestSnapshotSlot } from "./get-highest-snapshot-slot";
5
+ export { getLeaderSchedule } from "./get-leader-schedule";
6
+ export { getMaxRetransmitSlot } from "./get-max-retransmit-slot";
7
+ export { getMaxShredInsertSlot } from "./get-max-shred-insert-slot";
8
+ export { getSlotLeader } from "./get-slot-leader";
9
+ export { getSlotLeaders } from "./get-slot-leaders";
10
+ export { getStakeActivation } from "./get-stake-activation";
11
+ export { getStakeMinimumDelegation } from "./get-stake-minimum-delegation";
12
+ export { getVoteAccounts } from "./get-vote-accounts";
13
+ export { minimumLedgerSlot } from "./minimum-ledger-slot";
@@ -0,0 +1,5 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const minimumLedgerSlot: RpcMethodHandler = (id, _params, _context) => {
4
+ return { jsonrpc: "2.0", id, result: 0 };
5
+ };
@@ -0,0 +1,12 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getFeeCalculatorForBlockhash: RpcMethodHandler = (
4
+ id,
5
+ _params,
6
+ context,
7
+ ) => {
8
+ return context.createSuccessResponse(id, {
9
+ context: { slot: Number(context.slot) },
10
+ value: { feeCalculator: { lamportsPerSignature: 5000 } },
11
+ });
12
+ };
@@ -0,0 +1,8 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getFeeForMessage: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ context: { slot: Number(context.slot), apiVersion: "1.17.9" },
6
+ value: 5000,
7
+ });
8
+ };
@@ -0,0 +1,16 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getFeeRateGovernor: RpcMethodHandler = (id, _params, context) => {
4
+ return context.createSuccessResponse(id, {
5
+ context: { slot: Number(context.slot) },
6
+ value: {
7
+ feeRateGovernor: {
8
+ burnPercent: 50,
9
+ maxLamportsPerSignature: 100000,
10
+ minLamportsPerSignature: 5000,
11
+ targetLamportsPerSignature: 10000,
12
+ targetSignaturesPerSlot: 20000,
13
+ },
14
+ },
15
+ });
16
+ };
@@ -0,0 +1,14 @@
1
+ import type { RpcMethodHandler } from "../../types";
2
+
3
+ export const getFees: RpcMethodHandler = (id, _params, context) => {
4
+ const blockhash = context.svm.latestBlockhash();
5
+ return context.createSuccessResponse(id, {
6
+ context: { slot: Number(context.slot) },
7
+ value: {
8
+ blockhash,
9
+ feeCalculator: { lamportsPerSignature: 5000 },
10
+ lastValidSlot: Number(context.slot) + 150,
11
+ lastValidBlockHeight: Number(context.slot) + 150,
12
+ },
13
+ });
14
+ };
@@ -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
+ };