@solana/rpc-graphql 2.0.0-experimental.f16a625 → 2.0.0-experimental.f4436f4
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 +1221 -752
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +1222 -753
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +1222 -753
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +1221 -752
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +1222 -753
- 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 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loaders/account.d.ts +12 -2
- package/dist/types/loaders/account.d.ts.map +1 -1
- 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 -10
- package/dist/types/loaders/loader.d.ts.map +1 -1
- package/dist/types/loaders/program-accounts.d.ts +5 -1
- package/dist/types/loaders/program-accounts.d.ts.map +1 -1
- package/dist/types/loaders/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/account.d.ts +160 -42
- package/dist/types/resolvers/account.d.ts.map +1 -1
- package/dist/types/resolvers/block.d.ts +95 -11
- package/dist/types/resolvers/block.d.ts.map +1 -1
- package/dist/types/resolvers/index.d.ts.map +1 -1
- package/dist/types/resolvers/instruction.d.ts +1531 -259
- package/dist/types/resolvers/instruction.d.ts.map +1 -1
- package/dist/types/resolvers/program-accounts.d.ts +12 -3
- package/dist/types/resolvers/program-accounts.d.ts.map +1 -1
- package/dist/types/resolvers/resolve-info/account.d.ts +15 -0
- package/dist/types/resolvers/resolve-info/account.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/block.d.ts +13 -0
- package/dist/types/resolvers/resolve-info/block.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/index.d.ts +6 -0
- package/dist/types/resolvers/resolve-info/index.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/program-accounts.d.ts +20 -0
- package/dist/types/resolvers/resolve-info/program-accounts.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/transaction.d.ts +15 -0
- package/dist/types/resolvers/resolve-info/transaction.d.ts.map +1 -0
- package/dist/types/resolvers/resolve-info/visitor.d.ts +18 -0
- package/dist/types/resolvers/resolve-info/visitor.d.ts.map +1 -0
- package/dist/types/resolvers/transaction.d.ts +32 -9
- package/dist/types/resolvers/transaction.d.ts.map +1 -1
- package/dist/types/resolvers/types.d.ts +77 -9
- package/dist/types/resolvers/types.d.ts.map +1 -1
- package/dist/types/schema/account.d.ts +1 -1
- package/dist/types/schema/account.d.ts.map +1 -1
- package/dist/types/schema/block.d.ts +1 -1
- package/dist/types/schema/block.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/dist/types/schema/instruction.d.ts +1 -1
- package/dist/types/schema/root.d.ts +1 -1
- package/dist/types/schema/root.d.ts.map +1 -1
- package/dist/types/schema/transaction.d.ts +1 -1
- package/dist/types/schema/transaction.d.ts.map +1 -1
- package/dist/types/schema/types.d.ts +2 -0
- package/dist/types/schema/types.d.ts.map +1 -0
- package/package.json +4 -3
- package/dist/types/resolvers/resolve-info.d.ts +0 -3
- package/dist/types/resolvers/resolve-info.d.ts.map +0 -1
- package/dist/types/resolvers/scalars.d.ts +0 -44
- package/dist/types/resolvers/scalars.d.ts.map +0 -1
- package/dist/types/schema/common/inputs.d.ts +0 -2
- package/dist/types/schema/common/inputs.d.ts.map +0 -1
- package/dist/types/schema/common/scalars.d.ts +0 -2
- package/dist/types/schema/common/scalars.d.ts.map +0 -1
- package/dist/types/schema/common/types.d.ts +0 -2
- package/dist/types/schema/common/types.d.ts.map +0 -1
package/dist/index.browser.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var schema = require('@graphql-tools/schema');
|
|
4
4
|
var graphql = require('graphql');
|
|
5
|
+
var codecsStrings = require('@solana/codecs-strings');
|
|
5
6
|
var DataLoader = require('dataloader');
|
|
6
7
|
var stringify = require('json-stable-stringify');
|
|
7
8
|
|
|
@@ -19,54 +20,270 @@ function replacer(_, value) {
|
|
|
19
20
|
}
|
|
20
21
|
var cacheKeyFn = (obj) => stringify__default.default(obj, { replacer });
|
|
21
22
|
|
|
23
|
+
// src/loaders/coalescer.ts
|
|
24
|
+
var hashOmit = (args, omit) => {
|
|
25
|
+
const argsObj = {};
|
|
26
|
+
for (const [key, value] of Object.entries(args)) {
|
|
27
|
+
if (!omit.includes(key)) {
|
|
28
|
+
argsObj[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return cacheKeyFn(argsObj);
|
|
32
|
+
};
|
|
33
|
+
function buildCoalescedFetchesByArgsHash(toFetchMap, orphanConfig) {
|
|
34
|
+
const fetchesByArgsHash = {};
|
|
35
|
+
const orphanedFetches = {};
|
|
36
|
+
Object.entries(toFetchMap).forEach(([signature, toFetch]) => {
|
|
37
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
38
|
+
if (orphanConfig.criteria(args)) {
|
|
39
|
+
const toFetch2 = orphanedFetches[signature] ||= [];
|
|
40
|
+
toFetch2.push({ args, promiseCallback });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const argsHash = hashOmit(args, []);
|
|
44
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
45
|
+
args,
|
|
46
|
+
fetches: {}
|
|
47
|
+
};
|
|
48
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
49
|
+
callbacks: []
|
|
50
|
+
};
|
|
51
|
+
promiseCallbacksForSignature.push(promiseCallback);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
Object.entries(orphanedFetches).forEach(([signature, toFetch]) => {
|
|
55
|
+
toFetch.forEach(({ args: orphanArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
56
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
57
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
58
|
+
if (hashOmit(orphanArgs, orphanConfig.hashOmit) === hashOmit(args2, orphanConfig.hashOmit)) {
|
|
59
|
+
const { callbacks: promiseCallbacksForSignature2 } = fetches[signature] ||= {
|
|
60
|
+
callbacks: []
|
|
61
|
+
};
|
|
62
|
+
promiseCallbacksForSignature2.push(orphanPromiseCallback);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const args = orphanConfig.defaults(orphanArgs);
|
|
68
|
+
const argsHash = hashOmit(args, []);
|
|
69
|
+
const transactionFetches = fetchesByArgsHash[argsHash] ||= {
|
|
70
|
+
args,
|
|
71
|
+
fetches: {}
|
|
72
|
+
};
|
|
73
|
+
const { callbacks: promiseCallbacksForSignature } = transactionFetches.fetches[signature] ||= {
|
|
74
|
+
callbacks: []
|
|
75
|
+
};
|
|
76
|
+
promiseCallbacksForSignature.push(orphanPromiseCallback);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
return fetchesByArgsHash;
|
|
80
|
+
}
|
|
81
|
+
function buildCoalescedFetchesByArgsHashWithDataSlice(toFetchMap, maxDataSliceByteRange) {
|
|
82
|
+
const fetchesByArgsHash = {};
|
|
83
|
+
const orphanedFetches = {};
|
|
84
|
+
Object.entries(toFetchMap).forEach(([address, toFetch]) => {
|
|
85
|
+
toFetch.forEach(({ args, promiseCallback }) => {
|
|
86
|
+
if (!args.encoding) {
|
|
87
|
+
const toFetch2 = orphanedFetches[address] ||= [];
|
|
88
|
+
toFetch2.push({ args, promiseCallback });
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (args.encoding != "base64+zstd" && args.dataSlice) {
|
|
92
|
+
const r = args.dataSlice;
|
|
93
|
+
for (const { fetches: fetchAddresses, args: fetchArgs } of Object.values(fetchesByArgsHash)) {
|
|
94
|
+
const addCallbackWithDataSlice = (updateDataSlice) => {
|
|
95
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetchAddresses[address] ||= {
|
|
96
|
+
callbacks: []
|
|
97
|
+
};
|
|
98
|
+
promiseCallbacksForAddress2.push({
|
|
99
|
+
callback: promiseCallback,
|
|
100
|
+
dataSlice: args.dataSlice ?? null
|
|
101
|
+
});
|
|
102
|
+
if (fetchArgs.dataSlice && updateDataSlice) {
|
|
103
|
+
fetchArgs.dataSlice = updateDataSlice;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (hashOmit(args, ["dataSlice"]) === hashOmit(fetchArgs, ["dataSlice"])) {
|
|
107
|
+
if (fetchArgs.dataSlice) {
|
|
108
|
+
const g = fetchArgs.dataSlice;
|
|
109
|
+
if (r.offset <= g.offset && g.offset - r.offset + r.length <= maxDataSliceByteRange) {
|
|
110
|
+
const length = Math.max(r.length, g.offset + g.length - r.offset);
|
|
111
|
+
const offset = r.offset;
|
|
112
|
+
addCallbackWithDataSlice({ length, offset });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (r.offset >= g.offset && r.offset - g.offset + g.length <= maxDataSliceByteRange) {
|
|
116
|
+
const length = Math.max(g.length, r.offset + r.length - g.offset);
|
|
117
|
+
const offset = g.offset;
|
|
118
|
+
addCallbackWithDataSlice({ length, offset });
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
const { length, offset } = r;
|
|
123
|
+
addCallbackWithDataSlice({ length, offset });
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const argsHash = hashOmit(args, []);
|
|
130
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
131
|
+
args,
|
|
132
|
+
fetches: {}
|
|
133
|
+
};
|
|
134
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
135
|
+
callbacks: []
|
|
136
|
+
};
|
|
137
|
+
promiseCallbacksForAddress.push({ callback: promiseCallback, dataSlice: args.dataSlice ?? null });
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
Object.entries(orphanedFetches).forEach(([address, toFetch]) => {
|
|
141
|
+
toFetch.forEach(({ args: orphanedArgs, promiseCallback: orphanPromiseCallback }) => {
|
|
142
|
+
if (Object.keys(fetchesByArgsHash).length !== 0) {
|
|
143
|
+
for (const { fetches, args: args2 } of Object.values(fetchesByArgsHash)) {
|
|
144
|
+
if (hashOmit(orphanedArgs, ["encoding", "dataSlice"]) === hashOmit(args2, ["encoding", "dataSlice"])) {
|
|
145
|
+
const { callbacks: promiseCallbacksForAddress2 } = fetches[address] ||= {
|
|
146
|
+
callbacks: []
|
|
147
|
+
};
|
|
148
|
+
promiseCallbacksForAddress2.push({ callback: orphanPromiseCallback });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const args = { ...orphanedArgs, encoding: "base64" };
|
|
154
|
+
const argsHash = hashOmit(args, []);
|
|
155
|
+
const accountFetches = fetchesByArgsHash[argsHash] ||= {
|
|
156
|
+
args,
|
|
157
|
+
fetches: {}
|
|
158
|
+
};
|
|
159
|
+
const { callbacks: promiseCallbacksForAddress } = accountFetches.fetches[address] ||= {
|
|
160
|
+
callbacks: []
|
|
161
|
+
};
|
|
162
|
+
promiseCallbacksForAddress.push({ callback: orphanPromiseCallback });
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
return fetchesByArgsHash;
|
|
166
|
+
}
|
|
167
|
+
|
|
22
168
|
// src/loaders/account.ts
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
encoding
|
|
35
|
-
|
|
36
|
-
|
|
169
|
+
function getCodec(encoding) {
|
|
170
|
+
switch (encoding) {
|
|
171
|
+
case "base58":
|
|
172
|
+
return codecsStrings.getBase58Codec();
|
|
173
|
+
default:
|
|
174
|
+
return codecsStrings.getBase64Codec();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function sliceData(account, dataSlice, masterDataSlice) {
|
|
178
|
+
if (dataSlice) {
|
|
179
|
+
const masterOffset = masterDataSlice ? masterDataSlice.offset : 0;
|
|
180
|
+
const slicedData = (data, encoding) => {
|
|
181
|
+
if (encoding === "base64+zstd") {
|
|
182
|
+
return data;
|
|
183
|
+
}
|
|
184
|
+
const { offset, length } = dataSlice;
|
|
185
|
+
const trueOffset = offset - masterOffset;
|
|
186
|
+
const codec = getCodec(encoding);
|
|
187
|
+
return codec.decode(codec.encode(data).slice(trueOffset, trueOffset + length));
|
|
188
|
+
};
|
|
189
|
+
if (Array.isArray(account.data)) {
|
|
190
|
+
const [data, encoding] = account.data;
|
|
191
|
+
return {
|
|
192
|
+
...account,
|
|
193
|
+
data: [slicedData(data, encoding), encoding]
|
|
194
|
+
};
|
|
195
|
+
} else if (typeof account.data === "string") {
|
|
196
|
+
const data = account.data;
|
|
197
|
+
return {
|
|
198
|
+
...account,
|
|
199
|
+
data: slicedData(data, "base58")
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return account;
|
|
37
204
|
}
|
|
38
205
|
async function loadAccount(rpc, { address, ...config }) {
|
|
39
206
|
return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
|
|
40
207
|
}
|
|
41
|
-
function
|
|
208
|
+
async function loadMultipleAccounts(rpc, { addresses, ...config }) {
|
|
209
|
+
return await rpc.getMultipleAccounts(addresses, config).send().then((res) => res.value);
|
|
210
|
+
}
|
|
211
|
+
function createAccountBatchLoadFn(rpc, config) {
|
|
42
212
|
const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
|
|
213
|
+
const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc);
|
|
43
214
|
return async (accountQueryArgs) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
215
|
+
const accountsToFetch = {};
|
|
216
|
+
try {
|
|
217
|
+
return Promise.all(
|
|
218
|
+
accountQueryArgs.map(
|
|
219
|
+
({ address, ...args }) => new Promise((resolve, reject) => {
|
|
220
|
+
const accountRecords = accountsToFetch[address] ||= [];
|
|
221
|
+
if (!args.commitment) {
|
|
222
|
+
args.commitment = "confirmed";
|
|
223
|
+
}
|
|
224
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
} finally {
|
|
229
|
+
const { maxDataSliceByteRange, maxMultipleAccountsBatchSize } = config;
|
|
230
|
+
const accountFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
231
|
+
accountsToFetch,
|
|
232
|
+
maxDataSliceByteRange
|
|
233
|
+
);
|
|
234
|
+
Object.values(accountFetchesByArgsHash).map(({ args, fetches: addressCallbacks }) => {
|
|
235
|
+
const addresses = Object.keys(addressCallbacks);
|
|
236
|
+
if (addresses.length === 1) {
|
|
237
|
+
const address = addresses[0];
|
|
238
|
+
return Array.from({ length: 1 }, async () => {
|
|
239
|
+
try {
|
|
240
|
+
const result = await resolveAccountUsingRpc({ address, ...args });
|
|
241
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
242
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
243
|
+
});
|
|
244
|
+
} catch (e) {
|
|
245
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
246
|
+
callback.reject(e);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
} else {
|
|
251
|
+
return Array.from(
|
|
252
|
+
{ length: Math.ceil(addresses.length / maxMultipleAccountsBatchSize) },
|
|
253
|
+
async (_, ii) => {
|
|
254
|
+
const startIndex = ii * maxMultipleAccountsBatchSize;
|
|
255
|
+
const endIndex = startIndex + maxMultipleAccountsBatchSize;
|
|
256
|
+
const chunk = addresses.slice(startIndex, endIndex);
|
|
257
|
+
try {
|
|
258
|
+
const results = await resolveMultipleAccountsUsingRpc({
|
|
259
|
+
addresses: chunk,
|
|
260
|
+
...args
|
|
261
|
+
});
|
|
262
|
+
chunk.forEach((address, ii2) => {
|
|
263
|
+
const result = results[ii2];
|
|
264
|
+
addressCallbacks[address].callbacks.forEach(({ callback, dataSlice }) => {
|
|
265
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
} catch (e) {
|
|
269
|
+
chunk.forEach((address) => {
|
|
270
|
+
addressCallbacks[address].callbacks.forEach(({ callback }) => {
|
|
271
|
+
callback.reject(e);
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}
|
|
53
280
|
};
|
|
54
281
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
commitment,
|
|
58
|
-
encoding = "jsonParsed",
|
|
59
|
-
maxSupportedTransactionVersion = 0,
|
|
60
|
-
rewards,
|
|
61
|
-
transactionDetails = "full"
|
|
62
|
-
}) {
|
|
282
|
+
function createAccountLoader(rpc, config) {
|
|
283
|
+
const loader = new DataLoader__default.default(createAccountBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
63
284
|
return {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
maxSupportedTransactionVersion,
|
|
67
|
-
rewards,
|
|
68
|
-
slot,
|
|
69
|
-
transactionDetails
|
|
285
|
+
load: async (args) => loader.load(args),
|
|
286
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
70
287
|
};
|
|
71
288
|
}
|
|
72
289
|
async function loadBlock(rpc, { slot, ...config }) {
|
|
@@ -79,30 +296,51 @@ async function loadBlock(rpc, { slot, ...config }) {
|
|
|
79
296
|
function createBlockBatchLoadFn(rpc) {
|
|
80
297
|
const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
|
|
81
298
|
return async (blockQueryArgs) => {
|
|
82
|
-
|
|
299
|
+
const blocksToFetch = {};
|
|
300
|
+
try {
|
|
301
|
+
return Promise.all(
|
|
302
|
+
blockQueryArgs.map(
|
|
303
|
+
({ slot, ...args }) => new Promise((resolve, reject) => {
|
|
304
|
+
const blockRecords = blocksToFetch[slot.toString()] ||= [];
|
|
305
|
+
if (!args.commitment) {
|
|
306
|
+
args.commitment = "confirmed";
|
|
307
|
+
}
|
|
308
|
+
blockRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
309
|
+
})
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
} finally {
|
|
313
|
+
const blockFetchesByArgsHash = buildCoalescedFetchesByArgsHash(blocksToFetch, {
|
|
314
|
+
criteria: (args) => args.encoding === void 0 && args.transactionDetails !== "signatures",
|
|
315
|
+
defaults: (args) => ({
|
|
316
|
+
...args,
|
|
317
|
+
transactionDetails: "none"
|
|
318
|
+
}),
|
|
319
|
+
hashOmit: ["encoding", "transactionDetails"]
|
|
320
|
+
});
|
|
321
|
+
Object.values(blockFetchesByArgsHash).map(({ args, fetches: blockCallbacks }) => {
|
|
322
|
+
return Object.entries(blockCallbacks).map(([slot, { callbacks }]) => {
|
|
323
|
+
return Array.from({ length: 1 }, async () => {
|
|
324
|
+
try {
|
|
325
|
+
const result = await resolveBlockUsingRpc({
|
|
326
|
+
slot: BigInt(slot),
|
|
327
|
+
...args
|
|
328
|
+
});
|
|
329
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
330
|
+
} catch (e) {
|
|
331
|
+
callbacks.forEach((c) => c.reject(e));
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
83
337
|
};
|
|
84
338
|
}
|
|
85
339
|
function createBlockLoader(rpc) {
|
|
86
340
|
const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
|
|
87
341
|
return {
|
|
88
|
-
load: async (args) => loader.load(
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
function applyDefaultArgs3({
|
|
92
|
-
commitment,
|
|
93
|
-
dataSlice,
|
|
94
|
-
encoding = "jsonParsed",
|
|
95
|
-
filters,
|
|
96
|
-
minContextSlot,
|
|
97
|
-
programAddress
|
|
98
|
-
}) {
|
|
99
|
-
return {
|
|
100
|
-
commitment,
|
|
101
|
-
dataSlice,
|
|
102
|
-
encoding,
|
|
103
|
-
filters,
|
|
104
|
-
minContextSlot,
|
|
105
|
-
programAddress
|
|
342
|
+
load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
|
|
343
|
+
loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
|
|
106
344
|
};
|
|
107
345
|
}
|
|
108
346
|
async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
@@ -112,29 +350,55 @@ async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
|
112
350
|
config
|
|
113
351
|
).send();
|
|
114
352
|
}
|
|
115
|
-
function createProgramAccountsBatchLoadFn(rpc) {
|
|
353
|
+
function createProgramAccountsBatchLoadFn(rpc, config) {
|
|
116
354
|
const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
|
|
117
|
-
return async (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
355
|
+
return async (accountQueryArgs) => {
|
|
356
|
+
const programAccountsToFetch = {};
|
|
357
|
+
try {
|
|
358
|
+
return Promise.all(
|
|
359
|
+
accountQueryArgs.map(
|
|
360
|
+
({ programAddress, ...args }) => new Promise((resolve, reject) => {
|
|
361
|
+
const accountRecords = programAccountsToFetch[programAddress] ||= [];
|
|
362
|
+
if (!args.commitment) {
|
|
363
|
+
args.commitment = "confirmed";
|
|
364
|
+
}
|
|
365
|
+
accountRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
366
|
+
})
|
|
367
|
+
)
|
|
368
|
+
);
|
|
369
|
+
} finally {
|
|
370
|
+
const { maxDataSliceByteRange } = config;
|
|
371
|
+
const programAccountsFetchesByArgsHash = buildCoalescedFetchesByArgsHashWithDataSlice(
|
|
372
|
+
programAccountsToFetch,
|
|
373
|
+
maxDataSliceByteRange
|
|
374
|
+
);
|
|
375
|
+
Object.values(programAccountsFetchesByArgsHash).map(({ args, fetches: programAddressCallbacks }) => {
|
|
376
|
+
return Object.entries(programAddressCallbacks).map(([programAddress, { callbacks }]) => {
|
|
377
|
+
return Array.from({ length: 1 }, async () => {
|
|
378
|
+
try {
|
|
379
|
+
const result = await resolveProgramAccountsUsingRpc({
|
|
380
|
+
programAddress,
|
|
381
|
+
...args
|
|
382
|
+
});
|
|
383
|
+
callbacks.forEach(({ callback, dataSlice }) => {
|
|
384
|
+
callback.resolve(sliceData(result, dataSlice, args.dataSlice));
|
|
385
|
+
});
|
|
386
|
+
} catch (e) {
|
|
387
|
+
callbacks.forEach(({ callback }) => {
|
|
388
|
+
callback.reject(e);
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
}
|
|
127
395
|
};
|
|
128
396
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
encoding = "jsonParsed",
|
|
132
|
-
signature
|
|
133
|
-
}) {
|
|
397
|
+
function createProgramAccountsLoader(rpc, config) {
|
|
398
|
+
const loader = new DataLoader__default.default(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
134
399
|
return {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
signature
|
|
400
|
+
load: async (args) => loader.load(args),
|
|
401
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
138
402
|
};
|
|
139
403
|
}
|
|
140
404
|
async function loadTransaction(rpc, { signature, ...config }) {
|
|
@@ -147,163 +411,388 @@ async function loadTransaction(rpc, { signature, ...config }) {
|
|
|
147
411
|
function createTransactionBatchLoadFn(rpc) {
|
|
148
412
|
const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
|
|
149
413
|
return async (transactionQueryArgs) => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
414
|
+
const transactionsToFetch = {};
|
|
415
|
+
try {
|
|
416
|
+
return Promise.all(
|
|
417
|
+
transactionQueryArgs.map(
|
|
418
|
+
({ signature, ...args }) => new Promise((resolve, reject) => {
|
|
419
|
+
const transactionRecords = transactionsToFetch[signature] ||= [];
|
|
420
|
+
if (!args.commitment) {
|
|
421
|
+
args.commitment = "confirmed";
|
|
422
|
+
}
|
|
423
|
+
transactionRecords.push({ args, promiseCallback: { reject, resolve } });
|
|
424
|
+
})
|
|
425
|
+
)
|
|
426
|
+
);
|
|
427
|
+
} finally {
|
|
428
|
+
const transactionFetchesByArgsHash = buildCoalescedFetchesByArgsHash(transactionsToFetch, {
|
|
429
|
+
criteria: (args) => args.encoding === void 0,
|
|
430
|
+
defaults: (args) => ({ ...args, encoding: "base64" }),
|
|
431
|
+
hashOmit: ["encoding"]
|
|
432
|
+
});
|
|
433
|
+
Object.values(transactionFetchesByArgsHash).map(({ args, fetches: transactionCallbacks }) => {
|
|
434
|
+
return Object.entries(transactionCallbacks).map(([signature, { callbacks }]) => {
|
|
435
|
+
return Array.from({ length: 1 }, async () => {
|
|
436
|
+
try {
|
|
437
|
+
const result = await resolveTransactionUsingRpc({
|
|
438
|
+
signature,
|
|
439
|
+
...args
|
|
440
|
+
});
|
|
441
|
+
callbacks.forEach((c) => c.resolve(result));
|
|
442
|
+
} catch (e) {
|
|
443
|
+
callbacks.forEach((c) => c.reject(e));
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
}
|
|
153
449
|
};
|
|
154
450
|
}
|
|
155
451
|
function createTransactionLoader(rpc) {
|
|
156
452
|
const loader = new DataLoader__default.default(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
|
|
157
453
|
return {
|
|
158
|
-
load: async (args) => loader.load(
|
|
454
|
+
load: async (args) => loader.load(args),
|
|
455
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
159
456
|
};
|
|
160
457
|
}
|
|
161
458
|
|
|
162
459
|
// src/context.ts
|
|
163
|
-
function createSolanaGraphQLContext(rpc) {
|
|
460
|
+
function createSolanaGraphQLContext(rpc, config) {
|
|
164
461
|
return {
|
|
165
462
|
loaders: {
|
|
166
|
-
account: createAccountLoader(rpc),
|
|
463
|
+
account: createAccountLoader(rpc, config),
|
|
167
464
|
block: createBlockLoader(rpc),
|
|
168
|
-
programAccounts: createProgramAccountsLoader(rpc),
|
|
465
|
+
programAccounts: createProgramAccountsLoader(rpc, config),
|
|
169
466
|
transaction: createTransactionLoader(rpc)
|
|
170
467
|
}
|
|
171
468
|
};
|
|
172
469
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
470
|
+
function injectableRootVisitor(info, rootNode, operations) {
|
|
471
|
+
const { fieldNodes } = info;
|
|
472
|
+
const root = rootNode ?? fieldNodes[0];
|
|
473
|
+
const parentIsRoot = (ancestors) => (Array.isArray(ancestors) ? ancestors[0] : ancestors) === root;
|
|
474
|
+
graphql.visit(root, {
|
|
475
|
+
Field(node, key, parent, path, ancestors) {
|
|
476
|
+
if (!parentIsRoot(ancestors))
|
|
477
|
+
return;
|
|
478
|
+
return operations.fieldNodeOperation(info, node, key, parent, path, ancestors);
|
|
479
|
+
},
|
|
480
|
+
FragmentSpread(node, key, parent, path, ancestors) {
|
|
481
|
+
const fragmentDefinition = info.fragments[node.name.value];
|
|
482
|
+
return operations.fragmentSpreadNodeOperation(info, fragmentDefinition, node, key, parent, path, ancestors);
|
|
483
|
+
},
|
|
484
|
+
InlineFragment(node, key, parent, path, ancestors) {
|
|
485
|
+
if (!parentIsRoot(ancestors))
|
|
486
|
+
return;
|
|
487
|
+
return operations.inlineFragmentNodeOperation(info, node, key, parent, path, ancestors);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
function onlyFieldsRequested(fieldNames, info, rootNode) {
|
|
492
|
+
let onlyFieldsRequested2 = true;
|
|
493
|
+
function checkFieldsWithVisitor(root) {
|
|
494
|
+
injectableRootVisitor(info, root, {
|
|
495
|
+
fieldNodeOperation(_info, node) {
|
|
496
|
+
onlyFieldsRequested2 = fieldNames.includes(node.name.value);
|
|
497
|
+
if (!onlyFieldsRequested2) {
|
|
498
|
+
return graphql.BREAK;
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
502
|
+
checkFieldsWithVisitor(fragment);
|
|
503
|
+
},
|
|
504
|
+
inlineFragmentNodeOperation(_info, node) {
|
|
505
|
+
checkFieldsWithVisitor(node);
|
|
181
506
|
}
|
|
182
|
-
return null;
|
|
183
507
|
});
|
|
184
|
-
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === fieldName) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
508
|
}
|
|
188
|
-
|
|
509
|
+
checkFieldsWithVisitor(rootNode ?? null);
|
|
510
|
+
return onlyFieldsRequested2;
|
|
189
511
|
}
|
|
190
512
|
|
|
191
|
-
// src/resolvers/account.ts
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
parsed: { info: result, type: accountType },
|
|
195
|
-
program: programName,
|
|
196
|
-
programId
|
|
197
|
-
} = parsedAccountData;
|
|
198
|
-
result.accountType = accountType;
|
|
199
|
-
result.programId = programId;
|
|
200
|
-
result.programName = programName;
|
|
201
|
-
return result;
|
|
513
|
+
// src/resolvers/resolve-info/account.ts
|
|
514
|
+
function findArgumentNodeByName(argumentNodes, name) {
|
|
515
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
202
516
|
}
|
|
203
|
-
function
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// but the data could not be parsed.
|
|
217
|
-
// Defaults to base64 encoding.
|
|
218
|
-
[{ data: account.data[0] }, "base64"]
|
|
219
|
-
) : (
|
|
220
|
-
// The requested encoding is base58,
|
|
221
|
-
// base64, or base64+zstd.
|
|
222
|
-
[{ data: account.data[0] }, encoding]
|
|
223
|
-
) : (
|
|
224
|
-
// The account data was returned as an object,
|
|
225
|
-
// so it was parsed successfully.
|
|
226
|
-
[transformParsedAccountData(account.data), "jsonParsed"]
|
|
227
|
-
);
|
|
228
|
-
account.address = address;
|
|
229
|
-
account.encoding = responseEncoding;
|
|
230
|
-
account.ownerProgram = account.owner;
|
|
231
|
-
return {
|
|
232
|
-
...account,
|
|
233
|
-
...data
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
var resolveAccount = (fieldName) => {
|
|
237
|
-
return async (parent, args, context, info) => {
|
|
238
|
-
const address = fieldName ? parent[fieldName] : args.address;
|
|
239
|
-
if (!address) {
|
|
240
|
-
return null;
|
|
517
|
+
function parseAccountEncodingArgument(argumentNodes, variableValues) {
|
|
518
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "encoding");
|
|
519
|
+
if (argumentNode) {
|
|
520
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
521
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
522
|
+
return "base58";
|
|
523
|
+
}
|
|
524
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
525
|
+
return "base64";
|
|
526
|
+
}
|
|
527
|
+
if (argumentNode.value.value === "BASE_64_ZSTD") {
|
|
528
|
+
return "base64+zstd";
|
|
529
|
+
}
|
|
241
530
|
}
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
531
|
+
if (argumentNode.value.kind === "Variable") {
|
|
532
|
+
return variableValues[argumentNode.value.name.value];
|
|
244
533
|
}
|
|
245
|
-
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
534
|
+
} else {
|
|
535
|
+
return void 0;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
function parseAccountDataSliceArgument(argumentNodes, variableValues) {
|
|
539
|
+
const argumentNode = findArgumentNodeByName(argumentNodes, "dataSlice");
|
|
540
|
+
if (argumentNode) {
|
|
541
|
+
if (argumentNode.value.kind === "ObjectValue") {
|
|
542
|
+
const offsetArg = argumentNode.value.fields?.find((field) => field.name.value === "offset");
|
|
543
|
+
const lengthArg = argumentNode.value.fields?.find((field) => field.name.value === "length");
|
|
544
|
+
const length = lengthArg?.value.kind === "IntValue" ? parseInt(lengthArg.value.value) : lengthArg?.value.kind === "Variable" ? variableValues[lengthArg.value.name.value] : void 0;
|
|
545
|
+
const offset = offsetArg?.value.kind === "IntValue" ? parseInt(offsetArg.value.value) : offsetArg?.value.kind === "Variable" ? variableValues[offsetArg.value.name.value] : void 0;
|
|
546
|
+
return length !== void 0 && length !== null && offset !== void 0 && offset !== null ? { length, offset } : void 0;
|
|
547
|
+
}
|
|
548
|
+
if (argumentNode.value.kind === "Variable") {
|
|
549
|
+
return variableValues[argumentNode.value.name.value];
|
|
550
|
+
}
|
|
551
|
+
} else {
|
|
552
|
+
return void 0;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function buildAccountArgSetWithVisitor(args, info) {
|
|
556
|
+
const argSet = [args];
|
|
557
|
+
function buildArgSetWithVisitor(root) {
|
|
558
|
+
injectableRootVisitor(info, root, {
|
|
559
|
+
fieldNodeOperation(info2, node) {
|
|
560
|
+
if (node.name.value !== "data") {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
if (node.arguments) {
|
|
564
|
+
const { variableValues } = info2;
|
|
565
|
+
const encoding = parseAccountEncodingArgument(node.arguments, variableValues);
|
|
566
|
+
const dataSlice = parseAccountDataSliceArgument(node.arguments, variableValues);
|
|
567
|
+
argSet.push({ ...args, dataSlice, encoding });
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
571
|
+
buildArgSetWithVisitor(fragment);
|
|
572
|
+
},
|
|
573
|
+
inlineFragmentNodeOperation(info2, node) {
|
|
574
|
+
const { schema } = info2;
|
|
575
|
+
const accountInterface = schema.getType("Account");
|
|
576
|
+
if (graphql.isInterfaceType(accountInterface) && // Recursively check if the inline fragment requests any
|
|
577
|
+
// fields outside of the `Account` interface.
|
|
578
|
+
!onlyFieldsRequested(Object.keys(accountInterface.getFields()), info2, node)) {
|
|
579
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
580
|
+
}
|
|
254
581
|
}
|
|
255
|
-
|
|
256
|
-
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
buildArgSetWithVisitor(null);
|
|
585
|
+
return argSet;
|
|
586
|
+
}
|
|
587
|
+
function buildAccountLoaderArgSetFromResolveInfo(args, info) {
|
|
588
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// src/resolvers/resolve-info/transaction.ts
|
|
592
|
+
function findArgumentNodeByName2(argumentNodes, name) {
|
|
593
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
594
|
+
}
|
|
595
|
+
function parseTransactionEncodingArgument(argumentNodes, variableValues) {
|
|
596
|
+
const argumentNode = findArgumentNodeByName2(argumentNodes, "encoding");
|
|
597
|
+
if (argumentNode) {
|
|
598
|
+
if (argumentNode.value.kind === "EnumValue") {
|
|
599
|
+
if (argumentNode.value.value === "BASE_58") {
|
|
600
|
+
return "base58";
|
|
257
601
|
}
|
|
258
|
-
if (
|
|
259
|
-
return "
|
|
602
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
603
|
+
return "base64";
|
|
260
604
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
605
|
+
}
|
|
606
|
+
if (argumentNode.value.kind === "Variable") {
|
|
607
|
+
return variableValues[argumentNode.value.name.value];
|
|
608
|
+
}
|
|
609
|
+
} else {
|
|
610
|
+
return void 0;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function buildTransactionArgSetWithVisitor(args, info) {
|
|
614
|
+
const argSet = [args];
|
|
615
|
+
function buildArgSetWithVisitor(root) {
|
|
616
|
+
injectableRootVisitor(info, root, {
|
|
617
|
+
fieldNodeOperation(info2, node) {
|
|
618
|
+
if (node.name.value === "message" || node.name.value === "meta") {
|
|
619
|
+
argSet.push({ ...args, encoding: "jsonParsed" });
|
|
620
|
+
} else if (node.name.value === "data") {
|
|
621
|
+
if (node.arguments) {
|
|
622
|
+
const { variableValues } = info2;
|
|
623
|
+
const encoding = parseTransactionEncodingArgument(
|
|
624
|
+
node.arguments,
|
|
625
|
+
variableValues
|
|
626
|
+
);
|
|
627
|
+
argSet.push({ ...args, encoding });
|
|
628
|
+
}
|
|
264
629
|
}
|
|
265
|
-
|
|
266
|
-
|
|
630
|
+
},
|
|
631
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
632
|
+
buildArgSetWithVisitor(fragment);
|
|
633
|
+
},
|
|
634
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
635
|
+
return;
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
buildArgSetWithVisitor(null);
|
|
640
|
+
return argSet;
|
|
641
|
+
}
|
|
642
|
+
function buildTransactionLoaderArgSetFromResolveInfo(args, info) {
|
|
643
|
+
return buildTransactionArgSetWithVisitor(args, info);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// src/resolvers/resolve-info/block.ts
|
|
647
|
+
function buildBlockLoaderArgSetFromResolveInfo(args, info) {
|
|
648
|
+
const argSet = [args];
|
|
649
|
+
function buildArgSetWithVisitor(root) {
|
|
650
|
+
injectableRootVisitor(info, root, {
|
|
651
|
+
fieldNodeOperation(info2, node) {
|
|
652
|
+
if (node.name.value === "signatures") {
|
|
653
|
+
argSet.push({ ...args, transactionDetails: "signatures" });
|
|
654
|
+
} else if (node.name.value === "transactions") {
|
|
655
|
+
argSet.push(...buildTransactionArgSetWithVisitor({ ...args, transactionDetails: "full" }, info2));
|
|
267
656
|
}
|
|
268
|
-
|
|
269
|
-
|
|
657
|
+
},
|
|
658
|
+
fragmentSpreadNodeOperation(_info, fragment) {
|
|
659
|
+
buildArgSetWithVisitor(fragment);
|
|
660
|
+
},
|
|
661
|
+
inlineFragmentNodeOperation(_info, _node) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
buildArgSetWithVisitor(null);
|
|
667
|
+
return argSet;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// src/resolvers/resolve-info/program-accounts.ts
|
|
671
|
+
function buildProgramAccountsLoaderArgSetFromResolveInfo(args, info) {
|
|
672
|
+
return buildAccountArgSetWithVisitor(args, info);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// src/resolvers/account.ts
|
|
676
|
+
var resolveAccountData = () => {
|
|
677
|
+
return (parent, args) => {
|
|
678
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
var resolveAccount = (fieldName) => {
|
|
682
|
+
return async (parent, args, context, info) => {
|
|
683
|
+
const address = fieldName ? parent[fieldName] : args.address;
|
|
684
|
+
if (address) {
|
|
685
|
+
if (onlyFieldsRequested(["address"], info)) {
|
|
686
|
+
return { address };
|
|
687
|
+
}
|
|
688
|
+
const argsSet = buildAccountLoaderArgSetFromResolveInfo({ ...args, address }, info);
|
|
689
|
+
const loadedAccounts = await context.loaders.account.loadMany(argsSet);
|
|
690
|
+
let result = {
|
|
691
|
+
address,
|
|
692
|
+
encodedData: {}
|
|
693
|
+
};
|
|
694
|
+
loadedAccounts.forEach((account, i) => {
|
|
695
|
+
if (account instanceof Error) {
|
|
696
|
+
console.error(account);
|
|
697
|
+
return;
|
|
270
698
|
}
|
|
271
|
-
if (account
|
|
272
|
-
return
|
|
699
|
+
if (account === null) {
|
|
700
|
+
return;
|
|
273
701
|
}
|
|
274
|
-
if (
|
|
275
|
-
|
|
702
|
+
if (!result.ownerProgram) {
|
|
703
|
+
result = {
|
|
704
|
+
...result,
|
|
705
|
+
...account,
|
|
706
|
+
ownerProgram: account.owner
|
|
707
|
+
};
|
|
276
708
|
}
|
|
277
|
-
|
|
278
|
-
|
|
709
|
+
const { data } = account;
|
|
710
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
711
|
+
if (encoding && result.encodedData) {
|
|
712
|
+
if (Array.isArray(data)) {
|
|
713
|
+
result.encodedData[cacheKeyFn({
|
|
714
|
+
dataSlice,
|
|
715
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
716
|
+
})] = data[0];
|
|
717
|
+
} else if (typeof data === "string") {
|
|
718
|
+
result.encodedData[cacheKeyFn({
|
|
719
|
+
dataSlice,
|
|
720
|
+
encoding: "base58"
|
|
721
|
+
})] = data;
|
|
722
|
+
} else if (typeof data === "object") {
|
|
723
|
+
const {
|
|
724
|
+
parsed: { info: parsedData, type: accountType },
|
|
725
|
+
program: programName,
|
|
726
|
+
programId
|
|
727
|
+
} = data;
|
|
728
|
+
result.jsonParsedConfigs = {
|
|
729
|
+
accountType,
|
|
730
|
+
programId,
|
|
731
|
+
programName
|
|
732
|
+
};
|
|
733
|
+
result = {
|
|
734
|
+
...result,
|
|
735
|
+
...parsedData
|
|
736
|
+
};
|
|
737
|
+
}
|
|
279
738
|
}
|
|
280
|
-
}
|
|
281
|
-
return
|
|
739
|
+
});
|
|
740
|
+
return result;
|
|
282
741
|
}
|
|
742
|
+
return null;
|
|
743
|
+
};
|
|
744
|
+
};
|
|
745
|
+
function resolveAccountType(accountResult) {
|
|
746
|
+
const { jsonParsedConfigs } = accountResult;
|
|
747
|
+
if (jsonParsedConfigs) {
|
|
748
|
+
if (jsonParsedConfigs.programName === "nonce") {
|
|
749
|
+
return "NonceAccount";
|
|
750
|
+
}
|
|
751
|
+
if (jsonParsedConfigs.accountType === "mint" && jsonParsedConfigs.programName === "spl-token") {
|
|
752
|
+
return "MintAccount";
|
|
753
|
+
}
|
|
754
|
+
if (jsonParsedConfigs.accountType === "account" && jsonParsedConfigs.programName === "spl-token") {
|
|
755
|
+
return "TokenAccount";
|
|
756
|
+
}
|
|
757
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
758
|
+
return "StakeAccount";
|
|
759
|
+
}
|
|
760
|
+
if (jsonParsedConfigs.accountType === "vote" && jsonParsedConfigs.programName === "vote") {
|
|
761
|
+
return "VoteAccount";
|
|
762
|
+
}
|
|
763
|
+
if (jsonParsedConfigs.accountType === "lookupTable" && jsonParsedConfigs.programName === "address-lookup-table") {
|
|
764
|
+
return "LookupTableAccount";
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return "GenericAccount";
|
|
768
|
+
}
|
|
769
|
+
var accountResolvers = {
|
|
770
|
+
Account: {
|
|
771
|
+
__resolveType: resolveAccountType,
|
|
772
|
+
data: resolveAccountData()
|
|
283
773
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
},
|
|
287
|
-
AccountBase64: {
|
|
288
|
-
ownerProgram: resolveAccount("ownerProgram")
|
|
289
|
-
},
|
|
290
|
-
AccountBase64Zstd: {
|
|
774
|
+
GenericAccount: {
|
|
775
|
+
data: resolveAccountData(),
|
|
291
776
|
ownerProgram: resolveAccount("ownerProgram")
|
|
292
777
|
},
|
|
293
778
|
LookupTableAccount: {
|
|
294
779
|
authority: resolveAccount("authority"),
|
|
780
|
+
data: resolveAccountData(),
|
|
295
781
|
ownerProgram: resolveAccount("ownerProgram")
|
|
296
782
|
},
|
|
297
783
|
MintAccount: {
|
|
784
|
+
data: resolveAccountData(),
|
|
298
785
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
299
786
|
mintAuthority: resolveAccount("mintAuthority"),
|
|
300
787
|
ownerProgram: resolveAccount("ownerProgram")
|
|
301
788
|
},
|
|
302
789
|
NonceAccount: {
|
|
303
790
|
authority: resolveAccount("authority"),
|
|
791
|
+
data: resolveAccountData(),
|
|
304
792
|
ownerProgram: resolveAccount("ownerProgram")
|
|
305
793
|
},
|
|
306
794
|
StakeAccount: {
|
|
795
|
+
data: resolveAccountData(),
|
|
307
796
|
ownerProgram: resolveAccount("ownerProgram")
|
|
308
797
|
},
|
|
309
798
|
StakeAccountDataMetaAuthorized: {
|
|
@@ -317,12 +806,14 @@ var accountResolvers = {
|
|
|
317
806
|
voter: resolveAccount("voter")
|
|
318
807
|
},
|
|
319
808
|
TokenAccount: {
|
|
809
|
+
data: resolveAccountData(),
|
|
320
810
|
mint: resolveAccount("mint"),
|
|
321
811
|
owner: resolveAccount("owner"),
|
|
322
812
|
ownerProgram: resolveAccount("ownerProgram")
|
|
323
813
|
},
|
|
324
814
|
VoteAccount: {
|
|
325
815
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
816
|
+
data: resolveAccountData(),
|
|
326
817
|
node: resolveAccount("nodePubkey"),
|
|
327
818
|
ownerProgram: resolveAccount("ownerProgram")
|
|
328
819
|
},
|
|
@@ -332,147 +823,207 @@ var accountResolvers = {
|
|
|
332
823
|
};
|
|
333
824
|
|
|
334
825
|
// src/resolvers/transaction.ts
|
|
335
|
-
function
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
826
|
+
function mapJsonParsedInstructions(instructions) {
|
|
827
|
+
return instructions.map((instruction) => {
|
|
828
|
+
if ("parsed" in instruction) {
|
|
829
|
+
if (typeof instruction.parsed === "string" && instruction.program === "spl-memo") {
|
|
830
|
+
const { parsed: memo, program: programName2, programId: programId2 } = instruction;
|
|
831
|
+
const instructionType2 = "memo";
|
|
832
|
+
const jsonParsedConfigs2 = {
|
|
833
|
+
instructionType: instructionType2,
|
|
834
|
+
programId: programId2,
|
|
835
|
+
programName: programName2
|
|
836
|
+
};
|
|
837
|
+
return { jsonParsedConfigs: jsonParsedConfigs2, memo, programId: programId2 };
|
|
838
|
+
}
|
|
839
|
+
const {
|
|
840
|
+
parsed: { info: data, type: instructionType },
|
|
841
|
+
program: programName,
|
|
842
|
+
programId
|
|
843
|
+
} = instruction;
|
|
844
|
+
const jsonParsedConfigs = {
|
|
845
|
+
instructionType,
|
|
846
|
+
programId,
|
|
847
|
+
programName
|
|
848
|
+
};
|
|
849
|
+
return { jsonParsedConfigs, ...data, programId };
|
|
850
|
+
} else {
|
|
851
|
+
return instruction;
|
|
852
|
+
}
|
|
359
853
|
});
|
|
360
|
-
return [transactionData, transactionMeta];
|
|
361
854
|
}
|
|
362
|
-
function
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
[transaction.transaction[0], transaction.meta]
|
|
369
|
-
) : (
|
|
370
|
-
// The transaction was either partially parsed or
|
|
371
|
-
// fully JSON-parsed, which will be sorted later.
|
|
372
|
-
transformParsedTransaction(transaction)
|
|
373
|
-
);
|
|
374
|
-
transaction.data = transactionData;
|
|
375
|
-
transaction.encoding = encoding;
|
|
376
|
-
transaction.meta = transactionMeta;
|
|
377
|
-
return transaction;
|
|
855
|
+
function mapJsonParsedInnerInstructions(innerInstructions) {
|
|
856
|
+
return innerInstructions.map(({ index, instructions }) => ({
|
|
857
|
+
index,
|
|
858
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
859
|
+
instructions: mapJsonParsedInstructions(instructions)
|
|
860
|
+
}));
|
|
378
861
|
}
|
|
862
|
+
var resolveTransactionData = () => {
|
|
863
|
+
return (parent, args) => {
|
|
864
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
865
|
+
};
|
|
866
|
+
};
|
|
379
867
|
function resolveTransaction(fieldName) {
|
|
380
868
|
return async (parent, args, context, info) => {
|
|
381
869
|
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
382
|
-
if (
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
if (args.encoding !== "jsonParsed") {
|
|
393
|
-
const transactionJsonParsed = await context.loaders.transaction.load({
|
|
394
|
-
...args,
|
|
395
|
-
encoding: "jsonParsed",
|
|
870
|
+
if (signature) {
|
|
871
|
+
if (onlyFieldsRequested(["signature"], info)) {
|
|
872
|
+
return { signature };
|
|
873
|
+
}
|
|
874
|
+
const argsSet = buildTransactionLoaderArgSetFromResolveInfo({ ...args, signature }, info);
|
|
875
|
+
const loadedTransactions = await context.loaders.transaction.loadMany(argsSet);
|
|
876
|
+
let result = {
|
|
877
|
+
encodedData: {},
|
|
396
878
|
signature
|
|
879
|
+
};
|
|
880
|
+
loadedTransactions.forEach((loadedTransaction, i) => {
|
|
881
|
+
if (loadedTransaction instanceof Error) {
|
|
882
|
+
console.error(loadedTransaction);
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
if (loadedTransaction === null) {
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
if (!result.slot) {
|
|
889
|
+
result = {
|
|
890
|
+
...result,
|
|
891
|
+
...loadedTransaction
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
const { transaction: data } = loadedTransaction;
|
|
895
|
+
const { encoding } = argsSet[i];
|
|
896
|
+
if (encoding && result.encodedData) {
|
|
897
|
+
if (Array.isArray(data)) {
|
|
898
|
+
result.encodedData[cacheKeyFn({
|
|
899
|
+
encoding
|
|
900
|
+
})] = data[0];
|
|
901
|
+
} else if (typeof data === "object") {
|
|
902
|
+
const jsonParsedData = data;
|
|
903
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
904
|
+
jsonParsedData.message.instructions
|
|
905
|
+
);
|
|
906
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
907
|
+
if (loadedInnerInstructions) {
|
|
908
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
909
|
+
const jsonParsedMeta = {
|
|
910
|
+
...loadedTransaction.meta,
|
|
911
|
+
innerInstructions
|
|
912
|
+
};
|
|
913
|
+
result = {
|
|
914
|
+
...result,
|
|
915
|
+
...jsonParsedData,
|
|
916
|
+
meta: jsonParsedMeta
|
|
917
|
+
};
|
|
918
|
+
} else {
|
|
919
|
+
result = {
|
|
920
|
+
...result,
|
|
921
|
+
...jsonParsedData
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
397
926
|
});
|
|
398
|
-
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
transaction.meta = transactionJsonParsed.meta;
|
|
927
|
+
return result;
|
|
402
928
|
}
|
|
403
|
-
return
|
|
929
|
+
return null;
|
|
404
930
|
};
|
|
405
931
|
}
|
|
406
932
|
var transactionResolvers = {
|
|
407
933
|
Transaction: {
|
|
408
|
-
|
|
409
|
-
switch (transaction.encoding) {
|
|
410
|
-
case "base58":
|
|
411
|
-
return "TransactionBase58";
|
|
412
|
-
case "base64":
|
|
413
|
-
return "TransactionBase64";
|
|
414
|
-
default:
|
|
415
|
-
return "TransactionParsed";
|
|
416
|
-
}
|
|
417
|
-
}
|
|
934
|
+
data: resolveTransactionData()
|
|
418
935
|
}
|
|
419
936
|
};
|
|
420
937
|
|
|
421
938
|
// src/resolvers/block.ts
|
|
422
|
-
function transformLoadedBlock({
|
|
423
|
-
block,
|
|
424
|
-
encoding = "jsonParsed",
|
|
425
|
-
transactionDetails = "full"
|
|
426
|
-
}) {
|
|
427
|
-
const transformedBlock = block;
|
|
428
|
-
if (typeof block === "object" && "transactions" in block) {
|
|
429
|
-
transformedBlock.transactions = block.transactions.map((transaction) => {
|
|
430
|
-
if (transactionDetails === "accounts") {
|
|
431
|
-
return {
|
|
432
|
-
data: transaction.transaction,
|
|
433
|
-
meta: transaction.meta,
|
|
434
|
-
version: transaction.version
|
|
435
|
-
};
|
|
436
|
-
} else {
|
|
437
|
-
return transformLoadedTransaction({ encoding, transaction });
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
block.encoding = encoding;
|
|
442
|
-
block.transactionDetails = transactionDetails;
|
|
443
|
-
return block;
|
|
444
|
-
}
|
|
445
939
|
var resolveBlock = (fieldName) => {
|
|
446
940
|
return async (parent, args, context, info) => {
|
|
447
941
|
const slot = fieldName ? parent[fieldName] : args.slot;
|
|
448
|
-
if (
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
942
|
+
if (slot) {
|
|
943
|
+
if (onlyFieldsRequested(["slot"], info)) {
|
|
944
|
+
return { slot };
|
|
945
|
+
}
|
|
946
|
+
const argsSet = buildBlockLoaderArgSetFromResolveInfo({ ...args, slot }, info);
|
|
947
|
+
const loadedBlocks = await context.loaders.block.loadMany(argsSet);
|
|
948
|
+
let result = {
|
|
949
|
+
slot
|
|
950
|
+
};
|
|
951
|
+
loadedBlocks.forEach((loadedBlock, i) => {
|
|
952
|
+
if (loadedBlock instanceof Error) {
|
|
953
|
+
console.error(loadedBlock);
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
if (loadedBlock === null) {
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
if (!result.blockhash) {
|
|
960
|
+
result = {
|
|
961
|
+
...result,
|
|
962
|
+
...loadedBlock
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
if (!result.signatures && loadedBlock.signatures) {
|
|
966
|
+
result = {
|
|
967
|
+
...result,
|
|
968
|
+
// @ts-expect-error FIX ME: https://github.com/solana-labs/solana-web3.js/pull/2052
|
|
969
|
+
signatures: loadedBlock.signatures
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
if (!result.transactionResults && loadedBlock.transactions) {
|
|
973
|
+
result.transactionResults = Array.from({ length: loadedBlock.transactions.length }, (_, i2) => ({
|
|
974
|
+
[i2]: { encodedData: {} }
|
|
975
|
+
}));
|
|
976
|
+
}
|
|
977
|
+
const { transactions } = loadedBlock;
|
|
978
|
+
const { encoding } = argsSet[i];
|
|
979
|
+
if (encoding) {
|
|
980
|
+
transactions.forEach((loadedTransaction, j) => {
|
|
981
|
+
const { transaction: data } = loadedTransaction;
|
|
982
|
+
if (result.transactionResults) {
|
|
983
|
+
const thisTransactionResult = result.transactionResults[j] ||= {
|
|
984
|
+
encodedData: {}
|
|
985
|
+
};
|
|
986
|
+
if (Array.isArray(data)) {
|
|
987
|
+
const thisEncodedData = thisTransactionResult.encodedData ||= {};
|
|
988
|
+
thisEncodedData[cacheKeyFn({
|
|
989
|
+
encoding
|
|
990
|
+
})] = data[0];
|
|
991
|
+
} else if (typeof data === "object") {
|
|
992
|
+
const jsonParsedData = data;
|
|
993
|
+
jsonParsedData.message.instructions = mapJsonParsedInstructions(
|
|
994
|
+
jsonParsedData.message.instructions
|
|
995
|
+
);
|
|
996
|
+
const loadedInnerInstructions = loadedTransaction.meta?.innerInstructions;
|
|
997
|
+
if (loadedInnerInstructions) {
|
|
998
|
+
const innerInstructions = mapJsonParsedInnerInstructions(loadedInnerInstructions);
|
|
999
|
+
const jsonParsedMeta = {
|
|
1000
|
+
...loadedTransaction.meta,
|
|
1001
|
+
innerInstructions
|
|
1002
|
+
};
|
|
1003
|
+
result.transactionResults[j] = {
|
|
1004
|
+
...thisTransactionResult,
|
|
1005
|
+
...jsonParsedData,
|
|
1006
|
+
meta: jsonParsedMeta
|
|
1007
|
+
};
|
|
1008
|
+
} else {
|
|
1009
|
+
result.transactionResults[j] = {
|
|
1010
|
+
...thisTransactionResult,
|
|
1011
|
+
...jsonParsedData
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
return result;
|
|
457
1020
|
}
|
|
458
|
-
|
|
459
|
-
return transformLoadedBlock({ block, encoding, transactionDetails });
|
|
1021
|
+
return null;
|
|
460
1022
|
};
|
|
461
1023
|
};
|
|
462
1024
|
var blockResolvers = {
|
|
463
1025
|
Block: {
|
|
464
|
-
|
|
465
|
-
switch (block.transactionDetails) {
|
|
466
|
-
case "accounts":
|
|
467
|
-
return "BlockWithAccounts";
|
|
468
|
-
case "none":
|
|
469
|
-
return "BlockWithNone";
|
|
470
|
-
case "signatures":
|
|
471
|
-
return "BlockWithSignatures";
|
|
472
|
-
default:
|
|
473
|
-
return "BlockWithFull";
|
|
474
|
-
}
|
|
475
|
-
}
|
|
1026
|
+
transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
|
|
476
1027
|
}
|
|
477
1028
|
};
|
|
478
1029
|
|
|
@@ -480,7 +1031,8 @@ var blockResolvers = {
|
|
|
480
1031
|
var instructionResolvers = {
|
|
481
1032
|
AdvanceNonceAccountInstruction: {
|
|
482
1033
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
483
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1034
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1035
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
|
|
484
1036
|
},
|
|
485
1037
|
AllocateInstruction: {
|
|
486
1038
|
account: resolveAccount("account")
|
|
@@ -517,9 +1069,11 @@ var instructionResolvers = {
|
|
|
517
1069
|
BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
|
|
518
1070
|
authority: resolveAccount("authority"),
|
|
519
1071
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
1072
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
520
1073
|
payerAccount: resolveAccount("payerAccount"),
|
|
521
1074
|
programAccount: resolveAccount("programAccount"),
|
|
522
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
1075
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1076
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
523
1077
|
},
|
|
524
1078
|
BpfUpgradeableLoaderExtendProgramInstruction: {
|
|
525
1079
|
payerAccount: resolveAccount("payerAccount"),
|
|
@@ -543,8 +1097,10 @@ var instructionResolvers = {
|
|
|
543
1097
|
BpfUpgradeableLoaderUpgradeInstruction: {
|
|
544
1098
|
authority: resolveAccount("authority"),
|
|
545
1099
|
bufferAccount: resolveAccount("bufferAccount"),
|
|
1100
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
546
1101
|
programAccount: resolveAccount("programAccount"),
|
|
547
|
-
programDataAccount: resolveAccount("programDataAccount")
|
|
1102
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1103
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
548
1104
|
},
|
|
549
1105
|
BpfUpgradeableLoaderWriteInstruction: {
|
|
550
1106
|
account: resolveAccount("account"),
|
|
@@ -587,7 +1143,9 @@ var instructionResolvers = {
|
|
|
587
1143
|
},
|
|
588
1144
|
InitializeNonceAccountInstruction: {
|
|
589
1145
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
590
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1146
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1147
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1148
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
591
1149
|
},
|
|
592
1150
|
Lockup: {
|
|
593
1151
|
custodian: resolveAccount("custodian")
|
|
@@ -663,7 +1221,8 @@ var instructionResolvers = {
|
|
|
663
1221
|
SplTokenInitializeAccount2Instruction: {
|
|
664
1222
|
account: resolveAccount("account"),
|
|
665
1223
|
mint: resolveAccount("mint"),
|
|
666
|
-
owner: resolveAccount("owner")
|
|
1224
|
+
owner: resolveAccount("owner"),
|
|
1225
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
667
1226
|
},
|
|
668
1227
|
SplTokenInitializeAccount3Instruction: {
|
|
669
1228
|
account: resolveAccount("account"),
|
|
@@ -673,7 +1232,8 @@ var instructionResolvers = {
|
|
|
673
1232
|
SplTokenInitializeAccountInstruction: {
|
|
674
1233
|
account: resolveAccount("account"),
|
|
675
1234
|
mint: resolveAccount("mint"),
|
|
676
|
-
owner: resolveAccount("owner")
|
|
1235
|
+
owner: resolveAccount("owner"),
|
|
1236
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
677
1237
|
},
|
|
678
1238
|
SplTokenInitializeMint2Instruction: {
|
|
679
1239
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
@@ -687,13 +1247,15 @@ var instructionResolvers = {
|
|
|
687
1247
|
SplTokenInitializeMintInstruction: {
|
|
688
1248
|
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
689
1249
|
mint: resolveAccount("mint"),
|
|
690
|
-
mintAuthority: resolveAccount("mintAuthority")
|
|
1250
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1251
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
691
1252
|
},
|
|
692
1253
|
SplTokenInitializeMultisig2Instruction: {
|
|
693
1254
|
multisig: resolveAccount("multisig")
|
|
694
1255
|
},
|
|
695
1256
|
SplTokenInitializeMultisigInstruction: {
|
|
696
|
-
multisig: resolveAccount("multisig")
|
|
1257
|
+
multisig: resolveAccount("multisig"),
|
|
1258
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
697
1259
|
},
|
|
698
1260
|
SplTokenMintToCheckedInstruction: {
|
|
699
1261
|
account: resolveAccount("account"),
|
|
@@ -746,6 +1308,7 @@ var instructionResolvers = {
|
|
|
746
1308
|
},
|
|
747
1309
|
StakeAuthorizeCheckedInstruction: {
|
|
748
1310
|
authority: resolveAccount("authority"),
|
|
1311
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
749
1312
|
custodian: resolveAccount("custodian"),
|
|
750
1313
|
newAuthority: resolveAccount("newAuthority"),
|
|
751
1314
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -753,12 +1316,14 @@ var instructionResolvers = {
|
|
|
753
1316
|
StakeAuthorizeCheckedWithSeedInstruction: {
|
|
754
1317
|
authorityBase: resolveAccount("authorityBase"),
|
|
755
1318
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1319
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
756
1320
|
custodian: resolveAccount("custodian"),
|
|
757
1321
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
758
1322
|
stakeAccount: resolveAccount("stakeAccount")
|
|
759
1323
|
},
|
|
760
1324
|
StakeAuthorizeInstruction: {
|
|
761
1325
|
authority: resolveAccount("authority"),
|
|
1326
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
762
1327
|
custodian: resolveAccount("custodian"),
|
|
763
1328
|
newAuthority: resolveAccount("newAuthority"),
|
|
764
1329
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -766,6 +1331,7 @@ var instructionResolvers = {
|
|
|
766
1331
|
StakeAuthorizeWithSeedInstruction: {
|
|
767
1332
|
authorityBase: resolveAccount("authorityBase"),
|
|
768
1333
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1334
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
769
1335
|
custodian: resolveAccount("custodian"),
|
|
770
1336
|
newAuthorized: resolveAccount("newAuthorized"),
|
|
771
1337
|
stakeAccount: resolveAccount("stakeAccount")
|
|
@@ -776,20 +1342,28 @@ var instructionResolvers = {
|
|
|
776
1342
|
voteAccount: resolveAccount("voteAccount")
|
|
777
1343
|
},
|
|
778
1344
|
StakeDeactivateInstruction: {
|
|
1345
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
779
1346
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
780
1347
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
781
1348
|
},
|
|
782
1349
|
StakeDelegateStakeInstruction: {
|
|
1350
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
783
1351
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
784
1352
|
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
785
1353
|
stakeConfigAccount: resolveAccount("stakeConfigAccount"),
|
|
1354
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
|
|
786
1355
|
voteAccount: resolveAccount("voteAccount")
|
|
787
1356
|
},
|
|
1357
|
+
StakeInitializeCheckedInstruction: {
|
|
1358
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1359
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1360
|
+
},
|
|
788
1361
|
StakeInitializeCheckedInstructionDataAuthorized: {
|
|
789
1362
|
staker: resolveAccount("staker"),
|
|
790
1363
|
withdrawer: resolveAccount("withdrawer")
|
|
791
1364
|
},
|
|
792
1365
|
StakeInitializeInstruction: {
|
|
1366
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
793
1367
|
stakeAccount: resolveAccount("stakeAccount")
|
|
794
1368
|
},
|
|
795
1369
|
StakeInitializeInstructionDataAuthorized: {
|
|
@@ -797,9 +1371,11 @@ var instructionResolvers = {
|
|
|
797
1371
|
withdrawer: resolveAccount("withdrawer")
|
|
798
1372
|
},
|
|
799
1373
|
StakeMergeInstruction: {
|
|
1374
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
800
1375
|
destination: resolveAccount("destination"),
|
|
801
1376
|
source: resolveAccount("source"),
|
|
802
|
-
stakeAuthority: resolveAccount("stakeAuthority")
|
|
1377
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1378
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
|
|
803
1379
|
},
|
|
804
1380
|
StakeRedelegateInstruction: {
|
|
805
1381
|
newStakeAccount: resolveAccount("newStakeAccount"),
|
|
@@ -822,287 +1398,289 @@ var instructionResolvers = {
|
|
|
822
1398
|
stakeAuthority: resolveAccount("stakeAuthority")
|
|
823
1399
|
},
|
|
824
1400
|
StakeWithdrawInstruction: {
|
|
1401
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
825
1402
|
destination: resolveAccount("destination"),
|
|
826
1403
|
stakeAccount: resolveAccount("stakeAccount"),
|
|
827
1404
|
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
828
1405
|
},
|
|
829
1406
|
TransactionInstruction: {
|
|
830
|
-
__resolveType(
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1407
|
+
__resolveType(instructionResult) {
|
|
1408
|
+
const { jsonParsedConfigs } = instructionResult;
|
|
1409
|
+
if (jsonParsedConfigs) {
|
|
1410
|
+
if (jsonParsedConfigs.programName === "address-lookup-table") {
|
|
1411
|
+
if (jsonParsedConfigs.instructionType === "createLookupTable") {
|
|
834
1412
|
return "CreateLookupTableInstruction";
|
|
835
1413
|
}
|
|
836
|
-
if (
|
|
1414
|
+
if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
|
|
837
1415
|
return "FreezeLookupTableInstruction";
|
|
838
1416
|
}
|
|
839
|
-
if (
|
|
1417
|
+
if (jsonParsedConfigs.instructionType === "extendLookupTable") {
|
|
840
1418
|
return "ExtendLookupTableInstruction";
|
|
841
1419
|
}
|
|
842
|
-
if (
|
|
1420
|
+
if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
|
|
843
1421
|
return "DeactivateLookupTableInstruction";
|
|
844
1422
|
}
|
|
845
|
-
if (
|
|
1423
|
+
if (jsonParsedConfigs.instructionType === "closeLookupTable") {
|
|
846
1424
|
return "CloseLookupTableInstruction";
|
|
847
1425
|
}
|
|
848
1426
|
}
|
|
849
|
-
if (
|
|
850
|
-
if (
|
|
1427
|
+
if (jsonParsedConfigs.programName === "bpf-loader") {
|
|
1428
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
851
1429
|
return "BpfLoaderWriteInstruction";
|
|
852
1430
|
}
|
|
853
|
-
if (
|
|
1431
|
+
if (jsonParsedConfigs.instructionType === "finalize") {
|
|
854
1432
|
return "BpfLoaderFinalizeInstruction";
|
|
855
1433
|
}
|
|
856
1434
|
}
|
|
857
|
-
if (
|
|
858
|
-
if (
|
|
1435
|
+
if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
|
|
1436
|
+
if (jsonParsedConfigs.instructionType === "initializeBuffer") {
|
|
859
1437
|
return "BpfUpgradeableLoaderInitializeBufferInstruction";
|
|
860
1438
|
}
|
|
861
|
-
if (
|
|
1439
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
862
1440
|
return "BpfUpgradeableLoaderWriteInstruction";
|
|
863
1441
|
}
|
|
864
|
-
if (
|
|
1442
|
+
if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
|
|
865
1443
|
return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
|
|
866
1444
|
}
|
|
867
|
-
if (
|
|
1445
|
+
if (jsonParsedConfigs.instructionType === "upgrade") {
|
|
868
1446
|
return "BpfUpgradeableLoaderUpgradeInstruction";
|
|
869
1447
|
}
|
|
870
|
-
if (
|
|
1448
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
871
1449
|
return "BpfUpgradeableLoaderSetAuthorityInstruction";
|
|
872
1450
|
}
|
|
873
|
-
if (
|
|
1451
|
+
if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
|
|
874
1452
|
return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
|
|
875
1453
|
}
|
|
876
|
-
if (
|
|
1454
|
+
if (jsonParsedConfigs.instructionType === "close") {
|
|
877
1455
|
return "BpfUpgradeableLoaderCloseInstruction";
|
|
878
1456
|
}
|
|
879
|
-
if (
|
|
1457
|
+
if (jsonParsedConfigs.instructionType === "extendProgram") {
|
|
880
1458
|
return "BpfUpgradeableLoaderExtendProgramInstruction";
|
|
881
1459
|
}
|
|
882
1460
|
}
|
|
883
|
-
if (
|
|
884
|
-
if (
|
|
1461
|
+
if (jsonParsedConfigs.programName === "spl-associated-token-account") {
|
|
1462
|
+
if (jsonParsedConfigs.instructionType === "create") {
|
|
885
1463
|
return "SplAssociatedTokenCreateInstruction";
|
|
886
1464
|
}
|
|
887
|
-
if (
|
|
1465
|
+
if (jsonParsedConfigs.instructionType === "createIdempotent") {
|
|
888
1466
|
return "SplAssociatedTokenCreateIdempotentInstruction";
|
|
889
1467
|
}
|
|
890
|
-
if (
|
|
1468
|
+
if (jsonParsedConfigs.instructionType === "recoverNested") {
|
|
891
1469
|
return "SplAssociatedTokenRecoverNestedInstruction";
|
|
892
1470
|
}
|
|
893
1471
|
}
|
|
894
|
-
if (
|
|
1472
|
+
if (jsonParsedConfigs.programName === "spl-memo") {
|
|
895
1473
|
return "SplMemoInstruction";
|
|
896
1474
|
}
|
|
897
|
-
if (
|
|
898
|
-
if (
|
|
1475
|
+
if (jsonParsedConfigs.programName === "spl-token") {
|
|
1476
|
+
if (jsonParsedConfigs.instructionType === "initializeMint") {
|
|
899
1477
|
return "SplTokenInitializeMintInstruction";
|
|
900
1478
|
}
|
|
901
|
-
if (
|
|
1479
|
+
if (jsonParsedConfigs.instructionType === "initializeMint2") {
|
|
902
1480
|
return "SplTokenInitializeMint2Instruction";
|
|
903
1481
|
}
|
|
904
|
-
if (
|
|
1482
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount") {
|
|
905
1483
|
return "SplTokenInitializeAccountInstruction";
|
|
906
1484
|
}
|
|
907
|
-
if (
|
|
1485
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount2") {
|
|
908
1486
|
return "SplTokenInitializeAccount2Instruction";
|
|
909
1487
|
}
|
|
910
|
-
if (
|
|
1488
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount3") {
|
|
911
1489
|
return "SplTokenInitializeAccount3Instruction";
|
|
912
1490
|
}
|
|
913
|
-
if (
|
|
1491
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig") {
|
|
914
1492
|
return "SplTokenInitializeMultisigInstruction";
|
|
915
1493
|
}
|
|
916
|
-
if (
|
|
1494
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
|
|
917
1495
|
return "SplTokenInitializeMultisig2Instruction";
|
|
918
1496
|
}
|
|
919
|
-
if (
|
|
1497
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
920
1498
|
return "SplTokenTransferInstruction";
|
|
921
1499
|
}
|
|
922
|
-
if (
|
|
1500
|
+
if (jsonParsedConfigs.instructionType === "approve") {
|
|
923
1501
|
return "SplTokenApproveInstruction";
|
|
924
1502
|
}
|
|
925
|
-
if (
|
|
1503
|
+
if (jsonParsedConfigs.instructionType === "revoke") {
|
|
926
1504
|
return "SplTokenRevokeInstruction";
|
|
927
1505
|
}
|
|
928
|
-
if (
|
|
1506
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
929
1507
|
return "SplTokenSetAuthorityInstruction";
|
|
930
1508
|
}
|
|
931
|
-
if (
|
|
1509
|
+
if (jsonParsedConfigs.instructionType === "mintTo") {
|
|
932
1510
|
return "SplTokenMintToInstruction";
|
|
933
1511
|
}
|
|
934
|
-
if (
|
|
1512
|
+
if (jsonParsedConfigs.instructionType === "burn") {
|
|
935
1513
|
return "SplTokenBurnInstruction";
|
|
936
1514
|
}
|
|
937
|
-
if (
|
|
1515
|
+
if (jsonParsedConfigs.instructionType === "closeAccount") {
|
|
938
1516
|
return "SplTokenCloseAccountInstruction";
|
|
939
1517
|
}
|
|
940
|
-
if (
|
|
1518
|
+
if (jsonParsedConfigs.instructionType === "freezeAccount") {
|
|
941
1519
|
return "SplTokenFreezeAccountInstruction";
|
|
942
1520
|
}
|
|
943
|
-
if (
|
|
1521
|
+
if (jsonParsedConfigs.instructionType === "thawAccount") {
|
|
944
1522
|
return "SplTokenThawAccountInstruction";
|
|
945
1523
|
}
|
|
946
|
-
if (
|
|
1524
|
+
if (jsonParsedConfigs.instructionType === "transferChecked") {
|
|
947
1525
|
return "SplTokenTransferCheckedInstruction";
|
|
948
1526
|
}
|
|
949
|
-
if (
|
|
1527
|
+
if (jsonParsedConfigs.instructionType === "approveChecked") {
|
|
950
1528
|
return "SplTokenApproveCheckedInstruction";
|
|
951
1529
|
}
|
|
952
|
-
if (
|
|
1530
|
+
if (jsonParsedConfigs.instructionType === "mintToChecked") {
|
|
953
1531
|
return "SplTokenMintToCheckedInstruction";
|
|
954
1532
|
}
|
|
955
|
-
if (
|
|
1533
|
+
if (jsonParsedConfigs.instructionType === "burnChecked") {
|
|
956
1534
|
return "SplTokenBurnCheckedInstruction";
|
|
957
1535
|
}
|
|
958
|
-
if (
|
|
1536
|
+
if (jsonParsedConfigs.instructionType === "syncNative") {
|
|
959
1537
|
return "SplTokenSyncNativeInstruction";
|
|
960
1538
|
}
|
|
961
|
-
if (
|
|
1539
|
+
if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
|
|
962
1540
|
return "SplTokenGetAccountDataSizeInstruction";
|
|
963
1541
|
}
|
|
964
|
-
if (
|
|
1542
|
+
if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
|
|
965
1543
|
return "SplTokenInitializeImmutableOwnerInstruction";
|
|
966
1544
|
}
|
|
967
|
-
if (
|
|
1545
|
+
if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
|
|
968
1546
|
return "SplTokenAmountToUiAmountInstruction";
|
|
969
1547
|
}
|
|
970
|
-
if (
|
|
1548
|
+
if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
|
|
971
1549
|
return "SplTokenUiAmountToAmountInstruction";
|
|
972
1550
|
}
|
|
973
|
-
if (
|
|
1551
|
+
if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
|
|
974
1552
|
return "SplTokenInitializeMintCloseAuthorityInstruction";
|
|
975
1553
|
}
|
|
976
1554
|
}
|
|
977
|
-
if (
|
|
978
|
-
if (
|
|
1555
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
1556
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
979
1557
|
return "StakeInitializeInstruction";
|
|
980
1558
|
}
|
|
981
|
-
if (
|
|
1559
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
982
1560
|
return "StakeAuthorizeInstruction";
|
|
983
1561
|
}
|
|
984
|
-
if (
|
|
1562
|
+
if (jsonParsedConfigs.instructionType === "delegate") {
|
|
985
1563
|
return "StakeDelegateStakeInstruction";
|
|
986
1564
|
}
|
|
987
|
-
if (
|
|
1565
|
+
if (jsonParsedConfigs.instructionType === "split") {
|
|
988
1566
|
return "StakeSplitInstruction";
|
|
989
1567
|
}
|
|
990
|
-
if (
|
|
1568
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
991
1569
|
return "StakeWithdrawInstruction";
|
|
992
1570
|
}
|
|
993
|
-
if (
|
|
1571
|
+
if (jsonParsedConfigs.instructionType === "deactivate") {
|
|
994
1572
|
return "StakeDeactivateInstruction";
|
|
995
1573
|
}
|
|
996
|
-
if (
|
|
1574
|
+
if (jsonParsedConfigs.instructionType === "setLockup") {
|
|
997
1575
|
return "StakeSetLockupInstruction";
|
|
998
1576
|
}
|
|
999
|
-
if (
|
|
1577
|
+
if (jsonParsedConfigs.instructionType === "merge") {
|
|
1000
1578
|
return "StakeMergeInstruction";
|
|
1001
1579
|
}
|
|
1002
|
-
if (
|
|
1580
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1003
1581
|
return "StakeAuthorizeWithSeedInstruction";
|
|
1004
1582
|
}
|
|
1005
|
-
if (
|
|
1583
|
+
if (jsonParsedConfigs.instructionType === "initializeChecked") {
|
|
1006
1584
|
return "StakeInitializeCheckedInstruction";
|
|
1007
1585
|
}
|
|
1008
|
-
if (
|
|
1586
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1009
1587
|
return "StakeAuthorizeCheckedInstruction";
|
|
1010
1588
|
}
|
|
1011
|
-
if (
|
|
1589
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1012
1590
|
return "StakeAuthorizeCheckedWithSeedInstruction";
|
|
1013
1591
|
}
|
|
1014
|
-
if (
|
|
1592
|
+
if (jsonParsedConfigs.instructionType === "setLockupChecked") {
|
|
1015
1593
|
return "StakeSetLockupCheckedInstruction";
|
|
1016
1594
|
}
|
|
1017
|
-
if (
|
|
1595
|
+
if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
|
|
1018
1596
|
return "StakeDeactivateDelinquentInstruction";
|
|
1019
1597
|
}
|
|
1020
|
-
if (
|
|
1598
|
+
if (jsonParsedConfigs.instructionType === "redelegate") {
|
|
1021
1599
|
return "StakeRedelegateInstruction";
|
|
1022
1600
|
}
|
|
1023
1601
|
}
|
|
1024
|
-
if (
|
|
1025
|
-
if (
|
|
1602
|
+
if (jsonParsedConfigs.programName === "system") {
|
|
1603
|
+
if (jsonParsedConfigs.instructionType === "createAccount") {
|
|
1026
1604
|
return "CreateAccountInstruction";
|
|
1027
1605
|
}
|
|
1028
|
-
if (
|
|
1606
|
+
if (jsonParsedConfigs.instructionType === "assign") {
|
|
1029
1607
|
return "AssignInstruction";
|
|
1030
1608
|
}
|
|
1031
|
-
if (
|
|
1609
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
1032
1610
|
return "TransferInstruction";
|
|
1033
1611
|
}
|
|
1034
|
-
if (
|
|
1612
|
+
if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
|
|
1035
1613
|
return "CreateAccountWithSeedInstruction";
|
|
1036
1614
|
}
|
|
1037
|
-
if (
|
|
1615
|
+
if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
|
|
1038
1616
|
return "AdvanceNonceAccountInstruction";
|
|
1039
1617
|
}
|
|
1040
|
-
if (
|
|
1618
|
+
if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
|
|
1041
1619
|
return "WithdrawNonceAccountInstruction";
|
|
1042
1620
|
}
|
|
1043
|
-
if (
|
|
1621
|
+
if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
|
|
1044
1622
|
return "InitializeNonceAccountInstruction";
|
|
1045
1623
|
}
|
|
1046
|
-
if (
|
|
1624
|
+
if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
|
|
1047
1625
|
return "AuthorizeNonceAccountInstruction";
|
|
1048
1626
|
}
|
|
1049
|
-
if (
|
|
1627
|
+
if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
|
|
1050
1628
|
return "UpgradeNonceAccountInstruction";
|
|
1051
1629
|
}
|
|
1052
|
-
if (
|
|
1630
|
+
if (jsonParsedConfigs.instructionType === "allocate") {
|
|
1053
1631
|
return "AllocateInstruction";
|
|
1054
1632
|
}
|
|
1055
|
-
if (
|
|
1633
|
+
if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
|
|
1056
1634
|
return "AllocateWithSeedInstruction";
|
|
1057
1635
|
}
|
|
1058
|
-
if (
|
|
1636
|
+
if (jsonParsedConfigs.instructionType === "assignWithSeed") {
|
|
1059
1637
|
return "AssignWithSeedInstruction";
|
|
1060
1638
|
}
|
|
1061
|
-
if (
|
|
1639
|
+
if (jsonParsedConfigs.instructionType === "transferWithSeed") {
|
|
1062
1640
|
return "TransferWithSeedInstruction";
|
|
1063
1641
|
}
|
|
1064
1642
|
}
|
|
1065
|
-
if (
|
|
1066
|
-
if (
|
|
1643
|
+
if (jsonParsedConfigs.programName === "vote") {
|
|
1644
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
1067
1645
|
return "VoteInitializeAccountInstruction";
|
|
1068
1646
|
}
|
|
1069
|
-
if (
|
|
1647
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
1070
1648
|
return "VoteAuthorizeInstruction";
|
|
1071
1649
|
}
|
|
1072
|
-
if (
|
|
1650
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1073
1651
|
return "VoteAuthorizeWithSeedInstruction";
|
|
1074
1652
|
}
|
|
1075
|
-
if (
|
|
1653
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1076
1654
|
return "VoteAuthorizeCheckedWithSeedInstruction";
|
|
1077
1655
|
}
|
|
1078
|
-
if (
|
|
1656
|
+
if (jsonParsedConfigs.instructionType === "vote") {
|
|
1079
1657
|
return "VoteVoteInstruction";
|
|
1080
1658
|
}
|
|
1081
|
-
if (
|
|
1659
|
+
if (jsonParsedConfigs.instructionType === "updatevotestate") {
|
|
1082
1660
|
return "VoteUpdateVoteStateInstruction";
|
|
1083
1661
|
}
|
|
1084
|
-
if (
|
|
1662
|
+
if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
|
|
1085
1663
|
return "VoteUpdateVoteStateSwitchInstruction";
|
|
1086
1664
|
}
|
|
1087
|
-
if (
|
|
1665
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
|
|
1088
1666
|
return "VoteCompactUpdateVoteStateInstruction";
|
|
1089
1667
|
}
|
|
1090
|
-
if (
|
|
1668
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
|
|
1091
1669
|
return "VoteCompactUpdateVoteStateSwitchInstruction";
|
|
1092
1670
|
}
|
|
1093
|
-
if (
|
|
1671
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
1094
1672
|
return "VoteWithdrawInstruction";
|
|
1095
1673
|
}
|
|
1096
|
-
if (
|
|
1674
|
+
if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
|
|
1097
1675
|
return "VoteUpdateValidatorIdentityInstruction";
|
|
1098
1676
|
}
|
|
1099
|
-
if (
|
|
1677
|
+
if (jsonParsedConfigs.instructionType === "updateCommission") {
|
|
1100
1678
|
return "VoteUpdateCommissionInstruction";
|
|
1101
1679
|
}
|
|
1102
|
-
if (
|
|
1680
|
+
if (jsonParsedConfigs.instructionType === "voteSwitch") {
|
|
1103
1681
|
return "VoteVoteSwitchInstruction";
|
|
1104
1682
|
}
|
|
1105
|
-
if (
|
|
1683
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1106
1684
|
return "VoteAuthorizeCheckedInstruction";
|
|
1107
1685
|
}
|
|
1108
1686
|
}
|
|
@@ -1125,21 +1703,25 @@ var instructionResolvers = {
|
|
|
1125
1703
|
},
|
|
1126
1704
|
VoteAuthorizeCheckedInstruction: {
|
|
1127
1705
|
authority: resolveAccount("authority"),
|
|
1706
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1128
1707
|
newAuthority: resolveAccount("newAuthority"),
|
|
1129
1708
|
voteAccount: resolveAccount("voteAccount")
|
|
1130
1709
|
},
|
|
1131
1710
|
VoteAuthorizeCheckedWithSeedInstruction: {
|
|
1132
1711
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1712
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1133
1713
|
newAuthority: resolveAccount("newAuthority"),
|
|
1134
1714
|
voteAccount: resolveAccount("voteAccount")
|
|
1135
1715
|
},
|
|
1136
1716
|
VoteAuthorizeInstruction: {
|
|
1137
1717
|
authority: resolveAccount("authority"),
|
|
1718
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1138
1719
|
newAuthority: resolveAccount("newAuthority"),
|
|
1139
1720
|
voteAccount: resolveAccount("voteAccount")
|
|
1140
1721
|
},
|
|
1141
1722
|
VoteAuthorizeWithSeedInstruction: {
|
|
1142
1723
|
authorityOwner: resolveAccount("authorityOwner"),
|
|
1724
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1143
1725
|
newAuthority: resolveAccount("newAuthority"),
|
|
1144
1726
|
voteAccount: resolveAccount("voteAccount")
|
|
1145
1727
|
},
|
|
@@ -1154,7 +1736,9 @@ var instructionResolvers = {
|
|
|
1154
1736
|
VoteInitializeAccountInstruction: {
|
|
1155
1737
|
authorizedVoter: resolveAccount("authorizedVoter"),
|
|
1156
1738
|
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
1739
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1157
1740
|
node: resolveAccount("node"),
|
|
1741
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1158
1742
|
voteAccount: resolveAccount("voteAccount")
|
|
1159
1743
|
},
|
|
1160
1744
|
VoteUpdateCommissionInstruction: {
|
|
@@ -1175,10 +1759,14 @@ var instructionResolvers = {
|
|
|
1175
1759
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1176
1760
|
},
|
|
1177
1761
|
VoteVoteInstruction: {
|
|
1762
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1763
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1178
1764
|
voteAccount: resolveAccount("voteAccount"),
|
|
1179
1765
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1180
1766
|
},
|
|
1181
1767
|
VoteVoteSwitchInstruction: {
|
|
1768
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1769
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1182
1770
|
voteAccount: resolveAccount("voteAccount"),
|
|
1183
1771
|
voteAuthority: resolveAccount("voteAuthority")
|
|
1184
1772
|
},
|
|
@@ -1189,7 +1777,9 @@ var instructionResolvers = {
|
|
|
1189
1777
|
WithdrawNonceAccountInstruction: {
|
|
1190
1778
|
destination: resolveAccount("destination"),
|
|
1191
1779
|
nonceAccount: resolveAccount("nonceAccount"),
|
|
1192
|
-
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1780
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1781
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1782
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1193
1783
|
}
|
|
1194
1784
|
};
|
|
1195
1785
|
|
|
@@ -1197,20 +1787,57 @@ var instructionResolvers = {
|
|
|
1197
1787
|
function resolveProgramAccounts(fieldName) {
|
|
1198
1788
|
return async (parent, args, context, info) => {
|
|
1199
1789
|
const programAddress = fieldName ? parent[fieldName] : args.programAddress;
|
|
1200
|
-
if (
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1790
|
+
if (programAddress) {
|
|
1791
|
+
const argsSet = buildProgramAccountsLoaderArgSetFromResolveInfo({ ...args, programAddress }, info);
|
|
1792
|
+
const loadedProgramAccountsLists = await context.loaders.programAccounts.loadMany(argsSet);
|
|
1793
|
+
const result = {};
|
|
1794
|
+
loadedProgramAccountsLists.forEach((programAccounts, i) => {
|
|
1795
|
+
if (programAccounts instanceof Error) {
|
|
1796
|
+
console.error(programAccounts);
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
programAccounts.forEach((programAccount) => {
|
|
1800
|
+
const { account, pubkey: address } = programAccount;
|
|
1801
|
+
const thisResult = result[address] ||= {
|
|
1802
|
+
...account,
|
|
1803
|
+
address,
|
|
1804
|
+
encodedData: {},
|
|
1805
|
+
ownerProgram: account.owner
|
|
1806
|
+
};
|
|
1807
|
+
const { data } = account;
|
|
1808
|
+
const { encoding, dataSlice } = argsSet[i];
|
|
1809
|
+
if (encoding && thisResult.encodedData) {
|
|
1810
|
+
if (Array.isArray(data)) {
|
|
1811
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1812
|
+
dataSlice,
|
|
1813
|
+
encoding: encoding === "jsonParsed" ? "base64" : encoding
|
|
1814
|
+
})] = data[0];
|
|
1815
|
+
} else if (typeof data === "string") {
|
|
1816
|
+
thisResult.encodedData[cacheKeyFn({
|
|
1817
|
+
dataSlice,
|
|
1818
|
+
encoding: "base58"
|
|
1819
|
+
})] = data;
|
|
1820
|
+
} else if (typeof data === "object") {
|
|
1821
|
+
const {
|
|
1822
|
+
parsed: { info: parsedData, type: accountType },
|
|
1823
|
+
program: programName,
|
|
1824
|
+
programId
|
|
1825
|
+
} = data;
|
|
1826
|
+
thisResult.jsonParsedConfigs = {
|
|
1827
|
+
accountType,
|
|
1828
|
+
programId,
|
|
1829
|
+
programName
|
|
1830
|
+
};
|
|
1831
|
+
for (const key in parsedData) {
|
|
1832
|
+
thisResult[key] = parsedData[key];
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
});
|
|
1837
|
+
});
|
|
1838
|
+
return Object.values(result);
|
|
1839
|
+
}
|
|
1840
|
+
return null;
|
|
1214
1841
|
};
|
|
1215
1842
|
}
|
|
1216
1843
|
|
|
@@ -1237,47 +1864,49 @@ var stringScalarAlias = {
|
|
|
1237
1864
|
return value;
|
|
1238
1865
|
}
|
|
1239
1866
|
};
|
|
1240
|
-
var
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1245
|
-
BigInt: {
|
|
1246
|
-
__parseLiteral(ast) {
|
|
1247
|
-
if (ast.kind === graphql.Kind.STRING) {
|
|
1248
|
-
return BigInt(ast.value);
|
|
1249
|
-
}
|
|
1250
|
-
return null;
|
|
1251
|
-
},
|
|
1252
|
-
__parseValue(value) {
|
|
1253
|
-
return BigInt(value);
|
|
1254
|
-
},
|
|
1255
|
-
__serialize(value) {
|
|
1256
|
-
return BigInt(value);
|
|
1867
|
+
var bigIntScalarAlias = {
|
|
1868
|
+
__parseLiteral(ast) {
|
|
1869
|
+
if (ast.kind === graphql.Kind.STRING || ast.kind === graphql.Kind.INT || ast.kind === graphql.Kind.FLOAT) {
|
|
1870
|
+
return BigInt(ast.value);
|
|
1257
1871
|
}
|
|
1872
|
+
return null;
|
|
1873
|
+
},
|
|
1874
|
+
__parseValue(value) {
|
|
1875
|
+
return BigInt(value);
|
|
1876
|
+
},
|
|
1877
|
+
__serialize(value) {
|
|
1878
|
+
return BigInt(value);
|
|
1258
1879
|
}
|
|
1259
1880
|
};
|
|
1260
|
-
|
|
1261
|
-
// src/resolvers/types.ts
|
|
1262
|
-
var commonTypeResolvers = {
|
|
1881
|
+
var typeTypeResolvers = {
|
|
1263
1882
|
AccountEncoding: {
|
|
1264
1883
|
BASE_58: "base58",
|
|
1265
1884
|
BASE_64: "base64",
|
|
1266
|
-
BASE_64_ZSTD: "base64+zstd"
|
|
1267
|
-
PARSED: "jsonParsed"
|
|
1885
|
+
BASE_64_ZSTD: "base64+zstd"
|
|
1268
1886
|
},
|
|
1887
|
+
Address: stringScalarAlias,
|
|
1888
|
+
Base58EncodedBytes: stringScalarAlias,
|
|
1889
|
+
Base64EncodedBytes: stringScalarAlias,
|
|
1890
|
+
Base64ZstdEncodedBytes: stringScalarAlias,
|
|
1891
|
+
BigInt: bigIntScalarAlias,
|
|
1892
|
+
Commitment: {
|
|
1893
|
+
CONFIRMED: "confirmed",
|
|
1894
|
+
FINALIZED: "finalized",
|
|
1895
|
+
PROCESSED: "processed"
|
|
1896
|
+
},
|
|
1897
|
+
CommitmentWithoutProcessed: {
|
|
1898
|
+
CONFIRMED: "confirmed",
|
|
1899
|
+
FINALIZED: "finalized"
|
|
1900
|
+
},
|
|
1901
|
+
Signature: stringScalarAlias,
|
|
1902
|
+
Slot: bigIntScalarAlias,
|
|
1269
1903
|
TokenBalance: {
|
|
1270
1904
|
mint: resolveAccount("mint"),
|
|
1271
1905
|
owner: resolveAccount("owner")
|
|
1272
1906
|
},
|
|
1273
1907
|
TransactionEncoding: {
|
|
1274
1908
|
BASE_58: "base58",
|
|
1275
|
-
BASE_64: "base64"
|
|
1276
|
-
PARSED: "jsonParsed"
|
|
1277
|
-
},
|
|
1278
|
-
TransactionVersion: {
|
|
1279
|
-
LEGACY: "legacy",
|
|
1280
|
-
ZERO: 0
|
|
1909
|
+
BASE_64: "base64"
|
|
1281
1910
|
}
|
|
1282
1911
|
};
|
|
1283
1912
|
|
|
@@ -1286,11 +1915,10 @@ function createSolanaGraphQLResolvers() {
|
|
|
1286
1915
|
return {
|
|
1287
1916
|
...accountResolvers,
|
|
1288
1917
|
...blockResolvers,
|
|
1289
|
-
...commonTypeResolvers,
|
|
1290
1918
|
...instructionResolvers,
|
|
1291
1919
|
...rootResolvers,
|
|
1292
|
-
...
|
|
1293
|
-
...
|
|
1920
|
+
...transactionResolvers,
|
|
1921
|
+
...typeTypeResolvers
|
|
1294
1922
|
};
|
|
1295
1923
|
}
|
|
1296
1924
|
|
|
@@ -1303,6 +1931,7 @@ var accountTypeDefs = (
|
|
|
1303
1931
|
"""
|
|
1304
1932
|
interface Account {
|
|
1305
1933
|
address: Address
|
|
1934
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1306
1935
|
executable: Boolean
|
|
1307
1936
|
lamports: BigInt
|
|
1308
1937
|
ownerProgram: Account
|
|
@@ -1311,37 +1940,11 @@ var accountTypeDefs = (
|
|
|
1311
1940
|
}
|
|
1312
1941
|
|
|
1313
1942
|
"""
|
|
1314
|
-
|
|
1943
|
+
Generic base account type
|
|
1315
1944
|
"""
|
|
1316
|
-
type
|
|
1945
|
+
type GenericAccount implements Account {
|
|
1317
1946
|
address: Address
|
|
1318
|
-
data:
|
|
1319
|
-
executable: Boolean
|
|
1320
|
-
lamports: BigInt
|
|
1321
|
-
ownerProgram: Account
|
|
1322
|
-
space: BigInt
|
|
1323
|
-
rentEpoch: BigInt
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
"""
|
|
1327
|
-
An account with base64 encoded data
|
|
1328
|
-
"""
|
|
1329
|
-
type AccountBase64 implements Account {
|
|
1330
|
-
address: Address
|
|
1331
|
-
data: Base64EncodedBytes
|
|
1332
|
-
executable: Boolean
|
|
1333
|
-
lamports: BigInt
|
|
1334
|
-
ownerProgram: Account
|
|
1335
|
-
space: BigInt
|
|
1336
|
-
rentEpoch: BigInt
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
"""
|
|
1340
|
-
An account with base64+zstd encoded data
|
|
1341
|
-
"""
|
|
1342
|
-
type AccountBase64Zstd implements Account {
|
|
1343
|
-
address: Address
|
|
1344
|
-
data: Base64ZstdEncodedBytes
|
|
1947
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1345
1948
|
executable: Boolean
|
|
1346
1949
|
lamports: BigInt
|
|
1347
1950
|
ownerProgram: Account
|
|
@@ -1357,6 +1960,7 @@ var accountTypeDefs = (
|
|
|
1357
1960
|
"""
|
|
1358
1961
|
type NonceAccount implements Account {
|
|
1359
1962
|
address: Address
|
|
1963
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1360
1964
|
executable: Boolean
|
|
1361
1965
|
lamports: BigInt
|
|
1362
1966
|
ownerProgram: Account
|
|
@@ -1372,6 +1976,7 @@ var accountTypeDefs = (
|
|
|
1372
1976
|
"""
|
|
1373
1977
|
type LookupTableAccount implements Account {
|
|
1374
1978
|
address: Address
|
|
1979
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1375
1980
|
executable: Boolean
|
|
1376
1981
|
lamports: BigInt
|
|
1377
1982
|
ownerProgram: Account
|
|
@@ -1389,6 +1994,7 @@ var accountTypeDefs = (
|
|
|
1389
1994
|
"""
|
|
1390
1995
|
type MintAccount implements Account {
|
|
1391
1996
|
address: Address
|
|
1997
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1392
1998
|
executable: Boolean
|
|
1393
1999
|
lamports: BigInt
|
|
1394
2000
|
ownerProgram: Account
|
|
@@ -1406,6 +2012,7 @@ var accountTypeDefs = (
|
|
|
1406
2012
|
"""
|
|
1407
2013
|
type TokenAccount implements Account {
|
|
1408
2014
|
address: Address
|
|
2015
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1409
2016
|
executable: Boolean
|
|
1410
2017
|
lamports: BigInt
|
|
1411
2018
|
ownerProgram: Account
|
|
@@ -1448,6 +2055,7 @@ var accountTypeDefs = (
|
|
|
1448
2055
|
"""
|
|
1449
2056
|
type StakeAccount implements Account {
|
|
1450
2057
|
address: Address
|
|
2058
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1451
2059
|
executable: Boolean
|
|
1452
2060
|
lamports: BigInt
|
|
1453
2061
|
ownerProgram: Account
|
|
@@ -1479,6 +2087,7 @@ var accountTypeDefs = (
|
|
|
1479
2087
|
"""
|
|
1480
2088
|
type VoteAccount implements Account {
|
|
1481
2089
|
address: Address
|
|
2090
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1482
2091
|
executable: Boolean
|
|
1483
2092
|
lamports: BigInt
|
|
1484
2093
|
ownerProgram: Account
|
|
@@ -1501,188 +2110,18 @@ var accountTypeDefs = (
|
|
|
1501
2110
|
var blockTypeDefs = (
|
|
1502
2111
|
/* GraphQL */
|
|
1503
2112
|
`
|
|
1504
|
-
type TransactionMetaForAccounts {
|
|
1505
|
-
err: String
|
|
1506
|
-
fee: BigInt
|
|
1507
|
-
postBalances: [BigInt]
|
|
1508
|
-
postTokenBalances: [TokenBalance]
|
|
1509
|
-
preBalances: [BigInt]
|
|
1510
|
-
preTokenBalances: [TokenBalance]
|
|
1511
|
-
status: TransactionStatus
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
type TransactionDataForAccounts {
|
|
1515
|
-
accountKeys: [Address]
|
|
1516
|
-
signatures: [String]
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
type BlockTransactionAccounts {
|
|
1520
|
-
meta: TransactionMetaForAccounts
|
|
1521
|
-
data: TransactionDataForAccounts
|
|
1522
|
-
version: String
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
2113
|
"""
|
|
1526
|
-
|
|
2114
|
+
A Solana block
|
|
1527
2115
|
"""
|
|
1528
|
-
|
|
2116
|
+
type Block {
|
|
1529
2117
|
blockhash: String
|
|
1530
2118
|
blockHeight: BigInt
|
|
1531
2119
|
blockTime: BigInt
|
|
1532
|
-
parentSlot:
|
|
1533
|
-
previousBlockhash: String
|
|
1534
|
-
rewards: [Reward]
|
|
1535
|
-
transactionDetails: String
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
"""
|
|
1539
|
-
A block with account transaction details
|
|
1540
|
-
"""
|
|
1541
|
-
type BlockWithAccounts implements Block {
|
|
1542
|
-
blockhash: String
|
|
1543
|
-
blockHeight: BigInt
|
|
1544
|
-
blockTime: BigInt
|
|
1545
|
-
parentSlot: BigInt
|
|
1546
|
-
previousBlockhash: String
|
|
1547
|
-
rewards: [Reward]
|
|
1548
|
-
transactions: [BlockTransactionAccounts]
|
|
1549
|
-
transactionDetails: String
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
"""
|
|
1553
|
-
A block with full transaction details
|
|
1554
|
-
"""
|
|
1555
|
-
type BlockWithFull implements Block {
|
|
1556
|
-
blockhash: String
|
|
1557
|
-
blockHeight: BigInt
|
|
1558
|
-
blockTime: BigInt
|
|
1559
|
-
parentSlot: BigInt
|
|
2120
|
+
parentSlot: Slot
|
|
1560
2121
|
previousBlockhash: String
|
|
1561
2122
|
rewards: [Reward]
|
|
2123
|
+
signatures: [Signature]
|
|
1562
2124
|
transactions: [Transaction]
|
|
1563
|
-
transactionDetails: String
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
"""
|
|
1567
|
-
A block with no transaction details
|
|
1568
|
-
"""
|
|
1569
|
-
type BlockWithNone implements Block {
|
|
1570
|
-
blockhash: String
|
|
1571
|
-
blockHeight: BigInt
|
|
1572
|
-
blockTime: BigInt
|
|
1573
|
-
parentSlot: BigInt
|
|
1574
|
-
previousBlockhash: String
|
|
1575
|
-
rewards: [Reward]
|
|
1576
|
-
transactionDetails: String
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
"""
|
|
1580
|
-
A block with signature transaction details
|
|
1581
|
-
"""
|
|
1582
|
-
type BlockWithSignatures implements Block {
|
|
1583
|
-
blockhash: String
|
|
1584
|
-
blockHeight: BigInt
|
|
1585
|
-
blockTime: BigInt
|
|
1586
|
-
parentSlot: BigInt
|
|
1587
|
-
previousBlockhash: String
|
|
1588
|
-
rewards: [Reward]
|
|
1589
|
-
signatures: [String]
|
|
1590
|
-
transactionDetails: String
|
|
1591
|
-
}
|
|
1592
|
-
`
|
|
1593
|
-
);
|
|
1594
|
-
|
|
1595
|
-
// src/schema/common/inputs.ts
|
|
1596
|
-
var inputTypeDefs = (
|
|
1597
|
-
/* GraphQL */
|
|
1598
|
-
`
|
|
1599
|
-
input DataSlice {
|
|
1600
|
-
offset: Int
|
|
1601
|
-
length: Int
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
input ProgramAccountsFilter {
|
|
1605
|
-
bytes: BigInt
|
|
1606
|
-
dataSize: BigInt
|
|
1607
|
-
encoding: AccountEncoding
|
|
1608
|
-
offset: BigInt
|
|
1609
|
-
}
|
|
1610
|
-
`
|
|
1611
|
-
);
|
|
1612
|
-
|
|
1613
|
-
// src/schema/common/scalars.ts
|
|
1614
|
-
var scalarTypeDefs = (
|
|
1615
|
-
/* GraphQL */
|
|
1616
|
-
`
|
|
1617
|
-
scalar Address
|
|
1618
|
-
scalar Base58EncodedBytes
|
|
1619
|
-
scalar Base64EncodedBytes
|
|
1620
|
-
scalar Base64ZstdEncodedBytes
|
|
1621
|
-
scalar BigInt
|
|
1622
|
-
`
|
|
1623
|
-
);
|
|
1624
|
-
|
|
1625
|
-
// src/schema/common/types.ts
|
|
1626
|
-
var commonTypeDefs = (
|
|
1627
|
-
/* GraphQL */
|
|
1628
|
-
`
|
|
1629
|
-
enum AccountEncoding {
|
|
1630
|
-
BASE_58
|
|
1631
|
-
BASE_64
|
|
1632
|
-
BASE_64_ZSTD
|
|
1633
|
-
PARSED
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
enum BlockTransactionDetails {
|
|
1637
|
-
accounts
|
|
1638
|
-
full
|
|
1639
|
-
none
|
|
1640
|
-
signatures
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
enum Commitment {
|
|
1644
|
-
confirmed
|
|
1645
|
-
finalized
|
|
1646
|
-
processed
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
type ReturnData {
|
|
1650
|
-
data: Base64EncodedBytes
|
|
1651
|
-
programId: Address
|
|
1652
|
-
}
|
|
1653
|
-
|
|
1654
|
-
type Reward {
|
|
1655
|
-
commission: Int
|
|
1656
|
-
lamports: BigInt
|
|
1657
|
-
postBalance: BigInt
|
|
1658
|
-
pubkey: Address
|
|
1659
|
-
rewardType: String
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
type TokenAmount {
|
|
1663
|
-
amount: String
|
|
1664
|
-
decimals: Int
|
|
1665
|
-
uiAmount: BigInt
|
|
1666
|
-
uiAmountString: String
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
|
-
type TokenBalance {
|
|
1670
|
-
accountIndex: Int
|
|
1671
|
-
mint: Account
|
|
1672
|
-
owner: Account
|
|
1673
|
-
programId: Address
|
|
1674
|
-
uiTokenAmount: TokenAmount
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
enum TransactionEncoding {
|
|
1678
|
-
BASE_58
|
|
1679
|
-
BASE_64
|
|
1680
|
-
PARSED
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
enum TransactionVersion {
|
|
1684
|
-
LEGACY
|
|
1685
|
-
ZERO
|
|
1686
2125
|
}
|
|
1687
2126
|
`
|
|
1688
2127
|
);
|
|
@@ -1804,12 +2243,12 @@ var instructionTypeDefs = (
|
|
|
1804
2243
|
programId: Address
|
|
1805
2244
|
authority: Account
|
|
1806
2245
|
bufferAccount: Account
|
|
1807
|
-
clockSysvar:
|
|
2246
|
+
clockSysvar: Account
|
|
1808
2247
|
maxDataLen: BigInt
|
|
1809
2248
|
payerAccount: Account
|
|
1810
2249
|
programAccount: Account
|
|
1811
2250
|
programDataAccount: Account
|
|
1812
|
-
rentSysvar:
|
|
2251
|
+
rentSysvar: Account
|
|
1813
2252
|
}
|
|
1814
2253
|
|
|
1815
2254
|
"""
|
|
@@ -1819,10 +2258,10 @@ var instructionTypeDefs = (
|
|
|
1819
2258
|
programId: Address
|
|
1820
2259
|
authority: Account
|
|
1821
2260
|
bufferAccount: Account
|
|
1822
|
-
clockSysvar:
|
|
2261
|
+
clockSysvar: Account
|
|
1823
2262
|
programAccount: Account
|
|
1824
2263
|
programDataAccount: Account
|
|
1825
|
-
rentSysvar:
|
|
2264
|
+
rentSysvar: Account
|
|
1826
2265
|
spillAccount: Account
|
|
1827
2266
|
}
|
|
1828
2267
|
|
|
@@ -1875,7 +2314,7 @@ var instructionTypeDefs = (
|
|
|
1875
2314
|
type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
|
|
1876
2315
|
programId: Address
|
|
1877
2316
|
account: Account
|
|
1878
|
-
mint:
|
|
2317
|
+
mint: Account
|
|
1879
2318
|
source: Account
|
|
1880
2319
|
systemProgram: Account
|
|
1881
2320
|
tokenProgram: Account
|
|
@@ -1888,7 +2327,7 @@ var instructionTypeDefs = (
|
|
|
1888
2327
|
type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
|
|
1889
2328
|
programId: Address
|
|
1890
2329
|
account: Account
|
|
1891
|
-
mint:
|
|
2330
|
+
mint: Account
|
|
1892
2331
|
source: Account
|
|
1893
2332
|
systemProgram: Account
|
|
1894
2333
|
tokenProgram: Account
|
|
@@ -1926,7 +2365,7 @@ var instructionTypeDefs = (
|
|
|
1926
2365
|
freezeAuthority: Account
|
|
1927
2366
|
mint: Account
|
|
1928
2367
|
mintAuthority: Account
|
|
1929
|
-
rentSysvar:
|
|
2368
|
+
rentSysvar: Account
|
|
1930
2369
|
}
|
|
1931
2370
|
|
|
1932
2371
|
"""
|
|
@@ -1948,7 +2387,7 @@ var instructionTypeDefs = (
|
|
|
1948
2387
|
account: Account
|
|
1949
2388
|
mint: Account
|
|
1950
2389
|
owner: Account
|
|
1951
|
-
rentSysvar:
|
|
2390
|
+
rentSysvar: Account
|
|
1952
2391
|
}
|
|
1953
2392
|
|
|
1954
2393
|
"""
|
|
@@ -1959,7 +2398,7 @@ var instructionTypeDefs = (
|
|
|
1959
2398
|
account: Account
|
|
1960
2399
|
mint: Account
|
|
1961
2400
|
owner: Account
|
|
1962
|
-
rentSysvar:
|
|
2401
|
+
rentSysvar: Account
|
|
1963
2402
|
}
|
|
1964
2403
|
|
|
1965
2404
|
"""
|
|
@@ -1979,7 +2418,7 @@ var instructionTypeDefs = (
|
|
|
1979
2418
|
programId: Address
|
|
1980
2419
|
m: BigInt # FIXME:*
|
|
1981
2420
|
multisig: Account
|
|
1982
|
-
rentSysvar:
|
|
2421
|
+
rentSysvar: Account
|
|
1983
2422
|
signers: [Address]
|
|
1984
2423
|
}
|
|
1985
2424
|
|
|
@@ -2234,7 +2673,7 @@ var instructionTypeDefs = (
|
|
|
2234
2673
|
programId: Address
|
|
2235
2674
|
authorized: StakeInitializeInstructionDataAuthorized
|
|
2236
2675
|
lockup: Lockup
|
|
2237
|
-
rentSysvar:
|
|
2676
|
+
rentSysvar: Account
|
|
2238
2677
|
stakeAccount: Account
|
|
2239
2678
|
}
|
|
2240
2679
|
|
|
@@ -2245,7 +2684,7 @@ var instructionTypeDefs = (
|
|
|
2245
2684
|
programId: Address
|
|
2246
2685
|
authority: Account
|
|
2247
2686
|
authorityType: String
|
|
2248
|
-
clockSysvar:
|
|
2687
|
+
clockSysvar: Account
|
|
2249
2688
|
custodian: Account
|
|
2250
2689
|
newAuthority: Account
|
|
2251
2690
|
stakeAccount: Account
|
|
@@ -2256,11 +2695,11 @@ var instructionTypeDefs = (
|
|
|
2256
2695
|
"""
|
|
2257
2696
|
type StakeDelegateStakeInstruction implements TransactionInstruction {
|
|
2258
2697
|
programId: Address
|
|
2259
|
-
clockSysvar:
|
|
2698
|
+
clockSysvar: Account
|
|
2260
2699
|
stakeAccount: Account
|
|
2261
2700
|
stakeAuthority: Account
|
|
2262
2701
|
stakeConfigAccount: Account
|
|
2263
|
-
stakeHistorySysvar:
|
|
2702
|
+
stakeHistorySysvar: Account
|
|
2264
2703
|
voteAccount: Account
|
|
2265
2704
|
}
|
|
2266
2705
|
|
|
@@ -2280,7 +2719,7 @@ var instructionTypeDefs = (
|
|
|
2280
2719
|
"""
|
|
2281
2720
|
type StakeWithdrawInstruction implements TransactionInstruction {
|
|
2282
2721
|
programId: Address
|
|
2283
|
-
clockSysvar:
|
|
2722
|
+
clockSysvar: Account
|
|
2284
2723
|
destination: Account
|
|
2285
2724
|
lamports: BigInt
|
|
2286
2725
|
stakeAccount: Account
|
|
@@ -2292,7 +2731,7 @@ var instructionTypeDefs = (
|
|
|
2292
2731
|
"""
|
|
2293
2732
|
type StakeDeactivateInstruction implements TransactionInstruction {
|
|
2294
2733
|
programId: Address
|
|
2295
|
-
clockSysvar:
|
|
2734
|
+
clockSysvar: Account
|
|
2296
2735
|
stakeAccount: Account
|
|
2297
2736
|
stakeAuthority: Account
|
|
2298
2737
|
}
|
|
@@ -2312,11 +2751,11 @@ var instructionTypeDefs = (
|
|
|
2312
2751
|
"""
|
|
2313
2752
|
type StakeMergeInstruction implements TransactionInstruction {
|
|
2314
2753
|
programId: Address
|
|
2315
|
-
clockSysvar:
|
|
2754
|
+
clockSysvar: Account
|
|
2316
2755
|
destination: Account
|
|
2317
2756
|
source: Account
|
|
2318
2757
|
stakeAuthority: Account
|
|
2319
|
-
stakeHistorySysvar:
|
|
2758
|
+
stakeHistorySysvar: Account
|
|
2320
2759
|
}
|
|
2321
2760
|
|
|
2322
2761
|
"""
|
|
@@ -2328,7 +2767,7 @@ var instructionTypeDefs = (
|
|
|
2328
2767
|
authorityOwner: Account
|
|
2329
2768
|
authoritySeed: String
|
|
2330
2769
|
authorityType: String
|
|
2331
|
-
clockSysvar:
|
|
2770
|
+
clockSysvar: Account
|
|
2332
2771
|
custodian: Account
|
|
2333
2772
|
newAuthorized: Account
|
|
2334
2773
|
stakeAccount: Account
|
|
@@ -2345,7 +2784,7 @@ var instructionTypeDefs = (
|
|
|
2345
2784
|
programId: Address
|
|
2346
2785
|
authorized: StakeInitializeCheckedInstructionDataAuthorized
|
|
2347
2786
|
lockup: Lockup
|
|
2348
|
-
rentSysvar:
|
|
2787
|
+
rentSysvar: Account
|
|
2349
2788
|
stakeAccount: Account
|
|
2350
2789
|
}
|
|
2351
2790
|
|
|
@@ -2356,7 +2795,7 @@ var instructionTypeDefs = (
|
|
|
2356
2795
|
programId: Address
|
|
2357
2796
|
authority: Account
|
|
2358
2797
|
authorityType: String
|
|
2359
|
-
clockSysvar:
|
|
2798
|
+
clockSysvar: Account
|
|
2360
2799
|
custodian: Account
|
|
2361
2800
|
newAuthority: Account
|
|
2362
2801
|
stakeAccount: Account
|
|
@@ -2371,7 +2810,7 @@ var instructionTypeDefs = (
|
|
|
2371
2810
|
authorityOwner: Account
|
|
2372
2811
|
authoritySeed: String
|
|
2373
2812
|
authorityType: String
|
|
2374
|
-
clockSysvar:
|
|
2813
|
+
clockSysvar: Account
|
|
2375
2814
|
custodian: Account
|
|
2376
2815
|
newAuthorized: Account
|
|
2377
2816
|
stakeAccount: Account
|
|
@@ -2459,7 +2898,7 @@ var instructionTypeDefs = (
|
|
|
2459
2898
|
programId: Address
|
|
2460
2899
|
nonceAccount: Account
|
|
2461
2900
|
nonceAuthority: Account
|
|
2462
|
-
recentBlockhashesSysvar:
|
|
2901
|
+
recentBlockhashesSysvar: Account
|
|
2463
2902
|
}
|
|
2464
2903
|
|
|
2465
2904
|
"""
|
|
@@ -2471,8 +2910,8 @@ var instructionTypeDefs = (
|
|
|
2471
2910
|
lamports: BigInt
|
|
2472
2911
|
nonceAccount: Account
|
|
2473
2912
|
nonceAuthority: Account
|
|
2474
|
-
recentBlockhashesSysvar:
|
|
2475
|
-
rentSysvar:
|
|
2913
|
+
recentBlockhashesSysvar: Account
|
|
2914
|
+
rentSysvar: Account
|
|
2476
2915
|
}
|
|
2477
2916
|
|
|
2478
2917
|
"""
|
|
@@ -2482,8 +2921,8 @@ var instructionTypeDefs = (
|
|
|
2482
2921
|
programId: Address
|
|
2483
2922
|
nonceAccount: Account
|
|
2484
2923
|
nonceAuthority: Account
|
|
2485
|
-
recentBlockhashesSysvar:
|
|
2486
|
-
rentSysvar:
|
|
2924
|
+
recentBlockhashesSysvar: Account
|
|
2925
|
+
rentSysvar: Account
|
|
2487
2926
|
}
|
|
2488
2927
|
|
|
2489
2928
|
"""
|
|
@@ -2557,10 +2996,10 @@ var instructionTypeDefs = (
|
|
|
2557
2996
|
programId: Address
|
|
2558
2997
|
authorizedVoter: Account
|
|
2559
2998
|
authorizedWithdrawer: Account
|
|
2560
|
-
clockSysvar:
|
|
2999
|
+
clockSysvar: Account
|
|
2561
3000
|
commission: BigInt # FIXME:*
|
|
2562
3001
|
node: Account
|
|
2563
|
-
rentSysvar:
|
|
3002
|
+
rentSysvar: Account
|
|
2564
3003
|
voteAccount: Account
|
|
2565
3004
|
}
|
|
2566
3005
|
|
|
@@ -2571,7 +3010,7 @@ var instructionTypeDefs = (
|
|
|
2571
3010
|
programId: Address
|
|
2572
3011
|
authority: Account
|
|
2573
3012
|
authorityType: String
|
|
2574
|
-
clockSysvar:
|
|
3013
|
+
clockSysvar: Account
|
|
2575
3014
|
newAuthority: Account
|
|
2576
3015
|
voteAccount: Account
|
|
2577
3016
|
}
|
|
@@ -2585,7 +3024,7 @@ var instructionTypeDefs = (
|
|
|
2585
3024
|
authorityOwner: Account
|
|
2586
3025
|
authoritySeed: String
|
|
2587
3026
|
authorityType: String
|
|
2588
|
-
clockSysvar:
|
|
3027
|
+
clockSysvar: Account
|
|
2589
3028
|
newAuthority: Account
|
|
2590
3029
|
voteAccount: Account
|
|
2591
3030
|
}
|
|
@@ -2599,7 +3038,7 @@ var instructionTypeDefs = (
|
|
|
2599
3038
|
authorityOwner: Account
|
|
2600
3039
|
authoritySeed: String
|
|
2601
3040
|
authorityType: String
|
|
2602
|
-
clockSysvar:
|
|
3041
|
+
clockSysvar: Account
|
|
2603
3042
|
newAuthority: Account
|
|
2604
3043
|
voteAccount: Account
|
|
2605
3044
|
}
|
|
@@ -2615,8 +3054,8 @@ var instructionTypeDefs = (
|
|
|
2615
3054
|
"""
|
|
2616
3055
|
type VoteVoteInstruction implements TransactionInstruction {
|
|
2617
3056
|
programId: Address
|
|
2618
|
-
clockSysvar:
|
|
2619
|
-
slotHashesSysvar:
|
|
3057
|
+
clockSysvar: Account
|
|
3058
|
+
slotHashesSysvar: Account
|
|
2620
3059
|
vote: Vote
|
|
2621
3060
|
voteAccount: Account
|
|
2622
3061
|
voteAuthority: Account
|
|
@@ -2713,9 +3152,9 @@ var instructionTypeDefs = (
|
|
|
2713
3152
|
"""
|
|
2714
3153
|
type VoteVoteSwitchInstruction implements TransactionInstruction {
|
|
2715
3154
|
programId: Address
|
|
2716
|
-
clockSysvar:
|
|
3155
|
+
clockSysvar: Account
|
|
2717
3156
|
hash: String
|
|
2718
|
-
slotHashesSysvar:
|
|
3157
|
+
slotHashesSysvar: Account
|
|
2719
3158
|
vote: Vote
|
|
2720
3159
|
voteAccount: Account
|
|
2721
3160
|
voteAuthority: Account
|
|
@@ -2728,7 +3167,7 @@ var instructionTypeDefs = (
|
|
|
2728
3167
|
programId: Address
|
|
2729
3168
|
authority: Account
|
|
2730
3169
|
authorityType: String
|
|
2731
|
-
clockSysvar:
|
|
3170
|
+
clockSysvar: Account
|
|
2732
3171
|
newAuthority: Account
|
|
2733
3172
|
voteAccount: Account
|
|
2734
3173
|
}
|
|
@@ -2740,28 +3179,15 @@ var rootTypeDefs = (
|
|
|
2740
3179
|
/* GraphQL */
|
|
2741
3180
|
`
|
|
2742
3181
|
type Query {
|
|
2743
|
-
account(
|
|
2744
|
-
|
|
2745
|
-
commitment: Commitment
|
|
2746
|
-
dataSlice: DataSlice
|
|
2747
|
-
encoding: AccountEncoding
|
|
2748
|
-
minContextSlot: BigInt
|
|
2749
|
-
): Account
|
|
2750
|
-
block(
|
|
2751
|
-
slot: BigInt!
|
|
2752
|
-
commitment: Commitment
|
|
2753
|
-
encoding: TransactionEncoding
|
|
2754
|
-
transactionDetails: BlockTransactionDetails
|
|
2755
|
-
): Block
|
|
3182
|
+
account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
|
|
3183
|
+
block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
|
|
2756
3184
|
programAccounts(
|
|
2757
|
-
programAddress:
|
|
3185
|
+
programAddress: Address!
|
|
2758
3186
|
commitment: Commitment
|
|
2759
|
-
dataSlice: DataSlice
|
|
2760
|
-
encoding: AccountEncoding
|
|
2761
3187
|
filters: [ProgramAccountsFilter]
|
|
2762
|
-
minContextSlot:
|
|
3188
|
+
minContextSlot: Slot
|
|
2763
3189
|
): [Account]
|
|
2764
|
-
transaction(signature:
|
|
3190
|
+
transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
|
|
2765
3191
|
}
|
|
2766
3192
|
|
|
2767
3193
|
schema {
|
|
@@ -2836,77 +3262,120 @@ var transactionTypeDefs = (
|
|
|
2836
3262
|
}
|
|
2837
3263
|
|
|
2838
3264
|
"""
|
|
2839
|
-
|
|
3265
|
+
A Solana transaction
|
|
2840
3266
|
"""
|
|
2841
|
-
|
|
3267
|
+
type Transaction {
|
|
2842
3268
|
blockTime: BigInt
|
|
3269
|
+
data(encoding: TransactionEncoding!): String
|
|
3270
|
+
message: TransactionMessage
|
|
2843
3271
|
meta: TransactionMeta
|
|
2844
|
-
|
|
3272
|
+
signatures: [Signature]
|
|
3273
|
+
slot: Slot
|
|
2845
3274
|
version: String
|
|
2846
3275
|
}
|
|
3276
|
+
`
|
|
3277
|
+
);
|
|
2847
3278
|
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
version: String
|
|
3279
|
+
// src/schema/types.ts
|
|
3280
|
+
var typeTypeDefs = (
|
|
3281
|
+
/* GraphQL */
|
|
3282
|
+
`
|
|
3283
|
+
enum AccountEncoding {
|
|
3284
|
+
BASE_58
|
|
3285
|
+
BASE_64
|
|
3286
|
+
BASE_64_ZSTD
|
|
2857
3287
|
}
|
|
2858
3288
|
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
3289
|
+
scalar Address
|
|
3290
|
+
|
|
3291
|
+
scalar Base58EncodedBytes
|
|
3292
|
+
|
|
3293
|
+
scalar Base64EncodedBytes
|
|
3294
|
+
|
|
3295
|
+
scalar Base64ZstdEncodedBytes
|
|
3296
|
+
|
|
3297
|
+
scalar BigInt
|
|
3298
|
+
|
|
3299
|
+
enum Commitment {
|
|
3300
|
+
CONFIRMED
|
|
3301
|
+
FINALIZED
|
|
3302
|
+
PROCESSED
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
enum CommitmentWithoutProcessed {
|
|
3306
|
+
CONFIRMED
|
|
3307
|
+
FINALIZED
|
|
3308
|
+
}
|
|
3309
|
+
|
|
3310
|
+
input DataSlice {
|
|
3311
|
+
offset: Int!
|
|
3312
|
+
length: Int!
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
input ProgramAccountsFilter {
|
|
3316
|
+
bytes: BigInt
|
|
3317
|
+
dataSize: BigInt
|
|
3318
|
+
encoding: AccountEncoding
|
|
3319
|
+
offset: BigInt
|
|
3320
|
+
}
|
|
3321
|
+
|
|
3322
|
+
type ReturnData {
|
|
2864
3323
|
data: Base64EncodedBytes
|
|
2865
|
-
|
|
2866
|
-
slot: BigInt
|
|
2867
|
-
version: String
|
|
3324
|
+
programId: Address
|
|
2868
3325
|
}
|
|
2869
3326
|
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3327
|
+
type Reward {
|
|
3328
|
+
commission: Int
|
|
3329
|
+
lamports: BigInt
|
|
3330
|
+
postBalance: BigInt
|
|
3331
|
+
pubkey: Address
|
|
3332
|
+
rewardType: String
|
|
2876
3333
|
}
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
3334
|
+
|
|
3335
|
+
scalar Signature
|
|
3336
|
+
|
|
3337
|
+
scalar Slot
|
|
3338
|
+
|
|
3339
|
+
type TokenAmount {
|
|
3340
|
+
amount: String
|
|
3341
|
+
decimals: Int
|
|
3342
|
+
uiAmount: BigInt
|
|
3343
|
+
uiAmountString: String
|
|
3344
|
+
}
|
|
3345
|
+
|
|
3346
|
+
type TokenBalance {
|
|
3347
|
+
accountIndex: Int
|
|
3348
|
+
mint: Account
|
|
3349
|
+
owner: Account
|
|
3350
|
+
programId: Address
|
|
3351
|
+
uiTokenAmount: TokenAmount
|
|
3352
|
+
}
|
|
3353
|
+
|
|
3354
|
+
enum TransactionEncoding {
|
|
3355
|
+
BASE_58
|
|
3356
|
+
BASE_64
|
|
2883
3357
|
}
|
|
2884
3358
|
`
|
|
2885
3359
|
);
|
|
2886
3360
|
|
|
2887
3361
|
// src/schema/index.ts
|
|
2888
3362
|
function createSolanaGraphQLTypeDefs() {
|
|
2889
|
-
return [
|
|
2890
|
-
accountTypeDefs,
|
|
2891
|
-
blockTypeDefs,
|
|
2892
|
-
commonTypeDefs,
|
|
2893
|
-
inputTypeDefs,
|
|
2894
|
-
instructionTypeDefs,
|
|
2895
|
-
rootTypeDefs,
|
|
2896
|
-
scalarTypeDefs,
|
|
2897
|
-
transactionTypeDefs
|
|
2898
|
-
];
|
|
3363
|
+
return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
|
|
2899
3364
|
}
|
|
2900
3365
|
|
|
2901
3366
|
// src/index.ts
|
|
2902
|
-
function createRpcGraphQL(rpc) {
|
|
3367
|
+
function createRpcGraphQL(rpc, config) {
|
|
3368
|
+
const rpcGraphQLConfig = {
|
|
3369
|
+
maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
|
|
3370
|
+
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
|
|
3371
|
+
};
|
|
2903
3372
|
const schema$1 = schema.makeExecutableSchema({
|
|
2904
3373
|
resolvers: createSolanaGraphQLResolvers(),
|
|
2905
3374
|
typeDefs: createSolanaGraphQLTypeDefs()
|
|
2906
3375
|
});
|
|
2907
3376
|
return {
|
|
2908
3377
|
async query(source, variableValues) {
|
|
2909
|
-
const contextValue = createSolanaGraphQLContext(rpc);
|
|
3378
|
+
const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
|
|
2910
3379
|
return graphql.graphql({
|
|
2911
3380
|
contextValue,
|
|
2912
3381
|
schema: schema$1,
|