@solana/rpc-graphql 2.0.0-experimental.dacecb7 → 2.0.0-experimental.dd2096e

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 (83) hide show
  1. package/README.md +1088 -30
  2. package/dist/index.browser.cjs +2689 -1970
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +2686 -1972
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.native.js +2657 -1939
  7. package/dist/index.native.js.map +1 -1
  8. package/dist/index.node.cjs +2660 -1937
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.js +2657 -1939
  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 +9 -1
  15. package/dist/types/index.d.ts.map +1 -0
  16. package/dist/types/loaders/account.d.ts +5 -0
  17. package/dist/types/loaders/account.d.ts.map +1 -0
  18. package/dist/types/loaders/block.d.ts +5 -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 +5 -0
  25. package/dist/types/loaders/program-accounts.d.ts.map +1 -0
  26. package/dist/types/loaders/transaction.d.ts +5 -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/scalars.d.ts +44 -0
  43. package/dist/types/resolvers/scalars.d.ts.map +1 -0
  44. package/dist/types/resolvers/transaction.d.ts +19 -0
  45. package/dist/types/resolvers/transaction.d.ts.map +1 -0
  46. package/dist/types/resolvers/types.d.ts +26 -0
  47. package/dist/types/resolvers/types.d.ts.map +1 -0
  48. package/dist/types/schema/account.d.ts +2 -0
  49. package/dist/types/schema/account.d.ts.map +1 -0
  50. package/dist/types/schema/block.d.ts +2 -0
  51. package/dist/types/schema/block.d.ts.map +1 -0
  52. package/dist/types/schema/common/inputs.d.ts +2 -0
  53. package/dist/types/schema/common/inputs.d.ts.map +1 -0
  54. package/dist/types/schema/common/scalars.d.ts +2 -0
  55. package/dist/types/schema/common/scalars.d.ts.map +1 -0
  56. package/dist/types/schema/common/types.d.ts +2 -0
  57. package/dist/types/schema/common/types.d.ts.map +1 -0
  58. package/dist/types/schema/index.d.ts +2 -0
  59. package/dist/types/schema/index.d.ts.map +1 -0
  60. package/dist/types/schema/instruction.d.ts +2 -0
  61. package/dist/types/schema/instruction.d.ts.map +1 -0
  62. package/dist/types/schema/root.d.ts +2 -0
  63. package/dist/types/schema/root.d.ts.map +1 -0
  64. package/dist/types/schema/transaction.d.ts +2 -0
  65. package/dist/types/schema/transaction.d.ts.map +1 -0
  66. package/package.json +21 -16
  67. package/dist/types/cache.d.ts +0 -7
  68. package/dist/types/rpc.d.ts +0 -13
  69. package/dist/types/schema/account/index.d.ts +0 -3
  70. package/dist/types/schema/account/query.d.ts +0 -38
  71. package/dist/types/schema/account/types.d.ts +0 -5
  72. package/dist/types/schema/block/index.d.ts +0 -3
  73. package/dist/types/schema/block/query.d.ts +0 -42
  74. package/dist/types/schema/block/types.d.ts +0 -7
  75. package/dist/types/schema/inputs.d.ts +0 -9
  76. package/dist/types/schema/picks.d.ts +0 -36
  77. package/dist/types/schema/program-accounts/index.d.ts +0 -2
  78. package/dist/types/schema/program-accounts/query.d.ts +0 -47
  79. package/dist/types/schema/program-accounts/types.d.ts +0 -3
  80. package/dist/types/schema/scalars.d.ts +0 -3
  81. package/dist/types/schema/transaction/index.d.ts +0 -3
  82. package/dist/types/schema/transaction/query.d.ts +0 -33
  83. package/dist/types/schema/transaction/types.d.ts +0 -12
@@ -1,2194 +1,2912 @@
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/solana-labs/solana-web3.js/pull/2052
69
+ config
70
+ ).send();
71
+ }
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
+ };
160
83
  }
161
- var memoisedBigint;
162
- function bigint() {
163
- if (!memoisedBigint)
164
- memoisedBigint = { type: BigIntScalar() };
165
- return memoisedBigint;
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
+ };
166
100
  }
167
- function number() {
168
- return { type: GraphQLInt };
101
+ async function loadProgramAccounts(rpc, { programAddress, ...config }) {
102
+ return await rpc.getProgramAccounts(
103
+ programAddress,
104
+ // @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
105
+ config
106
+ ).send();
169
107
  }
170
- function string() {
171
- return { type: GraphQLString };
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/solana-labs/solana-web3.js/pull/2052
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
1206
  );
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
- );
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
1218
  };
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;
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
+ }
2037
1232
  };
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";
1233
+ var scalarResolvers = {
1234
+ Address: stringScalarAlias,
1235
+ Base58EncodedBytes: stringScalarAlias,
1236
+ Base64EncodedBytes: stringScalarAlias,
1237
+ Base64ZstdEncodedBytes: stringScalarAlias,
1238
+ BigInt: {
1239
+ __parseLiteral(ast) {
1240
+ if (ast.kind === Kind.STRING) {
1241
+ return BigInt(ast.value);
2057
1242
  }
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
- };
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;
2098
- };
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;
2111
- };
2112
- var memoisedBlockTypes;
2113
- var blockTypes = () => {
2114
- if (!memoisedBlockTypes)
2115
- memoisedBlockTypes = [
2116
- blockWithNoTransactions(),
2117
- blockWithSignatures(),
2118
- blockWithAccounts(),
2119
- blockWithTransactions()
2120
- ];
2121
- return memoisedBlockTypes;
2122
- };
2123
-
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())
1243
+ return null;
2134
1244
  },
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()
1245
+ __parseValue(value) {
1246
+ return BigInt(value);
2158
1247
  },
