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

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