@solana/rpc-graphql 2.0.0-experimental.fd11bd1 → 2.0.0-experimental.fd64233

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