@solana/rpc-graphql 2.0.0-experimental.eb5fd16 → 2.0.0-experimental.eb951b0
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/LICENSE +1 -1
- package/README.md +1088 -30
- package/dist/index.browser.cjs +3364 -51
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +3361 -53
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +3365 -53
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +3365 -48
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +3365 -53
- package/dist/index.node.js.map +1 -1
- package/dist/types/context.d.ts +17 -6
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/loaders/account.d.ts +14 -0
- package/dist/types/loaders/account.d.ts.map +1 -0
- package/dist/types/loaders/block.d.ts +4 -0
- package/dist/types/loaders/block.d.ts.map +1 -0
- 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 +6 -0
- package/dist/types/loaders/index.d.ts.map +1 -0
- package/dist/types/loaders/loader.d.ts +82 -0
- package/dist/types/loaders/loader.d.ts.map +1 -0
- package/dist/types/loaders/program-accounts.d.ts +8 -0
- package/dist/types/loaders/program-accounts.d.ts.map +1 -0
- package/dist/types/loaders/transaction.d.ts +4 -0
- package/dist/types/loaders/transaction.d.ts.map +1 -0
- package/dist/types/resolvers/account.d.ts +232 -0
- package/dist/types/resolvers/account.d.ts.map +1 -0
- package/dist/types/resolvers/block.d.ts +104 -0
- package/dist/types/resolvers/block.d.ts.map +1 -0
- package/dist/types/resolvers/index.d.ts +3 -0
- package/dist/types/resolvers/index.d.ts.map +1 -0
- package/dist/types/resolvers/instruction.d.ts +2220 -0
- package/dist/types/resolvers/instruction.d.ts.map +1 -0
- package/dist/types/resolvers/program-accounts.d.ts +19 -0
- package/dist/types/resolvers/program-accounts.d.ts.map +1 -0
- 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/root.d.ts +3 -0
- package/dist/types/resolvers/root.d.ts.map +1 -0
- package/dist/types/resolvers/transaction.d.ts +42 -0
- package/dist/types/resolvers/transaction.d.ts.map +1 -0
- package/dist/types/resolvers/types.d.ts +94 -0
- package/dist/types/resolvers/types.d.ts.map +1 -0
- package/dist/types/schema/account.d.ts +2 -0
- package/dist/types/schema/account.d.ts.map +1 -0
- package/dist/types/schema/block.d.ts +2 -0
- package/dist/types/schema/block.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +2 -0
- package/dist/types/schema/index.d.ts.map +1 -0
- package/dist/types/schema/instruction.d.ts +2 -0
- package/dist/types/schema/instruction.d.ts.map +1 -0
- package/dist/types/schema/root.d.ts +2 -0
- package/dist/types/schema/root.d.ts.map +1 -0
- package/dist/types/schema/transaction.d.ts +2 -0
- package/dist/types/schema/transaction.d.ts.map +1 -0
- package/dist/types/schema/types.d.ts +2 -0
- package/dist/types/schema/types.d.ts.map +1 -0
- package/package.json +15 -36
- package/dist/types/cache.d.ts +0 -7
- package/dist/types/rpc.d.ts +0 -13
package/dist/index.node.cjs
CHANGED
|
@@ -1,71 +1,3388 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var schema = require('@graphql-tools/schema');
|
|
3
4
|
var graphql = require('graphql');
|
|
5
|
+
var codecsStrings = require('@solana/codecs-strings');
|
|
6
|
+
var DataLoader = require('dataloader');
|
|
7
|
+
var stringify = require('json-stable-stringify');
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
var DataLoader__default = /*#__PURE__*/_interopDefault(DataLoader);
|
|
12
|
+
var stringify__default = /*#__PURE__*/_interopDefault(stringify);
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
function replacer(_, value) {
|
|
16
|
+
if (typeof value === "bigint") {
|
|
17
|
+
return value.toString() + "n";
|
|
12
18
|
}
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
var cacheKeyFn = (obj) => stringify__default.default(obj, { replacer });
|
|
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
|
+
|
|
168
|
+
// src/loaders/account.ts
|
|
169
|
+
function getCodec(encoding) {
|
|
170
|
+
switch (encoding) {
|
|
171
|
+
case "base58":
|
|
172
|
+
return codecsStrings.getBase58Codec();
|
|
173
|
+
default:
|
|
174
|
+
return codecsStrings.getBase64Codec();
|
|
18
175
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
204
|
+
}
|
|
205
|
+
async function loadAccount(rpc, { address, ...config }) {
|
|
206
|
+
return await rpc.getAccountInfo(address, config).send().then((res) => res.value);
|
|
207
|
+
}
|
|
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) {
|
|
212
|
+
const resolveAccountUsingRpc = loadAccount.bind(null, rpc);
|
|
213
|
+
const resolveMultipleAccountsUsingRpc = loadMultipleAccounts.bind(null, rpc);
|
|
214
|
+
return async (accountQueryArgs) => {
|
|
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
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function createAccountLoader(rpc, config) {
|
|
283
|
+
const loader = new DataLoader__default.default(createAccountBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
23
284
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
285
|
+
load: async (args) => loader.load(args),
|
|
286
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
async function loadBlock(rpc, { slot, ...config }) {
|
|
290
|
+
return await rpc.getBlock(
|
|
291
|
+
slot,
|
|
292
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
293
|
+
config
|
|
294
|
+
).send();
|
|
295
|
+
}
|
|
296
|
+
function createBlockBatchLoadFn(rpc) {
|
|
297
|
+
const resolveBlockUsingRpc = loadBlock.bind(null, rpc);
|
|
298
|
+
return async (blockQueryArgs) => {
|
|
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
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function createBlockLoader(rpc) {
|
|
340
|
+
const loader = new DataLoader__default.default(createBlockBatchLoadFn(rpc), { cacheKeyFn });
|
|
341
|
+
return {
|
|
342
|
+
load: async (args) => loader.load({ ...args, maxSupportedTransactionVersion: 0 }),
|
|
343
|
+
loadMany: async (args) => loader.loadMany(args.map((a) => ({ ...a, maxSupportedTransactionVersion: 0 })))
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
async function loadProgramAccounts(rpc, { programAddress, ...config }) {
|
|
347
|
+
return await rpc.getProgramAccounts(
|
|
348
|
+
programAddress,
|
|
349
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
350
|
+
config
|
|
351
|
+
).send();
|
|
352
|
+
}
|
|
353
|
+
function createProgramAccountsBatchLoadFn(rpc, config) {
|
|
354
|
+
const resolveProgramAccountsUsingRpc = loadProgramAccounts.bind(null, rpc);
|
|
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
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function createProgramAccountsLoader(rpc, config) {
|
|
398
|
+
const loader = new DataLoader__default.default(createProgramAccountsBatchLoadFn(rpc, config), { cacheKeyFn });
|
|
399
|
+
return {
|
|
400
|
+
load: async (args) => loader.load(args),
|
|
401
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
async function loadTransaction(rpc, { signature, ...config }) {
|
|
405
|
+
return await rpc.getTransaction(
|
|
406
|
+
signature,
|
|
407
|
+
// @ts-expect-error FIX ME: https://github.com/microsoft/TypeScript/issues/43187
|
|
408
|
+
config
|
|
409
|
+
).send();
|
|
410
|
+
}
|
|
411
|
+
function createTransactionBatchLoadFn(rpc) {
|
|
412
|
+
const resolveTransactionUsingRpc = loadTransaction.bind(null, rpc);
|
|
413
|
+
return async (transactionQueryArgs) => {
|
|
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
|
+
});
|
|
34
448
|
}
|
|
35
449
|
};
|
|
36
450
|
}
|
|
451
|
+
function createTransactionLoader(rpc) {
|
|
452
|
+
const loader = new DataLoader__default.default(createTransactionBatchLoadFn(rpc), { cacheKeyFn });
|
|
453
|
+
return {
|
|
454
|
+
load: async (args) => loader.load(args),
|
|
455
|
+
loadMany: async (args) => loader.loadMany(args)
|
|
456
|
+
};
|
|
457
|
+
}
|
|
37
458
|
|
|
38
459
|
// src/context.ts
|
|
39
|
-
function createSolanaGraphQLContext(rpc) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
460
|
+
function createSolanaGraphQLContext(rpc, config) {
|
|
461
|
+
return {
|
|
462
|
+
loaders: {
|
|
463
|
+
account: createAccountLoader(rpc, config),
|
|
464
|
+
block: createBlockLoader(rpc),
|
|
465
|
+
programAccounts: createProgramAccountsLoader(rpc, config),
|
|
466
|
+
transaction: createTransactionLoader(rpc)
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
}
|
|
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);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
checkFieldsWithVisitor(rootNode ?? null);
|
|
510
|
+
return onlyFieldsRequested2;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/resolvers/resolve-info/account.ts
|
|
514
|
+
function findArgumentNodeByName(argumentNodes, name) {
|
|
515
|
+
return argumentNodes.find((argumentNode) => argumentNode.name.value === name);
|
|
516
|
+
}
|
|
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
|
+
}
|
|
530
|
+
}
|
|
531
|
+
if (argumentNode.value.kind === "Variable") {
|
|
532
|
+
return variableValues[argumentNode.value.name.value];
|
|
533
|
+
}
|
|
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
|
+
}
|
|
581
|
+
}
|
|
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";
|
|
601
|
+
}
|
|
602
|
+
if (argumentNode.value.value === "BASE_64") {
|
|
603
|
+
return "base64";
|
|
604
|
+
}
|
|
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
|
+
}
|
|
629
|
+
}
|
|
51
630
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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));
|
|
656
|
+
}
|
|
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;
|
|
698
|
+
}
|
|
699
|
+
if (account === null) {
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (!result.ownerProgram) {
|
|
703
|
+
result = {
|
|
704
|
+
...result,
|
|
705
|
+
...account,
|
|
706
|
+
ownerProgram: account.owner
|
|
707
|
+
};
|
|
708
|
+
}
|
|
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
|
+
}
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
return result;
|
|
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()
|
|
773
|
+
},
|
|
774
|
+
GenericAccount: {
|
|
775
|
+
data: resolveAccountData(),
|
|
776
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
777
|
+
},
|
|
778
|
+
LookupTableAccount: {
|
|
779
|
+
authority: resolveAccount("authority"),
|
|
780
|
+
data: resolveAccountData(),
|
|
781
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
782
|
+
},
|
|
783
|
+
MintAccount: {
|
|
784
|
+
data: resolveAccountData(),
|
|
785
|
+
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
786
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
787
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
788
|
+
},
|
|
789
|
+
NonceAccount: {
|
|
790
|
+
authority: resolveAccount("authority"),
|
|
791
|
+
data: resolveAccountData(),
|
|
792
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
793
|
+
},
|
|
794
|
+
StakeAccount: {
|
|
795
|
+
data: resolveAccountData(),
|
|
796
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
797
|
+
},
|
|
798
|
+
StakeAccountDataMetaAuthorized: {
|
|
799
|
+
staker: resolveAccount("staker"),
|
|
800
|
+
withdrawer: resolveAccount("withdrawer")
|
|
801
|
+
},
|
|
802
|
+
StakeAccountDataMetaLockup: {
|
|
803
|
+
custodian: resolveAccount("custodian")
|
|
804
|
+
},
|
|
805
|
+
StakeAccountDataStakeDelegation: {
|
|
806
|
+
voter: resolveAccount("voter")
|
|
807
|
+
},
|
|
808
|
+
TokenAccount: {
|
|
809
|
+
data: resolveAccountData(),
|
|
810
|
+
mint: resolveAccount("mint"),
|
|
811
|
+
owner: resolveAccount("owner"),
|
|
812
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
813
|
+
},
|
|
814
|
+
VoteAccount: {
|
|
815
|
+
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
816
|
+
data: resolveAccountData(),
|
|
817
|
+
node: resolveAccount("nodePubkey"),
|
|
818
|
+
ownerProgram: resolveAccount("ownerProgram")
|
|
819
|
+
},
|
|
820
|
+
VoteAccountDataAuthorizedVoter: {
|
|
821
|
+
authorizedVoter: resolveAccount("authorizedVoter")
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
// src/resolvers/transaction.ts
|
|
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
|
+
}
|
|
853
|
+
});
|
|
854
|
+
}
|
|
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
|
+
}));
|
|
861
|
+
}
|
|
862
|
+
var resolveTransactionData = () => {
|
|
863
|
+
return (parent, args) => {
|
|
864
|
+
return parent === null ? null : parent.encodedData ? parent.encodedData[cacheKeyFn(args)] : null;
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
function resolveTransaction(fieldName) {
|
|
868
|
+
return async (parent, args, context, info) => {
|
|
869
|
+
const signature = fieldName ? parent[fieldName] : args.signature;
|
|
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: {},
|
|
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
|
+
}
|
|
926
|
+
});
|
|
927
|
+
return result;
|
|
928
|
+
}
|
|
929
|
+
return null;
|
|
930
|
+
};
|
|
931
|
+
}
|
|
932
|
+
var transactionResolvers = {
|
|
933
|
+
Transaction: {
|
|
934
|
+
data: resolveTransactionData()
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
// src/resolvers/block.ts
|
|
939
|
+
var resolveBlock = (fieldName) => {
|
|
940
|
+
return async (parent, args, context, info) => {
|
|
941
|
+
const slot = fieldName ? parent[fieldName] : args.slot;
|
|
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;
|
|
1020
|
+
}
|
|
1021
|
+
return null;
|
|
1022
|
+
};
|
|
1023
|
+
};
|
|
1024
|
+
var blockResolvers = {
|
|
1025
|
+
Block: {
|
|
1026
|
+
transactions: (parent) => parent?.transactionResults ? Object.values(parent.transactionResults) : null
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
// src/resolvers/instruction.ts
|
|
1031
|
+
var instructionResolvers = {
|
|
1032
|
+
AdvanceNonceAccountInstruction: {
|
|
1033
|
+
nonceAccount: resolveAccount("nonceAccount"),
|
|
1034
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1035
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar")
|
|
1036
|
+
},
|
|
1037
|
+
AllocateInstruction: {
|
|
1038
|
+
account: resolveAccount("account")
|
|
1039
|
+
},
|
|
1040
|
+
AllocateWithSeedInstruction: {
|
|
1041
|
+
account: resolveAccount("account"),
|
|
1042
|
+
owner: resolveAccount("owner")
|
|
1043
|
+
},
|
|
1044
|
+
AssignInstruction: {
|
|
1045
|
+
account: resolveAccount("account"),
|
|
1046
|
+
owner: resolveAccount("owner")
|
|
1047
|
+
},
|
|
1048
|
+
AssignWithSeedInstruction: {
|
|
1049
|
+
account: resolveAccount("account"),
|
|
1050
|
+
owner: resolveAccount("owner")
|
|
1051
|
+
},
|
|
1052
|
+
AuthorizeNonceAccountInstruction: {
|
|
1053
|
+
newAuthorized: resolveAccount("newAuthorized"),
|
|
1054
|
+
nonceAccount: resolveAccount("nonceAccount"),
|
|
1055
|
+
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1056
|
+
},
|
|
1057
|
+
BpfLoaderFinalizeInstruction: {
|
|
1058
|
+
account: resolveAccount("account")
|
|
1059
|
+
},
|
|
1060
|
+
BpfLoaderWriteInstruction: {
|
|
1061
|
+
account: resolveAccount("account")
|
|
1062
|
+
},
|
|
1063
|
+
BpfUpgradeableLoaderCloseInstruction: {
|
|
1064
|
+
account: resolveAccount("account"),
|
|
1065
|
+
authority: resolveAccount("authority"),
|
|
1066
|
+
programAccount: resolveAccount("programAccount"),
|
|
1067
|
+
recipient: resolveAccount("recipient")
|
|
1068
|
+
},
|
|
1069
|
+
BpfUpgradeableLoaderDeployWithMaxDataLenInstruction: {
|
|
1070
|
+
authority: resolveAccount("authority"),
|
|
1071
|
+
bufferAccount: resolveAccount("bufferAccount"),
|
|
1072
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1073
|
+
payerAccount: resolveAccount("payerAccount"),
|
|
1074
|
+
programAccount: resolveAccount("programAccount"),
|
|
1075
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1076
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1077
|
+
},
|
|
1078
|
+
BpfUpgradeableLoaderExtendProgramInstruction: {
|
|
1079
|
+
payerAccount: resolveAccount("payerAccount"),
|
|
1080
|
+
programAccount: resolveAccount("programAccount"),
|
|
1081
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1082
|
+
systemProgram: resolveAccount("systemProgram")
|
|
1083
|
+
},
|
|
1084
|
+
BpfUpgradeableLoaderInitializeBufferInstruction: {
|
|
1085
|
+
account: resolveAccount("account")
|
|
1086
|
+
},
|
|
1087
|
+
BpfUpgradeableLoaderSetAuthorityCheckedInstruction: {
|
|
1088
|
+
account: resolveAccount("account"),
|
|
1089
|
+
authority: resolveAccount("authority"),
|
|
1090
|
+
newAuthority: resolveAccount("newAuthority")
|
|
1091
|
+
},
|
|
1092
|
+
BpfUpgradeableLoaderSetAuthorityInstruction: {
|
|
1093
|
+
account: resolveAccount("account"),
|
|
1094
|
+
authority: resolveAccount("authority"),
|
|
1095
|
+
newAuthority: resolveAccount("newAuthority")
|
|
1096
|
+
},
|
|
1097
|
+
BpfUpgradeableLoaderUpgradeInstruction: {
|
|
1098
|
+
authority: resolveAccount("authority"),
|
|
1099
|
+
bufferAccount: resolveAccount("bufferAccount"),
|
|
1100
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1101
|
+
programAccount: resolveAccount("programAccount"),
|
|
1102
|
+
programDataAccount: resolveAccount("programDataAccount"),
|
|
1103
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1104
|
+
},
|
|
1105
|
+
BpfUpgradeableLoaderWriteInstruction: {
|
|
1106
|
+
account: resolveAccount("account"),
|
|
1107
|
+
authority: resolveAccount("authority")
|
|
1108
|
+
},
|
|
1109
|
+
CloseLookupTableInstruction: {
|
|
1110
|
+
lookupTableAccount: resolveAccount("lookupTableAccount"),
|
|
1111
|
+
lookupTableAuthority: resolveAccount("lookupTableAuthority"),
|
|
1112
|
+
recipient: resolveAccount("recipient")
|
|
1113
|
+
},
|
|
1114
|
+
CreateAccountInstruction: {
|
|
1115
|
+
newAccount: resolveAccount("newAccount"),
|
|
1116
|
+
owner: resolveAccount("owner"),
|
|
1117
|
+
source: resolveAccount("source")
|
|
1118
|
+
},
|
|
1119
|
+
CreateAccountWithSeedInstruction: {
|
|
1120
|
+
base: resolveAccount("base"),
|
|
1121
|
+
owner: resolveAccount("owner"),
|
|
1122
|
+
seed: resolveAccount("seed")
|
|
1123
|
+
},
|
|
1124
|
+
CreateLookupTableInstruction: {
|
|
1125
|
+
lookupTableAccount: resolveAccount("lookupTableAccount"),
|
|
1126
|
+
lookupTableAuthority: resolveAccount("lookupTableAuthority"),
|
|
1127
|
+
payerAccount: resolveAccount("payerAccount"),
|
|
1128
|
+
systemProgram: resolveAccount("systemProgram")
|
|
1129
|
+
},
|
|
1130
|
+
DeactivateLookupTableInstruction: {
|
|
1131
|
+
lookupTableAccount: resolveAccount("lookupTableAccount"),
|
|
1132
|
+
lookupTableAuthority: resolveAccount("lookupTableAuthority")
|
|
1133
|
+
},
|
|
1134
|
+
ExtendLookupTableInstruction: {
|
|
1135
|
+
lookupTableAccount: resolveAccount("lookupTableAccount"),
|
|
1136
|
+
lookupTableAuthority: resolveAccount("lookupTableAuthority"),
|
|
1137
|
+
payerAccount: resolveAccount("payerAccount"),
|
|
1138
|
+
systemProgram: resolveAccount("systemProgram")
|
|
1139
|
+
},
|
|
1140
|
+
FreezeLookupTableInstruction: {
|
|
1141
|
+
lookupTableAccount: resolveAccount("lookupTableAccount"),
|
|
1142
|
+
lookupTableAuthority: resolveAccount("lookupTableAuthority")
|
|
1143
|
+
},
|
|
1144
|
+
InitializeNonceAccountInstruction: {
|
|
1145
|
+
nonceAccount: resolveAccount("nonceAccount"),
|
|
1146
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1147
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1148
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1149
|
+
},
|
|
1150
|
+
Lockup: {
|
|
1151
|
+
custodian: resolveAccount("custodian")
|
|
1152
|
+
},
|
|
1153
|
+
SplAssociatedTokenCreateIdempotentInstruction: {
|
|
1154
|
+
account: resolveAccount("account"),
|
|
1155
|
+
mint: resolveAccount("mint"),
|
|
1156
|
+
source: resolveAccount("source"),
|
|
1157
|
+
systemProgram: resolveAccount("systemProgram"),
|
|
1158
|
+
tokenProgram: resolveAccount("tokenProgram"),
|
|
1159
|
+
wallet: resolveAccount("wallet")
|
|
1160
|
+
},
|
|
1161
|
+
SplAssociatedTokenCreateInstruction: {
|
|
1162
|
+
account: resolveAccount("account"),
|
|
1163
|
+
mint: resolveAccount("mint"),
|
|
1164
|
+
source: resolveAccount("source"),
|
|
1165
|
+
systemProgram: resolveAccount("systemProgram"),
|
|
1166
|
+
tokenProgram: resolveAccount("tokenProgram"),
|
|
1167
|
+
wallet: resolveAccount("wallet")
|
|
1168
|
+
},
|
|
1169
|
+
SplAssociatedTokenRecoverNestedInstruction: {
|
|
1170
|
+
destination: resolveAccount("destination"),
|
|
1171
|
+
nestedMint: resolveAccount("nestedMint"),
|
|
1172
|
+
nestedOwner: resolveAccount("nestedOwner"),
|
|
1173
|
+
nestedSource: resolveAccount("nestedSource"),
|
|
1174
|
+
ownerMint: resolveAccount("ownerMint"),
|
|
1175
|
+
tokenProgram: resolveAccount("tokenProgram"),
|
|
1176
|
+
wallet: resolveAccount("wallet")
|
|
1177
|
+
},
|
|
1178
|
+
SplTokenAmountToUiAmountInstruction: {
|
|
1179
|
+
mint: resolveAccount("mint")
|
|
1180
|
+
},
|
|
1181
|
+
SplTokenApproveCheckedInstruction: {
|
|
1182
|
+
delegate: resolveAccount("delegate"),
|
|
1183
|
+
mint: resolveAccount("mint"),
|
|
1184
|
+
multisigOwner: resolveAccount("multisigOwner"),
|
|
1185
|
+
owner: resolveAccount("owner"),
|
|
1186
|
+
source: resolveAccount("source")
|
|
1187
|
+
},
|
|
1188
|
+
SplTokenApproveInstruction: {
|
|
1189
|
+
delegate: resolveAccount("delegate"),
|
|
1190
|
+
multisigOwner: resolveAccount("multisigOwner"),
|
|
1191
|
+
owner: resolveAccount("owner"),
|
|
1192
|
+
source: resolveAccount("source")
|
|
1193
|
+
},
|
|
1194
|
+
SplTokenBurnCheckedInstruction: {
|
|
1195
|
+
account: resolveAccount("account"),
|
|
1196
|
+
authority: resolveAccount("authority"),
|
|
1197
|
+
mint: resolveAccount("mint"),
|
|
1198
|
+
multisigAuthority: resolveAccount("multisigAuthority")
|
|
1199
|
+
},
|
|
1200
|
+
SplTokenBurnInstruction: {
|
|
1201
|
+
account: resolveAccount("account"),
|
|
1202
|
+
authority: resolveAccount("authority"),
|
|
1203
|
+
mint: resolveAccount("mint"),
|
|
1204
|
+
multisigAuthority: resolveAccount("multisigAuthority")
|
|
1205
|
+
},
|
|
1206
|
+
SplTokenCloseAccountInstruction: {
|
|
1207
|
+
account: resolveAccount("account"),
|
|
1208
|
+
destination: resolveAccount("destination"),
|
|
1209
|
+
multisigOwner: resolveAccount("multisigOwner"),
|
|
1210
|
+
owner: resolveAccount("owner")
|
|
1211
|
+
},
|
|
1212
|
+
SplTokenFreezeAccountInstruction: {
|
|
1213
|
+
account: resolveAccount("account"),
|
|
1214
|
+
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
1215
|
+
mint: resolveAccount("mint"),
|
|
1216
|
+
multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
|
|
1217
|
+
},
|
|
1218
|
+
SplTokenGetAccountDataSizeInstruction: {
|
|
1219
|
+
mint: resolveAccount("mint")
|
|
1220
|
+
},
|
|
1221
|
+
SplTokenInitializeAccount2Instruction: {
|
|
1222
|
+
account: resolveAccount("account"),
|
|
1223
|
+
mint: resolveAccount("mint"),
|
|
1224
|
+
owner: resolveAccount("owner"),
|
|
1225
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1226
|
+
},
|
|
1227
|
+
SplTokenInitializeAccount3Instruction: {
|
|
1228
|
+
account: resolveAccount("account"),
|
|
1229
|
+
mint: resolveAccount("mint"),
|
|
1230
|
+
owner: resolveAccount("owner")
|
|
1231
|
+
},
|
|
1232
|
+
SplTokenInitializeAccountInstruction: {
|
|
1233
|
+
account: resolveAccount("account"),
|
|
1234
|
+
mint: resolveAccount("mint"),
|
|
1235
|
+
owner: resolveAccount("owner"),
|
|
1236
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1237
|
+
},
|
|
1238
|
+
SplTokenInitializeMint2Instruction: {
|
|
1239
|
+
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
1240
|
+
mint: resolveAccount("mint"),
|
|
1241
|
+
mintAuthority: resolveAccount("mintAuthority")
|
|
1242
|
+
},
|
|
1243
|
+
SplTokenInitializeMintCloseAuthorityInstruction: {
|
|
1244
|
+
mint: resolveAccount("mint"),
|
|
1245
|
+
newAuthority: resolveAccount("newAuthority")
|
|
1246
|
+
},
|
|
1247
|
+
SplTokenInitializeMintInstruction: {
|
|
1248
|
+
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
1249
|
+
mint: resolveAccount("mint"),
|
|
1250
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1251
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1252
|
+
},
|
|
1253
|
+
SplTokenInitializeMultisig2Instruction: {
|
|
1254
|
+
multisig: resolveAccount("multisig")
|
|
1255
|
+
},
|
|
1256
|
+
SplTokenInitializeMultisigInstruction: {
|
|
1257
|
+
multisig: resolveAccount("multisig"),
|
|
1258
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1259
|
+
},
|
|
1260
|
+
SplTokenMintToCheckedInstruction: {
|
|
1261
|
+
account: resolveAccount("account"),
|
|
1262
|
+
authority: resolveAccount("authority"),
|
|
1263
|
+
mint: resolveAccount("mint"),
|
|
1264
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1265
|
+
multisigMintAuthority: resolveAccount("multisigMintAuthority")
|
|
1266
|
+
},
|
|
1267
|
+
SplTokenMintToInstruction: {
|
|
1268
|
+
account: resolveAccount("account"),
|
|
1269
|
+
authority: resolveAccount("authority"),
|
|
1270
|
+
mint: resolveAccount("mint"),
|
|
1271
|
+
mintAuthority: resolveAccount("mintAuthority"),
|
|
1272
|
+
multisigMintAuthority: resolveAccount("multisigMintAuthority")
|
|
1273
|
+
},
|
|
1274
|
+
SplTokenRevokeInstruction: {
|
|
1275
|
+
multisigOwner: resolveAccount("multisigOwner"),
|
|
1276
|
+
owner: resolveAccount("owner"),
|
|
1277
|
+
source: resolveAccount("source")
|
|
1278
|
+
},
|
|
1279
|
+
SplTokenSetAuthorityInstruction: {
|
|
1280
|
+
authority: resolveAccount("authority"),
|
|
1281
|
+
multisigAuthority: resolveAccount("multisigAuthority"),
|
|
1282
|
+
newAuthority: resolveAccount("newAuthority")
|
|
1283
|
+
},
|
|
1284
|
+
SplTokenSyncNativeInstruction: {
|
|
1285
|
+
account: resolveAccount("account")
|
|
1286
|
+
},
|
|
1287
|
+
SplTokenThawAccountInstruction: {
|
|
1288
|
+
account: resolveAccount("account"),
|
|
1289
|
+
freezeAuthority: resolveAccount("freezeAuthority"),
|
|
1290
|
+
mint: resolveAccount("mint"),
|
|
1291
|
+
multisigFreezeAuthority: resolveAccount("multisigFreezeAuthority")
|
|
1292
|
+
},
|
|
1293
|
+
SplTokenTransferCheckedInstruction: {
|
|
1294
|
+
authority: resolveAccount("authority"),
|
|
1295
|
+
destination: resolveAccount("destination"),
|
|
1296
|
+
mint: resolveAccount("mint"),
|
|
1297
|
+
multisigAuthority: resolveAccount("multisigAuthority"),
|
|
1298
|
+
source: resolveAccount("source")
|
|
1299
|
+
},
|
|
1300
|
+
SplTokenTransferInstruction: {
|
|
1301
|
+
authority: resolveAccount("authority"),
|
|
1302
|
+
destination: resolveAccount("destination"),
|
|
1303
|
+
multisigAuthority: resolveAccount("multisigAuthority"),
|
|
1304
|
+
source: resolveAccount("source")
|
|
1305
|
+
},
|
|
1306
|
+
SplTokenUiAmountToAmountInstruction: {
|
|
1307
|
+
mint: resolveAccount("mint")
|
|
1308
|
+
},
|
|
1309
|
+
StakeAuthorizeCheckedInstruction: {
|
|
1310
|
+
authority: resolveAccount("authority"),
|
|
1311
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1312
|
+
custodian: resolveAccount("custodian"),
|
|
1313
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1314
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1315
|
+
},
|
|
1316
|
+
StakeAuthorizeCheckedWithSeedInstruction: {
|
|
1317
|
+
authorityBase: resolveAccount("authorityBase"),
|
|
1318
|
+
authorityOwner: resolveAccount("authorityOwner"),
|
|
1319
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1320
|
+
custodian: resolveAccount("custodian"),
|
|
1321
|
+
newAuthorized: resolveAccount("newAuthorized"),
|
|
1322
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1323
|
+
},
|
|
1324
|
+
StakeAuthorizeInstruction: {
|
|
1325
|
+
authority: resolveAccount("authority"),
|
|
1326
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1327
|
+
custodian: resolveAccount("custodian"),
|
|
1328
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1329
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1330
|
+
},
|
|
1331
|
+
StakeAuthorizeWithSeedInstruction: {
|
|
1332
|
+
authorityBase: resolveAccount("authorityBase"),
|
|
1333
|
+
authorityOwner: resolveAccount("authorityOwner"),
|
|
1334
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1335
|
+
custodian: resolveAccount("custodian"),
|
|
1336
|
+
newAuthorized: resolveAccount("newAuthorized"),
|
|
1337
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1338
|
+
},
|
|
1339
|
+
StakeDeactivateDelinquentInstruction: {
|
|
1340
|
+
referenceVoteAccount: resolveAccount("referenceVoteAccount"),
|
|
1341
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1342
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1343
|
+
},
|
|
1344
|
+
StakeDeactivateInstruction: {
|
|
1345
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1346
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1347
|
+
stakeAuthority: resolveAccount("stakeAuthority")
|
|
1348
|
+
},
|
|
1349
|
+
StakeDelegateStakeInstruction: {
|
|
1350
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1351
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1352
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1353
|
+
stakeConfigAccount: resolveAccount("stakeConfigAccount"),
|
|
1354
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar"),
|
|
1355
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1356
|
+
},
|
|
1357
|
+
StakeInitializeCheckedInstruction: {
|
|
1358
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1359
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1360
|
+
},
|
|
1361
|
+
StakeInitializeCheckedInstructionDataAuthorized: {
|
|
1362
|
+
staker: resolveAccount("staker"),
|
|
1363
|
+
withdrawer: resolveAccount("withdrawer")
|
|
1364
|
+
},
|
|
1365
|
+
StakeInitializeInstruction: {
|
|
1366
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1367
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1368
|
+
},
|
|
1369
|
+
StakeInitializeInstructionDataAuthorized: {
|
|
1370
|
+
staker: resolveAccount("staker"),
|
|
1371
|
+
withdrawer: resolveAccount("withdrawer")
|
|
1372
|
+
},
|
|
1373
|
+
StakeMergeInstruction: {
|
|
1374
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1375
|
+
destination: resolveAccount("destination"),
|
|
1376
|
+
source: resolveAccount("source"),
|
|
1377
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1378
|
+
stakeHistorySysvar: resolveAccount("stakeHistorySysvar")
|
|
1379
|
+
},
|
|
1380
|
+
StakeRedelegateInstruction: {
|
|
1381
|
+
newStakeAccount: resolveAccount("newStakeAccount"),
|
|
1382
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1383
|
+
stakeAuthority: resolveAccount("stakeAuthority"),
|
|
1384
|
+
stakeConfigAccount: resolveAccount("stakeConfigAccount"),
|
|
1385
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1386
|
+
},
|
|
1387
|
+
StakeSetLockupCheckedInstruction: {
|
|
1388
|
+
custodian: resolveAccount("custodian"),
|
|
1389
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1390
|
+
},
|
|
1391
|
+
StakeSetLockupInstruction: {
|
|
1392
|
+
custodian: resolveAccount("custodian"),
|
|
1393
|
+
stakeAccount: resolveAccount("stakeAccount")
|
|
1394
|
+
},
|
|
1395
|
+
StakeSplitInstruction: {
|
|
1396
|
+
newSplitAccount: resolveAccount("newSplitAccount"),
|
|
1397
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1398
|
+
stakeAuthority: resolveAccount("stakeAuthority")
|
|
1399
|
+
},
|
|
1400
|
+
StakeWithdrawInstruction: {
|
|
1401
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1402
|
+
destination: resolveAccount("destination"),
|
|
1403
|
+
stakeAccount: resolveAccount("stakeAccount"),
|
|
1404
|
+
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
1405
|
+
},
|
|
1406
|
+
TransactionInstruction: {
|
|
1407
|
+
__resolveType(instructionResult) {
|
|
1408
|
+
const { jsonParsedConfigs } = instructionResult;
|
|
1409
|
+
if (jsonParsedConfigs) {
|
|
1410
|
+
if (jsonParsedConfigs.programName === "address-lookup-table") {
|
|
1411
|
+
if (jsonParsedConfigs.instructionType === "createLookupTable") {
|
|
1412
|
+
return "CreateLookupTableInstruction";
|
|
1413
|
+
}
|
|
1414
|
+
if (jsonParsedConfigs.instructionType === "freezeLookupTable") {
|
|
1415
|
+
return "FreezeLookupTableInstruction";
|
|
1416
|
+
}
|
|
1417
|
+
if (jsonParsedConfigs.instructionType === "extendLookupTable") {
|
|
1418
|
+
return "ExtendLookupTableInstruction";
|
|
1419
|
+
}
|
|
1420
|
+
if (jsonParsedConfigs.instructionType === "deactivateLookupTable") {
|
|
1421
|
+
return "DeactivateLookupTableInstruction";
|
|
1422
|
+
}
|
|
1423
|
+
if (jsonParsedConfigs.instructionType === "closeLookupTable") {
|
|
1424
|
+
return "CloseLookupTableInstruction";
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
if (jsonParsedConfigs.programName === "bpf-loader") {
|
|
1428
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
1429
|
+
return "BpfLoaderWriteInstruction";
|
|
1430
|
+
}
|
|
1431
|
+
if (jsonParsedConfigs.instructionType === "finalize") {
|
|
1432
|
+
return "BpfLoaderFinalizeInstruction";
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
if (jsonParsedConfigs.programName === "bpf-upgradeable-loader") {
|
|
1436
|
+
if (jsonParsedConfigs.instructionType === "initializeBuffer") {
|
|
1437
|
+
return "BpfUpgradeableLoaderInitializeBufferInstruction";
|
|
1438
|
+
}
|
|
1439
|
+
if (jsonParsedConfigs.instructionType === "write") {
|
|
1440
|
+
return "BpfUpgradeableLoaderWriteInstruction";
|
|
1441
|
+
}
|
|
1442
|
+
if (jsonParsedConfigs.instructionType === "deployWithMaxDataLen") {
|
|
1443
|
+
return "BpfUpgradeableLoaderDeployWithMaxDataLenInstruction";
|
|
1444
|
+
}
|
|
1445
|
+
if (jsonParsedConfigs.instructionType === "upgrade") {
|
|
1446
|
+
return "BpfUpgradeableLoaderUpgradeInstruction";
|
|
1447
|
+
}
|
|
1448
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
1449
|
+
return "BpfUpgradeableLoaderSetAuthorityInstruction";
|
|
1450
|
+
}
|
|
1451
|
+
if (jsonParsedConfigs.instructionType === "setAuthorityChecked") {
|
|
1452
|
+
return "BpfUpgradeableLoaderSetAuthorityCheckedInstruction";
|
|
1453
|
+
}
|
|
1454
|
+
if (jsonParsedConfigs.instructionType === "close") {
|
|
1455
|
+
return "BpfUpgradeableLoaderCloseInstruction";
|
|
1456
|
+
}
|
|
1457
|
+
if (jsonParsedConfigs.instructionType === "extendProgram") {
|
|
1458
|
+
return "BpfUpgradeableLoaderExtendProgramInstruction";
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
if (jsonParsedConfigs.programName === "spl-associated-token-account") {
|
|
1462
|
+
if (jsonParsedConfigs.instructionType === "create") {
|
|
1463
|
+
return "SplAssociatedTokenCreateInstruction";
|
|
1464
|
+
}
|
|
1465
|
+
if (jsonParsedConfigs.instructionType === "createIdempotent") {
|
|
1466
|
+
return "SplAssociatedTokenCreateIdempotentInstruction";
|
|
1467
|
+
}
|
|
1468
|
+
if (jsonParsedConfigs.instructionType === "recoverNested") {
|
|
1469
|
+
return "SplAssociatedTokenRecoverNestedInstruction";
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
if (jsonParsedConfigs.programName === "spl-memo") {
|
|
1473
|
+
return "SplMemoInstruction";
|
|
1474
|
+
}
|
|
1475
|
+
if (jsonParsedConfigs.programName === "spl-token") {
|
|
1476
|
+
if (jsonParsedConfigs.instructionType === "initializeMint") {
|
|
1477
|
+
return "SplTokenInitializeMintInstruction";
|
|
1478
|
+
}
|
|
1479
|
+
if (jsonParsedConfigs.instructionType === "initializeMint2") {
|
|
1480
|
+
return "SplTokenInitializeMint2Instruction";
|
|
1481
|
+
}
|
|
1482
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount") {
|
|
1483
|
+
return "SplTokenInitializeAccountInstruction";
|
|
1484
|
+
}
|
|
1485
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount2") {
|
|
1486
|
+
return "SplTokenInitializeAccount2Instruction";
|
|
1487
|
+
}
|
|
1488
|
+
if (jsonParsedConfigs.instructionType === "initializeAccount3") {
|
|
1489
|
+
return "SplTokenInitializeAccount3Instruction";
|
|
1490
|
+
}
|
|
1491
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig") {
|
|
1492
|
+
return "SplTokenInitializeMultisigInstruction";
|
|
1493
|
+
}
|
|
1494
|
+
if (jsonParsedConfigs.instructionType === "initializeMultisig2") {
|
|
1495
|
+
return "SplTokenInitializeMultisig2Instruction";
|
|
1496
|
+
}
|
|
1497
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
1498
|
+
return "SplTokenTransferInstruction";
|
|
1499
|
+
}
|
|
1500
|
+
if (jsonParsedConfigs.instructionType === "approve") {
|
|
1501
|
+
return "SplTokenApproveInstruction";
|
|
1502
|
+
}
|
|
1503
|
+
if (jsonParsedConfigs.instructionType === "revoke") {
|
|
1504
|
+
return "SplTokenRevokeInstruction";
|
|
1505
|
+
}
|
|
1506
|
+
if (jsonParsedConfigs.instructionType === "setAuthority") {
|
|
1507
|
+
return "SplTokenSetAuthorityInstruction";
|
|
1508
|
+
}
|
|
1509
|
+
if (jsonParsedConfigs.instructionType === "mintTo") {
|
|
1510
|
+
return "SplTokenMintToInstruction";
|
|
1511
|
+
}
|
|
1512
|
+
if (jsonParsedConfigs.instructionType === "burn") {
|
|
1513
|
+
return "SplTokenBurnInstruction";
|
|
1514
|
+
}
|
|
1515
|
+
if (jsonParsedConfigs.instructionType === "closeAccount") {
|
|
1516
|
+
return "SplTokenCloseAccountInstruction";
|
|
1517
|
+
}
|
|
1518
|
+
if (jsonParsedConfigs.instructionType === "freezeAccount") {
|
|
1519
|
+
return "SplTokenFreezeAccountInstruction";
|
|
1520
|
+
}
|
|
1521
|
+
if (jsonParsedConfigs.instructionType === "thawAccount") {
|
|
1522
|
+
return "SplTokenThawAccountInstruction";
|
|
1523
|
+
}
|
|
1524
|
+
if (jsonParsedConfigs.instructionType === "transferChecked") {
|
|
1525
|
+
return "SplTokenTransferCheckedInstruction";
|
|
1526
|
+
}
|
|
1527
|
+
if (jsonParsedConfigs.instructionType === "approveChecked") {
|
|
1528
|
+
return "SplTokenApproveCheckedInstruction";
|
|
1529
|
+
}
|
|
1530
|
+
if (jsonParsedConfigs.instructionType === "mintToChecked") {
|
|
1531
|
+
return "SplTokenMintToCheckedInstruction";
|
|
1532
|
+
}
|
|
1533
|
+
if (jsonParsedConfigs.instructionType === "burnChecked") {
|
|
1534
|
+
return "SplTokenBurnCheckedInstruction";
|
|
1535
|
+
}
|
|
1536
|
+
if (jsonParsedConfigs.instructionType === "syncNative") {
|
|
1537
|
+
return "SplTokenSyncNativeInstruction";
|
|
1538
|
+
}
|
|
1539
|
+
if (jsonParsedConfigs.instructionType === "getAccountDataSize") {
|
|
1540
|
+
return "SplTokenGetAccountDataSizeInstruction";
|
|
1541
|
+
}
|
|
1542
|
+
if (jsonParsedConfigs.instructionType === "initializeImmutableOwner") {
|
|
1543
|
+
return "SplTokenInitializeImmutableOwnerInstruction";
|
|
1544
|
+
}
|
|
1545
|
+
if (jsonParsedConfigs.instructionType === "amountToUiAmount") {
|
|
1546
|
+
return "SplTokenAmountToUiAmountInstruction";
|
|
1547
|
+
}
|
|
1548
|
+
if (jsonParsedConfigs.instructionType === "uiAmountToAmount") {
|
|
1549
|
+
return "SplTokenUiAmountToAmountInstruction";
|
|
1550
|
+
}
|
|
1551
|
+
if (jsonParsedConfigs.instructionType === "initializeMintCloseAuthority") {
|
|
1552
|
+
return "SplTokenInitializeMintCloseAuthorityInstruction";
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
if (jsonParsedConfigs.programName === "stake") {
|
|
1556
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
1557
|
+
return "StakeInitializeInstruction";
|
|
1558
|
+
}
|
|
1559
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
1560
|
+
return "StakeAuthorizeInstruction";
|
|
1561
|
+
}
|
|
1562
|
+
if (jsonParsedConfigs.instructionType === "delegate") {
|
|
1563
|
+
return "StakeDelegateStakeInstruction";
|
|
1564
|
+
}
|
|
1565
|
+
if (jsonParsedConfigs.instructionType === "split") {
|
|
1566
|
+
return "StakeSplitInstruction";
|
|
1567
|
+
}
|
|
1568
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
1569
|
+
return "StakeWithdrawInstruction";
|
|
1570
|
+
}
|
|
1571
|
+
if (jsonParsedConfigs.instructionType === "deactivate") {
|
|
1572
|
+
return "StakeDeactivateInstruction";
|
|
1573
|
+
}
|
|
1574
|
+
if (jsonParsedConfigs.instructionType === "setLockup") {
|
|
1575
|
+
return "StakeSetLockupInstruction";
|
|
1576
|
+
}
|
|
1577
|
+
if (jsonParsedConfigs.instructionType === "merge") {
|
|
1578
|
+
return "StakeMergeInstruction";
|
|
1579
|
+
}
|
|
1580
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1581
|
+
return "StakeAuthorizeWithSeedInstruction";
|
|
1582
|
+
}
|
|
1583
|
+
if (jsonParsedConfigs.instructionType === "initializeChecked") {
|
|
1584
|
+
return "StakeInitializeCheckedInstruction";
|
|
1585
|
+
}
|
|
1586
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1587
|
+
return "StakeAuthorizeCheckedInstruction";
|
|
1588
|
+
}
|
|
1589
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1590
|
+
return "StakeAuthorizeCheckedWithSeedInstruction";
|
|
1591
|
+
}
|
|
1592
|
+
if (jsonParsedConfigs.instructionType === "setLockupChecked") {
|
|
1593
|
+
return "StakeSetLockupCheckedInstruction";
|
|
1594
|
+
}
|
|
1595
|
+
if (jsonParsedConfigs.instructionType === "deactivateDelinquent") {
|
|
1596
|
+
return "StakeDeactivateDelinquentInstruction";
|
|
1597
|
+
}
|
|
1598
|
+
if (jsonParsedConfigs.instructionType === "redelegate") {
|
|
1599
|
+
return "StakeRedelegateInstruction";
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
if (jsonParsedConfigs.programName === "system") {
|
|
1603
|
+
if (jsonParsedConfigs.instructionType === "createAccount") {
|
|
1604
|
+
return "CreateAccountInstruction";
|
|
1605
|
+
}
|
|
1606
|
+
if (jsonParsedConfigs.instructionType === "assign") {
|
|
1607
|
+
return "AssignInstruction";
|
|
1608
|
+
}
|
|
1609
|
+
if (jsonParsedConfigs.instructionType === "transfer") {
|
|
1610
|
+
return "TransferInstruction";
|
|
1611
|
+
}
|
|
1612
|
+
if (jsonParsedConfigs.instructionType === "createAccountWithSeed") {
|
|
1613
|
+
return "CreateAccountWithSeedInstruction";
|
|
1614
|
+
}
|
|
1615
|
+
if (jsonParsedConfigs.instructionType === "advanceNonceAccount") {
|
|
1616
|
+
return "AdvanceNonceAccountInstruction";
|
|
1617
|
+
}
|
|
1618
|
+
if (jsonParsedConfigs.instructionType === "withdrawNonceAccount") {
|
|
1619
|
+
return "WithdrawNonceAccountInstruction";
|
|
1620
|
+
}
|
|
1621
|
+
if (jsonParsedConfigs.instructionType === "initializeNonceAccount") {
|
|
1622
|
+
return "InitializeNonceAccountInstruction";
|
|
1623
|
+
}
|
|
1624
|
+
if (jsonParsedConfigs.instructionType === "authorizeNonceAccount") {
|
|
1625
|
+
return "AuthorizeNonceAccountInstruction";
|
|
1626
|
+
}
|
|
1627
|
+
if (jsonParsedConfigs.instructionType === "upgradeNonceAccount") {
|
|
1628
|
+
return "UpgradeNonceAccountInstruction";
|
|
1629
|
+
}
|
|
1630
|
+
if (jsonParsedConfigs.instructionType === "allocate") {
|
|
1631
|
+
return "AllocateInstruction";
|
|
1632
|
+
}
|
|
1633
|
+
if (jsonParsedConfigs.instructionType === "allocateWithSeed") {
|
|
1634
|
+
return "AllocateWithSeedInstruction";
|
|
1635
|
+
}
|
|
1636
|
+
if (jsonParsedConfigs.instructionType === "assignWithSeed") {
|
|
1637
|
+
return "AssignWithSeedInstruction";
|
|
1638
|
+
}
|
|
1639
|
+
if (jsonParsedConfigs.instructionType === "transferWithSeed") {
|
|
1640
|
+
return "TransferWithSeedInstruction";
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
if (jsonParsedConfigs.programName === "vote") {
|
|
1644
|
+
if (jsonParsedConfigs.instructionType === "initialize") {
|
|
1645
|
+
return "VoteInitializeAccountInstruction";
|
|
1646
|
+
}
|
|
1647
|
+
if (jsonParsedConfigs.instructionType === "authorize") {
|
|
1648
|
+
return "VoteAuthorizeInstruction";
|
|
1649
|
+
}
|
|
1650
|
+
if (jsonParsedConfigs.instructionType === "authorizeWithSeed") {
|
|
1651
|
+
return "VoteAuthorizeWithSeedInstruction";
|
|
1652
|
+
}
|
|
1653
|
+
if (jsonParsedConfigs.instructionType === "authorizeCheckedWithSeed") {
|
|
1654
|
+
return "VoteAuthorizeCheckedWithSeedInstruction";
|
|
1655
|
+
}
|
|
1656
|
+
if (jsonParsedConfigs.instructionType === "vote") {
|
|
1657
|
+
return "VoteVoteInstruction";
|
|
1658
|
+
}
|
|
1659
|
+
if (jsonParsedConfigs.instructionType === "updatevotestate") {
|
|
1660
|
+
return "VoteUpdateVoteStateInstruction";
|
|
1661
|
+
}
|
|
1662
|
+
if (jsonParsedConfigs.instructionType === "updatevotestateswitch") {
|
|
1663
|
+
return "VoteUpdateVoteStateSwitchInstruction";
|
|
1664
|
+
}
|
|
1665
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestate") {
|
|
1666
|
+
return "VoteCompactUpdateVoteStateInstruction";
|
|
1667
|
+
}
|
|
1668
|
+
if (jsonParsedConfigs.instructionType === "compactupdatevotestateswitch") {
|
|
1669
|
+
return "VoteCompactUpdateVoteStateSwitchInstruction";
|
|
1670
|
+
}
|
|
1671
|
+
if (jsonParsedConfigs.instructionType === "withdraw") {
|
|
1672
|
+
return "VoteWithdrawInstruction";
|
|
1673
|
+
}
|
|
1674
|
+
if (jsonParsedConfigs.instructionType === "updateValidatorIdentity") {
|
|
1675
|
+
return "VoteUpdateValidatorIdentityInstruction";
|
|
1676
|
+
}
|
|
1677
|
+
if (jsonParsedConfigs.instructionType === "updateCommission") {
|
|
1678
|
+
return "VoteUpdateCommissionInstruction";
|
|
1679
|
+
}
|
|
1680
|
+
if (jsonParsedConfigs.instructionType === "voteSwitch") {
|
|
1681
|
+
return "VoteVoteSwitchInstruction";
|
|
1682
|
+
}
|
|
1683
|
+
if (jsonParsedConfigs.instructionType === "authorizeChecked") {
|
|
1684
|
+
return "VoteAuthorizeCheckedInstruction";
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
return "GenericInstruction";
|
|
1689
|
+
}
|
|
1690
|
+
},
|
|
1691
|
+
TransferInstruction: {
|
|
1692
|
+
destination: resolveAccount("destination"),
|
|
1693
|
+
source: resolveAccount("source")
|
|
1694
|
+
},
|
|
1695
|
+
TransferWithSeedInstruction: {
|
|
1696
|
+
destination: resolveAccount("destination"),
|
|
1697
|
+
source: resolveAccount("source"),
|
|
1698
|
+
sourceOwner: resolveAccount("sourceOwner")
|
|
1699
|
+
},
|
|
1700
|
+
UpgradeNonceAccountInstruction: {
|
|
1701
|
+
nonceAccount: resolveAccount("nonceAccount"),
|
|
1702
|
+
nonceAuthority: resolveAccount("nonceAuthority")
|
|
1703
|
+
},
|
|
1704
|
+
VoteAuthorizeCheckedInstruction: {
|
|
1705
|
+
authority: resolveAccount("authority"),
|
|
1706
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1707
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1708
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1709
|
+
},
|
|
1710
|
+
VoteAuthorizeCheckedWithSeedInstruction: {
|
|
1711
|
+
authorityOwner: resolveAccount("authorityOwner"),
|
|
1712
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1713
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1714
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1715
|
+
},
|
|
1716
|
+
VoteAuthorizeInstruction: {
|
|
1717
|
+
authority: resolveAccount("authority"),
|
|
1718
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1719
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1720
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1721
|
+
},
|
|
1722
|
+
VoteAuthorizeWithSeedInstruction: {
|
|
1723
|
+
authorityOwner: resolveAccount("authorityOwner"),
|
|
1724
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1725
|
+
newAuthority: resolveAccount("newAuthority"),
|
|
1726
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1727
|
+
},
|
|
1728
|
+
VoteCompactUpdateVoteStateInstruction: {
|
|
1729
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1730
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1731
|
+
},
|
|
1732
|
+
VoteCompactUpdateVoteStateSwitchInstruction: {
|
|
1733
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1734
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1735
|
+
},
|
|
1736
|
+
VoteInitializeAccountInstruction: {
|
|
1737
|
+
authorizedVoter: resolveAccount("authorizedVoter"),
|
|
1738
|
+
authorizedWithdrawer: resolveAccount("authorizedWithdrawer"),
|
|
1739
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1740
|
+
node: resolveAccount("node"),
|
|
1741
|
+
rentSysvar: resolveAccount("rentSysvar"),
|
|
1742
|
+
voteAccount: resolveAccount("voteAccount")
|
|
1743
|
+
},
|
|
1744
|
+
VoteUpdateCommissionInstruction: {
|
|
1745
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1746
|
+
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
1747
|
+
},
|
|
1748
|
+
VoteUpdateValidatorIdentityInstruction: {
|
|
1749
|
+
newValidatorIdentity: resolveAccount("newValidatorIdentity"),
|
|
1750
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1751
|
+
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
1752
|
+
},
|
|
1753
|
+
VoteUpdateVoteStateInstruction: {
|
|
1754
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1755
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1756
|
+
},
|
|
1757
|
+
VoteUpdateVoteStateSwitchInstruction: {
|
|
1758
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1759
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1760
|
+
},
|
|
1761
|
+
VoteVoteInstruction: {
|
|
1762
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1763
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1764
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1765
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1766
|
+
},
|
|
1767
|
+
VoteVoteSwitchInstruction: {
|
|
1768
|
+
clockSysvar: resolveAccount("clockSysvar"),
|
|
1769
|
+
slotHashesSysvar: resolveAccount("slotHashesSysvar"),
|
|
1770
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1771
|
+
voteAuthority: resolveAccount("voteAuthority")
|
|
1772
|
+
},
|
|
1773
|
+
VoteWithdrawInstruction: {
|
|
1774
|
+
voteAccount: resolveAccount("voteAccount"),
|
|
1775
|
+
withdrawAuthority: resolveAccount("withdrawAuthority")
|
|
1776
|
+
},
|
|
1777
|
+
WithdrawNonceAccountInstruction: {
|
|
1778
|
+
destination: resolveAccount("destination"),
|
|
1779
|
+
nonceAccount: resolveAccount("nonceAccount"),
|
|
1780
|
+
nonceAuthority: resolveAccount("nonceAuthority"),
|
|
1781
|
+
recentBlockhashesSysvar: resolveAccount("recentBlockhashesSysvar"),
|
|
1782
|
+
rentSysvar: resolveAccount("rentSysvar")
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
|
|
1786
|
+
// src/resolvers/program-accounts.ts
|
|
1787
|
+
function resolveProgramAccounts(fieldName) {
|
|
1788
|
+
return async (parent, args, context, info) => {
|
|
1789
|
+
const programAddress = fieldName ? parent[fieldName] : args.programAddress;
|
|
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;
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// src/resolvers/root.ts
|
|
1845
|
+
var rootResolvers = {
|
|
1846
|
+
Query: {
|
|
1847
|
+
account: resolveAccount(),
|
|
1848
|
+
block: resolveBlock(),
|
|
1849
|
+
programAccounts: resolveProgramAccounts(),
|
|
1850
|
+
transaction: resolveTransaction()
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
var stringScalarAlias = {
|
|
1854
|
+
__parseLiteral(ast) {
|
|
1855
|
+
if (ast.kind === graphql.Kind.STRING) {
|
|
1856
|
+
return ast.value.toString();
|
|
1857
|
+
}
|
|
1858
|
+
return null;
|
|
1859
|
+
},
|
|
1860
|
+
__parseValue(value) {
|
|
1861
|
+
return value;
|
|
1862
|
+
},
|
|
1863
|
+
__serialize(value) {
|
|
1864
|
+
return value;
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
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);
|
|
1871
|
+
}
|
|
1872
|
+
return null;
|
|
1873
|
+
},
|
|
1874
|
+
__parseValue(value) {
|
|
1875
|
+
return BigInt(value);
|
|
1876
|
+
},
|
|
1877
|
+
__serialize(value) {
|
|
1878
|
+
return BigInt(value);
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
var typeTypeResolvers = {
|
|
1882
|
+
AccountEncoding: {
|
|
1883
|
+
BASE_58: "base58",
|
|
1884
|
+
BASE_64: "base64",
|
|
1885
|
+
BASE_64_ZSTD: "base64+zstd"
|
|
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,
|
|
1903
|
+
TokenBalance: {
|
|
1904
|
+
mint: resolveAccount("mint"),
|
|
1905
|
+
owner: resolveAccount("owner")
|
|
1906
|
+
},
|
|
1907
|
+
TransactionEncoding: {
|
|
1908
|
+
BASE_58: "base58",
|
|
1909
|
+
BASE_64: "base64"
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1912
|
+
|
|
1913
|
+
// src/resolvers/index.ts
|
|
1914
|
+
function createSolanaGraphQLResolvers() {
|
|
1915
|
+
return {
|
|
1916
|
+
...accountResolvers,
|
|
1917
|
+
...blockResolvers,
|
|
1918
|
+
...instructionResolvers,
|
|
1919
|
+
...rootResolvers,
|
|
1920
|
+
...transactionResolvers,
|
|
1921
|
+
...typeTypeResolvers
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
// src/schema/account.ts
|
|
1926
|
+
var accountTypeDefs = (
|
|
1927
|
+
/* GraphQL */
|
|
1928
|
+
`
|
|
1929
|
+
"""
|
|
1930
|
+
Account interface
|
|
1931
|
+
"""
|
|
1932
|
+
interface Account {
|
|
1933
|
+
address: Address
|
|
1934
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1935
|
+
executable: Boolean
|
|
1936
|
+
lamports: BigInt
|
|
1937
|
+
ownerProgram: Account
|
|
1938
|
+
space: BigInt
|
|
1939
|
+
rentEpoch: BigInt
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
"""
|
|
1943
|
+
Generic base account type
|
|
1944
|
+
"""
|
|
1945
|
+
type GenericAccount implements Account {
|
|
1946
|
+
address: Address
|
|
1947
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1948
|
+
executable: Boolean
|
|
1949
|
+
lamports: BigInt
|
|
1950
|
+
ownerProgram: Account
|
|
1951
|
+
space: BigInt
|
|
1952
|
+
rentEpoch: BigInt
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
type NonceAccountFeeCalculator {
|
|
1956
|
+
lamportsPerSignature: String
|
|
1957
|
+
}
|
|
1958
|
+
"""
|
|
1959
|
+
A nonce account
|
|
1960
|
+
"""
|
|
1961
|
+
type NonceAccount implements Account {
|
|
1962
|
+
address: Address
|
|
1963
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1964
|
+
executable: Boolean
|
|
1965
|
+
lamports: BigInt
|
|
1966
|
+
ownerProgram: Account
|
|
1967
|
+
space: BigInt
|
|
1968
|
+
rentEpoch: BigInt
|
|
1969
|
+
authority: Account
|
|
1970
|
+
blockhash: String
|
|
1971
|
+
feeCalculator: NonceAccountFeeCalculator
|
|
1972
|
+
}
|
|
1973
|
+
|
|
1974
|
+
"""
|
|
1975
|
+
A lookup table account
|
|
1976
|
+
"""
|
|
1977
|
+
type LookupTableAccount implements Account {
|
|
1978
|
+
address: Address
|
|
1979
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1980
|
+
executable: Boolean
|
|
1981
|
+
lamports: BigInt
|
|
1982
|
+
ownerProgram: Account
|
|
1983
|
+
space: BigInt
|
|
1984
|
+
rentEpoch: BigInt
|
|
1985
|
+
addresses: [Address]
|
|
1986
|
+
authority: Account
|
|
1987
|
+
deactivationSlot: String
|
|
1988
|
+
lastExtendedSlot: String
|
|
1989
|
+
lastExtendedSlotStartIndex: Int
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
"""
|
|
1993
|
+
A mint account
|
|
1994
|
+
"""
|
|
1995
|
+
type MintAccount implements Account {
|
|
1996
|
+
address: Address
|
|
1997
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
1998
|
+
executable: Boolean
|
|
1999
|
+
lamports: BigInt
|
|
2000
|
+
ownerProgram: Account
|
|
2001
|
+
space: BigInt
|
|
2002
|
+
rentEpoch: BigInt
|
|
2003
|
+
decimals: Int
|
|
2004
|
+
freezeAuthority: Account
|
|
2005
|
+
isInitialized: Boolean
|
|
2006
|
+
mintAuthority: Account
|
|
2007
|
+
supply: String
|
|
2008
|
+
}
|
|
2009
|
+
|
|
2010
|
+
"""
|
|
2011
|
+
A token account
|
|
2012
|
+
"""
|
|
2013
|
+
type TokenAccount implements Account {
|
|
2014
|
+
address: Address
|
|
2015
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
2016
|
+
executable: Boolean
|
|
2017
|
+
lamports: BigInt
|
|
2018
|
+
ownerProgram: Account
|
|
2019
|
+
space: BigInt
|
|
2020
|
+
rentEpoch: BigInt
|
|
2021
|
+
isNative: Boolean
|
|
2022
|
+
mint: Account
|
|
2023
|
+
owner: Account
|
|
2024
|
+
state: String
|
|
2025
|
+
tokenAmount: TokenAmount
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
type StakeAccountDataMetaAuthorized {
|
|
2029
|
+
staker: Account
|
|
2030
|
+
withdrawer: Account
|
|
2031
|
+
}
|
|
2032
|
+
type StakeAccountDataMetaLockup {
|
|
2033
|
+
custodian: Account
|
|
2034
|
+
epoch: BigInt
|
|
2035
|
+
unixTimestamp: BigInt
|
|
2036
|
+
}
|
|
2037
|
+
type StakeAccountDataMeta {
|
|
2038
|
+
authorized: StakeAccountDataMetaAuthorized
|
|
2039
|
+
lockup: StakeAccountDataMetaLockup
|
|
2040
|
+
rentExemptReserve: String
|
|
2041
|
+
}
|
|
2042
|
+
type StakeAccountDataStakeDelegation {
|
|
2043
|
+
activationEpoch: BigInt
|
|
2044
|
+
deactivationEpoch: BigInt
|
|
2045
|
+
stake: String
|
|
2046
|
+
voter: Account
|
|
2047
|
+
warmupCooldownRate: Int
|
|
2048
|
+
}
|
|
2049
|
+
type StakeAccountDataStake {
|
|
2050
|
+
creditsObserved: BigInt
|
|
2051
|
+
delegation: StakeAccountDataStakeDelegation
|
|
2052
|
+
}
|
|
2053
|
+
"""
|
|
2054
|
+
A stake account
|
|
2055
|
+
"""
|
|
2056
|
+
type StakeAccount implements Account {
|
|
2057
|
+
address: Address
|
|
2058
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
2059
|
+
executable: Boolean
|
|
2060
|
+
lamports: BigInt
|
|
2061
|
+
ownerProgram: Account
|
|
2062
|
+
space: BigInt
|
|
2063
|
+
rentEpoch: BigInt
|
|
2064
|
+
meta: StakeAccountDataMeta
|
|
2065
|
+
stake: StakeAccountDataStake
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
type VoteAccountDataAuthorizedVoter {
|
|
2069
|
+
authorizedVoter: Account
|
|
2070
|
+
epoch: BigInt
|
|
2071
|
+
}
|
|
2072
|
+
type VoteAccountDataEpochCredit {
|
|
2073
|
+
credits: String
|
|
2074
|
+
epoch: BigInt
|
|
2075
|
+
previousCredits: String
|
|
2076
|
+
}
|
|
2077
|
+
type VoteAccountDataLastTimestamp {
|
|
2078
|
+
slot: BigInt
|
|
2079
|
+
timestamp: BigInt
|
|
2080
|
+
}
|
|
2081
|
+
type VoteAccountDataVote {
|
|
2082
|
+
confirmationCount: Int
|
|
2083
|
+
slot: BigInt
|
|
2084
|
+
}
|
|
2085
|
+
"""
|
|
2086
|
+
A vote account
|
|
2087
|
+
"""
|
|
2088
|
+
type VoteAccount implements Account {
|
|
2089
|
+
address: Address
|
|
2090
|
+
data(encoding: AccountEncoding!, dataSlice: DataSlice): String
|
|
2091
|
+
executable: Boolean
|
|
2092
|
+
lamports: BigInt
|
|
2093
|
+
ownerProgram: Account
|
|
2094
|
+
space: BigInt
|
|
2095
|
+
rentEpoch: BigInt
|
|
2096
|
+
authorizedVoters: [VoteAccountDataAuthorizedVoter]
|
|
2097
|
+
authorizedWithdrawer: Account
|
|
2098
|
+
commission: Int
|
|
2099
|
+
epochCredits: [VoteAccountDataEpochCredit]
|
|
2100
|
+
lastTimestamp: VoteAccountDataLastTimestamp
|
|
2101
|
+
node: Account
|
|
2102
|
+
priorVoters: [Address]
|
|
2103
|
+
rootSlot: BigInt
|
|
2104
|
+
votes: [VoteAccountDataVote]
|
|
2105
|
+
}
|
|
2106
|
+
`
|
|
2107
|
+
);
|
|
2108
|
+
|
|
2109
|
+
// src/schema/block.ts
|
|
2110
|
+
var blockTypeDefs = (
|
|
2111
|
+
/* GraphQL */
|
|
2112
|
+
`
|
|
2113
|
+
"""
|
|
2114
|
+
A Solana block
|
|
2115
|
+
"""
|
|
2116
|
+
type Block {
|
|
2117
|
+
blockhash: String
|
|
2118
|
+
blockHeight: BigInt
|
|
2119
|
+
blockTime: BigInt
|
|
2120
|
+
parentSlot: Slot
|
|
2121
|
+
previousBlockhash: String
|
|
2122
|
+
rewards: [Reward]
|
|
2123
|
+
signatures: [Signature]
|
|
2124
|
+
transactions: [Transaction]
|
|
2125
|
+
}
|
|
2126
|
+
`
|
|
2127
|
+
);
|
|
2128
|
+
|
|
2129
|
+
// src/schema/instruction.ts
|
|
2130
|
+
var instructionTypeDefs = (
|
|
2131
|
+
/* GraphQL */
|
|
2132
|
+
`
|
|
2133
|
+
"""
|
|
2134
|
+
Transaction instruction interface
|
|
2135
|
+
"""
|
|
2136
|
+
interface TransactionInstruction {
|
|
2137
|
+
programId: Address
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
"""
|
|
2141
|
+
Generic transaction instruction
|
|
2142
|
+
"""
|
|
2143
|
+
type GenericInstruction implements TransactionInstruction {
|
|
2144
|
+
accounts: [Address]
|
|
2145
|
+
data: Base64EncodedBytes
|
|
2146
|
+
programId: Address
|
|
2147
|
+
}
|
|
2148
|
+
|
|
2149
|
+
"""
|
|
2150
|
+
AddressLookupTable: CreateLookupTable instruction
|
|
2151
|
+
"""
|
|
2152
|
+
type CreateLookupTableInstruction implements TransactionInstruction {
|
|
2153
|
+
programId: Address
|
|
2154
|
+
bumpSeed: BigInt # FIXME:*
|
|
2155
|
+
lookupTableAccount: Account
|
|
2156
|
+
lookupTableAuthority: Account
|
|
2157
|
+
payerAccount: Account
|
|
2158
|
+
recentSlot: BigInt
|
|
2159
|
+
systemProgram: Account
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
"""
|
|
2163
|
+
AddressLookupTable: ExtendLookupTable instruction
|
|
2164
|
+
"""
|
|
2165
|
+
type ExtendLookupTableInstruction implements TransactionInstruction {
|
|
2166
|
+
programId: Address
|
|
2167
|
+
lookupTableAccount: Account
|
|
2168
|
+
lookupTableAuthority: Account
|
|
2169
|
+
newAddresses: [Address]
|
|
2170
|
+
payerAccount: Account
|
|
2171
|
+
systemProgram: Account
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
"""
|
|
2175
|
+
AddressLookupTable: FreezeLookupTable instruction
|
|
2176
|
+
"""
|
|
2177
|
+
type FreezeLookupTableInstruction implements TransactionInstruction {
|
|
2178
|
+
programId: Address
|
|
2179
|
+
lookupTableAccount: Account
|
|
2180
|
+
lookupTableAuthority: Account
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
"""
|
|
2184
|
+
AddressLookupTable: DeactivateLookupTable instruction
|
|
2185
|
+
"""
|
|
2186
|
+
type DeactivateLookupTableInstruction implements TransactionInstruction {
|
|
2187
|
+
programId: Address
|
|
2188
|
+
lookupTableAccount: Account
|
|
2189
|
+
lookupTableAuthority: Account
|
|
2190
|
+
}
|
|
2191
|
+
|
|
2192
|
+
"""
|
|
2193
|
+
AddressLookupTable: CloseLookupTable instruction
|
|
2194
|
+
"""
|
|
2195
|
+
type CloseLookupTableInstruction implements TransactionInstruction {
|
|
2196
|
+
programId: Address
|
|
2197
|
+
lookupTableAccount: Account
|
|
2198
|
+
lookupTableAuthority: Account
|
|
2199
|
+
recipient: Account
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
"""
|
|
2203
|
+
BpfLoader: Write instruction
|
|
2204
|
+
"""
|
|
2205
|
+
type BpfLoaderWriteInstruction implements TransactionInstruction {
|
|
2206
|
+
programId: Address
|
|
2207
|
+
account: Account
|
|
2208
|
+
bytes: Base64EncodedBytes
|
|
2209
|
+
offset: BigInt # FIXME:*
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
"""
|
|
2213
|
+
BpfLoader: Finalize instruction
|
|
2214
|
+
"""
|
|
2215
|
+
type BpfLoaderFinalizeInstruction implements TransactionInstruction {
|
|
2216
|
+
programId: Address
|
|
2217
|
+
account: Account
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
"""
|
|
2221
|
+
BpfUpgradeableLoader: InitializeBuffer instruction
|
|
2222
|
+
"""
|
|
2223
|
+
type BpfUpgradeableLoaderInitializeBufferInstruction implements TransactionInstruction {
|
|
2224
|
+
programId: Address
|
|
2225
|
+
account: Account
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
"""
|
|
2229
|
+
BpfUpgradeableLoader: Write instruction
|
|
2230
|
+
"""
|
|
2231
|
+
type BpfUpgradeableLoaderWriteInstruction implements TransactionInstruction {
|
|
2232
|
+
programId: Address
|
|
2233
|
+
account: Account
|
|
2234
|
+
authority: Account
|
|
2235
|
+
bytes: Base64EncodedBytes
|
|
2236
|
+
offset: BigInt # FIXME:*
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
"""
|
|
2240
|
+
BpfUpgradeableLoader: DeployWithMaxDataLen instruction
|
|
2241
|
+
"""
|
|
2242
|
+
type BpfUpgradeableLoaderDeployWithMaxDataLenInstruction implements TransactionInstruction {
|
|
2243
|
+
programId: Address
|
|
2244
|
+
authority: Account
|
|
2245
|
+
bufferAccount: Account
|
|
2246
|
+
clockSysvar: Account
|
|
2247
|
+
maxDataLen: BigInt
|
|
2248
|
+
payerAccount: Account
|
|
2249
|
+
programAccount: Account
|
|
2250
|
+
programDataAccount: Account
|
|
2251
|
+
rentSysvar: Account
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
"""
|
|
2255
|
+
BpfUpgradeableLoader: Upgrade instruction
|
|
2256
|
+
"""
|
|
2257
|
+
type BpfUpgradeableLoaderUpgradeInstruction implements TransactionInstruction {
|
|
2258
|
+
programId: Address
|
|
2259
|
+
authority: Account
|
|
2260
|
+
bufferAccount: Account
|
|
2261
|
+
clockSysvar: Account
|
|
2262
|
+
programAccount: Account
|
|
2263
|
+
programDataAccount: Account
|
|
2264
|
+
rentSysvar: Account
|
|
2265
|
+
spillAccount: Account
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
"""
|
|
2269
|
+
BpfUpgradeableLoader: SetAuthority instruction
|
|
2270
|
+
"""
|
|
2271
|
+
type BpfUpgradeableLoaderSetAuthorityInstruction implements TransactionInstruction {
|
|
2272
|
+
programId: Address
|
|
2273
|
+
account: Account
|
|
2274
|
+
authority: Account
|
|
2275
|
+
newAuthority: Account
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
"""
|
|
2279
|
+
BpfUpgradeableLoader: SetAuthorityChecked instruction
|
|
2280
|
+
"""
|
|
2281
|
+
type BpfUpgradeableLoaderSetAuthorityCheckedInstruction implements TransactionInstruction {
|
|
2282
|
+
programId: Address
|
|
2283
|
+
account: Account
|
|
2284
|
+
authority: Account
|
|
2285
|
+
newAuthority: Account
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
"""
|
|
2289
|
+
BpfUpgradeableLoader: Close instruction
|
|
2290
|
+
"""
|
|
2291
|
+
type BpfUpgradeableLoaderCloseInstruction implements TransactionInstruction {
|
|
2292
|
+
programId: Address
|
|
2293
|
+
account: Account
|
|
2294
|
+
authority: Account
|
|
2295
|
+
programAccount: Account
|
|
2296
|
+
recipient: Account
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
"""
|
|
2300
|
+
BpfUpgradeableLoader: ExtendProgram instruction
|
|
2301
|
+
"""
|
|
2302
|
+
type BpfUpgradeableLoaderExtendProgramInstruction implements TransactionInstruction {
|
|
2303
|
+
programId: Address
|
|
2304
|
+
additionalBytes: BigInt
|
|
2305
|
+
payerAccount: Account
|
|
2306
|
+
programAccount: Account
|
|
2307
|
+
programDataAccount: Account
|
|
2308
|
+
systemProgram: Account
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
"""
|
|
2312
|
+
SplAssociatedTokenAccount: Create instruction
|
|
2313
|
+
"""
|
|
2314
|
+
type SplAssociatedTokenCreateInstruction implements TransactionInstruction {
|
|
2315
|
+
programId: Address
|
|
2316
|
+
account: Account
|
|
2317
|
+
mint: Account
|
|
2318
|
+
source: Account
|
|
2319
|
+
systemProgram: Account
|
|
2320
|
+
tokenProgram: Account
|
|
2321
|
+
wallet: Account
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
"""
|
|
2325
|
+
SplAssociatedTokenAccount: CreateIdempotent instruction
|
|
2326
|
+
"""
|
|
2327
|
+
type SplAssociatedTokenCreateIdempotentInstruction implements TransactionInstruction {
|
|
2328
|
+
programId: Address
|
|
2329
|
+
account: Account
|
|
2330
|
+
mint: Account
|
|
2331
|
+
source: Account
|
|
2332
|
+
systemProgram: Account
|
|
2333
|
+
tokenProgram: Account
|
|
2334
|
+
wallet: Account
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
"""
|
|
2338
|
+
SplAssociatedTokenAccount: RecoverNested instruction
|
|
2339
|
+
"""
|
|
2340
|
+
type SplAssociatedTokenRecoverNestedInstruction implements TransactionInstruction {
|
|
2341
|
+
programId: Address
|
|
2342
|
+
destination: Account
|
|
2343
|
+
nestedMint: Account
|
|
2344
|
+
nestedOwner: Account
|
|
2345
|
+
nestedSource: Account
|
|
2346
|
+
ownerMint: Account
|
|
2347
|
+
tokenProgram: Account
|
|
2348
|
+
wallet: Account
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
"""
|
|
2352
|
+
SplMemo instruction
|
|
2353
|
+
"""
|
|
2354
|
+
type SplMemoInstruction implements TransactionInstruction {
|
|
2355
|
+
programId: Address
|
|
2356
|
+
memo: String
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
"""
|
|
2360
|
+
SplToken: InitializeMint instruction
|
|
2361
|
+
"""
|
|
2362
|
+
type SplTokenInitializeMintInstruction implements TransactionInstruction {
|
|
2363
|
+
programId: Address
|
|
2364
|
+
decimals: BigInt # FIXME:*
|
|
2365
|
+
freezeAuthority: Account
|
|
2366
|
+
mint: Account
|
|
2367
|
+
mintAuthority: Account
|
|
2368
|
+
rentSysvar: Account
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
"""
|
|
2372
|
+
SplToken: InitializeMint2 instruction
|
|
2373
|
+
"""
|
|
2374
|
+
type SplTokenInitializeMint2Instruction implements TransactionInstruction {
|
|
2375
|
+
programId: Address
|
|
2376
|
+
decimals: BigInt # FIXME:*
|
|
2377
|
+
freezeAuthority: Account
|
|
2378
|
+
mint: Account
|
|
2379
|
+
mintAuthority: Account
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
"""
|
|
2383
|
+
SplToken: InitializeAccount instruction
|
|
2384
|
+
"""
|
|
2385
|
+
type SplTokenInitializeAccountInstruction implements TransactionInstruction {
|
|
2386
|
+
programId: Address
|
|
2387
|
+
account: Account
|
|
2388
|
+
mint: Account
|
|
2389
|
+
owner: Account
|
|
2390
|
+
rentSysvar: Account
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
"""
|
|
2394
|
+
SplToken: InitializeAccount2 instruction
|
|
2395
|
+
"""
|
|
2396
|
+
type SplTokenInitializeAccount2Instruction implements TransactionInstruction {
|
|
2397
|
+
programId: Address
|
|
2398
|
+
account: Account
|
|
2399
|
+
mint: Account
|
|
2400
|
+
owner: Account
|
|
2401
|
+
rentSysvar: Account
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
"""
|
|
2405
|
+
SplToken: InitializeAccount3 instruction
|
|
2406
|
+
"""
|
|
2407
|
+
type SplTokenInitializeAccount3Instruction implements TransactionInstruction {
|
|
2408
|
+
programId: Address
|
|
2409
|
+
account: Account
|
|
2410
|
+
mint: Account
|
|
2411
|
+
owner: Account
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
"""
|
|
2415
|
+
SplToken: InitializeMultisig instruction
|
|
2416
|
+
"""
|
|
2417
|
+
type SplTokenInitializeMultisigInstruction implements TransactionInstruction {
|
|
2418
|
+
programId: Address
|
|
2419
|
+
m: BigInt # FIXME:*
|
|
2420
|
+
multisig: Account
|
|
2421
|
+
rentSysvar: Account
|
|
2422
|
+
signers: [Address]
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
"""
|
|
2426
|
+
SplToken: InitializeMultisig2 instruction
|
|
2427
|
+
"""
|
|
2428
|
+
type SplTokenInitializeMultisig2Instruction implements TransactionInstruction {
|
|
2429
|
+
programId: Address
|
|
2430
|
+
m: BigInt # FIXME:*
|
|
2431
|
+
multisig: Account
|
|
2432
|
+
signers: [Address]
|
|
2433
|
+
}
|
|
2434
|
+
|
|
2435
|
+
"""
|
|
2436
|
+
SplToken: Transfer instruction
|
|
2437
|
+
"""
|
|
2438
|
+
type SplTokenTransferInstruction implements TransactionInstruction {
|
|
2439
|
+
programId: Address
|
|
2440
|
+
amount: String
|
|
2441
|
+
authority: Account
|
|
2442
|
+
destination: Account
|
|
2443
|
+
multisigAuthority: Account
|
|
2444
|
+
source: Account
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
"""
|
|
2448
|
+
SplToken: Approve instruction
|
|
2449
|
+
"""
|
|
2450
|
+
type SplTokenApproveInstruction implements TransactionInstruction {
|
|
2451
|
+
programId: Address
|
|
2452
|
+
amount: String
|
|
2453
|
+
delegate: Account
|
|
2454
|
+
multisigOwner: Account
|
|
2455
|
+
owner: Account
|
|
2456
|
+
source: Account
|
|
2457
|
+
}
|
|
2458
|
+
|
|
2459
|
+
"""
|
|
2460
|
+
SplToken: Revoke instruction
|
|
2461
|
+
"""
|
|
2462
|
+
type SplTokenRevokeInstruction implements TransactionInstruction {
|
|
2463
|
+
programId: Address
|
|
2464
|
+
multisigOwner: Account
|
|
2465
|
+
owner: Account
|
|
2466
|
+
source: Account
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
"""
|
|
2470
|
+
SplToken: SetAuthority instruction
|
|
2471
|
+
"""
|
|
2472
|
+
type SplTokenSetAuthorityInstruction implements TransactionInstruction {
|
|
2473
|
+
programId: Address
|
|
2474
|
+
authority: Account
|
|
2475
|
+
authorityType: String
|
|
2476
|
+
multisigAuthority: Account
|
|
2477
|
+
newAuthority: Account
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
"""
|
|
2481
|
+
SplToken: MintTo instruction
|
|
2482
|
+
"""
|
|
2483
|
+
type SplTokenMintToInstruction implements TransactionInstruction {
|
|
2484
|
+
programId: Address
|
|
2485
|
+
account: Account
|
|
2486
|
+
amount: String
|
|
2487
|
+
authority: Account
|
|
2488
|
+
mint: Account
|
|
2489
|
+
mintAuthority: Account
|
|
2490
|
+
multisigMintAuthority: Account
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
"""
|
|
2494
|
+
SplToken: Burn instruction
|
|
2495
|
+
"""
|
|
2496
|
+
type SplTokenBurnInstruction implements TransactionInstruction {
|
|
2497
|
+
programId: Address
|
|
2498
|
+
account: Account
|
|
2499
|
+
amount: String
|
|
2500
|
+
authority: Account
|
|
2501
|
+
mint: Account
|
|
2502
|
+
multisigAuthority: Account
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
"""
|
|
2506
|
+
SplToken: CloseAccount instruction
|
|
2507
|
+
"""
|
|
2508
|
+
type SplTokenCloseAccountInstruction implements TransactionInstruction {
|
|
2509
|
+
programId: Address
|
|
2510
|
+
account: Account
|
|
2511
|
+
destination: Account
|
|
2512
|
+
multisigOwner: Account
|
|
2513
|
+
owner: Account
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
"""
|
|
2517
|
+
SplToken: FreezeAccount instruction
|
|
2518
|
+
"""
|
|
2519
|
+
type SplTokenFreezeAccountInstruction implements TransactionInstruction {
|
|
2520
|
+
programId: Address
|
|
2521
|
+
account: Account
|
|
2522
|
+
freezeAuthority: Account
|
|
2523
|
+
mint: Account
|
|
2524
|
+
multisigFreezeAuthority: Account
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
"""
|
|
2528
|
+
SplToken: ThawAccount instruction
|
|
2529
|
+
"""
|
|
2530
|
+
type SplTokenThawAccountInstruction implements TransactionInstruction {
|
|
2531
|
+
programId: Address
|
|
2532
|
+
account: Account
|
|
2533
|
+
freezeAuthority: Account
|
|
2534
|
+
mint: Account
|
|
2535
|
+
multisigFreezeAuthority: Account
|
|
2536
|
+
}
|
|
2537
|
+
|
|
2538
|
+
"""
|
|
2539
|
+
SplToken: TransferChecked instruction
|
|
2540
|
+
"""
|
|
2541
|
+
type SplTokenTransferCheckedInstruction implements TransactionInstruction {
|
|
2542
|
+
programId: Address
|
|
2543
|
+
amount: String
|
|
2544
|
+
authority: Account
|
|
2545
|
+
decimals: BigInt # FIXME:*
|
|
2546
|
+
destination: Account
|
|
2547
|
+
mint: Account
|
|
2548
|
+
multisigAuthority: Account
|
|
2549
|
+
source: Account
|
|
2550
|
+
tokenAmount: String
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
"""
|
|
2554
|
+
SplToken: ApproveChecked instruction
|
|
2555
|
+
"""
|
|
2556
|
+
type SplTokenApproveCheckedInstruction implements TransactionInstruction {
|
|
2557
|
+
programId: Address
|
|
2558
|
+
delegate: Account
|
|
2559
|
+
mint: Account
|
|
2560
|
+
multisigOwner: Account
|
|
2561
|
+
owner: Account
|
|
2562
|
+
source: Account
|
|
2563
|
+
tokenAmount: String
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
"""
|
|
2567
|
+
SplToken: MintToChecked instruction
|
|
2568
|
+
"""
|
|
2569
|
+
type SplTokenMintToCheckedInstruction implements TransactionInstruction {
|
|
2570
|
+
programId: Address
|
|
2571
|
+
account: Account
|
|
2572
|
+
authority: Account
|
|
2573
|
+
mint: Account
|
|
2574
|
+
mintAuthority: Account
|
|
2575
|
+
multisigMintAuthority: Account
|
|
2576
|
+
tokenAmount: String
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
"""
|
|
2580
|
+
SplToken: BurnChecked instruction
|
|
2581
|
+
"""
|
|
2582
|
+
type SplTokenBurnCheckedInstruction implements TransactionInstruction {
|
|
2583
|
+
programId: Address
|
|
2584
|
+
account: Account
|
|
2585
|
+
authority: Account
|
|
2586
|
+
mint: Account
|
|
2587
|
+
multisigAuthority: Account
|
|
2588
|
+
tokenAmount: String
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
"""
|
|
2592
|
+
SplToken: SyncNative instruction
|
|
2593
|
+
"""
|
|
2594
|
+
type SplTokenSyncNativeInstruction implements TransactionInstruction {
|
|
2595
|
+
programId: Address
|
|
2596
|
+
account: Account
|
|
2597
|
+
}
|
|
2598
|
+
|
|
2599
|
+
"""
|
|
2600
|
+
SplToken: GetAccountDataSize instruction
|
|
2601
|
+
"""
|
|
2602
|
+
type SplTokenGetAccountDataSizeInstruction implements TransactionInstruction {
|
|
2603
|
+
programId: Address
|
|
2604
|
+
extensionTypes: [String]
|
|
2605
|
+
mint: Account
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
"""
|
|
2609
|
+
SplToken: InitializeImmutableOwner instruction
|
|
2610
|
+
"""
|
|
2611
|
+
type SplTokenInitializeImmutableOwnerInstruction implements TransactionInstruction {
|
|
2612
|
+
programId: Address
|
|
2613
|
+
account: Account
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
"""
|
|
2617
|
+
SplToken: AmountToUiAmount instruction
|
|
2618
|
+
"""
|
|
2619
|
+
type SplTokenAmountToUiAmountInstruction implements TransactionInstruction {
|
|
2620
|
+
programId: Address
|
|
2621
|
+
amount: String
|
|
2622
|
+
mint: Account
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2625
|
+
"""
|
|
2626
|
+
SplToken: UiAmountToAmount instruction
|
|
2627
|
+
"""
|
|
2628
|
+
type SplTokenUiAmountToAmountInstruction implements TransactionInstruction {
|
|
2629
|
+
programId: Address
|
|
2630
|
+
mint: Account
|
|
2631
|
+
uiAmount: String
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
"""
|
|
2635
|
+
SplToken: InitializeMintCloseAuthority instruction
|
|
2636
|
+
"""
|
|
2637
|
+
type SplTokenInitializeMintCloseAuthorityInstruction implements TransactionInstruction {
|
|
2638
|
+
programId: Address
|
|
2639
|
+
mint: Account
|
|
2640
|
+
newAuthority: Account
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
# TODO: Extensions!
|
|
2644
|
+
# - TransferFeeExtension
|
|
2645
|
+
# - ConfidentialTransferFeeExtension
|
|
2646
|
+
# - DefaultAccountStateExtension
|
|
2647
|
+
# - Reallocate
|
|
2648
|
+
# - MemoTransferExtension
|
|
2649
|
+
# - CreateNativeMint
|
|
2650
|
+
# - InitializeNonTransferableMint
|
|
2651
|
+
# - InterestBearingMintExtension
|
|
2652
|
+
# - CpiGuardExtension
|
|
2653
|
+
# - InitializePermanentDelegate
|
|
2654
|
+
# - TransferHookExtension
|
|
2655
|
+
# - ConfidentialTransferFeeExtension
|
|
2656
|
+
# - WithdrawExcessLamports
|
|
2657
|
+
# - MetadataPointerExtension
|
|
2658
|
+
|
|
2659
|
+
type Lockup {
|
|
2660
|
+
custodian: Account
|
|
2661
|
+
epoch: BigInt
|
|
2662
|
+
unixTimestamp: BigInt
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
"""
|
|
2666
|
+
Stake: Initialize instruction
|
|
2667
|
+
"""
|
|
2668
|
+
type StakeInitializeInstructionDataAuthorized {
|
|
2669
|
+
staker: Account
|
|
2670
|
+
withdrawer: Account
|
|
2671
|
+
}
|
|
2672
|
+
type StakeInitializeInstruction implements TransactionInstruction {
|
|
2673
|
+
programId: Address
|
|
2674
|
+
authorized: StakeInitializeInstructionDataAuthorized
|
|
2675
|
+
lockup: Lockup
|
|
2676
|
+
rentSysvar: Account
|
|
2677
|
+
stakeAccount: Account
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
"""
|
|
2681
|
+
Stake: Authorize instruction
|
|
2682
|
+
"""
|
|
2683
|
+
type StakeAuthorizeInstruction implements TransactionInstruction {
|
|
2684
|
+
programId: Address
|
|
2685
|
+
authority: Account
|
|
2686
|
+
authorityType: String
|
|
2687
|
+
clockSysvar: Account
|
|
2688
|
+
custodian: Account
|
|
2689
|
+
newAuthority: Account
|
|
2690
|
+
stakeAccount: Account
|
|
2691
|
+
}
|
|
2692
|
+
|
|
2693
|
+
"""
|
|
2694
|
+
Stake: DelegateStake instruction
|
|
2695
|
+
"""
|
|
2696
|
+
type StakeDelegateStakeInstruction implements TransactionInstruction {
|
|
2697
|
+
programId: Address
|
|
2698
|
+
clockSysvar: Account
|
|
2699
|
+
stakeAccount: Account
|
|
2700
|
+
stakeAuthority: Account
|
|
2701
|
+
stakeConfigAccount: Account
|
|
2702
|
+
stakeHistorySysvar: Account
|
|
2703
|
+
voteAccount: Account
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
"""
|
|
2707
|
+
Stake: Split instruction
|
|
2708
|
+
"""
|
|
2709
|
+
type StakeSplitInstruction implements TransactionInstruction {
|
|
2710
|
+
programId: Address
|
|
2711
|
+
lamports: BigInt
|
|
2712
|
+
newSplitAccount: Account
|
|
2713
|
+
stakeAccount: Account
|
|
2714
|
+
stakeAuthority: Account
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
"""
|
|
2718
|
+
Stake: Withdraw instruction
|
|
2719
|
+
"""
|
|
2720
|
+
type StakeWithdrawInstruction implements TransactionInstruction {
|
|
2721
|
+
programId: Address
|
|
2722
|
+
clockSysvar: Account
|
|
2723
|
+
destination: Account
|
|
2724
|
+
lamports: BigInt
|
|
2725
|
+
stakeAccount: Account
|
|
2726
|
+
withdrawAuthority: Account
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
"""
|
|
2730
|
+
Stake: Deactivate instruction
|
|
2731
|
+
"""
|
|
2732
|
+
type StakeDeactivateInstruction implements TransactionInstruction {
|
|
2733
|
+
programId: Address
|
|
2734
|
+
clockSysvar: Account
|
|
2735
|
+
stakeAccount: Account
|
|
2736
|
+
stakeAuthority: Account
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
"""
|
|
2740
|
+
Stake: SetLockup instruction
|
|
2741
|
+
"""
|
|
2742
|
+
type StakeSetLockupInstruction implements TransactionInstruction {
|
|
2743
|
+
programId: Address
|
|
2744
|
+
custodian: Account
|
|
2745
|
+
lockup: Lockup
|
|
2746
|
+
stakeAccount: Account
|
|
2747
|
+
}
|
|
2748
|
+
|
|
2749
|
+
"""
|
|
2750
|
+
Stake: Merge instruction
|
|
2751
|
+
"""
|
|
2752
|
+
type StakeMergeInstruction implements TransactionInstruction {
|
|
2753
|
+
programId: Address
|
|
2754
|
+
clockSysvar: Account
|
|
2755
|
+
destination: Account
|
|
2756
|
+
source: Account
|
|
2757
|
+
stakeAuthority: Account
|
|
2758
|
+
stakeHistorySysvar: Account
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
"""
|
|
2762
|
+
Stake: AuthorizeWithSeed instruction
|
|
2763
|
+
"""
|
|
2764
|
+
type StakeAuthorizeWithSeedInstruction implements TransactionInstruction {
|
|
2765
|
+
programId: Address
|
|
2766
|
+
authorityBase: Account
|
|
2767
|
+
authorityOwner: Account
|
|
2768
|
+
authoritySeed: String
|
|
2769
|
+
authorityType: String
|
|
2770
|
+
clockSysvar: Account
|
|
2771
|
+
custodian: Account
|
|
2772
|
+
newAuthorized: Account
|
|
2773
|
+
stakeAccount: Account
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
"""
|
|
2777
|
+
Stake: InitializeChecked instruction
|
|
2778
|
+
"""
|
|
2779
|
+
type StakeInitializeCheckedInstructionDataAuthorized {
|
|
2780
|
+
staker: Account
|
|
2781
|
+
withdrawer: Account
|
|
2782
|
+
}
|
|
2783
|
+
type StakeInitializeCheckedInstruction implements TransactionInstruction {
|
|
2784
|
+
programId: Address
|
|
2785
|
+
authorized: StakeInitializeCheckedInstructionDataAuthorized
|
|
2786
|
+
lockup: Lockup
|
|
2787
|
+
rentSysvar: Account
|
|
2788
|
+
stakeAccount: Account
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
"""
|
|
2792
|
+
Stake: AuthorizeChecked instruction
|
|
2793
|
+
"""
|
|
2794
|
+
type StakeAuthorizeCheckedInstruction implements TransactionInstruction {
|
|
2795
|
+
programId: Address
|
|
2796
|
+
authority: Account
|
|
2797
|
+
authorityType: String
|
|
2798
|
+
clockSysvar: Account
|
|
2799
|
+
custodian: Account
|
|
2800
|
+
newAuthority: Account
|
|
2801
|
+
stakeAccount: Account
|
|
2802
|
+
}
|
|
2803
|
+
|
|
2804
|
+
"""
|
|
2805
|
+
Stake: AuthorizeCheckedWithSeed instruction
|
|
2806
|
+
"""
|
|
2807
|
+
type StakeAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
|
|
2808
|
+
programId: Address
|
|
2809
|
+
authorityBase: Account
|
|
2810
|
+
authorityOwner: Account
|
|
2811
|
+
authoritySeed: String
|
|
2812
|
+
authorityType: String
|
|
2813
|
+
clockSysvar: Account
|
|
2814
|
+
custodian: Account
|
|
2815
|
+
newAuthorized: Account
|
|
2816
|
+
stakeAccount: Account
|
|
2817
|
+
}
|
|
2818
|
+
|
|
2819
|
+
"""
|
|
2820
|
+
Stake: SetLockupChecked instruction
|
|
2821
|
+
"""
|
|
2822
|
+
type StakeSetLockupCheckedInstruction implements TransactionInstruction {
|
|
2823
|
+
programId: Address
|
|
2824
|
+
custodian: Account
|
|
2825
|
+
lockup: Lockup
|
|
2826
|
+
stakeAccount: Account
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
"""
|
|
2830
|
+
Stake: DeactivateDelinquent instruction
|
|
2831
|
+
"""
|
|
2832
|
+
type StakeDeactivateDelinquentInstruction implements TransactionInstruction {
|
|
2833
|
+
programId: Address
|
|
2834
|
+
referenceVoteAccount: Account
|
|
2835
|
+
stakeAccount: Account
|
|
2836
|
+
voteAccount: Account
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
"""
|
|
2840
|
+
Stake: Redelegate instruction
|
|
2841
|
+
"""
|
|
2842
|
+
type StakeRedelegateInstruction implements TransactionInstruction {
|
|
2843
|
+
programId: Address
|
|
2844
|
+
newStakeAccount: Account
|
|
2845
|
+
stakeAccount: Account
|
|
2846
|
+
stakeAuthority: Account
|
|
2847
|
+
stakeConfigAccount: Account
|
|
2848
|
+
voteAccount: Account
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
"""
|
|
2852
|
+
System: CreateAccount instruction
|
|
2853
|
+
"""
|
|
2854
|
+
type CreateAccountInstruction implements TransactionInstruction {
|
|
2855
|
+
programId: Address
|
|
2856
|
+
lamports: BigInt
|
|
2857
|
+
newAccount: Account
|
|
2858
|
+
owner: Account
|
|
2859
|
+
source: Account
|
|
2860
|
+
space: BigInt
|
|
2861
|
+
}
|
|
2862
|
+
|
|
2863
|
+
"""
|
|
2864
|
+
System: Assign instruction
|
|
2865
|
+
"""
|
|
2866
|
+
type AssignInstruction implements TransactionInstruction {
|
|
2867
|
+
programId: Address
|
|
2868
|
+
account: Account
|
|
2869
|
+
owner: Account
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
"""
|
|
2873
|
+
System: Transfer instruction
|
|
2874
|
+
"""
|
|
2875
|
+
type TransferInstruction implements TransactionInstruction {
|
|
2876
|
+
programId: Address
|
|
2877
|
+
destination: Account
|
|
2878
|
+
lamports: BigInt
|
|
2879
|
+
source: Account
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
"""
|
|
2883
|
+
System: CreateAccountWithSeed instruction
|
|
2884
|
+
"""
|
|
2885
|
+
type CreateAccountWithSeedInstruction implements TransactionInstruction {
|
|
2886
|
+
programId: Address
|
|
2887
|
+
base: Account
|
|
2888
|
+
lamports: BigInt
|
|
2889
|
+
owner: Account
|
|
2890
|
+
seed: String
|
|
2891
|
+
space: BigInt
|
|
2892
|
+
}
|
|
2893
|
+
|
|
2894
|
+
"""
|
|
2895
|
+
System: AdvanceNonceAccount instruction
|
|
2896
|
+
"""
|
|
2897
|
+
type AdvanceNonceAccountInstruction implements TransactionInstruction {
|
|
2898
|
+
programId: Address
|
|
2899
|
+
nonceAccount: Account
|
|
2900
|
+
nonceAuthority: Account
|
|
2901
|
+
recentBlockhashesSysvar: Account
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
"""
|
|
2905
|
+
System: WithdrawNonceAccount instruction
|
|
2906
|
+
"""
|
|
2907
|
+
type WithdrawNonceAccountInstruction implements TransactionInstruction {
|
|
2908
|
+
programId: Address
|
|
2909
|
+
destination: Account
|
|
2910
|
+
lamports: BigInt
|
|
2911
|
+
nonceAccount: Account
|
|
2912
|
+
nonceAuthority: Account
|
|
2913
|
+
recentBlockhashesSysvar: Account
|
|
2914
|
+
rentSysvar: Account
|
|
2915
|
+
}
|
|
2916
|
+
|
|
2917
|
+
"""
|
|
2918
|
+
System: InitializeNonceAccount instruction
|
|
2919
|
+
"""
|
|
2920
|
+
type InitializeNonceAccountInstruction implements TransactionInstruction {
|
|
2921
|
+
programId: Address
|
|
2922
|
+
nonceAccount: Account
|
|
2923
|
+
nonceAuthority: Account
|
|
2924
|
+
recentBlockhashesSysvar: Account
|
|
2925
|
+
rentSysvar: Account
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2928
|
+
"""
|
|
2929
|
+
System: AuthorizeNonceAccount instruction
|
|
2930
|
+
"""
|
|
2931
|
+
type AuthorizeNonceAccountInstruction implements TransactionInstruction {
|
|
2932
|
+
programId: Address
|
|
2933
|
+
newAuthorized: Account
|
|
2934
|
+
nonceAccount: Account
|
|
2935
|
+
nonceAuthority: Account
|
|
2936
|
+
}
|
|
2937
|
+
|
|
2938
|
+
"""
|
|
2939
|
+
System: UpgradeNonceAccount instruction
|
|
2940
|
+
"""
|
|
2941
|
+
type UpgradeNonceAccountInstruction implements TransactionInstruction {
|
|
2942
|
+
programId: Address
|
|
2943
|
+
nonceAccount: Account
|
|
2944
|
+
nonceAuthority: Account
|
|
2945
|
+
}
|
|
2946
|
+
|
|
2947
|
+
"""
|
|
2948
|
+
System: Allocate instruction
|
|
2949
|
+
"""
|
|
2950
|
+
type AllocateInstruction implements TransactionInstruction {
|
|
2951
|
+
programId: Address
|
|
2952
|
+
account: Account
|
|
2953
|
+
space: BigInt
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
"""
|
|
2957
|
+
System: AllocateWithSeed instruction
|
|
2958
|
+
"""
|
|
2959
|
+
type AllocateWithSeedInstruction implements TransactionInstruction {
|
|
2960
|
+
programId: Address
|
|
2961
|
+
account: Account
|
|
2962
|
+
base: Address
|
|
2963
|
+
owner: Account
|
|
2964
|
+
seed: String
|
|
2965
|
+
space: BigInt
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
"""
|
|
2969
|
+
System: AssignWithSeed instruction
|
|
2970
|
+
"""
|
|
2971
|
+
type AssignWithSeedInstruction implements TransactionInstruction {
|
|
2972
|
+
programId: Address
|
|
2973
|
+
account: Account
|
|
2974
|
+
base: Address
|
|
2975
|
+
owner: Account
|
|
2976
|
+
seed: String
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
"""
|
|
2980
|
+
System: TransferWithSeed instruction
|
|
2981
|
+
"""
|
|
2982
|
+
type TransferWithSeedInstruction implements TransactionInstruction {
|
|
2983
|
+
programId: Address
|
|
2984
|
+
destination: Account
|
|
2985
|
+
lamports: BigInt
|
|
2986
|
+
source: Account
|
|
2987
|
+
sourceBase: Address
|
|
2988
|
+
sourceOwner: Account
|
|
2989
|
+
sourceSeed: String
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
"""
|
|
2993
|
+
Vote: InitializeAccount instruction
|
|
2994
|
+
"""
|
|
2995
|
+
type VoteInitializeAccountInstruction implements TransactionInstruction {
|
|
2996
|
+
programId: Address
|
|
2997
|
+
authorizedVoter: Account
|
|
2998
|
+
authorizedWithdrawer: Account
|
|
2999
|
+
clockSysvar: Account
|
|
3000
|
+
commission: BigInt # FIXME:*
|
|
3001
|
+
node: Account
|
|
3002
|
+
rentSysvar: Account
|
|
3003
|
+
voteAccount: Account
|
|
3004
|
+
}
|
|
3005
|
+
|
|
3006
|
+
"""
|
|
3007
|
+
Vote: Authorize instruction
|
|
3008
|
+
"""
|
|
3009
|
+
type VoteAuthorizeInstruction implements TransactionInstruction {
|
|
3010
|
+
programId: Address
|
|
3011
|
+
authority: Account
|
|
3012
|
+
authorityType: String
|
|
3013
|
+
clockSysvar: Account
|
|
3014
|
+
newAuthority: Account
|
|
3015
|
+
voteAccount: Account
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3018
|
+
"""
|
|
3019
|
+
Vote: AuthorizeWithSeed instruction
|
|
3020
|
+
"""
|
|
3021
|
+
type VoteAuthorizeWithSeedInstruction implements TransactionInstruction {
|
|
3022
|
+
programId: Address
|
|
3023
|
+
authorityBaseKey: String
|
|
3024
|
+
authorityOwner: Account
|
|
3025
|
+
authoritySeed: String
|
|
3026
|
+
authorityType: String
|
|
3027
|
+
clockSysvar: Account
|
|
3028
|
+
newAuthority: Account
|
|
3029
|
+
voteAccount: Account
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
"""
|
|
3033
|
+
Vote: AuthorizeCheckedWithSeed instruction
|
|
3034
|
+
"""
|
|
3035
|
+
type VoteAuthorizeCheckedWithSeedInstruction implements TransactionInstruction {
|
|
3036
|
+
programId: Address
|
|
3037
|
+
authorityBaseKey: String
|
|
3038
|
+
authorityOwner: Account
|
|
3039
|
+
authoritySeed: String
|
|
3040
|
+
authorityType: String
|
|
3041
|
+
clockSysvar: Account
|
|
3042
|
+
newAuthority: Account
|
|
3043
|
+
voteAccount: Account
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
type Vote {
|
|
3047
|
+
hash: String
|
|
3048
|
+
slots: [BigInt]
|
|
3049
|
+
timestamp: BigInt
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
"""
|
|
3053
|
+
Vote: Vote instruction
|
|
3054
|
+
"""
|
|
3055
|
+
type VoteVoteInstruction implements TransactionInstruction {
|
|
3056
|
+
programId: Address
|
|
3057
|
+
clockSysvar: Account
|
|
3058
|
+
slotHashesSysvar: Account
|
|
3059
|
+
vote: Vote
|
|
3060
|
+
voteAccount: Account
|
|
3061
|
+
voteAuthority: Account
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
type VoteStateUpdateLockout {
|
|
3065
|
+
confirmationCount: BigInt # FIXME:*
|
|
3066
|
+
slot: BigInt
|
|
3067
|
+
}
|
|
3068
|
+
type VoteStateUpdate {
|
|
3069
|
+
hash: String
|
|
3070
|
+
lockouts: [VoteStateUpdateLockout]
|
|
3071
|
+
root: BigInt
|
|
3072
|
+
timestamp: BigInt
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
"""
|
|
3076
|
+
Vote: UpdateVoteState instruction
|
|
3077
|
+
"""
|
|
3078
|
+
type VoteUpdateVoteStateInstruction implements TransactionInstruction {
|
|
3079
|
+
programId: Address
|
|
3080
|
+
hash: String
|
|
3081
|
+
voteAccount: Account
|
|
3082
|
+
voteAuthority: Account
|
|
3083
|
+
voteStateUpdate: VoteStateUpdate
|
|
3084
|
+
}
|
|
3085
|
+
|
|
3086
|
+
"""
|
|
3087
|
+
Vote: UpdateVoteStateSwitch instruction
|
|
3088
|
+
"""
|
|
3089
|
+
type VoteUpdateVoteStateSwitchInstruction implements TransactionInstruction {
|
|
3090
|
+
programId: Address
|
|
3091
|
+
hash: String
|
|
3092
|
+
voteAccount: Account
|
|
3093
|
+
voteAuthority: Account
|
|
3094
|
+
voteStateUpdate: VoteStateUpdate
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
"""
|
|
3098
|
+
Vote: CompactUpdateVoteState instruction
|
|
3099
|
+
"""
|
|
3100
|
+
type VoteCompactUpdateVoteStateInstruction implements TransactionInstruction {
|
|
3101
|
+
programId: Address
|
|
3102
|
+
hash: String
|
|
3103
|
+
voteAccount: Account
|
|
3104
|
+
voteAuthority: Account
|
|
3105
|
+
voteStateUpdate: VoteStateUpdate
|
|
3106
|
+
}
|
|
3107
|
+
|
|
3108
|
+
"""
|
|
3109
|
+
Vote: CompactUpdateVoteStateSwitch instruction
|
|
3110
|
+
"""
|
|
3111
|
+
type VoteCompactUpdateVoteStateSwitchInstruction implements TransactionInstruction {
|
|
3112
|
+
programId: Address
|
|
3113
|
+
hash: String
|
|
3114
|
+
voteAccount: Account
|
|
3115
|
+
voteAuthority: Account
|
|
3116
|
+
voteStateUpdate: VoteStateUpdate
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
"""
|
|
3120
|
+
Vote: Withdraw instruction
|
|
3121
|
+
"""
|
|
3122
|
+
type VoteWithdrawInstruction implements TransactionInstruction {
|
|
3123
|
+
programId: Address
|
|
3124
|
+
destination: Account
|
|
3125
|
+
lamports: BigInt
|
|
3126
|
+
voteAccount: Account
|
|
3127
|
+
withdrawAuthority: Account
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
"""
|
|
3131
|
+
Vote: UpdateValidatorIdentity instruction
|
|
3132
|
+
"""
|
|
3133
|
+
type VoteUpdateValidatorIdentityInstruction implements TransactionInstruction {
|
|
3134
|
+
programId: Address
|
|
3135
|
+
newValidatorIdentity: Account
|
|
3136
|
+
voteAccount: Account
|
|
3137
|
+
withdrawAuthority: Account
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
"""
|
|
3141
|
+
Vote: UpdateCommission instruction
|
|
3142
|
+
"""
|
|
3143
|
+
type VoteUpdateCommissionInstruction implements TransactionInstruction {
|
|
3144
|
+
programId: Address
|
|
3145
|
+
commission: BigInt # FIXME:*
|
|
3146
|
+
voteAccount: Account
|
|
3147
|
+
withdrawAuthority: Account
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
"""
|
|
3151
|
+
Vote: VoteSwitch instruction
|
|
3152
|
+
"""
|
|
3153
|
+
type VoteVoteSwitchInstruction implements TransactionInstruction {
|
|
3154
|
+
programId: Address
|
|
3155
|
+
clockSysvar: Account
|
|
3156
|
+
hash: String
|
|
3157
|
+
slotHashesSysvar: Account
|
|
3158
|
+
vote: Vote
|
|
3159
|
+
voteAccount: Account
|
|
3160
|
+
voteAuthority: Account
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
"""
|
|
3164
|
+
Vote: AuthorizeChecked instruction
|
|
3165
|
+
"""
|
|
3166
|
+
type VoteAuthorizeCheckedInstruction implements TransactionInstruction {
|
|
3167
|
+
programId: Address
|
|
3168
|
+
authority: Account
|
|
3169
|
+
authorityType: String
|
|
3170
|
+
clockSysvar: Account
|
|
3171
|
+
newAuthority: Account
|
|
3172
|
+
voteAccount: Account
|
|
3173
|
+
}
|
|
3174
|
+
`
|
|
3175
|
+
);
|
|
3176
|
+
|
|
3177
|
+
// src/schema/root.ts
|
|
3178
|
+
var rootTypeDefs = (
|
|
3179
|
+
/* GraphQL */
|
|
3180
|
+
`
|
|
3181
|
+
type Query {
|
|
3182
|
+
account(address: Address!, commitment: Commitment, minContextSlot: Slot): Account
|
|
3183
|
+
block(slot: Slot!, commitment: CommitmentWithoutProcessed): Block
|
|
3184
|
+
programAccounts(
|
|
3185
|
+
programAddress: Address!
|
|
3186
|
+
commitment: Commitment
|
|
3187
|
+
filters: [ProgramAccountsFilter]
|
|
3188
|
+
minContextSlot: Slot
|
|
3189
|
+
): [Account]
|
|
3190
|
+
transaction(signature: Signature!, commitment: CommitmentWithoutProcessed): Transaction
|
|
3191
|
+
}
|
|
3192
|
+
|
|
3193
|
+
schema {
|
|
3194
|
+
query: Query
|
|
3195
|
+
}
|
|
3196
|
+
`
|
|
3197
|
+
);
|
|
3198
|
+
|
|
3199
|
+
// src/schema/transaction.ts
|
|
3200
|
+
var transactionTypeDefs = (
|
|
3201
|
+
/* GraphQL */
|
|
3202
|
+
`
|
|
3203
|
+
type TransactionStatusOk {
|
|
3204
|
+
Ok: String
|
|
3205
|
+
}
|
|
3206
|
+
type TransactionStatusErr {
|
|
3207
|
+
Err: String
|
|
3208
|
+
}
|
|
3209
|
+
union TransactionStatus = TransactionStatusOk | TransactionStatusErr
|
|
3210
|
+
|
|
3211
|
+
type TransactionLoadedAddresses {
|
|
3212
|
+
readonly: [String]
|
|
3213
|
+
writable: [String]
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
type TransactionInnerInstruction {
|
|
3217
|
+
index: Int
|
|
3218
|
+
instructions: [TransactionInstruction]
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
type TransactionMeta {
|
|
3222
|
+
computeUnitsConsumed: BigInt
|
|
3223
|
+
err: String
|
|
3224
|
+
fee: BigInt
|
|
3225
|
+
innerInstructions: [TransactionInnerInstruction]
|
|
3226
|
+
loadedAddresses: TransactionLoadedAddresses
|
|
3227
|
+
logMessages: [String]
|
|
3228
|
+
postBalances: [BigInt]
|
|
3229
|
+
postTokenBalances: [TokenBalance]
|
|
3230
|
+
preBalances: [BigInt]
|
|
3231
|
+
preTokenBalances: [TokenBalance]
|
|
3232
|
+
returnData: ReturnData
|
|
3233
|
+
rewards: [Reward]
|
|
3234
|
+
status: TransactionStatus
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
type TransactionMessageAccountKey {
|
|
3238
|
+
pubkey: Address
|
|
3239
|
+
signer: Boolean
|
|
3240
|
+
source: String
|
|
3241
|
+
writable: Boolean
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
type TransactionMessageAddressTableLookup {
|
|
3245
|
+
accountKey: Address
|
|
3246
|
+
readableIndexes: [Int]
|
|
3247
|
+
writableIndexes: [Int]
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
type TransactionMessageHeader {
|
|
3251
|
+
numReadonlySignedAccounts: Int
|
|
3252
|
+
numReadonlyUnsignedAccounts: Int
|
|
3253
|
+
numRequiredSignatures: Int
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
type TransactionMessage {
|
|
3257
|
+
accountKeys: [TransactionMessageAccountKey]
|
|
3258
|
+
addressTableLookups: [TransactionMessageAddressTableLookup]
|
|
3259
|
+
header: TransactionMessageHeader
|
|
3260
|
+
instructions: [TransactionInstruction]
|
|
3261
|
+
recentBlockhash: String
|
|
3262
|
+
}
|
|
3263
|
+
|
|
3264
|
+
"""
|
|
3265
|
+
A Solana transaction
|
|
3266
|
+
"""
|
|
3267
|
+
type Transaction {
|
|
3268
|
+
blockTime: BigInt
|
|
3269
|
+
data(encoding: TransactionEncoding!): String
|
|
3270
|
+
message: TransactionMessage
|
|
3271
|
+
meta: TransactionMeta
|
|
3272
|
+
signatures: [Signature]
|
|
3273
|
+
slot: Slot
|
|
3274
|
+
version: String
|
|
3275
|
+
}
|
|
3276
|
+
`
|
|
3277
|
+
);
|
|
3278
|
+
|
|
3279
|
+
// src/schema/types.ts
|
|
3280
|
+
var typeTypeDefs = (
|
|
3281
|
+
/* GraphQL */
|
|
3282
|
+
`
|
|
3283
|
+
enum AccountEncoding {
|
|
3284
|
+
BASE_58
|
|
3285
|
+
BASE_64
|
|
3286
|
+
BASE_64_ZSTD
|
|
3287
|
+
}
|
|
3288
|
+
|
|
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 {
|
|
3323
|
+
data: Base64EncodedBytes
|
|
3324
|
+
programId: Address
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
type Reward {
|
|
3328
|
+
commission: Int
|
|
3329
|
+
lamports: BigInt
|
|
3330
|
+
postBalance: BigInt
|
|
3331
|
+
pubkey: Address
|
|
3332
|
+
rewardType: String
|
|
3333
|
+
}
|
|
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
|
|
3357
|
+
}
|
|
3358
|
+
`
|
|
3359
|
+
);
|
|
3360
|
+
|
|
3361
|
+
// src/schema/index.ts
|
|
3362
|
+
function createSolanaGraphQLTypeDefs() {
|
|
3363
|
+
return [accountTypeDefs, blockTypeDefs, instructionTypeDefs, rootTypeDefs, typeTypeDefs, transactionTypeDefs];
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
// src/index.ts
|
|
3367
|
+
function createRpcGraphQL(rpc, config) {
|
|
3368
|
+
const rpcGraphQLConfig = {
|
|
3369
|
+
maxDataSliceByteRange: config?.maxDataSliceByteRange ?? 200,
|
|
3370
|
+
maxMultipleAccountsBatchSize: config?.maxMultipleAccountsBatchSize ?? 100
|
|
3371
|
+
};
|
|
3372
|
+
const schema$1 = schema.makeExecutableSchema({
|
|
3373
|
+
resolvers: createSolanaGraphQLResolvers(),
|
|
3374
|
+
typeDefs: createSolanaGraphQLTypeDefs()
|
|
55
3375
|
});
|
|
56
3376
|
return {
|
|
57
|
-
context,
|
|
58
3377
|
async query(source, variableValues) {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
3378
|
+
const contextValue = createSolanaGraphQLContext(rpc, rpcGraphQLConfig);
|
|
3379
|
+
return graphql.graphql({
|
|
3380
|
+
contextValue,
|
|
3381
|
+
schema: schema$1,
|
|
62
3382
|
source,
|
|
63
3383
|
variableValues
|
|
64
3384
|
});
|
|
65
|
-
|
|
66
|
-
return result;
|
|
67
|
-
},
|
|
68
|
-
schema
|
|
3385
|
+
}
|
|
69
3386
|
};
|
|
70
3387
|
}
|
|
71
3388
|
|