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