@solana/rpc-graphql 2.0.0-experimental.8c5ac55 → 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 +160 -33
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +160 -33
- package/dist/index.browser.js.map +1 -1
- package/dist/index.native.js +160 -33
- package/dist/index.native.js.map +1 -1
- package/dist/index.node.cjs +160 -33
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.js +160 -33
- package/dist/index.node.js.map +1 -1
- package/dist/types/context.d.ts +3 -2
- package/dist/types/schema/account/query.d.ts +1 -1
- package/dist/types/schema/program-accounts/query.d.ts +1 -1
- package/package.json +6 -6
- 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) {
|
|
@@ -89,13 +101,14 @@ async function resolveProgramAccounts({ programAddress, encoding = "jsonParsed",
|
|
|
89
101
|
}).catch((e) => {
|
|
90
102
|
throw e;
|
|
91
103
|
});
|
|
92
|
-
const queryResponse = programAccounts.map((
|
|
93
|
-
const [data, responseEncoding] = Array.isArray(
|
|
94
|
-
const pubkey =
|
|
95
|
-
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;
|
|
96
107
|
return {
|
|
97
|
-
account,
|
|
98
|
-
pubkey
|
|
108
|
+
...programAccount.account,
|
|
109
|
+
address: pubkey,
|
|
110
|
+
data,
|
|
111
|
+
encoding: responseEncoding
|
|
99
112
|
};
|
|
100
113
|
});
|
|
101
114
|
cache.insert(programAddress, requestConfig, queryResponse);
|
|
@@ -130,8 +143,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
130
143
|
const cache = createGraphQLCache();
|
|
131
144
|
return {
|
|
132
145
|
cache,
|
|
133
|
-
resolveAccount(args) {
|
|
134
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
146
|
+
resolveAccount(args, info) {
|
|
147
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
135
148
|
},
|
|
136
149
|
resolveBlock(args) {
|
|
137
150
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -273,7 +286,7 @@ var dataSliceInputType = () => {
|
|
|
273
286
|
length: number(),
|
|
274
287
|
offset: number()
|
|
275
288
|
},
|
|
276
|
-
name: "
|
|
289
|
+
name: "DataSlice"
|
|
277
290
|
});
|
|
278
291
|
return memoisedDataSliceInputType;
|
|
279
292
|
};
|
|
@@ -408,6 +421,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
408
421
|
fields: {
|
|
409
422
|
...accountInterfaceFields(),
|
|
410
423
|
data,
|
|
424
|
+
// Nested Account interface
|
|
411
425
|
owner: {
|
|
412
426
|
args: {
|
|
413
427
|
commitment: type(commitmentInputType()),
|
|
@@ -415,7 +429,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
415
429
|
encoding: type(accountEncodingInputType()),
|
|
416
430
|
minContextSlot: bigint()
|
|
417
431
|
},
|
|
418
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
432
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
419
433
|
type: accountInterface()
|
|
420
434
|
}
|
|
421
435
|
},
|
|
@@ -459,7 +473,18 @@ var accountNonceAccount = () => {
|
|
|
459
473
|
"NonceAccount",
|
|
460
474
|
"A nonce account",
|
|
461
475
|
accountDataJsonParsed("Nonce", {
|
|
462
|
-
|
|
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
|
+
},
|
|
463
488
|
blockhash: string(),
|
|
464
489
|
feeCalculator: object("NonceFeeCalculator", {
|
|
465
490
|
lamportsPerSignature: string()
|
|
@@ -476,7 +501,18 @@ var accountLookupTable = () => {
|
|
|
476
501
|
"An address lookup table account",
|
|
477
502
|
accountDataJsonParsed("LookupTable", {
|
|
478
503
|
addresses: list(string()),
|
|
479
|
-
|
|
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
|
+
},
|
|
480
516
|
deactivationSlot: string(),
|
|
481
517
|
lastExtendedSlot: string(),
|
|
482
518
|
lastExtendedSlotStartIndex: number()
|
|
@@ -494,7 +530,18 @@ var accountMint = () => {
|
|
|
494
530
|
decimals: number(),
|
|
495
531
|
freezeAuthority: string(),
|
|
496
532
|
isInitialized: boolean(),
|
|
497
|
-
|
|
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
|
+
},
|
|
498
545
|
supply: string()
|
|
499
546
|
})
|
|
500
547
|
);
|
|
@@ -509,7 +556,18 @@ var accountTokenAccount = () => {
|
|
|
509
556
|
accountDataJsonParsed("TokenAccount", {
|
|
510
557
|
isNative: boolean(),
|
|
511
558
|
mint: string(),
|
|
512
|
-
|
|
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
|
+
},
|
|
513
571
|
state: string(),
|
|
514
572
|
tokenAmount: type(tokenAmountType())
|
|
515
573
|
})
|
|
@@ -525,11 +583,44 @@ var accountStakeAccount = () => {
|
|
|
525
583
|
accountDataJsonParsed("Stake", {
|
|
526
584
|
meta: object("StakeMeta", {
|
|
527
585
|
authorized: object("StakeMetaAuthorized", {
|
|
528
|
-
|
|
529
|
-
|
|
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
|
+
}
|
|
530
610
|
}),
|
|
531
611
|
lockup: object("StakeMetaLockup", {
|
|
532
|
-
|
|
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
|
+
},
|
|
533
624
|
epoch: bigint(),
|
|
534
625
|
unixTimestamp: bigint()
|
|
535
626
|
}),
|
|
@@ -541,7 +632,18 @@ var accountStakeAccount = () => {
|
|
|
541
632
|
activationEpoch: bigint(),
|
|
542
633
|
deactivationEpoch: bigint(),
|
|
543
634
|
stake: string(),
|
|
544
|
-
|
|
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
|
+
},
|
|
545
647
|
warmupCooldownRate: number()
|
|
546
648
|
})
|
|
547
649
|
})
|
|
@@ -558,11 +660,33 @@ var accountVoteAccount = () => {
|
|
|
558
660
|
accountDataJsonParsed("Vote", {
|
|
559
661
|
authorizedVoters: list(
|
|
560
662
|
object("VoteAuthorizedVoter", {
|
|
561
|
-
|
|
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
|
+
},
|
|
562
675
|
epoch: bigint()
|
|
563
676
|
})
|
|
564
677
|
),
|
|
565
|
-
|
|
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
|
+
},
|
|
566
690
|
commission: number(),
|
|
567
691
|
epochCredits: list(
|
|
568
692
|
object("VoteEpochCredits", {
|
|
@@ -575,7 +699,18 @@ var accountVoteAccount = () => {
|
|
|
575
699
|
slot: bigint(),
|
|
576
700
|
timestamp: bigint()
|
|
577
701
|
}),
|
|
578
|
-
|
|
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
|
+
},
|
|
579
714
|
priorVoters: list(string()),
|
|
580
715
|
rootSlot: bigint(),
|
|
581
716
|
votes: list(
|
|
@@ -615,7 +750,8 @@ var accountQuery = () => ({
|
|
|
615
750
|
encoding: type(accountEncodingInputType()),
|
|
616
751
|
minContextSlot: bigint()
|
|
617
752
|
},
|
|
618
|
-
|
|
753
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
754
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
619
755
|
type: accountInterface()
|
|
620
756
|
}
|
|
621
757
|
});
|
|
@@ -2144,15 +2280,6 @@ var blockQuery = () => ({
|
|
|
2144
2280
|
type: blockInterface()
|
|
2145
2281
|
}
|
|
2146
2282
|
});
|
|
2147
|
-
var programAccount = () => new GraphQLObjectType({
|
|
2148
|
-
fields: {
|
|
2149
|
-
account: type(accountInterface()),
|
|
2150
|
-
pubkey: string()
|
|
2151
|
-
},
|
|
2152
|
-
name: "ProgramAccount"
|
|
2153
|
-
});
|
|
2154
|
-
|
|
2155
|
-
// src/schema/program-accounts/query.ts
|
|
2156
2283
|
var programAccountsQuery = () => ({
|
|
2157
2284
|
programAccounts: {
|
|
2158
2285
|
args: {
|
|
@@ -2165,7 +2292,7 @@ var programAccountsQuery = () => ({
|
|
|
2165
2292
|
withContext: string()
|
|
2166
2293
|
},
|
|
2167
2294
|
resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
|
|
2168
|
-
type: new GraphQLList(
|
|
2295
|
+
type: new GraphQLList(accountInterface())
|
|
2169
2296
|
}
|
|
2170
2297
|
});
|
|
2171
2298
|
|