@solana/rpc-graphql 2.0.0-experimental.cf6ca9d → 2.0.0-experimental.d148156

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