@solana/rpc-graphql 2.0.0-experimental.fc4e943 → 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.node.cjs
CHANGED
|
@@ -36,7 +36,19 @@ function createGraphQLCache() {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// src/context.ts
|
|
39
|
-
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc) {
|
|
39
|
+
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc, info) {
|
|
40
|
+
if (info && info.fieldNodes[0].selectionSet) {
|
|
41
|
+
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
42
|
+
const requestedFields = selectionSet.selections.map((field) => {
|
|
43
|
+
if (field.kind === "Field") {
|
|
44
|
+
return field.name.value;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
});
|
|
48
|
+
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === "address") {
|
|
49
|
+
return { address };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
const requestConfig = { encoding, ...config };
|
|
41
53
|
const cached = cache.get(address, requestConfig);
|
|
42
54
|
if (cached !== null) {
|
|
@@ -46,11 +58,14 @@ async function resolveAccount({ address, encoding = "jsonParsed", ...config }, c
|
|
|
46
58
|
throw e;
|
|
47
59
|
});
|
|
48
60
|
if (account === null) {
|
|
49
|
-
return
|
|
61
|
+
return {
|
|
62
|
+
address
|
|
63
|
+
};
|
|
50
64
|
}
|
|
51
65
|
const [data, responseEncoding] = Array.isArray(account.data) ? encoding === "jsonParsed" ? [account.data[0], "base64"] : [account.data[0], encoding] : [account.data, "jsonParsed"];
|
|
52
66
|
const queryResponse = {
|
|
53
67
|
...account,
|
|
68
|
+
address,
|
|
54
69
|
data,
|
|
55
70
|
encoding: responseEncoding
|
|
56
71
|
};
|
|
@@ -125,8 +140,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
125
140
|
const cache = createGraphQLCache();
|
|
126
141
|
return {
|
|
127
142
|
cache,
|
|
128
|
-
resolveAccount(args) {
|
|
129
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
143
|
+
resolveAccount(args, info) {
|
|
144
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
130
145
|
},
|
|
131
146
|
resolveBlock(args) {
|
|
132
147
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -343,6 +358,7 @@ var memoisedAccountInterfaceFields;
|
|
|
343
358
|
var accountInterfaceFields = () => {
|
|
344
359
|
if (!memoisedAccountInterfaceFields) {
|
|
345
360
|
memoisedAccountInterfaceFields = {
|
|
361
|
+
address: string(),
|
|
346
362
|
encoding: string(),
|
|
347
363
|
executable: boolean(),
|
|
348
364
|
lamports: bigint(),
|
|
@@ -402,6 +418,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
402
418
|
fields: {
|
|
403
419
|
...accountInterfaceFields(),
|
|
404
420
|
data,
|
|
421
|
+
// Nested Account interface
|
|
405
422
|
owner: {
|
|
406
423
|
args: {
|
|
407
424
|
commitment: type(commitmentInputType()),
|
|
@@ -409,7 +426,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
409
426
|
encoding: type(accountEncodingInputType()),
|
|
410
427
|
minContextSlot: bigint()
|
|
411
428
|
},
|
|
412
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
429
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
413
430
|
type: accountInterface()
|
|
414
431
|
}
|
|
415
432
|
},
|
|
@@ -453,7 +470,18 @@ var accountNonceAccount = () => {
|
|
|
453
470
|
"NonceAccount",
|
|
454
471
|
"A nonce account",
|
|
455
472
|
accountDataJsonParsed("Nonce", {
|
|
456
|
-
|
|
473
|
+
// Nested Account interface
|
|
474
|
+
authority: {
|
|
475
|
+
args: {
|
|
476
|
+
commitment: type(commitmentInputType()),
|
|
477
|
+
dataSlice: type(dataSliceInputType()),
|
|
478
|
+
encoding: type(accountEncodingInputType()),
|
|
479
|
+
minContextSlot: bigint()
|
|
480
|
+
},
|
|
481
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
482
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
483
|
+
type: accountInterface()
|
|
484
|
+
},
|
|
457
485
|
blockhash: string(),
|
|
458
486
|
feeCalculator: object("NonceFeeCalculator", {
|
|
459
487
|
lamportsPerSignature: string()
|
|
@@ -470,7 +498,18 @@ var accountLookupTable = () => {
|
|
|
470
498
|
"An address lookup table account",
|
|
471
499
|
accountDataJsonParsed("LookupTable", {
|
|
472
500
|
addresses: list(string()),
|
|
473
|
-
|
|
501
|
+
// Nested Account interface
|
|
502
|
+
authority: {
|
|
503
|
+
args: {
|
|
504
|
+
commitment: type(commitmentInputType()),
|
|
505
|
+
dataSlice: type(dataSliceInputType()),
|
|
506
|
+
encoding: type(accountEncodingInputType()),
|
|
507
|
+
minContextSlot: bigint()
|
|
508
|
+
},
|
|
509
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
510
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
511
|
+
type: accountInterface()
|
|
512
|
+
},
|
|
474
513
|
deactivationSlot: string(),
|
|
475
514
|
lastExtendedSlot: string(),
|
|
476
515
|
lastExtendedSlotStartIndex: number()
|
|
@@ -488,7 +527,18 @@ var accountMint = () => {
|
|
|
488
527
|
decimals: number(),
|
|
489
528
|
freezeAuthority: string(),
|
|
490
529
|
isInitialized: boolean(),
|
|
491
|
-
|
|
530
|
+
// Nested Account interface
|
|
531
|
+
mintAuthority: {
|
|
532
|
+
args: {
|
|
533
|
+
commitment: type(commitmentInputType()),
|
|
534
|
+
dataSlice: type(dataSliceInputType()),
|
|
535
|
+
encoding: type(accountEncodingInputType()),
|
|
536
|
+
minContextSlot: bigint()
|
|
537
|
+
},
|
|
538
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
539
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.mintAuthority }, info),
|
|
540
|
+
type: accountInterface()
|
|
541
|
+
},
|
|
492
542
|
supply: string()
|
|
493
543
|
})
|
|
494
544
|
);
|
|
@@ -503,7 +553,18 @@ var accountTokenAccount = () => {
|
|
|
503
553
|
accountDataJsonParsed("TokenAccount", {
|
|
504
554
|
isNative: boolean(),
|
|
505
555
|
mint: string(),
|
|
506
|
-
|
|
556
|
+
// Nested Account interface
|
|
557
|
+
owner: {
|
|
558
|
+
args: {
|
|
559
|
+
commitment: type(commitmentInputType()),
|
|
560
|
+
dataSlice: type(dataSliceInputType()),
|
|
561
|
+
encoding: type(accountEncodingInputType()),
|
|
562
|
+
minContextSlot: bigint()
|
|
563
|
+
},
|
|
564
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
565
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
566
|
+
type: accountInterface()
|
|
567
|
+
},
|
|
507
568
|
state: string(),
|
|
508
569
|
tokenAmount: type(tokenAmountType())
|
|
509
570
|
})
|
|
@@ -519,11 +580,44 @@ var accountStakeAccount = () => {
|
|
|
519
580
|
accountDataJsonParsed("Stake", {
|
|
520
581
|
meta: object("StakeMeta", {
|
|
521
582
|
authorized: object("StakeMetaAuthorized", {
|
|
522
|
-
|
|
523
|
-
|
|
583
|
+
// Nested Account interface
|
|
584
|
+
staker: {
|
|
585
|
+
args: {
|
|
586
|
+
commitment: type(commitmentInputType()),
|
|
587
|
+
dataSlice: type(dataSliceInputType()),
|
|
588
|
+
encoding: type(accountEncodingInputType()),
|
|
589
|
+
minContextSlot: bigint()
|
|
590
|
+
},
|
|
591
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
592
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.staker }, info),
|
|
593
|
+
type: accountInterface()
|
|
594
|
+
},
|
|
595
|
+
// Nested Account interface
|
|
596
|
+
withdrawer: {
|
|
597
|
+
args: {
|
|
598
|
+
commitment: type(commitmentInputType()),
|
|
599
|
+
dataSlice: type(dataSliceInputType()),
|
|
600
|
+
encoding: type(accountEncodingInputType()),
|
|
601
|
+
minContextSlot: bigint()
|
|
602
|
+
},
|
|
603
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
604
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.withdrawer }, info),
|
|
605
|
+
type: accountInterface()
|
|
606
|
+
}
|
|
524
607
|
}),
|
|
525
608
|
lockup: object("StakeMetaLockup", {
|
|
526
|
-
|
|
609
|
+
// Nested Account interface
|
|
610
|
+
custodian: {
|
|
611
|
+
args: {
|
|
612
|
+
commitment: type(commitmentInputType()),
|
|
613
|
+
dataSlice: type(dataSliceInputType()),
|
|
614
|
+
encoding: type(accountEncodingInputType()),
|
|
615
|
+
minContextSlot: bigint()
|
|
616
|
+
},
|
|
617
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
618
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.custodian }, info),
|
|
619
|
+
type: accountInterface()
|
|
620
|
+
},
|
|
527
621
|
epoch: bigint(),
|
|
528
622
|
unixTimestamp: bigint()
|
|
529
623
|
}),
|
|
@@ -535,7 +629,18 @@ var accountStakeAccount = () => {
|
|
|
535
629
|
activationEpoch: bigint(),
|
|
536
630
|
deactivationEpoch: bigint(),
|
|
537
631
|
stake: string(),
|
|
538
|
-
|
|
632
|
+
// Nested Account interface
|
|
633
|
+
voter: {
|
|
634
|
+
args: {
|
|
635
|
+
commitment: type(commitmentInputType()),
|
|
636
|
+
dataSlice: type(dataSliceInputType()),
|
|
637
|
+
encoding: type(accountEncodingInputType()),
|
|
638
|
+
minContextSlot: bigint()
|
|
639
|
+
},
|
|
640
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
641
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.voter }, info),
|
|
642
|
+
type: accountInterface()
|
|
643
|
+
},
|
|
539
644
|
warmupCooldownRate: number()
|
|
540
645
|
})
|
|
541
646
|
})
|
|
@@ -552,11 +657,33 @@ var accountVoteAccount = () => {
|
|
|
552
657
|
accountDataJsonParsed("Vote", {
|
|
553
658
|
authorizedVoters: list(
|
|
554
659
|
object("VoteAuthorizedVoter", {
|
|
555
|
-
|
|
660
|
+
// Nested Account interface
|
|
661
|
+
authorizedVoter: {
|
|
662
|
+
args: {
|
|
663
|
+
commitment: type(commitmentInputType()),
|
|
664
|
+
dataSlice: type(dataSliceInputType()),
|
|
665
|
+
encoding: type(accountEncodingInputType()),
|
|
666
|
+
minContextSlot: bigint()
|
|
667
|
+
},
|
|
668
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
669
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedVoter }, info),
|
|
670
|
+
type: accountInterface()
|
|
671
|
+
},
|
|
556
672
|
epoch: bigint()
|
|
557
673
|
})
|
|
558
674
|
),
|
|
559
|
-
|
|
675
|
+
// Nested Account interface
|
|
676
|
+
authorizedWithdrawer: {
|
|
677
|
+
args: {
|
|
678
|
+
commitment: type(commitmentInputType()),
|
|
679
|
+
dataSlice: type(dataSliceInputType()),
|
|
680
|
+
encoding: type(accountEncodingInputType()),
|
|
681
|
+
minContextSlot: bigint()
|
|
682
|
+
},
|
|
683
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
684
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedWithdrawer }, info),
|
|
685
|
+
type: accountInterface()
|
|
686
|
+
},
|
|
560
687
|
commission: number(),
|
|
561
688
|
epochCredits: list(
|
|
562
689
|
object("VoteEpochCredits", {
|
|
@@ -569,7 +696,18 @@ var accountVoteAccount = () => {
|
|
|
569
696
|
slot: bigint(),
|
|
570
697
|
timestamp: bigint()
|
|
571
698
|
}),
|
|
572
|
-
|
|
699
|
+
// Nested Account interface
|
|
700
|
+
node: {
|
|
701
|
+
args: {
|
|
702
|
+
commitment: type(commitmentInputType()),
|
|
703
|
+
dataSlice: type(dataSliceInputType()),
|
|
704
|
+
encoding: type(accountEncodingInputType()),
|
|
705
|
+
minContextSlot: bigint()
|
|
706
|
+
},
|
|
707
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
708
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.nodePubkey }, info),
|
|
709
|
+
type: accountInterface()
|
|
710
|
+
},
|
|
573
711
|
priorVoters: list(string()),
|
|
574
712
|
rootSlot: bigint(),
|
|
575
713
|
votes: list(
|
|
@@ -609,7 +747,8 @@ var accountQuery = () => ({
|
|
|
609
747
|
encoding: type(accountEncodingInputType()),
|
|
610
748
|
minContextSlot: bigint()
|
|
611
749
|
},
|
|
612
|
-
|
|
750
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
751
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
613
752
|
type: accountInterface()
|
|
614
753
|
}
|
|
615
754
|
});
|
|
@@ -2195,5 +2334,3 @@ function createRpcGraphQL(rpc) {
|
|
|
2195
2334
|
}
|
|
2196
2335
|
|
|
2197
2336
|
exports.createRpcGraphQL = createRpcGraphQL;
|
|
2198
|
-
//# sourceMappingURL=out.js.map
|
|
2199
|
-
//# sourceMappingURL=index.node.cjs.map
|