@solana/rpc-graphql 2.0.0-experimental.9c8a30e → 2.0.0-experimental.a1fafee

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