@solana/rpc-graphql 2.0.0-experimental.ee4214c → 2.0.0-experimental.fd11bd1
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 +156 -19
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +156 -17
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +156 -17
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +156 -19
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +156 -17
- package/dist/index.node.js.map +1 -1
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/context.d.ts +3 -2
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/rpc.d.ts.map +1 -0
- package/dist/types/schema/account/index.d.ts.map +1 -0
- package/dist/types/schema/account/query.d.ts +2 -2
- package/dist/types/schema/account/query.d.ts.map +1 -0
- package/dist/types/schema/account/types.d.ts.map +1 -0
- package/dist/types/schema/block/index.d.ts.map +1 -0
- package/dist/types/schema/block/query.d.ts +1 -1
- package/dist/types/schema/block/query.d.ts.map +1 -0
- package/dist/types/schema/block/types.d.ts.map +1 -0
- package/dist/types/schema/inputs.d.ts.map +1 -0
- package/dist/types/schema/picks.d.ts.map +1 -0
- package/dist/types/schema/program-accounts/index.d.ts.map +1 -0
- package/dist/types/schema/program-accounts/query.d.ts +1 -1
- package/dist/types/schema/program-accounts/query.d.ts.map +1 -0
- package/dist/types/schema/program-accounts/types.d.ts.map +1 -0
- package/dist/types/schema/scalars.d.ts.map +1 -0
- package/dist/types/schema/transaction/index.d.ts.map +1 -0
- package/dist/types/schema/transaction/query.d.ts +1 -1
- package/dist/types/schema/transaction/query.d.ts.map +1 -0
- package/dist/types/schema/transaction/types.d.ts.map +1 -0
- package/package.json +12 -11
package/dist/index.browser.cjs
CHANGED
|
@@ -40,7 +40,19 @@ function createGraphQLCache() {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// src/context.ts
|
|
43
|
-
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc) {
|
|
43
|
+
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc, info) {
|
|
44
|
+
if (info && info.fieldNodes[0].selectionSet) {
|
|
45
|
+
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
46
|
+
const requestedFields = selectionSet.selections.map((field) => {
|
|
47
|
+
if (field.kind === "Field") {
|
|
48
|
+
return field.name.value;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
});
|
|
52
|
+
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === "address") {
|
|
53
|
+
return { address };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
44
56
|
const requestConfig = { encoding, ...config };
|
|
45
57
|
const cached = cache.get(address, requestConfig);
|
|
46
58
|
if (cached !== null) {
|
|
@@ -50,11 +62,14 @@ async function resolveAccount({ address, encoding = "jsonParsed", ...config }, c
|
|
|
50
62
|
throw e;
|
|
51
63
|
});
|
|
52
64
|
if (account === null) {
|
|
53
|
-
return
|
|
65
|
+
return {
|
|
66
|
+
address
|
|
67
|
+
};
|
|
54
68
|
}
|
|
55
69
|
const [data, responseEncoding] = Array.isArray(account.data) ? encoding === "jsonParsed" ? [account.data[0], "base64"] : [account.data[0], encoding] : [account.data, "jsonParsed"];
|
|
56
70
|
const queryResponse = {
|
|
57
71
|
...account,
|
|
72
|
+
address,
|
|
58
73
|
data,
|
|
59
74
|
encoding: responseEncoding
|
|
60
75
|
};
|
|
@@ -129,8 +144,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
129
144
|
const cache = createGraphQLCache();
|
|
130
145
|
return {
|
|
131
146
|
cache,
|
|
132
|
-
resolveAccount(args) {
|
|
133
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
147
|
+
resolveAccount(args, info) {
|
|
148
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
134
149
|
},
|
|
135
150
|
resolveBlock(args) {
|
|
136
151
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -347,6 +362,7 @@ var memoisedAccountInterfaceFields;
|
|
|
347
362
|
var accountInterfaceFields = () => {
|
|
348
363
|
if (!memoisedAccountInterfaceFields) {
|
|
349
364
|
memoisedAccountInterfaceFields = {
|
|
365
|
+
address: string(),
|
|
350
366
|
encoding: string(),
|
|
351
367
|
executable: boolean(),
|
|
352
368
|
lamports: bigint(),
|
|
@@ -406,6 +422,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
406
422
|
fields: {
|
|
407
423
|
...accountInterfaceFields(),
|
|
408
424
|
data,
|
|
425
|
+
// Nested Account interface
|
|
409
426
|
owner: {
|
|
410
427
|
args: {
|
|
411
428
|
commitment: type(commitmentInputType()),
|
|
@@ -413,7 +430,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
413
430
|
encoding: type(accountEncodingInputType()),
|
|
414
431
|
minContextSlot: bigint()
|
|
415
432
|
},
|
|
416
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
433
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
417
434
|
type: accountInterface()
|
|
418
435
|
}
|
|
419
436
|
},
|
|
@@ -457,7 +474,18 @@ var accountNonceAccount = () => {
|
|
|
457
474
|
"NonceAccount",
|
|
458
475
|
"A nonce account",
|
|
459
476
|
accountDataJsonParsed("Nonce", {
|
|
460
|
-
|
|
477
|
+
// Nested Account interface
|
|
478
|
+
authority: {
|
|
479
|
+
args: {
|
|
480
|
+
commitment: type(commitmentInputType()),
|
|
481
|
+
dataSlice: type(dataSliceInputType()),
|
|
482
|
+
encoding: type(accountEncodingInputType()),
|
|
483
|
+
minContextSlot: bigint()
|
|
484
|
+
},
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
486
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
487
|
+
type: accountInterface()
|
|
488
|
+
},
|
|
461
489
|
blockhash: string(),
|
|
462
490
|
feeCalculator: object("NonceFeeCalculator", {
|
|
463
491
|
lamportsPerSignature: string()
|
|
@@ -474,7 +502,18 @@ var accountLookupTable = () => {
|
|
|
474
502
|
"An address lookup table account",
|
|
475
503
|
accountDataJsonParsed("LookupTable", {
|
|
476
504
|
addresses: list(string()),
|
|
477
|
-
|
|
505
|
+
// Nested Account interface
|
|
506
|
+
authority: {
|
|
507
|
+
args: {
|
|
508
|
+
commitment: type(commitmentInputType()),
|
|
509
|
+
dataSlice: type(dataSliceInputType()),
|
|
510
|
+
encoding: type(accountEncodingInputType()),
|
|
511
|
+
minContextSlot: bigint()
|
|
512
|
+
},
|
|
513
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
514
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
515
|
+
type: accountInterface()
|
|
516
|
+
},
|
|
478
517
|
deactivationSlot: string(),
|
|
479
518
|
lastExtendedSlot: string(),
|
|
480
519
|
lastExtendedSlotStartIndex: number()
|
|
@@ -492,7 +531,18 @@ var accountMint = () => {
|
|
|
492
531
|
decimals: number(),
|
|
493
532
|
freezeAuthority: string(),
|
|
494
533
|
isInitialized: boolean(),
|
|
495
|
-
|
|
534
|
+
// Nested Account interface
|
|
535
|
+
mintAuthority: {
|
|
536
|
+
args: {
|
|
537
|
+
commitment: type(commitmentInputType()),
|
|
538
|
+
dataSlice: type(dataSliceInputType()),
|
|
539
|
+
encoding: type(accountEncodingInputType()),
|
|
540
|
+
minContextSlot: bigint()
|
|
541
|
+
},
|
|
542
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
543
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.mintAuthority }, info),
|
|
544
|
+
type: accountInterface()
|
|
545
|
+
},
|
|
496
546
|
supply: string()
|
|
497
547
|
})
|
|
498
548
|
);
|
|
@@ -507,7 +557,18 @@ var accountTokenAccount = () => {
|
|
|
507
557
|
accountDataJsonParsed("TokenAccount", {
|
|
508
558
|
isNative: boolean(),
|
|
509
559
|
mint: string(),
|
|
510
|
-
|
|
560
|
+
// Nested Account interface
|
|
561
|
+
owner: {
|
|
562
|
+
args: {
|
|
563
|
+
commitment: type(commitmentInputType()),
|
|
564
|
+
dataSlice: type(dataSliceInputType()),
|
|
565
|
+
encoding: type(accountEncodingInputType()),
|
|
566
|
+
minContextSlot: bigint()
|
|
567
|
+
},
|
|
568
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
569
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
570
|
+
type: accountInterface()
|
|
571
|
+
},
|
|
511
572
|
state: string(),
|
|
512
573
|
tokenAmount: type(tokenAmountType())
|
|
513
574
|
})
|
|
@@ -523,11 +584,44 @@ var accountStakeAccount = () => {
|
|
|
523
584
|
accountDataJsonParsed("Stake", {
|
|
524
585
|
meta: object("StakeMeta", {
|
|
525
586
|
authorized: object("StakeMetaAuthorized", {
|
|
526
|
-
|
|
527
|
-
|
|
587
|
+
// Nested Account interface
|
|
588
|
+
staker: {
|
|
589
|
+
args: {
|
|
590
|
+
commitment: type(commitmentInputType()),
|
|
591
|
+
dataSlice: type(dataSliceInputType()),
|
|
592
|
+
encoding: type(accountEncodingInputType()),
|
|
593
|
+
minContextSlot: bigint()
|
|
594
|
+
},
|
|
595
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
596
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.staker }, info),
|
|
597
|
+
type: accountInterface()
|
|
598
|
+
},
|
|
599
|
+
// Nested Account interface
|
|
600
|
+
withdrawer: {
|
|
601
|
+
args: {
|
|
602
|
+
commitment: type(commitmentInputType()),
|
|
603
|
+
dataSlice: type(dataSliceInputType()),
|
|
604
|
+
encoding: type(accountEncodingInputType()),
|
|
605
|
+
minContextSlot: bigint()
|
|
606
|
+
},
|
|
607
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
608
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.withdrawer }, info),
|
|
609
|
+
type: accountInterface()
|
|
610
|
+
}
|
|
528
611
|
}),
|
|
529
612
|
lockup: object("StakeMetaLockup", {
|
|
530
|
-
|
|
613
|
+
// Nested Account interface
|
|
614
|
+
custodian: {
|
|
615
|
+
args: {
|
|
616
|
+
commitment: type(commitmentInputType()),
|
|
617
|
+
dataSlice: type(dataSliceInputType()),
|
|
618
|
+
encoding: type(accountEncodingInputType()),
|
|
619
|
+
minContextSlot: bigint()
|
|
620
|
+
},
|
|
621
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
622
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.custodian }, info),
|
|
623
|
+
type: accountInterface()
|
|
624
|
+
},
|
|
531
625
|
epoch: bigint(),
|
|
532
626
|
unixTimestamp: bigint()
|
|
533
627
|
}),
|
|
@@ -539,7 +633,18 @@ var accountStakeAccount = () => {
|
|
|
539
633
|
activationEpoch: bigint(),
|
|
540
634
|
deactivationEpoch: bigint(),
|
|
541
635
|
stake: string(),
|
|
542
|
-
|
|
636
|
+
// Nested Account interface
|
|
637
|
+
voter: {
|
|
638
|
+
args: {
|
|
639
|
+
commitment: type(commitmentInputType()),
|
|
640
|
+
dataSlice: type(dataSliceInputType()),
|
|
641
|
+
encoding: type(accountEncodingInputType()),
|
|
642
|
+
minContextSlot: bigint()
|
|
643
|
+
},
|
|
644
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
645
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.voter }, info),
|
|
646
|
+
type: accountInterface()
|
|
647
|
+
},
|
|
543
648
|
warmupCooldownRate: number()
|
|
544
649
|
})
|
|
545
650
|
})
|
|
@@ -556,11 +661,33 @@ var accountVoteAccount = () => {
|
|
|
556
661
|
accountDataJsonParsed("Vote", {
|
|
557
662
|
authorizedVoters: list(
|
|
558
663
|
object("VoteAuthorizedVoter", {
|
|
559
|
-
|
|
664
|
+
// Nested Account interface
|
|
665
|
+
authorizedVoter: {
|
|
666
|
+
args: {
|
|
667
|
+
commitment: type(commitmentInputType()),
|
|
668
|
+
dataSlice: type(dataSliceInputType()),
|
|
669
|
+
encoding: type(accountEncodingInputType()),
|
|
670
|
+
minContextSlot: bigint()
|
|
671
|
+
},
|
|
672
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
673
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedVoter }, info),
|
|
674
|
+
type: accountInterface()
|
|
675
|
+
},
|
|
560
676
|
epoch: bigint()
|
|
561
677
|
})
|
|
562
678
|
),
|
|
563
|
-
|
|
679
|
+
// Nested Account interface
|
|
680
|
+
authorizedWithdrawer: {
|
|
681
|
+
args: {
|
|
682
|
+
commitment: type(commitmentInputType()),
|
|
683
|
+
dataSlice: type(dataSliceInputType()),
|
|
684
|
+
encoding: type(accountEncodingInputType()),
|
|
685
|
+
minContextSlot: bigint()
|
|
686
|
+
},
|
|
687
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
688
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedWithdrawer }, info),
|
|
689
|
+
type: accountInterface()
|
|
690
|
+
},
|
|
564
691
|
commission: number(),
|
|
565
692
|
epochCredits: list(
|
|
566
693
|
object("VoteEpochCredits", {
|
|
@@ -573,7 +700,18 @@ var accountVoteAccount = () => {
|
|
|
573
700
|
slot: bigint(),
|
|
574
701
|
timestamp: bigint()
|
|
575
702
|
}),
|
|
576
|
-
|
|
703
|
+
// Nested Account interface
|
|
704
|
+
node: {
|
|
705
|
+
args: {
|
|
706
|
+
commitment: type(commitmentInputType()),
|
|
707
|
+
dataSlice: type(dataSliceInputType()),
|
|
708
|
+
encoding: type(accountEncodingInputType()),
|
|
709
|
+
minContextSlot: bigint()
|
|
710
|
+
},
|
|
711
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
712
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.nodePubkey }, info),
|
|
713
|
+
type: accountInterface()
|
|
714
|
+
},
|
|
577
715
|
priorVoters: list(string()),
|
|
578
716
|
rootSlot: bigint(),
|
|
579
717
|
votes: list(
|
|
@@ -613,7 +751,8 @@ var accountQuery = () => ({
|
|
|
613
751
|
encoding: type(accountEncodingInputType()),
|
|
614
752
|
minContextSlot: bigint()
|
|
615
753
|
},
|
|
616
|
-
|
|
754
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
755
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
617
756
|
type: accountInterface()
|
|
618
757
|
}
|
|
619
758
|
});
|
|
@@ -2199,5 +2338,3 @@ function createRpcGraphQL(rpc) {
|
|
|
2199
2338
|
}
|
|
2200
2339
|
|
|
2201
2340
|
exports.createRpcGraphQL = createRpcGraphQL;
|
|
2202
|
-
//# sourceMappingURL=out.js.map
|
|
2203
|
-
//# sourceMappingURL=index.browser.cjs.map
|