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