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