@solana/rpc-graphql 2.0.0-experimental.9e133fd → 2.0.0-experimental.a0b9a27

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