@solana/rpc-graphql 2.0.0-experimental.99a64e9 → 2.0.0-experimental.9c8a30e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.cjs +165 -34
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +165 -34
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +165 -34
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +165 -34
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +165 -34
- package/dist/index.node.js.map +1 -1
- package/dist/types/context.d.ts +3 -2
- package/dist/types/schema/account/query.d.ts +2 -2
- package/dist/types/schema/block/query.d.ts +1 -1
- package/dist/types/schema/program-accounts/query.d.ts +2 -2
- package/dist/types/schema/transaction/query.d.ts +1 -1
- package/package.json +12 -11
- package/dist/types/schema/program-accounts/types.d.ts +0 -3
package/dist/index.browser.js
CHANGED
|
@@ -38,7 +38,19 @@ function createGraphQLCache() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// src/context.ts
|
|
41
|
-
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc) {
|
|
41
|
+
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc, info) {
|
|
42
|
+
if (info && info.fieldNodes[0].selectionSet) {
|
|
43
|
+
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
44
|
+
const requestedFields = selectionSet.selections.map((field) => {
|
|
45
|
+
if (field.kind === "Field") {
|
|
46
|
+
return field.name.value;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
});
|
|
50
|
+
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === "address") {
|
|
51
|
+
return { address };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
42
54
|
const requestConfig = { encoding, ...config };
|
|
43
55
|
const cached = cache.get(address, requestConfig);
|
|
44
56
|
if (cached !== null) {
|
|
@@ -48,11 +60,14 @@ async function resolveAccount({ address, encoding = "jsonParsed", ...config }, c
|
|
|
48
60
|
throw e;
|
|
49
61
|
});
|
|
50
62
|
if (account === null) {
|
|
51
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
address
|
|
65
|
+
};
|
|
52
66
|
}
|
|
53
67
|
const [data, responseEncoding] = Array.isArray(account.data) ? encoding === "jsonParsed" ? [account.data[0], "base64"] : [account.data[0], encoding] : [account.data, "jsonParsed"];
|
|
54
68
|
const queryResponse = {
|
|
55
69
|
...account,
|
|
70
|
+
address,
|
|
56
71
|
data,
|
|
57
72
|
encoding: responseEncoding
|
|
58
73
|
};
|
|
@@ -86,13 +101,14 @@ async function resolveProgramAccounts({ programAddress, encoding = "jsonParsed",
|
|
|
86
101
|
}).catch((e) => {
|
|
87
102
|
throw e;
|
|
88
103
|
});
|
|
89
|
-
const queryResponse = programAccounts.map((
|
|
90
|
-
const [data, responseEncoding] = Array.isArray(
|
|
91
|
-
const pubkey =
|
|
92
|
-
const account = { ...programAccount2.account, data, encoding: responseEncoding };
|
|
104
|
+
const queryResponse = programAccounts.map((programAccount) => {
|
|
105
|
+
const [data, responseEncoding] = Array.isArray(programAccount.account.data) ? encoding === "jsonParsed" ? [programAccount.account.data[0], "base64"] : [programAccount.account.data[0], encoding] : [programAccount.account.data, "jsonParsed"];
|
|
106
|
+
const pubkey = programAccount.pubkey;
|
|
93
107
|
return {
|
|
94
|
-
account,
|
|
95
|
-
pubkey
|
|
108
|
+
...programAccount.account,
|
|
109
|
+
address: pubkey,
|
|
110
|
+
data,
|
|
111
|
+
encoding: responseEncoding
|
|
96
112
|
};
|
|
97
113
|
});
|
|
98
114
|
cache.insert(programAddress, requestConfig, queryResponse);
|
|
@@ -127,8 +143,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
127
143
|
const cache = createGraphQLCache();
|
|
128
144
|
return {
|
|
129
145
|
cache,
|
|
130
|
-
resolveAccount(args) {
|
|
131
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
146
|
+
resolveAccount(args, info) {
|
|
147
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
132
148
|
},
|
|
133
149
|
resolveBlock(args) {
|
|
134
150
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -270,7 +286,7 @@ var dataSliceInputType = () => {
|
|
|
270
286
|
length: number(),
|
|
271
287
|
offset: number()
|
|
272
288
|
},
|
|
273
|
-
name: "
|
|
289
|
+
name: "DataSlice"
|
|
274
290
|
});
|
|
275
291
|
return memoisedDataSliceInputType;
|
|
276
292
|
};
|
|
@@ -345,6 +361,7 @@ var memoisedAccountInterfaceFields;
|
|
|
345
361
|
var accountInterfaceFields = () => {
|
|
346
362
|
if (!memoisedAccountInterfaceFields) {
|
|
347
363
|
memoisedAccountInterfaceFields = {
|
|
364
|
+
address: string(),
|
|
348
365
|
encoding: string(),
|
|
349
366
|
executable: boolean(),
|
|
350
367
|
lamports: bigint(),
|
|
@@ -404,6 +421,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
404
421
|
fields: {
|
|
405
422
|
...accountInterfaceFields(),
|
|
406
423
|
data,
|
|
424
|
+
// Nested Account interface
|
|
407
425
|
owner: {
|
|
408
426
|
args: {
|
|
409
427
|
commitment: type(commitmentInputType()),
|
|
@@ -411,7 +429,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
411
429
|
encoding: type(accountEncodingInputType()),
|
|
412
430
|
minContextSlot: bigint()
|
|
413
431
|
},
|
|
414
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
432
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
415
433
|
type: accountInterface()
|
|
416
434
|
}
|
|
417
435
|
},
|
|
@@ -455,7 +473,18 @@ var accountNonceAccount = () => {
|
|
|
455
473
|
"NonceAccount",
|
|
456
474
|
"A nonce account",
|
|
457
475
|
accountDataJsonParsed("Nonce", {
|
|
458
|
-
|
|
476
|
+
// Nested Account interface
|
|
477
|
+
authority: {
|
|
478
|
+
args: {
|
|
479
|
+
commitment: type(commitmentInputType()),
|
|
480
|
+
dataSlice: type(dataSliceInputType()),
|
|
481
|
+
encoding: type(accountEncodingInputType()),
|
|
482
|
+
minContextSlot: bigint()
|
|
483
|
+
},
|
|
484
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
485
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
486
|
+
type: accountInterface()
|
|
487
|
+
},
|
|
459
488
|
blockhash: string(),
|
|
460
489
|
feeCalculator: object("NonceFeeCalculator", {
|
|
461
490
|
lamportsPerSignature: string()
|
|
@@ -472,7 +501,18 @@ var accountLookupTable = () => {
|
|
|
472
501
|
"An address lookup table account",
|
|
473
502
|
accountDataJsonParsed("LookupTable", {
|
|
474
503
|
addresses: list(string()),
|
|
475
|
-
|
|
504
|
+
// Nested Account interface
|
|
505
|
+
authority: {
|
|
506
|
+
args: {
|
|
507
|
+
commitment: type(commitmentInputType()),
|
|
508
|
+
dataSlice: type(dataSliceInputType()),
|
|
509
|
+
encoding: type(accountEncodingInputType()),
|
|
510
|
+
minContextSlot: bigint()
|
|
511
|
+
},
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
513
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
514
|
+
type: accountInterface()
|
|
515
|
+
},
|
|
476
516
|
deactivationSlot: string(),
|
|
477
517
|
lastExtendedSlot: string(),
|
|
478
518
|
lastExtendedSlotStartIndex: number()
|
|
@@ -490,7 +530,18 @@ var accountMint = () => {
|
|
|
490
530
|
decimals: number(),
|
|
491
531
|
freezeAuthority: string(),
|
|
492
532
|
isInitialized: boolean(),
|
|
493
|
-
|
|
533
|
+
// Nested Account interface
|
|
534
|
+
mintAuthority: {
|
|
535
|
+
args: {
|
|
536
|
+
commitment: type(commitmentInputType()),
|
|
537
|
+
dataSlice: type(dataSliceInputType()),
|
|
538
|
+
encoding: type(accountEncodingInputType()),
|
|
539
|
+
minContextSlot: bigint()
|
|
540
|
+
},
|
|
541
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
542
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.mintAuthority }, info),
|
|
543
|
+
type: accountInterface()
|
|
544
|
+
},
|
|
494
545
|
supply: string()
|
|
495
546
|
})
|
|
496
547
|
);
|
|
@@ -505,7 +556,18 @@ var accountTokenAccount = () => {
|
|
|
505
556
|
accountDataJsonParsed("TokenAccount", {
|
|
506
557
|
isNative: boolean(),
|
|
507
558
|
mint: string(),
|
|
508
|
-
|
|
559
|
+
// Nested Account interface
|
|
560
|
+
owner: {
|
|
561
|
+
args: {
|
|
562
|
+
commitment: type(commitmentInputType()),
|
|
563
|
+
dataSlice: type(dataSliceInputType()),
|
|
564
|
+
encoding: type(accountEncodingInputType()),
|
|
565
|
+
minContextSlot: bigint()
|
|
566
|
+
},
|
|
567
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
568
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
569
|
+
type: accountInterface()
|
|
570
|
+
},
|
|
509
571
|
state: string(),
|
|
510
572
|
tokenAmount: type(tokenAmountType())
|
|
511
573
|
})
|
|
@@ -521,11 +583,44 @@ var accountStakeAccount = () => {
|
|
|
521
583
|
accountDataJsonParsed("Stake", {
|
|
522
584
|
meta: object("StakeMeta", {
|
|
523
585
|
authorized: object("StakeMetaAuthorized", {
|
|
524
|
-
|
|
525
|
-
|
|
586
|
+
// Nested Account interface
|
|
587
|
+
staker: {
|
|
588
|
+
args: {
|
|
589
|
+
commitment: type(commitmentInputType()),
|
|
590
|
+
dataSlice: type(dataSliceInputType()),
|
|
591
|
+
encoding: type(accountEncodingInputType()),
|
|
592
|
+
minContextSlot: bigint()
|
|
593
|
+
},
|
|
594
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
595
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.staker }, info),
|
|
596
|
+
type: accountInterface()
|
|
597
|
+
},
|
|
598
|
+
// Nested Account interface
|
|
599
|
+
withdrawer: {
|
|
600
|
+
args: {
|
|
601
|
+
commitment: type(commitmentInputType()),
|
|
602
|
+
dataSlice: type(dataSliceInputType()),
|
|
603
|
+
encoding: type(accountEncodingInputType()),
|
|
604
|
+
minContextSlot: bigint()
|
|
605
|
+
},
|
|
606
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
607
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.withdrawer }, info),
|
|
608
|
+
type: accountInterface()
|
|
609
|
+
}
|
|
526
610
|
}),
|
|
527
611
|
lockup: object("StakeMetaLockup", {
|
|
528
|
-
|
|
612
|
+
// Nested Account interface
|
|
613
|
+
custodian: {
|
|
614
|
+
args: {
|
|
615
|
+
commitment: type(commitmentInputType()),
|
|
616
|
+
dataSlice: type(dataSliceInputType()),
|
|
617
|
+
encoding: type(accountEncodingInputType()),
|
|
618
|
+
minContextSlot: bigint()
|
|
619
|
+
},
|
|
620
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
621
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.custodian }, info),
|
|
622
|
+
type: accountInterface()
|
|
623
|
+
},
|
|
529
624
|
epoch: bigint(),
|
|
530
625
|
unixTimestamp: bigint()
|
|
531
626
|
}),
|
|
@@ -537,7 +632,18 @@ var accountStakeAccount = () => {
|
|
|
537
632
|
activationEpoch: bigint(),
|
|
538
633
|
deactivationEpoch: bigint(),
|
|
539
634
|
stake: string(),
|
|
540
|
-
|
|
635
|
+
// Nested Account interface
|
|
636
|
+
voter: {
|
|
637
|
+
args: {
|
|
638
|
+
commitment: type(commitmentInputType()),
|
|
639
|
+
dataSlice: type(dataSliceInputType()),
|
|
640
|
+
encoding: type(accountEncodingInputType()),
|
|
641
|
+
minContextSlot: bigint()
|
|
642
|
+
},
|
|
643
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
644
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.voter }, info),
|
|
645
|
+
type: accountInterface()
|
|
646
|
+
},
|
|
541
647
|
warmupCooldownRate: number()
|
|
542
648
|
})
|
|
543
649
|
})
|
|
@@ -554,11 +660,33 @@ var accountVoteAccount = () => {
|
|
|
554
660
|
accountDataJsonParsed("Vote", {
|
|
555
661
|
authorizedVoters: list(
|
|
556
662
|
object("VoteAuthorizedVoter", {
|
|
557
|
-
|
|
663
|
+
// Nested Account interface
|
|
664
|
+
authorizedVoter: {
|
|
665
|
+
args: {
|
|
666
|
+
commitment: type(commitmentInputType()),
|
|
667
|
+
dataSlice: type(dataSliceInputType()),
|
|
668
|
+
encoding: type(accountEncodingInputType()),
|
|
669
|
+
minContextSlot: bigint()
|
|
670
|
+
},
|
|
671
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
672
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedVoter }, info),
|
|
673
|
+
type: accountInterface()
|
|
674
|
+
},
|
|
558
675
|
epoch: bigint()
|
|
559
676
|
})
|
|
560
677
|
),
|
|
561
|
-
|
|
678
|
+
// Nested Account interface
|
|
679
|
+
authorizedWithdrawer: {
|
|
680
|
+
args: {
|
|
681
|
+
commitment: type(commitmentInputType()),
|
|
682
|
+
dataSlice: type(dataSliceInputType()),
|
|
683
|
+
encoding: type(accountEncodingInputType()),
|
|
684
|
+
minContextSlot: bigint()
|
|
685
|
+
},
|
|
686
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
687
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedWithdrawer }, info),
|
|
688
|
+
type: accountInterface()
|
|
689
|
+
},
|
|
562
690
|
commission: number(),
|
|
563
691
|
epochCredits: list(
|
|
564
692
|
object("VoteEpochCredits", {
|
|
@@ -571,7 +699,18 @@ var accountVoteAccount = () => {
|
|
|
571
699
|
slot: bigint(),
|
|
572
700
|
timestamp: bigint()
|
|
573
701
|
}),
|
|
574
|
-
|
|
702
|
+
// Nested Account interface
|
|
703
|
+
node: {
|
|
704
|
+
args: {
|
|
705
|
+
commitment: type(commitmentInputType()),
|
|
706
|
+
dataSlice: type(dataSliceInputType()),
|
|
707
|
+
encoding: type(accountEncodingInputType()),
|
|
708
|
+
minContextSlot: bigint()
|
|
709
|
+
},
|
|
710
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
711
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.nodePubkey }, info),
|
|
712
|
+
type: accountInterface()
|
|
713
|
+
},
|
|
575
714
|
priorVoters: list(string()),
|
|
576
715
|
rootSlot: bigint(),
|
|
577
716
|
votes: list(
|
|
@@ -611,7 +750,8 @@ var accountQuery = () => ({
|
|
|
611
750
|
encoding: type(accountEncodingInputType()),
|
|
612
751
|
minContextSlot: bigint()
|
|
613
752
|
},
|
|
614
|
-
|
|
753
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
754
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
615
755
|
type: accountInterface()
|
|
616
756
|
}
|
|
617
757
|
});
|
|
@@ -2140,15 +2280,6 @@ var blockQuery = () => ({
|
|
|
2140
2280
|
type: blockInterface()
|
|
2141
2281
|
}
|
|
2142
2282
|
});
|
|
2143
|
-
var programAccount = () => new GraphQLObjectType({
|
|
2144
|
-
fields: {
|
|
2145
|
-
account: type(accountInterface()),
|
|
2146
|
-
pubkey: string()
|
|
2147
|
-
},
|
|
2148
|
-
name: "ProgramAccount"
|
|
2149
|
-
});
|
|
2150
|
-
|
|
2151
|
-
// src/schema/program-accounts/query.ts
|
|
2152
2283
|
var programAccountsQuery = () => ({
|
|
2153
2284
|
programAccounts: {
|
|
2154
2285
|
args: {
|
|
@@ -2161,7 +2292,7 @@ var programAccountsQuery = () => ({
|
|
|
2161
2292
|
withContext: string()
|
|
2162
2293
|
},
|
|
2163
2294
|
resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
|
|
2164
|
-
type: new GraphQLList(
|
|
2295
|
+
type: new GraphQLList(accountInterface())
|
|
2165
2296
|
}
|
|
2166
2297
|
});
|
|
2167
2298
|
|