solforge 0.2.8 → 0.2.10

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.
@@ -7,33 +7,33 @@ import { txAccounts } from "./schema/tx-accounts";
7
7
  import { txAccountStates } from "./schema/tx-account-states";
8
8
 
9
9
  export type InsertTxBundle = {
10
- signature: string;
11
- slot: number;
12
- blockTime?: number;
13
- version: 0 | "legacy";
14
- fee: number;
15
- err: unknown | null;
16
- rawBase64: string;
17
- preBalances: number[];
18
- postBalances: number[];
19
- logs: string[];
20
- innerInstructions?: unknown[];
21
- computeUnits?: number | bigint | null;
22
- returnData?: { programId: string; dataBase64: string } | null;
23
- accounts: Array<{
24
- address: string;
25
- index: number;
26
- signer: boolean;
27
- writable: boolean;
28
- programIdIndex?: number;
29
- }>;
30
- preTokenBalances?: unknown[];
31
- postTokenBalances?: unknown[];
32
- accountStates?: Array<{
33
- address: string;
34
- pre?: Partial<AccountSnapshot> | null;
35
- post?: Partial<AccountSnapshot> | null;
36
- }>;
10
+ signature: string;
11
+ slot: number;
12
+ blockTime?: number;
13
+ version: 0 | "legacy";
14
+ fee: number;
15
+ err: unknown | null;
16
+ rawBase64: string;
17
+ preBalances: number[];
18
+ postBalances: number[];
19
+ logs: string[];
20
+ innerInstructions?: unknown[];
21
+ computeUnits?: number | bigint | null;
22
+ returnData?: { programId: string; dataBase64: string } | null;
23
+ accounts: Array<{
24
+ address: string;
25
+ index: number;
26
+ signer: boolean;
27
+ writable: boolean;
28
+ programIdIndex?: number;
29
+ }>;
30
+ preTokenBalances?: unknown[];
31
+ postTokenBalances?: unknown[];
32
+ accountStates?: Array<{
33
+ address: string;
34
+ pre?: Partial<AccountSnapshot> | null;
35
+ post?: Partial<AccountSnapshot> | null;
36
+ }>;
37
37
  };
38
38
 
