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