@solana/rpc-graphql 2.0.0-development → 2.0.0-experimental.021706b

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 (77) hide show
  1. package/README.md +1088 -30
  2. package/dist/index.browser.cjs +2657 -1942
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +2654 -1944
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.native.js +2654 -1940
  7. package/dist/index.native.js.map +1 -1
  8. package/dist/index.node.cjs +2657 -1938
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.js +2654 -1940
  11. package/dist/index.node.js.map +1 -1
  12. package/dist/types/context.d.ts +5 -19
  13. package/dist/types/context.d.ts.map +1 -0
  14. package/dist/types/index.d.ts +8 -1
  15. package/dist/types/index.d.ts.map +1 -0
  16. package/dist/types/loaders/account.d.ts +4 -0
  17. package/dist/types/loaders/account.d.ts.map +1 -0
  18. package/dist/types/loaders/block.d.ts +4 -0
  19. package/dist/types/loaders/block.d.ts.map +1 -0
  20. package/dist/types/loaders/index.d.ts +6 -0
  21. package/dist/types/loaders/index.d.ts.map +1 -0
  22. package/dist/types/loaders/loader.d.ts +63 -0
  23. package/dist/types/loaders/loader.d.ts.map +1 -0
  24. package/dist/types/loaders/program-accounts.d.ts +4 -0
  25. package/dist/types/loaders/program-accounts.d.ts.map +1 -0
  26. package/dist/types/loaders/transaction.d.ts +4 -0
  27. package/dist/types/loaders/transaction.d.ts.map +1 -0
  28. package/dist/types/resolvers/account.d.ts +114 -0
  29. package/dist/types/resolvers/account.d.ts.map +1 -0
  30. package/dist/types/resolvers/block.d.ts +20 -0
  31. package/dist/types/resolvers/block.d.ts.map +1 -0
  32. package/dist/types/resolvers/index.d.ts +3 -0
  33. package/dist/types/resolvers/index.d.ts.map +1 -0
  34. package/dist/types/resolvers/instruction.d.ts +948 -0
  35. package/dist/types/resolvers/instruction.d.ts.map +1 -0
  36. package/dist/types/resolvers/program-accounts.d.ts +10 -0
  37. package/dist/types/resolvers/program-accounts.d.ts.map +1 -0
  38. package/dist/types/resolvers/resolve-info.d.ts +3 -0
  39. package/dist/types/resolvers/resolve-info.d.ts.map +1 -0
  40. package/dist/types/resolvers/root.d.ts +3 -0
  41. package/dist/types/resolvers/root.d.ts.map +1 -0
  42. package/dist/types/resolvers/transaction.d.ts +19 -0
  43. package/dist/types/resolvers/transaction.d.ts.map +1 -0
  44. package/dist/types/resolvers/types.d.ts +94 -0
  45. package/dist/types/resolvers/types.d.ts.map +1 -0
  46. package/dist/types/schema/account.d.ts +2 -0
  47. package/dist/types/schema/account.d.ts.map +1 -0
  48. package/dist/types/schema/block.d.ts +2 -0
  49. package/dist/types/schema/block.d.ts.map +1 -0
  50. package/dist/types/schema/index.d.ts +2 -0
  51. package/dist/types/schema/index.d.ts.map +1 -0
  52. package/dist/types/schema/instruction.d.ts +2 -0
  53. package/dist/types/schema/instruction.d.ts.map +1 -0
  54. package/dist/types/schema/root.d.ts +2 -0
  55. package/dist/types/schema/root.d.ts.map +1 -0
  56. package/dist/types/schema/transaction.d.ts +2 -0
  57. package/dist/types/schema/transaction.d.ts.map +1 -0
  58. package/dist/types/schema/types.d.ts +2 -0
  59. package/dist/types/schema/types.d.ts.map +1 -0
  60. package/package.json +13 -37
  61. package/dist/types/cache.d.ts +0 -7
  62. package/dist/types/rpc.d.ts +0 -13
  63. package/dist/types/schema/account/index.d.ts +0 -3
  64. package/dist/types/schema/account/query.d.ts +0 -38
  65. package/dist/types/schema/account/types.d.ts +0 -5
  66. package/dist/types/schema/block/index.d.ts +0 -3
  67. package/dist/types/schema/block/query.d.ts +0 -42
  68. package/dist/types/schema/block/types.d.ts +0 -7
  69. package/dist/types/schema/inputs.d.ts +0 -9
  70. package/dist/types/schema/picks.d.ts +0 -36
  71. package/dist/types/schema/program-accounts/index.d.ts +0 -2
  72. package/dist/types/schema/program-accounts/query.d.ts +0 -47
  73. package/dist/types/schema/program-accounts/types.d.ts +0 -3
  74. package/dist/types/schema/scalars.d.ts +0 -3
  75. package/dist/types/schema/transaction/index.d.ts +0 -3
  76. package/dist/types/schema/transaction/query.d.ts +0 -33
  77. package/dist/types/schema/transaction/types.d.ts +0 -12
@@ -1,2198 +1,2908 @@
1
- import { GraphQLSchema, GraphQLObjectType, graphql, GraphQLList, GraphQLBoolean, GraphQLString, GraphQLNonNull, GraphQLEnumType, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLScalarType, Kind, GraphQLInt, GraphQLUnionType } from 'graphql';
1
+ import { makeExecutableSchema } from '@graphql-tools/schema';
2
+ import { graphql, Kind } from 'graphql';
3
+ import DataLoader from 'dataloader';
4
+ import stringify from 'json-stable-stringify';
2
5
 
