@solana/rpc-graphql 2.0.0-experimental.ce179f2 → 2.0.0-experimental.cee6f23

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