39
39
  export type AccountSnapshot = {
@@ -48,81 +48,79 @@ export type AccountSnapshot = {
48
48
  };
49
49
 
50
50
  export class TxStore {
51
- async insertTransactionBundle(bundle: InsertTxBundle): Promise<void> {
52
- const errJson = bundle.err ? JSON.stringify(bundle.err) : null;
53
- await db.transaction(async (tx) => {
54
- await tx
55
- .insert(transactions)
56
- .values({
57
- signature: bundle.signature,
58
- slot: bundle.slot,
59
- blockTime: bundle.blockTime ?? null,
60
- version: String(bundle.version),
61
- errJson,
62
- fee: bundle.fee,
63
- rawBase64: bundle.rawBase64,
64
- preBalancesJson: JSON.stringify(bundle.preBalances ?? []),
65
- postBalancesJson: JSON.stringify(bundle.postBalances ?? []),
66
- logsJson: JSON.stringify(bundle.logs ?? []),
67
- preTokenBalancesJson: JSON.stringify(bundle.preTokenBalances ?? []),
68
- postTokenBalancesJson: JSON.stringify(bundle.postTokenBalances ?? []),
69
- innerInstructionsJson: JSON.stringify(bundle.innerInstructions ?? []),
70
- computeUnits:
71
- bundle.computeUnits == null
72
- ? null
73
- : Number(bundle.computeUnits),
74
- returnDataProgramId: bundle.returnData?.programId ?? null,
75
- returnDataBase64: bundle.returnData?.dataBase64 ?? null,
76
- })
77
- .onConflictDoNothing();
51
+ async insertTransactionBundle(bundle: InsertTxBundle): Promise<void> {
52
+ const errJson = bundle.err ? JSON.stringify(bundle.err) : null;
53
+ await db.transaction(async (tx) => {
54
+ await tx
55
+ .insert(transactions)
56
+ .values({
57
+ signature: bundle.signature,
58
+ slot: bundle.slot,
59
+ blockTime: bundle.blockTime ?? null,
60
+ version: String(bundle.version),
61
+ errJson,
62
+ fee: bundle.fee,
63
+ rawBase64: bundle.rawBase64,
64
+ preBalancesJson: JSON.stringify(bundle.preBalances ?? []),
65
+ postBalancesJson: JSON.stringify(bundle.postBalances ?? []),
66
+ logsJson: JSON.stringify(bundle.logs ?? []),
67
+ preTokenBalancesJson: JSON.stringify(bundle.preTokenBalances ?? []),
68
+ postTokenBalancesJson: JSON.stringify(bundle.postTokenBalances ?? []),
69
+ innerInstructionsJson: JSON.stringify(bundle.innerInstructions ?? []),
70
+ computeUnits:
71
+ bundle.computeUnits == null ? null : Number(bundle.computeUnits),
72
+ returnDataProgramId: bundle.returnData?.programId ?? null,
73
+ returnDataBase64: bundle.returnData?.dataBase64 ?? null,
74
+ })
75
+ .onConflictDoNothing();
78
76
 
79
- if (Array.isArray(bundle.accounts) && bundle.accounts.length > 0) {
80
- await tx
81
- .insert(txAccounts)
82
- .values(
83
- bundle.accounts.map((a) => ({
84
- signature: bundle.signature,
85
- accountIndex: a.index,
86
- address: a.address,
87
- signer: a.signer ? 1 : 0,
88
- writable: a.writable ? 1 : 0,
89
- programIdIndex: a.programIdIndex ?? null,
90
- })),
91
- )
92
- .onConflictDoNothing();
77
+ if (Array.isArray(bundle.accounts) && bundle.accounts.length > 0) {
78
+ await tx
79
+ .insert(txAccounts)
80
+ .values(
81
+ bundle.accounts.map((a) => ({
82
+ signature: bundle.signature,
83
+ accountIndex: a.index,
84
+ address: a.address,
85
+ signer: a.signer ? 1 : 0,
86
+ writable: a.writable ? 1 : 0,
87
+ programIdIndex: a.programIdIndex ?? null,
88
+ })),
89
+ )
90
+ .onConflictDoNothing();
93
91
 
94
- await tx
95
- .insert(addressSignatures)
96
- .values(
97
- bundle.accounts.map((a) => ({
98
- address: a.address,
99
- signature: bundle.signature,
100
- slot: bundle.slot,
101
- err: errJson ? 1 : 0,
102
- blockTime: bundle.blockTime ?? null,
103
- })),
104
- )
105
- .onConflictDoNothing();
106
- }
92
+ await tx
93
+ .insert(addressSignatures)
94
+ .values(
95
+ bundle.accounts.map((a) => ({
96
+ address: a.address,
97
+ signature: bundle.signature,
98
+ slot: bundle.slot,
99
+ err: errJson ? 1 : 0,
100
+ blockTime: bundle.blockTime ?? null,
101
+ })),
102
+ )
103
+ .onConflictDoNothing();
104
+ }
107
105
 
108
- if (
109
- Array.isArray(bundle.accountStates) &&
110
- bundle.accountStates.length > 0
111
- ) {
112
- await tx
113
- .insert(txAccountStates)
114
- .values(
115
- bundle.accountStates.map((s) => ({
116
- signature: bundle.signature,
117
- address: s.address,
118
- preJson: s.pre ? JSON.stringify(s.pre) : null,
119
- postJson: s.post ? JSON.stringify(s.post) : null,
120
- })),
121
- )
122
- .onConflictDoNothing();
123
- }
124
- });
125
- }
106
+ if (
107
+ Array.isArray(bundle.accountStates) &&
108
+ bundle.accountStates.length > 0
109
+ ) {
110
+ await tx
111
+ .insert(txAccountStates)
112
+ .values(
113
+ bundle.accountStates.map((s) => ({
114
+ signature: bundle.signature,
115
+ address: s.address,
116
+ preJson: s.pre ? JSON.stringify(s.pre) : null,
117
+ postJson: s.post ? JSON.stringify(s.post) : null,
118
+ })),
119
+ )
120
+ .onConflictDoNothing();
121
+ }
122
+ });
123
+ }
126
124
 
127
125
  async upsertAccounts(snapshots: AccountSnapshot[]): Promise<void> {
128
126
  if (!Array.isArray(snapshots) || snapshots.length === 0) return;
@@ -13,11 +13,11 @@ import mig0001 from "../drizzle/0001_stale_sentinels.sql" with { type: "file" };
13
13
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
14
  // @ts-expect-error - Bun import attributes
15
15
  import mig0002 from "../drizzle/0002_graceful_caretaker.sql" with {
16
- type: "file",
16
+ type: "file",
17
17
  };
18
18
 
19
19
  export const bundledMigrations: Array<{ name: string; path: string }> = [
20
- { name: "0000_friendly_millenium_guard.sql", path: mig0000 },
21
- { name: "0001_stale_sentinels.sql", path: mig0001 },
22
- { name: "0002_graceful_caretaker.sql", path: mig0002 },
20
+ { name: "0000_friendly_millenium_guard.sql", path: mig0000 },
21
+ { name: "0001_stale_sentinels.sql", path: mig0001 },
22
+ { name: "0002_graceful_caretaker.sql", path: mig0002 },
23
23
  ];