3
- // src/rpc.ts
4
-
5
- // src/cache.ts
6
- var stringifyValue = (value) => JSON.stringify(value, (_, value2) => {
7
- if (typeof value2 === "bigint") {
8
- return value2.toString() + "n";
9
- }
10
- return value2;
11
- });
12
- var parseValue = (value) => JSON.parse(value, (_, value2) => {
13
- if (typeof value2 === "string" && /\d+n$/.test(value2)) {
14
- return BigInt(value2.slice(0, -1));
6
+ // src/index.ts
7
+ function replacer(_, value) {
8
+ if (typeof value === "bigint") {
9
+ return value.toString() + "n";
15
10
  }
16
- return value2;
17
- });
18
- var cacheKey = (key, variables) => `GraphQLCache:${stringifyValue(key)}:${stringifyValue(variables)}`;
19
- function createGraphQLCache() {
20
- return {
21
- // Browser
22
- flush: () => {
23
- for (let i = localStorage.length - 1; i >= 0; i--) {
24
- const storageKey = localStorage.key(i);
25
- if (storageKey && storageKey.startsWith("GraphQLCache:")) {
26
- localStorage.removeItem(storageKey);
27
- }
28
- }
29
- },
30
- get: (key, variables) => {
31
- const value = localStorage.getItem(cacheKey(key, variables));
32
- return value === null ? null : parseValue(value);
33
- },
34
- insert: (key, variables, value) => {
35
- localStorage.setItem(cacheKey(key, variables), stringifyValue(value));
36
- }
37
- } ;
11
+ return value;
38
12
  }
13
+ var cacheKeyFn = (obj) => stringify(obj, { replacer });
39
14
 
40
- // src/context.ts
41
- async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc) {
42
- const requestConfig = { encoding, ...config };
43
- const cached = cache.get(address, requestConfig);
44
- if (cached !== null) {
45
- return cached;
46
- }
47
- const account = await rpc.getAccountInfo(address, requestConfig).send().then((res) => res.value).catch((e) => {
48
- throw e;
49
- });
50
- if (account === null) {
51
- return null;
52
- }
53
- const [data, responseEncoding] = Array.isArray(account.data) ? encoding === "jsonParsed" ? [account.data[0], "base64"] : [account.data[0], encoding] : [account.data, "jsonParsed"];
54
- const queryResponse = {
55
- ...account,
56
- data,
57
- encoding: responseEncoding
15
+ // src/loaders/account.ts
16
+ function applyDefaultArgs({
17
+ address,
18
+ commitment,
19
+ dataSlice,
20
+ encoding = "jsonParsed",
21
+ minContextSlot
22
+ }) {
23
+ return {
24
+ address,
25
+ commitment,
26
+ dataSlice,
27
+ encoding,
28
+ minContextSlot
58
29
  };
59
- cache.insert(address, requestConfig, queryResponse);
60
- return queryResponse;
61
30
  }
62
- async function resolveBlock({ slot, encoding = "jsonParsed", ...config }, cache, rpc) {
63
- const requestConfig = { encoding, ...config };
64
- const cached = cache.get(slot, config);
65
- if (cached !== null) {
66
- return cached;
67
- }
68
- const block = await rpc.getBlock(slot, requestConfig).send();
69
- if (block === null) {
70
- return null;
71
- }
72
- cache.insert(slot, config, block);
73
- return block;
31
+ async function loadAccount(rpc, { address, ...config }) {
32
+ return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
74
33
  }
75
- async function resolveProgramAccounts({ programAddress, encoding = "jsonParsed", ...config }, cache, rpc) {
76
- const requestConfig = { encoding, ...config };
77
- const cached = cache.get(programAddress, requestConfig);
78
- if (cached !== null) {
79
- return cached;
80
- }
81
- const programAccounts = await rpc.getProgramAccounts(programAddress, requestConfig).send().then((res) => {
82
- if ("value" in res) {
83
- return res.value;
84
- }
85
- return res;
86
- }).catch((e) => {
87
- throw e;
88
- });
89
- const queryResponse = programAccounts.map((programAccount2) => {
90
- const [data, responseEncoding] = Array.isArray(programAccount2.account.data) ? encoding === "jsonParsed" ? [programAccount2.account.data[0], "base64"] : [programAccount2.account.data[0], encoding] : [programAccount2.account.data, "jsonParsed"];
91
- const pubkey = programAccount2.pubkey;
92
- const account = { ...programAccount2.account, data, encoding: responseEncoding };
93
- return {
94
- account,
95
- pubkey
96
- };
97
- });
98
- cache.insert(programAddress, requestConfig, queryResponse);
99
- return queryResponse;
34
+ function createAccountBatchLoadFn(rpc) {
35
+ const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
36
+ return async (accountQueryArgs) => {
37
+ return await Promise.all(
38
+ accountQueryArgs.map(async (args) => await resolveAccountUsingRpc(applyDefaultArgs(args)))
39
+ );
40
+ };
100
41
  }
101
- async function resolveTransaction({ signature, encoding = "jsonParsed", ...config }, cache, rpc) {
102
- const requestConfig = { encoding, ...config };
103
- const cached = cache.get(signature, requestConfig);
104
- if (cached !== null) {
105
- return cached;
106
- }
107
- const transaction = await rpc.getTransaction(signature, requestConfig).send();
108
- if (transaction === null) {
109
- return null;
110
- }
111
- const [transactionData, responseEncoding, responseFormat] = Array.isArray(transaction.transaction) ? encoding === "jsonParsed" ? [transaction.transaction[0], "base64", "unparsed"] : [transaction.transaction[0], encoding, "unparsed"] : encoding === "jsonParsed" ? [transaction.transaction, encoding, "parsed"] : [transaction.transaction, encoding, "unparsed"];
112
- if (transaction.meta) {
113
- transaction.meta["format"] = responseFormat;
114
- }
115
- if (transactionData.message) {
116
- transactionData.message["format"] = responseFormat;
117
- }
118
- const queryResponse = {
119
- ...transaction,
120
- encoding: responseEncoding,
121
- transaction: transactionData
42
+ function createAccountLoader(rpc) {
43
+ const loader = new DataLoader(createAccountBatchLoadFn(rpc), { cacheKeyFn });
44
+ return {
45
+ load: async (args) => loader.load(applyDefaultArgs(args))
122
46
  };
123
- cache.insert(signature, requestConfig, queryResponse);
124
- return queryResponse;
125
47
  }
126
- function createSolanaGraphQLContext(rpc) {
127
- const cache = createGraphQLCache();
48
+ function applyDefaultArgs2({
49
+ slot,
50
+ commitment,
51
+ encoding = "jsonParsed",
52
+ maxSupportedTransactionVersion = 0,
53
+ rewards,
54
+ transactionDetails = "full"
55
+ }) {
128
56
  return {
129
- cache,
130
- resolveAccount(args) {
131
- return resolveAccount(args, this.cache, this.rpc);
132
- },
133
- resolveBlock(args) {
134
- return resolveBlock(args, this.cache, this.rpc);
135
- },
136
- resolveProgramAccounts(args) {
137
- return resolveProgramAccounts(args, this.cache, this.rpc);
138
- },
139
- resolveTransaction(args) {
140
- return resolveTransaction(args, this.cache, this.rpc);
141
- },
142
- rpc
57
+ commitment,
58
+ encoding,
59
+ maxSupportedTransactionVersion,
60
+ rewards,
61
+ slot,
62
+ transactionDetails
143
63
  };
144
64
  }
145
- var BigIntScalar = () => new GraphQLScalarType({
146
- name: "BigInt",
147
- parseLiteral(ast) {
148
- if (ast.kind === Kind.STRING) {
149
- return BigInt(ast.value);
150
- }
151
- return null;
152
- },
153
- parseValue(value) {
154
- return BigInt(value);
155
- },
156
- serialize(value) {
157
- return BigInt(value);
158
- }
159
- });
160
-
161
- // src/schema/picks.ts
162
- function boolean() {
163
- return { type: GraphQLBoolean };
65
+ async function loadBlock(rpc, { slot, ...config }) {
66
+ return await rpc.getBlock(
67
+ slot,
68
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
69
+ config
70
+ ).send();
164
71
  }
165
- var memoisedBigint;
166
- function bigint() {
167
- if (!memoisedBigint)
168
- memoisedBigint = { type: BigIntScalar() };
169
- return memoisedBigint;
72
+ function createBlockBatchLoadFn(rpc) {
73
+ const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
74
+ return async (blockQueryArgs) => {
75
+ return await Promise.all(blockQueryArgs.map(async (args) => await resolveBlockUsingRpc(applyDefaultArgs2(args))));
76
+ };
77
+ }
78
+ function createBlockLoader(rpc) {
79
+ const loader = new DataLoader(createBlockBatchLoadFn(rpc), { cacheKeyFn });
80
+ return {
81
+ load: async (args) => loader.load(applyDefaultArgs2(args))
82
+ };
170
83
  }
171
- function number() {
172
- return { type: GraphQLInt };
84
+ function applyDefaultArgs3({
85
+ commitment,
86
+ dataSlice,
87
+ encoding = "jsonParsed",
88
+ filters,
89
+ minContextSlot,
90
+ programAddress
91
+ }) {
92
+ return {
93
+ commitment,
94
+ dataSlice,
95
+ encoding,
96
+ filters,
97
+ minContextSlot,
98
+ programAddress
99
+ };
173
100
  }
174
- function string() {
175
- return { type: GraphQLString };
101
+ async function loadProgramAccounts(rpc, { programAddress, ...config }) {
102
+ return await rpc.getProgramAccounts(
103
+ programAddress,
104
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
105
+ config
106
+ ).send();
107
+ }
108
+ function createProgramAccountsBatchLoadFn(rpc) {
109
+ const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
110
+ return async (programAccountsQueryArgs) => {
111
+ return await Promise.all(
112
+ programAccountsQueryArgs.map(async (args) => await resolveProgramAccountsUsingRpc(applyDefaultArgs3(args)))
113
+ );
114
+ };
176
115
  }
177
- function type(fieldType) {
116
+ function createProgramAccountsLoader(rpc) {
117
+ const loader = new DataLoader(createProgramAccountsBatchLoadFn(rpc), { cacheKeyFn });
178
118
  return {
179
- type: fieldType
119
+ load: async (args) => loader.load(applyDefaultArgs3(args))
180
120
  };
181
121
  }
182
- function nonNull(fieldType) {
122
+ function applyDefaultArgs4({
123
+ commitment,
124
+ encoding = "jsonParsed",
125
+ signature
126
+ }) {
183
127
  return {
184
- type: new GraphQLNonNull(fieldType.type)
128
+ commitment,
129
+ encoding,
130
+ signature
131
+ };
132
+ }
133
+ async function loadTransaction(rpc, { signature, ...config }) {
134
+ return await rpc.getTransaction(
135
+ signature,
136
+ // @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
137
+ config
138
+ ).send();
139
+ }
140
+ function createTransactionBatchLoadFn(rpc) {
141
+ const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
142
+ return async (transactionQueryArgs) => {
143
+ return await Promise.all(
144
+ transactionQueryArgs.map(async (args) => await resolveTransactionUsingRpc(applyDefaultArgs4(args)))
145
+ );
185
146
  };
186
147
  }
187
- function list(elementType) {
148
+ function createTransactionLoader(rpc) {
149
+ const loader = new DataLoader(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
188
150
  return {
189
- type: new GraphQLList(elementType.type)
151
+ load: async (args) => loader.load(applyDefaultArgs4(args))
190
152
  };
191
153
  }
192
- function object(name, fields) {
154
+
155
+ // src/context.ts
156
+ function createSolanaGraphQLContext(rpc) {
193
157
  return {
194
- type: new GraphQLObjectType({
195
- fields,
196
- name
197
- })
158
+ loaders: {
159
+ account: createAccountLoader(rpc),
160
+ block: createBlockLoader(rpc),
161
+ programAccounts: createProgramAccountsLoader(rpc),
162
+ transaction: createTransactionLoader(rpc)
163
+ }
198
164
  };
199
165
  }
200
166
 
201
- // src/schema/inputs.ts
202
- var memoisedAccountEncodingInputType;
203
- var accountEncodingInputType = () => {
204
- if (!memoisedAccountEncodingInputType)
205
- memoisedAccountEncodingInputType = new GraphQLEnumType({
206
- name: "AccountEncoding",
207
- values: {
208
- base58: {
209
- value: "base58"
210
- },
211
- base64: {
212
- value: "base64"
213
- },
214
- base64Zstd: {
215
- value: "base64+zstd"
216
- },
217
- jsonParsed: {
218
- value: "jsonParsed"
219
- }
167
+ // src/resolvers/resolve-info.ts
168
+ function onlyPresentFieldRequested(fieldName, info) {
169
+ if (info && info.fieldNodes[0].selectionSet) {
170
+ const selectionSet = info.fieldNodes[0].selectionSet;
171
+ const requestedFields = selectionSet.selections.map((field) => {
172
+ if (field.kind === "Field") {
173
+ return field.name.value;
220
174
  }
175
+ return null;
221
176
  });
222
- return memoisedAccountEncodingInputType;
177
+ if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
178
+ return true;
179
+ }
180
+ }
181
+ return false;
182
+ }
183
+
184
+ // src/resolvers/account.ts
185
+ function transformParsedAccountData(parsedAccountData) {
186
+ const {
187
+ parsed: { info: result, type: accountType },
188
+ program: programName,
189
+ programId
190
+ } = parsedAccountData;
191
+ result.accountType = accountType;
192
+ result.programId = programId;
193
+ result.programName = programName;
194
+ return result;
195
+ }
196
+ function transformLoadedAccount({
197
+ account,
198
+ address,
199
+ encoding = "jsonParsed"
200
+ }) {
201
+ const [
202
+ // The account's data, either encoded or parsed.
203
+ data,
204
+ // Tells GraphQL which encoding has been returned
205
+ // by the RPC.
206
+ responseEncoding
207
+ ] = Array.isArray(account.data) ? encoding === "jsonParsed" ? (
208
+ // The requested encoding is jsonParsed,
209
+ // but the data could not be parsed.
210
+ // Defaults to base64 encoding.
211
+ [{ data: account.data[0] }, "base64"]
212
+ ) : (
213
+ // The requested encoding is base58,
214
+ // base64, or base64+zstd.
215
+ [{ data: account.data[0] }, encoding]
216
+ ) : (
217
+ // The account data was returned as an object,
218
+ // so it was parsed successfully.
219
+ [transformParsedAccountData(account.data), "jsonParsed"]
220
+ );
221
+ account.address = address;
222
+ account.encoding = responseEncoding;
223
+ account.ownerProgram = account.owner;
224
+ return {
225
+ ...account,
226
+ ...data
227
+ };
228
+ }
229
+ var resolveAccount = (fieldName) => {
230
+ return async (parent, args, context, info) => {
231
+ const address = fieldName ? parent[fieldName] : args.address;
232
+ if (!address) {
233
+ return null;
234
+ }
235
+ if (onlyPresentFieldRequested("address", info)) {
236
+ return { address };
237
+ }
238
+ const account = await context.loaders.account.load({ ...args, address });
239
+ return account === null ? { address } : transformLoadedAccount({ account, address, encoding: args.encoding });
240
+ };
223
241
  };
224
- var memoisedBlockTransactionDetailsInputType;
225
- var blockTransactionDetailsInputType = () => {
226
- if (!memoisedBlockTransactionDetailsInputType)
227
- memoisedBlockTransactionDetailsInputType = new GraphQLEnumType({
228
- name: "BlockTransactionDetails",
229
- values: {
230
- accounts: {
231
- value: "accounts"
232
- },
233
- full: {
234
- value: "full"
235
- },
236
- none: {
237
- value: "none"
238
- },
239
- signatures: {
240
- value: "signatures"
241
- }
242
+ var accountResolvers = {
243
+ Account: {
244
+ __resolveType(account) {
245
+ if (account.encoding === "base58") {
246
+ return "AccountBase58";
242
247
  }
243
- });
244
- return memoisedBlockTransactionDetailsInputType;
245
- };
246
- var memoisedCommitmentInputType;
247
- var commitmentInputType = () => {
248
- if (!memoisedCommitmentInputType)
249
- memoisedCommitmentInputType = new GraphQLEnumType({
250
- name: "Commitment",
251
- values: {
252
- confirmed: {
253
- value: "confirmed"
254
- },
255
- finalized: {
256
- value: "finalized"
257
- },
258
- processed: {
259
- value: "processed"
260
- }
248
+ if (account.encoding === "base64") {
249
+ return "AccountBase64";
261
250
  }
262
- });
263
- return memoisedCommitmentInputType;
264
- };
265
- var memoisedDataSliceInputType;
266
- var dataSliceInputType = () => {
267
- if (!memoisedDataSliceInputType)
268
- memoisedDataSliceInputType = new GraphQLInputObjectType({
269
- fields: {
270
- length: number(),
271
- offset: number()
272
- },
273
- name: "DataSliceConfig"
274
- });
275
- return memoisedDataSliceInputType;
276
- };
277
- var memoisedMaxSupportedTransactionVersionInputType;
278
- var maxSupportedTransactionVersionInputType = () => {
279
- if (!memoisedMaxSupportedTransactionVersionInputType)
280
- memoisedMaxSupportedTransactionVersionInputType = new GraphQLEnumType({
281
- name: "MaxSupportedTransactionVersion",
282
- values: {
283
- legacy: {
284
- value: "legacy"
285
- },
286
- zero: {
287
- value: "0"
288
- }
251
+ if (account.encoding === "base64+zstd") {
252
+ return "AccountBase64Zstd";
289
253
  }
290
- });
291
- return memoisedMaxSupportedTransactionVersionInputType;
292
- };
293
- var memoisedProgramAccountFilterInputType;
294
- var programAccountFilterInputType = () => {
295
- if (!memoisedProgramAccountFilterInputType)
296
- memoisedProgramAccountFilterInputType = new GraphQLInputObjectType({
297
- fields: {
298
- bytes: bigint(),
299
- dataSize: bigint(),
300
- encoding: string(),
301
- offset: bigint()
302
- },
303
- name: "ProgramAccountFilter"
304
- });
305
- return memoisedProgramAccountFilterInputType;
306
- };
307
- var memoisedTransactionEncodingInputType;
308
- var transactionEncodingInputType = () => {
309
- if (!memoisedTransactionEncodingInputType)
310
- memoisedTransactionEncodingInputType = new GraphQLEnumType({
311
- name: "TransactionEncoding",
312
- values: {
313
- base58: {
314
- value: "base58"
315
- },
316
- base64: {
317
- value: "base64"
318
- },
319
- json: {
320
- value: "json"
321
- },
322
- jsonParsed: {
323
- value: "jsonParsed"
254
+ if (account.encoding === "jsonParsed") {
255
+ if (account.programName === "nonce") {
256
+ return "NonceAccount";
324
257
  }
325
- }
326
- });
327
- return memoisedTransactionEncodingInputType;
328
- };
329
- var memoisedTokenAmountType;
330
- var tokenAmountType = () => {
331
- if (!memoisedTokenAmountType) {
332
- memoisedTokenAmountType = new GraphQLObjectType({
333
- fields: {
334
- amount: string(),
335
- decimals: number(),
336
- uiAmount: bigint(),
337
- uiAmountString: string()
338
- },
339
- name: "TokenAmount"
340
- });
341
- }
342
- return memoisedTokenAmountType;
343
- };
344
- var memoisedAccountInterfaceFields;
345
- var accountInterfaceFields = () => {
346
- if (!memoisedAccountInterfaceFields) {
347
- memoisedAccountInterfaceFields = {
348
- encoding: string(),
349
- executable: boolean(),
350
- lamports: bigint(),
351
- rentEpoch: bigint()
352
- };
353
- }
354
- return memoisedAccountInterfaceFields;
355
- };
356
- var memoisedAccountInterface;
357
- var accountInterface = () => {
358
- if (!memoisedAccountInterface) {
359
- memoisedAccountInterface = new GraphQLInterfaceType({
360
- description: "A Solana account",
361
- fields: () => ({
362
- ...accountInterfaceFields(),
363
- owner: type(accountInterface())
364
- }),
365
- name: "Account",
366
- resolveType(account) {
367
- if (account.encoding === "base58") {
368
- return "AccountBase58";
258
+ if (account.accountType === "mint" && account.programName === "spl-token") {
259
+ return "MintAccount";
369
260
  }
370
- if (account.encoding === "base64") {
371
- return "AccountBase64";
261
+ if (account.accountType === "account" && account.programName === "spl-token") {
262
+ return "TokenAccount";
372
263
  }
373
- if (account.encoding === "base64+zstd") {
374
- return "AccountBase64Zstd";
264
+ if (account.programName === "stake") {
265
+ return "StakeAccount";
375
266
  }
376
- if (account.encoding === "jsonParsed") {
377
- if (account.data.parsed.type === "mint" && account.data.program === "spl-token") {
378
- return "MintAccount";
379
- }
380
- if (account.data.parsed.type === "account" && account.data.program === "spl-token") {
381
- return "TokenAccount";
382
- }
383
- if (account.data.program === "nonce") {
384
- return "NonceAccount";
385
- }
386
- if (account.data.program === "stake") {
387
- return "StakeAccount";
388
- }
389
- if (account.data.parsed.type === "vote" && account.data.program === "vote") {
390
- return "VoteAccount";
391
- }
392
- if (account.data.parsed.type === "lookupTable" && account.data.program === "address-lookup-table") {
393
- return "LookupTableAccount";
394
- }
267
+ if (account.accountType === "vote" && account.programName === "vote") {
268
+ return "VoteAccount";
269
+ }
270
+ if (account.accountType === "lookupTable" && account.programName === "address-lookup-table") {
271
+ return "LookupTableAccount";
395
272
  }
396
- return "AccountBase64";
397
273
  }
398
- });
274
+ return "AccountBase64";
275
+ }
276
+ },
277
+ AccountBase58: {
278
+ ownerProgram: resolveAccount("ownerProgram")
279
+ },
280
+ AccountBase64: {
281
+ ownerProgram: resolveAccount("ownerProgram")
282
+ },
283
+ AccountBase64Zstd: {
284
+ ownerProgram: resolveAccount("ownerProgram")
285
+ },
286
+ LookupTableAccount: {
287
+ authority: resolveAccount("authority"),
288
+ ownerProgram: resolveAccount("ownerProgram")
289
+ },
290
+ MintAccount: {
291
+ freezeAuthority: resolveAccount("freezeAuthority"),
292
+ mintAuthority: resolveAccount("mintAuthority"),
293
+ ownerProgram: resolveAccount("ownerProgram")
294
+ },
295
+ NonceAccount: {
296
+ authority: resolveAccount("authority"),
297
+ ownerProgram: resolveAccount("ownerProgram")
298
+ },
299
+ StakeAccount: {
300
+ ownerProgram: resolveAccount("ownerProgram")
301
+ },
302
+ StakeAccountDataMetaAuthorized: {
303
+ staker: resolveAccount("staker"),
304
+ withdrawer: resolveAccount("withdrawer")
305
+ },
306
+ StakeAccountDataMetaLockup: {
307
+ custodian: resolveAccount("custodian")
308
+ },
309
+ StakeAccountDataStakeDelegation: {
310
+ voter: resolveAccount("voter")
311
+ },
312
+ TokenAccount: {
313
+ mint: resolveAccount("mint"),
314
+ owner: resolveAccount("owner"),
315
+ ownerProgram: resolveAccount("ownerProgram")
316
+ },
317
+ VoteAccount: {
318
+ authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
319
+ node: resolveAccount("nodePubkey"),
320
+ ownerProgram: resolveAccount("ownerProgram")
321
+ },
322
+ VoteAccountDataAuthorizedVoter: {
323
+ authorizedVoter: resolveAccount("authorizedVoter")
399
324
  }
400
- return memoisedAccountInterface;
401
- };
402
- var accountType = (name, description, data) => new GraphQLObjectType({
403
- description,
404
- fields: {
405
- ...accountInterfaceFields(),
406
- data,
407
- owner: {
408
- args: {
409
- commitment: type(commitmentInputType()),
410
- dataSlice: type(dataSliceInputType()),
411
- encoding: type(accountEncodingInputType()),
412
- minContextSlot: bigint()
413
- },
414
- resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
415
- type: accountInterface()
416
- }
417
- },
418
- interfaces: [accountInterface()],
419
- name
420
- });
421
- var accountDataJsonParsed = (name, parsedInfoFields) => object(name + "Data", {
422
- parsed: object(name + "DataParsed", {
423
- info: object(name + "DataParsedInfo", parsedInfoFields),
424
- type: string()
425
- }),
426
- program: string(),
427
- space: bigint()
428
- });
429
- var memoisedAccountBase58;
430
- var accountBase58 = () => {
431
- if (!memoisedAccountBase58)
432
- memoisedAccountBase58 = accountType("AccountBase58", "A Solana account with base58 encoded data", string());
433
- return memoisedAccountBase58;
434
- };
435
- var memoisedAccountBase64;
436
- var accountBase64 = () => {
437
- if (!memoisedAccountBase64)
438
- memoisedAccountBase64 = accountType("AccountBase64", "A Solana account with base64 encoded data", string());
439
- return memoisedAccountBase64;
440
- };
441
- var memoisedAccountBase64Zstd;
442
- var accountBase64Zstd = () => {
443
- if (!memoisedAccountBase64Zstd)
444
- memoisedAccountBase64Zstd = accountType(
445
- "AccountBase64Zstd",
446
- "A Solana account with base64 encoded data compressed with zstd",
447
- string()
448
- );
449
- return memoisedAccountBase64Zstd;
450
- };
451
- var memoisedAccountNonceAccount;
452
- var accountNonceAccount = () => {
453
- if (!memoisedAccountNonceAccount)
454
- memoisedAccountNonceAccount = accountType(
455
- "NonceAccount",
456
- "A nonce account",
457
- accountDataJsonParsed("Nonce", {
458
- authority: string(),
459
- blockhash: string(),
460
- feeCalculator: object("NonceFeeCalculator", {
461
- lamportsPerSignature: string()
462
- })
463
- })
464
- );
465
- return memoisedAccountNonceAccount;
466
- };
467
- var memoisedAccountLookupTable;
468
- var accountLookupTable = () => {
469
- if (!memoisedAccountLookupTable)
470
- memoisedAccountLookupTable = accountType(
471
- "LookupTableAccount",
472
- "An address lookup table account",
473
- accountDataJsonParsed("LookupTable", {
474
- addresses: list(string()),
475
- authority: string(),
476
- deactivationSlot: string(),
477
- lastExtendedSlot: string(),
478
- lastExtendedSlotStartIndex: number()
479
- })
480
- );
481
- return memoisedAccountLookupTable;
482
- };
483
- var memoisedAccountMint;
484
- var accountMint = () => {
485
- if (!memoisedAccountMint)
486
- memoisedAccountMint = accountType(
487
- "MintAccount",
488
- "An SPL mint",
489
- accountDataJsonParsed("Mint", {
490
- decimals: number(),
491
- freezeAuthority: string(),
492
- isInitialized: boolean(),
493
- mintAuthority: string(),
494
- supply: string()
495
- })
496
- );
497
- return memoisedAccountMint;
498
- };
499
- var memoisedAccountTokenAccount;
500
- var accountTokenAccount = () => {
501
- if (!memoisedAccountTokenAccount)
502
- memoisedAccountTokenAccount = accountType(
503
- "TokenAccount",
504
- "An SPL token account",
505
- accountDataJsonParsed("TokenAccount", {
506
- isNative: boolean(),
507
- mint: string(),
508
- owner: string(),
509
- state: string(),
510
- tokenAmount: type(tokenAmountType())
511
- })
512
- );
513
- return memoisedAccountTokenAccount;
514
- };
515
- var memoisedAccountStakeAccount;
516
- var accountStakeAccount = () => {
517
- if (!memoisedAccountStakeAccount)
518
- memoisedAccountStakeAccount = accountType(
519
- "StakeAccount",
520
- "A stake account",
521
- accountDataJsonParsed("Stake", {
522
- meta: object("StakeMeta", {
523
- authorized: object("StakeMetaAuthorized", {
524
- staker: string(),
525
- withdrawer: string()
526
- }),
527
- lockup: object("StakeMetaLockup", {
528
- custodian: string(),
529
- epoch: bigint(),
530
- unixTimestamp: bigint()
531
- }),
532
- rentExemptReserve: string()
533
- }),
534
- stake: object("StakeStake", {
535
- creditsObserved: bigint(),
536
- delegation: object("StakeStakeDelegation", {
537
- activationEpoch: bigint(),
538
- deactivationEpoch: bigint(),
539
- stake: string(),
540
- voter: string(),
541
- warmupCooldownRate: number()
542
- })
543
- })
544
- })
545
- );
546
- return memoisedAccountStakeAccount;
547
- };
548
- var memoisedAccountVoteAccount;
549
- var accountVoteAccount = () => {
550
- if (!memoisedAccountVoteAccount)
551
- memoisedAccountVoteAccount = accountType(
552
- "VoteAccount",
553
- "A vote account",
554
- accountDataJsonParsed("Vote", {
555
- authorizedVoters: list(
556
- object("VoteAuthorizedVoter", {
557
- authorizedVoter: string(),
558
- epoch: bigint()
559
- })
560
- ),
561
- authorizedWithdrawer: string(),
562
- commission: number(),
563
- epochCredits: list(
564
- object("VoteEpochCredits", {
565
- credits: string(),
566
- epoch: bigint(),
567
- previousCredits: string()
568
- })
569
- ),
570
- lastTimestamp: object("VoteLastTimestamp", {
571
- slot: bigint(),
572
- timestamp: bigint()
573
- }),
574
- nodePubkey: string(),
575
- priorVoters: list(string()),
576
- rootSlot: bigint(),
577
- votes: list(
578
- object("VoteVote", {
579
- confirmationCount: number(),
580
- slot: bigint()
581
- })
582
- )
583
- })
584
- );
585
- return memoisedAccountVoteAccount;
586
- };
587
- var memoisedAccountTypes;
588
- var accountTypes = () => {
589
- if (!memoisedAccountTypes)
590
- memoisedAccountTypes = [
591
- accountBase58(),
592
- accountBase64(),
593
- accountBase64Zstd(),
594
- accountNonceAccount(),
595
- accountLookupTable(),
596
- accountMint(),
597
- accountTokenAccount(),
598
- accountStakeAccount(),
599
- accountVoteAccount()
600
- ];
601
- return memoisedAccountTypes;
602
325
  };
603
326
 
604
- // src/schema/account/query.ts
605
- var accountQuery = () => ({
606
- account: {
607
- args: {
608
- address: nonNull(string()),
609
- commitment: type(commitmentInputType()),
610
- dataSlice: type(dataSliceInputType()),
611
- encoding: type(accountEncodingInputType()),
612
- minContextSlot: bigint()
613
- },
614
- resolve: (_parent, args, context) => context.resolveAccount(args),
615
- type: accountInterface()
327
+ // src/resolvers/transaction.ts
328
+ function transformParsedInstruction(parsedInstruction) {
329
+ if ("parsed" in parsedInstruction) {
330
+ if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
331
+ const { parsed: memo, program: programName2, programId: programId2 } = parsedInstruction;
332
+ const instructionType2 = "memo";
333
+ return { instructionType: instructionType2, memo, programId: programId2, programName: programName2 };
334
+ }
335
+ const {
336
+ parsed: { info: data, type: instructionType },
337
+ program: programName,
338
+ programId
339
+ } = parsedInstruction;
340
+ return { instructionType, programId, programName, ...data };
341
+ } else {
342
+ return parsedInstruction;
343
+ }
344
+ }
345
+ function transformParsedTransaction(parsedTransaction) {
346
+ const transactionData = parsedTransaction.transaction;
347
+ const transactionMeta = parsedTransaction.meta;
348
+ transactionData.message.instructions = transactionData.message.instructions.map(transformParsedInstruction);
349
+ transactionMeta.innerInstructions = transactionMeta.innerInstructions.map((innerInstruction) => {
350
+ innerInstruction.instructions = innerInstruction.instructions.map(transformParsedInstruction);
351
+ return innerInstruction;
352
+ });
353
+ return [transactionData, transactionMeta];
354
+ }
355
+ function transformLoadedTransaction({
356
+ encoding = "jsonParsed",
357
+ transaction
358
+ }) {
359
+ const [transactionData, transactionMeta] = Array.isArray(transaction.transaction) ? (
360
+ // The requested encoding is base58 or base64.
361
+ [transaction.transaction[0], transaction.meta]
362
+ ) : (
363
+ // The transaction was either partially parsed or
364
+ // fully JSON-parsed, which will be sorted later.
365
+ transformParsedTransaction(transaction)
366
+ );
367
+ transaction.data = transactionData;
368
+ transaction.encoding = encoding;
369
+ transaction.meta = transactionMeta;
370
+ return transaction;
371
+ }
372
+ function resolveTransaction(fieldName) {
373
+ return async (parent, args, context, info) => {
374
+ const signature = fieldName ? parent[fieldName] : args.signature;
375
+ if (!signature) {
376
+ return null;
377
+ }
378
+ if (onlyPresentFieldRequested("signature", info)) {
379
+ return { signature };
380
+ }
381
+ const transaction = await context.loaders.transaction.load({ ...args, signature });
382
+ if (!transaction) {
383
+ return null;
384
+ }
385
+ if (args.encoding !== "jsonParsed") {
386
+ const transactionJsonParsed = await context.loaders.transaction.load({
387
+ ...args,
388
+ encoding: "jsonParsed",
389
+ signature
390
+ });
391
+ if (transactionJsonParsed === null) {
392
+ return null;
393
+ }
394
+ transaction.meta = transactionJsonParsed.meta;
395
+ }
396
+ return transformLoadedTransaction({ encoding: args.encoding, transaction });
397
+ };
398
+ }
399
+ var transactionResolvers = {
400
+ Transaction: {
401
+ __resolveType(transaction) {
402
+ switch (transaction.encoding) {
403
+ case "base58":
404
+ return "TransactionBase58";
405
+ case "base64":
406
+ return "TransactionBase64";
407
+ default:
408
+ return "TransactionParsed";
409
+ }
410
+ }
616
411
  }
617
- });
618
- var memoisedTokenBalance;
619
- var tokenBalance = () => {
620
- if (!memoisedTokenBalance)
621
- memoisedTokenBalance = new GraphQLObjectType({
622
- fields: {
623
- accountIndex: number(),
624
- mint: string(),
625
- owner: string(),
626
- programId: string(),
627
- uiAmountString: string()
628
- },
629
- name: "TokenBalance"
630
- });
631
- return memoisedTokenBalance;
632
- };
633
- var memoisedTransactionStatus;
634
- var transactionStatus = () => {
635
- if (!memoisedTransactionStatus)
636
- memoisedTransactionStatus = new GraphQLUnionType({
637
- name: "TransactionStatus",
638
- types: [
639
- new GraphQLObjectType({
640
- fields: {
641
- Err: string()
642
- },
643
- name: "TransactionStatusError"
644
- }),
645
- new GraphQLObjectType({
646
- fields: {
647
- Ok: string()
648
- },
649
- name: "TransactionStatusOk"
650
- })
651
- ]
652
- });
653
- return memoisedTransactionStatus;
654
- };
655
- var memoisedReward;
656
- var reward = () => {
657
- if (!memoisedReward)
658
- memoisedReward = new GraphQLObjectType({
659
- fields: {
660
- commission: number(),
661
- lamports: bigint(),
662
- postBalance: bigint(),
663
- pubkey: string(),
664
- rewardType: string()
665
- },
666
- name: "Reward"
667
- });
668
- return memoisedReward;
669
- };
670
- var memoisedAddressTableLookup;
671
- var addressTableLookup = () => {
672
- if (!memoisedAddressTableLookup)
673
- memoisedAddressTableLookup = new GraphQLObjectType({
674
- fields: {
675
- accountKey: string(),
676
- readableIndexes: list(number()),
677
- writableIndexes: list(number())
678
- },
679
- name: "AddressTableLookup"
680
- });
681
- return memoisedAddressTableLookup;
682
- };
683
- var memoisedReturnData;
684
- var returnData = () => {
685
- if (!memoisedReturnData)
686
- memoisedReturnData = new GraphQLObjectType({
687
- fields: {
688
- data: string(),
689
- programId: string()
690
- },
691
- name: "ReturnData"
692
- });
693
- return memoisedReturnData;
694
412
  };
695
- var memoisedTransactionInstruction;
696
- var transactionInstruction = () => {
697
- if (!memoisedTransactionInstruction)
698
- memoisedTransactionInstruction = new GraphQLObjectType({
699
- fields: {
700
- accounts: list(number()),
701
- data: string(),
702
- programIdIndex: number()
703
- },
704
- name: "TransactionInstruction"
413
+
414
+ // src/resolvers/block.ts
415
+ function transformLoadedBlock({
416
+ block,
417
+ encoding = "jsonParsed",
418
+ transactionDetails = "full"
419
+ }) {
420
+ const transformedBlock = block;
421
+ if (typeof block === "object" && "transactions" in block) {
422
+ transformedBlock.transactions = block.transactions.map((transaction) => {
423
+ if (transactionDetails === "accounts") {
424
+ return {
425
+ data: transaction.transaction,
426
+ meta: transaction.meta,
427
+ version: transaction.version
428
+ };
429
+ } else {
430
+ return transformLoadedTransaction({ encoding, transaction });
431
+ }
705
432
  });
706
- return memoisedTransactionInstruction;
433
+ }
434
+ block.encoding = encoding;
435
+ block.transactionDetails = transactionDetails;
436
+ return block;
437
+ }
438
+ var resolveBlock = (fieldName) => {
439
+ return async (parent, args, context, info) => {
440
+ const slot = fieldName ? parent[fieldName] : args.slot;
441
+ if (!slot) {
442
+ return null;
443
+ }
444
+ if (onlyPresentFieldRequested("slot", info)) {
445
+ return { slot };
446
+ }
447
+ const block = await context.loaders.block.load({ ...args, slot });
448
+ if (block === null) {
449
+ return null;
450
+ }
451
+ const { encoding, transactionDetails } = args;
452
+ return transformLoadedBlock({ block, encoding, transactionDetails });
453
+ };
707
454
  };
708
- var memoisedTransactionMetaLoadedAddresses;
709
- var transactionMetaLoadedAddresses = () => {
710
- if (!memoisedTransactionMetaLoadedAddresses)
711
- memoisedTransactionMetaLoadedAddresses = new GraphQLObjectType({
712
- fields: {
713
- readonly: list(string()),
714
- // Base58 encoded addresses
715
- writable: list(string())
716
- // Base58 encoded addresses
717
- },
718
- name: "TransactionMetaLoadedAddresses"
719
- });
720
- return memoisedTransactionMetaLoadedAddresses;
455
+ var blockResolvers = {
456
+ Block: {
457
+ __resolveType(block) {
458
+ switch (block.transactionDetails) {
459
+ case "accounts":
460
+ return "BlockWithAccounts";
461
+ case "none":
462
+ return "BlockWithNone";
463
+ case "signatures":
464
+ return "BlockWithSignatures";
465
+ default:
466
+ return "BlockWithFull";
467
+ }
468
+ }
469
+ }
721
470
  };
722
- var memoisedParsedTransactionInstructionInterface;
723
- var parsedTransactionInstructionInterface = () => {
724
- if (!memoisedParsedTransactionInstructionInterface)
725
- memoisedParsedTransactionInstructionInterface = new GraphQLInterfaceType({
726
- fields: {
727
- programId: string()
728
- },
729
- name: "ParsedTransactionInstruction",
730
- resolveType(instruction) {
731
- if (instruction.program === "address-lookup-table") {
732
- if (instruction.info.type === "createLookupTable") {
471
+
472
+ // src/resolvers/instruction.ts
473
+ var instructionResolvers = {
474
+ AdvanceNonceAccountInstruction: {
475
+ nonceAccount: resolveAccount("nonceAccount"),
476
+ nonceAuthority: resolveAccount("nonceAuthority")
477
+ },
478
+ AllocateInstruction: {
479
+ account: resolveAccount("account")
480
+ },
481
+ AllocateWithSeedInstruction: {
482
+ account: resolveAccount("account"),
483
+ owner: resolveAccount("owner")
484
+ },
485
+ AssignInstruction: {
486
+ account: resolveAccount("account"),
487
+ owner: resolveAccount("owner")
488
+ },
489
+ AssignWithSeedInstruction: {
490
+ account: resolveAccount("account"),
491
+ owner: resolveAccount("owner")
492
+ },
493
+ AuthorizeNonceAccountInstruction: {
494
+ newAuthorized: resolveAccount("newAuthorized"),
495
+ nonceAccount: resolveAccount("nonceAccount"),
496
+ nonceAuthority: resolveAccount("nonceAuthority")
497
+ },
498
+ BpfLoaderFinalizeInstruction: {
499
+ account: resolveAccount("account")
500
+ },
501
+ BpfLoaderWriteInstruction: {
502
+ account: resolveAccount("account")
503
+ },
504
+ BpfUpgradeableLoaderCloseInstruction: {
505
+ account: resolveAccount("account"),
506
+ authority: resolveAccount("authority"),
507
+ programAccount: resolveAccount("programAccount"),
508
+ recipient: resolveAccount("recipient")
509
+ },
510
+ BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
511
+ authority: resolveAccount("authority"),
512
+ bufferAccount: resolveAccount("bufferAccount"),
513
+ payerAccount: resolveAccount("payerAccount"),
514
+ programAccount: resolveAccount("programAccount"),
515
+ programDataAccount: resolveAccount("programDataAccount")
516
+ },
517
+ BpfUpgradeableLoaderExtendProgramInstruction: {
518
+ payerAccount: resolveAccount("payerAccount"),
519
+ programAccount: resolveAccount("programAccount"),
520
+ programDataAccount: resolveAccount("programDataAccount"),
521
+ systemProgram: resolveAccount("systemProgram")
522
+ },
523
+ BpfUpgradeableLoaderInitializeBufferInstruction: {
524
+ account: resolveAccount("account")
525
+ },
526
+ BpfUpgradeableLoaderSetAuthorityCheckedInstruction: {
527
+ account: resolveAccount("account"),
528
+ authority: resolveAccount("authority"),
529
+ newAuthority: resolveAccount("newAuthority")
530
+ },
531
+ BpfUpgradeableLoaderSetAuthorityInstruction: {
532
+ account: resolveAccount("account"),
533
+ authority: resolveAccount("authority"),
534
+ newAuthority: resolveAccount("newAuthority")
535
+ },
536
+ BpfUpgradeableLoaderUpgradeInstruction: {
537
+ authority: resolveAccount("authority"),
538
+ bufferAccount: resolveAccount("bufferAccount"),
539
+ programAccount: resolveAccount("programAccount"),
540
+ programDataAccount: resolveAccount("programDataAccount")
541
+ },
542
+ BpfUpgradeableLoaderWriteInstruction: {
543
+ account: resolveAccount("account"),
544
+ authority: resolveAccount("authority")
545
+ },
546
+ CloseLookupTableInstruction: {
547
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
548
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
549
+ recipient: resolveAccount("recipient")
550
+ },
551
+ CreateAccountInstruction: {
552
+ newAccount: resolveAccount("newAccount"),
553
+ owner: resolveAccount("owner"),
554
+ source: resolveAccount("source")
555
+ },
556
+ CreateAccountWithSeedInstruction: {
557
+ base: resolveAccount("base"),
558
+ owner: resolveAccount("owner"),
559
+ seed: resolveAccount("seed")
560
+ },
561
+ CreateLookupTableInstruction: {
562
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
563
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
564
+ payerAccount: resolveAccount("payerAccount"),
565
+ systemProgram: resolveAccount("systemProgram")
566
+ },
567
+ DeactivateLookupTableInstruction: {
568
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
569
+ lookupTableAuthority: resolveAccount("lookupTableAuthority")
570
+ },
571
+ ExtendLookupTableInstruction: {
572
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
573
+ lookupTableAuthority: resolveAccount("lookupTableAuthority"),
574
+ payerAccount: resolveAccount("payerAccount"),
575
+ systemProgram: resolveAccount("systemProgram")
576
+ },
577
+ FreezeLookupTableInstruction: {
578
+ lookupTableAccount: resolveAccount("lookupTableAccount"),
579
+ lookupTableAuthority: resolveAccount("lookupTableAuthority")
580
+ },
581
+ InitializeNonceAccountInstruction: {
582
+ nonceAccount: resolveAccount("nonceAccount"),
583
+ nonceAuthority: resolveAccount("nonceAuthority")
584
+ },
585
+ Lockup: {
586
+ custodian: resolveAccount("custodian")
587
+ },
588
+ SplAssociatedTokenCreateIdempotentInstruction: {
589
+ account: resolveAccount("account"),
590
+ mint: resolveAccount("mint"),
591
+ source: resolveAccount("source"),
592
+ systemProgram: resolveAccount("systemProgram"),
593
+ tokenProgram: resolveAccount("tokenProgram"),
594
+ wallet: resolveAccount("wallet")
595
+ },
596
+ SplAssociatedTokenCreateInstruction: {
597
+ account: resolveAccount("account"),
598
+ mint: resolveAccount("mint"),
599
+ source: resolveAccount("source"),
600
+ systemProgram: resolveAccount("systemProgram"),
601
+ tokenProgram: resolveAccount("tokenProgram"),
602
+ wallet: resolveAccount("wallet")
603
+ },
604
+ SplAssociatedTokenRecoverNestedInstruction: {
605
+ destination: resolveAccount("destination"),
606
+ nestedMint: resolveAccount("nestedMint"),
607
+ nestedOwner: resolveAccount("nestedOwner"),
608
+ nestedSource: resolveAccount("nestedSource"),
609
+ ownerMint: resolveAccount("ownerMint"),
610
+ tokenProgram: resolveAccount("tokenProgram"),
611
+ wallet: resolveAccount("wallet")
612
+ },
613
+ SplTokenAmountToUiAmountInstruction: {
614
+ mint: resolveAccount("mint")
615
+ },
616
+ SplTokenApproveCheckedInstruction: {
617
+ delegate: resolveAccount("delegate"),
618
+ mint: resolveAccount("mint"),
619
+ multisigOwner: resolveAccount("multisigOwner"),
620
+ owner: resolveAccount("owner"),
621
+ source: resolveAccount("source")
622
+ },
623
+ SplTokenApproveInstruction: {
624
+ delegate: resolveAccount("delegate"),
625
+ multisigOwner: resolveAccount("multisigOwner"),
626
+ owner: resolveAccount("owner"),
627
+ source: resolveAccount("source")
628
+ },
629
+ SplTokenBurnCheckedInstruction: {
630
+ account: resolveAccount("account"),
631
+ authority: resolveAccount("authority"),
632
+ mint: resolveAccount("mint"),
633
+ multisigAuthority: resolveAccount("multisigAuthority")
634
+ },
635
+ SplTokenBurnInstruction: {
636
+ account: resolveAccount("account"),
637
+ authority: resolveAccount("authority"),
638
+ mint: resolveAccount("mint"),
639
+ multisigAuthority: resolveAccount("multisigAuthority")
640
+ },
641
+ SplTokenCloseAccountInstruction: {
642
+ account: resolveAccount("account"),
643
+ destination: resolveAccount("destination"),
644
+ multisigOwner: resolveAccount("multisigOwner"),
645
+ owner: resolveAccount("owner")
646
+ },
647
+ SplTokenFreezeAccountInstruction: {
648
+ account: resolveAccount("account"),
649
+ freezeAuthority: resolveAccount("freezeAuthority"),
650
+ mint: resolveAccount("mint"),
651
+ multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
652
+ },
653
+ SplTokenGetAccountDataSizeInstruction: {
654
+ mint: resolveAccount("mint")
655
+ },
656
+ SplTokenInitializeAccount2Instruction: {
657
+ account: resolveAccount("account"),
658
+ mint: resolveAccount("mint"),
659
+ owner: resolveAccount("owner")
660
+ },
661
+ SplTokenInitializeAccount3Instruction: {
662
+ account: resolveAccount("account"),
663
+ mint: resolveAccount("mint"),
664
+ owner: resolveAccount("owner")
665
+ },
666
+ SplTokenInitializeAccountInstruction: {
667
+ account: resolveAccount("account"),
668
+ mint: resolveAccount("mint"),
669
+ owner: resolveAccount("owner")
670
+ },
671
+ SplTokenInitializeMint2Instruction: {
672
+ freezeAuthority: resolveAccount("freezeAuthority"),
673
+ mint: resolveAccount("mint"),
674
+ mintAuthority: resolveAccount("mintAuthority")
675
+ },
676
+ SplTokenInitializeMintCloseAuthorityInstruction: {
677
+ mint: resolveAccount("mint"),
678
+ newAuthority: resolveAccount("newAuthority")
679
+ },
680
+ SplTokenInitializeMintInstruction: {
681
+ freezeAuthority: resolveAccount("freezeAuthority"),
682
+ mint: resolveAccount("mint"),
683
+ mintAuthority: resolveAccount("mintAuthority")
684
+ },
685
+ SplTokenInitializeMultisig2Instruction: {
686
+ multisig: resolveAccount("multisig")
687
+ },
688
+ SplTokenInitializeMultisigInstruction: {
689
+ multisig: resolveAccount("multisig")
690
+ },
691
+ SplTokenMintToCheckedInstruction: {
692
+ account: resolveAccount("account"),
693
+ authority: resolveAccount("authority"),
694
+ mint: resolveAccount("mint"),
695
+ mintAuthority: resolveAccount("mintAuthority"),
696
+ multisigMintAuthority: resolveAccount("multisigMintAuthority")
697
+ },
698
+ SplTokenMintToInstruction: {
699
+ account: resolveAccount("account"),
700
+ authority: resolveAccount("authority"),
701
+ mint: resolveAccount("mint"),
702
+ mintAuthority: resolveAccount("mintAuthority"),
703
+ multisigMintAuthority: resolveAccount("multisigMintAuthority")
704
+ },
705
+ SplTokenRevokeInstruction: {
706
+ multisigOwner: resolveAccount("multisigOwner"),
707
+ owner: resolveAccount("owner"),
708
+ source: resolveAccount("source")
709
+ },
710
+ SplTokenSetAuthorityInstruction: {
711
+ authority: resolveAccount("authority"),
712
+ multisigAuthority: resolveAccount("multisigAuthority"),
713
+ newAuthority: resolveAccount("newAuthority")
714
+ },
715
+ SplTokenSyncNativeInstruction: {
716
+ account: resolveAccount("account")
717
+ },
718
+ SplTokenThawAccountInstruction: {
719
+ account: resolveAccount("account"),
720
+ freezeAuthority: resolveAccount("freezeAuthority"),
721
+ mint: resolveAccount("mint"),
722
+ multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
723
+ },
724
+ SplTokenTransferCheckedInstruction: {
725
+ authority: resolveAccount("authority"),
726
+ destination: resolveAccount("destination"),
727
+ mint: resolveAccount("mint"),
728
+ multisigAuthority: resolveAccount("multisigAuthority"),
729
+ source: resolveAccount("source")
730
+ },
731
+ SplTokenTransferInstruction: {
732
+ authority: resolveAccount("authority"),
733
+ destination: resolveAccount("destination"),
734
+ multisigAuthority: resolveAccount("multisigAuthority"),
735
+ source: resolveAccount("source")
736
+ },
737
+ SplTokenUiAmountToAmountInstruction: {
738
+ mint: resolveAccount("mint")
739
+ },
740
+ StakeAuthorizeCheckedInstruction: {
741
+ authority: resolveAccount("authority"),
742
+ custodian: resolveAccount("custodian"),
743
+ newAuthority: resolveAccount("newAuthority"),
744
+ stakeAccount: resolveAccount("stakeAccount")
745
+ },
746
+ StakeAuthorizeCheckedWithSeedInstruction: {
747
+ authorityBase: resolveAccount("authorityBase"),
748
+ authorityOwner: resolveAccount("authorityOwner"),
749
+ custodian: resolveAccount("custodian"),
750
+ newAuthorized: resolveAccount("newAuthorized"),
751
+ stakeAccount: resolveAccount("stakeAccount")
752
+ },
753
+ StakeAuthorizeInstruction: {
754
+ authority: resolveAccount("authority"),
755
+ custodian: resolveAccount("custodian"),
756
+ newAuthority: resolveAccount("newAuthority"),
757
+ stakeAccount: resolveAccount("stakeAccount")
758
+ },
759
+ StakeAuthorizeWithSeedInstruction: {
760
+ authorityBase: resolveAccount("authorityBase"),
761
+ authorityOwner: resolveAccount("authorityOwner"),
762
+ custodian: resolveAccount("custodian"),
763
+ newAuthorized: resolveAccount("newAuthorized"),
764
+ stakeAccount: resolveAccount("stakeAccount")
765
+ },
766
+ StakeDeactivateDelinquentInstruction: {
767
+ referenceVoteAccount: resolveAccount("referenceVoteAccount"),
768
+ stakeAccount: resolveAccount("stakeAccount"),
769
+ voteAccount: resolveAccount("voteAccount")
770
+ },
771
+ StakeDeactivateInstruction: {
772
+ stakeAccount: resolveAccount("stakeAccount"),
773
+ stakeAuthority: resolveAccount("stakeAuthority")
774
+ },
775
+ StakeDelegateStakeInstruction: {
776
+ stakeAccount: resolveAccount("stakeAccount"),
777
+ stakeAuthority: resolveAccount("stakeAuthority"),
778
+ stakeConfigAccount: resolveAccount("stakeConfigAccount"),
779
+ voteAccount: resolveAccount("voteAccount")
780
+ },
781
+ StakeInitializeCheckedInstructionDataAuthorized: {
782
+ staker: resolveAccount("staker"),
783
+ withdrawer: resolveAccount("withdrawer")
784
+ },
785
+ StakeInitializeInstruction: {
786
+ stakeAccount: resolveAccount("stakeAccount")
787
+ },
788
+ StakeInitializeInstructionDataAuthorized: {
789
+ staker: resolveAccount("staker"),
790
+ withdrawer: resolveAccount("withdrawer")
791
+ },
792
+ StakeMergeInstruction: {
793
+ destination: resolveAccount("destination"),
794
+ source: resolveAccount("source"),
795
+ stakeAuthority: resolveAccount("stakeAuthority")
796
+ },
797
+ StakeRedelegateInstruction: {
798
+ newStakeAccount: resolveAccount("newStakeAccount"),
799
+ stakeAccount: resolveAccount("stakeAccount"),
800
+ stakeAuthority: resolveAccount("stakeAuthority"),
801
+ stakeConfigAccount: resolveAccount("stakeConfigAccount"),
802
+ voteAccount: resolveAccount("voteAccount")
803
+ },
804
+ StakeSetLockupCheckedInstruction: {
805
+ custodian: resolveAccount("custodian"),
806
+ stakeAccount: resolveAccount("stakeAccount")
807
+ },
808
+ StakeSetLockupInstruction: {
809
+ custodian: resolveAccount("custodian"),
810
+ stakeAccount: resolveAccount("stakeAccount")
811
+ },
812
+ StakeSplitInstruction: {
813
+ newSplitAccount: resolveAccount("newSplitAccount"),
814
+ stakeAccount: resolveAccount("stakeAccount"),
815
+ stakeAuthority: resolveAccount("stakeAuthority")
816
+ },
817
+ StakeWithdrawInstruction: {
818
+ destination: resolveAccount("destination"),
819
+ stakeAccount: resolveAccount("stakeAccount"),
820
+ withdrawAuthority: resolveAccount("withdrawAuthority")
821
+ },
822
+ TransactionInstruction: {
823
+ __resolveType(instruction) {
824
+ if (instruction.programName) {
825
+ if (instruction.programName === "address-lookup-table") {
826
+ if (instruction.instructionType === "createLookupTable") {
733
827
  return "CreateLookupTableInstruction";
734
828
  }
735
- if (instruction.info.type === "freezeLookupTable") {
829
+ if (instruction.instructionType === "freezeLookupTable") {
736
830
  return "FreezeLookupTableInstruction";
737
831
  }
738
- if (instruction.info.type === "extendLookupTable") {
832
+ if (instruction.instructionType === "extendLookupTable") {
739
833
  return "ExtendLookupTableInstruction";
740
834
  }
741
- if (instruction.info.type === "deactivateLookupTable") {
835
+ if (instruction.instructionType === "deactivateLookupTable") {
742
836
  return "DeactivateLookupTableInstruction";
743
837
  }
744
- if (instruction.info.type === "closeLookupTable") {
838
+ if (instruction.instructionType === "closeLookupTable") {
745
839
  return "CloseLookupTableInstruction";
746
840
  }
747
841
  }
748
- if (instruction.program === "bpf-loader") {
749
- if (instruction.info.type === "write") {
842
+ if (instruction.programName === "bpf-loader") {
843
+ if (instruction.instructionType === "write") {
750
844
  return "BpfLoaderWriteInstruction";
751
845
  }
752
- if (instruction.info.type === "finalize") {
846
+ if (instruction.instructionType === "finalize") {
753
847
  return "BpfLoaderFinalizeInstruction";
754
848
  }
755
849
  }
756
- if (instruction.program === "bpf-upgradeable-loader") {
757
- if (instruction.info.type === "initializeBuffer") {
850
+ if (instruction.programName === "bpf-upgradeable-loader") {
851
+ if (instruction.instructionType === "initializeBuffer") {
758
852
  return "BpfUpgradeableLoaderInitializeBufferInstruction";
759
853
  }
760
- if (instruction.info.type === "write") {
854
+ if (instruction.instructionType === "write") {
761
855
  return "BpfUpgradeableLoaderWriteInstruction";
762
856
  }
763
- if (instruction.info.type === "deployWithMaxDataLen") {
857
+ if (instruction.instructionType === "deployWithMaxDataLen") {
764
858
  return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
765
859
  }
766
- if (instruction.info.type === "upgrade") {
860
+ if (instruction.instructionType === "upgrade") {
767
861
  return "BpfUpgradeableLoaderUpgradeInstruction";
768
862
  }
769
- if (instruction.info.type === "setAuthority") {
863
+ if (instruction.instructionType === "setAuthority") {
770
864
  return "BpfUpgradeableLoaderSetAuthorityInstruction";
771
865
  }
772
- if (instruction.info.type === "setAuthorityChecked") {
866
+ if (instruction.instructionType === "setAuthorityChecked") {
773
867
  return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
774
868
  }
775
- if (instruction.info.type === "close") {
869
+ if (instruction.instructionType === "close") {
776
870
  return "BpfUpgradeableLoaderCloseInstruction";
777
871
  }
778
- if (instruction.info.type === "extendProgram") {
872
+ if (instruction.instructionType === "extendProgram") {
779
873
  return "BpfUpgradeableLoaderExtendProgramInstruction";
780
874
  }
781
875
  }
782
- if (instruction.program === "spl-associated-token-account") {
783
- if (instruction.info.type === "create") {
876
+ if (instruction.programName === "spl-associated-token-account") {
877
+ if (instruction.instructionType === "create") {
784
878
  return "SplAssociatedTokenCreateInstruction";
785
879
  }
786
- if (instruction.info.type === "createIdempotent") {
880
+ if (instruction.instructionType === "createIdempotent") {
787
881
  return "SplAssociatedTokenCreateIdempotentInstruction";
788
882
  }
789
- if (instruction.info.type === "recoverNested") {
883
+ if (instruction.instructionType === "recoverNested") {
790
884
  return "SplAssociatedTokenRecoverNestedInstruction";
791
885
  }
792
886
  }
793
- if (instruction.program === "spl-memo") {
887
+ if (instruction.programName === "spl-memo") {
794
888
  return "SplMemoInstruction";
795
889
  }
796
- if (instruction.program === "spl-token") {
797
- if (instruction.info.type === "initializeMint") {
890
+ if (instruction.programName === "spl-token") {
891
+ if (instruction.instructionType === "initializeMint") {
798
892
  return "SplTokenInitializeMintInstruction";
799
893
  }
800
- if (instruction.info.type === "initializeMint2") {
894
+ if (instruction.instructionType === "initializeMint2") {
801
895
  return "SplTokenInitializeMint2Instruction";
802
896
  }
803
- if (instruction.info.type === "initializeAccount") {
897
+ if (instruction.instructionType === "initializeAccount") {
804
898
  return "SplTokenInitializeAccountInstruction";
805
899
  }
806
- if (instruction.info.type === "initializeAccount2") {
900
+ if (instruction.instructionType === "initializeAccount2") {
807
901
  return "SplTokenInitializeAccount2Instruction";
808
902
  }
809
- if (instruction.info.type === "initializeAccount3") {
903
+ if (instruction.instructionType === "initializeAccount3") {
810
904
  return "SplTokenInitializeAccount3Instruction";
811
905
  }
812
- if (instruction.info.type === "initializeMultisig") {
906
+ if (instruction.instructionType === "initializeMultisig") {
813
907
  return "SplTokenInitializeMultisigInstruction";
814
908
  }
815
- if (instruction.info.type === "initializeMultisig2") {
909
+ if (instruction.instructionType === "initializeMultisig2") {
816
910
  return "SplTokenInitializeMultisig2Instruction";
817
911
  }
818
- if (instruction.info.type === "transfer") {
912
+ if (instruction.instructionType === "transfer") {
819
913
  return "SplTokenTransferInstruction";
820
914
  }
821
- if (instruction.info.type === "approve") {
915
+ if (instruction.instructionType === "approve") {
822
916
  return "SplTokenApproveInstruction";
823
917
  }
824
- if (instruction.info.type === "revoke") {
918
+ if (instruction.instructionType === "revoke") {
825
919
  return "SplTokenRevokeInstruction";
826
920
  }
827
- if (instruction.info.type === "setAuthority") {
921
+ if (instruction.instructionType === "setAuthority") {
828
922
  return "SplTokenSetAuthorityInstruction";
829
923
  }
830
- if (instruction.info.type === "mintTo") {
924
+ if (instruction.instructionType === "mintTo") {
831
925
  return "SplTokenMintToInstruction";
832
926
  }
833
- if (instruction.info.type === "burn") {
927
+ if (instruction.instructionType === "burn") {
834
928
  return "SplTokenBurnInstruction";
835
929
  }
836
- if (instruction.info.type === "closeAccount") {
930
+ if (instruction.instructionType === "closeAccount") {
837
931
  return "SplTokenCloseAccountInstruction";
838
932
  }
839
- if (instruction.info.type === "freezeAccount") {
933
+ if (instruction.instructionType === "freezeAccount") {
840
934
  return "SplTokenFreezeAccountInstruction";
841
935
  }
842
- if (instruction.info.type === "thawAccount") {
936
+ if (instruction.instructionType === "thawAccount") {
843
937
  return "SplTokenThawAccountInstruction";
844
938
  }
845
- if (instruction.info.type === "transferChecked") {
939
+ if (instruction.instructionType === "transferChecked") {
846
940
  return "SplTokenTransferCheckedInstruction";
847
941
  }
848
- if (instruction.info.type === "approveChecked") {
942
+ if (instruction.instructionType === "approveChecked") {
849
943
  return "SplTokenApproveCheckedInstruction";
850
944
  }
851
- if (instruction.info.type === "mintToChecked") {
945
+ if (instruction.instructionType === "mintToChecked") {
852
946
  return "SplTokenMintToCheckedInstruction";
853
947
  }
854
- if (instruction.info.type === "burnChecked") {
948
+ if (instruction.instructionType === "burnChecked") {
855
949
  return "SplTokenBurnCheckedInstruction";
856
950
  }
857
- if (instruction.info.type === "syncNative") {
951
+ if (instruction.instructionType === "syncNative") {
858
952
  return "SplTokenSyncNativeInstruction";
859
953
  }
860
- if (instruction.info.type === "getAccountDataSize") {
954
+ if (instruction.instructionType === "getAccountDataSize") {
861
955
  return "SplTokenGetAccountDataSizeInstruction";
862
956
  }
863
- if (instruction.info.type === "initializeImmutableOwner") {
957
+ if (instruction.instructionType === "initializeImmutableOwner") {
864
958
  return "SplTokenInitializeImmutableOwnerInstruction";
865
959
  }
866
- if (instruction.info.type === "amountToUiAmount") {
960
+ if (instruction.instructionType === "amountToUiAmount") {
867
961
  return "SplTokenAmountToUiAmountInstruction";
868
962
  }
869
- if (instruction.info.type === "uiAmountToAmount") {
963
+ if (instruction.instructionType === "uiAmountToAmount") {
870
964
  return "SplTokenUiAmountToAmountInstruction";
871
965
  }
872
- if (instruction.info.type === "initializeMintCloseAuthority") {
966
+ if (instruction.instructionType === "initializeMintCloseAuthority") {
873
967
  return "SplTokenInitializeMintCloseAuthorityInstruction";
874
968
  }
875
969
  }
876
- if (instruction.program === "stake") {
877
- if (instruction.info.type === "initialize") {
970
+ if (instruction.programName === "stake") {
971
+ if (instruction.instructionType === "initialize") {
878
972
  return "StakeInitializeInstruction";
879
973
  }
880
- if (instruction.info.type === "authorize") {
974
+ if (instruction.instructionType === "authorize") {
881
975
  return "StakeAuthorizeInstruction";
882
976
  }
883
- if (instruction.info.type === "delegate") {
977
+ if (instruction.instructionType === "delegate") {
884
978
  return "StakeDelegateStakeInstruction";
885
979
  }
886
- if (instruction.info.type === "split") {
980
+ if (instruction.instructionType === "split") {
887
981
  return "StakeSplitInstruction";
888
982
  }
889
- if (instruction.info.type === "withdraw") {
983
+ if (instruction.instructionType === "withdraw") {
890
984
  return "StakeWithdrawInstruction";
891
985
  }
892
- if (instruction.info.type === "deactivate") {
986
+ if (instruction.instructionType === "deactivate") {
893
987
  return "StakeDeactivateInstruction";
894
988
  }
895
- if (instruction.info.type === "setLockup") {
989
+ if (instruction.instructionType === "setLockup") {
896
990
  return "StakeSetLockupInstruction";
897
991
  }
898
- if (instruction.info.type === "merge") {
992
+ if (instruction.instructionType === "merge") {
899
993
  return "StakeMergeInstruction";
900
994
  }
901
- if (instruction.info.type === "authorizeWithSeed") {
995
+ if (instruction.instructionType === "authorizeWithSeed") {
902
996
  return "StakeAuthorizeWithSeedInstruction";
903
997
  }
904
- if (instruction.info.type === "initializeChecked") {
998
+ if (instruction.instructionType === "initializeChecked") {
905
999
  return "StakeInitializeCheckedInstruction";
906
1000
  }
907
- if (instruction.info.type === "authorizeChecked") {
1001
+ if (instruction.instructionType === "authorizeChecked") {
908
1002
  return "StakeAuthorizeCheckedInstruction";
909
1003
  }
910
- if (instruction.info.type === "authorizeCheckedWithSeed") {
1004
+ if (instruction.instructionType === "authorizeCheckedWithSeed") {
911
1005
  return "StakeAuthorizeCheckedWithSeedInstruction";
912
1006
  }
913
- if (instruction.info.type === "setLockupChecked") {
1007
+ if (instruction.instructionType === "setLockupChecked") {
914
1008
  return "StakeSetLockupCheckedInstruction";
915
1009
  }
916
- if (instruction.info.type === "deactivateDelinquent") {
1010
+ if (instruction.instructionType === "deactivateDelinquent") {
917
1011
  return "StakeDeactivateDelinquentInstruction";
918
1012
  }
919
- if (instruction.info.type === "redelegate") {
1013
+ if (instruction.instructionType === "redelegate") {
920
1014
  return "StakeRedelegateInstruction";
921
1015
  }
922
1016
  }
923
- if (instruction.program === "system") {
924
- if (instruction.info.type === "createAccount") {
1017
+ if (instruction.programName === "system") {
1018
+ if (instruction.instructionType === "createAccount") {
925
1019
  return "CreateAccountInstruction";
926
1020
  }
927
- if (instruction.info.type === "assign") {
1021
+ if (instruction.instructionType === "assign") {
928
1022
  return "AssignInstruction";
929
1023
  }
930
- if (instruction.info.type === "transfer") {
1024
+ if (instruction.instructionType === "transfer") {
931
1025
  return "TransferInstruction";
932
1026
  }
933
- if (instruction.info.type === "createAccountWithSeed") {
1027
+ if (instruction.instructionType === "createAccountWithSeed") {
934
1028
  return "CreateAccountWithSeedInstruction";
935
1029
  }
936
- if (instruction.info.type === "advanceNonceAccount") {
1030
+ if (instruction.instructionType === "advanceNonceAccount") {
937
1031
  return "AdvanceNonceAccountInstruction";
938
1032
  }
939
- if (instruction.info.type === "withdrawNonceAccount") {
1033
+ if (instruction.instructionType === "withdrawNonceAccount") {
940
1034
  return "WithdrawNonceAccountInstruction";
941
1035
  }
942
- if (instruction.info.type === "initializeNonceAccount") {
1036
+ if (instruction.instructionType === "initializeNonceAccount") {
943
1037
  return "InitializeNonceAccountInstruction";
944
1038
  }
945
- if (instruction.info.type === "authorizeNonceAccount") {
1039
+ if (instruction.instructionType === "authorizeNonceAccount") {
946
1040
  return "AuthorizeNonceAccountInstruction";
947
1041
  }
948
- if (instruction.info.type === "upgradeNonceAccount") {
1042
+ if (instruction.instructionType === "upgradeNonceAccount") {
949
1043
  return "UpgradeNonceAccountInstruction";
950
1044
  }
951
- if (instruction.info.type === "allocate") {
1045
+ if (instruction.instructionType === "allocate") {
952
1046
  return "AllocateInstruction";
953
1047
  }
954
- if (instruction.info.type === "allocateWithSeed") {
1048
+ if (instruction.instructionType === "allocateWithSeed") {
955
1049
  return "AllocateWithSeedInstruction";
956
1050
  }
957
- if (instruction.info.type === "assignWithSeed") {
1051
+ if (instruction.instructionType === "assignWithSeed") {
958
1052
  return "AssignWithSeedInstruction";
959
1053
  }
960
- if (instruction.info.type === "transferWithSeed") {
1054
+ if (instruction.instructionType === "transferWithSeed") {
961
1055
  return "TransferWithSeedInstruction";
962
1056
  }
963
1057
  }
964
- if (instruction.program === "vote") {
965
- if (instruction.info.type === "initialize") {
1058
+ if (instruction.programName === "vote") {
1059
+ if (instruction.instructionType === "initialize") {
966
1060
  return "VoteInitializeAccountInstruction";
967
1061
  }
968
- if (instruction.info.type === "authorize") {
1062
+ if (instruction.instructionType === "authorize") {
969
1063
  return "VoteAuthorizeInstruction";
970
1064
  }
971
- if (instruction.info.type === "authorizeWithSeed") {
1065
+ if (instruction.instructionType === "authorizeWithSeed") {
972
1066
  return "VoteAuthorizeWithSeedInstruction";
973
1067
  }
974
- if (instruction.info.type === "authorizeCheckedWithSeed") {
1068
+ if (instruction.instructionType === "authorizeCheckedWithSeed") {
975
1069
  return "VoteAuthorizeCheckedWithSeedInstruction";
976
1070
  }
977
- if (instruction.info.type === "vote") {
1071
+ if (instruction.instructionType === "vote") {
978
1072
  return "VoteVoteInstruction";
979
1073
  }
980
- if (instruction.info.type === "updatevotestate") {
1074
+ if (instruction.instructionType === "updatevotestate") {
981
1075
  return "VoteUpdateVoteStateInstruction";
982
1076
  }
983
- if (instruction.info.type === "updatevotestateswitch") {
1077
+ if (instruction.instructionType === "updatevotestateswitch") {
984
1078
  return "VoteUpdateVoteStateSwitchInstruction";
985
1079
  }
986
- if (instruction.info.type === "compactupdatevotestate") {
1080
+ if (instruction.instructionType === "compactupdatevotestate") {
987
1081
  return "VoteCompactUpdateVoteStateInstruction";
988
1082
  }
989
- if (instruction.info.type === "compactupdatevotestateswitch") {
1083
+ if (instruction.instructionType === "compactupdatevotestateswitch") {
990
1084
  return "VoteCompactUpdateVoteStateSwitchInstruction";
991
1085
  }
992
- if (instruction.info.type === "withdraw") {
1086
+ if (instruction.instructionType === "withdraw") {
993
1087
  return "VoteWithdrawInstruction";
994
1088
  }
995
- if (instruction.info.type === "updateValidatorIdentity") {
1089
+ if (instruction.instructionType === "updateValidatorIdentity") {
996
1090
  return "VoteUpdateValidatorIdentityInstruction";
997
1091
  }
998
- if (instruction.info.type === "updateCommission") {
1092
+ if (instruction.instructionType === "updateCommission") {
999
1093
  return "VoteUpdateCommissionInstruction";
1000
1094
  }
1001
- if (instruction.info.type === "voteSwitch") {
1095
+ if (instruction.instructionType === "voteSwitch") {
1002
1096
  return "VoteVoteSwitchInstruction";
1003
1097
  }
1004
- if (instruction.info.type === "authorizeChecked") {
1098
+ if (instruction.instructionType === "authorizeChecked") {
1005
1099
  return "VoteAuthorizeCheckedInstruction";
1006
1100
  }
1007
1101
  }
1008
- return "PartiallyDecodedInstruction";
1009
1102
  }
1010
- });
1011
- return memoisedParsedTransactionInstructionInterface;
1012
- };
1013
- var parsedTransactionInstructionType = (name, parsedInfoFields) => new GraphQLObjectType({
1014
- fields: {
1015
- parsed: object(name + "Parsed", {
1016
- info: object(name + "ParsedInfo", parsedInfoFields),
1017
- type: string()
1018
- }),
1019
- program: string(),
1020
- programId: string()
1021
- },
1022
- interfaces: [parsedTransactionInstructionInterface()],
1023
- name
1024
- });
1025
- var memoisedPartiallyDecodedTransactionInstruction;
1026
- var partiallyDecodedTransactionInstruction = () => {
1027
- if (!memoisedPartiallyDecodedTransactionInstruction)
1028
- memoisedPartiallyDecodedTransactionInstruction = new GraphQLObjectType({
1029
- fields: {
1030
- accounts: list(string()),
1031
- data: string(),
1032
- programId: string()
1033
- },
1034
- interfaces: [parsedTransactionInstructionInterface()],
1035
- name: "PartiallyDecodedInstruction"
1036
- });
1037
- return memoisedPartiallyDecodedTransactionInstruction;
1038
- };
1039
- var memoisedParsedInstructionsAddressLookupTable;
1040
- var parsedInstructionsAddressLookupTable = () => {
1041
- if (!memoisedParsedInstructionsAddressLookupTable)
1042
- memoisedParsedInstructionsAddressLookupTable = [
1043
- parsedTransactionInstructionType("CreateLookupTableInstruction", {
1044
- bumpSeed: number(),
1045
- lookupTableAccount: string(),
1046
- lookupTableAuthority: string(),
1047
- payerAccount: string(),
1048
- recentSlot: bigint(),
1049
- systemProgram: string()
1050
- }),
1051
- parsedTransactionInstructionType("FreezeLookupTableInstruction", {
1052
- lookupTableAccount: string(),
1053
- lookupTableAuthority: string()
1054
- }),
1055
- parsedTransactionInstructionType("ExtendLookupTableInstruction", {
1056
- lookupTableAccount: string(),
1057
- lookupTableAuthority: string(),
1058
- newAddresses: list(string()),
1059
- payerAccount: string(),
1060
- systemProgram: string()
1061
- }),
1062
- parsedTransactionInstructionType("DeactivateLookupTableInstruction", {
1063
- lookupTableAccount: string(),
1064
- lookupTableAuthority: string()
1065
- }),
1066
- parsedTransactionInstructionType("CloseLookupTableInstruction", {
1067
- lookupTableAccount: string(),
1068
- lookupTableAuthority: string(),
1069
- recipient: string()
1070
- })
1071
- ];
1072
- return memoisedParsedInstructionsAddressLookupTable;
1073
- };
1074
- var memoisedParsedInstructionsBpfLoader;
1075
- var parsedInstructionsBpfLoader = () => {
1076
- if (!memoisedParsedInstructionsBpfLoader)
1077
- memoisedParsedInstructionsBpfLoader = [
1078
- parsedTransactionInstructionType("BpfLoaderWriteInstruction", {
1079
- account: string(),
1080
- bytes: string(),
1081
- offset: number()
1082
- }),
1083
- parsedTransactionInstructionType("BpfLoaderFinalizeInstruction", {
1084
- account: string()
1085
- })
1086
- ];
1087
- return memoisedParsedInstructionsBpfLoader;
1088
- };
1089
- var memoisedParsedInstructionsBpfUpgradeableLoader;
1090
- var parsedInstructionsBpfUpgradeableLoader = () => {
1091
- if (!memoisedParsedInstructionsBpfUpgradeableLoader)
1092
- memoisedParsedInstructionsBpfUpgradeableLoader = [
1093
- parsedTransactionInstructionType("BpfUpgradeableLoaderInitializeBufferInstruction", {
1094
- account: string()
1095
- }),
1096
- parsedTransactionInstructionType("BpfUpgradeableLoaderWriteInstruction", {
1097
- account: string(),
1098
- authority: string(),
1099
- bytes: string(),
1100
- offset: number()
1101
- }),
1102
- parsedTransactionInstructionType("BpfUpgradeableLoaderDeployWithMaxDataLenInstruction", {
1103
- authority: string(),
1104
- bufferAccount: string(),
1105
- clockSysvar: string(),
1106
- maxDataLen: bigint(),
1107
- payerAccount: string(),
1108
- programAccount: string(),
1109
- programDataAccount: string(),
1110
- rentSysvar: string()
1111
- }),
1112
- parsedTransactionInstructionType("BpfUpgradeableLoaderUpgradeInstruction", {
1113
- authority: string(),
1114
- bufferAccount: string(),
1115
- clockSysvar: string(),
1116
- programAccount: string(),
1117
- programDataAccount: string(),
1118
- rentSysvar: string(),
1119
- spillAccount: string()
1120
- }),
1121
- parsedTransactionInstructionType("BpfUpgradeableLoaderSetAuthorityInstruction", {
1122
- account: string(),
1123
- authority: string(),
1124
- newAuthority: string()
1125
- }),
1126
- parsedTransactionInstructionType("BpfUpgradeableLoaderSetAuthorityCheckedInstruction", {
1127
- account: string(),
1128
- authority: string(),
1129
- newAuthority: string()
1130
- }),
1131
- parsedTransactionInstructionType("BpfUpgradeableLoaderCloseInstruction", {
1132
- account: string(),
1133
- authority: string(),
1134
- programAccount: string(),
1135
- recipient: string()
1136
- }),
1137
- parsedTransactionInstructionType("BpfUpgradeableLoaderExtendProgramInstruction", {
1138
- additionalBytes: bigint(),
1139
- payerAccount: string(),
1140
- programAccount: string(),
1141
- programDataAccount: string(),
1142
- systemProgram: string()
1143
- })
1144
- ];
1145
- return memoisedParsedInstructionsBpfUpgradeableLoader;
1146
- };
1147
- var memoisedParsedInstructionsSplAssociatedToken;
1148
- var parsedInstructionsSplAssociatedToken = () => {
1149
- if (!memoisedParsedInstructionsSplAssociatedToken)
1150
- memoisedParsedInstructionsSplAssociatedToken = [
1151
- parsedTransactionInstructionType("SplAssociatedTokenCreateInstruction", {
1152
- account: string(),
1153
- mint: string(),
1154
- source: string(),
1155
- systemProgram: string(),
1156
- tokenProgram: string(),
1157
- wallet: string()
1158
- }),
1159
- parsedTransactionInstructionType("SplAssociatedTokenCreateIdempotentInstruction", {
1160
- account: string(),
1161
- mint: string(),
1162
- source: string(),
1163
- systemProgram: string(),
1164
- tokenProgram: string(),
1165
- wallet: string()
1166
- }),
1167
- parsedTransactionInstructionType("SplAssociatedTokenRecoverNestedInstruction", {
1168
- destination: string(),
1169
- nestedMint: string(),
1170
- nestedOwner: string(),
1171
- nestedSource: string(),
1172
- ownerMint: string(),
1173
- tokenProgram: string(),
1174
- wallet: string()
1175
- })
1176
- ];
1177
- return memoisedParsedInstructionsSplAssociatedToken;
1178
- };
1179
- var memoisedParsedInstructionSplMemo;
1180
- var parsedInstructionSplMemo = () => {
1181
- if (!memoisedParsedInstructionSplMemo)
1182
- memoisedParsedInstructionSplMemo = new GraphQLObjectType({
1183
- fields: {
1184
- parsed: string(),
1185
- program: string(),
1186
- programId: string()
1187
- },
1188
- interfaces: [parsedTransactionInstructionInterface()],
1189
- name: "SplMemoInstruction"
1190
- });
1191
- return memoisedParsedInstructionSplMemo;
1192
- };
1193
- var memoisedParsedInstructionsSplToken;
1194
- var parsedInstructionsSplToken = () => {
1195
- if (!memoisedParsedInstructionsSplToken)
1196
- memoisedParsedInstructionsSplToken = [
1197
- parsedTransactionInstructionType("SplTokenInitializeMintInstruction", {
1198
- decimals: number(),
1199
- freezeAuthority: string(),
1200
- mint: string(),
1201
- mintAuthority: string(),
1202
- rentSysvar: string()
1203
- }),
1204
- parsedTransactionInstructionType("SplTokenInitializeMint2Instruction", {
1205
- decimals: number(),
1206
- freezeAuthority: string(),
1207
- mint: string(),
1208
- mintAuthority: string()
1209
- }),
1210
- parsedTransactionInstructionType("SplTokenInitializeAccountInstruction", {
1211
- account: string(),
1212
- mint: string(),
1213
- owner: string(),
1214
- rentSysvar: string()
1215
- }),
1216
- parsedTransactionInstructionType("SplTokenInitializeAccount2Instruction", {
1217
- account: string(),
1218
- mint: string(),
1219
- owner: string(),
1220
- rentSysvar: string()
1221
- }),
1222
- parsedTransactionInstructionType("SplTokenInitializeAccount3Instruction", {
1223
- account: string(),
1224
- mint: string(),
1225
- owner: string()
1226
- }),
1227
- parsedTransactionInstructionType("SplTokenInitializeMultisigInstruction", {
1228
- m: number(),
1229
- multisig: string(),
1230
- rentSysvar: string(),
1231
- signers: list(string())
1232
- }),
1233
- parsedTransactionInstructionType("SplTokenInitializeMultisig2Instruction", {
1234
- m: number(),
1235
- multisig: string(),
1236
- signers: list(string())
1237
- }),
1238
- parsedTransactionInstructionType("SplTokenTransferInstruction", {
1239
- amount: string(),
1240
- authority: string(),
1241
- destination: string(),
1242
- multisigAuthority: string(),
1243
- source: string()
1244
- }),
1245
- parsedTransactionInstructionType("SplTokenApproveInstruction", {
1246
- amount: string(),
1247
- delegate: string(),
1248
- multisigOwner: string(),
1249
- owner: string(),
1250
- source: string()
1251
- }),
1252
- parsedTransactionInstructionType("SplTokenRevokeInstruction", {
1253
- multisigOwner: string(),
1254
- owner: string(),
1255
- source: string()
1256
- }),
1257
- parsedTransactionInstructionType("SplTokenSetAuthorityInstruction", {
1258
- authority: string(),
1259
- authorityType: string(),
1260
- multisigAuthority: string(),
1261
- newAuthority: string()
1262
- }),
1263
- parsedTransactionInstructionType("SplTokenMintToInstruction", {
1264
- account: string(),
1265
- amount: string(),
1266
- authority: string(),
1267
- mint: string(),
1268
- mintAuthority: string(),
1269
- multisigMintAuthority: string()
1270
- }),
1271
- parsedTransactionInstructionType("SplTokenBurnInstruction", {
1272
- account: string(),
1273
- amount: string(),
1274
- authority: string(),
1275
- mint: string(),
1276
- multisigAuthority: string()
1277
- }),
1278
- parsedTransactionInstructionType("SplTokenCloseAccountInstruction", {
1279
- account: string(),
1280
- destination: string(),
1281
- multisigOwner: string(),
1282
- owner: string()
1283
- }),
1284
- parsedTransactionInstructionType("SplTokenFreezeAccountInstruction", {
1285
- account: string(),
1286
- freezeAuthority: string(),
1287
- mint: string(),
1288
- multisigFreezeAuthority: string()
1289
- }),
1290
- parsedTransactionInstructionType("SplTokenThawAccountInstruction", {
1291
- account: string(),
1292
- freezeAuthority: string(),
1293
- mint: string(),
1294
- multisigFreezeAuthority: string()
1295
- }),
1296
- parsedTransactionInstructionType("SplTokenTransferCheckedInstruction", {
1297
- authority: string(),
1298
- destination: string(),
1299
- mint: string(),
1300
- multisigAuthority: string(),
1301
- source: string(),
1302
- tokenAmount: string()
1303
- }),
1304
- parsedTransactionInstructionType("SplTokenApproveCheckedInstruction", {
1305
- delegate: string(),
1306
- mint: string(),
1307
- multisigOwner: string(),
1308
- owner: string(),
1309
- source: string(),
1310
- tokenAmount: string()
1311
- }),
1312
- parsedTransactionInstructionType("SplTokenMintToCheckedInstruction", {
1313
- account: string(),
1314
- authority: string(),
1315
- mint: string(),
1316
- mintAuthority: string(),
1317
- multisigMintAuthority: string(),
1318
- tokenAmount: string()
1319
- }),
1320
- parsedTransactionInstructionType("SplTokenBurnCheckedInstruction", {
1321
- account: string(),
1322
- authority: string(),
1323
- mint: string(),
1324
- multisigAuthority: string(),
1325
- tokenAmount: string()
1326
- }),
1327
- parsedTransactionInstructionType("SplTokenSyncNativeInstruction", {
1328
- account: string()
1329
- }),
1330
- parsedTransactionInstructionType("SplTokenGetAccountDataSizeInstruction", {
1331
- extensionTypes: list(string()),
1332
- mint: string()
1333
- }),
1334
- parsedTransactionInstructionType("SplTokenInitializeImmutableOwnerInstruction", {
1335
- account: string()
1336
- }),
1337
- parsedTransactionInstructionType("SplTokenAmountToUiAmountInstruction", {
1338
- amount: string(),
1339
- mint: string()
1340
- }),
1341
- parsedTransactionInstructionType("SplTokenUiAmountToAmountInstruction", {
1342
- mint: string(),
1343
- uiAmount: string()
1344
- }),
1345
- parsedTransactionInstructionType("SplTokenInitializeMintCloseAuthorityInstruction", {
1346
- mint: string(),
1347
- newAuthority: string()
1348
- })
1349
- // TODO: Extensions!
1350
- // - TransferFeeExtension
1351
- // - ConfidentialTransferFeeExtension
1352
- // - DefaultAccountStateExtension
1353
- // - Reallocate
1354
- // - MemoTransferExtension
1355
- // - CreateNativeMint
1356
- // - InitializeNonTransferableMint
1357
- // - InterestBearingMintExtension
1358
- // - CpiGuardExtension
1359
- // - InitializePermanentDelegate
1360
- // - TransferHookExtension
1361
- // - ConfidentialTransferFeeExtension
1362
- // - WithdrawExcessLamports
1363
- // - MetadataPointerExtension
1364
- ];
1365
- return memoisedParsedInstructionsSplToken;
1366
- };
1367
- var memoisedLockup;
1368
- var lockup = () => {
1369
- if (!memoisedLockup)
1370
- memoisedLockup = new GraphQLObjectType({
1371
- fields: {
1372
- custodian: string(),
1373
- epoch: bigint(),
1374
- unixTimestamp: bigint()
1375
- },
1376
- name: "Lockup"
1377
- });
1378
- return memoisedLockup;
1379
- };
1380
- var memoisedParsedInstructionsStake;
1381
- var parsedInstructionsStake = () => {
1382
- if (!memoisedParsedInstructionsStake)
1383
- memoisedParsedInstructionsStake = [
1384
- parsedTransactionInstructionType("StakeInitializeInstruction", {
1385
- authorized: object("StakeInitializeInstructionAuthorized", {
1386
- staker: string(),
1387
- withdrawer: string()
1388
- }),
1389
- lockup: object("StakeInitializeInstructionLockup", {
1390
- custodian: string(),
1391
- epoch: bigint(),
1392
- unixTimestamp: bigint()
1393
- }),
1394
- rentSysvar: string(),
1395
- stakeAccount: string()
1396
- }),
1397
- parsedTransactionInstructionType("StakeAuthorizeInstruction", {
1398
- authority: string(),
1399
- authorityType: string(),
1400
- clockSysvar: string(),
1401
- custodian: string(),
1402
- newAuthority: string(),
1403
- stakeAccount: string()
1404
- }),
1405
- parsedTransactionInstructionType("StakeDelegateStakeInstruction", {
1406
- clockSysvar: string(),
1407
- stakeAccount: string(),
1408
- stakeAuthority: string(),
1409
- stakeConfigAccount: string(),
1410
- stakeHistorySysvar: string(),
1411
- voteAccount: string()
1412
- }),
1413
- parsedTransactionInstructionType("StakeSplitInstruction", {
1414
- lamports: bigint(),
1415
- newSplitAccount: string(),
1416
- stakeAccount: string(),
1417
- stakeAuthority: string()
1418
- }),
1419
- parsedTransactionInstructionType("StakeWithdrawInstruction", {
1420
- clockSysvar: string(),
1421
- destination: string(),
1422
- lamports: bigint(),
1423
- stakeAccount: string(),
1424
- withdrawAuthority: string()
1425
- }),
1426
- parsedTransactionInstructionType("StakeDeactivateInstruction", {
1427
- clockSysvar: string(),
1428
- stakeAccount: string(),
1429
- stakeAuthority: string()
1430
- }),
1431
- parsedTransactionInstructionType("StakeSetLockupInstruction", {
1432
- custodian: string(),
1433
- lockup: type(lockup()),
1434
- stakeAccount: string()
1435
- }),
1436
- parsedTransactionInstructionType("StakeMergeInstruction", {
1437
- clockSysvar: string(),
1438
- destination: string(),
1439
- source: string(),
1440
- stakeAuthority: string(),
1441
- stakeHistorySysvar: string()
1442
- }),
1443
- parsedTransactionInstructionType("StakeAuthorizeWithSeedInstruction", {
1444
- authorityBase: string(),
1445
- authorityOwner: string(),
1446
- authoritySeed: string(),
1447
- authorityType: string(),
1448
- clockSysvar: string(),
1449
- custodian: string(),
1450
- newAuthorized: string(),
1451
- stakeAccount: string()
1452
- }),
1453
- parsedTransactionInstructionType("StakeInitializeCheckedInstruction", {
1454
- rentSysvar: string(),
1455
- stakeAccount: string(),
1456
- staker: string(),
1457
- withdrawer: string()
1458
- }),
1459
- parsedTransactionInstructionType("StakeAuthorizeCheckedInstruction", {
1460
- authority: string(),
1461
- authorityType: string(),
1462
- clockSysvar: string(),
1463
- custodian: string(),
1464
- newAuthority: string(),
1465
- stakeAccount: string()
1466
- }),
1467
- parsedTransactionInstructionType("StakeAuthorizeCheckedWithSeedInstruction", {
1468
- authorityBase: string(),
1469
- authorityOwner: string(),
1470
- authoritySeed: string(),
1471
- authorityType: string(),
1472
- clockSysvar: string(),
1473
- custodian: string(),
1474
- newAuthorized: string(),
1475
- stakeAccount: string()
1476
- }),
1477
- parsedTransactionInstructionType("StakeSetLockupCheckedInstruction", {
1478
- custodian: string(),
1479
- lockup: type(lockup()),
1480
- stakeAccount: string()
1481
- }),
1482
- parsedTransactionInstructionType("StakeDeactivateDelinquentInstruction", {
1483
- referenceVoteAccount: string(),
1484
- stakeAccount: string(),
1485
- voteAccount: string()
1486
- }),
1487
- parsedTransactionInstructionType("StakeRedelegateInstruction", {
1488
- newStakeAccount: string(),
1489
- stakeAccount: string(),
1490
- stakeAuthority: string(),
1491
- stakeConfigAccount: string(),
1492
- voteAccount: string()
1493
- })
1494
- ];
1495
- return memoisedParsedInstructionsStake;
1496
- };
1497
- var memoisedParsedInstructionsSystem;
1498
- var parsedInstructionsSystem = () => {
1499
- if (!memoisedParsedInstructionsSystem)
1500
- memoisedParsedInstructionsSystem = [
1501
- parsedTransactionInstructionType("CreateAccountInstruction", {
1502
- lamports: bigint(),
1503
- newAccount: string(),
1504
- owner: string(),
1505
- source: string(),
1506
- space: bigint()
1507
- }),
1508
- parsedTransactionInstructionType("AssignInstruction", {
1509
- owner: string()
1510
- }),
1511
- parsedTransactionInstructionType("TransferInstruction", {
1512
- amount: string(),
1513
- lamports: number(),
1514
- source: string()
1515
- }),
1516
- parsedTransactionInstructionType("CreateAccountWithSeedInstruction", {
1517
- base: string(),
1518
- lamports: bigint(),
1519
- owner: string(),
1520
- seed: string(),
1521
- space: bigint()
1522
- }),
1523
- parsedTransactionInstructionType("AdvanceNonceAccountInstruction", {
1524
- nonceAccount: string(),
1525
- nonceAuthority: string(),
1526
- recentBlockhashesSysvar: string()
1527
- }),
1528
- parsedTransactionInstructionType("WithdrawNonceAccountInstruction", {
1529
- destination: string(),
1530
- lamports: bigint(),
1531
- nonceAccount: string(),
1532
- nonceAuthority: string(),
1533
- recentBlockhashesSysvar: string(),
1534
- rentSysvar: string()
1535
- }),
1536
- parsedTransactionInstructionType("InitializeNonceAccountInstruction", {
1537
- nonceAccount: string(),
1538
- nonceAuthority: string(),
1539
- recentBlockhashesSysvar: string(),
1540
- rentSysvar: string()
1541
- }),
1542
- parsedTransactionInstructionType("AuthorizeNonceAccountInstruction", {
1543
- newAuthorized: string(),
1544
- nonceAccount: string(),
1545
- nonceAuthority: string()
1546
- }),
1547
- parsedTransactionInstructionType("UpgradeNonceAccountInstruction", {
1548
- nonceAccount: string()
1549
- }),
1550
- parsedTransactionInstructionType("AllocateInstruction", {
1551
- account: string(),
1552
- space: bigint()
1553
- }),
1554
- parsedTransactionInstructionType("AllocateWithSeedInstruction", {
1555
- account: string(),
1556
- base: string(),
1557
- owner: string(),
1558
- seed: string(),
1559
- space: bigint()
1560
- }),
1561
- parsedTransactionInstructionType("AssignWithSeedInstruction", {
1562
- account: string(),
1563
- base: string(),
1564
- owner: string(),
1565
- seed: string()
1566
- }),
1567
- parsedTransactionInstructionType("TransferWithSeedInstruction", {
1568
- destination: string(),
1569
- lamports: bigint(),
1570
- source: string(),
1571
- sourceBase: string(),
1572
- sourceOwner: string(),
1573
- sourceSeed: string()
1574
- })
1575
- ];
1576
- return memoisedParsedInstructionsSystem;
1577
- };
1578
- var memoisedVote;
1579
- var vote = () => {
1580
- if (!memoisedVote)
1581
- memoisedVote = new GraphQLObjectType({
1582
- fields: {
1583
- hash: string(),
1584
- slots: list(bigint()),
1585
- timestamp: bigint()
1586
- },
1587
- name: "Vote"
1588
- });
1589
- return memoisedVote;
1590
- };
1591
- var memoisedVoteStateUpdate;
1592
- var voteStateUpdate = () => {
1593
- if (!memoisedVoteStateUpdate)
1594
- memoisedVoteStateUpdate = new GraphQLObjectType({
1595
- fields: {
1596
- hash: string(),
1597
- lockouts: list(
1598
- object("VoteStateUpdateLockout", {
1599
- confirmationCount: number(),
1600
- slot: bigint()
1601
- })
1602
- ),
1603
- root: bigint(),
1604
- timestamp: bigint()
1605
- },
1606
- name: "VoteStateUpdate"
1607
- });
1608
- return memoisedVoteStateUpdate;
1103
+ return "GenericInstruction";
1104
+ }
1105
+ },
1106
+ TransferInstruction: {
1107
+ destination: resolveAccount("destination"),
1108
+ source: resolveAccount("source")
1109
+ },
1110
+ TransferWithSeedInstruction: {
1111
+ destination: resolveAccount("destination"),
1112
+ source: resolveAccount("source"),
1113
+ sourceOwner: resolveAccount("sourceOwner")
1114
+ },
1115
+ UpgradeNonceAccountInstruction: {
1116
+ nonceAccount: resolveAccount("nonceAccount"),
1117
+ nonceAuthority: resolveAccount("nonceAuthority")
1118
+ },
1119
+ VoteAuthorizeCheckedInstruction: {
1120
+ authority: resolveAccount("authority"),
1121
+ newAuthority: resolveAccount("newAuthority"),
1122
+ voteAccount: resolveAccount("voteAccount")
1123
+ },
1124
+ VoteAuthorizeCheckedWithSeedInstruction: {
1125
+ authorityOwner: resolveAccount("authorityOwner"),
1126
+ newAuthority: resolveAccount("newAuthority"),
1127
+ voteAccount: resolveAccount("voteAccount")
1128
+ },
1129
+ VoteAuthorizeInstruction: {
1130
+ authority: resolveAccount("authority"),
1131
+ newAuthority: resolveAccount("newAuthority"),
1132
+ voteAccount: resolveAccount("voteAccount")
1133
+ },
1134
+ VoteAuthorizeWithSeedInstruction: {
1135
+ authorityOwner: resolveAccount("authorityOwner"),
1136
+ newAuthority: resolveAccount("newAuthority"),
1137
+ voteAccount: resolveAccount("voteAccount")
1138
+ },
1139
+ VoteCompactUpdateVoteStateInstruction: {
1140
+ voteAccount: resolveAccount("voteAccount"),
1141
+ voteAuthority: resolveAccount("voteAuthority")
1142
+ },
1143
+ VoteCompactUpdateVoteStateSwitchInstruction: {
1144
+ voteAccount: resolveAccount("voteAccount"),
1145
+ voteAuthority: resolveAccount("voteAuthority")
1146
+ },
1147
+ VoteInitializeAccountInstruction: {
1148
+ authorizedVoter: resolveAccount("authorizedVoter"),
1149
+ authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
1150
+ node: resolveAccount("node"),
1151
+ voteAccount: resolveAccount("voteAccount")
1152
+ },
1153
+ VoteUpdateCommissionInstruction: {
1154
+ voteAccount: resolveAccount("voteAccount"),
1155
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1156
+ },
1157
+ VoteUpdateValidatorIdentityInstruction: {
1158
+ newValidatorIdentity: resolveAccount("newValidatorIdentity"),
1159
+ voteAccount: resolveAccount("voteAccount"),
1160
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1161
+ },
1162
+ VoteUpdateVoteStateInstruction: {
1163
+ voteAccount: resolveAccount("voteAccount"),
1164
+ voteAuthority: resolveAccount("voteAuthority")
1165
+ },
1166
+ VoteUpdateVoteStateSwitchInstruction: {
1167
+ voteAccount: resolveAccount("voteAccount"),
1168
+ voteAuthority: resolveAccount("voteAuthority")
1169
+ },
1170
+ VoteVoteInstruction: {
1171
+ voteAccount: resolveAccount("voteAccount"),
1172
+ voteAuthority: resolveAccount("voteAuthority")
1173
+ },
1174
+ VoteVoteSwitchInstruction: {
1175
+ voteAccount: resolveAccount("voteAccount"),
1176
+ voteAuthority: resolveAccount("voteAuthority")
1177
+ },
1178
+ VoteWithdrawInstruction: {
1179
+ voteAccount: resolveAccount("voteAccount"),
1180
+ withdrawAuthority: resolveAccount("withdrawAuthority")
1181
+ },
1182
+ WithdrawNonceAccountInstruction: {
1183
+ destination: resolveAccount("destination"),
1184
+ nonceAccount: resolveAccount("nonceAccount"),
1185
+ nonceAuthority: resolveAccount("nonceAuthority")
1186
+ }
1609
1187
  };
1610
- var memoisedParsedInstructionsVote;
1611
- var parsedInstructionsVote = () => {
1612
- if (!memoisedParsedInstructionsVote)
1613
- memoisedParsedInstructionsVote = [
1614
- parsedTransactionInstructionType("VoteInitializeAccountInstruction", {
1615
- authorizedVoter: string(),
1616
- authorizedWithdrawer: string(),
1617
- clockSysvar: string(),
1618
- commission: number(),
1619
- node: string(),
1620
- rentSysvar: string(),
1621
- voteAccount: string()
1622
- }),
1623
- parsedTransactionInstructionType("VoteAuthorizeInstruction", {
1624
- authority: string(),
1625
- authorityType: string(),
1626
- clockSysvar: string(),
1627
- newAuthority: string(),
1628
- voteAccount: string()
1629
- }),
1630
- parsedTransactionInstructionType("VoteAuthorizeWithSeedInstruction", {
1631
- authorityBaseKey: string(),
1632
- authorityOwner: string(),
1633
- authoritySeed: string(),
1634
- authorityType: string(),
1635
- clockSysvar: string(),
1636
- newAuthority: string(),
1637
- voteAccount: string()
1638
- }),
1639
- parsedTransactionInstructionType("VoteAuthorizeCheckedWithSeedInstruction", {
1640
- authorityBaseKey: string(),
1641
- authorityOwner: string(),
1642
- authoritySeed: string(),
1643
- authorityType: string(),
1644
- clockSysvar: string(),
1645
- newAuthority: string(),
1646
- voteAccount: string()
1647
- }),
1648
- parsedTransactionInstructionType("VoteVoteInstruction", {
1649
- clockSysvar: string(),
1650
- slotHashedSysvar: string(),
1651
- vote: type(vote()),
1652
- voteAccount: string(),
1653
- voteAuthority: string()
1654
- }),
1655
- parsedTransactionInstructionType("VoteUpdateVoteStateInstruction", {
1656
- hash: string(),
1657
- voteAccount: string(),
1658
- voteAuthority: string(),
1659
- voteStateUpdate: type(voteStateUpdate())
1660
- }),
1661
- parsedTransactionInstructionType("VoteUpdateVoteStateSwitchInstruction", {
1662
- hash: string(),
1663
- voteAccount: string(),
1664
- voteAuthority: string(),
1665
- voteStateUpdate: type(voteStateUpdate())
1666
- }),
1667
- parsedTransactionInstructionType("VoteCompactUpdateVoteStateInstruction", {
1668
- hash: string(),
1669
- voteAccount: string(),
1670
- voteAuthority: string(),
1671
- voteStateUpdate: type(voteStateUpdate())
1672
- }),
1673
- parsedTransactionInstructionType("VoteCompactUpdateVoteStateSwitchInstruction", {
1674
- hash: string(),
1675
- voteAccount: string(),
1676
- voteAuthority: string(),
1677
- voteStateUpdate: type(voteStateUpdate())
1678
- }),
1679
- parsedTransactionInstructionType("VoteWithdrawInstruction", {
1680
- destination: string(),
1681
- lamports: bigint(),
1682
- voteAccount: string(),
1683
- withdrawAuthority: string()
1684
- }),
1685
- parsedTransactionInstructionType("VoteUpdateValidatorIdentityInstruction", {
1686
- newValidatorIdentity: string(),
1687
- voteAccount: string(),
1688
- withdrawAuthority: string()
1689
- }),
1690
- parsedTransactionInstructionType("VoteUpdateCommissionInstruction", {
1691
- commission: string(),
1692
- voteAccount: string(),
1693
- withdrawAuthority: string()
1694
- }),
1695
- parsedTransactionInstructionType("VoteVoteSwitchInstruction", {
1696
- clockSysvar: string(),
1697
- hash: string(),
1698
- slotHashesSysvar: string(),
1699
- vote: type(vote()),
1700
- voteAccount: string(),
1701
- voteAuthority: string()
1702
- }),
1703
- parsedTransactionInstructionType("VoteAuthorizeCheckedInstruction", {
1704
- authority: string(),
1705
- authorityType: string(),
1706
- clockSysvar: string(),
1707
- newAuthority: string(),
1708
- voteAccount: string()
1188
+
1189
+ // src/resolvers/program-accounts.ts
1190
+ function resolveProgramAccounts(fieldName) {
1191
+ return async (parent, args, context, info) => {
1192
+ const programAddress = fieldName ? parent[fieldName] : args.programAddress;
1193
+ if (!programAddress) {
1194
+ return null;
1195
+ }
1196
+ if (onlyPresentFieldRequested("programAddress", info)) {
1197
+ return { programAddress };
1198
+ }
1199
+ const programAccounts = await context.loaders.programAccounts.load({ ...args, programAddress });
1200
+ return programAccounts === null ? { programAddress } : programAccounts.map(
1201
+ (programAccount) => transformLoadedAccount({
1202
+ account: programAccount.account,
1203
+ address: programAccount.pubkey,
1204
+ encoding: args.encoding
1709
1205
  })
1710
- ];
1711
- return memoisedParsedInstructionsVote;
1712
- };
1713
- var memoisedTransactionMetaInterfaceFields;
1714
- var transactionMetaInterfaceFields = () => {
1715
- if (!memoisedTransactionMetaInterfaceFields)
1716
- memoisedTransactionMetaInterfaceFields = {
1717
- computeUnitsConsumed: bigint(),
1718
- err: string(),
1719
- fee: bigint(),
1720
- format: string(),
1721
- loadedAddresses: type(transactionMetaLoadedAddresses()),
1722
- logMessages: list(string()),
1723
- postBalances: list(bigint()),
1724
- postTokenBalances: list(type(tokenBalance())),
1725
- preBalances: list(bigint()),
1726
- preTokenBalances: list(type(tokenBalance())),
1727
- returnData: type(returnData()),
1728
- rewards: list(type(reward())),
1729
- status: type(transactionStatus())
1730
- };
1731
- return memoisedTransactionMetaInterfaceFields;
1732
- };
1733
- var memoisedTransactionMetaInterface;
1734
- var transactionMetaInterface = () => {
1735
- if (!memoisedTransactionMetaInterface)
1736
- memoisedTransactionMetaInterface = new GraphQLInterfaceType({
1737
- fields: {
1738
- ...transactionMetaInterfaceFields()
1739
- },
1740
- name: "TransactionMeta",
1741
- resolveType(meta) {
1742
- if (meta.format === "parsed") {
1743
- return "TransactionMetaParsed";
1744
- }
1745
- return "TransactionMetaUnparsed";
1746
- }
1747
- });
1748
- return memoisedTransactionMetaInterface;
1749
- };
1750
- var transactionMetaType = (name, description, innerInstructions) => new GraphQLObjectType({
1751
- description,
1752
- fields: {
1753
- ...transactionMetaInterfaceFields(),
1754
- innerInstructions
1755
- },
1756
- interfaces: [transactionMetaInterface()],
1757
- name
1758
- });
1759
- var memoisedTransactionMetaUnparsed;
1760
- var transactionMetaUnparsed = () => {
1761
- if (!memoisedTransactionMetaUnparsed)
1762
- memoisedTransactionMetaUnparsed = transactionMetaType(
1763
- "TransactionMetaUnparsed",
1764
- "Non-parsed transaction meta",
1765
- list(
1766
- object("TransactionMetaInnerInstructionsUnparsed", {
1767
- index: number(),
1768
- instructions: list(
1769
- object("TransactionMetaInnerInstructionsUnparsedInstruction", {
1770
- index: number(),
1771
- instructions: list(type(transactionInstruction()))
1772
- })
1773
- )
1774
- })
1775
- )
1776
- );
1777
- return memoisedTransactionMetaUnparsed;
1778
- };
1779
- var memoisedTransactionMetaParsed;
1780
- var transactionMetaParsed = () => {
1781
- if (!memoisedTransactionMetaParsed)
1782
- memoisedTransactionMetaParsed = transactionMetaType(
1783
- "TransactionMetaParsed",
1784
- "Parsed transaction meta",
1785
- list(
1786
- object("TransactionMetaInnerInstructionsParsed", {
1787
- index: number(),
1788
- instructions: list(type(parsedTransactionInstructionInterface()))
1789
- })
1790
- )
1791
- );
1792
- return memoisedTransactionMetaParsed;
1793
- };
1794
- var memoisedTransactionMessageInterfaceFields;
1795
- var transactionMessageInterfaceFields = () => {
1796
- if (!memoisedTransactionMessageInterfaceFields)
1797
- memoisedTransactionMessageInterfaceFields = {
1798
- addressTableLookups: list(type(addressTableLookup())),
1799
- format: string(),
1800
- header: object("TransactionJsonTransactionHeader", {
1801
- numReadonlySignedAccounts: number(),
1802
- numReadonlyUnsignedAccounts: number(),
1803
- numRequiredSignatures: number()
1804
- }),
1805
- recentBlockhash: string()
1806
- };
1807
- return memoisedTransactionMessageInterfaceFields;
1808
- };
1809
- var memoisedTransactionMessageInterface;
1810
- var transactionMessageInterface = () => {
1811
- if (!memoisedTransactionMessageInterface)
1812
- memoisedTransactionMessageInterface = new GraphQLInterfaceType({
1813
- fields: {
1814
- ...transactionMessageInterfaceFields()
1815
- },
1816
- name: "TransactionMessage",
1817
- resolveType(message) {
1818
- if (message.format === "parsed") {
1819
- return "TransactionMessageParsed";
1820
- }
1821
- return "TransactionMessageUnparsed";
1822
- }
1823
- });
1824
- return memoisedTransactionMessageInterface;
1825
- };
1826
- var transactionMessageType = (name, description, accountKeys, instructions) => new GraphQLObjectType({
1827
- description,
1828
- fields: {
1829
- ...transactionMessageInterfaceFields(),
1830
- accountKeys,
1831
- instructions
1832
- },
1833
- interfaces: [transactionMessageInterface()],
1834
- name
1835
- });
1836
- var memoisedTransactionMessageUnparsed;
1837
- var transactionMessageUnparsed = () => {
1838
- if (!memoisedTransactionMessageUnparsed)
1839
- memoisedTransactionMessageUnparsed = transactionMessageType(
1840
- "TransactionMessageUnparsed",
1841
- "Non-parsed transaction message",
1842
- list(string()),
1843
- list(type(transactionInstruction()))
1844
- );
1845
- return memoisedTransactionMessageUnparsed;
1846
- };
1847
- var memoisedTransactionMessageParsed;
1848
- var transactionMessageParsed = () => {
1849
- if (!memoisedTransactionMessageParsed)
1850
- memoisedTransactionMessageParsed = transactionMessageType(
1851
- "TransactionMessageParsed",
1852
- "Parsed transaction message",
1853
- list(
1854
- object("transactionMessageParsedAccountKey", {
1855
- pubkey: string(),
1856
- signer: boolean(),
1857
- source: string(),
1858
- writable: boolean()
1859
- })
1860
- ),
1861
- list(type(parsedTransactionInstructionInterface()))
1862
- );
1863
- return memoisedTransactionMessageParsed;
1864
- };
1865
- var memoisedTransactionTransaction;
1866
- var transactionTransaction = () => {
1867
- if (!memoisedTransactionTransaction)
1868
- memoisedTransactionTransaction = new GraphQLObjectType({
1869
- fields: {
1870
- message: type(transactionMessageInterface()),
1871
- signatures: list(string())
1872
- },
1873
- name: "TransactionTransaction"
1874
- });
1875
- return memoisedTransactionTransaction;
1876
- };
1877
- var memoisedTransactionInterfaceFields;
1878
- var transactionInterfaceFields = () => {
1879
- if (!memoisedTransactionInterfaceFields)
1880
- memoisedTransactionInterfaceFields = {
1881
- blockTime: bigint(),
1882
- encoding: string(),
1883
- meta: type(transactionMetaInterface()),
1884
- slot: bigint()
1885
- };
1886
- return memoisedTransactionInterfaceFields;
1887
- };
1888
- var memoisedTransactionInterface;
1889
- var transactionInterface = () => {
1890
- if (!memoisedTransactionInterface)
1891
- memoisedTransactionInterface = new GraphQLInterfaceType({
1892
- fields: {
1893
- ...transactionInterfaceFields()
1894
- },
1895
- name: "Transaction",
1896
- resolveType(transaction) {
1897
- if (transaction.encoding === "base58") {
1898
- return "TransactionBase58";
1899
- }
1900
- if (transaction.encoding === "base64") {
1901
- return "TransactionBase64";
1902
- }
1903
- if (transaction.encoding === "json") {
1904
- return "TransactionJson";
1905
- }
1906
- return "TransactionJsonParsed";
1907
- }
1908
- });
1909
- return memoisedTransactionInterface;
1910
- };
1911
- var transactionType = (name, description, transaction) => new GraphQLObjectType({
1912
- description,
1913
- fields: {
1914
- ...transactionInterfaceFields(),
1915
- transaction
1916
- },
1917
- interfaces: [transactionInterface()],
1918
- name
1919
- });
1920
- var memoisedTransactionBase58;
1921
- var transactionBase58 = () => {
1922
- if (!memoisedTransactionBase58)
1923
- memoisedTransactionBase58 = transactionType(
1924
- "TransactionBase58",
1925
- "A Solana transaction as base58 encoded data",
1926
- string()
1927
- );
1928
- return memoisedTransactionBase58;
1929
- };
1930
- var memoisedTransactionBase64;
1931
- var transactionBase64 = () => {
1932
- if (!memoisedTransactionBase64)
1933
- memoisedTransactionBase64 = transactionType(
1934
- "TransactionBase64",
1935
- "A Solana transaction as base64 encoded data",
1936
- string()
1937
- );
1938
- return memoisedTransactionBase64;
1939
- };
1940
- var memoisedTransactionJson;
1941
- var transactionJson = () => {
1942
- if (!memoisedTransactionJson)
1943
- memoisedTransactionJson = transactionType(
1944
- "TransactionJson",
1945
- "A Solana transaction as a JSON object",
1946
- type(transactionTransaction())
1947
- );
1948
- return memoisedTransactionJson;
1949
- };
1950
- var memoisedTransactionJsonParsed;
1951
- var transactionJsonParsed = () => {
1952
- if (!memoisedTransactionJsonParsed)
1953
- memoisedTransactionJsonParsed = transactionType(
1954
- "TransactionJsonParsed",
1955
- "A Solana transaction as a parsed JSON object",
1956
- type(transactionTransaction())
1957
1206
  );
1958
- return memoisedTransactionJsonParsed;
1959
- };
1960
- var memoisedTransactionTypes;
1961
- var transactionTypes = () => {
1962
- if (!memoisedTransactionTypes)
1963
- memoisedTransactionTypes = [
1964
- partiallyDecodedTransactionInstruction(),
1965
- ...parsedInstructionsAddressLookupTable(),
1966
- ...parsedInstructionsBpfLoader(),
1967
- ...parsedInstructionsBpfUpgradeableLoader(),
1968
- ...parsedInstructionsStake(),
1969
- ...parsedInstructionsSplAssociatedToken(),
1970
- parsedInstructionSplMemo(),
1971
- ...parsedInstructionsSplToken(),
1972
- ...parsedInstructionsSystem(),
1973
- ...parsedInstructionsVote(),
1974
- transactionMetaUnparsed(),
1975
- transactionMetaParsed(),
1976
- transactionMessageUnparsed(),
1977
- transactionMessageParsed(),
1978
- transactionBase58(),
1979
- transactionBase64(),
1980
- transactionJson(),
1981
- transactionJsonParsed()
1982
- ];
1983
- return memoisedTransactionTypes;
1984
- };
1207
+ };
1208
+ }
1985
1209
 
1986
- // src/schema/transaction/query.ts
1987
- var transactionQuery = () => ({
1988
- transaction: {
1989
- args: {
1990
- commitment: type(commitmentInputType()),
1991
- encoding: type(transactionEncodingInputType()),
1992
- maxSupportedTransactionVersion: type(maxSupportedTransactionVersionInputType()),
1993
- signature: nonNull(string())
1994
- },
1995
- resolve: (_parent, args, context) => context.resolveTransaction(args),
1996
- type: transactionInterface()
1210
+ // src/resolvers/root.ts
1211
+ var rootResolvers = {
1212
+ Query: {
1213
+ account: resolveAccount(),
1214
+ block: resolveBlock(),
1215
+ programAccounts: resolveProgramAccounts(),
1216
+ transaction: resolveTransaction()
1997
1217
  }
1998
- });
1999
-
2000
- // src/schema/block/types.ts
2001
- var memoisedTransactionForAccounts;
2002
- var transactionForAccounts = () => {
2003
- if (!memoisedTransactionForAccounts)
2004
- memoisedTransactionForAccounts = new GraphQLObjectType({
2005
- fields: {
2006
- meta: object("TransactionMetaForAccounts", {
2007
- computeUnitsUsed: bigint(),
2008
- err: string(),
2009
- fee: bigint(),
2010
- format: string(),
2011
- loadedAddresses: type(transactionMetaLoadedAddresses()),
2012
- logMessages: list(string()),
2013
- postBalances: list(bigint()),
2014
- postTokenBalances: list(type(tokenBalance())),
2015
- preBalances: list(bigint()),
2016
- preTokenBalances: list(type(tokenBalance())),
2017
- returnData: type(returnData()),
2018
- rewards: list(type(reward())),
2019
- status: type(transactionStatus())
2020
- }),
2021
- transaction: type(transactionInterface()),
2022
- // TODO
2023
- version: string()
2024
- },
2025
- name: "TransactionForAccounts"
2026
- });
2027
- return memoisedTransactionForAccounts;
2028
- };
2029
- var memoisedBlockInterfaceFields;
2030
- var blockInterfaceFields = () => {
2031
- if (!memoisedBlockInterfaceFields)
2032
- memoisedBlockInterfaceFields = {
2033
- blockHeight: bigint(),
2034
- blockTime: bigint(),
2035
- blockhash: string(),
2036
- parentSlot: bigint(),
2037
- previousBlockhash: string(),
2038
- rewards: list(type(reward()))
2039
- };
2040
- return memoisedBlockInterfaceFields;
2041
- };
2042
- var memoisedBlockInterface;
2043
- var blockInterface = () => {
2044
- if (!memoisedBlockInterface)
2045
- memoisedBlockInterface = new GraphQLInterfaceType({
2046
- fields: {
2047
- ...blockInterfaceFields()
2048
- },
2049
- name: "Block",
2050
- resolveType(block) {
2051
- if (block.transactionDetails === "signatures") {
2052
- return "BlockWithSignatures";
2053
- }
2054
- if (block.transactionDetails === "accounts") {
2055
- return "BlockWithAccounts";
2056
- }
2057
- if (block.transactionDetails === "none") {
2058
- return "BlockWithNoTransactions";
2059
- }
2060
- return "BlockWithTransactions";
2061
- }
2062
- });
2063
- return memoisedBlockInterface;
2064
- };
2065
- var memoisedBlockWithNoTransactions;
2066
- var blockWithNoTransactions = () => {
2067
- if (!memoisedBlockWithNoTransactions)
2068
- memoisedBlockWithNoTransactions = new GraphQLObjectType({
2069
- fields: {
2070
- ...blockInterfaceFields()
2071
- },
2072
- interfaces: [blockInterface()],
2073
- name: "BlockWithNoTransactions"
2074
- });
2075
- return memoisedBlockWithNoTransactions;
2076
1218
  };
2077
- var memoisedBlockWithSignatures;
2078
- var blockWithSignatures = () => {
2079
- if (!memoisedBlockWithSignatures)
2080
- memoisedBlockWithSignatures = new GraphQLObjectType({
2081
- fields: {
2082
- ...blockInterfaceFields(),
2083
- signatures: list(string())
2084
- },
2085
- interfaces: [blockInterface()],
2086
- name: "BlockWithSignatures"
2087
- });
2088
- return memoisedBlockWithSignatures;
2089
- };
2090
- var memoisedBlockWithAccounts;
2091
- var blockWithAccounts = () => {
2092
- if (!memoisedBlockWithAccounts)
2093
- memoisedBlockWithAccounts = new GraphQLObjectType({
2094
- fields: {
2095
- ...blockInterfaceFields(),
2096
- transactions: list(type(transactionForAccounts()))
2097
- },
2098
- interfaces: [blockInterface()],
2099
- name: "BlockWithAccounts"
2100
- });
2101
- return memoisedBlockWithAccounts;
1219
+ var stringScalarAlias = {
1220
+ __parseLiteral(ast) {
1221
+ if (ast.kind === Kind.STRING) {
1222
+ return ast.value.toString();
1223
+ }
1224
+ return null;
1225
+ },
1226
+ __parseValue(value) {
1227
+ return value;
1228
+ },
1229
+ __serialize(value) {
1230
+ return value;
1231
+ }
2102
1232
  };
2103
- var memoisedBlockWithTransactions;
2104
- var blockWithTransactions = () => {
2105
- if (!memoisedBlockWithTransactions)
2106
- memoisedBlockWithTransactions = new GraphQLObjectType({
2107
- fields: {
2108
- ...blockInterfaceFields(),
2109
- transactions: list(type(transactionInterface()))
2110
- },
2111
- interfaces: [blockInterface()],
2112
- name: "BlockWithTransactions"
2113
- });
2114
- return memoisedBlockWithTransactions;
1233
+ var bigIntScalarAlias = {
1234
+ __parseLiteral(ast) {
1235
+ if (ast.kind === Kind.STRING) {
1236
+ return BigInt(ast.value);
1237
+ }
1238
+ return null;
1239
+ },
1240
+ __parseValue(value) {
1241
+ return BigInt(value);
1242
+ },
1243
+ __serialize(value) {
1244
+ return BigInt(value);
1245
+ }
2115
1246
  };
2116
- var memoisedBlockTypes;
2117
- var blockTypes = () => {
2118
- if (!memoisedBlockTypes)
2119
- memoisedBlockTypes = [
2120
- blockWithNoTransactions(),
2121
- blockWithSignatures(),
2122
- blockWithAccounts(),
2123
- blockWithTransactions()
2124
- ];
2125
- return memoisedBlockTypes;
1247
+ var typeTypeResolvers = {
1248
+ AccountEncoding: {
1249
+ BASE_58: "base58",
1250
+ BASE_64: "base64",
1251
+ BASE_64_ZSTD: "base64+zstd",
1252
+ PARSED: "jsonParsed"
1253
+ },
1254
+ Address: stringScalarAlias,
1255
+ Base58EncodedBytes: stringScalarAlias,
1256
+ Base64EncodedBytes: stringScalarAlias,
1257
+ Base64ZstdEncodedBytes: stringScalarAlias,
1258
+ BigInt: bigIntScalarAlias,
1259
+ BlockTransactionDetails: {
1260
+ ACCOUNTS: "accounts",
1261
+ FULL: "full",
1262
+ NONE: "none",
1263
+ SIGNATURES: "signatures"
1264
+ },
1265
+ Commitment: {
1266
+ CONFIRMED: "confirmed",
1267
+ FINALIZED: "finalized",
1268
+ PROCESSED: "processed"
1269
+ },
1270
+ Signature: stringScalarAlias,
1271
+ Slot: bigIntScalarAlias,
1272
+ TokenBalance: {
1273
+ mint: resolveAccount("mint"),
1274
+ owner: resolveAccount("owner")
1275
+ },
1276
+ TransactionEncoding: {
1277
+ BASE_58: "base58",
1278
+ BASE_64: "base64",
1279
+ PARSED: "jsonParsed"
1280
+ },
1281
+ TransactionVersion: {
1282
+ LEGACY: "legacy",
1283
+ ZERO: 0
1284
+ }
2126
1285
  };
2127
1286
 
2128
- // src/schema/block/query.ts
2129
- var blockQuery = () => ({
2130
- block: {
2131
- args: {
2132
- commitment: type(commitmentInputType()),
2133
- encoding: type(transactionEncodingInputType()),
2134
- maxSupportedTransactionVersion: string(),
2135
- rewards: boolean(),
2136
- slot: nonNull(bigint()),
2137
- transactionDetails: type(blockTransactionDetailsInputType())
2138
- },
2139
- resolve: (_parent, args, context) => context.resolveBlock(args),
2140
- type: blockInterface()
2141
- }
2142
- });
2143
- var programAccount = () => new GraphQLObjectType({
2144
- fields: {
2145
- account: type(accountInterface()),
2146
- pubkey: string()
2147
- },
2148
- name: "ProgramAccount"
2149
- });
2150
-
2151
- // src/schema/program-accounts/query.ts
2152
- var programAccountsQuery = () => ({
2153
- programAccounts: {
2154
- args: {
2155
- commitment: type(commitmentInputType()),
2156
- dataSlice: type(dataSliceInputType()),
2157
- encoding: type(accountEncodingInputType()),
2158
- filters: list(type(programAccountFilterInputType())),
2159
- minContextSlot: bigint(),
2160
- programAddress: nonNull(string()),
2161
- withContext: string()
2162
- },
2163
- resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
2164
- type: new GraphQLList(programAccount())
2165
- }
2166
- });
1287
+ // src/resolvers/index.ts
1288
+ function createSolanaGraphQLResolvers() {
1289
+ return {
1290
+ ...accountResolvers,
1291
+ ...blockResolvers,
1292
+ ...instructionResolvers,
1293
+ ...rootResolvers,
1294
+ ...transactionResolvers,
1295
+ ...typeTypeResolvers
1296
+ };
1297
+ }
1298
+
1299
+ // src/schema/account.ts
1300
+ var accountTypeDefs = (
1301
+ /* GraphQL */
1302
+ `
1303
+ """
1304
+ Account interface
1305
+ """
1306
+ interface Account {
1307
+ address: Address
1308
+ executable: Boolean
1309
+ lamports: BigInt
1310
+ ownerProgram: Account
1311
+ space: BigInt
1312
+ rentEpoch: BigInt
1313
+ }
1314
+
1315
+ """
1316
+ An account with base58 encoded data
1317
+ """
1318
+ type AccountBase58 implements Account {
1319
+ address: Address
1320
+ data: Base58EncodedBytes
1321
+ executable: Boolean
1322
+ lamports: BigInt
1323
+ ownerProgram: Account
1324
+ space: BigInt
1325
+ rentEpoch: BigInt
1326
+ }
1327
+
1328
+ """
1329
+ An account with base64 encoded data
1330
+ """
1331
+ type AccountBase64 implements Account {
1332
+ address: Address
1333
+ data: Base64EncodedBytes
1334
+ executable: Boolean
1335
+ lamports: BigInt
1336
+ ownerProgram: Account
1337
+ space: BigInt
1338
+ rentEpoch: BigInt
1339
+ }
1340
+
1341
+ """
1342
+ An account with base64+zstd encoded data
1343
+ """
1344
+ type AccountBase64Zstd implements Account {
1345
+ address: Address
1346
+ data: Base64ZstdEncodedBytes
1347
+ executable: Boolean
1348
+ lamports: BigInt
1349
+ ownerProgram: Account
1350
+ space: BigInt
1351
+ rentEpoch: BigInt
1352
+ }
1353
+
1354
+ type NonceAccountFeeCalculator {
1355
+ lamportsPerSignature: String
1356
+ }
1357
+ """
1358
+ A nonce account
1359
+ """
1360
+ type NonceAccount implements Account {
1361
+ address: Address
1362
+ executable: Boolean
1363
+ lamports: BigInt
1364
+ ownerProgram: Account
1365
+ space: BigInt
1366
+ rentEpoch: BigInt
1367
+ authority: Account
1368
+ blockhash: String
1369
+ feeCalculator: NonceAccountFeeCalculator
1370
+ }
1371
+
1372
+ """
1373
+ A lookup table account
1374
+ """
1375
+ type LookupTableAccount implements Account {
1376
+ address: Address
1377
+ executable: Boolean
1378
+ lamports: BigInt
1379
+ ownerProgram: Account
1380
+ space: BigInt
1381
+ rentEpoch: BigInt
1382
+ addresses: [Address]
1383
+ authority: Account
1384
+ deactivationSlot: String
1385
+ lastExtendedSlot: String
1386
+ lastExtendedSlotStartIndex: Int
1387
+ }
1388
+
1389
+ """
1390
+ A mint account
1391
+ """
1392
+ type MintAccount implements Account {
1393
+ address: Address
1394
+ executable: Boolean
1395
+ lamports: BigInt
1396
+ ownerProgram: Account
1397
+ space: BigInt
1398
+ rentEpoch: BigInt
1399
+ decimals: Int
1400
+ freezeAuthority: Account
1401
+ isInitialized: Boolean
1402
+ mintAuthority: Account
1403
+ supply: String
1404
+ }
1405
+
1406
+ """
1407
+ A token account
1408
+ """
1409
+ type TokenAccount implements Account {
1410
+ address: Address
1411
+ executable: Boolean
1412
+ lamports: BigInt
1413
+ ownerProgram: Account
1414
+ space: BigInt
1415
+ rentEpoch: BigInt
1416
+ isNative: Boolean
1417
+ mint: Account
1418
+ owner: Account
1419
+ state: String
1420
+ tokenAmount: TokenAmount
1421
+ }
1422
+
1423
+ type StakeAccountDataMetaAuthorized {
1424
+ staker: Account
1425
+ withdrawer: Account
1426
+ }
1427
+ type StakeAccountDataMetaLockup {
1428
+ custodian: Account
1429
+ epoch: BigInt
1430
+ unixTimestamp: BigInt
1431
+ }
1432
+ type StakeAccountDataMeta {
1433
+ authorized: StakeAccountDataMetaAuthorized
1434
+ lockup: StakeAccountDataMetaLockup
1435
+ rentExemptReserve: String
1436
+ }
1437
+ type StakeAccountDataStakeDelegation {
1438
+ activationEpoch: BigInt
1439
+ deactivationEpoch: BigInt
1440
+ stake: String
1441
+ voter: Account
1442
+ warmupCooldownRate: Int
1443
+ }
1444
+ type StakeAccountDataStake {
1445
+ creditsObserved: BigInt
1446
+ delegation: StakeAccountDataStakeDelegation
1447
+ }
1448
+ """
1449
+ A stake account
1450
+ """
1451
+ type StakeAccount implements Account {
1452
+ address: Address
1453
+ executable: Boolean
1454
+ lamports: BigInt
1455
+ ownerProgram: Account
1456
+ space: BigInt
1457
+ rentEpoch: BigInt
1458
+ meta: StakeAccountDataMeta
1459
+ stake: StakeAccountDataStake
1460
+ }
1461
+
1462
+ type VoteAccountDataAuthorizedVoter {
1463
+ authorizedVoter: Account
1464
+ epoch: BigInt
1465
+ }
1466
+ type VoteAccountDataEpochCredit {
1467
+ credits: String
1468
+ epoch: BigInt
1469
+ previousCredits: String
1470
+ }
1471
+ type VoteAccountDataLastTimestamp {
1472
+ slot: BigInt
1473
+ timestamp: BigInt
1474
+ }
1475
+ type VoteAccountDataVote {
1476
+ confirmationCount: Int
1477
+ slot: BigInt
1478
+ }
1479
+ """
1480
+ A vote account
1481
+ """
1482
+ type VoteAccount implements Account {
1483
+ address: Address
1484
+ executable: Boolean
1485
+ lamports: BigInt
1486
+ ownerProgram: Account
1487
+ space: BigInt
1488
+ rentEpoch: BigInt
1489
+ authorizedVoters: [VoteAccountDataAuthorizedVoter]
1490
+ authorizedWithdrawer: Account
1491
+ commission: Int
1492
+ epochCredits: [VoteAccountDataEpochCredit]
1493
+ lastTimestamp: VoteAccountDataLastTimestamp
1494
+ node: Account
1495
+ priorVoters: [Address]
1496
+ rootSlot: BigInt
1497
+ votes: [VoteAccountDataVote]
1498
+ }
1499
+ `
1500
+ );
1501
+
1502
+ // src/schema/block.ts
1503
+ var blockTypeDefs = (
1504
+ /* GraphQL */
1505
+ `
1506
+ type TransactionMetaForAccounts {
1507
+ err: String
1508
+ fee: BigInt
1509
+ postBalances: [BigInt]
1510
+ postTokenBalances: [TokenBalance]
1511
+ preBalances: [BigInt]
1512
+ preTokenBalances: [TokenBalance]
1513
+ status: TransactionStatus
1514
+ }
1515
+
1516
+ type TransactionDataForAccounts {
1517
+ accountKeys: [Address]
1518
+ signatures: [String]
1519
+ }
1520
+
1521
+ type BlockTransactionAccounts {
1522
+ meta: TransactionMetaForAccounts
1523
+ data: TransactionDataForAccounts
1524
+ version: String
1525
+ }
1526
+
1527
+ """
1528
+ Block interface
1529
+ """
1530
+ interface Block {
1531
+ blockhash: String
1532
+ blockHeight: BigInt
1533
+ blockTime: BigInt
1534
+ parentSlot: BigInt
1535
+ previousBlockhash: String
1536
+ rewards: [Reward]
1537
+ transactionDetails: String
1538
+ }
1539
+
1540
+ """
1541
+ A block with account transaction details
1542
+ """
1543
+ type BlockWithAccounts implements Block {
1544
+ blockhash: String
1545
+ blockHeight: BigInt
1546
+ blockTime: BigInt
1547
+ parentSlot: BigInt
1548
+ previousBlockhash: String
1549
+ rewards: [Reward]
1550
+ transactions: [BlockTransactionAccounts]
1551
+ transactionDetails: String
1552
+ }
1553
+
1554
+ """
1555
+ A block with full transaction details
1556
+ """
1557
+ type BlockWithFull implements Block {
1558
+ blockhash: String
1559
+ blockHeight: BigInt
1560
+ blockTime: BigInt
1561
+ parentSlot: BigInt
1562
+ previousBlockhash: String
1563
+ rewards: [Reward]
1564
+ transactions: [Transaction]
1565
+ transactionDetails: String
1566
+ }
1567
+
1568
+ """
1569
+ A block with no transaction details
1570
+ """
1571
+ type BlockWithNone implements Block {
1572
+ blockhash: String
1573
+ blockHeight: BigInt
1574
+ blockTime: BigInt
1575
+ parentSlot: BigInt
1576
+ previousBlockhash: String
1577
+ rewards: [Reward]
1578
+ transactionDetails: String
1579
+ }
1580
+
1581
+ """
1582
+ A block with signature transaction details
1583
+ """
1584
+ type BlockWithSignatures implements Block {
1585
+ blockhash: String
1586
+ blockHeight: BigInt
1587
+ blockTime: BigInt
1588
+ parentSlot: BigInt
1589
+ previousBlockhash: String
1590
+ rewards: [Reward]
1591
+ signatures: [String]
1592
+ transactionDetails: String
1593
+ }
1594
+ `
1595
+ );
1596
+
1597
+ // src/schema/instruction.ts
1598
+ var instructionTypeDefs = (
1599
+ /* GraphQL */
1600
+ `
1601
+ """
1602
+ Transaction instruction interface
1603
+ """
1604
+ interface TransactionInstruction {
1605
+ programId: Address
1606
+ }
1607
+
1608
+ """
1609
+ Generic transaction instruction
1610
+ """
1611
+ type GenericInstruction implements TransactionInstruction {
1612
+ accounts: [Address]
1613
+ data: Base64EncodedBytes
1614
+ programId: Address
1615
+ }
1616
+
1617
+ """
1618
+ AddressLookupTable: CreateLookupTable instruction
1619
+ """
1620
+ type CreateLookupTableInstruction implements TransactionInstruction {
1621
+ programId: Address
1622
+ bumpSeed: BigInt # FIXME:*
1623
+ lookupTableAccount: Account
1624
+ lookupTableAuthority: Account
1625
+ payerAccount: Account
1626
+ recentSlot: BigInt
1627
+ systemProgram: Account
1628
+ }
1629
+
1630
+ """
1631
+ AddressLookupTable: ExtendLookupTable instruction
1632
+ """
1633
+ type ExtendLookupTableInstruction implements TransactionInstruction {
1634
+ programId: Address
1635
+ lookupTableAccount: Account
1636
+ lookupTableAuthority: Account
1637
+ newAddresses: [Address]
1638
+ payerAccount: Account
1639
+ systemProgram: Account
1640
+ }
1641
+
1642
+ """
1643
+ AddressLookupTable: FreezeLookupTable instruction
1644
+ """
1645
+ type FreezeLookupTableInstruction implements TransactionInstruction {
1646
+ programId: Address
1647
+ lookupTableAccount: Account
1648
+ lookupTableAuthority: Account
1649
+ }
1650
+
1651
+ """
1652
+ AddressLookupTable: DeactivateLookupTable instruction
1653
+ """
1654
+ type DeactivateLookupTableInstruction implements TransactionInstruction {
1655
+ programId: Address
1656
+ lookupTableAccount: Account
1657
+ lookupTableAuthority: Account
1658
+ }
1659
+
1660
+ """
1661
+ AddressLookupTable: CloseLookupTable instruction
1662
+ """
1663
+ type CloseLookupTableInstruction implements TransactionInstruction {
1664
+ programId: Address
1665
+ lookupTableAccount: Account
1666
+ lookupTableAuthority: Account
1667
+ recipient: Account
1668
+ }
1669
+
1670
+ """
1671
+ BpfLoader: Write instruction
1672
+ """
1673
+ type BpfLoaderWriteInstruction implements TransactionInstruction {
1674
+ programId: Address
1675
+ account: Account
1676
+ bytes: Base64EncodedBytes
1677
+ offset: BigInt # FIXME:*
1678
+ }
1679
+
1680
+ """
1681
+ BpfLoader: Finalize instruction
1682
+ """
1683
+ type BpfLoaderFinalizeInstruction implements TransactionInstruction {
1684
+ programId: Address
1685
+ account: Account
1686
+ }
1687
+
1688
+ """
1689
+ BpfUpgradeableLoader: InitializeBuffer instruction
1690
+ """
1691
+ type BpfUpgradeableLoaderInitializeBufferInstruction implements TransactionInstruction {
1692
+ programId: Address
1693
+ account: Account
1694
+ }
1695
+
1696
+ """
1697
+ BpfUpgradeableLoader: Write instruction
1698
+ """
1699
+ type BpfUpgradeableLoaderWriteInstruction implements TransactionInstruction {
1700
+ programId: Address
1701
+ account: Account
1702
+ authority: Account
1703
+ bytes: Base64EncodedBytes
1704
+ offset: BigInt # FIXME:*
1705
+ }
1706
+
1707
+ """
1708
+ BpfUpgradeableLoader: DeployWithMaxDataLen instruction
1709
+ """
1710
+ type BpfUpgradeableLoaderDeployWithMaxDataLenInstruction implements TransactionInstruction {
1711
+ programId: Address
1712
+ authority: Account
1713
+ bufferAccount: Account
1714
+ clockSysvar: Address
1715
+ maxDataLen: BigInt
1716
+ payerAccount: Account
1717
+ programAccount: Account
1718
+ programDataAccount: Account
1719
+ rentSysvar: Address
1720
+ }
1721
+
1722
+ """
1723
+ BpfUpgradeableLoader: Upgrade instruction
1724
+ """
1725
+ type BpfUpgradeableLoaderUpgradeInstruction implements TransactionInstruction {
1726
+ programId: Address
1727
+ authority: Account
1728
+ bufferAccount: Account
1729
+ clockSysvar: Address
1730
+ programAccount: Account
1731
+ programDataAccount: Account
1732
+ rentSysvar: Address
1733
+ spillAccount: Account
1734
+ }
1735
+
1736
+ """
1737
+ BpfUpgradeableLoader: SetAuthority instruction
1738
+ """
1739
+ type BpfUpgradeableLoaderSetAuthorityInstruction implements TransactionInstruction {
1740
+ programId: Address
1741
+ account: Account
1742
+ authority: Account
1743
+ newAuthority: Account
1744
+ }
1745
+
1746
+ """
1747
+ BpfUpgradeableLoader: SetAuthorityChecked instruction
1748
+ """
1749
+ type BpfUpgradeableLoaderSetAuthorityCheckedInstruction implements TransactionInstruction {
1750
+ programId: Address
1751
+ account: Account
1752
+ authority: Account
1753
+ newAuthority: Account
1754
+ }
1755
+
1756
+ """
1757
+ BpfUpgradeableLoader: Close instruction
1758
+ """
1759
+ type BpfUpgradeableLoaderCloseInstruction implements TransactionInstruction {
1760
+ programId: Address
1761
+ account: Account
1762
+ authority: Account
1763
+ programAccount: Account
1764
+ recipient: Account
1765
+ }
1766
+
1767
+ """
1768
+ BpfUpgradeableLoader: ExtendProgram instruction
1769
+ """
1770
+ type BpfUpgradeableLoaderExtendProgramInstruction implements TransactionInstruction {
1771
+ programId: Address
1772
+ additionalBytes: BigInt
1773
+ payerAccount: Account
1774
+ programAccount: Account
1775
+ programDataAccount: Account
1776
+ systemProgram: Account
1777
+ }
1778
+
1779
+ """
1780
+ SplAssociatedTokenAccount: Create instruction
1781
+ """
1782
+ type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1783
+ programId: Address
1784
+ account: Account
1785
+ mint: Address
1786
+ source: Account
1787
+ systemProgram: Account
1788
+ tokenProgram: Account
1789
+ wallet: Account
1790
+ }
1791
+
1792
+ """
1793
+ SplAssociatedTokenAccount: CreateIdempotent instruction
1794
+ """
1795
+ type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1796
+ programId: Address
1797
+ account: Account
1798
+ mint: Address
1799
+ source: Account
1800
+ systemProgram: Account
1801
+ tokenProgram: Account
1802
+ wallet: Account
1803
+ }
1804
+
1805
+ """
1806
+ SplAssociatedTokenAccount: RecoverNested instruction
1807
+ """
1808
+ type SplAssociatedTokenRecoverNestedInstruction implements TransactionInstruction {
1809
+ programId: Address
1810
+ destination: Account
1811
+ nestedMint: Account
1812
+ nestedOwner: Account
1813
+ nestedSource: Account
1814
+ ownerMint: Account
1815
+ tokenProgram: Account
1816
+ wallet: Account
1817
+ }
1818
+
1819
+ """
1820
+ SplMemo instruction
1821
+ """
1822
+ type SplMemoInstruction implements TransactionInstruction {
1823
+ programId: Address
1824
+ memo: String
1825
+ }
1826
+
1827
+ """
1828
+ SplToken: InitializeMint instruction
1829
+ """
1830
+ type SplTokenInitializeMintInstruction implements TransactionInstruction {
1831
+ programId: Address
1832
+ decimals: BigInt # FIXME:*
1833
+ freezeAuthority: Account
1834
+ mint: Account
1835
+ mintAuthority: Account
1836
+ rentSysvar: Address
1837
+ }
1838
+
1839
+ """
1840
+ SplToken: InitializeMint2 instruction
1841
+ """
1842
+ type SplTokenInitializeMint2Instruction implements TransactionInstruction {
1843
+ programId: Address
1844
+ decimals: BigInt # FIXME:*
1845
+ freezeAuthority: Account
1846
+ mint: Account
1847
+ mintAuthority: Account
1848
+ }
1849
+
1850
+ """
1851
+ SplToken: InitializeAccount instruction
1852
+ """
1853
+ type SplTokenInitializeAccountInstruction implements TransactionInstruction {
1854
+ programId: Address
1855
+ account: Account
1856
+ mint: Account
1857
+ owner: Account
1858
+ rentSysvar: Address
1859
+ }
1860
+
1861
+ """
1862
+ SplToken: InitializeAccount2 instruction
1863
+ """
1864
+ type SplTokenInitializeAccount2Instruction implements TransactionInstruction {
1865
+ programId: Address
1866
+ account: Account
1867
+ mint: Account
1868
+ owner: Account
1869
+ rentSysvar: Address
1870
+ }
1871
+
1872
+ """
1873
+ SplToken: InitializeAccount3 instruction
1874
+ """
1875
+ type SplTokenInitializeAccount3Instruction implements TransactionInstruction {
1876
+ programId: Address
1877
+ account: Account
1878
+ mint: Account
1879
+ owner: Account
1880
+ }
1881
+
1882
+ """
1883
+ SplToken: InitializeMultisig instruction
1884
+ """
1885
+ type SplTokenInitializeMultisigInstruction implements TransactionInstruction {
1886
+ programId: Address
1887
+ m: BigInt # FIXME:*
1888
+ multisig: Account
1889
+ rentSysvar: Address
1890
+ signers: [Address]
1891
+ }
1892
+
1893
+ """
1894
+ SplToken: InitializeMultisig2 instruction
1895
+ """
1896
+ type SplTokenInitializeMultisig2Instruction implements TransactionInstruction {
1897
+ programId: Address
1898
+ m: BigInt # FIXME:*
1899
+ multisig: Account
1900
+ signers: [Address]
1901
+ }
1902
+
1903
+ """
1904
+ SplToken: Transfer instruction
1905
+ """
1906
+ type SplTokenTransferInstruction implements TransactionInstruction {
1907
+ programId: Address
1908
+ amount: String
1909
+ authority: Account
1910
+ destination: Account
1911
+ multisigAuthority: Account
1912
+ source: Account
1913
+ }
1914
+
1915
+ """
1916
+ SplToken: Approve instruction
1917
+ """
1918
+ type SplTokenApproveInstruction implements TransactionInstruction {
1919
+ programId: Address
1920
+ amount: String
1921
+ delegate: Account
1922
+ multisigOwner: Account
1923
+ owner: Account
1924
+ source: Account
1925
+ }
1926
+
1927
+ """
1928
+ SplToken: Revoke instruction
1929
+ """
1930
+ type SplTokenRevokeInstruction implements TransactionInstruction {
1931
+ programId: Address
1932
+ multisigOwner: Account
1933
+ owner: Account
1934
+ source: Account
1935
+ }
1936
+
1937
+ """
1938
+ SplToken: SetAuthority instruction
1939
+ """
1940
+ type SplTokenSetAuthorityInstruction implements TransactionInstruction {
1941
+ programId: Address
1942
+ authority: Account
1943
+ authorityType: String
1944
+ multisigAuthority: Account
1945
+ newAuthority: Account
1946
+ }
1947
+
1948
+ """
1949
+ SplToken: MintTo instruction
1950
+ """
1951
+ type SplTokenMintToInstruction implements TransactionInstruction {
1952
+ programId: Address
1953
+ account: Account
1954
+ amount: String
1955
+ authority: Account
1956
+ mint: Account
1957
+ mintAuthority: Account
1958
+ multisigMintAuthority: Account
1959
+ }
1960
+
1961
+ """
1962
+ SplToken: Burn instruction
1963
+ """
1964
+ type SplTokenBurnInstruction implements TransactionInstruction {
1965
+ programId: Address
1966
+ account: Account
1967
+ amount: String
1968
+ authority: Account
1969
+ mint: Account
1970
+ multisigAuthority: Account
1971
+ }
1972
+
1973
+ """
1974
+ SplToken: CloseAccount instruction
1975
+ """
1976
+ type SplTokenCloseAccountInstruction implements TransactionInstruction {
1977
+ programId: Address
1978
+ account: Account
1979
+ destination: Account
1980
+ multisigOwner: Account
1981
+ owner: Account
1982
+ }
1983
+
1984
+ """
1985
+ SplToken: FreezeAccount instruction
1986
+ """
1987
+ type SplTokenFreezeAccountInstruction implements TransactionInstruction {
1988
+ programId: Address
1989
+ account: Account
1990
+ freezeAuthority: Account
1991
+ mint: Account
1992
+ multisigFreezeAuthority: Account
1993
+ }
1994
+
1995
+ """
1996
+ SplToken: ThawAccount instruction
1997
+ """
1998
+ type SplTokenThawAccountInstruction implements TransactionInstruction {
1999
+ programId: Address
2000
+ account: Account
2001
+ freezeAuthority: Account
2002
+ mint: Account
2003
+ multisigFreezeAuthority: Account
2004
+ }
2005
+
2006
+ """
2007
+ SplToken: TransferChecked instruction
2008
+ """
2009
+ type SplTokenTransferCheckedInstruction implements TransactionInstruction {
2010
+ programId: Address
2011
+ amount: String
2012
+ authority: Account
2013
+ decimals: BigInt # FIXME:*
2014
+ destination: Account
2015
+ mint: Account
2016
+ multisigAuthority: Account
2017
+ source: Account
2018
+ tokenAmount: String
2019
+ }
2020
+
2021
+ """
2022
+ SplToken: ApproveChecked instruction
2023
+ """
2024
+ type SplTokenApproveCheckedInstruction implements TransactionInstruction {
2025
+ programId: Address
2026
+ delegate: Account
2027
+ mint: Account
2028
+ multisigOwner: Account
2029
+ owner: Account
2030
+ source: Account
2031
+ tokenAmount: String
2032
+ }
2033
+
2034
+ """
2035
+ SplToken: MintToChecked instruction
2036
+ """
2037
+ type SplTokenMintToCheckedInstruction implements TransactionInstruction {
2038
+ programId: Address
2039
+ account: Account
2040
+ authority: Account
2041
+ mint: Account
2042
+ mintAuthority: Account
2043
+ multisigMintAuthority: Account
2044
+ tokenAmount: String
2045
+ }
2046
+
2047
+ """
2048
+ SplToken: BurnChecked instruction
2049
+ """
2050
+ type SplTokenBurnCheckedInstruction implements TransactionInstruction {
2051
+ programId: Address
2052
+ account: Account
2053
+ authority: Account
2054
+ mint: Account
2055
+ multisigAuthority: Account
2056
+ tokenAmount: String
2057
+ }
2058
+
2059
+ """
2060
+ SplToken: SyncNative instruction
2061
+ """
2062
+ type SplTokenSyncNativeInstruction implements TransactionInstruction {
2063
+ programId: Address
2064
+ account: Account
2065
+ }
2066
+
2067
+ """
2068
+ SplToken: GetAccountDataSize instruction
2069
+ """
2070
+ type SplTokenGetAccountDataSizeInstruction implements TransactionInstruction {
2071
+ programId: Address
2072
+ extensionTypes: [String]
2073
+ mint: Account
2074
+ }
2075
+
2076
+ """
2077
+ SplToken: InitializeImmutableOwner instruction
2078
+ """
2079
+ type SplTokenInitializeImmutableOwnerInstruction implements TransactionInstruction {
2080
+ programId: Address
2081
+ account: Account
2082
+ }
2083
+
2084
+ """
2085
+ SplToken: AmountToUiAmount instruction
2086
+ """
2087
+ type SplTokenAmountToUiAmountInstruction implements TransactionInstruction {
2088
+ programId: Address
2089
+ amount: String
2090
+ mint: Account
2091
+ }
2092
+
2093
+ """
2094
+ SplToken: UiAmountToAmount instruction
2095
+ """
2096
+ type SplTokenUiAmountToAmountInstruction implements TransactionInstruction {
2097
+ programId: Address
2098
+ mint: Account
2099
+ uiAmount: String
2100
+ }
2101
+
2102
+ """
2103
+ SplToken: InitializeMintCloseAuthority instruction
2104
+ """
2105
+ type SplTokenInitializeMintCloseAuthorityInstruction implements TransactionInstruction {
2106
+ programId: Address
2107
+ mint: Account
2108
+ newAuthority: Account
2109
+ }
2110
+
2111
+ # TODO: Extensions!
2112
+ # - TransferFeeExtension
2113
+ # - ConfidentialTransferFeeExtension
2114
+ # - DefaultAccountStateExtension
2115
+ # - Reallocate
2116
+ # - MemoTransferExtension
2117
+ # - CreateNativeMint
2118
+ # - InitializeNonTransferableMint
2119
+ # - InterestBearingMintExtension
2120
+ # - CpiGuardExtension
2121
+ # - InitializePermanentDelegate
2122
+ # - TransferHookExtension
2123
+ # - ConfidentialTransferFeeExtension
2124
+ # - WithdrawExcessLamports
2125
+ # - MetadataPointerExtension
2126
+
2127
+ type Lockup {
2128
+ custodian: Account
2129
+ epoch: BigInt
2130
+ unixTimestamp: BigInt
2131
+ }
2132
+
2133
+ """
2134
+ Stake: Initialize instruction
2135
+ """
2136
+ type StakeInitializeInstructionDataAuthorized {
2137
+ staker: Account
2138
+ withdrawer: Account
2139
+ }
2140
+ type StakeInitializeInstruction implements TransactionInstruction {
2141
+ programId: Address
2142
+ authorized: StakeInitializeInstructionDataAuthorized
2143
+ lockup: Lockup
2144
+ rentSysvar: Address
2145
+ stakeAccount: Account
2146
+ }
2147
+
2148
+ """
2149
+ Stake: Authorize instruction
2150
+ """
2151
+ type StakeAuthorizeInstruction implements TransactionInstruction {
2152
+ programId: Address
2153
+ authority: Account
2154
+ authorityType: String
2155
+ clockSysvar: Address
2156
+ custodian: Account
2157
+ newAuthority: Account
2158
+ stakeAccount: Account
2159
+ }
2160
+
2161
+ """
2162
+ Stake: DelegateStake instruction
2163
+ """
2164
+ type StakeDelegateStakeInstruction implements TransactionInstruction {
2165
+ programId: Address
2166
+ clockSysvar: Address
2167
+ stakeAccount: Account
2168
+ stakeAuthority: Account
2169
+ stakeConfigAccount: Account
2170
+ stakeHistorySysvar: Address
2171
+ voteAccount: Account
2172
+ }
2173
+
2174
+ """
2175
+ Stake: Split instruction
2176
+ """
2177
+ type StakeSplitInstruction implements TransactionInstruction {
2178
+ programId: Address
2179
+ lamports: BigInt
2180
+ newSplitAccount: Account
2181
+ stakeAccount: Account
2182
+ stakeAuthority: Account
2183
+ }
2184
+
2185
+ """
2186
+ Stake: Withdraw instruction
2187
+ """
2188
+ type StakeWithdrawInstruction implements TransactionInstruction {
2189
+ programId: Address
2190
+ clockSysvar: Address
2191
+ destination: Account
2192
+ lamports: BigInt
2193
+ stakeAccount: Account
2194
+ withdrawAuthority: Account
2195
+ }
2196
+
2197
+ """
2198
+ Stake: Deactivate instruction
2199
+ """
2200
+ type StakeDeactivateInstruction implements TransactionInstruction {
2201
+ programId: Address
2202
+ clockSysvar: Address
2203
+ stakeAccount: Account
2204
+ stakeAuthority: Account
2205
+ }
2206
+
2207
+ """
2208
+ Stake: SetLockup instruction
2209
+ """
2210
+ type StakeSetLockupInstruction implements TransactionInstruction {
2211
+ programId: Address
2212
+ custodian: Account
2213
+ lockup: Lockup
2214
+ stakeAccount: Account
2215
+ }
2216
+
2217
+ """
2218
+ Stake: Merge instruction
2219
+ """
2220
+ type StakeMergeInstruction implements TransactionInstruction {
2221
+ programId: Address
2222
+ clockSysvar: Address
2223
+ destination: Account
2224
+ source: Account
2225
+ stakeAuthority: Account
2226
+ stakeHistorySysvar: Address
2227
+ }
2228
+
2229
+ """
2230
+ Stake: AuthorizeWithSeed instruction
2231
+ """
2232
+ type StakeAuthorizeWithSeedInstruction implements TransactionInstruction {
2233
+ programId: Address
2234
+ authorityBase: Account
2235
+ authorityOwner: Account
2236
+ authoritySeed: String
2237
+ authorityType: String
2238
+ clockSysvar: Address
2239
+ custodian: Account
2240
+ newAuthorized: Account
2241
+ stakeAccount: Account
2242
+ }
2243
+
2244
+ """
2245
+ Stake: InitializeChecked instruction
2246
+ """
2247
+ type StakeInitializeCheckedInstructionDataAuthorized {
2248
+ staker: Account
2249
+ withdrawer: Account
2250
+ }
2251
+ type StakeInitializeCheckedInstruction implements TransactionInstruction {
2252
+ programId: Address
2253
+ authorized: StakeInitializeCheckedInstructionDataAuthorized
2254
+ lockup: Lockup
2255
+ rentSysvar: Address
2256
+ stakeAccount: Account
2257
+ }
2258
+
2259
+ """
2260
+ Stake: AuthorizeChecked instruction
2261
+ """
2262
+ type StakeAuthorizeCheckedInstruction implements TransactionInstruction {
2263
+ programId: Address
2264
+ authority: Account
2265
+ authorityType: String
2266
+ clockSysvar: Address
2267
+ custodian: Account
2268
+ newAuthority: Account
2269
+ stakeAccount: Account
2270
+ }
2271
+
2272
+ """
2273
+ Stake: AuthorizeCheckedWithSeed instruction
2274
+ """
2275
+ type StakeAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2276
+ programId: Address
2277
+ authorityBase: Account
2278
+ authorityOwner: Account
2279
+ authoritySeed: String
2280
+ authorityType: String
2281
+ clockSysvar: Address
2282
+ custodian: Account
2283
+ newAuthorized: Account
2284
+ stakeAccount: Account
2285
+ }
2286
+
2287
+ """
2288
+ Stake: SetLockupChecked instruction
2289
+ """
2290
+ type StakeSetLockupCheckedInstruction implements TransactionInstruction {
2291
+ programId: Address
2292
+ custodian: Account
2293
+ lockup: Lockup
2294
+ stakeAccount: Account
2295
+ }
2296
+
2297
+ """
2298
+ Stake: DeactivateDelinquent instruction
2299
+ """
2300
+ type StakeDeactivateDelinquentInstruction implements TransactionInstruction {
2301
+ programId: Address
2302
+ referenceVoteAccount: Account
2303
+ stakeAccount: Account
2304
+ voteAccount: Account
2305
+ }
2306
+
2307
+ """
2308
+ Stake: Redelegate instruction
2309
+ """
2310
+ type StakeRedelegateInstruction implements TransactionInstruction {
2311
+ programId: Address
2312
+ newStakeAccount: Account
2313
+ stakeAccount: Account
2314
+ stakeAuthority: Account
2315
+ stakeConfigAccount: Account
2316
+ voteAccount: Account
2317
+ }
2318
+
2319
+ """
2320
+ System: CreateAccount instruction
2321
+ """
2322
+ type CreateAccountInstruction implements TransactionInstruction {
2323
+ programId: Address
2324
+ lamports: BigInt
2325
+ newAccount: Account
2326
+ owner: Account
2327
+ source: Account
2328
+ space: BigInt
2329
+ }
2330
+
2331
+ """
2332
+ System: Assign instruction
2333
+ """
2334
+ type AssignInstruction implements TransactionInstruction {
2335
+ programId: Address
2336
+ account: Account
2337
+ owner: Account
2338
+ }
2339
+
2340
+ """
2341
+ System: Transfer instruction
2342
+ """
2343
+ type TransferInstruction implements TransactionInstruction {
2344
+ programId: Address
2345
+ destination: Account
2346
+ lamports: BigInt
2347
+ source: Account
2348
+ }
2349
+
2350
+ """
2351
+ System: CreateAccountWithSeed instruction
2352
+ """
2353
+ type CreateAccountWithSeedInstruction implements TransactionInstruction {
2354
+ programId: Address
2355
+ base: Account
2356
+ lamports: BigInt
2357
+ owner: Account
2358
+ seed: String
2359
+ space: BigInt
2360
+ }
2361
+
2362
+ """
2363
+ System: AdvanceNonceAccount instruction
2364
+ """
2365
+ type AdvanceNonceAccountInstruction implements TransactionInstruction {
2366
+ programId: Address
2367
+ nonceAccount: Account
2368
+ nonceAuthority: Account
2369
+ recentBlockhashesSysvar: Address
2370
+ }
2371
+
2372
+ """
2373
+ System: WithdrawNonceAccount instruction
2374
+ """
2375
+ type WithdrawNonceAccountInstruction implements TransactionInstruction {
2376
+ programId: Address
2377
+ destination: Account
2378
+ lamports: BigInt
2379
+ nonceAccount: Account
2380
+ nonceAuthority: Account
2381
+ recentBlockhashesSysvar: Address
2382
+ rentSysvar: Address
2383
+ }
2384
+
2385
+ """
2386
+ System: InitializeNonceAccount instruction
2387
+ """
2388
+ type InitializeNonceAccountInstruction implements TransactionInstruction {
2389
+ programId: Address
2390
+ nonceAccount: Account
2391
+ nonceAuthority: Account
2392
+ recentBlockhashesSysvar: Address
2393
+ rentSysvar: Address
2394
+ }
2395
+
2396
+ """
2397
+ System: AuthorizeNonceAccount instruction
2398
+ """
2399
+ type AuthorizeNonceAccountInstruction implements TransactionInstruction {
2400
+ programId: Address
2401
+ newAuthorized: Account
2402
+ nonceAccount: Account
2403
+ nonceAuthority: Account
2404
+ }
2167
2405
 
2168
- // src/rpc.ts
2406
+ """
2407
+ System: UpgradeNonceAccount instruction
2408
+ """
2409
+ type UpgradeNonceAccountInstruction implements TransactionInstruction {
2410
+ programId: Address
2411
+ nonceAccount: Account
2412
+ nonceAuthority: Account
2413
+ }
2414
+
2415
+ """
2416
+ System: Allocate instruction
2417
+ """
2418
+ type AllocateInstruction implements TransactionInstruction {
2419
+ programId: Address
2420
+ account: Account
2421
+ space: BigInt
2422
+ }
2423
+
2424
+ """
2425
+ System: AllocateWithSeed instruction
2426
+ """
2427
+ type AllocateWithSeedInstruction implements TransactionInstruction {
2428
+ programId: Address
2429
+ account: Account
2430
+ base: Address
2431
+ owner: Account
2432
+ seed: String
2433
+ space: BigInt
2434
+ }
2435
+
2436
+ """
2437
+ System: AssignWithSeed instruction
2438
+ """
2439
+ type AssignWithSeedInstruction implements TransactionInstruction {
2440
+ programId: Address
2441
+ account: Account
2442
+ base: Address
2443
+ owner: Account
2444
+ seed: String
2445
+ }
2446
+
2447
+ """
2448
+ System: TransferWithSeed instruction
2449
+ """
2450
+ type TransferWithSeedInstruction implements TransactionInstruction {
2451
+ programId: Address
2452
+ destination: Account
2453
+ lamports: BigInt
2454
+ source: Account
2455
+ sourceBase: Address
2456
+ sourceOwner: Account
2457
+ sourceSeed: String
2458
+ }
2459
+
2460
+ """
2461
+ Vote: InitializeAccount instruction
2462
+ """
2463
+ type VoteInitializeAccountInstruction implements TransactionInstruction {
2464
+ programId: Address
2465
+ authorizedVoter: Account
2466
+ authorizedWithdrawer: Account
2467
+ clockSysvar: Address
2468
+ commission: BigInt # FIXME:*
2469
+ node: Account
2470
+ rentSysvar: Address
2471
+ voteAccount: Account
2472
+ }
2473
+
2474
+ """
2475
+ Vote: Authorize instruction
2476
+ """
2477
+ type VoteAuthorizeInstruction implements TransactionInstruction {
2478
+ programId: Address
2479
+ authority: Account
2480
+ authorityType: String
2481
+ clockSysvar: Address
2482
+ newAuthority: Account
2483
+ voteAccount: Account
2484
+ }
2485
+
2486
+ """
2487
+ Vote: AuthorizeWithSeed instruction
2488
+ """
2489
+ type VoteAuthorizeWithSeedInstruction implements TransactionInstruction {
2490
+ programId: Address
2491
+ authorityBaseKey: String
2492
+ authorityOwner: Account
2493
+ authoritySeed: String
2494
+ authorityType: String
2495
+ clockSysvar: Address
2496
+ newAuthority: Account
2497
+ voteAccount: Account
2498
+ }
2499
+
2500
+ """
2501
+ Vote: AuthorizeCheckedWithSeed instruction
2502
+ """
2503
+ type VoteAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2504
+ programId: Address
2505
+ authorityBaseKey: String
2506
+ authorityOwner: Account
2507
+ authoritySeed: String
2508
+ authorityType: String
2509
+ clockSysvar: Address
2510
+ newAuthority: Account
2511
+ voteAccount: Account
2512
+ }
2513
+
2514
+ type Vote {
2515
+ hash: String
2516
+ slots: [BigInt]
2517
+ timestamp: BigInt
2518
+ }
2519
+
2520
+ """
2521
+ Vote: Vote instruction
2522
+ """
2523
+ type VoteVoteInstruction implements TransactionInstruction {
2524
+ programId: Address
2525
+ clockSysvar: Address
2526
+ slotHashesSysvar: Address
2527
+ vote: Vote
2528
+ voteAccount: Account
2529
+ voteAuthority: Account
2530
+ }
2531
+
2532
+ type VoteStateUpdateLockout {
2533
+ confirmationCount: BigInt # FIXME:*
2534
+ slot: BigInt
2535
+ }
2536
+ type VoteStateUpdate {
2537
+ hash: String
2538
+ lockouts: [VoteStateUpdateLockout]
2539
+ root: BigInt
2540
+ timestamp: BigInt
2541
+ }
2542
+
2543
+ """
2544
+ Vote: UpdateVoteState instruction
2545
+ """
2546
+ type VoteUpdateVoteStateInstruction implements TransactionInstruction {
2547
+ programId: Address
2548
+ hash: String
2549
+ voteAccount: Account
2550
+ voteAuthority: Account
2551
+ voteStateUpdate: VoteStateUpdate
2552
+ }
2553
+
2554
+ """
2555
+ Vote: UpdateVoteStateSwitch instruction
2556
+ """
2557
+ type VoteUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2558
+ programId: Address
2559
+ hash: String
2560
+ voteAccount: Account
2561
+ voteAuthority: Account
2562
+ voteStateUpdate: VoteStateUpdate
2563
+ }
2564
+
2565
+ """
2566
+ Vote: CompactUpdateVoteState instruction
2567
+ """
2568
+ type VoteCompactUpdateVoteStateInstruction implements TransactionInstruction {
2569
+ programId: Address
2570
+ hash: String
2571
+ voteAccount: Account
2572
+ voteAuthority: Account
2573
+ voteStateUpdate: VoteStateUpdate
2574
+ }
2575
+
2576
+ """
2577
+ Vote: CompactUpdateVoteStateSwitch instruction
2578
+ """
2579
+ type VoteCompactUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2580
+ programId: Address
2581
+ hash: String
2582
+ voteAccount: Account
2583
+ voteAuthority: Account
2584
+ voteStateUpdate: VoteStateUpdate
2585
+ }
2586
+
2587
+ """
2588
+ Vote: Withdraw instruction
2589
+ """
2590
+ type VoteWithdrawInstruction implements TransactionInstruction {
2591
+ programId: Address
2592
+ destination: Account
2593
+ lamports: BigInt
2594
+ voteAccount: Account
2595
+ withdrawAuthority: Account
2596
+ }
2597
+
2598
+ """
2599
+ Vote: UpdateValidatorIdentity instruction
2600
+ """
2601
+ type VoteUpdateValidatorIdentityInstruction implements TransactionInstruction {
2602
+ programId: Address
2603
+ newValidatorIdentity: Account
2604
+ voteAccount: Account
2605
+ withdrawAuthority: Account
2606
+ }
2607
+
2608
+ """
2609
+ Vote: UpdateCommission instruction
2610
+ """
2611
+ type VoteUpdateCommissionInstruction implements TransactionInstruction {
2612
+ programId: Address
2613
+ commission: BigInt # FIXME:*
2614
+ voteAccount: Account
2615
+ withdrawAuthority: Account
2616
+ }
2617
+
2618
+ """
2619
+ Vote: VoteSwitch instruction
2620
+ """
2621
+ type VoteVoteSwitchInstruction implements TransactionInstruction {
2622
+ programId: Address
2623
+ clockSysvar: Address
2624
+ hash: String
2625
+ slotHashesSysvar: Address
2626
+ vote: Vote
2627
+ voteAccount: Account
2628
+ voteAuthority: Account
2629
+ }
2630
+
2631
+ """
2632
+ Vote: AuthorizeChecked instruction
2633
+ """
2634
+ type VoteAuthorizeCheckedInstruction implements TransactionInstruction {
2635
+ programId: Address
2636
+ authority: Account
2637
+ authorityType: String
2638
+ clockSysvar: Address
2639
+ newAuthority: Account
2640
+ voteAccount: Account
2641
+ }
2642
+ `
2643
+ );
2644
+
2645
+ // src/schema/root.ts
2646
+ var rootTypeDefs = (
2647
+ /* GraphQL */
2648
+ `
2649
+ type Query {
2650
+ account(
2651
+ address: Address!
2652
+ commitment: Commitment
2653
+ dataSlice: DataSlice
2654
+ encoding: AccountEncoding
2655
+ minContextSlot: Slot
2656
+ ): Account
2657
+ block(
2658
+ slot: Slot!
2659
+ commitment: Commitment
2660
+ encoding: TransactionEncoding
2661
+ transactionDetails: BlockTransactionDetails
2662
+ ): Block
2663
+ programAccounts(
2664
+ programAddress: Address!
2665
+ commitment: Commitment
2666
+ dataSlice: DataSlice
2667
+ encoding: AccountEncoding
2668
+ filters: [ProgramAccountsFilter]
2669
+ minContextSlot: Slot
2670
+ ): [Account]
2671
+ transaction(signature: Signature!, commitment: Commitment, encoding: TransactionEncoding): Transaction
2672
+ }
2673
+
2674
+ schema {
2675
+ query: Query
2676
+ }
2677
+ `
2678
+ );
2679
+
2680
+ // src/schema/transaction.ts
2681
+ var transactionTypeDefs = (
2682
+ /* GraphQL */
2683
+ `
2684
+ type TransactionStatusOk {
2685
+ Ok: String
2686
+ }
2687
+ type TransactionStatusErr {
2688
+ Err: String
2689
+ }
2690
+ union TransactionStatus = TransactionStatusOk | TransactionStatusErr
2691
+
2692
+ type TransactionLoadedAddresses {
2693
+ readonly: [String]
2694
+ writable: [String]
2695
+ }
2696
+
2697
+ type TransactionInnerInstruction {
2698
+ index: Int
2699
+ instructions: [TransactionInstruction]
2700
+ }
2701
+
2702
+ type TransactionMeta {
2703
+ computeUnitsConsumed: BigInt
2704
+ err: String
2705
+ fee: BigInt
2706
+ innerInstructions: [TransactionInnerInstruction]
2707
+ loadedAddresses: TransactionLoadedAddresses
2708
+ logMessages: [String]
2709
+ postBalances: [BigInt]
2710
+ postTokenBalances: [TokenBalance]
2711
+ preBalances: [BigInt]
2712
+ preTokenBalances: [TokenBalance]
2713
+ returnData: ReturnData
2714
+ rewards: [Reward]
2715
+ status: TransactionStatus
2716
+ }
2717
+
2718
+ type TransactionMessageAccountKey {
2719
+ pubkey: Address
2720
+ signer: Boolean
2721
+ source: String
2722
+ writable: Boolean
2723
+ }
2724
+
2725
+ type TransactionMessageAddressTableLookup {
2726
+ accountKey: Address
2727
+ readableIndexes: [Int]
2728
+ writableIndexes: [Int]
2729
+ }
2730
+
2731
+ type TransactionMessageHeader {
2732
+ numReadonlySignedAccounts: Int
2733
+ numReadonlyUnsignedAccounts: Int
2734
+ numRequiredSignatures: Int
2735
+ }
2736
+
2737
+ type TransactionMessage {
2738
+ accountKeys: [TransactionMessageAccountKey]
2739
+ addressTableLookups: [TransactionMessageAddressTableLookup]
2740
+ header: TransactionMessageHeader
2741
+ instructions: [TransactionInstruction]
2742
+ recentBlockhash: String
2743
+ }
2744
+
2745
+ """
2746
+ Transaction interface
2747
+ """
2748
+ interface Transaction {
2749
+ blockTime: BigInt
2750
+ meta: TransactionMeta
2751
+ slot: BigInt
2752
+ version: String
2753
+ }
2754
+
2755
+ """
2756
+ A transaction with base58 encoded data
2757
+ """
2758
+ type TransactionBase58 implements Transaction {
2759
+ blockTime: BigInt
2760
+ data: Base58EncodedBytes
2761
+ meta: TransactionMeta
2762
+ slot: BigInt
2763
+ version: String
2764
+ }
2765
+
2766
+ """
2767
+ A transaction with base64 encoded data
2768
+ """
2769
+ type TransactionBase64 implements Transaction {
2770
+ blockTime: BigInt
2771
+ data: Base64EncodedBytes
2772
+ meta: TransactionMeta
2773
+ slot: BigInt
2774
+ version: String
2775
+ }
2776
+
2777
+ """
2778
+ A transaction with JSON encoded data
2779
+ """
2780
+ type TransactionDataParsed {
2781
+ message: TransactionMessage
2782
+ signatures: [String]
2783
+ }
2784
+ type TransactionParsed implements Transaction {
2785
+ blockTime: BigInt
2786
+ data: TransactionDataParsed
2787
+ meta: TransactionMeta
2788
+ slot: BigInt
2789
+ version: String
2790
+ }
2791
+ `
2792
+ );
2793
+
2794
+ // src/schema/types.ts
2795
+ var typeTypeDefs = (
2796
+ /* GraphQL */
2797
+ `
2798
+ enum AccountEncoding {
2799
+ BASE_58
2800
+ BASE_64
2801
+ BASE_64_ZSTD
2802
+ PARSED
2803
+ }
2804
+
2805
+ scalar Address
2806
+
2807
+ scalar Base58EncodedBytes
2808
+
2809
+ scalar Base64EncodedBytes
2810
+
2811
+ scalar Base64ZstdEncodedBytes
2812
+
2813
+ scalar BigInt
2814
+
2815
+ enum BlockTransactionDetails {
2816
+ ACCOUNTS
2817
+ FULL
2818
+ NONE
2819
+ SIGNATURES
2820
+ }
2821
+
2822
+ enum Commitment {
2823
+ CONFIRMED
2824
+ FINALIZED
2825
+ PROCESSED
2826
+ }
2827
+
2828
+ input DataSlice {
2829
+ offset: Int!
2830
+ length: Int!
2831
+ }
2832
+
2833
+ input ProgramAccountsFilter {
2834
+ bytes: BigInt
2835
+ dataSize: BigInt
2836
+ encoding: AccountEncoding
2837
+ offset: BigInt
2838
+ }
2839
+
2840
+ type ReturnData {
2841
+ data: Base64EncodedBytes
2842
+ programId: Address
2843
+ }
2844
+
2845
+ type Reward {
2846
+ commission: Int
2847
+ lamports: BigInt
2848
+ postBalance: BigInt
2849
+ pubkey: Address
2850
+ rewardType: String
2851
+ }
2852
+
2853
+ scalar Signature
2854
+
2855
+ scalar Slot
2856
+
2857
+ type TokenAmount {
2858
+ amount: String
2859
+ decimals: Int
2860
+ uiAmount: BigInt
2861
+ uiAmountString: String
2862
+ }
2863
+
2864
+ type TokenBalance {
2865
+ accountIndex: Int
2866
+ mint: Account
2867
+ owner: Account
2868
+ programId: Address
2869
+ uiTokenAmount: TokenAmount
2870
+ }
2871
+
2872
+ enum TransactionEncoding {
2873
+ BASE_58
2874
+ BASE_64
2875
+ PARSED
2876
+ }
2877
+
2878
+ enum TransactionVersion {
2879
+ LEGACY
2880
+ ZERO
2881
+ }
2882
+ `
2883
+ );
2884
+
2885
+ // src/schema/index.ts
2886
+ function createSolanaGraphQLTypeDefs() {
2887
+ return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
2888
+ }
2889
+
2890
+ // src/index.ts
2169
2891
  function createRpcGraphQL(rpc) {
2170
- const context = createSolanaGraphQLContext(rpc);
2171
- const schema = new GraphQLSchema({
2172
- query: new GraphQLObjectType({
2173
- fields: {
2174
- ...accountQuery(),
2175
- ...blockQuery(),
2176
- ...programAccountsQuery(),
2177
- ...transactionQuery()
2178
- },
2179
- name: "RootQuery"
2180
- }),
2181
- types: [...accountTypes(), ...blockTypes(), ...transactionTypes()]
2892
+ const schema = makeExecutableSchema({
2893
+ resolvers: createSolanaGraphQLResolvers(),
2894
+ typeDefs: createSolanaGraphQLTypeDefs()
2182
2895
  });
2183
2896
  return {
2184
- context,
2185
2897
  async query(source, variableValues) {
2186
- const result = await graphql({
2187
- contextValue: this.context,
2188
- schema: this.schema,
2898
+ const contextValue = createSolanaGraphQLContext(rpc);
2899
+ return graphql({
2900
+ contextValue,
2901
+ schema,
2189
2902
  source,
2190
2903
  variableValues
2191
2904
  });
2192
- this.context.cache.flush();
2193
- return result;
2194
- },
2195
- schema
2905
+ }
2196
2906
  };
2197
2907
  }
2198
2908