@solana/rpc-graphql 2.0.0-development → 2.0.0-experimental.021706b

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