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.
- package/package.json +1 -1
- package/scripts/decode-b58.ts +5 -1
- package/server/lib/instruction-parser.ts +302 -238
- package/server/lib/parsers/spl-associated-token-account.ts +36 -30
- package/server/lib/parsers/spl-token.ts +310 -142
- package/server/methods/account/request-airdrop.ts +121 -105
- package/server/methods/admin/mint-to.ts +29 -14
- package/server/methods/transaction/get-transaction.ts +390 -326
- package/server/methods/transaction/inner-instructions.test.ts +91 -50
- package/server/methods/transaction/send-transaction.ts +269 -236
- package/server/rpc-server.ts +101 -104
- package/server/types.ts +56 -56
- package/src/db/schema/transactions.ts +29 -29
- package/src/db/schema/tx-account-states.ts +16 -14
- package/src/db/tx-store.ts +97 -99
- package/src/migrations-bundled.ts +4 -4
package/src/db/tx-store.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
16
|
+
type: "file",
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const bundledMigrations: Array<{ name: string; path: string }> = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
];
|