@solana/rpc-graphql 2.0.0-experimental.c7ef49c → 2.0.0-experimental.ca243cb

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