@solana/rpc-graphql 2.0.0-development → 2.0.0-experimental.0835c79

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