@solana/rpc-graphql 2.0.0-experimental.e9c1b10 → 2.0.0-experimental.eb14acd
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 +1106 -579
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1107 -580
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +1107 -580
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +1106 -579
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +1107 -580
- 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 +29 -12
- 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 +6 -2
- 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/index.d.ts +5 -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 +17 -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 +83 -4
- 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/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 +11 -38
- 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.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var schema = require('@graphql-tools/schema');
|
|
4
4
|
var graphql = require('graphql');
|
|
5
|
+
var codecsStrings = require('@solana/codecs-strings');
|
|
5
6
|
var DataLoader = require('dataloader');
|
|
6
7
|
var stringify = require('json-stable-stringify');
|
|
7
8
|
|
|
@@ -19,40 +20,273 @@ function replacer(_, value) {
|
|
|
19
20
|
}
|
|
20
21
|
var cacheKeyFn = (obj) => stringify__default.default(obj, { replacer });
|
|
21
22
|
|
|
23
|
+
// src/loaders/coalescer.ts
|
|
24
|
+
var hashOmit = (args, omit) => {
|
|
25
|
+
const argsObj = {};
|
|
26
|
+
for (const [key, value] of Object.entries(args)) {
|
|
27
|
+
if (!omit.includes(key)) {
|
|
28
|
+
argsObj[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return cacheKeyFn(argsObj);
|
|
32
|
+
};
|
|
33
|
+
function buildCoalescedFetchesByArgsHash(toFetchMap, orphanConfig) {
|
|
34
|
+
const fetchesByArgsHash = {};
|
|
35
|
+
const orphanedFetches = {};
|
|
36
|
+
Object.entries(toFetchMap).forEach(([signature, toFetch]) => {
|
|
37
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
38
|
+
if (orphanConfig.criteria(args)) {
|
|
39
|
+
const toFetch2 = orphanedFetches[signature] ||= [];
|
|
40
|
+
toFetch2.push({ args, promiseCallback });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const argsHash = hashOmit(args, []);
|
|
44
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
45
|
+
args,
|
|
46
|
+
fetches: {}
|
|
47
|
+
};
|
|
48
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
49
|
+
callbacks: []
|
|
50
|
+
};
|
|
51
|
+
promiseCallbacksForSignature.push(promiseCallback);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
Object.entries(orphanedFetches).forEach(([signature, toFetch]) => {
|
|
55
|
+
toFetch.forEach(({ args: orphanArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
56
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
57
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
58
|
+
if (hashOmit(orphanArgs, orphanConfig.hashOmit) === hashOmit(args2, orphanConfig.hashOmit)) {
|
|
59
|
+
const { callbacks: promiseCallbacksForSignature2 } = fetches[signature] ||= {
|
|
60
|
+
callbacks: []
|
|
61
|
+
};
|
|
62
|
+
promiseCallbacksForSignature2.push(orphanPromiseCallback);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const args = orphanConfig.defaults(orphanArgs);
|
|
68
|
+
const argsHash = hashOmit(args, []);
|
|
69
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
70
|
+
args,
|
|
71
|
+
fetches: {}
|
|
72
|
+
};
|
|
73
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
74
|
+
callbacks: []
|
|
75
|
+
};
|
|
76
|
+
promiseCallbacksForSignature.push(orphanPromiseCallback);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return fetchesByArgsHash;
|
|
80
|
+
}
|
|
81
|
+
function buildCoalescedFetchesByArgsHashWithDataSlice(toFetchMap, maxDataSliceByteRange) {
|
|
82
|
+
const fetchesByArgsHash = {};
|
|
83
|
+
const orphanedFetches = {};
|
|
84
|
+
Object.entries(toFetchMap).forEach(([address, toFetch]) => {
|
|
85
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
86
|
+
if (!args.encoding) {
|
|
87
|
+
const toFetch2 = orphanedFetches[address] ||= [];
|
|
88
|
+
toFetch2.push({ args, promiseCallback });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (args.encoding != "base64+zstd" && args.dataSlice) {
|
|
92
|
+
const r = args.dataSlice;
|
|
93
|
+
for (const { fetches: fetchAddresses, args: fetchArgs } of Object.values(fetchesByArgsHash)) {
|
|
94
|
+
const addCallbackWithDataSlice = (updateDataSlice) => {
|
|
95
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetchAddresses[address] ||= {
|
|
96
|
+
callbacks: []
|
|
97
|
+
};
|
|
98
|
+
promiseCallbacksForAddress2.push({
|
|
99
|
+
callback: promiseCallback,
|
|
100
|
+
dataSlice: args.dataSlice ?? null
|
|
101
|
+
});
|
|
102
|
+
if (fetchArgs.dataSlice && updateDataSlice) {
|
|
103
|
+
fetchArgs.dataSlice = updateDataSlice;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (hashOmit(args, ["dataSlice"]) === hashOmit(fetchArgs, ["dataSlice"])) {
|
|
107
|
+
if (fetchArgs.dataSlice) {
|
|
108
|
+
const g = fetchArgs.dataSlice;
|
|
109
|
+
if (r.offset <= g.offset && g.offset - r.offset + r.length <= maxDataSliceByteRange) {
|
|
110
|
+
const length = Math.max(r.length, g.offset + g.length - r.offset);
|
|
111
|
+
const offset = r.offset;
|
|
112
|
+
addCallbackWithDataSlice({ length, offset });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (r.offset >= g.offset && r.offset - g.offset + g.length <= maxDataSliceByteRange) {
|
|
116
|
+
const length = Math.max(g.length, r.offset + r.length - g.offset);
|
|
117
|
+
const offset = g.offset;
|
|
118
|
+
addCallbackWithDataSlice({ length, offset });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
const { length, offset } = r;
|
|
123
|
+
addCallbackWithDataSlice({ length, offset });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const argsHash = hashOmit(args, []);
|
|
130
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
131
|
+
args,
|
|
132
|
+
fetches: {}
|
|
133
|
+
};
|
|
134
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
135
|
+
callbacks: []
|
|
136
|
+
};
|
|
137
|
+
promiseCallbacksForAddress.push({ callback: promiseCallback, dataSlice: args.dataSlice ?? null });
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
Object.entries(orphanedFetches).forEach(([address, toFetch]) => {
|
|
141
|
+
toFetch.forEach(({ args: orphanedArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
142
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
143
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
144
|
+
if (hashOmit(orphanedArgs, ["encoding", "dataSlice"]) === hashOmit(args2, ["encoding", "dataSlice"])) {
|
|
145
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetches[address] ||= {
|
|
146
|
+
callbacks: []
|
|
147
|
+
};
|
|
148
|
+
promiseCallbacksForAddress2.push({ callback: orphanPromiseCallback });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const args = { ...orphanedArgs, encoding: "base64" };
|
|
154
|
+
const argsHash = hashOmit(args, []);
|
|
155
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
156
|
+
args,
|
|
157
|
+
fetches: {}
|
|
158
|
+
};
|
|
159
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
160
|
+
callbacks: []
|
|
161
|
+
};
|
|
162
|
+
promiseCallbacksForAddress.push({ callback: orphanPromiseCallback });
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
return fetchesByArgsHash;
|
|
166
|
+
}
|
|
167
|
+
|
|
22
168
|
// src/loaders/account.ts
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
encoding
|
|
35
|
-
|
|
36
|
-
|
|
169
|
+
function getCodec(encoding) {
|
|
170
|
+
switch (encoding) {
|
|
171
|
+
case "base58":
|
|
172
|
+
return codecsStrings.getBase58Codec();
|
|
173
|
+
default:
|
|
174
|
+
return codecsStrings.getBase64Codec();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function sliceData(account, dataSlice, masterDataSlice) {
|
|
178
|
+
if (dataSlice) {
|
|
179
|
+
const masterOffset = masterDataSlice ? masterDataSlice.offset : 0;
|
|
180
|
+
const slicedData = (data, encoding) => {
|
|
181
|
+
if (encoding === "base64+zstd") {
|
|
182
|
+
return data;
|
|
183
|
+
}
|
|
184
|
+
const { offset, length } = dataSlice;
|
|
185
|
+
const trueOffset = offset - masterOffset;
|
|
186
|
+
const codec = getCodec(encoding);
|
|
187
|
+
return codec.decode(codec.encode(data).slice(trueOffset, trueOffset + length));
|
|
188
|
+
};
|
|
189
|
+
if (Array.isArray(account.data)) {
|
|
190
|
+
const [data, encoding] = account.data;
|
|
191
|
+
return {
|
|
192
|
+
...account,
|
|
193
|
+
data: [slicedData(data, encoding), encoding]
|
|
194
|
+
};
|
|
195
|
+
} else if (typeof account.data === "string") {
|
|
196
|
+
const data = account.data;
|
|
197
|
+
return {
|
|
198
|
+
...account,
|
|
199
|
+
data: slicedData(data, "base58")
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return account;
|
|
37
204
|
}
|
|
38
205
|
async function loadAccount(rpc, { address, ...config }) {
|
|
39
206
|
return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
|
|
40
207
|
}
|
|
41
|
-
function
|
|
208
|
+
async function loadMultipleAccounts(rpc, { addresses, ...config }) {
|
|
209
|
+
return await rpc.getMultipleAccounts(addresses, config).send().then((res) => res.value);
|
|
210
|
+
}
|
|
211
|
+
function createAccountBatchLoadFn(rpc, config) {
|
|
42
212
|
const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
|
|
213
|
+
const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc);
|
|
43
214
|
return async (accountQueryArgs) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
215
|
+
const accountsToFetch = {};
|
|
216
|
+
try {
|
|
217
|
+
return Promise.all(
|
|
218
|
+
accountQueryArgs.map(
|
|
219
|
+
({ address, ...args }) => new Promise((resolve, reject) => {
|
|
220
|
+
const accountRecords = accountsToFetch[address] ||= [];
|
|
221
|
+
if (!args.commitment) {
|
|
222
|
+
args.commitment = "confirmed";
|
|
223
|
+
}
|
|
224
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
} finally {
|
|
229
|
+
const { maxDataSliceByteRange, maxMultipleAccountsBatchSize } = config;
|
|
230
|
+
const accountFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
231
|
+
accountsToFetch,
|
|
232
|
+
maxDataSliceByteRange
|
|
233
|
+
);
|
|
234
|
+
Object.values(accountFetchesByArgsHash).map(({ args, fetches: addressCallbacks }) => {
|
|
235
|
+
const addresses = Object.keys(addressCallbacks);
|
|
236
|
+
if (addresses.length === 1) {
|
|
237
|
+
const address = addresses[0];
|
|
238
|
+
return Array.from({ length: 1 }, async () => {
|
|
239
|
+
try {
|
|
240
|
+
const result = await resolveAccountUsingRpc({ address, ...args });
|
|
241
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
242
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
243
|
+
});
|
|
244
|
+
} catch (e) {
|
|
245
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
246
|
+
callback.reject(e);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
} else {
|
|
251
|
+
return Array.from(
|
|
252
|
+
{ length: Math.ceil(addresses.length / maxMultipleAccountsBatchSize) },
|
|
253
|
+
async (_, ii) => {
|
|
254
|
+
const startIndex = ii * maxMultipleAccountsBatchSize;
|
|
255
|
+
const endIndex = startIndex + maxMultipleAccountsBatchSize;
|
|
256
|
+
const chunk = addresses.slice(startIndex, endIndex);
|
|
257
|
+
try {
|
|
258
|
+
const results = await resolveMultipleAccountsUsingRpc({
|
|
259
|
+
addresses: chunk,
|
|
260
|
+
...args
|
|
261
|
+
});
|
|
262
|
+
chunk.forEach((address, ii2) => {
|
|
263
|
+
const result = results[ii2];
|
|
264
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
265
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
} catch (e) {
|
|
269
|
+
chunk.forEach((address) => {
|
|
270
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
271
|
+
callback.reject(e);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
47
280
|
};
|
|
48
281
|
}
|
|
49
|
-
function createAccountLoader(rpc) {
|
|
50
|
-
const loader = new DataLoader__default.default(createAccountBatchLoadFn(rpc), { cacheKeyFn });
|
|
282
|
+
function createAccountLoader(rpc, config) {
|
|
283
|
+
const loader = new DataLoader__default.default(createAccountBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
51
284
|
return {
|
|
52
|
-
load: async (args) => loader.load(
|
|
285
|
+
load: async (args) => loader.load(args),
|
|
286
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
53
287
|
};
|
|
54
288
|
}
|
|
55
|
-
function
|
|
289
|
+
function applyDefaultArgs({
|
|
56
290
|
slot,
|
|
57
291
|
commitment,
|
|
58
292
|
encoding = "jsonParsed",
|
|
@@ -72,238 +306,437 @@ function applyDefaultArgs2({
|
|
|
72
306
|
async function loadBlock(rpc, { slot, ...config }) {
|
|
73
307
|
return await rpc.getBlock(
|
|
74
308
|
slot,
|
|
75
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
309
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
76
310
|
config
|
|
77
311
|
).send();
|
|
78
312
|
}
|
|
79
313
|
function createBlockBatchLoadFn(rpc) {
|
|
80
314
|
const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
|
|
81
|
-
return async (blockQueryArgs) =>
|
|
82
|
-
return await Promise.all(blockQueryArgs.map(async (args) => await resolveBlockUsingRpc(applyDefaultArgs2(args))));
|
|
83
|
-
};
|
|
315
|
+
return async (blockQueryArgs) => Promise.all(blockQueryArgs.map(async (args) => resolveBlockUsingRpc(applyDefaultArgs(args))));
|
|
84
316
|
}
|
|
85
317
|
function createBlockLoader(rpc) {
|
|
86
318
|
const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
|
|
87
319
|
return {
|
|
88
|
-
load: async (args) => loader.load(
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
function applyDefaultArgs3({
|
|
92
|
-
commitment,
|
|
93
|
-
dataSlice,
|
|
94
|
-
encoding = "jsonParsed",
|
|
95
|
-
filters,
|
|
96
|
-
minContextSlot,
|
|
97
|
-
programAddress
|
|
98
|
-
}) {
|
|
99
|
-
return {
|
|
100
|
-
commitment,
|
|
101
|
-
dataSlice,
|
|
102
|
-
encoding,
|
|
103
|
-
filters,
|
|
104
|
-
minContextSlot,
|
|
105
|
-
programAddress
|
|
320
|
+
load: async (args) => loader.load(applyDefaultArgs(args)),
|
|
321
|
+
loadMany: async (args) => loader.loadMany(args.map(applyDefaultArgs))
|
|
106
322
|
};
|
|
107
323
|
}
|
|
108
324
|
async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
109
325
|
return await rpc.getProgramAccounts(
|
|
110
326
|
programAddress,
|
|
111
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
327
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
112
328
|
config
|
|
113
329
|
).send();
|
|
114
330
|
}
|
|
115
|
-
function createProgramAccountsBatchLoadFn(rpc) {
|
|
331
|
+
function createProgramAccountsBatchLoadFn(rpc, config) {
|
|
116
332
|
const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
|
|
117
|
-
return async (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
333
|
+
return async (accountQueryArgs) => {
|
|
334
|
+
const programAccountsToFetch = {};
|
|
335
|
+
try {
|
|
336
|
+
return Promise.all(accountQueryArgs.map(
|
|
337
|
+
({ programAddress, ...args }) => new Promise((resolve, reject) => {
|
|
338
|
+
const accountRecords = programAccountsToFetch[programAddress] ||= [];
|
|
339
|
+
if (!args.commitment) {
|
|
340
|
+
args.commitment = "confirmed";
|
|
341
|
+
}
|
|
342
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
343
|
+
})
|
|
344
|
+
));
|
|
345
|
+
} finally {
|
|
346
|
+
const { maxDataSliceByteRange } = config;
|
|
347
|
+
const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(programAccountsToFetch, maxDataSliceByteRange);
|
|
348
|
+
Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
|
|
349
|
+
return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
|
|
350
|
+
return Array.from({ length: 1 }, async () => {
|
|
351
|
+
try {
|
|
352
|
+
const result = await resolveProgramAccountsUsingRpc({
|
|
353
|
+
programAddress,
|
|
354
|
+
...args
|
|
355
|
+
});
|
|
356
|
+
callbacks.forEach(({ callback, dataSlice }) => {
|
|
357
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
358
|
+
});
|
|
359
|
+
} catch (e) {
|
|
360
|
+
callbacks.forEach(({ callback }) => {
|
|
361
|
+
callback.reject(e);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
}
|
|
127
368
|
};
|
|
128
369
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
encoding = "jsonParsed",
|
|
132
|
-
signature
|
|
133
|
-
}) {
|
|
370
|
+
function createProgramAccountsLoader(rpc, config) {
|
|
371
|
+
const loader = new DataLoader__default.default(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
134
372
|
return {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
signature
|
|
373
|
+
load: async (args) => loader.load(args),
|
|
374
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
138
375
|
};
|
|
139
376
|
}
|
|
140
377
|
async function loadTransaction(rpc, { signature, ...config }) {
|
|
141
378
|
return await rpc.getTransaction(
|
|
142
379
|
signature,
|
|
143
|
-
// @ts-expect-error FIX ME: https://github.com/
|
|
380
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
144
381
|
config
|
|
145
382
|
).send();
|
|
146
383
|
}
|
|
147
384
|
function createTransactionBatchLoadFn(rpc) {
|
|
148
385
|
const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
|
|
149
386
|
return async (transactionQueryArgs) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
387
|
+
const transactionsToFetch = {};
|
|
388
|
+
try {
|
|
389
|
+
return Promise.all(transactionQueryArgs.map(
|
|
390
|
+
({ signature, ...args }) => new Promise((resolve, reject) => {
|
|
391
|
+
const transactionRecords = transactionsToFetch[signature] ||= [];
|
|
392
|
+
if (!args.commitment) {
|
|
393
|
+
args.commitment = "confirmed";
|
|
394
|
+
}
|
|
395
|
+
transactionRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
396
|
+
})
|
|
397
|
+
));
|
|
398
|
+
} finally {
|
|
399
|
+
const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
|
|
400
|
+
criteria: (args) => args.encoding === void 0,
|
|
401
|
+
defaults: (args) => ({ ...args, encoding: "base64" }),
|
|
402
|
+
hashOmit: ["encoding"]
|
|
403
|
+
});
|
|
404
|
+
Object.values(transactionFetchesByArgsHash).map(({ args, fetches: transactionCallbacks }) => {
|
|
405
|
+
return Object.entries(transactionCallbacks).map(([signature, { callbacks }]) => {
|
|
406
|
+
return Array.from({ length: 1 }, async () => {
|
|
407
|
+
try {
|
|
408
|
+
const result = await resolveTransactionUsingRpc({
|
|
409
|
+
signature,
|
|
410
|
+
...args
|
|
411
|
+
});
|
|
412
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
413
|
+
} catch (e) {
|
|
414
|
+
callbacks.forEach((c) => c.reject(e));
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
}
|
|
153
420
|
};
|
|
154
421
|
}
|
|
155
422
|
function createTransactionLoader(rpc) {
|
|
156
423
|
const loader = new DataLoader__default.default(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
|
|
157
424
|
return {
|
|
158
|
-
load: async (args) => loader.load(
|
|
425
|
+
load: async (args) => loader.load(args),
|
|
426
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
159
427
|
};
|
|
160
428
|
}
|
|
161
429
|
|
|
162
430
|
// src/context.ts
|
|
163
|
-
function createSolanaGraphQLContext(rpc) {
|
|
431
|
+
function createSolanaGraphQLContext(rpc, config) {
|
|
164
432
|
return {
|
|
165
433
|
loaders: {
|
|
166
|
-
account: createAccountLoader(rpc),
|
|
434
|
+
account: createAccountLoader(rpc, config),
|
|
167
435
|
block: createBlockLoader(rpc),
|
|
168
|
-
programAccounts: createProgramAccountsLoader(rpc),
|
|
436
|
+
programAccounts: createProgramAccountsLoader(rpc, config),
|
|
169
437
|
transaction: createTransactionLoader(rpc)
|
|
170
438
|
}
|
|
171
439
|
};
|
|
172
440
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
441
|
+
function injectableRootVisitor(info, rootNode, operations) {
|
|
442
|
+
const { fieldNodes } = info;
|
|
443
|
+
const root = rootNode ?? fieldNodes[0];
|
|
444
|
+
const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
|
|
445
|
+
graphql.visit(root, {
|
|
446
|
+
Field(node, key, parent, path, ancestors) {
|
|
447
|
+
if (!parentIsRoot(ancestors))
|
|
448
|
+
return;
|
|
449
|
+
return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
|
|
450
|
+
},
|
|
451
|
+
FragmentSpread(node, key, parent, path, ancestors) {
|
|
452
|
+
const fragmentDefinition = info.fragments[node.name.value];
|
|
453
|
+
return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
|
|
454
|
+
},
|
|
455
|
+
InlineFragment(node, key, parent, path, ancestors) {
|
|
456
|
+
if (!parentIsRoot(ancestors))
|
|
457
|
+
return;
|
|
458
|
+
return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function onlyFieldsRequested(fieldNames, info, rootNode) {
|
|
463
|
+
let onlyFieldsRequested2 = true;
|
|
464
|
+
function checkFieldsWithVisitor(root) {
|
|
465
|
+
injectableRootVisitor(info, root, {
|
|
466
|
+
fieldNodeOperation(_info, node) {
|
|
467
|
+
onlyFieldsRequested2 = fieldNames.includes(node.name.value);
|
|
468
|
+
if (!onlyFieldsRequested2) {
|
|
469
|
+
return graphql.BREAK;
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
473
|
+
checkFieldsWithVisitor(fragment);
|
|
474
|
+
},
|
|
475
|
+
inlineFragmentNodeOperation(_info, node) {
|
|
476
|
+
checkFieldsWithVisitor(node);
|
|
181
477
|
}
|
|
182
|
-
return null;
|
|
183
478
|
});
|
|
184
|
-
|
|
185
|
-
|
|
479
|
+
}
|
|
480
|
+
checkFieldsWithVisitor(rootNode ?? null);
|
|
481
|
+
return onlyFieldsRequested2;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/resolvers/resolve-info/account.ts
|
|
485
|
+
function findArgumentNodeByName(argumentNodes, name) {
|
|
486
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
487
|
+
}
|
|
488
|
+
function parseAccountEncodingArgument(argumentNodes, variableValues) {
|
|
489
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
|
|
490
|
+
if (argumentNode) {
|
|
491
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
492
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
493
|
+
return "base58";
|
|
494
|
+
}
|
|
495
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
496
|
+
return "base64";
|
|
497
|
+
}
|
|
498
|
+
if (argumentNode.value.value === "BASE_64_ZSTD") {
|
|
499
|
+
return "base64+zstd";
|
|
500
|
+
}
|
|
186
501
|
}
|
|
502
|
+
if (argumentNode.value.kind === "Variable") {
|
|
503
|
+
return variableValues[argumentNode.value.name.value];
|
|
504
|
+
}
|
|
505
|
+
} else {
|
|
506
|
+
return void 0;
|
|
187
507
|
}
|
|
188
|
-
|
|
508
|
+
}
|
|
509
|
+
function parseAccountDataSliceArgument(argumentNodes, variableValues) {
|
|
510
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
|
|
511
|
+
if (argumentNode) {
|
|
512
|
+
if (argumentNode.value.kind === "ObjectValue") {
|
|
513
|
+
const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
|
|
514
|
+
const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
|
|
515
|
+
const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
|
|
516
|
+
const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
|
|
517
|
+
return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
|
|
518
|
+
}
|
|
519
|
+
if (argumentNode.value.kind === "Variable") {
|
|
520
|
+
return variableValues[argumentNode.value.name.value];
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
return void 0;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function buildAccountArgSetWithVisitor(args, info) {
|
|
527
|
+
const argSet = [args];
|
|
528
|
+
function buildArgSetWithVisitor(root) {
|
|
529
|
+
injectableRootVisitor(info, root, {
|
|
530
|
+
fieldNodeOperation(info2, node) {
|
|
531
|
+
if (node.name.value !== "data") {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (node.arguments) {
|
|
535
|
+
const { variableValues } = info2;
|
|
536
|
+
const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
|
|
537
|
+
const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
|
|
538
|
+
argSet.push({ ...args, dataSlice, encoding });
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
542
|
+
buildArgSetWithVisitor(fragment);
|
|
543
|
+
},
|
|
544
|
+
inlineFragmentNodeOperation(info2, node) {
|
|
545
|
+
const { schema } = info2;
|
|
546
|
+
const accountInterface = schema.getType("Account");
|
|
547
|
+
if (graphql.isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
|
|
548
|
+
// fields outside of the `Account` interface.
|
|
549
|
+
!onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
|
|
550
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
buildArgSetWithVisitor(null);
|
|
556
|
+
return argSet;
|
|
557
|
+
}
|
|
558
|
+
function buildAccountLoaderArgSetFromResolveInfo(args, info) {
|
|
559
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
189
560
|
}
|
|
190
561
|
|
|
191
|
-
// src/resolvers/
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
parsed: { info: result, type: accountType },
|
|
195
|
-
program: programName,
|
|
196
|
-
programId
|
|
197
|
-
} = parsedAccountData;
|
|
198
|
-
result.accountType = accountType;
|
|
199
|
-
result.programId = programId;
|
|
200
|
-
result.programName = programName;
|
|
201
|
-
return result;
|
|
562
|
+
// src/resolvers/resolve-info/program-accounts.ts
|
|
563
|
+
function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
|
|
564
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
202
565
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}) {
|
|
208
|
-
const [
|
|
209
|
-
// The account's data, either encoded or parsed.
|
|
210
|
-
data,
|
|
211
|
-
// Tells GraphQL which encoding has been returned
|
|
212
|
-
// by the RPC.
|
|
213
|
-
responseEncoding
|
|
214
|
-
] = Array.isArray(account.data) ? encoding === "jsonParsed" ? (
|
|
215
|
-
// The requested encoding is jsonParsed,
|
|
216
|
-
// but the data could not be parsed.
|
|
217
|
-
// Defaults to base64 encoding.
|
|
218
|
-
[{ data: account.data[0] }, "base64"]
|
|
219
|
-
) : (
|
|
220
|
-
// The requested encoding is base58,
|
|
221
|
-
// base64, or base64+zstd.
|
|
222
|
-
[{ data: account.data[0] }, encoding]
|
|
223
|
-
) : (
|
|
224
|
-
// The account data was returned as an object,
|
|
225
|
-
// so it was parsed successfully.
|
|
226
|
-
[transformParsedAccountData(account.data), "jsonParsed"]
|
|
227
|
-
);
|
|
228
|
-
account.address = address;
|
|
229
|
-
account.encoding = responseEncoding;
|
|
230
|
-
account.ownerProgram = account.owner;
|
|
231
|
-
return {
|
|
232
|
-
...account,
|
|
233
|
-
...data
|
|
234
|
-
};
|
|
566
|
+
|
|
567
|
+
// src/resolvers/resolve-info/transaction.ts
|
|
568
|
+
function findArgumentNodeByName2(argumentNodes, name) {
|
|
569
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
235
570
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
if (
|
|
240
|
-
|
|
571
|
+
function parseTransactionEncodingArgument(argumentNodes, variableValues) {
|
|
572
|
+
const argumentNode = findArgumentNodeByName2(argumentNodes, "encoding");
|
|
573
|
+
if (argumentNode) {
|
|
574
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
575
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
576
|
+
return "base58";
|
|
577
|
+
}
|
|
578
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
579
|
+
return "base64";
|
|
580
|
+
}
|
|
241
581
|
}
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
582
|
+
if (argumentNode.value.kind === "Variable") {
|
|
583
|
+
return variableValues[argumentNode.value.name.value];
|
|
244
584
|
}
|
|
245
|
-
|
|
246
|
-
return
|
|
585
|
+
} else {
|
|
586
|
+
return void 0;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
|
|
590
|
+
const argSet = [args];
|
|
591
|
+
function buildArgSetWithVisitor(root) {
|
|
592
|
+
injectableRootVisitor(info, root, {
|
|
593
|
+
fieldNodeOperation(info2, node) {
|
|
594
|
+
if (node.name.value === "message" || node.name.value === "meta") {
|
|
595
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
596
|
+
} else if (node.name.value === "data") {
|
|
597
|
+
if (node.arguments) {
|
|
598
|
+
const { variableValues } = info2;
|
|
599
|
+
const encoding = parseTransactionEncodingArgument(
|
|
600
|
+
node.arguments,
|
|
601
|
+
variableValues
|
|
602
|
+
);
|
|
603
|
+
argSet.push({ ...args, encoding });
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
608
|
+
buildArgSetWithVisitor(fragment);
|
|
609
|
+
},
|
|
610
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
buildArgSetWithVisitor(null);
|
|
616
|
+
return argSet;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
// src/resolvers/account.ts
|
|
620
|
+
var resolveAccountData = () => {
|
|
621
|
+
return (parent, args) => {
|
|
622
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
247
623
|
};
|
|
248
624
|
};
|
|
249
|
-
var
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (account.encoding === "base64") {
|
|
256
|
-
return "AccountBase64";
|
|
257
|
-
}
|
|
258
|
-
if (account.encoding === "base64+zstd") {
|
|
259
|
-
return "AccountBase64Zstd";
|
|
625
|
+
var resolveAccount = (fieldName) => {
|
|
626
|
+
return async (parent, args, context, info) => {
|
|
627
|
+
const address = fieldName ? parent[fieldName] : args.address;
|
|
628
|
+
if (address) {
|
|
629
|
+
if (onlyFieldsRequested(["address"], info)) {
|
|
630
|
+
return { address };
|
|
260
631
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (account
|
|
269
|
-
|
|
632
|
+
const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
|
|
633
|
+
const loadedAccounts = await context.loaders.account.loadMany(argsSet);
|
|
634
|
+
let result = {
|
|
635
|
+
address,
|
|
636
|
+
encodedData: {}
|
|
637
|
+
};
|
|
638
|
+
loadedAccounts.forEach((account, i) => {
|
|
639
|
+
if (account instanceof Error) {
|
|
640
|
+
console.error(account);
|
|
641
|
+
return;
|
|
270
642
|
}
|
|
271
|
-
if (account
|
|
272
|
-
return
|
|
643
|
+
if (account === null) {
|
|
644
|
+
return;
|
|
273
645
|
}
|
|
274
|
-
if (
|
|
275
|
-
|
|
646
|
+
if (!result.ownerProgram) {
|
|
647
|
+
result = {
|
|
648
|
+
...result,
|
|
649
|
+
...account,
|
|
650
|
+
ownerProgram: account.owner
|
|
651
|
+
};
|
|
276
652
|
}
|
|
277
|
-
|
|
278
|
-
|
|
653
|
+
const { data } = account;
|
|
654
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
655
|
+
if (encoding && result.encodedData) {
|
|
656
|
+
if (Array.isArray(data)) {
|
|
657
|
+
result.encodedData[cacheKeyFn({
|
|
658
|
+
dataSlice,
|
|
659
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
660
|
+
})] = data[0];
|
|
661
|
+
} else if (typeof data === "string") {
|
|
662
|
+
result.encodedData[cacheKeyFn({
|
|
663
|
+
dataSlice,
|
|
664
|
+
encoding: "base58"
|
|
665
|
+
})] = data;
|
|
666
|
+
} else if (typeof data === "object") {
|
|
667
|
+
const {
|
|
668
|
+
parsed: { info: parsedData, type: accountType },
|
|
669
|
+
program: programName,
|
|
670
|
+
programId
|
|
671
|
+
} = data;
|
|
672
|
+
result.jsonParsedConfigs = {
|
|
673
|
+
accountType,
|
|
674
|
+
programId,
|
|
675
|
+
programName
|
|
676
|
+
};
|
|
677
|
+
result = {
|
|
678
|
+
...result,
|
|
679
|
+
...parsedData
|
|
680
|
+
};
|
|
681
|
+
}
|
|
279
682
|
}
|
|
280
|
-
}
|
|
281
|
-
return
|
|
683
|
+
});
|
|
684
|
+
return result;
|
|
282
685
|
}
|
|
686
|
+
return null;
|
|
687
|
+
};
|
|
688
|
+
};
|
|
689
|
+
function resolveAccountType(accountResult) {
|
|
690
|
+
const { jsonParsedConfigs } = accountResult;
|
|
691
|
+
if (jsonParsedConfigs) {
|
|
692
|
+
if (jsonParsedConfigs.programName === "nonce") {
|
|
693
|
+
return "NonceAccount";
|
|
694
|
+
}
|
|
695
|
+
if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
|
|
696
|
+
return "MintAccount";
|
|
697
|
+
}
|
|
698
|
+
if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
|
|
699
|
+
return "TokenAccount";
|
|
700
|
+
}
|
|
701
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
702
|
+
return "StakeAccount";
|
|
703
|
+
}
|
|
704
|
+
if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
|
|
705
|
+
return "VoteAccount";
|
|
706
|
+
}
|
|
707
|
+
if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
|
|
708
|
+
return "LookupTableAccount";
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return "GenericAccount";
|
|
712
|
+
}
|
|
713
|
+
var accountResolvers = {
|
|
714
|
+
Account: {
|
|
715
|
+
__resolveType: resolveAccountType,
|
|
716
|
+
data: resolveAccountData()
|
|
283
717
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
AccountBase64: {
|
|
288
|
-
ownerProgram: resolveAccount("ownerProgram")
|
|
289
|
-
},
|
|
290
|
-
AccountBase64Zstd: {
|
|
718
|
+
GenericAccount: {
|
|
719
|
+
data: resolveAccountData(),
|
|
291
720
|
ownerProgram: resolveAccount("ownerProgram")
|
|
292
721
|
},
|
|
293
722
|
LookupTableAccount: {
|
|
294
723
|
authority: resolveAccount("authority"),
|
|
724
|
+
data: resolveAccountData(),
|
|
295
725
|
ownerProgram: resolveAccount("ownerProgram")
|
|
296
726
|
},
|
|
297
727
|
MintAccount: {
|
|
728
|
+
data: resolveAccountData(),
|
|
298
729
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
299
730
|
mintAuthority: resolveAccount("mintAuthority"),
|
|
300
731
|
ownerProgram: resolveAccount("ownerProgram")
|
|
301
732
|
},
|
|
302
733
|
NonceAccount: {
|
|
303
734
|
authority: resolveAccount("authority"),
|
|
735
|
+
data: resolveAccountData(),
|
|
304
736
|
ownerProgram: resolveAccount("ownerProgram")
|
|
305
737
|
},
|
|
306
738
|
StakeAccount: {
|
|
739
|
+
data: resolveAccountData(),
|
|
307
740
|
ownerProgram: resolveAccount("ownerProgram")
|
|
308
741
|
},
|
|
309
742
|
StakeAccountDataMetaAuthorized: {
|
|
@@ -317,12 +750,14 @@ var accountResolvers = {
|
|
|
317
750
|
voter: resolveAccount("voter")
|
|
318
751
|
},
|
|
319
752
|
TokenAccount: {
|
|
753
|
+
data: resolveAccountData(),
|
|
320
754
|
mint: resolveAccount("mint"),
|
|
321
755
|
owner: resolveAccount("owner"),
|
|
322
756
|
ownerProgram: resolveAccount("ownerProgram")
|
|
323
757
|
},
|
|
324
758
|
VoteAccount: {
|
|
325
759
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
760
|
+
data: resolveAccountData(),
|
|
326
761
|
node: resolveAccount("nodePubkey"),
|
|
327
762
|
ownerProgram: resolveAccount("ownerProgram")
|
|
328
763
|
},
|
|
@@ -331,7 +766,7 @@ var accountResolvers = {
|
|
|
331
766
|
}
|
|
332
767
|
};
|
|
333
768
|
|
|
334
|
-
// src/resolvers/
|
|
769
|
+
// src/resolvers/block.ts
|
|
335
770
|
function transformParsedInstruction(parsedInstruction) {
|
|
336
771
|
if ("parsed" in parsedInstruction) {
|
|
337
772
|
if (typeof parsedInstruction.parsed === "string" && parsedInstruction.program === "spl-memo") {
|
|
@@ -376,49 +811,6 @@ function transformLoadedTransaction({
|
|
|
376
811
|
transaction.meta = transactionMeta;
|
|
377
812
|
return transaction;
|
|
378
813
|
}
|
|
379
|
-
function resolveTransaction(fieldName) {
|
|
380
|
-
return async (parent, args, context, info) => {
|
|
381
|
-
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
382
|
-
if (!signature) {
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
if (onlyPresentFieldRequested("signature", info)) {
|
|
386
|
-
return { signature };
|
|
387
|
-
}
|
|
388
|
-
const transaction = await context.loaders.transaction.load({ ...args, signature });
|
|
389
|
-
if (!transaction) {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
if (args.encoding !== "jsonParsed") {
|
|
393
|
-
const transactionJsonParsed = await context.loaders.transaction.load({
|
|
394
|
-
...args,
|
|
395
|
-
encoding: "jsonParsed",
|
|
396
|
-
signature
|
|
397
|
-
});
|
|
398
|
-
if (transactionJsonParsed === null) {
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
transaction.meta = transactionJsonParsed.meta;
|
|
402
|
-
}
|
|
403
|
-
return transformLoadedTransaction({ encoding: args.encoding, transaction });
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
var transactionResolvers = {
|
|
407
|
-
Transaction: {
|
|
408
|
-
__resolveType(transaction) {
|
|
409
|
-
switch (transaction.encoding) {
|
|
410
|
-
case "base58":
|
|
411
|
-
return "TransactionBase58";
|
|
412
|
-
case "base64":
|
|
413
|
-
return "TransactionBase64";
|
|
414
|
-
default:
|
|
415
|
-
return "TransactionParsed";
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
// src/resolvers/block.ts
|
|
422
814
|
function transformLoadedBlock({
|
|
423
815
|
block,
|
|
424
816
|
encoding = "jsonParsed",
|
|
@@ -448,7 +840,7 @@ var resolveBlock = (fieldName) => {
|
|
|
448
840
|
if (!slot) {
|
|
449
841
|
return null;
|
|
450
842
|
}
|
|
451
|
-
if (
|
|
843
|
+
if (onlyFieldsRequested(["slot"], info)) {
|
|
452
844
|
return { slot };
|
|
453
845
|
}
|
|
454
846
|
const block = await context.loaders.block.load({ ...args, slot });
|
|
@@ -480,7 +872,8 @@ var blockResolvers = {
|
|
|
480
872
|
var instructionResolvers = {
|
|
481
873
|
AdvanceNonceAccountInstruction: {
|
|
482
874
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
483
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
875
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
876
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
|
|
484
877
|
},
|
|
485
878
|
AllocateInstruction: {
|
|
486
879
|
account: resolveAccount("account")
|
|
@@ -517,9 +910,11 @@ var instructionResolvers = {
|
|
|
517
910
|
BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
|
|
518
911
|
authority: resolveAccount("authority"),
|
|
519
912
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
913
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
520
914
|
payerAccount: resolveAccount("payerAccount"),
|
|
521
915
|
programAccount: resolveAccount("programAccount"),
|
|
522
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
916
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
917
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
523
918
|
},
|
|
524
919
|
BpfUpgradeableLoaderExtendProgramInstruction: {
|
|
525
920
|
payerAccount: resolveAccount("payerAccount"),
|
|
@@ -543,8 +938,10 @@ var instructionResolvers = {
|
|
|
543
938
|
BpfUpgradeableLoaderUpgradeInstruction: {
|
|
544
939
|
authority: resolveAccount("authority"),
|
|
545
940
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
941
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
546
942
|
programAccount: resolveAccount("programAccount"),
|
|
547
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
943
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
944
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
548
945
|
},
|
|
549
946
|
BpfUpgradeableLoaderWriteInstruction: {
|
|
550
947
|
account: resolveAccount("account"),
|
|
@@ -587,7 +984,9 @@ var instructionResolvers = {
|
|
|
587
984
|
},
|
|
588
985
|
InitializeNonceAccountInstruction: {
|
|
589
986
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
590
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
987
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
988
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
989
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
591
990
|
},
|
|
592
991
|
Lockup: {
|
|
593
992
|
custodian: resolveAccount("custodian")
|
|
@@ -663,7 +1062,8 @@ var instructionResolvers = {
|
|
|
663
1062
|
SplTokenInitializeAccount2Instruction: {
|
|
664
1063
|
account: resolveAccount("account"),
|
|
665
1064
|
mint: resolveAccount("mint"),
|
|
666
|
-
owner: resolveAccount("owner")
|
|
1065
|
+
owner: resolveAccount("owner"),
|
|
1066
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
667
1067
|
},
|
|
668
1068
|
SplTokenInitializeAccount3Instruction: {
|
|
669
1069
|
account: resolveAccount("account"),
|
|
@@ -673,7 +1073,8 @@ var instructionResolvers = {
|
|
|
673
1073
|
SplTokenInitializeAccountInstruction: {
|
|
674
1074
|
account: resolveAccount("account"),
|
|
675
1075
|
mint: resolveAccount("mint"),
|
|
676
|
-
owner: resolveAccount("owner")
|
|
1076
|
+
owner: resolveAccount("owner"),
|
|
1077
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
677
1078
|
},
|
|
678
1079
|
SplTokenInitializeMint2Instruction: {
|
|
679
1080
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
@@ -687,13 +1088,15 @@ var instructionResolvers = {
|
|
|
687
1088
|
SplTokenInitializeMintInstruction: {
|
|
688
1089
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
689
1090
|
mint: resolveAccount("mint"),
|
|
690
|
-
mintAuthority: resolveAccount("mintAuthority")
|
|
1091
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1092
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
691
1093
|
},
|
|
692
1094
|
SplTokenInitializeMultisig2Instruction: {
|
|
693
1095
|
multisig: resolveAccount("multisig")
|
|
694
1096
|
},
|
|
695
1097
|
SplTokenInitializeMultisigInstruction: {
|
|
696
|
-
multisig: resolveAccount("multisig")
|
|
1098
|
+
multisig: resolveAccount("multisig"),
|
|
1099
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
697
1100
|
},
|
|
698
1101
|
SplTokenMintToCheckedInstruction: {
|
|
699
1102
|
account: resolveAccount("account"),
|
|
@@ -746,6 +1149,7 @@ var instructionResolvers = {
|
|
|
746
1149
|
},
|
|
747
1150
|
StakeAuthorizeCheckedInstruction: {
|
|
748
1151
|
authority: resolveAccount("authority"),
|
|
1152
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
749
1153
|
custodian: resolveAccount("custodian"),
|
|
750
1154
|
newAuthority: resolveAccount("newAuthority"),
|
|
751
1155
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -753,12 +1157,14 @@ var instructionResolvers = {
|
|
|
753
1157
|
StakeAuthorizeCheckedWithSeedInstruction: {
|
|
754
1158
|
authorityBase: resolveAccount("authorityBase"),
|
|
755
1159
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1160
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
756
1161
|
custodian: resolveAccount("custodian"),
|
|
757
1162
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
758
1163
|
stakeAccount: resolveAccount("stakeAccount")
|
|
759
1164
|
},
|
|
760
1165
|
StakeAuthorizeInstruction: {
|
|
761
1166
|
authority: resolveAccount("authority"),
|
|
1167
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
762
1168
|
custodian: resolveAccount("custodian"),
|
|
763
1169
|
newAuthority: resolveAccount("newAuthority"),
|
|
764
1170
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -766,6 +1172,7 @@ var instructionResolvers = {
|
|
|
766
1172
|
StakeAuthorizeWithSeedInstruction: {
|
|
767
1173
|
authorityBase: resolveAccount("authorityBase"),
|
|
768
1174
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1175
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
769
1176
|
custodian: resolveAccount("custodian"),
|
|
770
1177
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
771
1178
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -776,20 +1183,28 @@ var instructionResolvers = {
|
|
|
776
1183
|
voteAccount: resolveAccount("voteAccount")
|
|
777
1184
|
},
|
|
778
1185
|
StakeDeactivateInstruction: {
|
|
1186
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
779
1187
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
780
1188
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
781
1189
|
},
|
|
782
1190
|
StakeDelegateStakeInstruction: {
|
|
1191
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
783
1192
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
784
1193
|
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
785
1194
|
stakeConfigAccount: resolveAccount("stakeConfigAccount"),
|
|
1195
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
|
|
786
1196
|
voteAccount: resolveAccount("voteAccount")
|
|
787
1197
|
},
|
|
1198
|
+
StakeInitializeCheckedInstruction: {
|
|
1199
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1200
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1201
|
+
},
|
|
788
1202
|
StakeInitializeCheckedInstructionDataAuthorized: {
|
|
789
1203
|
staker: resolveAccount("staker"),
|
|
790
1204
|
withdrawer: resolveAccount("withdrawer")
|
|
791
1205
|
},
|
|
792
1206
|
StakeInitializeInstruction: {
|
|
1207
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
793
1208
|
stakeAccount: resolveAccount("stakeAccount")
|
|
794
1209
|
},
|
|
795
1210
|
StakeInitializeInstructionDataAuthorized: {
|
|
@@ -797,9 +1212,11 @@ var instructionResolvers = {
|
|
|
797
1212
|
withdrawer: resolveAccount("withdrawer")
|
|
798
1213
|
},
|
|
799
1214
|
StakeMergeInstruction: {
|
|
1215
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
800
1216
|
destination: resolveAccount("destination"),
|
|
801
1217
|
source: resolveAccount("source"),
|
|
802
|
-
stakeAuthority: resolveAccount("stakeAuthority")
|
|
1218
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1219
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
|
|
803
1220
|
},
|
|
804
1221
|
StakeRedelegateInstruction: {
|
|
805
1222
|
newStakeAccount: resolveAccount("newStakeAccount"),
|
|
@@ -822,287 +1239,289 @@ var instructionResolvers = {
|
|
|
822
1239
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
823
1240
|
},
|
|
824
1241
|
StakeWithdrawInstruction: {
|
|
1242
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
825
1243
|
destination: resolveAccount("destination"),
|
|
826
1244
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
827
1245
|
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
828
1246
|
},
|
|
829
1247
|
TransactionInstruction: {
|
|
830
|
-
__resolveType(
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1248
|
+
__resolveType(instructionResult) {
|
|
1249
|
+
const { jsonParsedConfigs } = instructionResult;
|
|
1250
|
+
if (jsonParsedConfigs) {
|
|
1251
|
+
if (jsonParsedConfigs.programName === "address-lookup-table") {
|
|
1252
|
+
if (jsonParsedConfigs.instructionType === "createLookupTable") {
|
|
834
1253
|
return "CreateLookupTableInstruction";
|
|
835
1254
|
}
|
|
836
|
-
if (
|
|
1255
|
+
if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
|
|
837
1256
|
return "FreezeLookupTableInstruction";
|
|
838
1257
|
}
|
|
839
|
-
if (
|
|
1258
|
+
if (jsonParsedConfigs.instructionType === "extendLookupTable") {
|
|
840
1259
|
return "ExtendLookupTableInstruction";
|
|
841
1260
|
}
|
|
842
|
-
if (
|
|
1261
|
+
if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
|
|
843
1262
|
return "DeactivateLookupTableInstruction";
|
|
844
1263
|
}
|
|
845
|
-
if (
|
|
1264
|
+
if (jsonParsedConfigs.instructionType === "closeLookupTable") {
|
|
846
1265
|
return "CloseLookupTableInstruction";
|
|
847
1266
|
}
|
|
848
1267
|
}
|
|
849
|
-
if (
|
|
850
|
-
if (
|
|
1268
|
+
if (jsonParsedConfigs.programName === "bpf-loader") {
|
|
1269
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
851
1270
|
return "BpfLoaderWriteInstruction";
|
|
852
1271
|
}
|
|
853
|
-
if (
|
|
1272
|
+
if (jsonParsedConfigs.instructionType === "finalize") {
|
|
854
1273
|
return "BpfLoaderFinalizeInstruction";
|
|
855
1274
|
}
|
|
856
1275
|
}
|
|
857
|
-
if (
|
|
858
|
-
if (
|
|
1276
|
+
if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
|
|
1277
|
+
if (jsonParsedConfigs.instructionType === "initializeBuffer") {
|
|
859
1278
|
return "BpfUpgradeableLoaderInitializeBufferInstruction";
|
|
860
1279
|
}
|
|
861
|
-
if (
|
|
1280
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
862
1281
|
return "BpfUpgradeableLoaderWriteInstruction";
|
|
863
1282
|
}
|
|
864
|
-
if (
|
|
1283
|
+
if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
|
|
865
1284
|
return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
|
|
866
1285
|
}
|
|
867
|
-
if (
|
|
1286
|
+
if (jsonParsedConfigs.instructionType === "upgrade") {
|
|
868
1287
|
return "BpfUpgradeableLoaderUpgradeInstruction";
|
|
869
1288
|
}
|
|
870
|
-
if (
|
|
1289
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
871
1290
|
return "BpfUpgradeableLoaderSetAuthorityInstruction";
|
|
872
1291
|
}
|
|
873
|
-
if (
|
|
1292
|
+
if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
|
|
874
1293
|
return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
|
|
875
1294
|
}
|
|
876
|
-
if (
|
|
1295
|
+
if (jsonParsedConfigs.instructionType === "close") {
|
|
877
1296
|
return "BpfUpgradeableLoaderCloseInstruction";
|
|
878
1297
|
}
|
|
879
|
-
if (
|
|
1298
|
+
if (jsonParsedConfigs.instructionType === "extendProgram") {
|
|
880
1299
|
return "BpfUpgradeableLoaderExtendProgramInstruction";
|
|
881
1300
|
}
|
|
882
1301
|
}
|
|
883
|
-
if (
|
|
884
|
-
if (
|
|
1302
|
+
if (jsonParsedConfigs.programName === "spl-associated-token-account") {
|
|
1303
|
+
if (jsonParsedConfigs.instructionType === "create") {
|
|
885
1304
|
return "SplAssociatedTokenCreateInstruction";
|
|
886
1305
|
}
|
|
887
|
-
if (
|
|
1306
|
+
if (jsonParsedConfigs.instructionType === "createIdempotent") {
|
|
888
1307
|
return "SplAssociatedTokenCreateIdempotentInstruction";
|
|
889
1308
|
}
|
|
890
|
-
if (
|
|
1309
|
+
if (jsonParsedConfigs.instructionType === "recoverNested") {
|
|
891
1310
|
return "SplAssociatedTokenRecoverNestedInstruction";
|
|
892
1311
|
}
|
|
893
1312
|
}
|
|
894
|
-
if (
|
|
1313
|
+
if (jsonParsedConfigs.programName === "spl-memo") {
|
|
895
1314
|
return "SplMemoInstruction";
|
|
896
1315
|
}
|
|
897
|
-
if (
|
|
898
|
-
if (
|
|
1316
|
+
if (jsonParsedConfigs.programName === "spl-token") {
|
|
1317
|
+
if (jsonParsedConfigs.instructionType === "initializeMint") {
|
|
899
1318
|
return "SplTokenInitializeMintInstruction";
|
|
900
1319
|
}
|
|
901
|
-
if (
|
|
1320
|
+
if (jsonParsedConfigs.instructionType === "initializeMint2") {
|
|
902
1321
|
return "SplTokenInitializeMint2Instruction";
|
|
903
1322
|
}
|
|
904
|
-
if (
|
|
1323
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount") {
|
|
905
1324
|
return "SplTokenInitializeAccountInstruction";
|
|
906
1325
|
}
|
|
907
|
-
if (
|
|
1326
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount2") {
|
|
908
1327
|
return "SplTokenInitializeAccount2Instruction";
|
|
909
1328
|
}
|
|
910
|
-
if (
|
|
1329
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount3") {
|
|
911
1330
|
return "SplTokenInitializeAccount3Instruction";
|
|
912
1331
|
}
|
|
913
|
-
if (
|
|
1332
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig") {
|
|
914
1333
|
return "SplTokenInitializeMultisigInstruction";
|
|
915
1334
|
}
|
|
916
|
-
if (
|
|
1335
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
|
|
917
1336
|
return "SplTokenInitializeMultisig2Instruction";
|
|
918
1337
|
}
|
|
919
|
-
if (
|
|
1338
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
920
1339
|
return "SplTokenTransferInstruction";
|
|
921
1340
|
}
|
|
922
|
-
if (
|
|
1341
|
+
if (jsonParsedConfigs.instructionType === "approve") {
|
|
923
1342
|
return "SplTokenApproveInstruction";
|
|
924
1343
|
}
|
|
925
|
-
if (
|
|
1344
|
+
if (jsonParsedConfigs.instructionType === "revoke") {
|
|
926
1345
|
return "SplTokenRevokeInstruction";
|
|
927
1346
|
}
|
|
928
|
-
if (
|
|
1347
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
929
1348
|
return "SplTokenSetAuthorityInstruction";
|
|
930
1349
|
}
|
|
931
|
-
if (
|
|
1350
|
+
if (jsonParsedConfigs.instructionType === "mintTo") {
|
|
932
1351
|
return "SplTokenMintToInstruction";
|
|
933
1352
|
}
|
|
934
|
-
if (
|
|
1353
|
+
if (jsonParsedConfigs.instructionType === "burn") {
|
|
935
1354
|
return "SplTokenBurnInstruction";
|
|
936
1355
|
}
|
|
937
|
-
if (
|
|
1356
|
+
if (jsonParsedConfigs.instructionType === "closeAccount") {
|
|
938
1357
|
return "SplTokenCloseAccountInstruction";
|
|
939
1358
|
}
|
|
940
|
-
if (
|
|
1359
|
+
if (jsonParsedConfigs.instructionType === "freezeAccount") {
|
|
941
1360
|
return "SplTokenFreezeAccountInstruction";
|
|
942
1361
|
}
|
|
943
|
-
if (
|
|
1362
|
+
if (jsonParsedConfigs.instructionType === "thawAccount") {
|
|
944
1363
|
return "SplTokenThawAccountInstruction";
|
|
945
1364
|
}
|
|
946
|
-
if (
|
|
1365
|
+
if (jsonParsedConfigs.instructionType === "transferChecked") {
|
|
947
1366
|
return "SplTokenTransferCheckedInstruction";
|
|
948
1367
|
}
|
|
949
|
-
if (
|
|
1368
|
+
if (jsonParsedConfigs.instructionType === "approveChecked") {
|
|
950
1369
|
return "SplTokenApproveCheckedInstruction";
|
|
951
1370
|
}
|
|
952
|
-
if (
|
|
1371
|
+
if (jsonParsedConfigs.instructionType === "mintToChecked") {
|
|
953
1372
|
return "SplTokenMintToCheckedInstruction";
|
|
954
1373
|
}
|
|
955
|
-
if (
|
|
1374
|
+
if (jsonParsedConfigs.instructionType === "burnChecked") {
|
|
956
1375
|
return "SplTokenBurnCheckedInstruction";
|
|
957
1376
|
}
|
|
958
|
-
if (
|
|
1377
|
+
if (jsonParsedConfigs.instructionType === "syncNative") {
|
|
959
1378
|
return "SplTokenSyncNativeInstruction";
|
|
960
1379
|
}
|
|
961
|
-
if (
|
|
1380
|
+
if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
|
|
962
1381
|
return "SplTokenGetAccountDataSizeInstruction";
|
|
963
1382
|
}
|
|
964
|
-
if (
|
|
1383
|
+
if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
|
|
965
1384
|
return "SplTokenInitializeImmutableOwnerInstruction";
|
|
966
1385
|
}
|
|
967
|
-
if (
|
|
1386
|
+
if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
|
|
968
1387
|
return "SplTokenAmountToUiAmountInstruction";
|
|
969
1388
|
}
|
|
970
|
-
if (
|
|
1389
|
+
if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
|
|
971
1390
|
return "SplTokenUiAmountToAmountInstruction";
|
|
972
1391
|
}
|
|
973
|
-
if (
|
|
1392
|
+
if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
|
|
974
1393
|
return "SplTokenInitializeMintCloseAuthorityInstruction";
|
|
975
1394
|
}
|
|
976
1395
|
}
|
|
977
|
-
if (
|
|
978
|
-
if (
|
|
1396
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
1397
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
979
1398
|
return "StakeInitializeInstruction";
|
|
980
1399
|
}
|
|
981
|
-
if (
|
|
1400
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
982
1401
|
return "StakeAuthorizeInstruction";
|
|
983
1402
|
}
|
|
984
|
-
if (
|
|
1403
|
+
if (jsonParsedConfigs.instructionType === "delegate") {
|
|
985
1404
|
return "StakeDelegateStakeInstruction";
|
|
986
1405
|
}
|
|
987
|
-
if (
|
|
1406
|
+
if (jsonParsedConfigs.instructionType === "split") {
|
|
988
1407
|
return "StakeSplitInstruction";
|
|
989
1408
|
}
|
|
990
|
-
if (
|
|
1409
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
991
1410
|
return "StakeWithdrawInstruction";
|
|
992
1411
|
}
|
|
993
|
-
if (
|
|
1412
|
+
if (jsonParsedConfigs.instructionType === "deactivate") {
|
|
994
1413
|
return "StakeDeactivateInstruction";
|
|
995
1414
|
}
|
|
996
|
-
if (
|
|
1415
|
+
if (jsonParsedConfigs.instructionType === "setLockup") {
|
|
997
1416
|
return "StakeSetLockupInstruction";
|
|
998
1417
|
}
|
|
999
|
-
if (
|
|
1418
|
+
if (jsonParsedConfigs.instructionType === "merge") {
|
|
1000
1419
|
return "StakeMergeInstruction";
|
|
1001
1420
|
}
|
|
1002
|
-
if (
|
|
1421
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1003
1422
|
return "StakeAuthorizeWithSeedInstruction";
|
|
1004
1423
|
}
|
|
1005
|
-
if (
|
|
1424
|
+
if (jsonParsedConfigs.instructionType === "initializeChecked") {
|
|
1006
1425
|
return "StakeInitializeCheckedInstruction";
|
|
1007
1426
|
}
|
|
1008
|
-
if (
|
|
1427
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1009
1428
|
return "StakeAuthorizeCheckedInstruction";
|
|
1010
1429
|
}
|
|
1011
|
-
if (
|
|
1430
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1012
1431
|
return "StakeAuthorizeCheckedWithSeedInstruction";
|
|
1013
1432
|
}
|
|
1014
|
-
if (
|
|
1433
|
+
if (jsonParsedConfigs.instructionType === "setLockupChecked") {
|
|
1015
1434
|
return "StakeSetLockupCheckedInstruction";
|
|
1016
1435
|
}
|
|
1017
|
-
if (
|
|
1436
|
+
if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
|
|
1018
1437
|
return "StakeDeactivateDelinquentInstruction";
|
|
1019
1438
|
}
|
|
1020
|
-
if (
|
|
1439
|
+
if (jsonParsedConfigs.instructionType === "redelegate") {
|
|
1021
1440
|
return "StakeRedelegateInstruction";
|
|
1022
1441
|
}
|
|
1023
1442
|
}
|
|
1024
|
-
if (
|
|
1025
|
-
if (
|
|
1443
|
+
if (jsonParsedConfigs.programName === "system") {
|
|
1444
|
+
if (jsonParsedConfigs.instructionType === "createAccount") {
|
|
1026
1445
|
return "CreateAccountInstruction";
|
|
1027
1446
|
}
|
|
1028
|
-
if (
|
|
1447
|
+
if (jsonParsedConfigs.instructionType === "assign") {
|
|
1029
1448
|
return "AssignInstruction";
|
|
1030
1449
|
}
|
|
1031
|
-
if (
|
|
1450
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
1032
1451
|
return "TransferInstruction";
|
|
1033
1452
|
}
|
|
1034
|
-
if (
|
|
1453
|
+
if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
|
|
1035
1454
|
return "CreateAccountWithSeedInstruction";
|
|
1036
1455
|
}
|
|
1037
|
-
if (
|
|
1456
|
+
if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
|
|
1038
1457
|
return "AdvanceNonceAccountInstruction";
|
|
1039
1458
|
}
|
|
1040
|
-
if (
|
|
1459
|
+
if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
|
|
1041
1460
|
return "WithdrawNonceAccountInstruction";
|
|
1042
1461
|
}
|
|
1043
|
-
if (
|
|
1462
|
+
if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
|
|
1044
1463
|
return "InitializeNonceAccountInstruction";
|
|
1045
1464
|
}
|
|
1046
|
-
if (
|
|
1465
|
+
if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
|
|
1047
1466
|
return "AuthorizeNonceAccountInstruction";
|
|
1048
1467
|
}
|
|
1049
|
-
if (
|
|
1468
|
+
if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
|
|
1050
1469
|
return "UpgradeNonceAccountInstruction";
|
|
1051
1470
|
}
|
|
1052
|
-
if (
|
|
1471
|
+
if (jsonParsedConfigs.instructionType === "allocate") {
|
|
1053
1472
|
return "AllocateInstruction";
|
|
1054
1473
|
}
|
|
1055
|
-
if (
|
|
1474
|
+
if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
|
|
1056
1475
|
return "AllocateWithSeedInstruction";
|
|
1057
1476
|
}
|
|
1058
|
-
if (
|
|
1477
|
+
if (jsonParsedConfigs.instructionType === "assignWithSeed") {
|
|
1059
1478
|
return "AssignWithSeedInstruction";
|
|
1060
1479
|
}
|
|
1061
|
-
if (
|
|
1480
|
+
if (jsonParsedConfigs.instructionType === "transferWithSeed") {
|
|
1062
1481
|
return "TransferWithSeedInstruction";
|
|
1063
1482
|
}
|
|
1064
1483
|
}
|
|
1065
|
-
if (
|
|
1066
|
-
if (
|
|
1484
|
+
if (jsonParsedConfigs.programName === "vote") {
|
|
1485
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
1067
1486
|
return "VoteInitializeAccountInstruction";
|
|
1068
1487
|
}
|
|
1069
|
-
if (
|
|
1488
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
1070
1489
|
return "VoteAuthorizeInstruction";
|
|
1071
1490
|
}
|
|
1072
|
-
if (
|
|
1491
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1073
1492
|
return "VoteAuthorizeWithSeedInstruction";
|
|
1074
1493
|
}
|
|
1075
|
-
if (
|
|
1494
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1076
1495
|
return "VoteAuthorizeCheckedWithSeedInstruction";
|
|
1077
1496
|
}
|
|
1078
|
-
if (
|
|
1497
|
+
if (jsonParsedConfigs.instructionType === "vote") {
|
|
1079
1498
|
return "VoteVoteInstruction";
|
|
1080
1499
|
}
|
|
1081
|
-
if (
|
|
1500
|
+
if (jsonParsedConfigs.instructionType === "updatevotestate") {
|
|
1082
1501
|
return "VoteUpdateVoteStateInstruction";
|
|
1083
1502
|
}
|
|
1084
|
-
if (
|
|
1503
|
+
if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
|
|
1085
1504
|
return "VoteUpdateVoteStateSwitchInstruction";
|
|
1086
1505
|
}
|
|
1087
|
-
if (
|
|
1506
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
|
|
1088
1507
|
return "VoteCompactUpdateVoteStateInstruction";
|
|
1089
1508
|
}
|
|
1090
|
-
if (
|
|
1509
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
|
|
1091
1510
|
return "VoteCompactUpdateVoteStateSwitchInstruction";
|
|
1092
1511
|
}
|
|
1093
|
-
if (
|
|
1512
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
1094
1513
|
return "VoteWithdrawInstruction";
|
|
1095
1514
|
}
|
|
1096
|
-
if (
|
|
1515
|
+
if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
|
|
1097
1516
|
return "VoteUpdateValidatorIdentityInstruction";
|
|
1098
1517
|
}
|
|
1099
|
-
if (
|
|
1518
|
+
if (jsonParsedConfigs.instructionType === "updateCommission") {
|
|
1100
1519
|
return "VoteUpdateCommissionInstruction";
|
|
1101
1520
|
}
|
|
1102
|
-
if (
|
|
1521
|
+
if (jsonParsedConfigs.instructionType === "voteSwitch") {
|
|
1103
1522
|
return "VoteVoteSwitchInstruction";
|
|
1104
1523
|
}
|
|
1105
|
-
if (
|
|
1524
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1106
1525
|
return "VoteAuthorizeCheckedInstruction";
|
|
1107
1526
|
}
|
|
1108
1527
|
}
|
|
@@ -1125,21 +1544,25 @@ var instructionResolvers = {
|
|
|
1125
1544
|
},
|
|
1126
1545
|
VoteAuthorizeCheckedInstruction: {
|
|
1127
1546
|
authority: resolveAccount("authority"),
|
|
1547
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1128
1548
|
newAuthority: resolveAccount("newAuthority"),
|
|
1129
1549
|
voteAccount: resolveAccount("voteAccount")
|
|
1130
1550
|
},
|
|
1131
1551
|
VoteAuthorizeCheckedWithSeedInstruction: {
|
|
1132
1552
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1553
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1133
1554
|
newAuthority: resolveAccount("newAuthority"),
|
|
1134
1555
|
voteAccount: resolveAccount("voteAccount")
|
|
1135
1556
|
},
|
|
1136
1557
|
VoteAuthorizeInstruction: {
|
|
1137
1558
|
authority: resolveAccount("authority"),
|
|
1559
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1138
1560
|
newAuthority: resolveAccount("newAuthority"),
|
|
1139
1561
|
voteAccount: resolveAccount("voteAccount")
|
|
1140
1562
|
},
|
|
1141
1563
|
VoteAuthorizeWithSeedInstruction: {
|
|
1142
1564
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1565
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1143
1566
|
newAuthority: resolveAccount("newAuthority"),
|
|
1144
1567
|
voteAccount: resolveAccount("voteAccount")
|
|
1145
1568
|
},
|
|
@@ -1154,7 +1577,9 @@ var instructionResolvers = {
|
|
|
1154
1577
|
VoteInitializeAccountInstruction: {
|
|
1155
1578
|
authorizedVoter: resolveAccount("authorizedVoter"),
|
|
1156
1579
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
1580
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1157
1581
|
node: resolveAccount("node"),
|
|
1582
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1158
1583
|
voteAccount: resolveAccount("voteAccount")
|
|
1159
1584
|
},
|
|
1160
1585
|
VoteUpdateCommissionInstruction: {
|
|
@@ -1175,10 +1600,14 @@ var instructionResolvers = {
|
|
|
1175
1600
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1176
1601
|
},
|
|
1177
1602
|
VoteVoteInstruction: {
|
|
1603
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1604
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1178
1605
|
voteAccount: resolveAccount("voteAccount"),
|
|
1179
1606
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1180
1607
|
},
|
|
1181
1608
|
VoteVoteSwitchInstruction: {
|
|
1609
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1610
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1182
1611
|
voteAccount: resolveAccount("voteAccount"),
|
|
1183
1612
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1184
1613
|
},
|
|
@@ -1189,7 +1618,9 @@ var instructionResolvers = {
|
|
|
1189
1618
|
WithdrawNonceAccountInstruction: {
|
|
1190
1619
|
destination: resolveAccount("destination"),
|
|
1191
1620
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
1192
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1621
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1622
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1623
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1193
1624
|
}
|
|
1194
1625
|
};
|
|
1195
1626
|
|
|
@@ -1197,23 +1628,173 @@ var instructionResolvers = {
|
|
|
1197
1628
|
function resolveProgramAccounts(fieldName) {
|
|
1198
1629
|
return async (parent, args, context, info) => {
|
|
1199
1630
|
const programAddress = fieldName ? parent[fieldName] : args.programAddress;
|
|
1200
|
-
if (
|
|
1201
|
-
|
|
1631
|
+
if (programAddress) {
|
|
1632
|
+
const argsSet = buildProgramAccountsLoaderArgSetFromResolveInfo({ ...args, programAddress }, info);
|
|
1633
|
+
const loadedProgramAccountsLists = await context.loaders.programAccounts.loadMany(argsSet);
|
|
1634
|
+
const result = {};
|
|
1635
|
+
loadedProgramAccountsLists.forEach((programAccounts, i) => {
|
|
1636
|
+
if (programAccounts instanceof Error) {
|
|
1637
|
+
console.error(programAccounts);
|
|
1638
|
+
return;
|
|
1639
|
+
}
|
|
1640
|
+
programAccounts.forEach((programAccount) => {
|
|
1641
|
+
const { account, pubkey: address } = programAccount;
|
|
1642
|
+
const thisResult = result[address] ||= {
|
|
1643
|
+
...account,
|
|
1644
|
+
address,
|
|
1645
|
+
encodedData: {},
|
|
1646
|
+
ownerProgram: account.owner
|
|
1647
|
+
};
|
|
1648
|
+
const { data } = account;
|
|
1649
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
1650
|
+
if (encoding && thisResult.encodedData) {
|
|
1651
|
+
if (Array.isArray(data)) {
|
|
1652
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1653
|
+
dataSlice,
|
|
1654
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
1655
|
+
})] = data[0];
|
|
1656
|
+
} else if (typeof data === "string") {
|
|
1657
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1658
|
+
dataSlice,
|
|
1659
|
+
encoding: "base58"
|
|
1660
|
+
})] = data;
|
|
1661
|
+
} else if (typeof data === "object") {
|
|
1662
|
+
const {
|
|
1663
|
+
parsed: { info: parsedData, type: accountType },
|
|
1664
|
+
program: programName,
|
|
1665
|
+
programId
|
|
1666
|
+
} = data;
|
|
1667
|
+
thisResult.jsonParsedConfigs = {
|
|
1668
|
+
accountType,
|
|
1669
|
+
programId,
|
|
1670
|
+
programName
|
|
1671
|
+
};
|
|
1672
|
+
for (const key in parsedData) {
|
|
1673
|
+
thisResult[key] = parsedData[key];
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
});
|
|
1678
|
+
});
|
|
1679
|
+
return Object.values(result);
|
|
1202
1680
|
}
|
|
1203
|
-
|
|
1204
|
-
return { programAddress };
|
|
1205
|
-
}
|
|
1206
|
-
const programAccounts = await context.loaders.programAccounts.load({ ...args, programAddress });
|
|
1207
|
-
return programAccounts === null ? { programAddress } : programAccounts.map(
|
|
1208
|
-
(programAccount) => transformLoadedAccount({
|
|
1209
|
-
account: programAccount.account,
|
|
1210
|
-
address: programAccount.pubkey,
|
|
1211
|
-
encoding: args.encoding
|
|
1212
|
-
})
|
|
1213
|
-
);
|
|
1681
|
+
return null;
|
|
1214
1682
|
};
|
|
1215
1683
|
}
|
|
1216
1684
|
|
|
1685
|
+
// src/resolvers/transaction.ts
|
|
1686
|
+
function mapJsonParsedInstructions(instructions) {
|
|
1687
|
+
return instructions.map((instruction) => {
|
|
1688
|
+
if ("parsed" in instruction) {
|
|
1689
|
+
if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
|
|
1690
|
+
const { parsed: memo, program: programName2, programId: programId2 } = instruction;
|
|
1691
|
+
const instructionType2 = "memo";
|
|
1692
|
+
const jsonParsedConfigs2 = {
|
|
1693
|
+
instructionType: instructionType2,
|
|
1694
|
+
programId: programId2,
|
|
1695
|
+
programName: programName2
|
|
1696
|
+
};
|
|
1697
|
+
return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
|
|
1698
|
+
}
|
|
1699
|
+
const {
|
|
1700
|
+
parsed: { info: data, type: instructionType },
|
|
1701
|
+
program: programName,
|
|
1702
|
+
programId
|
|
1703
|
+
} = instruction;
|
|
1704
|
+
const jsonParsedConfigs = {
|
|
1705
|
+
instructionType,
|
|
1706
|
+
programId,
|
|
1707
|
+
programName
|
|
1708
|
+
};
|
|
1709
|
+
return { jsonParsedConfigs, ...data, programId };
|
|
1710
|
+
} else {
|
|
1711
|
+
return instruction;
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
function mapJsonParsedInnerInstructions(innerInstructions) {
|
|
1716
|
+
return innerInstructions.map(({ index, instructions }) => ({
|
|
1717
|
+
index,
|
|
1718
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1719
|
+
instructions: mapJsonParsedInstructions(instructions)
|
|
1720
|
+
}));
|
|
1721
|
+
}
|
|
1722
|
+
var resolveTransactionData = () => {
|
|
1723
|
+
return (parent, args) => {
|
|
1724
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
1725
|
+
};
|
|
1726
|
+
};
|
|
1727
|
+
function resolveTransaction(fieldName) {
|
|
1728
|
+
return async (parent, args, context, info) => {
|
|
1729
|
+
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
1730
|
+
if (signature) {
|
|
1731
|
+
if (onlyFieldsRequested(["signature"], info)) {
|
|
1732
|
+
return { signature };
|
|
1733
|
+
}
|
|
1734
|
+
const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
|
|
1735
|
+
const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
|
|
1736
|
+
let result = {
|
|
1737
|
+
encodedData: {},
|
|
1738
|
+
signature
|
|
1739
|
+
};
|
|
1740
|
+
loadedTransactions.forEach((loadedTransaction, i) => {
|
|
1741
|
+
if (loadedTransaction instanceof Error) {
|
|
1742
|
+
console.error(loadedTransaction);
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1745
|
+
if (loadedTransaction === null) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
if (!result.slot) {
|
|
1749
|
+
result = {
|
|
1750
|
+
...result,
|
|
1751
|
+
...loadedTransaction
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
const { transaction: data } = loadedTransaction;
|
|
1755
|
+
const { encoding } = argsSet[i];
|
|
1756
|
+
if (encoding && result.encodedData) {
|
|
1757
|
+
if (Array.isArray(data)) {
|
|
1758
|
+
result.encodedData[cacheKeyFn({
|
|
1759
|
+
encoding
|
|
1760
|
+
})] = data[0];
|
|
1761
|
+
} else if (typeof data === "object") {
|
|
1762
|
+
const jsonParsedData = data;
|
|
1763
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
1764
|
+
jsonParsedData.message.instructions
|
|
1765
|
+
);
|
|
1766
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
1767
|
+
if (loadedInnerInstructions) {
|
|
1768
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
1769
|
+
const jsonParsedMeta = {
|
|
1770
|
+
...loadedTransaction.meta,
|
|
1771
|
+
innerInstructions
|
|
1772
|
+
};
|
|
1773
|
+
result = {
|
|
1774
|
+
...result,
|
|
1775
|
+
...jsonParsedData,
|
|
1776
|
+
meta: jsonParsedMeta
|
|
1777
|
+
};
|
|
1778
|
+
} else {
|
|
1779
|
+
result = {
|
|
1780
|
+
...result,
|
|
1781
|
+
...jsonParsedData
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
return result;
|
|
1788
|
+
}
|
|
1789
|
+
return null;
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
var transactionResolvers = {
|
|
1793
|
+
Transaction: {
|
|
1794
|
+
data: resolveTransactionData()
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1217
1798
|
// src/resolvers/root.ts
|
|
1218
1799
|
var rootResolvers = {
|
|
1219
1800
|
Query: {
|
|
@@ -1237,35 +1818,48 @@ var stringScalarAlias = {
|
|
|
1237
1818
|
return value;
|
|
1238
1819
|
}
|
|
1239
1820
|
};
|
|
1240
|
-
var
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1245
|
-
BigInt: {
|
|
1246
|
-
__parseLiteral(ast) {
|
|
1247
|
-
if (ast.kind === graphql.Kind.STRING) {
|
|
1248
|
-
return BigInt(ast.value);
|
|
1249
|
-
}
|
|
1250
|
-
return null;
|
|
1251
|
-
},
|
|
1252
|
-
__parseValue(value) {
|
|
1253
|
-
return BigInt(value);
|
|
1254
|
-
},
|
|
1255
|
-
__serialize(value) {
|
|
1256
|
-
return BigInt(value);
|
|
1821
|
+
var bigIntScalarAlias = {
|
|
1822
|
+
__parseLiteral(ast) {
|
|
1823
|
+
if (ast.kind === graphql.Kind.STRING) {
|
|
1824
|
+
return BigInt(ast.value);
|
|
1257
1825
|
}
|
|
1826
|
+
return null;
|
|
1827
|
+
},
|
|
1828
|
+
__parseValue(value) {
|
|
1829
|
+
return BigInt(value);
|
|
1830
|
+
},
|
|
1831
|
+
__serialize(value) {
|
|
1832
|
+
return BigInt(value);
|
|
1258
1833
|
}
|
|
1259
1834
|
};
|
|
1260
|
-
|
|
1261
|
-
// src/resolvers/types.ts
|
|
1262
|
-
var commonTypeResolvers = {
|
|
1835
|
+
var typeTypeResolvers = {
|
|
1263
1836
|
AccountEncoding: {
|
|
1264
1837
|
BASE_58: "base58",
|
|
1265
1838
|
BASE_64: "base64",
|
|
1266
|
-
BASE_64_ZSTD: "base64+zstd"
|
|
1267
|
-
PARSED: "jsonParsed"
|
|
1839
|
+
BASE_64_ZSTD: "base64+zstd"
|
|
1268
1840
|
},
|
|
1841
|
+
Address: stringScalarAlias,
|
|
1842
|
+
Base58EncodedBytes: stringScalarAlias,
|
|
1843
|
+
Base64EncodedBytes: stringScalarAlias,
|
|
1844
|
+
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1845
|
+
BigInt: bigIntScalarAlias,
|
|
1846
|
+
BlockTransactionDetails: {
|
|
1847
|
+
ACCOUNTS: "accounts",
|
|
1848
|
+
FULL: "full",
|
|
1849
|
+
NONE: "none",
|
|
1850
|
+
SIGNATURES: "signatures"
|
|
1851
|
+
},
|
|
1852
|
+
Commitment: {
|
|
1853
|
+
CONFIRMED: "confirmed",
|
|
1854
|
+
FINALIZED: "finalized",
|
|
1855
|
+
PROCESSED: "processed"
|
|
1856
|
+
},
|
|
1857
|
+
CommitmentWithoutProcessed: {
|
|
1858
|
+
CONFIRMED: "confirmed",
|
|
1859
|
+
FINALIZED: "finalized"
|
|
1860
|
+
},
|
|
1861
|
+
Signature: stringScalarAlias,
|
|
1862
|
+
Slot: bigIntScalarAlias,
|
|
1269
1863
|
TokenBalance: {
|
|
1270
1864
|
mint: resolveAccount("mint"),
|
|
1271
1865
|
owner: resolveAccount("owner")
|
|
@@ -1286,11 +1880,10 @@ function createSolanaGraphQLResolvers() {
|
|
|
1286
1880
|
return {
|
|
1287
1881
|
...accountResolvers,
|
|
1288
1882
|
...blockResolvers,
|
|
1289
|
-
...commonTypeResolvers,
|
|
1290
1883
|
...instructionResolvers,
|
|
1291
1884
|
...rootResolvers,
|
|
1292
|
-
...
|
|
1293
|
-
...
|
|
1885
|
+
...transactionResolvers,
|
|
1886
|
+
...typeTypeResolvers
|
|
1294
1887
|
};
|
|
1295
1888
|
}
|
|
1296
1889
|
|
|
@@ -1303,6 +1896,7 @@ var accountTypeDefs = (
|
|
|
1303
1896
|
"""
|
|
1304
1897
|
interface Account {
|
|
1305
1898
|
address: Address
|
|
1899
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1306
1900
|
executable: Boolean
|
|
1307
1901
|
lamports: BigInt
|
|
1308
1902
|
ownerProgram: Account
|
|
@@ -1311,37 +1905,11 @@ var accountTypeDefs = (
|
|
|
1311
1905
|
}
|
|
1312
1906
|
|
|
1313
1907
|
"""
|
|
1314
|
-
|
|
1315
|
-
"""
|
|
1316
|
-
type AccountBase58 implements Account {
|
|
1317
|
-
address: Address
|
|
1318
|
-
data: Base58EncodedBytes
|
|
1319
|
-
executable: Boolean
|
|
1320
|
-
lamports: BigInt
|
|
1321
|
-
ownerProgram: Account
|
|
1322
|
-
space: BigInt
|
|
1323
|
-
rentEpoch: BigInt
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
"""
|
|
1327
|
-
An account with base64 encoded data
|
|
1328
|
-
"""
|
|
1329
|
-
type AccountBase64 implements Account {
|
|
1330
|
-
address: Address
|
|
1331
|
-
data: Base64EncodedBytes
|
|
1332
|
-
executable: Boolean
|
|
1333
|
-
lamports: BigInt
|
|
1334
|
-
ownerProgram: Account
|
|
1335
|
-
space: BigInt
|
|
1336
|
-
rentEpoch: BigInt
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
"""
|
|
1340
|
-
An account with base64+zstd encoded data
|
|
1908
|
+
Generic base account type
|
|
1341
1909
|
"""
|
|
1342
|
-
type
|
|
1910
|
+
type GenericAccount implements Account {
|
|
1343
1911
|
address: Address
|
|
1344
|
-
data:
|
|
1912
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1345
1913
|
executable: Boolean
|
|
1346
1914
|
lamports: BigInt
|
|
1347
1915
|
ownerProgram: Account
|
|
@@ -1357,6 +1925,7 @@ var accountTypeDefs = (
|
|
|
1357
1925
|
"""
|
|
1358
1926
|
type NonceAccount implements Account {
|
|
1359
1927
|
address: Address
|
|
1928
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1360
1929
|
executable: Boolean
|
|
1361
1930
|
lamports: BigInt
|
|
1362
1931
|
ownerProgram: Account
|
|
@@ -1372,6 +1941,7 @@ var accountTypeDefs = (
|
|
|
1372
1941
|
"""
|
|
1373
1942
|
type LookupTableAccount implements Account {
|
|
1374
1943
|
address: Address
|
|
1944
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1375
1945
|
executable: Boolean
|
|
1376
1946
|
lamports: BigInt
|
|
1377
1947
|
ownerProgram: Account
|
|
@@ -1389,6 +1959,7 @@ var accountTypeDefs = (
|
|
|
1389
1959
|
"""
|
|
1390
1960
|
type MintAccount implements Account {
|
|
1391
1961
|
address: Address
|
|
1962
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1392
1963
|
executable: Boolean
|
|
1393
1964
|
lamports: BigInt
|
|
1394
1965
|
ownerProgram: Account
|
|
@@ -1406,6 +1977,7 @@ var accountTypeDefs = (
|
|
|
1406
1977
|
"""
|
|
1407
1978
|
type TokenAccount implements Account {
|
|
1408
1979
|
address: Address
|
|
1980
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1409
1981
|
executable: Boolean
|
|
1410
1982
|
lamports: BigInt
|
|
1411
1983
|
ownerProgram: Account
|
|
@@ -1448,6 +2020,7 @@ var accountTypeDefs = (
|
|
|
1448
2020
|
"""
|
|
1449
2021
|
type StakeAccount implements Account {
|
|
1450
2022
|
address: Address
|
|
2023
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1451
2024
|
executable: Boolean
|
|
1452
2025
|
lamports: BigInt
|
|
1453
2026
|
ownerProgram: Account
|
|
@@ -1479,6 +2052,7 @@ var accountTypeDefs = (
|
|
|
1479
2052
|
"""
|
|
1480
2053
|
type VoteAccount implements Account {
|
|
1481
2054
|
address: Address
|
|
2055
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1482
2056
|
executable: Boolean
|
|
1483
2057
|
lamports: BigInt
|
|
1484
2058
|
ownerProgram: Account
|
|
@@ -1592,101 +2166,6 @@ var blockTypeDefs = (
|
|
|
1592
2166
|
`
|
|
1593
2167
|
);
|
|
1594
2168
|
|
|
1595
|
-
// src/schema/common/inputs.ts
|
|
1596
|
-
var inputTypeDefs = (
|
|
1597
|
-
/* GraphQL */
|
|
1598
|
-
`
|
|
1599
|
-
input DataSlice {
|
|
1600
|
-
offset: Int
|
|
1601
|
-
length: Int
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
input ProgramAccountsFilter {
|
|
1605
|
-
bytes: BigInt
|
|
1606
|
-
dataSize: BigInt
|
|
1607
|
-
encoding: AccountEncoding
|
|
1608
|
-
offset: BigInt
|
|
1609
|
-
}
|
|
1610
|
-
`
|
|
1611
|
-
);
|
|
1612
|
-
|
|
1613
|
-
// src/schema/common/scalars.ts
|
|
1614
|
-
var scalarTypeDefs = (
|
|
1615
|
-
/* GraphQL */
|
|
1616
|
-
`
|
|
1617
|
-
scalar Address
|
|
1618
|
-
scalar Base58EncodedBytes
|
|
1619
|
-
scalar Base64EncodedBytes
|
|
1620
|
-
scalar Base64ZstdEncodedBytes
|
|
1621
|
-
scalar BigInt
|
|
1622
|
-
`
|
|
1623
|
-
);
|
|
1624
|
-
|
|
1625
|
-
// src/schema/common/types.ts
|
|
1626
|
-
var commonTypeDefs = (
|
|
1627
|
-
/* GraphQL */
|
|
1628
|
-
`
|
|
1629
|
-
enum AccountEncoding {
|
|
1630
|
-
BASE_58
|
|
1631
|
-
BASE_64
|
|
1632
|
-
BASE_64_ZSTD
|
|
1633
|
-
PARSED
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
enum BlockTransactionDetails {
|
|
1637
|
-
accounts
|
|
1638
|
-
full
|
|
1639
|
-
none
|
|
1640
|
-
signatures
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
enum Commitment {
|
|
1644
|
-
confirmed
|
|
1645
|
-
finalized
|
|
1646
|
-
processed
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
type ReturnData {
|
|
1650
|
-
data: Base64EncodedBytes
|
|
1651
|
-
programId: Address
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
type Reward {
|
|
1655
|
-
commission: Int
|
|
1656
|
-
lamports: BigInt
|
|
1657
|
-
postBalance: BigInt
|
|
1658
|
-
pubkey: Address
|
|
1659
|
-
rewardType: String
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
type TokenAmount {
|
|
1663
|
-
amount: String
|
|
1664
|
-
decimals: Int
|
|
1665
|
-
uiAmount: BigInt
|
|
1666
|
-
uiAmountString: String
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
type TokenBalance {
|
|
1670
|
-
accountIndex: Int
|
|
1671
|
-
mint: Account
|
|
1672
|
-
owner: Account
|
|
1673
|
-
programId: Address
|
|
1674
|
-
uiTokenAmount: TokenAmount
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
enum TransactionEncoding {
|
|
1678
|
-
BASE_58
|
|
1679
|
-
BASE_64
|
|
1680
|
-
PARSED
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
enum TransactionVersion {
|
|
1684
|
-
LEGACY
|
|
1685
|
-
ZERO
|
|
1686
|
-
}
|
|
1687
|
-
`
|
|
1688
|
-
);
|
|
1689
|
-
|
|
1690
2169
|
// src/schema/instruction.ts
|
|
1691
2170
|
var instructionTypeDefs = (
|
|
1692
2171
|
/* GraphQL */
|
|
@@ -1804,12 +2283,12 @@ var instructionTypeDefs = (
|
|
|
1804
2283
|
programId: Address
|
|
1805
2284
|
authority: Account
|
|
1806
2285
|
bufferAccount: Account
|
|
1807
|
-
clockSysvar:
|
|
2286
|
+
clockSysvar: Account
|
|
1808
2287
|
maxDataLen: BigInt
|
|
1809
2288
|
payerAccount: Account
|
|
1810
2289
|
programAccount: Account
|
|
1811
2290
|
programDataAccount: Account
|
|
1812
|
-
rentSysvar:
|
|
2291
|
+
rentSysvar: Account
|
|
1813
2292
|
}
|
|
1814
2293
|
|
|
1815
2294
|
"""
|
|
@@ -1819,10 +2298,10 @@ var instructionTypeDefs = (
|
|
|
1819
2298
|
programId: Address
|
|
1820
2299
|
authority: Account
|
|
1821
2300
|
bufferAccount: Account
|
|
1822
|
-
clockSysvar:
|
|
2301
|
+
clockSysvar: Account
|
|
1823
2302
|
programAccount: Account
|
|
1824
2303
|
programDataAccount: Account
|
|
1825
|
-
rentSysvar:
|
|
2304
|
+
rentSysvar: Account
|
|
1826
2305
|
spillAccount: Account
|
|
1827
2306
|
}
|
|
1828
2307
|
|
|
@@ -1875,7 +2354,7 @@ var instructionTypeDefs = (
|
|
|
1875
2354
|
type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
|
|
1876
2355
|
programId: Address
|
|
1877
2356
|
account: Account
|
|
1878
|
-
mint:
|
|
2357
|
+
mint: Account
|
|
1879
2358
|
source: Account
|
|
1880
2359
|
systemProgram: Account
|
|
1881
2360
|
tokenProgram: Account
|
|
@@ -1888,7 +2367,7 @@ var instructionTypeDefs = (
|
|
|
1888
2367
|
type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
|
|
1889
2368
|
programId: Address
|
|
1890
2369
|
account: Account
|
|
1891
|
-
mint:
|
|
2370
|
+
mint: Account
|
|
1892
2371
|
source: Account
|
|
1893
2372
|
systemProgram: Account
|
|
1894
2373
|
tokenProgram: Account
|
|
@@ -1926,7 +2405,7 @@ var instructionTypeDefs = (
|
|
|
1926
2405
|
freezeAuthority: Account
|
|
1927
2406
|
mint: Account
|
|
1928
2407
|
mintAuthority: Account
|
|
1929
|
-
rentSysvar:
|
|
2408
|
+
rentSysvar: Account
|
|
1930
2409
|
}
|
|
1931
2410
|
|
|
1932
2411
|
"""
|
|
@@ -1948,7 +2427,7 @@ var instructionTypeDefs = (
|
|
|
1948
2427
|
account: Account
|
|
1949
2428
|
mint: Account
|
|
1950
2429
|
owner: Account
|
|
1951
|
-
rentSysvar:
|
|
2430
|
+
rentSysvar: Account
|
|
1952
2431
|
}
|
|
1953
2432
|
|
|
1954
2433
|
"""
|
|
@@ -1959,7 +2438,7 @@ var instructionTypeDefs = (
|
|
|
1959
2438
|
account: Account
|
|
1960
2439
|
mint: Account
|
|
1961
2440
|
owner: Account
|
|
1962
|
-
rentSysvar:
|
|
2441
|
+
rentSysvar: Account
|
|
1963
2442
|
}
|
|
1964
2443
|
|
|
1965
2444
|
"""
|
|
@@ -1979,7 +2458,7 @@ var instructionTypeDefs = (
|
|
|
1979
2458
|
programId: Address
|
|
1980
2459
|
m: BigInt # FIXME:*
|
|
1981
2460
|
multisig: Account
|
|
1982
|
-
rentSysvar:
|
|
2461
|
+
rentSysvar: Account
|
|
1983
2462
|
signers: [Address]
|
|
1984
2463
|
}
|
|
1985
2464
|
|
|
@@ -2234,7 +2713,7 @@ var instructionTypeDefs = (
|
|
|
2234
2713
|
programId: Address
|
|
2235
2714
|
authorized: StakeInitializeInstructionDataAuthorized
|
|
2236
2715
|
lockup: Lockup
|
|
2237
|
-
rentSysvar:
|
|
2716
|
+
rentSysvar: Account
|
|
2238
2717
|
stakeAccount: Account
|
|
2239
2718
|
}
|
|
2240
2719
|
|
|
@@ -2245,7 +2724,7 @@ var instructionTypeDefs = (
|
|
|
2245
2724
|
programId: Address
|
|
2246
2725
|
authority: Account
|
|
2247
2726
|
authorityType: String
|
|
2248
|
-
clockSysvar:
|
|
2727
|
+
clockSysvar: Account
|
|
2249
2728
|
custodian: Account
|
|
2250
2729
|
newAuthority: Account
|
|
2251
2730
|
stakeAccount: Account
|
|
@@ -2256,11 +2735,11 @@ var instructionTypeDefs = (
|
|
|
2256
2735
|
"""
|
|
2257
2736
|
type StakeDelegateStakeInstruction implements TransactionInstruction {
|
|
2258
2737
|
programId: Address
|
|
2259
|
-
clockSysvar:
|
|
2738
|
+
clockSysvar: Account
|
|
2260
2739
|
stakeAccount: Account
|
|
2261
2740
|
stakeAuthority: Account
|
|
2262
2741
|
stakeConfigAccount: Account
|
|
2263
|
-
stakeHistorySysvar:
|
|
2742
|
+
stakeHistorySysvar: Account
|
|
2264
2743
|
voteAccount: Account
|
|
2265
2744
|
}
|
|
2266
2745
|
|
|
@@ -2280,7 +2759,7 @@ var instructionTypeDefs = (
|
|
|
2280
2759
|
"""
|
|
2281
2760
|
type StakeWithdrawInstruction implements TransactionInstruction {
|
|
2282
2761
|
programId: Address
|
|
2283
|
-
clockSysvar:
|
|
2762
|
+
clockSysvar: Account
|
|
2284
2763
|
destination: Account
|
|
2285
2764
|
lamports: BigInt
|
|
2286
2765
|
stakeAccount: Account
|
|
@@ -2292,7 +2771,7 @@ var instructionTypeDefs = (
|
|
|
2292
2771
|
"""
|
|
2293
2772
|
type StakeDeactivateInstruction implements TransactionInstruction {
|
|
2294
2773
|
programId: Address
|
|
2295
|
-
clockSysvar:
|
|
2774
|
+
clockSysvar: Account
|
|
2296
2775
|
stakeAccount: Account
|
|
2297
2776
|
stakeAuthority: Account
|
|
2298
2777
|
}
|
|
@@ -2312,11 +2791,11 @@ var instructionTypeDefs = (
|
|
|
2312
2791
|
"""
|
|
2313
2792
|
type StakeMergeInstruction implements TransactionInstruction {
|
|
2314
2793
|
programId: Address
|
|
2315
|
-
clockSysvar:
|
|
2794
|
+
clockSysvar: Account
|
|
2316
2795
|
destination: Account
|
|
2317
2796
|
source: Account
|
|
2318
2797
|
stakeAuthority: Account
|
|
2319
|
-
stakeHistorySysvar:
|
|
2798
|
+
stakeHistorySysvar: Account
|
|
2320
2799
|
}
|
|
2321
2800
|
|
|
2322
2801
|
"""
|
|
@@ -2328,7 +2807,7 @@ var instructionTypeDefs = (
|
|
|
2328
2807
|
authorityOwner: Account
|
|
2329
2808
|
authoritySeed: String
|
|
2330
2809
|
authorityType: String
|
|
2331
|
-
clockSysvar:
|
|
2810
|
+
clockSysvar: Account
|
|
2332
2811
|
custodian: Account
|
|
2333
2812
|
newAuthorized: Account
|
|
2334
2813
|
stakeAccount: Account
|
|
@@ -2345,7 +2824,7 @@ var instructionTypeDefs = (
|
|
|
2345
2824
|
programId: Address
|
|
2346
2825
|
authorized: StakeInitializeCheckedInstructionDataAuthorized
|
|
2347
2826
|
lockup: Lockup
|
|
2348
|
-
rentSysvar:
|
|
2827
|
+
rentSysvar: Account
|
|
2349
2828
|
stakeAccount: Account
|
|
2350
2829
|
}
|
|
2351
2830
|
|
|
@@ -2356,7 +2835,7 @@ var instructionTypeDefs = (
|
|
|
2356
2835
|
programId: Address
|
|
2357
2836
|
authority: Account
|
|
2358
2837
|
authorityType: String
|
|
2359
|
-
clockSysvar:
|
|
2838
|
+
clockSysvar: Account
|
|
2360
2839
|
custodian: Account
|
|
2361
2840
|
newAuthority: Account
|
|
2362
2841
|
stakeAccount: Account
|
|
@@ -2371,7 +2850,7 @@ var instructionTypeDefs = (
|
|
|
2371
2850
|
authorityOwner: Account
|
|
2372
2851
|
authoritySeed: String
|
|
2373
2852
|
authorityType: String
|
|
2374
|
-
clockSysvar:
|
|
2853
|
+
clockSysvar: Account
|
|
2375
2854
|
custodian: Account
|
|
2376
2855
|
newAuthorized: Account
|
|
2377
2856
|
stakeAccount: Account
|
|
@@ -2459,7 +2938,7 @@ var instructionTypeDefs = (
|
|
|
2459
2938
|
programId: Address
|
|
2460
2939
|
nonceAccount: Account
|
|
2461
2940
|
nonceAuthority: Account
|
|
2462
|
-
recentBlockhashesSysvar:
|
|
2941
|
+
recentBlockhashesSysvar: Account
|
|
2463
2942
|
}
|
|
2464
2943
|
|
|
2465
2944
|
"""
|
|
@@ -2471,8 +2950,8 @@ var instructionTypeDefs = (
|
|
|
2471
2950
|
lamports: BigInt
|
|
2472
2951
|
nonceAccount: Account
|
|
2473
2952
|
nonceAuthority: Account
|
|
2474
|
-
recentBlockhashesSysvar:
|
|
2475
|
-
rentSysvar:
|
|
2953
|
+
recentBlockhashesSysvar: Account
|
|
2954
|
+
rentSysvar: Account
|
|
2476
2955
|
}
|
|
2477
2956
|
|
|
2478
2957
|
"""
|
|
@@ -2482,8 +2961,8 @@ var instructionTypeDefs = (
|
|
|
2482
2961
|
programId: Address
|
|
2483
2962
|
nonceAccount: Account
|
|
2484
2963
|
nonceAuthority: Account
|
|
2485
|
-
recentBlockhashesSysvar:
|
|
2486
|
-
rentSysvar:
|
|
2964
|
+
recentBlockhashesSysvar: Account
|
|
2965
|
+
rentSysvar: Account
|
|
2487
2966
|
}
|
|
2488
2967
|
|
|
2489
2968
|
"""
|
|
@@ -2557,10 +3036,10 @@ var instructionTypeDefs = (
|
|
|
2557
3036
|
programId: Address
|
|
2558
3037
|
authorizedVoter: Account
|
|
2559
3038
|
authorizedWithdrawer: Account
|
|
2560
|
-
clockSysvar:
|
|
3039
|
+
clockSysvar: Account
|
|
2561
3040
|
commission: BigInt # FIXME:*
|
|
2562
3041
|
node: Account
|
|
2563
|
-
rentSysvar:
|
|
3042
|
+
rentSysvar: Account
|
|
2564
3043
|
voteAccount: Account
|
|
2565
3044
|
}
|
|
2566
3045
|
|
|
@@ -2571,7 +3050,7 @@ var instructionTypeDefs = (
|
|
|
2571
3050
|
programId: Address
|
|
2572
3051
|
authority: Account
|
|
2573
3052
|
authorityType: String
|
|
2574
|
-
clockSysvar:
|
|
3053
|
+
clockSysvar: Account
|
|
2575
3054
|
newAuthority: Account
|
|
2576
3055
|
voteAccount: Account
|
|
2577
3056
|
}
|
|
@@ -2585,7 +3064,7 @@ var instructionTypeDefs = (
|
|
|
2585
3064
|
authorityOwner: Account
|
|
2586
3065
|
authoritySeed: String
|
|
2587
3066
|
authorityType: String
|
|
2588
|
-
clockSysvar:
|
|
3067
|
+
clockSysvar: Account
|
|
2589
3068
|
newAuthority: Account
|
|
2590
3069
|
voteAccount: Account
|
|
2591
3070
|
}
|
|
@@ -2599,7 +3078,7 @@ var instructionTypeDefs = (
|
|
|
2599
3078
|
authorityOwner: Account
|
|
2600
3079
|
authoritySeed: String
|
|
2601
3080
|
authorityType: String
|
|
2602
|
-
clockSysvar:
|
|
3081
|
+
clockSysvar: Account
|
|
2603
3082
|
newAuthority: Account
|
|
2604
3083
|
voteAccount: Account
|
|
2605
3084
|
}
|
|
@@ -2615,8 +3094,8 @@ var instructionTypeDefs = (
|
|
|
2615
3094
|
"""
|
|
2616
3095
|
type VoteVoteInstruction implements TransactionInstruction {
|
|
2617
3096
|
programId: Address
|
|
2618
|
-
clockSysvar:
|
|
2619
|
-
slotHashesSysvar:
|
|
3097
|
+
clockSysvar: Account
|
|
3098
|
+
slotHashesSysvar: Account
|
|
2620
3099
|
vote: Vote
|
|
2621
3100
|
voteAccount: Account
|
|
2622
3101
|
voteAuthority: Account
|
|
@@ -2713,9 +3192,9 @@ var instructionTypeDefs = (
|
|
|
2713
3192
|
"""
|
|
2714
3193
|
type VoteVoteSwitchInstruction implements TransactionInstruction {
|
|
2715
3194
|
programId: Address
|
|
2716
|
-
clockSysvar:
|
|
3195
|
+
clockSysvar: Account
|
|
2717
3196
|
hash: String
|
|
2718
|
-
slotHashesSysvar:
|
|
3197
|
+
slotHashesSysvar: Account
|
|
2719
3198
|
vote: Vote
|
|
2720
3199
|
voteAccount: Account
|
|
2721
3200
|
voteAuthority: Account
|
|
@@ -2728,7 +3207,7 @@ var instructionTypeDefs = (
|
|
|
2728
3207
|
programId: Address
|
|
2729
3208
|
authority: Account
|
|
2730
3209
|
authorityType: String
|
|
2731
|
-
clockSysvar:
|
|
3210
|
+
clockSysvar: Account
|
|
2732
3211
|
newAuthority: Account
|
|
2733
3212
|
voteAccount: Account
|
|
2734
3213
|
}
|
|
@@ -2740,28 +3219,20 @@ var rootTypeDefs = (
|
|
|
2740
3219
|
/* GraphQL */
|
|
2741
3220
|
`
|
|
2742
3221
|
type Query {
|
|
2743
|
-
account(
|
|
2744
|
-
address: String!
|
|
2745
|
-
commitment: Commitment
|
|
2746
|
-
dataSlice: DataSlice
|
|
2747
|
-
encoding: AccountEncoding
|
|
2748
|
-
minContextSlot: BigInt
|
|
2749
|
-
): Account
|
|
3222
|
+
account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
|
|
2750
3223
|
block(
|
|
2751
|
-
slot:
|
|
3224
|
+
slot: Slot!
|
|
2752
3225
|
commitment: Commitment
|
|
2753
3226
|
encoding: TransactionEncoding
|
|
2754
3227
|
transactionDetails: BlockTransactionDetails
|
|
2755
3228
|
): Block
|
|
2756
3229
|
programAccounts(
|
|
2757
|
-
programAddress:
|
|
3230
|
+
programAddress: Address!
|
|
2758
3231
|
commitment: Commitment
|
|
2759
|
-
dataSlice: DataSlice
|
|
2760
|
-
encoding: AccountEncoding
|
|
2761
3232
|
filters: [ProgramAccountsFilter]
|
|
2762
|
-
minContextSlot:
|
|
3233
|
+
minContextSlot: Slot
|
|
2763
3234
|
): [Account]
|
|
2764
|
-
transaction(signature:
|
|
3235
|
+
transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
|
|
2765
3236
|
}
|
|
2766
3237
|
|
|
2767
3238
|
schema {
|
|
@@ -2836,77 +3307,133 @@ var transactionTypeDefs = (
|
|
|
2836
3307
|
}
|
|
2837
3308
|
|
|
2838
3309
|
"""
|
|
2839
|
-
|
|
3310
|
+
A Solana transaction
|
|
2840
3311
|
"""
|
|
2841
|
-
|
|
3312
|
+
type Transaction {
|
|
2842
3313
|
blockTime: BigInt
|
|
3314
|
+
data(encoding: TransactionEncoding!): String
|
|
3315
|
+
message: TransactionMessage
|
|
2843
3316
|
meta: TransactionMeta
|
|
2844
|
-
|
|
3317
|
+
signatures: [Signature]
|
|
3318
|
+
slot: Slot
|
|
2845
3319
|
version: String
|
|
2846
3320
|
}
|
|
3321
|
+
`
|
|
3322
|
+
);
|
|
2847
3323
|
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
version: String
|
|
3324
|
+
// src/schema/types.ts
|
|
3325
|
+
var typeTypeDefs = (
|
|
3326
|
+
/* GraphQL */
|
|
3327
|
+
`
|
|
3328
|
+
enum AccountEncoding {
|
|
3329
|
+
BASE_58
|
|
3330
|
+
BASE_64
|
|
3331
|
+
BASE_64_ZSTD
|
|
2857
3332
|
}
|
|
2858
3333
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
3334
|
+
scalar Address
|
|
3335
|
+
|
|
3336
|
+
scalar Base58EncodedBytes
|
|
3337
|
+
|
|
3338
|
+
scalar Base64EncodedBytes
|
|
3339
|
+
|
|
3340
|
+
scalar Base64ZstdEncodedBytes
|
|
3341
|
+
|
|
3342
|
+
scalar BigInt
|
|
3343
|
+
|
|
3344
|
+
enum BlockTransactionDetails {
|
|
3345
|
+
ACCOUNTS
|
|
3346
|
+
FULL
|
|
3347
|
+
NONE
|
|
3348
|
+
SIGNATURES
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
enum Commitment {
|
|
3352
|
+
CONFIRMED
|
|
3353
|
+
FINALIZED
|
|
3354
|
+
PROCESSED
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3357
|
+
enum CommitmentWithoutProcessed {
|
|
3358
|
+
CONFIRMED
|
|
3359
|
+
FINALIZED
|
|
3360
|
+
}
|
|
3361
|
+
|
|
3362
|
+
input DataSlice {
|
|
3363
|
+
offset: Int!
|
|
3364
|
+
length: Int!
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
input ProgramAccountsFilter {
|
|
3368
|
+
bytes: BigInt
|
|
3369
|
+
dataSize: BigInt
|
|
3370
|
+
encoding: AccountEncoding
|
|
3371
|
+
offset: BigInt
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
type ReturnData {
|
|
2864
3375
|
data: Base64EncodedBytes
|
|
2865
|
-
|
|
2866
|
-
slot: BigInt
|
|
2867
|
-
version: String
|
|
3376
|
+
programId: Address
|
|
2868
3377
|
}
|
|
2869
3378
|
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3379
|
+
type Reward {
|
|
3380
|
+
commission: Int
|
|
3381
|
+
lamports: BigInt
|
|
3382
|
+
postBalance: BigInt
|
|
3383
|
+
pubkey: Address
|
|
3384
|
+
rewardType: String
|
|
2876
3385
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
3386
|
+
|
|
3387
|
+
scalar Signature
|
|
3388
|
+
|
|
3389
|
+
scalar Slot
|
|
3390
|
+
|
|
3391
|
+
type TokenAmount {
|
|
3392
|
+
amount: String
|
|
3393
|
+
decimals: Int
|
|
3394
|
+
uiAmount: BigInt
|
|
3395
|
+
uiAmountString: String
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3398
|
+
type TokenBalance {
|
|
3399
|
+
accountIndex: Int
|
|
3400
|
+
mint: Account
|
|
3401
|
+
owner: Account
|
|
3402
|
+
programId: Address
|
|
3403
|
+
uiTokenAmount: TokenAmount
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
enum TransactionEncoding {
|
|
3407
|
+
BASE_58
|
|
3408
|
+
BASE_64
|
|
3409
|
+
PARSED
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
enum TransactionVersion {
|
|
3413
|
+
LEGACY
|
|
3414
|
+
ZERO
|
|
2883
3415
|
}
|
|
2884
3416
|
`
|
|
2885
3417
|
);
|
|
2886
3418
|
|
|
2887
3419
|
// src/schema/index.ts
|
|
2888
3420
|
function createSolanaGraphQLTypeDefs() {
|
|
2889
|
-
return [
|
|
2890
|
-
accountTypeDefs,
|
|
2891
|
-
blockTypeDefs,
|
|
2892
|
-
commonTypeDefs,
|
|
2893
|
-
inputTypeDefs,
|
|
2894
|
-
instructionTypeDefs,
|
|
2895
|
-
rootTypeDefs,
|
|
2896
|
-
scalarTypeDefs,
|
|
2897
|
-
transactionTypeDefs
|
|
2898
|
-
];
|
|
3421
|
+
return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
|
|
2899
3422
|
}
|
|
2900
3423
|
|
|
2901
3424
|
// src/index.ts
|
|
2902
|
-
function createRpcGraphQL(rpc) {
|
|
3425
|
+
function createRpcGraphQL(rpc, config) {
|
|
3426
|
+
const rpcGraphQLConfig = {
|
|
3427
|
+
maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
|
|
3428
|
+
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
|
|
3429
|
+
};
|
|
2903
3430
|
const schema$1 = schema.makeExecutableSchema({
|
|
2904
3431
|
resolvers: createSolanaGraphQLResolvers(),
|
|
2905
3432
|
typeDefs: createSolanaGraphQLTypeDefs()
|
|
2906
3433
|
});
|
|
2907
3434
|
return {
|
|
2908
3435
|
async query(source, variableValues) {
|
|
2909
|
-
const contextValue = createSolanaGraphQLContext(rpc);
|
|
3436
|
+
const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
|
|
2910
3437
|
return graphql.graphql({
|
|
2911
3438
|
contextValue,
|
|
2912
3439
|
schema: schema$1,
|