@solana/rpc-graphql 2.0.0-experimental.f025b33 → 2.0.0-experimental.f054d90
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.
- package/dist/index.browser.cjs +1215 -755
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1216 -756
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +1216 -756
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +1215 -755
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +1216 -756
- package/dist/index.node.js.map +1 -1
- package/dist/types/context.d.ts +15 -3
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -5
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loaders/account.d.ts +12 -3
- package/dist/types/loaders/account.d.ts.map +1 -1
- package/dist/types/loaders/block.d.ts +1 -2
- package/dist/types/loaders/block.d.ts.map +1 -1
- package/dist/types/loaders/coalescer.d.ts +55 -0
- package/dist/types/loaders/coalescer.d.ts.map +1 -0
- package/dist/types/loaders/index.d.ts +1 -1
- package/dist/types/loaders/index.d.ts.map +1 -1
- package/dist/types/loaders/loader.d.ts +33 -14
- package/dist/types/loaders/loader.d.ts.map +1 -1
- package/dist/types/loaders/program-accounts.d.ts +6 -3
- package/dist/types/loaders/program-accounts.d.ts.map +1 -1
- package/dist/types/loaders/transaction.d.ts +1 -2
- package/dist/types/loaders/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/account.d.ts +160 -42
- package/dist/types/resolvers/account.d.ts.map +1 -1
- package/dist/types/resolvers/block.d.ts +95 -11
- package/dist/types/resolvers/block.d.ts.map +1 -1
- package/dist/types/resolvers/index.d.ts.map +1 -1
- package/dist/types/resolvers/instruction.d.ts +1531 -259
- package/dist/types/resolvers/instruction.d.ts.map +1 -1
- package/dist/types/resolvers/program-accounts.d.ts +12 -3
- package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
- package/dist/types/resolvers/resolve-info/account.d.ts +15 -0
- package/dist/types/resolvers/resolve-info/account.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
- package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/index.d.ts +6 -0
- package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/program-accounts.d.ts +20 -0
- package/dist/types/resolvers/resolve-info/program-accounts.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/transaction.d.ts +15 -0
- package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/visitor.d.ts +18 -0
- package/dist/types/resolvers/resolve-info/visitor.d.ts.map +1 -0
- package/dist/types/resolvers/transaction.d.ts +32 -9
- package/dist/types/resolvers/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/types.d.ts +77 -9
- package/dist/types/resolvers/types.d.ts.map +1 -1
- package/dist/types/schema/account.d.ts +1 -1
- package/dist/types/schema/account.d.ts.map +1 -1
- package/dist/types/schema/block.d.ts +1 -1
- package/dist/types/schema/block.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/instruction.d.ts +1 -1
- package/dist/types/schema/root.d.ts +1 -1
- package/dist/types/schema/root.d.ts.map +1 -1
- package/dist/types/schema/transaction.d.ts +1 -1
- package/dist/types/schema/transaction.d.ts.map +1 -1
- package/dist/types/schema/types.d.ts +2 -0
- package/dist/types/schema/types.d.ts.map +1 -0
- package/package.json +12 -39
- package/dist/types/resolvers/resolve-info.d.ts +0 -3
- package/dist/types/resolvers/resolve-info.d.ts.map +0 -1
- package/dist/types/resolvers/scalars.d.ts +0 -44
- package/dist/types/resolvers/scalars.d.ts.map +0 -1
- package/dist/types/schema/common/inputs.d.ts +0 -2
- package/dist/types/schema/common/inputs.d.ts.map +0 -1
- package/dist/types/schema/common/scalars.d.ts +0 -2
- package/dist/types/schema/common/scalars.d.ts.map +0 -1
- package/dist/types/schema/common/types.d.ts +0 -2
- package/dist/types/schema/common/types.d.ts.map +0 -1
package/dist/index.browser.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { makeExecutableSchema } from '@graphql-tools/schema';
|
|
2
|
-
import { graphql, Kind } from 'graphql';
|
|
2
|
+
import { graphql, Kind, visit, BREAK, isInterfaceType } from 'graphql';
|
|
3
|
+
import { getBase64Codec, getBase58Codec } from '@solana/codecs-strings';
|
|
3
4
|
import DataLoader from 'dataloader';
|
|
4
5
|
import stringify from 'json-stable-stringify';
|
|
5
6
|
|
|
@@ -12,291 +13,770 @@ function replacer(_, value) {
|
|
|
12
13
|
}
|
|
13
14
|
var cacheKeyFn = (obj) => stringify(obj, { replacer });
|
|
14
15
|
|
|
16
|
+
// src/loaders/coalescer.ts
|
|
17
|
+
var hashOmit = (args, omit) => {
|
|
18
|
+
const argsObj = {};
|
|
19
|
+
for (const [key, value] of Object.entries(args)) {
|
|
20
|
+
if (!omit.includes(key)) {
|
|
21
|
+
argsObj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return cacheKeyFn(argsObj);
|
|
25
|
+
};
|
|
26
|
+
function buildCoalescedFetchesByArgsHash(toFetchMap, orphanConfig) {
|
|
27
|
+
const fetchesByArgsHash = {};
|
|
28
|
+
const orphanedFetches = {};
|
|
29
|
+
Object.entries(toFetchMap).forEach(([signature, toFetch]) => {
|
|
30
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
31
|
+
if (orphanConfig.criteria(args)) {
|
|
32
|
+
const toFetch2 = orphanedFetches[signature] ||= [];
|
|
33
|
+
toFetch2.push({ args, promiseCallback });
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const argsHash = hashOmit(args, []);
|
|
37
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
38
|
+
args,
|
|
39
|
+
fetches: {}
|
|
40
|
+
};
|
|
41
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
42
|
+
callbacks: []
|
|
43
|
+
};
|
|
44
|
+
promiseCallbacksForSignature.push(promiseCallback);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
Object.entries(orphanedFetches).forEach(([signature, toFetch]) => {
|
|
48
|
+
toFetch.forEach(({ args: orphanArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
49
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
50
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
51
|
+
if (hashOmit(orphanArgs, orphanConfig.hashOmit) === hashOmit(args2, orphanConfig.hashOmit)) {
|
|
52
|
+
const { callbacks: promiseCallbacksForSignature2 } = fetches[signature] ||= {
|
|
53
|
+
callbacks: []
|
|
54
|
+
};
|
|
55
|
+
promiseCallbacksForSignature2.push(orphanPromiseCallback);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const args = orphanConfig.defaults(orphanArgs);
|
|
61
|
+
const argsHash = hashOmit(args, []);
|
|
62
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
63
|
+
args,
|
|
64
|
+
fetches: {}
|
|
65
|
+
};
|
|
66
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
67
|
+
callbacks: []
|
|
68
|
+
};
|
|
69
|
+
promiseCallbacksForSignature.push(orphanPromiseCallback);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
return fetchesByArgsHash;
|
|
73
|
+
}
|
|
74
|
+
function buildCoalescedFetchesByArgsHashWithDataSlice(toFetchMap, maxDataSliceByteRange) {
|
|
75
|
+
const fetchesByArgsHash = {};
|
|
76
|
+
const orphanedFetches = {};
|
|
77
|
+
Object.entries(toFetchMap).forEach(([address, toFetch]) => {
|
|
78
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
79
|
+
if (!args.encoding) {
|
|
80
|
+
const toFetch2 = orphanedFetches[address] ||= [];
|
|
81
|
+
toFetch2.push({ args, promiseCallback });
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (args.encoding != "base64+zstd" && args.dataSlice) {
|
|
85
|
+
const r = args.dataSlice;
|
|
86
|
+
for (const { fetches: fetchAddresses, args: fetchArgs } of Object.values(fetchesByArgsHash)) {
|
|
87
|
+
const addCallbackWithDataSlice = (updateDataSlice) => {
|
|
88
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetchAddresses[address] ||= {
|
|
89
|
+
callbacks: []
|
|
90
|
+
};
|
|
91
|
+
promiseCallbacksForAddress2.push({
|
|
92
|
+
callback: promiseCallback,
|
|
93
|
+
dataSlice: args.dataSlice ?? null
|
|
94
|
+
});
|
|
95
|
+
if (fetchArgs.dataSlice && updateDataSlice) {
|
|
96
|
+
fetchArgs.dataSlice = updateDataSlice;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
if (hashOmit(args, ["dataSlice"]) === hashOmit(fetchArgs, ["dataSlice"])) {
|
|
100
|
+
if (fetchArgs.dataSlice) {
|
|
101
|
+
const g = fetchArgs.dataSlice;
|
|
102
|
+
if (r.offset <= g.offset && g.offset - r.offset + r.length <= maxDataSliceByteRange) {
|
|
103
|
+
const length = Math.max(r.length, g.offset + g.length - r.offset);
|
|
104
|
+
const offset = r.offset;
|
|
105
|
+
addCallbackWithDataSlice({ length, offset });
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (r.offset >= g.offset && r.offset - g.offset + g.length <= maxDataSliceByteRange) {
|
|
109
|
+
const length = Math.max(g.length, r.offset + r.length - g.offset);
|
|
110
|
+
const offset = g.offset;
|
|
111
|
+
addCallbackWithDataSlice({ length, offset });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
const { length, offset } = r;
|
|
116
|
+
addCallbackWithDataSlice({ length, offset });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const argsHash = hashOmit(args, []);
|
|
123
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
124
|
+
args,
|
|
125
|
+
fetches: {}
|
|
126
|
+
};
|
|
127
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
128
|
+
callbacks: []
|
|
129
|
+
};
|
|
130
|
+
promiseCallbacksForAddress.push({ callback: promiseCallback, dataSlice: args.dataSlice ?? null });
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
Object.entries(orphanedFetches).forEach(([address, toFetch]) => {
|
|
134
|
+
toFetch.forEach(({ args: orphanedArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
135
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
136
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
137
|
+
if (hashOmit(orphanedArgs, ["encoding", "dataSlice"]) === hashOmit(args2, ["encoding", "dataSlice"])) {
|
|
138
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetches[address] ||= {
|
|
139
|
+
callbacks: []
|
|
140
|
+
};
|
|
141
|
+
promiseCallbacksForAddress2.push({ callback: orphanPromiseCallback });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const args = { ...orphanedArgs, encoding: "base64" };
|
|
147
|
+
const argsHash = hashOmit(args, []);
|
|
148
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
149
|
+
args,
|
|
150
|
+
fetches: {}
|
|
151
|
+
};
|
|
152
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
153
|
+
callbacks: []
|
|
154
|
+
};
|
|
155
|
+
promiseCallbacksForAddress.push({ callback: orphanPromiseCallback });
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
return fetchesByArgsHash;
|
|
159
|
+
}
|
|
160
|
+
|
|
15
161
|
// src/loaders/account.ts
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
encoding
|
|
28
|
-
|
|
29
|
-
|
|
162
|
+
function getCodec(encoding) {
|
|
163
|
+
switch (encoding) {
|
|
164
|
+
case "base58":
|
|
165
|
+
return getBase58Codec();
|
|
166
|
+
default:
|
|
167
|
+
return getBase64Codec();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function sliceData(account, dataSlice, masterDataSlice) {
|
|
171
|
+
if (dataSlice) {
|
|
172
|
+
const masterOffset = masterDataSlice ? masterDataSlice.offset : 0;
|
|
173
|
+
const slicedData = (data, encoding) => {
|
|
174
|
+
if (encoding === "base64+zstd") {
|
|
175
|
+
return data;
|
|
176
|
+
}
|
|
177
|
+
const { offset, length } = dataSlice;
|
|
178
|
+
const trueOffset = offset - masterOffset;
|
|
179
|
+
const codec = getCodec(encoding);
|
|
180
|
+
return codec.decode(codec.encode(data).slice(trueOffset, trueOffset + length));
|
|
181
|
+
};
|
|
182
|
+
if (Array.isArray(account.data)) {
|
|
183
|
+
const [data, encoding] = account.data;
|
|
184
|
+
return {
|
|
185
|
+
...account,
|
|
186
|
+
data: [slicedData(data, encoding), encoding]
|
|
187
|
+
};
|
|
188
|
+
} else if (typeof account.data === "string") {
|
|
189
|
+
const data = account.data;
|
|
190
|
+
return {
|
|
191
|
+
...account,
|
|
192
|
+
data: slicedData(data, "base58")
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return account;
|
|
30
197
|
}
|
|
31
198
|
async function loadAccount(rpc, { address, ...config }) {
|
|
32
199
|
return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
|
|
33
200
|
}
|
|
34
|
-
function
|
|
201
|
+
async function loadMultipleAccounts(rpc, { addresses, ...config }) {
|
|
202
|
+
return await rpc.getMultipleAccounts(addresses, config).send().then((res) => res.value);
|
|
203
|
+
}
|
|
204
|
+
function createAccountBatchLoadFn(rpc, config) {
|
|
35
205
|
const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
|
|
206
|
+
const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc);
|
|
36
207
|
return async (accountQueryArgs) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
208
|
+
const accountsToFetch = {};
|
|
209
|
+
try {
|
|
210
|
+
return Promise.all(
|
|
211
|
+
accountQueryArgs.map(
|
|
212
|
+
({ address, ...args }) => new Promise((resolve, reject) => {
|
|
213
|
+
const accountRecords = accountsToFetch[address] ||= [];
|
|
214
|
+
if (!args.commitment) {
|
|
215
|
+
args.commitment = "confirmed";
|
|
216
|
+
}
|
|
217
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
218
|
+
})
|
|
219
|
+
)
|
|
220
|
+
);
|
|
221
|
+
} finally {
|
|
222
|
+
const { maxDataSliceByteRange, maxMultipleAccountsBatchSize } = config;
|
|
223
|
+
const accountFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
224
|
+
accountsToFetch,
|
|
225
|
+
maxDataSliceByteRange
|
|
226
|
+
);
|
|
227
|
+
Object.values(accountFetchesByArgsHash).map(({ args, fetches: addressCallbacks }) => {
|
|
228
|
+
const addresses = Object.keys(addressCallbacks);
|
|
229
|
+
if (addresses.length === 1) {
|
|
230
|
+
const address = addresses[0];
|
|
231
|
+
return Array.from({ length: 1 }, async () => {
|
|
232
|
+
try {
|
|
233
|
+
const result = await resolveAccountUsingRpc({ address, ...args });
|
|
234
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
235
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
236
|
+
});
|
|
237
|
+
} catch (e) {
|
|
238
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
239
|
+
callback.reject(e);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
} else {
|
|
244
|
+
return Array.from(
|
|
245
|
+
{ length: Math.ceil(addresses.length / maxMultipleAccountsBatchSize) },
|
|
246
|
+
async (_, ii) => {
|
|
247
|
+
const startIndex = ii * maxMultipleAccountsBatchSize;
|
|
248
|
+
const endIndex = startIndex + maxMultipleAccountsBatchSize;
|
|
249
|
+
const chunk = addresses.slice(startIndex, endIndex);
|
|
250
|
+
try {
|
|
251
|
+
const results = await resolveMultipleAccountsUsingRpc({
|
|
252
|
+
addresses: chunk,
|
|
253
|
+
...args
|
|
254
|
+
});
|
|
255
|
+
chunk.forEach((address, ii2) => {
|
|
256
|
+
const result = results[ii2];
|
|
257
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
258
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
} catch (e) {
|
|
262
|
+
chunk.forEach((address) => {
|
|
263
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
264
|
+
callback.reject(e);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
46
273
|
};
|
|
47
274
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
commitment,
|
|
51
|
-
encoding = "jsonParsed",
|
|
52
|
-
maxSupportedTransactionVersion = 0,
|
|
53
|
-
rewards,
|
|
54
|
-
transactionDetails = "full"
|
|
55
|
-
}) {
|
|
275
|
+
function createAccountLoader(rpc, config) {
|
|
276
|
+
const loader = new DataLoader(createAccountBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
56
277
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
maxSupportedTransactionVersion,
|
|
60
|
-
rewards,
|
|
61
|
-
slot,
|
|
62
|
-
transactionDetails
|
|
278
|
+
load: async (args) => loader.load(args),
|
|
279
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
63
280
|
};
|
|
64
281
|
}
|
|
65
282
|
async function loadBlock(rpc, { slot, ...config }) {
|
|
66
283
|
return await rpc.getBlock(
|
|
67
284
|
slot,
|
|
68
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
285
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
69
286
|
config
|
|
70
287
|
).send();
|
|
71
288
|
}
|
|
72
289
|
function createBlockBatchLoadFn(rpc) {
|
|
73
290
|
const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
|
|
74
291
|
return async (blockQueryArgs) => {
|
|
75
|
-
|
|
292
|
+
const blocksToFetch = {};
|
|
293
|
+
try {
|
|
294
|
+
return Promise.all(blockQueryArgs.map(
|
|
295
|
+
({ slot, ...args }) => new Promise((resolve, reject) => {
|
|
296
|
+
const blockRecords = blocksToFetch[slot.toString()] ||= [];
|
|
297
|
+
if (!args.commitment) {
|
|
298
|
+
args.commitment = "confirmed";
|
|
299
|
+
}
|
|
300
|
+
blockRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
301
|
+
})
|
|
302
|
+
));
|
|
303
|
+
} finally {
|
|
304
|
+
const blockFetchesByArgsHash = buildCoalescedFetchesByArgsHash(blocksToFetch, {
|
|
305
|
+
criteria: (args) => args.encoding === void 0 && args.transactionDetails !== "signatures",
|
|
306
|
+
defaults: (args) => ({
|
|
307
|
+
...args,
|
|
308
|
+
transactionDetails: "none"
|
|
309
|
+
}),
|
|
310
|
+
hashOmit: ["encoding", "transactionDetails"]
|
|
311
|
+
});
|
|
312
|
+
Object.values(blockFetchesByArgsHash).map(({ args, fetches: blockCallbacks }) => {
|
|
313
|
+
return Object.entries(blockCallbacks).map(([slot, { callbacks }]) => {
|
|
314
|
+
return Array.from({ length: 1 }, async () => {
|
|
315
|
+
try {
|
|
316
|
+
const result = await resolveBlockUsingRpc({
|
|
317
|
+
slot: BigInt(slot),
|
|
318
|
+
...args
|
|
319
|
+
});
|
|
320
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
321
|
+
} catch (e) {
|
|
322
|
+
callbacks.forEach((c) => c.reject(e));
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
}
|
|
76
328
|
};
|
|
77
329
|
}
|
|
78
330
|
function createBlockLoader(rpc) {
|
|
79
331
|
const loader = new DataLoader(createBlockBatchLoadFn(rpc), { cacheKeyFn });
|
|
80
332
|
return {
|
|
81
|
-
load: async (args) => loader.load(
|
|
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
|
|
333
|
+
load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
|
|
334
|
+
loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
|
|
99
335
|
};
|
|
100
336
|
}
|
|
101
337
|
async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
102
338
|
return await rpc.getProgramAccounts(
|
|
103
339
|
programAddress,
|
|
104
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
340
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
105
341
|
config
|
|
106
342
|
).send();
|
|
107
343
|
}
|
|
108
|
-
function createProgramAccountsBatchLoadFn(rpc) {
|
|
344
|
+
function createProgramAccountsBatchLoadFn(rpc, config) {
|
|
109
345
|
const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
|
|
110
|
-
return async (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
346
|
+
return async (accountQueryArgs) => {
|
|
347
|
+
const programAccountsToFetch = {};
|
|
348
|
+
try {
|
|
349
|
+
return Promise.all(accountQueryArgs.map(
|
|
350
|
+
({ programAddress, ...args }) => new Promise((resolve, reject) => {
|
|
351
|
+
const accountRecords = programAccountsToFetch[programAddress] ||= [];
|
|
352
|
+
if (!args.commitment) {
|
|
353
|
+
args.commitment = "confirmed";
|
|
354
|
+
}
|
|
355
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
356
|
+
})
|
|
357
|
+
));
|
|
358
|
+
} finally {
|
|
359
|
+
const { maxDataSliceByteRange } = config;
|
|
360
|
+
const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(programAccountsToFetch, maxDataSliceByteRange);
|
|
361
|
+
Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
|
|
362
|
+
return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
|
|
363
|
+
return Array.from({ length: 1 }, async () => {
|
|
364
|
+
try {
|
|
365
|
+
const result = await resolveProgramAccountsUsingRpc({
|
|
366
|
+
programAddress,
|
|
367
|
+
...args
|
|
368
|
+
});
|
|
369
|
+
callbacks.forEach(({ callback, dataSlice }) => {
|
|
370
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
371
|
+
});
|
|
372
|
+
} catch (e) {
|
|
373
|
+
callbacks.forEach(({ callback }) => {
|
|
374
|
+
callback.reject(e);
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
}
|
|
120
381
|
};
|
|
121
382
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
encoding = "jsonParsed",
|
|
125
|
-
signature
|
|
126
|
-
}) {
|
|
383
|
+
function createProgramAccountsLoader(rpc, config) {
|
|
384
|
+
const loader = new DataLoader(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
127
385
|
return {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
signature
|
|
386
|
+
load: async (args) => loader.load(args),
|
|
387
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
131
388
|
};
|
|
132
389
|
}
|
|
133
390
|
async function loadTransaction(rpc, { signature, ...config }) {
|
|
134
391
|
return await rpc.getTransaction(
|
|
135
392
|
signature,
|
|
136
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
393
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
137
394
|
config
|
|
138
395
|
).send();
|
|
139
396
|
}
|
|
140
397
|
function createTransactionBatchLoadFn(rpc) {
|
|
141
398
|
const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
|
|
142
399
|
return async (transactionQueryArgs) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
400
|
+
const transactionsToFetch = {};
|
|
401
|
+
try {
|
|
402
|
+
return Promise.all(transactionQueryArgs.map(
|
|
403
|
+
({ signature, ...args }) => new Promise((resolve, reject) => {
|
|
404
|
+
const transactionRecords = transactionsToFetch[signature] ||= [];
|
|
405
|
+
if (!args.commitment) {
|
|
406
|
+
args.commitment = "confirmed";
|
|
407
|
+
}
|
|
408
|
+
transactionRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
409
|
+
})
|
|
410
|
+
));
|
|
411
|
+
} finally {
|
|
412
|
+
const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
|
|
413
|
+
criteria: (args) => args.encoding === void 0,
|
|
414
|
+
defaults: (args) => ({ ...args, encoding: "base64" }),
|
|
415
|
+
hashOmit: ["encoding"]
|
|
416
|
+
});
|
|
417
|
+
Object.values(transactionFetchesByArgsHash).map(({ args, fetches: transactionCallbacks }) => {
|
|
418
|
+
return Object.entries(transactionCallbacks).map(([signature, { callbacks }]) => {
|
|
419
|
+
return Array.from({ length: 1 }, async () => {
|
|
420
|
+
try {
|
|
421
|
+
const result = await resolveTransactionUsingRpc({
|
|
422
|
+
signature,
|
|
423
|
+
...args
|
|
424
|
+
});
|
|
425
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
426
|
+
} catch (e) {
|
|
427
|
+
callbacks.forEach((c) => c.reject(e));
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
}
|
|
146
433
|
};
|
|
147
434
|
}
|
|
148
435
|
function createTransactionLoader(rpc) {
|
|
149
436
|
const loader = new DataLoader(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
|
|
150
437
|
return {
|
|
151
|
-
load: async (args) => loader.load(
|
|
438
|
+
load: async (args) => loader.load(args),
|
|
439
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
152
440
|
};
|
|
153
441
|
}
|
|
154
442
|
|
|
155
443
|
// src/context.ts
|
|
156
|
-
function createSolanaGraphQLContext(rpc) {
|
|
444
|
+
function createSolanaGraphQLContext(rpc, config) {
|
|
157
445
|
return {
|
|
158
446
|
loaders: {
|
|
159
|
-
account: createAccountLoader(rpc),
|
|
447
|
+
account: createAccountLoader(rpc, config),
|
|
160
448
|
block: createBlockLoader(rpc),
|
|
161
|
-
programAccounts: createProgramAccountsLoader(rpc),
|
|
449
|
+
programAccounts: createProgramAccountsLoader(rpc, config),
|
|
162
450
|
transaction: createTransactionLoader(rpc)
|
|
163
451
|
}
|
|
164
452
|
};
|
|
165
453
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (
|
|
173
|
-
return
|
|
454
|
+
function injectableRootVisitor(info, rootNode, operations) {
|
|
455
|
+
const { fieldNodes } = info;
|
|
456
|
+
const root = rootNode ?? fieldNodes[0];
|
|
457
|
+
const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
|
|
458
|
+
visit(root, {
|
|
459
|
+
Field(node, key, parent, path, ancestors) {
|
|
460
|
+
if (!parentIsRoot(ancestors))
|
|
461
|
+
return;
|
|
462
|
+
return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
|
|
463
|
+
},
|
|
464
|
+
FragmentSpread(node, key, parent, path, ancestors) {
|
|
465
|
+
const fragmentDefinition = info.fragments[node.name.value];
|
|
466
|
+
return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
|
|
467
|
+
},
|
|
468
|
+
InlineFragment(node, key, parent, path, ancestors) {
|
|
469
|
+
if (!parentIsRoot(ancestors))
|
|
470
|
+
return;
|
|
471
|
+
return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
function onlyFieldsRequested(fieldNames, info, rootNode) {
|
|
476
|
+
let onlyFieldsRequested2 = true;
|
|
477
|
+
function checkFieldsWithVisitor(root) {
|
|
478
|
+
injectableRootVisitor(info, root, {
|
|
479
|
+
fieldNodeOperation(_info, node) {
|
|
480
|
+
onlyFieldsRequested2 = fieldNames.includes(node.name.value);
|
|
481
|
+
if (!onlyFieldsRequested2) {
|
|
482
|
+
return BREAK;
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
486
|
+
checkFieldsWithVisitor(fragment);
|
|
487
|
+
},
|
|
488
|
+
inlineFragmentNodeOperation(_info, node) {
|
|
489
|
+
checkFieldsWithVisitor(node);
|
|
174
490
|
}
|
|
175
|
-
return null;
|
|
176
491
|
});
|
|
177
|
-
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
492
|
}
|
|
181
|
-
|
|
493
|
+
checkFieldsWithVisitor(rootNode ?? null);
|
|
494
|
+
return onlyFieldsRequested2;
|
|
182
495
|
}
|
|
183
496
|
|
|
184
|
-
// src/resolvers/account.ts
|
|
185
|
-
function
|
|
186
|
-
|
|
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;
|
|
497
|
+
// src/resolvers/resolve-info/account.ts
|
|
498
|
+
function findArgumentNodeByName(argumentNodes, name) {
|
|
499
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
195
500
|
}
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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;
|
|
501
|
+
function parseAccountEncodingArgument(argumentNodes, variableValues) {
|
|
502
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
|
|
503
|
+
if (argumentNode) {
|
|
504
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
505
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
506
|
+
return "base58";
|
|
507
|
+
}
|
|
508
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
509
|
+
return "base64";
|
|
510
|
+
}
|
|
511
|
+
if (argumentNode.value.value === "BASE_64_ZSTD") {
|
|
512
|
+
return "base64+zstd";
|
|
513
|
+
}
|
|
234
514
|
}
|
|
235
|
-
if (
|
|
236
|
-
return
|
|
515
|
+
if (argumentNode.value.kind === "Variable") {
|
|
516
|
+
return variableValues[argumentNode.value.name.value];
|
|
237
517
|
}
|
|
238
|
-
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
518
|
+
} else {
|
|
519
|
+
return void 0;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function parseAccountDataSliceArgument(argumentNodes, variableValues) {
|
|
523
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
|
|
524
|
+
if (argumentNode) {
|
|
525
|
+
if (argumentNode.value.kind === "ObjectValue") {
|
|
526
|
+
const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
|
|
527
|
+
const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
|
|
528
|
+
const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
|
|
529
|
+
const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
|
|
530
|
+
return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
|
|
531
|
+
}
|
|
532
|
+
if (argumentNode.value.kind === "Variable") {
|
|
533
|
+
return variableValues[argumentNode.value.name.value];
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
return void 0;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function buildAccountArgSetWithVisitor(args, info) {
|
|
540
|
+
const argSet = [args];
|
|
541
|
+
function buildArgSetWithVisitor(root) {
|
|
542
|
+
injectableRootVisitor(info, root, {
|
|
543
|
+
fieldNodeOperation(info2, node) {
|
|
544
|
+
if (node.name.value !== "data") {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (node.arguments) {
|
|
548
|
+
const { variableValues } = info2;
|
|
549
|
+
const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
|
|
550
|
+
const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
|
|
551
|
+
argSet.push({ ...args, dataSlice, encoding });
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
555
|
+
buildArgSetWithVisitor(fragment);
|
|
556
|
+
},
|
|
557
|
+
inlineFragmentNodeOperation(info2, node) {
|
|
558
|
+
const { schema } = info2;
|
|
559
|
+
const accountInterface = schema.getType("Account");
|
|
560
|
+
if (isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
|
|
561
|
+
// fields outside of the `Account` interface.
|
|
562
|
+
!onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
|
|
563
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
564
|
+
}
|
|
247
565
|
}
|
|
248
|
-
|
|
249
|
-
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
buildArgSetWithVisitor(null);
|
|
569
|
+
return argSet;
|
|
570
|
+
}
|
|
571
|
+
function buildAccountLoaderArgSetFromResolveInfo(args, info) {
|
|
572
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// src/resolvers/resolve-info/transaction.ts
|
|
576
|
+
function findArgumentNodeByName2(argumentNodes, name) {
|
|
577
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
578
|
+
}
|
|
579
|
+
function parseTransactionEncodingArgument(argumentNodes, variableValues) {
|
|
580
|
+
const argumentNode = findArgumentNodeByName2(argumentNodes, "encoding");
|
|
581
|
+
if (argumentNode) {
|
|
582
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
583
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
584
|
+
return "base58";
|
|
250
585
|
}
|
|
251
|
-
if (
|
|
252
|
-
return "
|
|
586
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
587
|
+
return "base64";
|
|
253
588
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
589
|
+
}
|
|
590
|
+
if (argumentNode.value.kind === "Variable") {
|
|
591
|
+
return variableValues[argumentNode.value.name.value];
|
|
592
|
+
}
|
|
593
|
+
} else {
|
|
594
|
+
return void 0;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function buildTransactionArgSetWithVisitor(args, info) {
|
|
598
|
+
const argSet = [args];
|
|
599
|
+
function buildArgSetWithVisitor(root) {
|
|
600
|
+
injectableRootVisitor(info, root, {
|
|
601
|
+
fieldNodeOperation(info2, node) {
|
|
602
|
+
if (node.name.value === "message" || node.name.value === "meta") {
|
|
603
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
604
|
+
} else if (node.name.value === "data") {
|
|
605
|
+
if (node.arguments) {
|
|
606
|
+
const { variableValues } = info2;
|
|
607
|
+
const encoding = parseTransactionEncodingArgument(
|
|
608
|
+
node.arguments,
|
|
609
|
+
variableValues
|
|
610
|
+
);
|
|
611
|
+
argSet.push({ ...args, encoding });
|
|
612
|
+
}
|
|
257
613
|
}
|
|
258
|
-
|
|
259
|
-
|
|
614
|
+
},
|
|
615
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
616
|
+
buildArgSetWithVisitor(fragment);
|
|
617
|
+
},
|
|
618
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
buildArgSetWithVisitor(null);
|
|
624
|
+
return argSet;
|
|
625
|
+
}
|
|
626
|
+
function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
|
|
627
|
+
return buildTransactionArgSetWithVisitor(args, info);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// src/resolvers/resolve-info/block.ts
|
|
631
|
+
function buildBlockLoaderArgSetFromResolveInfo(args, info) {
|
|
632
|
+
const argSet = [args];
|
|
633
|
+
function buildArgSetWithVisitor(root) {
|
|
634
|
+
injectableRootVisitor(info, root, {
|
|
635
|
+
fieldNodeOperation(info2, node) {
|
|
636
|
+
if (node.name.value === "signatures") {
|
|
637
|
+
argSet.push({ ...args, transactionDetails: "signatures" });
|
|
638
|
+
} else if (node.name.value === "transactions") {
|
|
639
|
+
argSet.push(...buildTransactionArgSetWithVisitor({ ...args, transactionDetails: "full" }, info2));
|
|
260
640
|
}
|
|
261
|
-
|
|
262
|
-
|
|
641
|
+
},
|
|
642
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
643
|
+
buildArgSetWithVisitor(fragment);
|
|
644
|
+
},
|
|
645
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
buildArgSetWithVisitor(null);
|
|
651
|
+
return argSet;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// src/resolvers/resolve-info/program-accounts.ts
|
|
655
|
+
function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
|
|
656
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/resolvers/account.ts
|
|
660
|
+
var resolveAccountData = () => {
|
|
661
|
+
return (parent, args) => {
|
|
662
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
var resolveAccount = (fieldName) => {
|
|
666
|
+
return async (parent, args, context, info) => {
|
|
667
|
+
const address = fieldName ? parent[fieldName] : args.address;
|
|
668
|
+
if (address) {
|
|
669
|
+
if (onlyFieldsRequested(["address"], info)) {
|
|
670
|
+
return { address };
|
|
671
|
+
}
|
|
672
|
+
const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
|
|
673
|
+
const loadedAccounts = await context.loaders.account.loadMany(argsSet);
|
|
674
|
+
let result = {
|
|
675
|
+
address,
|
|
676
|
+
encodedData: {}
|
|
677
|
+
};
|
|
678
|
+
loadedAccounts.forEach((account, i) => {
|
|
679
|
+
if (account instanceof Error) {
|
|
680
|
+
console.error(account);
|
|
681
|
+
return;
|
|
263
682
|
}
|
|
264
|
-
if (account
|
|
265
|
-
return
|
|
683
|
+
if (account === null) {
|
|
684
|
+
return;
|
|
266
685
|
}
|
|
267
|
-
if (
|
|
268
|
-
|
|
686
|
+
if (!result.ownerProgram) {
|
|
687
|
+
result = {
|
|
688
|
+
...result,
|
|
689
|
+
...account,
|
|
690
|
+
ownerProgram: account.owner
|
|
691
|
+
};
|
|
269
692
|
}
|
|
270
|
-
|
|
271
|
-
|
|
693
|
+
const { data } = account;
|
|
694
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
695
|
+
if (encoding && result.encodedData) {
|
|
696
|
+
if (Array.isArray(data)) {
|
|
697
|
+
result.encodedData[cacheKeyFn({
|
|
698
|
+
dataSlice,
|
|
699
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
700
|
+
})] = data[0];
|
|
701
|
+
} else if (typeof data === "string") {
|
|
702
|
+
result.encodedData[cacheKeyFn({
|
|
703
|
+
dataSlice,
|
|
704
|
+
encoding: "base58"
|
|
705
|
+
})] = data;
|
|
706
|
+
} else if (typeof data === "object") {
|
|
707
|
+
const {
|
|
708
|
+
parsed: { info: parsedData, type: accountType },
|
|
709
|
+
program: programName,
|
|
710
|
+
programId
|
|
711
|
+
} = data;
|
|
712
|
+
result.jsonParsedConfigs = {
|
|
713
|
+
accountType,
|
|
714
|
+
programId,
|
|
715
|
+
programName
|
|
716
|
+
};
|
|
717
|
+
result = {
|
|
718
|
+
...result,
|
|
719
|
+
...parsedData
|
|
720
|
+
};
|
|
721
|
+
}
|
|
272
722
|
}
|
|
273
|
-
}
|
|
274
|
-
return
|
|
723
|
+
});
|
|
724
|
+
return result;
|
|
275
725
|
}
|
|
726
|
+
return null;
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
function resolveAccountType(accountResult) {
|
|
730
|
+
const { jsonParsedConfigs } = accountResult;
|
|
731
|
+
if (jsonParsedConfigs) {
|
|
732
|
+
if (jsonParsedConfigs.programName === "nonce") {
|
|
733
|
+
return "NonceAccount";
|
|
734
|
+
}
|
|
735
|
+
if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
|
|
736
|
+
return "MintAccount";
|
|
737
|
+
}
|
|
738
|
+
if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
|
|
739
|
+
return "TokenAccount";
|
|
740
|
+
}
|
|
741
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
742
|
+
return "StakeAccount";
|
|
743
|
+
}
|
|
744
|
+
if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
|
|
745
|
+
return "VoteAccount";
|
|
746
|
+
}
|
|
747
|
+
if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
|
|
748
|
+
return "LookupTableAccount";
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
return "GenericAccount";
|
|
752
|
+
}
|
|
753
|
+
var accountResolvers = {
|
|
754
|
+
Account: {
|
|
755
|
+
__resolveType: resolveAccountType,
|
|
756
|
+
data: resolveAccountData()
|
|
276
757
|
},
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
},
|
|
280
|
-
AccountBase64: {
|
|
281
|
-
ownerProgram: resolveAccount("ownerProgram")
|
|
282
|
-
},
|
|
283
|
-
AccountBase64Zstd: {
|
|
758
|
+
GenericAccount: {
|
|
759
|
+
data: resolveAccountData(),
|
|
284
760
|
ownerProgram: resolveAccount("ownerProgram")
|
|
285
761
|
},
|
|
286
762
|
LookupTableAccount: {
|
|
287
763
|
authority: resolveAccount("authority"),
|
|
764
|
+
data: resolveAccountData(),
|
|
288
765
|
ownerProgram: resolveAccount("ownerProgram")
|
|
289
766
|
},
|
|
290
767
|
MintAccount: {
|
|
768
|
+
data: resolveAccountData(),
|
|
291
769
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
292
770
|
mintAuthority: resolveAccount("mintAuthority"),
|
|
293
771
|
ownerProgram: resolveAccount("ownerProgram")
|
|
294
772
|
},
|
|
295
773
|
NonceAccount: {
|
|
296
774
|
authority: resolveAccount("authority"),
|
|
775
|
+
data: resolveAccountData(),
|
|
297
776
|
ownerProgram: resolveAccount("ownerProgram")
|
|
298
777
|
},
|
|
299
778
|
StakeAccount: {
|
|
779
|
+
data: resolveAccountData(),
|
|
300
780
|
ownerProgram: resolveAccount("ownerProgram")
|
|
301
781
|
},
|
|
302
782
|
StakeAccountDataMetaAuthorized: {
|
|
@@ -310,12 +790,14 @@ var accountResolvers = {
|
|
|
310
790
|
voter: resolveAccount("voter")
|
|
311
791
|
},
|
|
312
792
|
TokenAccount: {
|
|
793
|
+
data: resolveAccountData(),
|
|
313
794
|
mint: resolveAccount("mint"),
|
|
314
795
|
owner: resolveAccount("owner"),
|
|
315
796
|
ownerProgram: resolveAccount("ownerProgram")
|
|
316
797
|
},
|
|
317
798
|
VoteAccount: {
|
|
318
799
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
800
|
+
data: resolveAccountData(),
|
|
319
801
|
node: resolveAccount("nodePubkey"),
|
|
320
802
|
ownerProgram: resolveAccount("ownerProgram")
|
|
321
803
|
},
|
|
@@ -325,147 +807,207 @@ var accountResolvers = {
|
|
|
325
807
|
};
|
|
326
808
|
|
|
327
809
|
// src/resolvers/transaction.ts
|
|
328
|
-
function
|
|
329
|
-
|
|
330
|
-
if (
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
810
|
+
function mapJsonParsedInstructions(instructions) {
|
|
811
|
+
return instructions.map((instruction) => {
|
|
812
|
+
if ("parsed" in instruction) {
|
|
813
|
+
if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
|
|
814
|
+
const { parsed: memo, program: programName2, programId: programId2 } = instruction;
|
|
815
|
+
const instructionType2 = "memo";
|
|
816
|
+
const jsonParsedConfigs2 = {
|
|
817
|
+
instructionType: instructionType2,
|
|
818
|
+
programId: programId2,
|
|
819
|
+
programName: programName2
|
|
820
|
+
};
|
|
821
|
+
return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
|
|
822
|
+
}
|
|
823
|
+
const {
|
|
824
|
+
parsed: { info: data, type: instructionType },
|
|
825
|
+
program: programName,
|
|
826
|
+
programId
|
|
827
|
+
} = instruction;
|
|
828
|
+
const jsonParsedConfigs = {
|
|
829
|
+
instructionType,
|
|
830
|
+
programId,
|
|
831
|
+
programName
|
|
832
|
+
};
|
|
833
|
+
return { jsonParsedConfigs, ...data, programId };
|
|
834
|
+
} else {
|
|
835
|
+
return instruction;
|
|
836
|
+
}
|
|
352
837
|
});
|
|
353
|
-
return [transactionData, transactionMeta];
|
|
354
838
|
}
|
|
355
|
-
function
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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;
|
|
839
|
+
function mapJsonParsedInnerInstructions(innerInstructions) {
|
|
840
|
+
return innerInstructions.map(({ index, instructions }) => ({
|
|
841
|
+
index,
|
|
842
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
843
|
+
instructions: mapJsonParsedInstructions(instructions)
|
|
844
|
+
}));
|
|
371
845
|
}
|
|
846
|
+
var resolveTransactionData = () => {
|
|
847
|
+
return (parent, args) => {
|
|
848
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
849
|
+
};
|
|
850
|
+
};
|
|
372
851
|
function resolveTransaction(fieldName) {
|
|
373
852
|
return async (parent, args, context, info) => {
|
|
374
853
|
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
if (args.encoding !== "jsonParsed") {
|
|
386
|
-
const transactionJsonParsed = await context.loaders.transaction.load({
|
|
387
|
-
...args,
|
|
388
|
-
encoding: "jsonParsed",
|
|
854
|
+
if (signature) {
|
|
855
|
+
if (onlyFieldsRequested(["signature"], info)) {
|
|
856
|
+
return { signature };
|
|
857
|
+
}
|
|
858
|
+
const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
|
|
859
|
+
const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
|
|
860
|
+
let result = {
|
|
861
|
+
encodedData: {},
|
|
389
862
|
signature
|
|
863
|
+
};
|
|
864
|
+
loadedTransactions.forEach((loadedTransaction, i) => {
|
|
865
|
+
if (loadedTransaction instanceof Error) {
|
|
866
|
+
console.error(loadedTransaction);
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
if (loadedTransaction === null) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (!result.slot) {
|
|
873
|
+
result = {
|
|
874
|
+
...result,
|
|
875
|
+
...loadedTransaction
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
const { transaction: data } = loadedTransaction;
|
|
879
|
+
const { encoding } = argsSet[i];
|
|
880
|
+
if (encoding && result.encodedData) {
|
|
881
|
+
if (Array.isArray(data)) {
|
|
882
|
+
result.encodedData[cacheKeyFn({
|
|
883
|
+
encoding
|
|
884
|
+
})] = data[0];
|
|
885
|
+
} else if (typeof data === "object") {
|
|
886
|
+
const jsonParsedData = data;
|
|
887
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
888
|
+
jsonParsedData.message.instructions
|
|
889
|
+
);
|
|
890
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
891
|
+
if (loadedInnerInstructions) {
|
|
892
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
893
|
+
const jsonParsedMeta = {
|
|
894
|
+
...loadedTransaction.meta,
|
|
895
|
+
innerInstructions
|
|
896
|
+
};
|
|
897
|
+
result = {
|
|
898
|
+
...result,
|
|
899
|
+
...jsonParsedData,
|
|
900
|
+
meta: jsonParsedMeta
|
|
901
|
+
};
|
|
902
|
+
} else {
|
|
903
|
+
result = {
|
|
904
|
+
...result,
|
|
905
|
+
...jsonParsedData
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
390
910
|
});
|
|
391
|
-
|
|
392
|
-
return null;
|
|
393
|
-
}
|
|
394
|
-
transaction.meta = transactionJsonParsed.meta;
|
|
911
|
+
return result;
|
|
395
912
|
}
|
|
396
|
-
return
|
|
913
|
+
return null;
|
|
397
914
|
};
|
|
398
915
|
}
|
|
399
916
|
var transactionResolvers = {
|
|
400
917
|
Transaction: {
|
|
401
|
-
|
|
402
|
-
switch (transaction.encoding) {
|
|
403
|
-
case "base58":
|
|
404
|
-
return "TransactionBase58";
|
|
405
|
-
case "base64":
|
|
406
|
-
return "TransactionBase64";
|
|
407
|
-
default:
|
|
408
|
-
return "TransactionParsed";
|
|
409
|
-
}
|
|
410
|
-
}
|
|
918
|
+
data: resolveTransactionData()
|
|
411
919
|
}
|
|
412
920
|
};
|
|
413
921
|
|
|
414
922
|
// 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
|
-
}
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
block.encoding = encoding;
|
|
435
|
-
block.transactionDetails = transactionDetails;
|
|
436
|
-
return block;
|
|
437
|
-
}
|
|
438
923
|
var resolveBlock = (fieldName) => {
|
|
439
924
|
return async (parent, args, context, info) => {
|
|
440
925
|
const slot = fieldName ? parent[fieldName] : args.slot;
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
926
|
+
if (slot) {
|
|
927
|
+
if (onlyFieldsRequested(["slot"], info)) {
|
|
928
|
+
return { slot };
|
|
929
|
+
}
|
|
930
|
+
const argsSet = buildBlockLoaderArgSetFromResolveInfo({ ...args, slot }, info);
|
|
931
|
+
const loadedBlocks = await context.loaders.block.loadMany(argsSet);
|
|
932
|
+
let result = {
|
|
933
|
+
slot
|
|
934
|
+
};
|
|
935
|
+
loadedBlocks.forEach((loadedBlock, i) => {
|
|
936
|
+
if (loadedBlock instanceof Error) {
|
|
937
|
+
console.error(loadedBlock);
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
if (loadedBlock === null) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (!result.blockhash) {
|
|
944
|
+
result = {
|
|
945
|
+
...result,
|
|
946
|
+
...loadedBlock
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
if (!result.signatures && loadedBlock.signatures) {
|
|
950
|
+
result = {
|
|
951
|
+
...result,
|
|
952
|
+
// @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
|
|
953
|
+
signatures: loadedBlock.signatures
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
if (!result.transactionResults && loadedBlock.transactions) {
|
|
957
|
+
result.transactionResults = Array.from({ length: loadedBlock.transactions.length }, (_, i2) => ({
|
|
958
|
+
[i2]: { encodedData: {} }
|
|
959
|
+
}));
|
|
960
|
+
}
|
|
961
|
+
const { transactions } = loadedBlock;
|
|
962
|
+
const { encoding } = argsSet[i];
|
|
963
|
+
if (encoding) {
|
|
964
|
+
transactions.forEach((loadedTransaction, j) => {
|
|
965
|
+
const { transaction: data } = loadedTransaction;
|
|
966
|
+
if (result.transactionResults) {
|
|
967
|
+
const thisTransactionResult = result.transactionResults[j] ||= {
|
|
968
|
+
encodedData: {}
|
|
969
|
+
};
|
|
970
|
+
if (Array.isArray(data)) {
|
|
971
|
+
const thisEncodedData = thisTransactionResult.encodedData ||= {};
|
|
972
|
+
thisEncodedData[cacheKeyFn({
|
|
973
|
+
encoding
|
|
974
|
+
})] = data[0];
|
|
975
|
+
} else if (typeof data === "object") {
|
|
976
|
+
const jsonParsedData = data;
|
|
977
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
978
|
+
jsonParsedData.message.instructions
|
|
979
|
+
);
|
|
980
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
981
|
+
if (loadedInnerInstructions) {
|
|
982
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
983
|
+
const jsonParsedMeta = {
|
|
984
|
+
...loadedTransaction.meta,
|
|
985
|
+
innerInstructions
|
|
986
|
+
};
|
|
987
|
+
result.transactionResults[j] = {
|
|
988
|
+
...thisTransactionResult,
|
|
989
|
+
...jsonParsedData,
|
|
990
|
+
meta: jsonParsedMeta
|
|
991
|
+
};
|
|
992
|
+
} else {
|
|
993
|
+
result.transactionResults[j] = {
|
|
994
|
+
...thisTransactionResult,
|
|
995
|
+
...jsonParsedData
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
return result;
|
|
450
1004
|
}
|
|
451
|
-
|
|
452
|
-
return transformLoadedBlock({ block, encoding, transactionDetails });
|
|
1005
|
+
return null;
|
|
453
1006
|
};
|
|
454
1007
|
};
|
|
455
1008
|
var blockResolvers = {
|
|
456
1009
|
Block: {
|
|
457
|
-
|
|
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
|
-
}
|
|
1010
|
+
transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
|
|
469
1011
|
}
|
|
470
1012
|
};
|
|
471
1013
|
|
|
@@ -473,7 +1015,8 @@ var blockResolvers = {
|
|
|
473
1015
|
var instructionResolvers = {
|
|
474
1016
|
AdvanceNonceAccountInstruction: {
|
|
475
1017
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
476
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1018
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1019
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
|
|
477
1020
|
},
|
|
478
1021
|
AllocateInstruction: {
|
|
479
1022
|
account: resolveAccount("account")
|
|
@@ -510,9 +1053,11 @@ var instructionResolvers = {
|
|
|
510
1053
|
BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
|
|
511
1054
|
authority: resolveAccount("authority"),
|
|
512
1055
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
1056
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
513
1057
|
payerAccount: resolveAccount("payerAccount"),
|
|
514
1058
|
programAccount: resolveAccount("programAccount"),
|
|
515
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
1059
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1060
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
516
1061
|
},
|
|
517
1062
|
BpfUpgradeableLoaderExtendProgramInstruction: {
|
|
518
1063
|
payerAccount: resolveAccount("payerAccount"),
|
|
@@ -536,8 +1081,10 @@ var instructionResolvers = {
|
|
|
536
1081
|
BpfUpgradeableLoaderUpgradeInstruction: {
|
|
537
1082
|
authority: resolveAccount("authority"),
|
|
538
1083
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
1084
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
539
1085
|
programAccount: resolveAccount("programAccount"),
|
|
540
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
1086
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1087
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
541
1088
|
},
|
|
542
1089
|
BpfUpgradeableLoaderWriteInstruction: {
|
|
543
1090
|
account: resolveAccount("account"),
|
|
@@ -580,7 +1127,9 @@ var instructionResolvers = {
|
|
|
580
1127
|
},
|
|
581
1128
|
InitializeNonceAccountInstruction: {
|
|
582
1129
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
583
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1130
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1131
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1132
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
584
1133
|
},
|
|
585
1134
|
Lockup: {
|
|
586
1135
|
custodian: resolveAccount("custodian")
|
|
@@ -656,7 +1205,8 @@ var instructionResolvers = {
|
|
|
656
1205
|
SplTokenInitializeAccount2Instruction: {
|
|
657
1206
|
account: resolveAccount("account"),
|
|
658
1207
|
mint: resolveAccount("mint"),
|
|
659
|
-
owner: resolveAccount("owner")
|
|
1208
|
+
owner: resolveAccount("owner"),
|
|
1209
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
660
1210
|
},
|
|
661
1211
|
SplTokenInitializeAccount3Instruction: {
|
|
662
1212
|
account: resolveAccount("account"),
|
|
@@ -666,7 +1216,8 @@ var instructionResolvers = {
|
|
|
666
1216
|
SplTokenInitializeAccountInstruction: {
|
|
667
1217
|
account: resolveAccount("account"),
|
|
668
1218
|
mint: resolveAccount("mint"),
|
|
669
|
-
owner: resolveAccount("owner")
|
|
1219
|
+
owner: resolveAccount("owner"),
|
|
1220
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
670
1221
|
},
|
|
671
1222
|
SplTokenInitializeMint2Instruction: {
|
|
672
1223
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
@@ -680,13 +1231,15 @@ var instructionResolvers = {
|
|
|
680
1231
|
SplTokenInitializeMintInstruction: {
|
|
681
1232
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
682
1233
|
mint: resolveAccount("mint"),
|
|
683
|
-
mintAuthority: resolveAccount("mintAuthority")
|
|
1234
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1235
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
684
1236
|
},
|
|
685
1237
|
SplTokenInitializeMultisig2Instruction: {
|
|
686
1238
|
multisig: resolveAccount("multisig")
|
|
687
1239
|
},
|
|
688
1240
|
SplTokenInitializeMultisigInstruction: {
|
|
689
|
-
multisig: resolveAccount("multisig")
|
|
1241
|
+
multisig: resolveAccount("multisig"),
|
|
1242
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
690
1243
|
},
|
|
691
1244
|
SplTokenMintToCheckedInstruction: {
|
|
692
1245
|
account: resolveAccount("account"),
|
|
@@ -739,6 +1292,7 @@ var instructionResolvers = {
|
|
|
739
1292
|
},
|
|
740
1293
|
StakeAuthorizeCheckedInstruction: {
|
|
741
1294
|
authority: resolveAccount("authority"),
|
|
1295
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
742
1296
|
custodian: resolveAccount("custodian"),
|
|
743
1297
|
newAuthority: resolveAccount("newAuthority"),
|
|
744
1298
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -746,12 +1300,14 @@ var instructionResolvers = {
|
|
|
746
1300
|
StakeAuthorizeCheckedWithSeedInstruction: {
|
|
747
1301
|
authorityBase: resolveAccount("authorityBase"),
|
|
748
1302
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1303
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
749
1304
|
custodian: resolveAccount("custodian"),
|
|
750
1305
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
751
1306
|
stakeAccount: resolveAccount("stakeAccount")
|
|
752
1307
|
},
|
|
753
1308
|
StakeAuthorizeInstruction: {
|
|
754
1309
|
authority: resolveAccount("authority"),
|
|
1310
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
755
1311
|
custodian: resolveAccount("custodian"),
|
|
756
1312
|
newAuthority: resolveAccount("newAuthority"),
|
|
757
1313
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -759,6 +1315,7 @@ var instructionResolvers = {
|
|
|
759
1315
|
StakeAuthorizeWithSeedInstruction: {
|
|
760
1316
|
authorityBase: resolveAccount("authorityBase"),
|
|
761
1317
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1318
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
762
1319
|
custodian: resolveAccount("custodian"),
|
|
763
1320
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
764
1321
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -769,20 +1326,28 @@ var instructionResolvers = {
|
|
|
769
1326
|
voteAccount: resolveAccount("voteAccount")
|
|
770
1327
|
},
|
|
771
1328
|
StakeDeactivateInstruction: {
|
|
1329
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
772
1330
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
773
1331
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
774
1332
|
},
|
|
775
1333
|
StakeDelegateStakeInstruction: {
|
|
1334
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
776
1335
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
777
1336
|
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
778
1337
|
stakeConfigAccount: resolveAccount("stakeConfigAccount"),
|
|
1338
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
|
|
779
1339
|
voteAccount: resolveAccount("voteAccount")
|
|
780
1340
|
},
|
|
1341
|
+
StakeInitializeCheckedInstruction: {
|
|
1342
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1343
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1344
|
+
},
|
|
781
1345
|
StakeInitializeCheckedInstructionDataAuthorized: {
|
|
782
1346
|
staker: resolveAccount("staker"),
|
|
783
1347
|
withdrawer: resolveAccount("withdrawer")
|
|
784
1348
|
},
|
|
785
1349
|
StakeInitializeInstruction: {
|
|
1350
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
786
1351
|
stakeAccount: resolveAccount("stakeAccount")
|
|
787
1352
|
},
|
|
788
1353
|
StakeInitializeInstructionDataAuthorized: {
|
|
@@ -790,9 +1355,11 @@ var instructionResolvers = {
|
|
|
790
1355
|
withdrawer: resolveAccount("withdrawer")
|
|
791
1356
|
},
|
|
792
1357
|
StakeMergeInstruction: {
|
|
1358
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
793
1359
|
destination: resolveAccount("destination"),
|
|
794
1360
|
source: resolveAccount("source"),
|
|
795
|
-
stakeAuthority: resolveAccount("stakeAuthority")
|
|
1361
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1362
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
|
|
796
1363
|
},
|
|
797
1364
|
StakeRedelegateInstruction: {
|
|
798
1365
|
newStakeAccount: resolveAccount("newStakeAccount"),
|
|
@@ -815,287 +1382,289 @@ var instructionResolvers = {
|
|
|
815
1382
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
816
1383
|
},
|
|
817
1384
|
StakeWithdrawInstruction: {
|
|
1385
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
818
1386
|
destination: resolveAccount("destination"),
|
|
819
1387
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
820
1388
|
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
821
1389
|
},
|
|
822
1390
|
TransactionInstruction: {
|
|
823
|
-
__resolveType(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1391
|
+
__resolveType(instructionResult) {
|
|
1392
|
+
const { jsonParsedConfigs } = instructionResult;
|
|
1393
|
+
if (jsonParsedConfigs) {
|
|
1394
|
+
if (jsonParsedConfigs.programName === "address-lookup-table") {
|
|
1395
|
+
if (jsonParsedConfigs.instructionType === "createLookupTable") {
|
|
827
1396
|
return "CreateLookupTableInstruction";
|
|
828
1397
|
}
|
|
829
|
-
if (
|
|
1398
|
+
if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
|
|
830
1399
|
return "FreezeLookupTableInstruction";
|
|
831
1400
|
}
|
|
832
|
-
if (
|
|
1401
|
+
if (jsonParsedConfigs.instructionType === "extendLookupTable") {
|
|
833
1402
|
return "ExtendLookupTableInstruction";
|
|
834
1403
|
}
|
|
835
|
-
if (
|
|
1404
|
+
if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
|
|
836
1405
|
return "DeactivateLookupTableInstruction";
|
|
837
1406
|
}
|
|
838
|
-
if (
|
|
1407
|
+
if (jsonParsedConfigs.instructionType === "closeLookupTable") {
|
|
839
1408
|
return "CloseLookupTableInstruction";
|
|
840
1409
|
}
|
|
841
1410
|
}
|
|
842
|
-
if (
|
|
843
|
-
if (
|
|
1411
|
+
if (jsonParsedConfigs.programName === "bpf-loader") {
|
|
1412
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
844
1413
|
return "BpfLoaderWriteInstruction";
|
|
845
1414
|
}
|
|
846
|
-
if (
|
|
1415
|
+
if (jsonParsedConfigs.instructionType === "finalize") {
|
|
847
1416
|
return "BpfLoaderFinalizeInstruction";
|
|
848
1417
|
}
|
|
849
1418
|
}
|
|
850
|
-
if (
|
|
851
|
-
if (
|
|
1419
|
+
if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
|
|
1420
|
+
if (jsonParsedConfigs.instructionType === "initializeBuffer") {
|
|
852
1421
|
return "BpfUpgradeableLoaderInitializeBufferInstruction";
|
|
853
1422
|
}
|
|
854
|
-
if (
|
|
1423
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
855
1424
|
return "BpfUpgradeableLoaderWriteInstruction";
|
|
856
1425
|
}
|
|
857
|
-
if (
|
|
1426
|
+
if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
|
|
858
1427
|
return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
|
|
859
1428
|
}
|
|
860
|
-
if (
|
|
1429
|
+
if (jsonParsedConfigs.instructionType === "upgrade") {
|
|
861
1430
|
return "BpfUpgradeableLoaderUpgradeInstruction";
|
|
862
1431
|
}
|
|
863
|
-
if (
|
|
1432
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
864
1433
|
return "BpfUpgradeableLoaderSetAuthorityInstruction";
|
|
865
1434
|
}
|
|
866
|
-
if (
|
|
1435
|
+
if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
|
|
867
1436
|
return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
|
|
868
1437
|
}
|
|
869
|
-
if (
|
|
1438
|
+
if (jsonParsedConfigs.instructionType === "close") {
|
|
870
1439
|
return "BpfUpgradeableLoaderCloseInstruction";
|
|
871
1440
|
}
|
|
872
|
-
if (
|
|
1441
|
+
if (jsonParsedConfigs.instructionType === "extendProgram") {
|
|
873
1442
|
return "BpfUpgradeableLoaderExtendProgramInstruction";
|
|
874
1443
|
}
|
|
875
1444
|
}
|
|
876
|
-
if (
|
|
877
|
-
if (
|
|
1445
|
+
if (jsonParsedConfigs.programName === "spl-associated-token-account") {
|
|
1446
|
+
if (jsonParsedConfigs.instructionType === "create") {
|
|
878
1447
|
return "SplAssociatedTokenCreateInstruction";
|
|
879
1448
|
}
|
|
880
|
-
if (
|
|
1449
|
+
if (jsonParsedConfigs.instructionType === "createIdempotent") {
|
|
881
1450
|
return "SplAssociatedTokenCreateIdempotentInstruction";
|
|
882
1451
|
}
|
|
883
|
-
if (
|
|
1452
|
+
if (jsonParsedConfigs.instructionType === "recoverNested") {
|
|
884
1453
|
return "SplAssociatedTokenRecoverNestedInstruction";
|
|
885
1454
|
}
|
|
886
1455
|
}
|
|
887
|
-
if (
|
|
1456
|
+
if (jsonParsedConfigs.programName === "spl-memo") {
|
|
888
1457
|
return "SplMemoInstruction";
|
|
889
1458
|
}
|
|
890
|
-
if (
|
|
891
|
-
if (
|
|
1459
|
+
if (jsonParsedConfigs.programName === "spl-token") {
|
|
1460
|
+
if (jsonParsedConfigs.instructionType === "initializeMint") {
|
|
892
1461
|
return "SplTokenInitializeMintInstruction";
|
|
893
1462
|
}
|
|
894
|
-
if (
|
|
1463
|
+
if (jsonParsedConfigs.instructionType === "initializeMint2") {
|
|
895
1464
|
return "SplTokenInitializeMint2Instruction";
|
|
896
1465
|
}
|
|
897
|
-
if (
|
|
1466
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount") {
|
|
898
1467
|
return "SplTokenInitializeAccountInstruction";
|
|
899
1468
|
}
|
|
900
|
-
if (
|
|
1469
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount2") {
|
|
901
1470
|
return "SplTokenInitializeAccount2Instruction";
|
|
902
1471
|
}
|
|
903
|
-
if (
|
|
1472
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount3") {
|
|
904
1473
|
return "SplTokenInitializeAccount3Instruction";
|
|
905
1474
|
}
|
|
906
|
-
if (
|
|
1475
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig") {
|
|
907
1476
|
return "SplTokenInitializeMultisigInstruction";
|
|
908
1477
|
}
|
|
909
|
-
if (
|
|
1478
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
|
|
910
1479
|
return "SplTokenInitializeMultisig2Instruction";
|
|
911
1480
|
}
|
|
912
|
-
if (
|
|
1481
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
913
1482
|
return "SplTokenTransferInstruction";
|
|
914
1483
|
}
|
|
915
|
-
if (
|
|
1484
|
+
if (jsonParsedConfigs.instructionType === "approve") {
|
|
916
1485
|
return "SplTokenApproveInstruction";
|
|
917
1486
|
}
|
|
918
|
-
if (
|
|
1487
|
+
if (jsonParsedConfigs.instructionType === "revoke") {
|
|
919
1488
|
return "SplTokenRevokeInstruction";
|
|
920
1489
|
}
|
|
921
|
-
if (
|
|
1490
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
922
1491
|
return "SplTokenSetAuthorityInstruction";
|
|
923
1492
|
}
|
|
924
|
-
if (
|
|
1493
|
+
if (jsonParsedConfigs.instructionType === "mintTo") {
|
|
925
1494
|
return "SplTokenMintToInstruction";
|
|
926
1495
|
}
|
|
927
|
-
if (
|
|
1496
|
+
if (jsonParsedConfigs.instructionType === "burn") {
|
|
928
1497
|
return "SplTokenBurnInstruction";
|
|
929
1498
|
}
|
|
930
|
-
if (
|
|
1499
|
+
if (jsonParsedConfigs.instructionType === "closeAccount") {
|
|
931
1500
|
return "SplTokenCloseAccountInstruction";
|
|
932
1501
|
}
|
|
933
|
-
if (
|
|
1502
|
+
if (jsonParsedConfigs.instructionType === "freezeAccount") {
|
|
934
1503
|
return "SplTokenFreezeAccountInstruction";
|
|
935
1504
|
}
|
|
936
|
-
if (
|
|
1505
|
+
if (jsonParsedConfigs.instructionType === "thawAccount") {
|
|
937
1506
|
return "SplTokenThawAccountInstruction";
|
|
938
1507
|
}
|
|
939
|
-
if (
|
|
1508
|
+
if (jsonParsedConfigs.instructionType === "transferChecked") {
|
|
940
1509
|
return "SplTokenTransferCheckedInstruction";
|
|
941
1510
|
}
|
|
942
|
-
if (
|
|
1511
|
+
if (jsonParsedConfigs.instructionType === "approveChecked") {
|
|
943
1512
|
return "SplTokenApproveCheckedInstruction";
|
|
944
1513
|
}
|
|
945
|
-
if (
|
|
1514
|
+
if (jsonParsedConfigs.instructionType === "mintToChecked") {
|
|
946
1515
|
return "SplTokenMintToCheckedInstruction";
|
|
947
1516
|
}
|
|
948
|
-
if (
|
|
1517
|
+
if (jsonParsedConfigs.instructionType === "burnChecked") {
|
|
949
1518
|
return "SplTokenBurnCheckedInstruction";
|
|
950
1519
|
}
|
|
951
|
-
if (
|
|
1520
|
+
if (jsonParsedConfigs.instructionType === "syncNative") {
|
|
952
1521
|
return "SplTokenSyncNativeInstruction";
|
|
953
1522
|
}
|
|
954
|
-
if (
|
|
1523
|
+
if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
|
|
955
1524
|
return "SplTokenGetAccountDataSizeInstruction";
|
|
956
1525
|
}
|
|
957
|
-
if (
|
|
1526
|
+
if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
|
|
958
1527
|
return "SplTokenInitializeImmutableOwnerInstruction";
|
|
959
1528
|
}
|
|
960
|
-
if (
|
|
1529
|
+
if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
|
|
961
1530
|
return "SplTokenAmountToUiAmountInstruction";
|
|
962
1531
|
}
|
|
963
|
-
if (
|
|
1532
|
+
if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
|
|
964
1533
|
return "SplTokenUiAmountToAmountInstruction";
|
|
965
1534
|
}
|
|
966
|
-
if (
|
|
1535
|
+
if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
|
|
967
1536
|
return "SplTokenInitializeMintCloseAuthorityInstruction";
|
|
968
1537
|
}
|
|
969
1538
|
}
|
|
970
|
-
if (
|
|
971
|
-
if (
|
|
1539
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
1540
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
972
1541
|
return "StakeInitializeInstruction";
|
|
973
1542
|
}
|
|
974
|
-
if (
|
|
1543
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
975
1544
|
return "StakeAuthorizeInstruction";
|
|
976
1545
|
}
|
|
977
|
-
if (
|
|
1546
|
+
if (jsonParsedConfigs.instructionType === "delegate") {
|
|
978
1547
|
return "StakeDelegateStakeInstruction";
|
|
979
1548
|
}
|
|
980
|
-
if (
|
|
1549
|
+
if (jsonParsedConfigs.instructionType === "split") {
|
|
981
1550
|
return "StakeSplitInstruction";
|
|
982
1551
|
}
|
|
983
|
-
if (
|
|
1552
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
984
1553
|
return "StakeWithdrawInstruction";
|
|
985
1554
|
}
|
|
986
|
-
if (
|
|
1555
|
+
if (jsonParsedConfigs.instructionType === "deactivate") {
|
|
987
1556
|
return "StakeDeactivateInstruction";
|
|
988
1557
|
}
|
|
989
|
-
if (
|
|
1558
|
+
if (jsonParsedConfigs.instructionType === "setLockup") {
|
|
990
1559
|
return "StakeSetLockupInstruction";
|
|
991
1560
|
}
|
|
992
|
-
if (
|
|
1561
|
+
if (jsonParsedConfigs.instructionType === "merge") {
|
|
993
1562
|
return "StakeMergeInstruction";
|
|
994
1563
|
}
|
|
995
|
-
if (
|
|
1564
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
996
1565
|
return "StakeAuthorizeWithSeedInstruction";
|
|
997
1566
|
}
|
|
998
|
-
if (
|
|
1567
|
+
if (jsonParsedConfigs.instructionType === "initializeChecked") {
|
|
999
1568
|
return "StakeInitializeCheckedInstruction";
|
|
1000
1569
|
}
|
|
1001
|
-
if (
|
|
1570
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1002
1571
|
return "StakeAuthorizeCheckedInstruction";
|
|
1003
1572
|
}
|
|
1004
|
-
if (
|
|
1573
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1005
1574
|
return "StakeAuthorizeCheckedWithSeedInstruction";
|
|
1006
1575
|
}
|
|
1007
|
-
if (
|
|
1576
|
+
if (jsonParsedConfigs.instructionType === "setLockupChecked") {
|
|
1008
1577
|
return "StakeSetLockupCheckedInstruction";
|
|
1009
1578
|
}
|
|
1010
|
-
if (
|
|
1579
|
+
if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
|
|
1011
1580
|
return "StakeDeactivateDelinquentInstruction";
|
|
1012
1581
|
}
|
|
1013
|
-
if (
|
|
1582
|
+
if (jsonParsedConfigs.instructionType === "redelegate") {
|
|
1014
1583
|
return "StakeRedelegateInstruction";
|
|
1015
1584
|
}
|
|
1016
1585
|
}
|
|
1017
|
-
if (
|
|
1018
|
-
if (
|
|
1586
|
+
if (jsonParsedConfigs.programName === "system") {
|
|
1587
|
+
if (jsonParsedConfigs.instructionType === "createAccount") {
|
|
1019
1588
|
return "CreateAccountInstruction";
|
|
1020
1589
|
}
|
|
1021
|
-
if (
|
|
1590
|
+
if (jsonParsedConfigs.instructionType === "assign") {
|
|
1022
1591
|
return "AssignInstruction";
|
|
1023
1592
|
}
|
|
1024
|
-
if (
|
|
1593
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
1025
1594
|
return "TransferInstruction";
|
|
1026
1595
|
}
|
|
1027
|
-
if (
|
|
1596
|
+
if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
|
|
1028
1597
|
return "CreateAccountWithSeedInstruction";
|
|
1029
1598
|
}
|
|
1030
|
-
if (
|
|
1599
|
+
if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
|
|
1031
1600
|
return "AdvanceNonceAccountInstruction";
|
|
1032
1601
|
}
|
|
1033
|
-
if (
|
|
1602
|
+
if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
|
|
1034
1603
|
return "WithdrawNonceAccountInstruction";
|
|
1035
1604
|
}
|
|
1036
|
-
if (
|
|
1605
|
+
if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
|
|
1037
1606
|
return "InitializeNonceAccountInstruction";
|
|
1038
1607
|
}
|
|
1039
|
-
if (
|
|
1608
|
+
if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
|
|
1040
1609
|
return "AuthorizeNonceAccountInstruction";
|
|
1041
1610
|
}
|
|
1042
|
-
if (
|
|
1611
|
+
if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
|
|
1043
1612
|
return "UpgradeNonceAccountInstruction";
|
|
1044
1613
|
}
|
|
1045
|
-
if (
|
|
1614
|
+
if (jsonParsedConfigs.instructionType === "allocate") {
|
|
1046
1615
|
return "AllocateInstruction";
|
|
1047
1616
|
}
|
|
1048
|
-
if (
|
|
1617
|
+
if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
|
|
1049
1618
|
return "AllocateWithSeedInstruction";
|
|
1050
1619
|
}
|
|
1051
|
-
if (
|
|
1620
|
+
if (jsonParsedConfigs.instructionType === "assignWithSeed") {
|
|
1052
1621
|
return "AssignWithSeedInstruction";
|
|
1053
1622
|
}
|
|
1054
|
-
if (
|
|
1623
|
+
if (jsonParsedConfigs.instructionType === "transferWithSeed") {
|
|
1055
1624
|
return "TransferWithSeedInstruction";
|
|
1056
1625
|
}
|
|
1057
1626
|
}
|
|
1058
|
-
if (
|
|
1059
|
-
if (
|
|
1627
|
+
if (jsonParsedConfigs.programName === "vote") {
|
|
1628
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
1060
1629
|
return "VoteInitializeAccountInstruction";
|
|
1061
1630
|
}
|
|
1062
|
-
if (
|
|
1631
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
1063
1632
|
return "VoteAuthorizeInstruction";
|
|
1064
1633
|
}
|
|
1065
|
-
if (
|
|
1634
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1066
1635
|
return "VoteAuthorizeWithSeedInstruction";
|
|
1067
1636
|
}
|
|
1068
|
-
if (
|
|
1637
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1069
1638
|
return "VoteAuthorizeCheckedWithSeedInstruction";
|
|
1070
1639
|
}
|
|
1071
|
-
if (
|
|
1640
|
+
if (jsonParsedConfigs.instructionType === "vote") {
|
|
1072
1641
|
return "VoteVoteInstruction";
|
|
1073
1642
|
}
|
|
1074
|
-
if (
|
|
1643
|
+
if (jsonParsedConfigs.instructionType === "updatevotestate") {
|
|
1075
1644
|
return "VoteUpdateVoteStateInstruction";
|
|
1076
1645
|
}
|
|
1077
|
-
if (
|
|
1646
|
+
if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
|
|
1078
1647
|
return "VoteUpdateVoteStateSwitchInstruction";
|
|
1079
1648
|
}
|
|
1080
|
-
if (
|
|
1649
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
|
|
1081
1650
|
return "VoteCompactUpdateVoteStateInstruction";
|
|
1082
1651
|
}
|
|
1083
|
-
if (
|
|
1652
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
|
|
1084
1653
|
return "VoteCompactUpdateVoteStateSwitchInstruction";
|
|
1085
1654
|
}
|
|
1086
|
-
if (
|
|
1655
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
1087
1656
|
return "VoteWithdrawInstruction";
|
|
1088
1657
|
}
|
|
1089
|
-
if (
|
|
1658
|
+
if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
|
|
1090
1659
|
return "VoteUpdateValidatorIdentityInstruction";
|
|
1091
1660
|
}
|
|
1092
|
-
if (
|
|
1661
|
+
if (jsonParsedConfigs.instructionType === "updateCommission") {
|
|
1093
1662
|
return "VoteUpdateCommissionInstruction";
|
|
1094
1663
|
}
|
|
1095
|
-
if (
|
|
1664
|
+
if (jsonParsedConfigs.instructionType === "voteSwitch") {
|
|
1096
1665
|
return "VoteVoteSwitchInstruction";
|
|
1097
1666
|
}
|
|
1098
|
-
if (
|
|
1667
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1099
1668
|
return "VoteAuthorizeCheckedInstruction";
|
|
1100
1669
|
}
|
|
1101
1670
|
}
|
|
@@ -1118,21 +1687,25 @@ var instructionResolvers = {
|
|
|
1118
1687
|
},
|
|
1119
1688
|
VoteAuthorizeCheckedInstruction: {
|
|
1120
1689
|
authority: resolveAccount("authority"),
|
|
1690
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1121
1691
|
newAuthority: resolveAccount("newAuthority"),
|
|
1122
1692
|
voteAccount: resolveAccount("voteAccount")
|
|
1123
1693
|
},
|
|
1124
1694
|
VoteAuthorizeCheckedWithSeedInstruction: {
|
|
1125
1695
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1696
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1126
1697
|
newAuthority: resolveAccount("newAuthority"),
|
|
1127
1698
|
voteAccount: resolveAccount("voteAccount")
|
|
1128
1699
|
},
|
|
1129
1700
|
VoteAuthorizeInstruction: {
|
|
1130
1701
|
authority: resolveAccount("authority"),
|
|
1702
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1131
1703
|
newAuthority: resolveAccount("newAuthority"),
|
|
1132
1704
|
voteAccount: resolveAccount("voteAccount")
|
|
1133
1705
|
},
|
|
1134
1706
|
VoteAuthorizeWithSeedInstruction: {
|
|
1135
1707
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1708
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1136
1709
|
newAuthority: resolveAccount("newAuthority"),
|
|
1137
1710
|
voteAccount: resolveAccount("voteAccount")
|
|
1138
1711
|
},
|
|
@@ -1147,7 +1720,9 @@ var instructionResolvers = {
|
|
|
1147
1720
|
VoteInitializeAccountInstruction: {
|
|
1148
1721
|
authorizedVoter: resolveAccount("authorizedVoter"),
|
|
1149
1722
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
1723
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1150
1724
|
node: resolveAccount("node"),
|
|
1725
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1151
1726
|
voteAccount: resolveAccount("voteAccount")
|
|
1152
1727
|
},
|
|
1153
1728
|
VoteUpdateCommissionInstruction: {
|
|
@@ -1168,10 +1743,14 @@ var instructionResolvers = {
|
|
|
1168
1743
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1169
1744
|
},
|
|
1170
1745
|
VoteVoteInstruction: {
|
|
1746
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1747
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1171
1748
|
voteAccount: resolveAccount("voteAccount"),
|
|
1172
1749
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1173
1750
|
},
|
|
1174
1751
|
VoteVoteSwitchInstruction: {
|
|
1752
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1753
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1175
1754
|
voteAccount: resolveAccount("voteAccount"),
|
|
1176
1755
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1177
1756
|
},
|
|
@@ -1182,7 +1761,9 @@ var instructionResolvers = {
|
|
|
1182
1761
|
WithdrawNonceAccountInstruction: {
|
|
1183
1762
|
destination: resolveAccount("destination"),
|
|
1184
1763
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
1185
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1764
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1765
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1766
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1186
1767
|
}
|
|
1187
1768
|
};
|
|
1188
1769
|
|
|
@@ -1190,20 +1771,57 @@ var instructionResolvers = {
|
|
|
1190
1771
|
function resolveProgramAccounts(fieldName) {
|
|
1191
1772
|
return async (parent, args, context, info) => {
|
|
1192
1773
|
const programAddress = fieldName ? parent[fieldName] : args.programAddress;
|
|
1193
|
-
if (
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1774
|
+
if (programAddress) {
|
|
1775
|
+
const argsSet = buildProgramAccountsLoaderArgSetFromResolveInfo({ ...args, programAddress }, info);
|
|
1776
|
+
const loadedProgramAccountsLists = await context.loaders.programAccounts.loadMany(argsSet);
|
|
1777
|
+
const result = {};
|
|
1778
|
+
loadedProgramAccountsLists.forEach((programAccounts, i) => {
|
|
1779
|
+
if (programAccounts instanceof Error) {
|
|
1780
|
+
console.error(programAccounts);
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
programAccounts.forEach((programAccount) => {
|
|
1784
|
+
const { account, pubkey: address } = programAccount;
|
|
1785
|
+
const thisResult = result[address] ||= {
|
|
1786
|
+
...account,
|
|
1787
|
+
address,
|
|
1788
|
+
encodedData: {},
|
|
1789
|
+
ownerProgram: account.owner
|
|
1790
|
+
};
|
|
1791
|
+
const { data } = account;
|
|
1792
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
1793
|
+
if (encoding && thisResult.encodedData) {
|
|
1794
|
+
if (Array.isArray(data)) {
|
|
1795
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1796
|
+
dataSlice,
|
|
1797
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
1798
|
+
})] = data[0];
|
|
1799
|
+
} else if (typeof data === "string") {
|
|
1800
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1801
|
+
dataSlice,
|
|
1802
|
+
encoding: "base58"
|
|
1803
|
+
})] = data;
|
|
1804
|
+
} else if (typeof data === "object") {
|
|
1805
|
+
const {
|
|
1806
|
+
parsed: { info: parsedData, type: accountType },
|
|
1807
|
+
program: programName,
|
|
1808
|
+
programId
|
|
1809
|
+
} = data;
|
|
1810
|
+
thisResult.jsonParsedConfigs = {
|
|
1811
|
+
accountType,
|
|
1812
|
+
programId,
|
|
1813
|
+
programName
|
|
1814
|
+
};
|
|
1815
|
+
for (const key in parsedData) {
|
|
1816
|
+
thisResult[key] = parsedData[key];
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
});
|
|
1821
|
+
});
|
|
1822
|
+
return Object.values(result);
|
|
1823
|
+
}
|
|
1824
|
+
return null;
|
|
1207
1825
|
};
|
|
1208
1826
|
}
|
|
1209
1827
|
|
|
@@ -1230,47 +1848,49 @@ var stringScalarAlias = {
|
|
|
1230
1848
|
return value;
|
|
1231
1849
|
}
|
|
1232
1850
|
};
|
|
1233
|
-
var
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1238
|
-
BigInt: {
|
|
1239
|
-
__parseLiteral(ast) {
|
|
1240
|
-
if (ast.kind === Kind.STRING) {
|
|
1241
|
-
return BigInt(ast.value);
|
|
1242
|
-
}
|
|
1243
|
-
return null;
|
|
1244
|
-
},
|
|
1245
|
-
__parseValue(value) {
|
|
1246
|
-
return BigInt(value);
|
|
1247
|
-
},
|
|
1248
|
-
__serialize(value) {
|
|
1249
|
-
return BigInt(value);
|
|
1851
|
+
var bigIntScalarAlias = {
|
|
1852
|
+
__parseLiteral(ast) {
|
|
1853
|
+
if (ast.kind === Kind.STRING || ast.kind === Kind.INT || ast.kind === Kind.FLOAT) {
|
|
1854
|
+
return BigInt(ast.value);
|
|
1250
1855
|
}
|
|
1856
|
+
return null;
|
|
1857
|
+
},
|
|
1858
|
+
__parseValue(value) {
|
|
1859
|
+
return BigInt(value);
|
|
1860
|
+
},
|
|
1861
|
+
__serialize(value) {
|
|
1862
|
+
return BigInt(value);
|
|
1251
1863
|
}
|
|
1252
1864
|
};
|
|
1253
|
-
|
|
1254
|
-
// src/resolvers/types.ts
|
|
1255
|
-
var commonTypeResolvers = {
|
|
1865
|
+
var typeTypeResolvers = {
|
|
1256
1866
|
AccountEncoding: {
|
|
1257
1867
|
BASE_58: "base58",
|
|
1258
1868
|
BASE_64: "base64",
|
|
1259
|
-
BASE_64_ZSTD: "base64+zstd"
|
|
1260
|
-
PARSED: "jsonParsed"
|
|
1869
|
+
BASE_64_ZSTD: "base64+zstd"
|
|
1261
1870
|
},
|
|
1871
|
+
Address: stringScalarAlias,
|
|
1872
|
+
Base58EncodedBytes: stringScalarAlias,
|
|
1873
|
+
Base64EncodedBytes: stringScalarAlias,
|
|
1874
|
+
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1875
|
+
BigInt: bigIntScalarAlias,
|
|
1876
|
+
Commitment: {
|
|
1877
|
+
CONFIRMED: "confirmed",
|
|
1878
|
+
FINALIZED: "finalized",
|
|
1879
|
+
PROCESSED: "processed"
|
|
1880
|
+
},
|
|
1881
|
+
CommitmentWithoutProcessed: {
|
|
1882
|
+
CONFIRMED: "confirmed",
|
|
1883
|
+
FINALIZED: "finalized"
|
|
1884
|
+
},
|
|
1885
|
+
Signature: stringScalarAlias,
|
|
1886
|
+
Slot: bigIntScalarAlias,
|
|
1262
1887
|
TokenBalance: {
|
|
1263
1888
|
mint: resolveAccount("mint"),
|
|
1264
1889
|
owner: resolveAccount("owner")
|
|
1265
1890
|
},
|
|
1266
1891
|
TransactionEncoding: {
|
|
1267
1892
|
BASE_58: "base58",
|
|
1268
|
-
BASE_64: "base64"
|
|
1269
|
-
PARSED: "jsonParsed"
|
|
1270
|
-
},
|
|
1271
|
-
TransactionVersion: {
|
|
1272
|
-
LEGACY: "legacy",
|
|
1273
|
-
ZERO: 0
|
|
1893
|
+
BASE_64: "base64"
|
|
1274
1894
|
}
|
|
1275
1895
|
};
|
|
1276
1896
|
|
|
@@ -1279,11 +1899,10 @@ function createSolanaGraphQLResolvers() {
|
|
|
1279
1899
|
return {
|
|
1280
1900
|
...accountResolvers,
|
|
1281
1901
|
...blockResolvers,
|
|
1282
|
-
...commonTypeResolvers,
|
|
1283
1902
|
...instructionResolvers,
|
|
1284
1903
|
...rootResolvers,
|
|
1285
|
-
...
|
|
1286
|
-
...
|
|
1904
|
+
...transactionResolvers,
|
|
1905
|
+
...typeTypeResolvers
|
|
1287
1906
|
};
|
|
1288
1907
|
}
|
|
1289
1908
|
|
|
@@ -1296,6 +1915,7 @@ var accountTypeDefs = (
|
|
|
1296
1915
|
"""
|
|
1297
1916
|
interface Account {
|
|
1298
1917
|
address: Address
|
|
1918
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1299
1919
|
executable: Boolean
|
|
1300
1920
|
lamports: BigInt
|
|
1301
1921
|
ownerProgram: Account
|
|
@@ -1304,37 +1924,11 @@ var accountTypeDefs = (
|
|
|
1304
1924
|
}
|
|
1305
1925
|
|
|
1306
1926
|
"""
|
|
1307
|
-
|
|
1927
|
+
Generic base account type
|
|
1308
1928
|
"""
|
|
1309
|
-
type
|
|
1929
|
+
type GenericAccount implements Account {
|
|
1310
1930
|
address: Address
|
|
1311
|
-
data:
|
|
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
|
|
1931
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1338
1932
|
executable: Boolean
|
|
1339
1933
|
lamports: BigInt
|
|
1340
1934
|
ownerProgram: Account
|
|
@@ -1350,6 +1944,7 @@ var accountTypeDefs = (
|
|
|
1350
1944
|
"""
|
|
1351
1945
|
type NonceAccount implements Account {
|
|
1352
1946
|
address: Address
|
|
1947
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1353
1948
|
executable: Boolean
|
|
1354
1949
|
lamports: BigInt
|
|
1355
1950
|
ownerProgram: Account
|
|
@@ -1365,6 +1960,7 @@ var accountTypeDefs = (
|
|
|
1365
1960
|
"""
|
|
1366
1961
|
type LookupTableAccount implements Account {
|
|
1367
1962
|
address: Address
|
|
1963
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1368
1964
|
executable: Boolean
|
|
1369
1965
|
lamports: BigInt
|
|
1370
1966
|
ownerProgram: Account
|
|
@@ -1382,6 +1978,7 @@ var accountTypeDefs = (
|
|
|
1382
1978
|
"""
|
|
1383
1979
|
type MintAccount implements Account {
|
|
1384
1980
|
address: Address
|
|
1981
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1385
1982
|
executable: Boolean
|
|
1386
1983
|
lamports: BigInt
|
|
1387
1984
|
ownerProgram: Account
|
|
@@ -1399,6 +1996,7 @@ var accountTypeDefs = (
|
|
|
1399
1996
|
"""
|
|
1400
1997
|
type TokenAccount implements Account {
|
|
1401
1998
|
address: Address
|
|
1999
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1402
2000
|
executable: Boolean
|
|
1403
2001
|
lamports: BigInt
|
|
1404
2002
|
ownerProgram: Account
|
|
@@ -1441,6 +2039,7 @@ var accountTypeDefs = (
|
|
|
1441
2039
|
"""
|
|
1442
2040
|
type StakeAccount implements Account {
|
|
1443
2041
|
address: Address
|
|
2042
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1444
2043
|
executable: Boolean
|
|
1445
2044
|
lamports: BigInt
|
|
1446
2045
|
ownerProgram: Account
|
|
@@ -1472,6 +2071,7 @@ var accountTypeDefs = (
|
|
|
1472
2071
|
"""
|
|
1473
2072
|
type VoteAccount implements Account {
|
|
1474
2073
|
address: Address
|
|
2074
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1475
2075
|
executable: Boolean
|
|
1476
2076
|
lamports: BigInt
|
|
1477
2077
|
ownerProgram: Account
|
|
@@ -1494,188 +2094,18 @@ var accountTypeDefs = (
|
|
|
1494
2094
|
var blockTypeDefs = (
|
|
1495
2095
|
/* GraphQL */
|
|
1496
2096
|
`
|
|
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
2097
|
"""
|
|
1519
|
-
|
|
2098
|
+
A Solana block
|
|
1520
2099
|
"""
|
|
1521
|
-
|
|
2100
|
+
type Block {
|
|
1522
2101
|
blockhash: String
|
|
1523
2102
|
blockHeight: BigInt
|
|
1524
2103
|
blockTime: BigInt
|
|
1525
|
-
parentSlot:
|
|
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
|
|
2104
|
+
parentSlot: Slot
|
|
1553
2105
|
previousBlockhash: String
|
|
1554
2106
|
rewards: [Reward]
|
|
2107
|
+
signatures: [Signature]
|
|
1555
2108
|
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
2109
|
}
|
|
1680
2110
|
`
|
|
1681
2111
|
);
|
|
@@ -1797,12 +2227,12 @@ var instructionTypeDefs = (
|
|
|
1797
2227
|
programId: Address
|
|
1798
2228
|
authority: Account
|
|
1799
2229
|
bufferAccount: Account
|
|
1800
|
-
clockSysvar:
|
|
2230
|
+
clockSysvar: Account
|
|
1801
2231
|
maxDataLen: BigInt
|
|
1802
2232
|
payerAccount: Account
|
|
1803
2233
|
programAccount: Account
|
|
1804
2234
|
programDataAccount: Account
|
|
1805
|
-
rentSysvar:
|
|
2235
|
+
rentSysvar: Account
|
|
1806
2236
|
}
|
|
1807
2237
|
|
|
1808
2238
|
"""
|
|
@@ -1812,10 +2242,10 @@ var instructionTypeDefs = (
|
|
|
1812
2242
|
programId: Address
|
|
1813
2243
|
authority: Account
|
|
1814
2244
|
bufferAccount: Account
|
|
1815
|
-
clockSysvar:
|
|
2245
|
+
clockSysvar: Account
|
|
1816
2246
|
programAccount: Account
|
|
1817
2247
|
programDataAccount: Account
|
|
1818
|
-
rentSysvar:
|
|
2248
|
+
rentSysvar: Account
|
|
1819
2249
|
spillAccount: Account
|
|
1820
2250
|
}
|
|
1821
2251
|
|
|
@@ -1868,7 +2298,7 @@ var instructionTypeDefs = (
|
|
|
1868
2298
|
type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
|
|
1869
2299
|
programId: Address
|
|
1870
2300
|
account: Account
|
|
1871
|
-
mint:
|
|
2301
|
+
mint: Account
|
|
1872
2302
|
source: Account
|
|
1873
2303
|
systemProgram: Account
|
|
1874
2304
|
tokenProgram: Account
|
|
@@ -1881,7 +2311,7 @@ var instructionTypeDefs = (
|
|
|
1881
2311
|
type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
|
|
1882
2312
|
programId: Address
|
|
1883
2313
|
account: Account
|
|
1884
|
-
mint:
|
|
2314
|
+
mint: Account
|
|
1885
2315
|
source: Account
|
|
1886
2316
|
systemProgram: Account
|
|
1887
2317
|
tokenProgram: Account
|
|
@@ -1919,7 +2349,7 @@ var instructionTypeDefs = (
|
|
|
1919
2349
|
freezeAuthority: Account
|
|
1920
2350
|
mint: Account
|
|
1921
2351
|
mintAuthority: Account
|
|
1922
|
-
rentSysvar:
|
|
2352
|
+
rentSysvar: Account
|
|
1923
2353
|
}
|
|
1924
2354
|
|
|
1925
2355
|
"""
|
|
@@ -1941,7 +2371,7 @@ var instructionTypeDefs = (
|
|
|
1941
2371
|
account: Account
|
|
1942
2372
|
mint: Account
|
|
1943
2373
|
owner: Account
|
|
1944
|
-
rentSysvar:
|
|
2374
|
+
rentSysvar: Account
|
|
1945
2375
|
}
|
|
1946
2376
|
|
|
1947
2377
|
"""
|
|
@@ -1952,7 +2382,7 @@ var instructionTypeDefs = (
|
|
|
1952
2382
|
account: Account
|
|
1953
2383
|
mint: Account
|
|
1954
2384
|
owner: Account
|
|
1955
|
-
rentSysvar:
|
|
2385
|
+
rentSysvar: Account
|
|
1956
2386
|
}
|
|
1957
2387
|
|
|
1958
2388
|
"""
|
|
@@ -1972,7 +2402,7 @@ var instructionTypeDefs = (
|
|
|
1972
2402
|
programId: Address
|
|
1973
2403
|
m: BigInt # FIXME:*
|
|
1974
2404
|
multisig: Account
|
|
1975
|
-
rentSysvar:
|
|
2405
|
+
rentSysvar: Account
|
|
1976
2406
|
signers: [Address]
|
|
1977
2407
|
}
|
|
1978
2408
|
|
|
@@ -2227,7 +2657,7 @@ var instructionTypeDefs = (
|
|
|
2227
2657
|
programId: Address
|
|
2228
2658
|
authorized: StakeInitializeInstructionDataAuthorized
|
|
2229
2659
|
lockup: Lockup
|
|
2230
|
-
rentSysvar:
|
|
2660
|
+
rentSysvar: Account
|
|
2231
2661
|
stakeAccount: Account
|
|
2232
2662
|
}
|
|
2233
2663
|
|
|
@@ -2238,7 +2668,7 @@ var instructionTypeDefs = (
|
|
|
2238
2668
|
programId: Address
|
|
2239
2669
|
authority: Account
|
|
2240
2670
|
authorityType: String
|
|
2241
|
-
clockSysvar:
|
|
2671
|
+
clockSysvar: Account
|
|
2242
2672
|
custodian: Account
|
|
2243
2673
|
newAuthority: Account
|
|
2244
2674
|
stakeAccount: Account
|
|
@@ -2249,11 +2679,11 @@ var instructionTypeDefs = (
|
|
|
2249
2679
|
"""
|
|
2250
2680
|
type StakeDelegateStakeInstruction implements TransactionInstruction {
|
|
2251
2681
|
programId: Address
|
|
2252
|
-
clockSysvar:
|
|
2682
|
+
clockSysvar: Account
|
|
2253
2683
|
stakeAccount: Account
|
|
2254
2684
|
stakeAuthority: Account
|
|
2255
2685
|
stakeConfigAccount: Account
|
|
2256
|
-
stakeHistorySysvar:
|
|
2686
|
+
stakeHistorySysvar: Account
|
|
2257
2687
|
voteAccount: Account
|
|
2258
2688
|
}
|
|
2259
2689
|
|
|
@@ -2273,7 +2703,7 @@ var instructionTypeDefs = (
|
|
|
2273
2703
|
"""
|
|
2274
2704
|
type StakeWithdrawInstruction implements TransactionInstruction {
|
|
2275
2705
|
programId: Address
|
|
2276
|
-
clockSysvar:
|
|
2706
|
+
clockSysvar: Account
|
|
2277
2707
|
destination: Account
|
|
2278
2708
|
lamports: BigInt
|
|
2279
2709
|
stakeAccount: Account
|
|
@@ -2285,7 +2715,7 @@ var instructionTypeDefs = (
|
|
|
2285
2715
|
"""
|
|
2286
2716
|
type StakeDeactivateInstruction implements TransactionInstruction {
|
|
2287
2717
|
programId: Address
|
|
2288
|
-
clockSysvar:
|
|
2718
|
+
clockSysvar: Account
|
|
2289
2719
|
stakeAccount: Account
|
|
2290
2720
|
stakeAuthority: Account
|
|
2291
2721
|
}
|
|
@@ -2305,11 +2735,11 @@ var instructionTypeDefs = (
|
|
|
2305
2735
|
"""
|
|
2306
2736
|
type StakeMergeInstruction implements TransactionInstruction {
|
|
2307
2737
|
programId: Address
|
|
2308
|
-
clockSysvar:
|
|
2738
|
+
clockSysvar: Account
|
|
2309
2739
|
destination: Account
|
|
2310
2740
|
source: Account
|
|
2311
2741
|
stakeAuthority: Account
|
|
2312
|
-
stakeHistorySysvar:
|
|
2742
|
+
stakeHistorySysvar: Account
|
|
2313
2743
|
}
|
|
2314
2744
|
|
|
2315
2745
|
"""
|
|
@@ -2321,7 +2751,7 @@ var instructionTypeDefs = (
|
|
|
2321
2751
|
authorityOwner: Account
|
|
2322
2752
|
authoritySeed: String
|
|
2323
2753
|
authorityType: String
|
|
2324
|
-
clockSysvar:
|
|
2754
|
+
clockSysvar: Account
|
|
2325
2755
|
custodian: Account
|
|
2326
2756
|
newAuthorized: Account
|
|
2327
2757
|
stakeAccount: Account
|
|
@@ -2338,7 +2768,7 @@ var instructionTypeDefs = (
|
|
|
2338
2768
|
programId: Address
|
|
2339
2769
|
authorized: StakeInitializeCheckedInstructionDataAuthorized
|
|
2340
2770
|
lockup: Lockup
|
|
2341
|
-
rentSysvar:
|
|
2771
|
+
rentSysvar: Account
|
|
2342
2772
|
stakeAccount: Account
|
|
2343
2773
|
}
|
|
2344
2774
|
|
|
@@ -2349,7 +2779,7 @@ var instructionTypeDefs = (
|
|
|
2349
2779
|
programId: Address
|
|
2350
2780
|
authority: Account
|
|
2351
2781
|
authorityType: String
|
|
2352
|
-
clockSysvar:
|
|
2782
|
+
clockSysvar: Account
|
|
2353
2783
|
custodian: Account
|
|
2354
2784
|
newAuthority: Account
|
|
2355
2785
|
stakeAccount: Account
|
|
@@ -2364,7 +2794,7 @@ var instructionTypeDefs = (
|
|
|
2364
2794
|
authorityOwner: Account
|
|
2365
2795
|
authoritySeed: String
|
|
2366
2796
|
authorityType: String
|
|
2367
|
-
clockSysvar:
|
|
2797
|
+
clockSysvar: Account
|
|
2368
2798
|
custodian: Account
|
|
2369
2799
|
newAuthorized: Account
|
|
2370
2800
|
stakeAccount: Account
|
|
@@ -2452,7 +2882,7 @@ var instructionTypeDefs = (
|
|
|
2452
2882
|
programId: Address
|
|
2453
2883
|
nonceAccount: Account
|
|
2454
2884
|
nonceAuthority: Account
|
|
2455
|
-
recentBlockhashesSysvar:
|
|
2885
|
+
recentBlockhashesSysvar: Account
|
|
2456
2886
|
}
|
|
2457
2887
|
|
|
2458
2888
|
"""
|
|
@@ -2464,8 +2894,8 @@ var instructionTypeDefs = (
|
|
|
2464
2894
|
lamports: BigInt
|
|
2465
2895
|
nonceAccount: Account
|
|
2466
2896
|
nonceAuthority: Account
|
|
2467
|
-
recentBlockhashesSysvar:
|
|
2468
|
-
rentSysvar:
|
|
2897
|
+
recentBlockhashesSysvar: Account
|
|
2898
|
+
rentSysvar: Account
|
|
2469
2899
|
}
|
|
2470
2900
|
|
|
2471
2901
|
"""
|
|
@@ -2475,8 +2905,8 @@ var instructionTypeDefs = (
|
|
|
2475
2905
|
programId: Address
|
|
2476
2906
|
nonceAccount: Account
|
|
2477
2907
|
nonceAuthority: Account
|
|
2478
|
-
recentBlockhashesSysvar:
|
|
2479
|
-
rentSysvar:
|
|
2908
|
+
recentBlockhashesSysvar: Account
|
|
2909
|
+
rentSysvar: Account
|
|
2480
2910
|
}
|
|
2481
2911
|
|
|
2482
2912
|
"""
|
|
@@ -2550,10 +2980,10 @@ var instructionTypeDefs = (
|
|
|
2550
2980
|
programId: Address
|
|
2551
2981
|
authorizedVoter: Account
|
|
2552
2982
|
authorizedWithdrawer: Account
|
|
2553
|
-
clockSysvar:
|
|
2983
|
+
clockSysvar: Account
|
|
2554
2984
|
commission: BigInt # FIXME:*
|
|
2555
2985
|
node: Account
|
|
2556
|
-
rentSysvar:
|
|
2986
|
+
rentSysvar: Account
|
|
2557
2987
|
voteAccount: Account
|
|
2558
2988
|
}
|
|
2559
2989
|
|
|
@@ -2564,7 +2994,7 @@ var instructionTypeDefs = (
|
|
|
2564
2994
|
programId: Address
|
|
2565
2995
|
authority: Account
|
|
2566
2996
|
authorityType: String
|
|
2567
|
-
clockSysvar:
|
|
2997
|
+
clockSysvar: Account
|
|
2568
2998
|
newAuthority: Account
|
|
2569
2999
|
voteAccount: Account
|
|
2570
3000
|
}
|
|
@@ -2578,7 +3008,7 @@ var instructionTypeDefs = (
|
|
|
2578
3008
|
authorityOwner: Account
|
|
2579
3009
|
authoritySeed: String
|
|
2580
3010
|
authorityType: String
|
|
2581
|
-
clockSysvar:
|
|
3011
|
+
clockSysvar: Account
|
|
2582
3012
|
newAuthority: Account
|
|
2583
3013
|
voteAccount: Account
|
|
2584
3014
|
}
|
|
@@ -2592,7 +3022,7 @@ var instructionTypeDefs = (
|
|
|
2592
3022
|
authorityOwner: Account
|
|
2593
3023
|
authoritySeed: String
|
|
2594
3024
|
authorityType: String
|
|
2595
|
-
clockSysvar:
|
|
3025
|
+
clockSysvar: Account
|
|
2596
3026
|
newAuthority: Account
|
|
2597
3027
|
voteAccount: Account
|
|
2598
3028
|
}
|
|
@@ -2608,8 +3038,8 @@ var instructionTypeDefs = (
|
|
|
2608
3038
|
"""
|
|
2609
3039
|
type VoteVoteInstruction implements TransactionInstruction {
|
|
2610
3040
|
programId: Address
|
|
2611
|
-
clockSysvar:
|
|
2612
|
-
slotHashesSysvar:
|
|
3041
|
+
clockSysvar: Account
|
|
3042
|
+
slotHashesSysvar: Account
|
|
2613
3043
|
vote: Vote
|
|
2614
3044
|
voteAccount: Account
|
|
2615
3045
|
voteAuthority: Account
|
|
@@ -2706,9 +3136,9 @@ var instructionTypeDefs = (
|
|
|
2706
3136
|
"""
|
|
2707
3137
|
type VoteVoteSwitchInstruction implements TransactionInstruction {
|
|
2708
3138
|
programId: Address
|
|
2709
|
-
clockSysvar:
|
|
3139
|
+
clockSysvar: Account
|
|
2710
3140
|
hash: String
|
|
2711
|
-
slotHashesSysvar:
|
|
3141
|
+
slotHashesSysvar: Account
|
|
2712
3142
|
vote: Vote
|
|
2713
3143
|
voteAccount: Account
|
|
2714
3144
|
voteAuthority: Account
|
|
@@ -2721,7 +3151,7 @@ var instructionTypeDefs = (
|
|
|
2721
3151
|
programId: Address
|
|
2722
3152
|
authority: Account
|
|
2723
3153
|
authorityType: String
|
|
2724
|
-
clockSysvar:
|
|
3154
|
+
clockSysvar: Account
|
|
2725
3155
|
newAuthority: Account
|
|
2726
3156
|
voteAccount: Account
|
|
2727
3157
|
}
|
|
@@ -2733,28 +3163,15 @@ var rootTypeDefs = (
|
|
|
2733
3163
|
/* GraphQL */
|
|
2734
3164
|
`
|
|
2735
3165
|
type Query {
|
|
2736
|
-
account(
|
|
2737
|
-
|
|
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
|
|
3166
|
+
account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
|
|
3167
|
+
block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
|
|
2749
3168
|
programAccounts(
|
|
2750
|
-
programAddress:
|
|
3169
|
+
programAddress: Address!
|
|
2751
3170
|
commitment: Commitment
|
|
2752
|
-
dataSlice: DataSlice
|
|
2753
|
-
encoding: AccountEncoding
|
|
2754
3171
|
filters: [ProgramAccountsFilter]
|
|
2755
|
-
minContextSlot:
|
|
3172
|
+
minContextSlot: Slot
|
|
2756
3173
|
): [Account]
|
|
2757
|
-
transaction(signature:
|
|
3174
|
+
transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
|
|
2758
3175
|
}
|
|
2759
3176
|
|
|
2760
3177
|
schema {
|
|
@@ -2829,77 +3246,120 @@ var transactionTypeDefs = (
|
|
|
2829
3246
|
}
|
|
2830
3247
|
|
|
2831
3248
|
"""
|
|
2832
|
-
|
|
3249
|
+
A Solana transaction
|
|
2833
3250
|
"""
|
|
2834
|
-
|
|
3251
|
+
type Transaction {
|
|
2835
3252
|
blockTime: BigInt
|
|
3253
|
+
data(encoding: TransactionEncoding!): String
|
|
3254
|
+
message: TransactionMessage
|
|
2836
3255
|
meta: TransactionMeta
|
|
2837
|
-
|
|
3256
|
+
signatures: [Signature]
|
|
3257
|
+
slot: Slot
|
|
2838
3258
|
version: String
|
|
2839
3259
|
}
|
|
3260
|
+
`
|
|
3261
|
+
);
|
|
2840
3262
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
version: String
|
|
3263
|
+
// src/schema/types.ts
|
|
3264
|
+
var typeTypeDefs = (
|
|
3265
|
+
/* GraphQL */
|
|
3266
|
+
`
|
|
3267
|
+
enum AccountEncoding {
|
|
3268
|
+
BASE_58
|
|
3269
|
+
BASE_64
|
|
3270
|
+
BASE_64_ZSTD
|
|
2850
3271
|
}
|
|
2851
3272
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
3273
|
+
scalar Address
|
|
3274
|
+
|
|
3275
|
+
scalar Base58EncodedBytes
|
|
3276
|
+
|
|
3277
|
+
scalar Base64EncodedBytes
|
|
3278
|
+
|
|
3279
|
+
scalar Base64ZstdEncodedBytes
|
|
3280
|
+
|
|
3281
|
+
scalar BigInt
|
|
3282
|
+
|
|
3283
|
+
enum Commitment {
|
|
3284
|
+
CONFIRMED
|
|
3285
|
+
FINALIZED
|
|
3286
|
+
PROCESSED
|
|
3287
|
+
}
|
|
3288
|
+
|
|
3289
|
+
enum CommitmentWithoutProcessed {
|
|
3290
|
+
CONFIRMED
|
|
3291
|
+
FINALIZED
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3294
|
+
input DataSlice {
|
|
3295
|
+
offset: Int!
|
|
3296
|
+
length: Int!
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3299
|
+
input ProgramAccountsFilter {
|
|
3300
|
+
bytes: BigInt
|
|
3301
|
+
dataSize: BigInt
|
|
3302
|
+
encoding: AccountEncoding
|
|
3303
|
+
offset: BigInt
|
|
3304
|
+
}
|
|
3305
|
+
|
|
3306
|
+
type ReturnData {
|
|
2857
3307
|
data: Base64EncodedBytes
|
|
2858
|
-
|
|
2859
|
-
slot: BigInt
|
|
2860
|
-
version: String
|
|
3308
|
+
programId: Address
|
|
2861
3309
|
}
|
|
2862
3310
|
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
3311
|
+
type Reward {
|
|
3312
|
+
commission: Int
|
|
3313
|
+
lamports: BigInt
|
|
3314
|
+
postBalance: BigInt
|
|
3315
|
+
pubkey: Address
|
|
3316
|
+
rewardType: String
|
|
2869
3317
|
}
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3318
|
+
|
|
3319
|
+
scalar Signature
|
|
3320
|
+
|
|
3321
|
+
scalar Slot
|
|
3322
|
+
|
|
3323
|
+
type TokenAmount {
|
|
3324
|
+
amount: String
|
|
3325
|
+
decimals: Int
|
|
3326
|
+
uiAmount: BigInt
|
|
3327
|
+
uiAmountString: String
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
type TokenBalance {
|
|
3331
|
+
accountIndex: Int
|
|
3332
|
+
mint: Account
|
|
3333
|
+
owner: Account
|
|
3334
|
+
programId: Address
|
|
3335
|
+
uiTokenAmount: TokenAmount
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
enum TransactionEncoding {
|
|
3339
|
+
BASE_58
|
|
3340
|
+
BASE_64
|
|
2876
3341
|
}
|
|
2877
3342
|
`
|
|
2878
3343
|
);
|
|
2879
3344
|
|
|
2880
3345
|
// src/schema/index.ts
|
|
2881
3346
|
function createSolanaGraphQLTypeDefs() {
|
|
2882
|
-
return [
|
|
2883
|
-
accountTypeDefs,
|
|
2884
|
-
blockTypeDefs,
|
|
2885
|
-
commonTypeDefs,
|
|
2886
|
-
inputTypeDefs,
|
|
2887
|
-
instructionTypeDefs,
|
|
2888
|
-
rootTypeDefs,
|
|
2889
|
-
scalarTypeDefs,
|
|
2890
|
-
transactionTypeDefs
|
|
2891
|
-
];
|
|
3347
|
+
return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
|
|
2892
3348
|
}
|
|
2893
3349
|
|
|
2894
3350
|
// src/index.ts
|
|
2895
|
-
function createRpcGraphQL(rpc) {
|
|
3351
|
+
function createRpcGraphQL(rpc, config) {
|
|
3352
|
+
const rpcGraphQLConfig = {
|
|
3353
|
+
maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
|
|
3354
|
+
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
|
|
3355
|
+
};
|
|
2896
3356
|
const schema = makeExecutableSchema({
|
|
2897
3357
|
resolvers: createSolanaGraphQLResolvers(),
|
|
2898
3358
|
typeDefs: createSolanaGraphQLTypeDefs()
|
|
2899
3359
|
});
|
|
2900
3360
|
return {
|
|
2901
3361
|
async query(source, variableValues) {
|
|
2902
|
-
const contextValue = createSolanaGraphQLContext(rpc);
|
|
3362
|
+
const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
|
|
2903
3363
|
return graphql({
|
|
2904
3364
|
contextValue,
|
|
2905
3365
|
schema,
|