2159
- resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
2160
- type: new GraphQLList(programAccount())
1248
+ __serialize(value) {
1249
+ return BigInt(value);
1250
+ }
1251
+ }
1252
+ };
1253
+
1254
+ // src/resolvers/types.ts
1255
+ var commonTypeResolvers = {
1256
+ AccountEncoding: {
1257
+ BASE_58: "base58",
1258
+ BASE_64: "base64",
1259
+ BASE_64_ZSTD: "base64+zstd",
1260
+ PARSED: "jsonParsed"
1261
+ },
1262
+ TokenBalance: {
1263
+ mint: resolveAccount("mint"),
1264
+ owner: resolveAccount("owner")
1265
+ },
1266
+ TransactionEncoding: {
1267
+ BASE_58: "base58",
1268
+ BASE_64: "base64",
1269
+ PARSED: "jsonParsed"
1270
+ },
1271
+ TransactionVersion: {
1272
+ LEGACY: "legacy",
1273
+ ZERO: 0
2161
1274
  }
2162
- });
1275
+ };
1276
+
1277
+ // src/resolvers/index.ts
1278
+ function createSolanaGraphQLResolvers() {
1279
+ return {
1280
+ ...accountResolvers,
1281
+ ...blockResolvers,
1282
+ ...commonTypeResolvers,
1283
+ ...instructionResolvers,
1284
+ ...rootResolvers,
1285
+ ...scalarResolvers,
1286
+ ...transactionResolvers
1287
+ };
1288
+ }
1289
+
1290
+ // src/schema/account.ts
1291
+ var accountTypeDefs = (
1292
+ /* GraphQL */
1293
+ `
1294
+ """
1295
+ Account interface
1296
+ """
1297
+ interface Account {
1298
+ address: Address
1299
+ executable: Boolean
1300
+ lamports: BigInt
1301
+ ownerProgram: Account
1302
+ space: BigInt
1303
+ rentEpoch: BigInt
1304
+ }
1305
+
1306
+ """
1307
+ An account with base58 encoded data
1308
+ """
1309
+ type AccountBase58 implements Account {
1310
+ address: Address
1311
+ data: Base58EncodedBytes
1312
+ executable: Boolean
1313
+ lamports: BigInt
1314
+ ownerProgram: Account
1315
+ space: BigInt
1316
+ rentEpoch: BigInt
1317
+ }
1318
+
1319
+ """
1320
+ An account with base64 encoded data
1321
+ """
1322
+ type AccountBase64 implements Account {
1323
+ address: Address
1324
+ data: Base64EncodedBytes
1325
+ executable: Boolean
1326
+ lamports: BigInt
1327
+ ownerProgram: Account
1328
+ space: BigInt
1329
+ rentEpoch: BigInt
1330
+ }
1331
+
1332
+ """
1333
+ An account with base64+zstd encoded data
1334
+ """
1335
+ type AccountBase64Zstd implements Account {
1336
+ address: Address
1337
+ data: Base64ZstdEncodedBytes
1338
+ executable: Boolean
1339
+ lamports: BigInt
1340
+ ownerProgram: Account
1341
+ space: BigInt
1342
+ rentEpoch: BigInt
1343
+ }
1344
+
1345
+ type NonceAccountFeeCalculator {
1346
+ lamportsPerSignature: String
1347
+ }
1348
+ """
1349
+ A nonce account
1350
+ """
1351
+ type NonceAccount implements Account {
1352
+ address: Address
1353
+ executable: Boolean
1354
+ lamports: BigInt
1355
+ ownerProgram: Account
1356
+ space: BigInt
1357
+ rentEpoch: BigInt
1358
+ authority: Account
1359
+ blockhash: String
1360
+ feeCalculator: NonceAccountFeeCalculator
1361
+ }
1362
+
1363
+ """
1364
+ A lookup table account
1365
+ """
1366
+ type LookupTableAccount implements Account {
1367
+ address: Address
1368
+ executable: Boolean
1369
+ lamports: BigInt
1370
+ ownerProgram: Account
1371
+ space: BigInt
1372
+ rentEpoch: BigInt
1373
+ addresses: [Address]
1374
+ authority: Account
1375
+ deactivationSlot: String
1376
+ lastExtendedSlot: String
1377
+ lastExtendedSlotStartIndex: Int
1378
+ }
1379
+
1380
+ """
1381
+ A mint account
1382
+ """
1383
+ type MintAccount implements Account {
1384
+ address: Address
1385
+ executable: Boolean
1386
+ lamports: BigInt
1387
+ ownerProgram: Account
1388
+ space: BigInt
1389
+ rentEpoch: BigInt
1390
+ decimals: Int
1391
+ freezeAuthority: Account
1392
+ isInitialized: Boolean
1393
+ mintAuthority: Account
1394
+ supply: String
1395
+ }
1396
+
1397
+ """
1398
+ A token account
1399
+ """
1400
+ type TokenAccount implements Account {
1401
+ address: Address
1402
+ executable: Boolean
1403
+ lamports: BigInt
1404
+ ownerProgram: Account
1405
+ space: BigInt
1406
+ rentEpoch: BigInt
1407
+ isNative: Boolean
1408
+ mint: Account
1409
+ owner: Account
1410
+ state: String
1411
+ tokenAmount: TokenAmount
1412
+ }
1413
+
1414
+ type StakeAccountDataMetaAuthorized {
1415
+ staker: Account
1416
+ withdrawer: Account
1417
+ }
1418
+ type StakeAccountDataMetaLockup {
1419
+ custodian: Account
1420
+ epoch: BigInt
1421
+ unixTimestamp: BigInt
1422
+ }
1423
+ type StakeAccountDataMeta {
1424
+ authorized: StakeAccountDataMetaAuthorized
1425
+ lockup: StakeAccountDataMetaLockup
1426
+ rentExemptReserve: String
1427
+ }
1428
+ type StakeAccountDataStakeDelegation {
1429
+ activationEpoch: BigInt
1430
+ deactivationEpoch: BigInt
1431
+ stake: String
1432
+ voter: Account
1433
+ warmupCooldownRate: Int
1434
+ }
1435
+ type StakeAccountDataStake {
1436
+ creditsObserved: BigInt
1437
+ delegation: StakeAccountDataStakeDelegation
1438
+ }
1439
+ """
1440
+ A stake account
1441
+ """
1442
+ type StakeAccount implements Account {
1443
+ address: Address
1444
+ executable: Boolean
1445
+ lamports: BigInt
1446
+ ownerProgram: Account
1447
+ space: BigInt
1448
+ rentEpoch: BigInt
1449
+ meta: StakeAccountDataMeta
1450
+ stake: StakeAccountDataStake
1451
+ }
1452
+
1453
+ type VoteAccountDataAuthorizedVoter {
1454
+ authorizedVoter: Account
1455
+ epoch: BigInt
1456
+ }
1457
+ type VoteAccountDataEpochCredit {
1458
+ credits: String
1459
+ epoch: BigInt
1460
+ previousCredits: String
1461
+ }
1462
+ type VoteAccountDataLastTimestamp {
1463
+ slot: BigInt
1464
+ timestamp: BigInt
1465
+ }
1466
+ type VoteAccountDataVote {
1467
+ confirmationCount: Int
1468
+ slot: BigInt
1469
+ }
1470
+ """
1471
+ A vote account
1472
+ """
1473
+ type VoteAccount implements Account {
1474
+ address: Address
1475
+ executable: Boolean
1476
+ lamports: BigInt
1477
+ ownerProgram: Account
1478
+ space: BigInt
1479
+ rentEpoch: BigInt
1480
+ authorizedVoters: [VoteAccountDataAuthorizedVoter]
1481
+ authorizedWithdrawer: Account
1482
+ commission: Int
1483
+ epochCredits: [VoteAccountDataEpochCredit]
1484
+ lastTimestamp: VoteAccountDataLastTimestamp
1485
+ node: Account
1486
+ priorVoters: [Address]
1487
+ rootSlot: BigInt
1488
+ votes: [VoteAccountDataVote]
1489
+ }
1490
+ `
1491
+ );
1492
+
1493
+ // src/schema/block.ts
1494
+ var blockTypeDefs = (
1495
+ /* GraphQL */
1496
+ `
1497
+ type TransactionMetaForAccounts {
1498
+ err: String
1499
+ fee: BigInt
1500
+ postBalances: [BigInt]
1501
+ postTokenBalances: [TokenBalance]
1502
+ preBalances: [BigInt]
1503
+ preTokenBalances: [TokenBalance]
1504
+ status: TransactionStatus
1505
+ }
1506
+
1507
+ type TransactionDataForAccounts {
1508
+ accountKeys: [Address]
1509
+ signatures: [String]
1510
+ }
1511
+
1512
+ type BlockTransactionAccounts {
1513
+ meta: TransactionMetaForAccounts
1514
+ data: TransactionDataForAccounts
1515
+ version: String
1516
+ }
1517
+
1518
+ """
1519
+ Block interface
1520
+ """
1521
+ interface Block {
1522
+ blockhash: String
1523
+ blockHeight: BigInt
1524
+ blockTime: BigInt
1525
+ parentSlot: BigInt
1526
+ previousBlockhash: String
1527
+ rewards: [Reward]
1528
+ transactionDetails: String
1529
+ }
1530
+
1531
+ """
1532
+ A block with account transaction details
1533
+ """
1534
+ type BlockWithAccounts implements Block {
1535
+ blockhash: String
1536
+ blockHeight: BigInt
1537
+ blockTime: BigInt
1538
+ parentSlot: BigInt
1539
+ previousBlockhash: String
1540
+ rewards: [Reward]
1541
+ transactions: [BlockTransactionAccounts]
1542
+ transactionDetails: String
1543
+ }
1544
+
1545
+ """
1546
+ A block with full transaction details
1547
+ """
1548
+ type BlockWithFull implements Block {
1549
+ blockhash: String
1550
+ blockHeight: BigInt
1551
+ blockTime: BigInt
1552
+ parentSlot: BigInt
1553
+ previousBlockhash: String
1554
+ rewards: [Reward]
1555
+ transactions: [Transaction]
1556
+ transactionDetails: String
1557
+ }
1558
+
1559
+ """
1560
+ A block with no transaction details
1561
+ """
1562
+ type BlockWithNone implements Block {
1563
+ blockhash: String
1564
+ blockHeight: BigInt
1565
+ blockTime: BigInt
1566
+ parentSlot: BigInt
1567
+ previousBlockhash: String
1568
+ rewards: [Reward]
1569
+ transactionDetails: String
1570
+ }
1571
+
1572
+ """
1573
+ A block with signature transaction details
1574
+ """
1575
+ type BlockWithSignatures implements Block {
1576
+ blockhash: String
1577
+ blockHeight: BigInt
1578
+ blockTime: BigInt
1579
+ parentSlot: BigInt
1580
+ previousBlockhash: String
1581
+ rewards: [Reward]
1582
+ signatures: [String]
1583
+ transactionDetails: String
1584
+ }
1585
+ `
1586
+ );
1587
+
1588
+ // src/schema/common/inputs.ts
1589
+ var inputTypeDefs = (
1590
+ /* GraphQL */
1591
+ `
1592
+ input DataSlice {
1593
+ offset: Int
1594
+ length: Int
1595
+ }
1596
+
1597
+ input ProgramAccountsFilter {
1598
+ bytes: BigInt
1599
+ dataSize: BigInt
1600
+ encoding: AccountEncoding
1601
+ offset: BigInt
1602
+ }
1603
+ `
1604
+ );
1605
+
1606
+ // src/schema/common/scalars.ts
1607
+ var scalarTypeDefs = (
1608
+ /* GraphQL */
1609
+ `
1610
+ scalar Address
1611
+ scalar Base58EncodedBytes
1612
+ scalar Base64EncodedBytes
1613
+ scalar Base64ZstdEncodedBytes
1614
+ scalar BigInt
1615
+ `
1616
+ );
1617
+
1618
+ // src/schema/common/types.ts
1619
+ var commonTypeDefs = (
1620
+ /* GraphQL */
1621
+ `
1622
+ enum AccountEncoding {
1623
+ BASE_58
1624
+ BASE_64
1625
+ BASE_64_ZSTD
1626
+ PARSED
1627
+ }
1628
+
1629
+ enum BlockTransactionDetails {
1630
+ accounts
1631
+ full
1632
+ none
1633
+ signatures
1634
+ }
1635
+
1636
+ enum Commitment {
1637
+ confirmed
1638
+ finalized
1639
+ processed
1640
+ }
1641
+
1642
+ type ReturnData {
1643
+ data: Base64EncodedBytes
1644
+ programId: Address
1645
+ }
1646
+
1647
+ type Reward {
1648
+ commission: Int
1649
+ lamports: BigInt
1650
+ postBalance: BigInt
1651
+ pubkey: Address
1652
+ rewardType: String
1653
+ }
1654
+
1655
+ type TokenAmount {
1656
+ amount: String
1657
+ decimals: Int
1658
+ uiAmount: BigInt
1659
+ uiAmountString: String
1660
+ }
1661
+
1662
+ type TokenBalance {
1663
+ accountIndex: Int
1664
+ mint: Account
1665
+ owner: Account
1666
+ programId: Address
1667
+ uiTokenAmount: TokenAmount
1668
+ }
1669
+
1670
+ enum TransactionEncoding {
1671
+ BASE_58
1672
+ BASE_64
1673
+ PARSED
1674
+ }
1675
+
1676
+ enum TransactionVersion {
1677
+ LEGACY
1678
+ ZERO
1679
+ }
1680
+ `
1681
+ );
1682
+
1683
+ // src/schema/instruction.ts
1684
+ var instructionTypeDefs = (
1685
+ /* GraphQL */
1686
+ `
1687
+ """
1688
+ Transaction instruction interface
1689
+ """
1690
+ interface TransactionInstruction {
1691
+ programId: Address
1692
+ }
1693
+
1694
+ """
1695
+ Generic transaction instruction
1696
+ """
1697
+ type GenericInstruction implements TransactionInstruction {
1698
+ accounts: [Address]
1699
+ data: Base64EncodedBytes
1700
+ programId: Address
1701
+ }
1702
+
1703
+ """
1704
+ AddressLookupTable: CreateLookupTable instruction
1705
+ """
1706
+ type CreateLookupTableInstruction implements TransactionInstruction {
1707
+ programId: Address
1708
+ bumpSeed: BigInt # FIXME:*
1709
+ lookupTableAccount: Account
1710
+ lookupTableAuthority: Account
1711
+ payerAccount: Account
1712
+ recentSlot: BigInt
1713
+ systemProgram: Account
1714
+ }
1715
+
1716
+ """
1717
+ AddressLookupTable: ExtendLookupTable instruction
1718
+ """
1719
+ type ExtendLookupTableInstruction implements TransactionInstruction {
1720
+ programId: Address
1721
+ lookupTableAccount: Account
1722
+ lookupTableAuthority: Account
1723
+ newAddresses: [Address]
1724
+ payerAccount: Account
1725
+ systemProgram: Account
1726
+ }
1727
+
1728
+ """
1729
+ AddressLookupTable: FreezeLookupTable instruction
1730
+ """
1731
+ type FreezeLookupTableInstruction implements TransactionInstruction {
1732
+ programId: Address
1733
+ lookupTableAccount: Account
1734
+ lookupTableAuthority: Account
1735
+ }
1736
+
1737
+ """
1738
+ AddressLookupTable: DeactivateLookupTable instruction
1739
+ """
1740
+ type DeactivateLookupTableInstruction implements TransactionInstruction {
1741
+ programId: Address
1742
+ lookupTableAccount: Account
1743
+ lookupTableAuthority: Account
1744
+ }
1745
+
1746
+ """
1747
+ AddressLookupTable: CloseLookupTable instruction
1748
+ """
1749
+ type CloseLookupTableInstruction implements TransactionInstruction {
1750
+ programId: Address
1751
+ lookupTableAccount: Account
1752
+ lookupTableAuthority: Account
1753
+ recipient: Account
1754
+ }
2163
1755
 
2164
- // src/rpc.ts
1756
+ """
1757
+ BpfLoader: Write instruction
1758
+ """
1759
+ type BpfLoaderWriteInstruction implements TransactionInstruction {
1760
+ programId: Address
1761
+ account: Account
1762
+ bytes: Base64EncodedBytes
1763
+ offset: BigInt # FIXME:*
1764
+ }
1765
+
1766
+ """
1767
+ BpfLoader: Finalize instruction
1768
+ """
1769
+ type BpfLoaderFinalizeInstruction implements TransactionInstruction {
1770
+ programId: Address
1771
+ account: Account
1772
+ }
1773
+
1774
+ """
1775
+ BpfUpgradeableLoader: InitializeBuffer instruction
1776
+ """
1777
+ type BpfUpgradeableLoaderInitializeBufferInstruction implements TransactionInstruction {
1778
+ programId: Address
1779
+ account: Account
1780
+ }
1781
+
1782
+ """
1783
+ BpfUpgradeableLoader: Write instruction
1784
+ """
1785
+ type BpfUpgradeableLoaderWriteInstruction implements TransactionInstruction {
1786
+ programId: Address
1787
+ account: Account
1788
+ authority: Account
1789
+ bytes: Base64EncodedBytes
1790
+ offset: BigInt # FIXME:*
1791
+ }
1792
+
1793
+ """
1794
+ BpfUpgradeableLoader: DeployWithMaxDataLen instruction
1795
+ """
1796
+ type BpfUpgradeableLoaderDeployWithMaxDataLenInstruction implements TransactionInstruction {
1797
+ programId: Address
1798
+ authority: Account
1799
+ bufferAccount: Account
1800
+ clockSysvar: Address
1801
+ maxDataLen: BigInt
1802
+ payerAccount: Account
1803
+ programAccount: Account
1804
+ programDataAccount: Account
1805
+ rentSysvar: Address
1806
+ }
1807
+
1808
+ """
1809
+ BpfUpgradeableLoader: Upgrade instruction
1810
+ """
1811
+ type BpfUpgradeableLoaderUpgradeInstruction implements TransactionInstruction {
1812
+ programId: Address
1813
+ authority: Account
1814
+ bufferAccount: Account
1815
+ clockSysvar: Address
1816
+ programAccount: Account
1817
+ programDataAccount: Account
1818
+ rentSysvar: Address
1819
+ spillAccount: Account
1820
+ }
1821
+
1822
+ """
1823
+ BpfUpgradeableLoader: SetAuthority instruction
1824
+ """
1825
+ type BpfUpgradeableLoaderSetAuthorityInstruction implements TransactionInstruction {
1826
+ programId: Address
1827
+ account: Account
1828
+ authority: Account
1829
+ newAuthority: Account
1830
+ }
1831
+
1832
+ """
1833
+ BpfUpgradeableLoader: SetAuthorityChecked instruction
1834
+ """
1835
+ type BpfUpgradeableLoaderSetAuthorityCheckedInstruction implements TransactionInstruction {
1836
+ programId: Address
1837
+ account: Account
1838
+ authority: Account
1839
+ newAuthority: Account
1840
+ }
1841
+
1842
+ """
1843
+ BpfUpgradeableLoader: Close instruction
1844
+ """
1845
+ type BpfUpgradeableLoaderCloseInstruction implements TransactionInstruction {
1846
+ programId: Address
1847
+ account: Account
1848
+ authority: Account
1849
+ programAccount: Account
1850
+ recipient: Account
1851
+ }
1852
+
1853
+ """
1854
+ BpfUpgradeableLoader: ExtendProgram instruction
1855
+ """
1856
+ type BpfUpgradeableLoaderExtendProgramInstruction implements TransactionInstruction {
1857
+ programId: Address
1858
+ additionalBytes: BigInt
1859
+ payerAccount: Account
1860
+ programAccount: Account
1861
+ programDataAccount: Account
1862
+ systemProgram: Account
1863
+ }
1864
+
1865
+ """
1866
+ SplAssociatedTokenAccount: Create instruction
1867
+ """
1868
+ type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
1869
+ programId: Address
1870
+ account: Account
1871
+ mint: Address
1872
+ source: Account
1873
+ systemProgram: Account
1874
+ tokenProgram: Account
1875
+ wallet: Account
1876
+ }
1877
+
1878
+ """
1879
+ SplAssociatedTokenAccount: CreateIdempotent instruction
1880
+ """
1881
+ type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
1882
+ programId: Address
1883
+ account: Account
1884
+ mint: Address
1885
+ source: Account
1886
+ systemProgram: Account
1887
+ tokenProgram: Account
1888
+ wallet: Account
1889
+ }
1890
+
1891
+ """
1892
+ SplAssociatedTokenAccount: RecoverNested instruction
1893
+ """
1894
+ type SplAssociatedTokenRecoverNestedInstruction implements TransactionInstruction {
1895
+ programId: Address
1896
+ destination: Account
1897
+ nestedMint: Account
1898
+ nestedOwner: Account
1899
+ nestedSource: Account
1900
+ ownerMint: Account
1901
+ tokenProgram: Account
1902
+ wallet: Account
1903
+ }
1904
+
1905
+ """
1906
+ SplMemo instruction
1907
+ """
1908
+ type SplMemoInstruction implements TransactionInstruction {
1909
+ programId: Address
1910
+ memo: String
1911
+ }
1912
+
1913
+ """
1914
+ SplToken: InitializeMint instruction
1915
+ """
1916
+ type SplTokenInitializeMintInstruction implements TransactionInstruction {
1917
+ programId: Address
1918
+ decimals: BigInt # FIXME:*
1919
+ freezeAuthority: Account
1920
+ mint: Account
1921
+ mintAuthority: Account
1922
+ rentSysvar: Address
1923
+ }
1924
+
1925
+ """
1926
+ SplToken: InitializeMint2 instruction
1927
+ """
1928
+ type SplTokenInitializeMint2Instruction implements TransactionInstruction {
1929
+ programId: Address
1930
+ decimals: BigInt # FIXME:*
1931
+ freezeAuthority: Account
1932
+ mint: Account
1933
+ mintAuthority: Account
1934
+ }
1935
+
1936
+ """
1937
+ SplToken: InitializeAccount instruction
1938
+ """
1939
+ type SplTokenInitializeAccountInstruction implements TransactionInstruction {
1940
+ programId: Address
1941
+ account: Account
1942
+ mint: Account
1943
+ owner: Account
1944
+ rentSysvar: Address
1945
+ }
1946
+
1947
+ """
1948
+ SplToken: InitializeAccount2 instruction
1949
+ """
1950
+ type SplTokenInitializeAccount2Instruction implements TransactionInstruction {
1951
+ programId: Address
1952
+ account: Account
1953
+ mint: Account
1954
+ owner: Account
1955
+ rentSysvar: Address
1956
+ }
1957
+
1958
+ """
1959
+ SplToken: InitializeAccount3 instruction
1960
+ """
1961
+ type SplTokenInitializeAccount3Instruction implements TransactionInstruction {
1962
+ programId: Address
1963
+ account: Account
1964
+ mint: Account
1965
+ owner: Account
1966
+ }
1967
+
1968
+ """
1969
+ SplToken: InitializeMultisig instruction
1970
+ """
1971
+ type SplTokenInitializeMultisigInstruction implements TransactionInstruction {
1972
+ programId: Address
1973
+ m: BigInt # FIXME:*
1974
+ multisig: Account
1975
+ rentSysvar: Address
1976
+ signers: [Address]
1977
+ }
1978
+
1979
+ """
1980
+ SplToken: InitializeMultisig2 instruction
1981
+ """
1982
+ type SplTokenInitializeMultisig2Instruction implements TransactionInstruction {
1983
+ programId: Address
1984
+ m: BigInt # FIXME:*
1985
+ multisig: Account
1986
+ signers: [Address]
1987
+ }
1988
+
1989
+ """
1990
+ SplToken: Transfer instruction
1991
+ """
1992
+ type SplTokenTransferInstruction implements TransactionInstruction {
1993
+ programId: Address
1994
+ amount: String
1995
+ authority: Account
1996
+ destination: Account
1997
+ multisigAuthority: Account
1998
+ source: Account
1999
+ }
2000
+
2001
+ """
2002
+ SplToken: Approve instruction
2003
+ """
2004
+ type SplTokenApproveInstruction implements TransactionInstruction {
2005
+ programId: Address
2006
+ amount: String
2007
+ delegate: Account
2008
+ multisigOwner: Account
2009
+ owner: Account
2010
+ source: Account
2011
+ }
2012
+
2013
+ """
2014
+ SplToken: Revoke instruction
2015
+ """
2016
+ type SplTokenRevokeInstruction implements TransactionInstruction {
2017
+ programId: Address
2018
+ multisigOwner: Account
2019
+ owner: Account
2020
+ source: Account
2021
+ }
2022
+
2023
+ """
2024
+ SplToken: SetAuthority instruction
2025
+ """
2026
+ type SplTokenSetAuthorityInstruction implements TransactionInstruction {
2027
+ programId: Address
2028
+ authority: Account
2029
+ authorityType: String
2030
+ multisigAuthority: Account
2031
+ newAuthority: Account
2032
+ }
2033
+
2034
+ """
2035
+ SplToken: MintTo instruction
2036
+ """
2037
+ type SplTokenMintToInstruction implements TransactionInstruction {
2038
+ programId: Address
2039
+ account: Account
2040
+ amount: String
2041
+ authority: Account
2042
+ mint: Account
2043
+ mintAuthority: Account
2044
+ multisigMintAuthority: Account
2045
+ }
2046
+
2047
+ """
2048
+ SplToken: Burn instruction
2049
+ """
2050
+ type SplTokenBurnInstruction implements TransactionInstruction {
2051
+ programId: Address
2052
+ account: Account
2053
+ amount: String
2054
+ authority: Account
2055
+ mint: Account
2056
+ multisigAuthority: Account
2057
+ }
2058
+
2059
+ """
2060
+ SplToken: CloseAccount instruction
2061
+ """
2062
+ type SplTokenCloseAccountInstruction implements TransactionInstruction {
2063
+ programId: Address
2064
+ account: Account
2065
+ destination: Account
2066
+ multisigOwner: Account
2067
+ owner: Account
2068
+ }
2069
+
2070
+ """
2071
+ SplToken: FreezeAccount instruction
2072
+ """
2073
+ type SplTokenFreezeAccountInstruction implements TransactionInstruction {
2074
+ programId: Address
2075
+ account: Account
2076
+ freezeAuthority: Account
2077
+ mint: Account
2078
+ multisigFreezeAuthority: Account
2079
+ }
2080
+
2081
+ """
2082
+ SplToken: ThawAccount instruction
2083
+ """
2084
+ type SplTokenThawAccountInstruction implements TransactionInstruction {
2085
+ programId: Address
2086
+ account: Account
2087
+ freezeAuthority: Account
2088
+ mint: Account
2089
+ multisigFreezeAuthority: Account
2090
+ }
2091
+
2092
+ """
2093
+ SplToken: TransferChecked instruction
2094
+ """
2095
+ type SplTokenTransferCheckedInstruction implements TransactionInstruction {
2096
+ programId: Address
2097
+ amount: String
2098
+ authority: Account
2099
+ decimals: BigInt # FIXME:*
2100
+ destination: Account
2101
+ mint: Account
2102
+ multisigAuthority: Account
2103
+ source: Account
2104
+ tokenAmount: String
2105
+ }
2106
+
2107
+ """
2108
+ SplToken: ApproveChecked instruction
2109
+ """
2110
+ type SplTokenApproveCheckedInstruction implements TransactionInstruction {
2111
+ programId: Address
2112
+ delegate: Account
2113
+ mint: Account
2114
+ multisigOwner: Account
2115
+ owner: Account
2116
+ source: Account
2117
+ tokenAmount: String
2118
+ }
2119
+
2120
+ """
2121
+ SplToken: MintToChecked instruction
2122
+ """
2123
+ type SplTokenMintToCheckedInstruction implements TransactionInstruction {
2124
+ programId: Address
2125
+ account: Account
2126
+ authority: Account
2127
+ mint: Account
2128
+ mintAuthority: Account
2129
+ multisigMintAuthority: Account
2130
+ tokenAmount: String
2131
+ }
2132
+
2133
+ """
2134
+ SplToken: BurnChecked instruction
2135
+ """
2136
+ type SplTokenBurnCheckedInstruction implements TransactionInstruction {
2137
+ programId: Address
2138
+ account: Account
2139
+ authority: Account
2140
+ mint: Account
2141
+ multisigAuthority: Account
2142
+ tokenAmount: String
2143
+ }
2144
+
2145
+ """
2146
+ SplToken: SyncNative instruction
2147
+ """
2148
+ type SplTokenSyncNativeInstruction implements TransactionInstruction {
2149
+ programId: Address
2150
+ account: Account
2151
+ }
2152
+
2153
+ """
2154
+ SplToken: GetAccountDataSize instruction
2155
+ """
2156
+ type SplTokenGetAccountDataSizeInstruction implements TransactionInstruction {
2157
+ programId: Address
2158
+ extensionTypes: [String]
2159
+ mint: Account
2160
+ }
2161
+
2162
+ """
2163
+ SplToken: InitializeImmutableOwner instruction
2164
+ """
2165
+ type SplTokenInitializeImmutableOwnerInstruction implements TransactionInstruction {
2166
+ programId: Address
2167
+ account: Account
2168
+ }
2169
+
2170
+ """
2171
+ SplToken: AmountToUiAmount instruction
2172
+ """
2173
+ type SplTokenAmountToUiAmountInstruction implements TransactionInstruction {
2174
+ programId: Address
2175
+ amount: String
2176
+ mint: Account
2177
+ }
2178
+
2179
+ """
2180
+ SplToken: UiAmountToAmount instruction
2181
+ """
2182
+ type SplTokenUiAmountToAmountInstruction implements TransactionInstruction {
2183
+ programId: Address
2184
+ mint: Account
2185
+ uiAmount: String
2186
+ }
2187
+
2188
+ """
2189
+ SplToken: InitializeMintCloseAuthority instruction
2190
+ """
2191
+ type SplTokenInitializeMintCloseAuthorityInstruction implements TransactionInstruction {
2192
+ programId: Address
2193
+ mint: Account
2194
+ newAuthority: Account
2195
+ }
2196
+
2197
+ # TODO: Extensions!
2198
+ # - TransferFeeExtension
2199
+ # - ConfidentialTransferFeeExtension
2200
+ # - DefaultAccountStateExtension
2201
+ # - Reallocate
2202
+ # - MemoTransferExtension
2203
+ # - CreateNativeMint
2204
+ # - InitializeNonTransferableMint
2205
+ # - InterestBearingMintExtension
2206
+ # - CpiGuardExtension
2207
+ # - InitializePermanentDelegate
2208
+ # - TransferHookExtension
2209
+ # - ConfidentialTransferFeeExtension
2210
+ # - WithdrawExcessLamports
2211
+ # - MetadataPointerExtension
2212
+
2213
+ type Lockup {
2214
+ custodian: Account
2215
+ epoch: BigInt
2216
+ unixTimestamp: BigInt
2217
+ }
2218
+
2219
+ """
2220
+ Stake: Initialize instruction
2221
+ """
2222
+ type StakeInitializeInstructionDataAuthorized {
2223
+ staker: Account
2224
+ withdrawer: Account
2225
+ }
2226
+ type StakeInitializeInstruction implements TransactionInstruction {
2227
+ programId: Address
2228
+ authorized: StakeInitializeInstructionDataAuthorized
2229
+ lockup: Lockup
2230
+ rentSysvar: Address
2231
+ stakeAccount: Account
2232
+ }
2233
+
2234
+ """
2235
+ Stake: Authorize instruction
2236
+ """
2237
+ type StakeAuthorizeInstruction implements TransactionInstruction {
2238
+ programId: Address
2239
+ authority: Account
2240
+ authorityType: String
2241
+ clockSysvar: Address
2242
+ custodian: Account
2243
+ newAuthority: Account
2244
+ stakeAccount: Account
2245
+ }
2246
+
2247
+ """
2248
+ Stake: DelegateStake instruction
2249
+ """
2250
+ type StakeDelegateStakeInstruction implements TransactionInstruction {
2251
+ programId: Address
2252
+ clockSysvar: Address
2253
+ stakeAccount: Account
2254
+ stakeAuthority: Account
2255
+ stakeConfigAccount: Account
2256
+ stakeHistorySysvar: Address
2257
+ voteAccount: Account
2258
+ }
2259
+
2260
+ """
2261
+ Stake: Split instruction
2262
+ """
2263
+ type StakeSplitInstruction implements TransactionInstruction {
2264
+ programId: Address
2265
+ lamports: BigInt
2266
+ newSplitAccount: Account
2267
+ stakeAccount: Account
2268
+ stakeAuthority: Account
2269
+ }
2270
+
2271
+ """
2272
+ Stake: Withdraw instruction
2273
+ """
2274
+ type StakeWithdrawInstruction implements TransactionInstruction {
2275
+ programId: Address
2276
+ clockSysvar: Address
2277
+ destination: Account
2278
+ lamports: BigInt
2279
+ stakeAccount: Account
2280
+ withdrawAuthority: Account
2281
+ }
2282
+
2283
+ """
2284
+ Stake: Deactivate instruction
2285
+ """
2286
+ type StakeDeactivateInstruction implements TransactionInstruction {
2287
+ programId: Address
2288
+ clockSysvar: Address
2289
+ stakeAccount: Account
2290
+ stakeAuthority: Account
2291
+ }
2292
+
2293
+ """
2294
+ Stake: SetLockup instruction
2295
+ """
2296
+ type StakeSetLockupInstruction implements TransactionInstruction {
2297
+ programId: Address
2298
+ custodian: Account
2299
+ lockup: Lockup
2300
+ stakeAccount: Account
2301
+ }
2302
+
2303
+ """
2304
+ Stake: Merge instruction
2305
+ """
2306
+ type StakeMergeInstruction implements TransactionInstruction {
2307
+ programId: Address
2308
+ clockSysvar: Address
2309
+ destination: Account
2310
+ source: Account
2311
+ stakeAuthority: Account
2312
+ stakeHistorySysvar: Address
2313
+ }
2314
+
2315
+ """
2316
+ Stake: AuthorizeWithSeed instruction
2317
+ """
2318
+ type StakeAuthorizeWithSeedInstruction implements TransactionInstruction {
2319
+ programId: Address
2320
+ authorityBase: Account
2321
+ authorityOwner: Account
2322
+ authoritySeed: String
2323
+ authorityType: String
2324
+ clockSysvar: Address
2325
+ custodian: Account
2326
+ newAuthorized: Account
2327
+ stakeAccount: Account
2328
+ }
2329
+
2330
+ """
2331
+ Stake: InitializeChecked instruction
2332
+ """
2333
+ type StakeInitializeCheckedInstructionDataAuthorized {
2334
+ staker: Account
2335
+ withdrawer: Account
2336
+ }
2337
+ type StakeInitializeCheckedInstruction implements TransactionInstruction {
2338
+ programId: Address
2339
+ authorized: StakeInitializeCheckedInstructionDataAuthorized
2340
+ lockup: Lockup
2341
+ rentSysvar: Address
2342
+ stakeAccount: Account
2343
+ }
2344
+
2345
+ """
2346
+ Stake: AuthorizeChecked instruction
2347
+ """
2348
+ type StakeAuthorizeCheckedInstruction implements TransactionInstruction {
2349
+ programId: Address
2350
+ authority: Account
2351
+ authorityType: String
2352
+ clockSysvar: Address
2353
+ custodian: Account
2354
+ newAuthority: Account
2355
+ stakeAccount: Account
2356
+ }
2357
+
2358
+ """
2359
+ Stake: AuthorizeCheckedWithSeed instruction
2360
+ """
2361
+ type StakeAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2362
+ programId: Address
2363
+ authorityBase: Account
2364
+ authorityOwner: Account
2365
+ authoritySeed: String
2366
+ authorityType: String
2367
+ clockSysvar: Address
2368
+ custodian: Account
2369
+ newAuthorized: Account
2370
+ stakeAccount: Account
2371
+ }
2372
+
2373
+ """
2374
+ Stake: SetLockupChecked instruction
2375
+ """
2376
+ type StakeSetLockupCheckedInstruction implements TransactionInstruction {
2377
+ programId: Address
2378
+ custodian: Account
2379
+ lockup: Lockup
2380
+ stakeAccount: Account
2381
+ }
2382
+
2383
+ """
2384
+ Stake: DeactivateDelinquent instruction
2385
+ """
2386
+ type StakeDeactivateDelinquentInstruction implements TransactionInstruction {
2387
+ programId: Address
2388
+ referenceVoteAccount: Account
2389
+ stakeAccount: Account
2390
+ voteAccount: Account
2391
+ }
2392
+
2393
+ """
2394
+ Stake: Redelegate instruction
2395
+ """
2396
+ type StakeRedelegateInstruction implements TransactionInstruction {
2397
+ programId: Address
2398
+ newStakeAccount: Account
2399
+ stakeAccount: Account
2400
+ stakeAuthority: Account
2401
+ stakeConfigAccount: Account
2402
+ voteAccount: Account
2403
+ }
2404
+
2405
+ """
2406
+ System: CreateAccount instruction
2407
+ """
2408
+ type CreateAccountInstruction implements TransactionInstruction {
2409
+ programId: Address
2410
+ lamports: BigInt
2411
+ newAccount: Account
2412
+ owner: Account
2413
+ source: Account
2414
+ space: BigInt
2415
+ }
2416
+
2417
+ """
2418
+ System: Assign instruction
2419
+ """
2420
+ type AssignInstruction implements TransactionInstruction {
2421
+ programId: Address
2422
+ account: Account
2423
+ owner: Account
2424
+ }
2425
+
2426
+ """
2427
+ System: Transfer instruction
2428
+ """
2429
+ type TransferInstruction implements TransactionInstruction {
2430
+ programId: Address
2431
+ destination: Account
2432
+ lamports: BigInt
2433
+ source: Account
2434
+ }
2435
+
2436
+ """
2437
+ System: CreateAccountWithSeed instruction
2438
+ """
2439
+ type CreateAccountWithSeedInstruction implements TransactionInstruction {
2440
+ programId: Address
2441
+ base: Account
2442
+ lamports: BigInt
2443
+ owner: Account
2444
+ seed: String
2445
+ space: BigInt
2446
+ }
2447
+
2448
+ """
2449
+ System: AdvanceNonceAccount instruction
2450
+ """
2451
+ type AdvanceNonceAccountInstruction implements TransactionInstruction {
2452
+ programId: Address
2453
+ nonceAccount: Account
2454
+ nonceAuthority: Account
2455
+ recentBlockhashesSysvar: Address
2456
+ }
2457
+
2458
+ """
2459
+ System: WithdrawNonceAccount instruction
2460
+ """
2461
+ type WithdrawNonceAccountInstruction implements TransactionInstruction {
2462
+ programId: Address
2463
+ destination: Account
2464
+ lamports: BigInt
2465
+ nonceAccount: Account
2466
+ nonceAuthority: Account
2467
+ recentBlockhashesSysvar: Address
2468
+ rentSysvar: Address
2469
+ }
2470
+
2471
+ """
2472
+ System: InitializeNonceAccount instruction
2473
+ """
2474
+ type InitializeNonceAccountInstruction implements TransactionInstruction {
2475
+ programId: Address
2476
+ nonceAccount: Account
2477
+ nonceAuthority: Account
2478
+ recentBlockhashesSysvar: Address
2479
+ rentSysvar: Address
2480
+ }
2481
+
2482
+ """
2483
+ System: AuthorizeNonceAccount instruction
2484
+ """
2485
+ type AuthorizeNonceAccountInstruction implements TransactionInstruction {
2486
+ programId: Address
2487
+ newAuthorized: Account
2488
+ nonceAccount: Account
2489
+ nonceAuthority: Account
2490
+ }
2491
+
2492
+ """
2493
+ System: UpgradeNonceAccount instruction
2494
+ """
2495
+ type UpgradeNonceAccountInstruction implements TransactionInstruction {
2496
+ programId: Address
2497
+ nonceAccount: Account
2498
+ nonceAuthority: Account
2499
+ }
2500
+
2501
+ """
2502
+ System: Allocate instruction
2503
+ """
2504
+ type AllocateInstruction implements TransactionInstruction {
2505
+ programId: Address
2506
+ account: Account
2507
+ space: BigInt
2508
+ }
2509
+
2510
+ """
2511
+ System: AllocateWithSeed instruction
2512
+ """
2513
+ type AllocateWithSeedInstruction implements TransactionInstruction {
2514
+ programId: Address
2515
+ account: Account
2516
+ base: Address
2517
+ owner: Account
2518
+ seed: String
2519
+ space: BigInt
2520
+ }
2521
+
2522
+ """
2523
+ System: AssignWithSeed instruction
2524
+ """
2525
+ type AssignWithSeedInstruction implements TransactionInstruction {
2526
+ programId: Address
2527
+ account: Account
2528
+ base: Address
2529
+ owner: Account
2530
+ seed: String
2531
+ }
2532
+
2533
+ """
2534
+ System: TransferWithSeed instruction
2535
+ """
2536
+ type TransferWithSeedInstruction implements TransactionInstruction {
2537
+ programId: Address
2538
+ destination: Account
2539
+ lamports: BigInt
2540
+ source: Account
2541
+ sourceBase: Address
2542
+ sourceOwner: Account
2543
+ sourceSeed: String
2544
+ }
2545
+
2546
+ """
2547
+ Vote: InitializeAccount instruction
2548
+ """
2549
+ type VoteInitializeAccountInstruction implements TransactionInstruction {
2550
+ programId: Address
2551
+ authorizedVoter: Account
2552
+ authorizedWithdrawer: Account
2553
+ clockSysvar: Address
2554
+ commission: BigInt # FIXME:*
2555
+ node: Account
2556
+ rentSysvar: Address
2557
+ voteAccount: Account
2558
+ }
2559
+
2560
+ """
2561
+ Vote: Authorize instruction
2562
+ """
2563
+ type VoteAuthorizeInstruction implements TransactionInstruction {
2564
+ programId: Address
2565
+ authority: Account
2566
+ authorityType: String
2567
+ clockSysvar: Address
2568
+ newAuthority: Account
2569
+ voteAccount: Account
2570
+ }
2571
+
2572
+ """
2573
+ Vote: AuthorizeWithSeed instruction
2574
+ """
2575
+ type VoteAuthorizeWithSeedInstruction implements TransactionInstruction {
2576
+ programId: Address
2577
+ authorityBaseKey: String
2578
+ authorityOwner: Account
2579
+ authoritySeed: String
2580
+ authorityType: String
2581
+ clockSysvar: Address
2582
+ newAuthority: Account
2583
+ voteAccount: Account
2584
+ }
2585
+
2586
+ """
2587
+ Vote: AuthorizeCheckedWithSeed instruction
2588
+ """
2589
+ type VoteAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
2590
+ programId: Address
2591
+ authorityBaseKey: String
2592
+ authorityOwner: Account
2593
+ authoritySeed: String
2594
+ authorityType: String
2595
+ clockSysvar: Address
2596
+ newAuthority: Account
2597
+ voteAccount: Account
2598
+ }
2599
+
2600
+ type Vote {
2601
+ hash: String
2602
+ slots: [BigInt]
2603
+ timestamp: BigInt
2604
+ }
2605
+
2606
+ """
2607
+ Vote: Vote instruction
2608
+ """
2609
+ type VoteVoteInstruction implements TransactionInstruction {
2610
+ programId: Address
2611
+ clockSysvar: Address
2612
+ slotHashesSysvar: Address
2613
+ vote: Vote
2614
+ voteAccount: Account
2615
+ voteAuthority: Account
2616
+ }
2617
+
2618
+ type VoteStateUpdateLockout {
2619
+ confirmationCount: BigInt # FIXME:*
2620
+ slot: BigInt
2621
+ }
2622
+ type VoteStateUpdate {
2623
+ hash: String
2624
+ lockouts: [VoteStateUpdateLockout]
2625
+ root: BigInt
2626
+ timestamp: BigInt
2627
+ }
2628
+
2629
+ """
2630
+ Vote: UpdateVoteState instruction
2631
+ """
2632
+ type VoteUpdateVoteStateInstruction implements TransactionInstruction {
2633
+ programId: Address
2634
+ hash: String
2635
+ voteAccount: Account
2636
+ voteAuthority: Account
2637
+ voteStateUpdate: VoteStateUpdate
2638
+ }
2639
+
2640
+ """
2641
+ Vote: UpdateVoteStateSwitch instruction
2642
+ """
2643
+ type VoteUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2644
+ programId: Address
2645
+ hash: String
2646
+ voteAccount: Account
2647
+ voteAuthority: Account
2648
+ voteStateUpdate: VoteStateUpdate
2649
+ }
2650
+
2651
+ """
2652
+ Vote: CompactUpdateVoteState instruction
2653
+ """
2654
+ type VoteCompactUpdateVoteStateInstruction implements TransactionInstruction {
2655
+ programId: Address
2656
+ hash: String
2657
+ voteAccount: Account
2658
+ voteAuthority: Account
2659
+ voteStateUpdate: VoteStateUpdate
2660
+ }
2661
+
2662
+ """
2663
+ Vote: CompactUpdateVoteStateSwitch instruction
2664
+ """
2665
+ type VoteCompactUpdateVoteStateSwitchInstruction implements TransactionInstruction {
2666
+ programId: Address
2667
+ hash: String
2668
+ voteAccount: Account
2669
+ voteAuthority: Account
2670
+ voteStateUpdate: VoteStateUpdate
2671
+ }
2672
+
2673
+ """
2674
+ Vote: Withdraw instruction
2675
+ """
2676
+ type VoteWithdrawInstruction implements TransactionInstruction {
2677
+ programId: Address
2678
+ destination: Account
2679
+ lamports: BigInt
2680
+ voteAccount: Account
2681
+ withdrawAuthority: Account
2682
+ }
2683
+
2684
+ """
2685
+ Vote: UpdateValidatorIdentity instruction
2686
+ """
2687
+ type VoteUpdateValidatorIdentityInstruction implements TransactionInstruction {
2688
+ programId: Address
2689
+ newValidatorIdentity: Account
2690
+ voteAccount: Account
2691
+ withdrawAuthority: Account
2692
+ }
2693
+
2694
+ """
2695
+ Vote: UpdateCommission instruction
2696
+ """
2697
+ type VoteUpdateCommissionInstruction implements TransactionInstruction {
2698
+ programId: Address
2699
+ commission: BigInt # FIXME:*
2700
+ voteAccount: Account
2701
+ withdrawAuthority: Account
2702
+ }
2703
+
2704
+ """
2705
+ Vote: VoteSwitch instruction
2706
+ """
2707
+ type VoteVoteSwitchInstruction implements TransactionInstruction {
2708
+ programId: Address
2709
+ clockSysvar: Address
2710
+ hash: String
2711
+ slotHashesSysvar: Address
2712
+ vote: Vote
2713
+ voteAccount: Account
2714
+ voteAuthority: Account
2715
+ }
2716
+
2717
+ """
2718
+ Vote: AuthorizeChecked instruction
2719
+ """
2720
+ type VoteAuthorizeCheckedInstruction implements TransactionInstruction {
2721
+ programId: Address
2722
+ authority: Account
2723
+ authorityType: String
2724
+ clockSysvar: Address
2725
+ newAuthority: Account
2726
+ voteAccount: Account
2727
+ }
2728
+ `
2729
+ );
2730
+
2731
+ // src/schema/root.ts
2732
+ var rootTypeDefs = (
2733
+ /* GraphQL */
2734
+ `
2735
+ type Query {
2736
+ account(
2737
+ address: String!
2738
+ commitment: Commitment
2739
+ dataSlice: DataSlice
2740
+ encoding: AccountEncoding
2741
+ minContextSlot: BigInt
2742
+ ): Account
2743
+ block(
2744
+ slot: BigInt!
2745
+ commitment: Commitment
2746
+ encoding: TransactionEncoding
2747
+ transactionDetails: BlockTransactionDetails
2748
+ ): Block
2749
+ programAccounts(
2750
+ programAddress: String!
2751
+ commitment: Commitment
2752
+ dataSlice: DataSlice
2753
+ encoding: AccountEncoding
2754
+ filters: [ProgramAccountsFilter]
2755
+ minContextSlot: BigInt
2756
+ ): [Account]
2757
+ transaction(signature: String!, commitment: Commitment, encoding: TransactionEncoding): Transaction
2758
+ }
2759
+
2760
+ schema {
2761
+ query: Query
2762
+ }
2763
+ `
2764
+ );
2765
+
2766
+ // src/schema/transaction.ts
2767
+ var transactionTypeDefs = (
2768
+ /* GraphQL */
2769
+ `
2770
+ type TransactionStatusOk {
2771
+ Ok: String
2772
+ }
2773
+ type TransactionStatusErr {
2774
+ Err: String
2775
+ }
2776
+ union TransactionStatus = TransactionStatusOk | TransactionStatusErr
2777
+
2778
+ type TransactionLoadedAddresses {
2779
+ readonly: [String]
2780
+ writable: [String]
2781
+ }
2782
+
2783
+ type TransactionInnerInstruction {
2784
+ index: Int
2785
+ instructions: [TransactionInstruction]
2786
+ }
2787
+
2788
+ type TransactionMeta {
2789
+ computeUnitsConsumed: BigInt
2790
+ err: String
2791
+ fee: BigInt
2792
+ innerInstructions: [TransactionInnerInstruction]
2793
+ loadedAddresses: TransactionLoadedAddresses
2794
+ logMessages: [String]
2795
+ postBalances: [BigInt]
2796
+ postTokenBalances: [TokenBalance]
2797
+ preBalances: [BigInt]
2798
+ preTokenBalances: [TokenBalance]
2799
+ returnData: ReturnData
2800
+ rewards: [Reward]
2801
+ status: TransactionStatus
2802
+ }
2803
+
2804
+ type TransactionMessageAccountKey {
2805
+ pubkey: Address
2806
+ signer: Boolean
2807
+ source: String
2808
+ writable: Boolean
2809
+ }
2810
+
2811
+ type TransactionMessageAddressTableLookup {
2812
+ accountKey: Address
2813
+ readableIndexes: [Int]
2814
+ writableIndexes: [Int]
2815
+ }
2816
+
2817
+ type TransactionMessageHeader {
2818
+ numReadonlySignedAccounts: Int
2819
+ numReadonlyUnsignedAccounts: Int
2820
+ numRequiredSignatures: Int
2821
+ }
2822
+
2823
+ type TransactionMessage {
2824
+ accountKeys: [TransactionMessageAccountKey]
2825
+ addressTableLookups: [TransactionMessageAddressTableLookup]
2826
+ header: TransactionMessageHeader
2827
+ instructions: [TransactionInstruction]
2828
+ recentBlockhash: String
2829
+ }
2830
+
2831
+ """
2832
+ Transaction interface
2833
+ """
2834
+ interface Transaction {
2835
+ blockTime: BigInt
2836
+ meta: TransactionMeta
2837
+ slot: BigInt
2838
+ version: String
2839
+ }
2840
+
2841
+ """
2842
+ A transaction with base58 encoded data
2843
+ """
2844
+ type TransactionBase58 implements Transaction {
2845
+ blockTime: BigInt
2846
+ data: Base58EncodedBytes
2847
+ meta: TransactionMeta
2848
+ slot: BigInt
2849
+ version: String
2850
+ }
2851
+
2852
+ """
2853
+ A transaction with base64 encoded data
2854
+ """
2855
+ type TransactionBase64 implements Transaction {
2856
+ blockTime: BigInt
2857
+ data: Base64EncodedBytes
2858
+ meta: TransactionMeta
2859
+ slot: BigInt
2860
+ version: String
2861
+ }
2862
+
2863
+ """
2864
+ A transaction with JSON encoded data
2865
+ """
2866
+ type TransactionDataParsed {
2867
+ message: TransactionMessage
2868
+ signatures: [String]
2869
+ }
2870
+ type TransactionParsed implements Transaction {
2871
+ blockTime: BigInt
2872
+ data: TransactionDataParsed
2873
+ meta: TransactionMeta
2874
+ slot: BigInt
2875
+ version: String
2876
+ }
2877
+ `
2878
+ );
2879
+
2880
+ // src/schema/index.ts
2881
+ function createSolanaGraphQLTypeDefs() {
2882
+ return [
2883
+ accountTypeDefs,
2884
+ blockTypeDefs,
2885
+ commonTypeDefs,
2886
+ inputTypeDefs,
2887
+ instructionTypeDefs,
2888
+ rootTypeDefs,
2889
+ scalarTypeDefs,
2890
+ transactionTypeDefs
2891
+ ];
2892
+ }
2893
+
2894
+ // src/index.ts
2165
2895
  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()]
2896
+ const schema = makeExecutableSchema({
2897
+ resolvers: createSolanaGraphQLResolvers(),
2898
+ typeDefs: createSolanaGraphQLTypeDefs()
2178
2899
  });
2179
2900
  return {
2180
- context,
2181
2901
  async query(source, variableValues) {
2182
- const result = await graphql({
2183
- contextValue: this.context,
2184
- schema: this.schema,
2902
+ const contextValue = createSolanaGraphQLContext(rpc);
2903
+ return graphql({
2904
+ contextValue,
2905
+ schema,
2185
2906
  source,
2186
2907
  variableValues
2187
2908
  });
2188
- this.context.cache.flush();
2189
- return result;
2190
- },
2191
- schema
2909
+ }
2192
2910
  };
2193
2911
  }
2194
2912