@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.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) {
|
|
@@ -91,13 +103,14 @@ async function resolveProgramAccounts({ programAddress, encoding = "jsonParsed",
|
|
|
91
103
|
}).catch((e) => {
|
|
92
104
|
throw e;
|
|
93
105
|
});
|
|
94
|
-
const queryResponse = programAccounts.map((
|
|
95
|
-
const [data, responseEncoding] = Array.isArray(
|
|
96
|
-
const pubkey =
|
|
97
|
-
const account = { ...programAccount2.account, data, encoding: responseEncoding };
|
|
106
|
+
const queryResponse = programAccounts.map((programAccount) => {
|
|
107
|
+
const [data, responseEncoding] = Array.isArray(programAccount.account.data) ? encoding === "jsonParsed" ? [programAccount.account.data[0], "base64"] : [programAccount.account.data[0], encoding] : [programAccount.account.data, "jsonParsed"];
|
|
108
|
+
const pubkey = programAccount.pubkey;
|
|
98
109
|
return {
|
|
99
|
-
account,
|
|
100
|
-
pubkey
|
|
110
|
+
...programAccount.account,
|
|
111
|
+
address: pubkey,
|
|
112
|
+
data,
|
|
113
|
+
encoding: responseEncoding
|
|
101
114
|
};
|
|
102
115
|
});
|
|
103
116
|
cache.insert(programAddress, requestConfig, queryResponse);
|
|
@@ -132,8 +145,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
132
145
|
const cache = createGraphQLCache();
|
|
133
146
|
return {
|
|
134
147
|
cache,
|
|
135
|
-
resolveAccount(args) {
|
|
136
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
148
|
+
resolveAccount(args, info) {
|
|
149
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
137
150
|
},
|
|
138
151
|
resolveBlock(args) {
|
|
139
152
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -275,7 +288,7 @@ var dataSliceInputType = () => {
|
|
|
275
288
|
length: number(),
|
|
276
289
|
offset: number()
|
|
277
290
|
},
|
|
278
|
-
name: "
|
|
291
|
+
name: "DataSlice"
|
|
279
292
|
});
|
|
280
293
|
return memoisedDataSliceInputType;
|
|
281
294
|
};
|
|
@@ -410,6 +423,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
410
423
|
fields: {
|
|
411
424
|
...accountInterfaceFields(),
|
|
412
425
|
data,
|
|
426
|
+
// Nested Account interface
|
|
413
427
|
owner: {
|
|
414
428
|
args: {
|
|
415
429
|
commitment: type(commitmentInputType()),
|
|
@@ -417,7 +431,7 @@ var accountType = (name, description, data) => new graphql.GraphQLObjectType({
|
|
|
417
431
|
encoding: type(accountEncodingInputType()),
|
|
418
432
|
minContextSlot: bigint()
|
|
419
433
|
},
|
|
420
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
434
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
421
435
|
type: accountInterface()
|
|
422
436
|
}
|
|
423
437
|
},
|
|
@@ -461,7 +475,18 @@ var accountNonceAccount = () => {
|
|
|
461
475
|
"NonceAccount",
|
|
462
476
|
"A nonce account",
|
|
463
477
|
accountDataJsonParsed("Nonce", {
|
|
464
|
-
|
|
478
|
+
// Nested Account interface
|
|
479
|
+
authority: {
|
|
480
|
+
args: {
|
|
481
|
+
commitment: type(commitmentInputType()),
|
|
482
|
+
dataSlice: type(dataSliceInputType()),
|
|
483
|
+
encoding: type(accountEncodingInputType()),
|
|
484
|
+
minContextSlot: bigint()
|
|
485
|
+
},
|
|
486
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
487
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
488
|
+
type: accountInterface()
|
|
489
|
+
},
|
|
465
490
|
blockhash: string(),
|
|
466
491
|
feeCalculator: object("NonceFeeCalculator", {
|
|
467
492
|
lamportsPerSignature: string()
|
|
@@ -478,7 +503,18 @@ var accountLookupTable = () => {
|
|
|
478
503
|
"An address lookup table account",
|
|
479
504
|
accountDataJsonParsed("LookupTable", {
|
|
480
505
|
addresses: list(string()),
|
|
481
|
-
|
|
506
|
+
// Nested Account interface
|
|
507
|
+
authority: {
|
|
508
|
+
args: {
|
|
509
|
+
commitment: type(commitmentInputType()),
|
|
510
|
+
dataSlice: type(dataSliceInputType()),
|
|
511
|
+
encoding: type(accountEncodingInputType()),
|
|
512
|
+
minContextSlot: bigint()
|
|
513
|
+
},
|
|
514
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
515
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
516
|
+
type: accountInterface()
|
|
517
|
+
},
|
|
482
518
|
deactivationSlot: string(),
|
|
483
519
|
lastExtendedSlot: string(),
|
|
484
520
|
lastExtendedSlotStartIndex: number()
|
|
@@ -496,7 +532,18 @@ var accountMint = () => {
|
|
|
496
532
|
decimals: number(),
|
|
497
533
|
freezeAuthority: string(),
|
|
498
534
|
isInitialized: boolean(),
|
|
499
|
-
|
|
535
|
+
// Nested Account interface
|
|
536
|
+
mintAuthority: {
|
|
537
|
+
args: {
|
|
538
|
+
commitment: type(commitmentInputType()),
|
|
539
|
+
dataSlice: type(dataSliceInputType()),
|
|
540
|
+
encoding: type(accountEncodingInputType()),
|
|
541
|
+
minContextSlot: bigint()
|
|
542
|
+
},
|
|
543
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
544
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.mintAuthority }, info),
|
|
545
|
+
type: accountInterface()
|
|
546
|
+
},
|
|
500
547
|
supply: string()
|
|
501
548
|
})
|
|
502
549
|
);
|
|
@@ -511,7 +558,18 @@ var accountTokenAccount = () => {
|
|
|
511
558
|
accountDataJsonParsed("TokenAccount", {
|
|
512
559
|
isNative: boolean(),
|
|
513
560
|
mint: string(),
|
|
514
|
-
|
|
561
|
+
// Nested Account interface
|
|
562
|
+
owner: {
|
|
563
|
+
args: {
|
|
564
|
+
commitment: type(commitmentInputType()),
|
|
565
|
+
dataSlice: type(dataSliceInputType()),
|
|
566
|
+
encoding: type(accountEncodingInputType()),
|
|
567
|
+
minContextSlot: bigint()
|
|
568
|
+
},
|
|
569
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
570
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
571
|
+
type: accountInterface()
|
|
572
|
+
},
|
|
515
573
|
state: string(),
|
|
516
574
|
tokenAmount: type(tokenAmountType())
|
|
517
575
|
})
|
|
@@ -527,11 +585,44 @@ var accountStakeAccount = () => {
|
|
|
527
585
|
accountDataJsonParsed("Stake", {
|
|
528
586
|
meta: object("StakeMeta", {
|
|
529
587
|
authorized: object("StakeMetaAuthorized", {
|
|
530
|
-
|
|
531
|
-
|
|
588
|
+
// Nested Account interface
|
|
589
|
+
staker: {
|
|
590
|
+
args: {
|
|
591
|
+
commitment: type(commitmentInputType()),
|
|
592
|
+
dataSlice: type(dataSliceInputType()),
|
|
593
|
+
encoding: type(accountEncodingInputType()),
|
|
594
|
+
minContextSlot: bigint()
|
|
595
|
+
},
|
|
596
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
597
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.staker }, info),
|
|
598
|
+
type: accountInterface()
|
|
599
|
+
},
|
|
600
|
+
// Nested Account interface
|
|
601
|
+
withdrawer: {
|
|
602
|
+
args: {
|
|
603
|
+
commitment: type(commitmentInputType()),
|
|
604
|
+
dataSlice: type(dataSliceInputType()),
|
|
605
|
+
encoding: type(accountEncodingInputType()),
|
|
606
|
+
minContextSlot: bigint()
|
|
607
|
+
},
|
|
608
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.withdrawer }, info),
|
|
610
|
+
type: accountInterface()
|
|
611
|
+
}
|
|
532
612
|
}),
|
|
533
613
|
lockup: object("StakeMetaLockup", {
|
|
534
|
-
|
|
614
|
+
// Nested Account interface
|
|
615
|
+
custodian: {
|
|
616
|
+
args: {
|
|
617
|
+
commitment: type(commitmentInputType()),
|
|
618
|
+
dataSlice: type(dataSliceInputType()),
|
|
619
|
+
encoding: type(accountEncodingInputType()),
|
|
620
|
+
minContextSlot: bigint()
|
|
621
|
+
},
|
|
622
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
623
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.custodian }, info),
|
|
624
|
+
type: accountInterface()
|
|
625
|
+
},
|
|
535
626
|
epoch: bigint(),
|
|
536
627
|
unixTimestamp: bigint()
|
|
537
628
|
}),
|
|
@@ -543,7 +634,18 @@ var accountStakeAccount = () => {
|
|
|
543
634
|
activationEpoch: bigint(),
|
|
544
635
|
deactivationEpoch: bigint(),
|
|
545
636
|
stake: string(),
|
|
546
|
-
|
|
637
|
+
// Nested Account interface
|
|
638
|
+
voter: {
|
|
639
|
+
args: {
|
|
640
|
+
commitment: type(commitmentInputType()),
|
|
641
|
+
dataSlice: type(dataSliceInputType()),
|
|
642
|
+
encoding: type(accountEncodingInputType()),
|
|
643
|
+
minContextSlot: bigint()
|
|
644
|
+
},
|
|
645
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
646
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.voter }, info),
|
|
647
|
+
type: accountInterface()
|
|
648
|
+
},
|
|
547
649
|
warmupCooldownRate: number()
|
|
548
650
|
})
|
|
549
651
|
})
|
|
@@ -560,11 +662,33 @@ var accountVoteAccount = () => {
|
|
|
560
662
|
accountDataJsonParsed("Vote", {
|
|
561
663
|
authorizedVoters: list(
|
|
562
664
|
object("VoteAuthorizedVoter", {
|
|
563
|
-
|
|
665
|
+
// Nested Account interface
|
|
666
|
+
authorizedVoter: {
|
|
667
|
+
args: {
|
|
668
|
+
commitment: type(commitmentInputType()),
|
|
669
|
+
dataSlice: type(dataSliceInputType()),
|
|
670
|
+
encoding: type(accountEncodingInputType()),
|
|
671
|
+
minContextSlot: bigint()
|
|
672
|
+
},
|
|
673
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
674
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedVoter }, info),
|
|
675
|
+
type: accountInterface()
|
|
676
|
+
},
|
|
564
677
|
epoch: bigint()
|
|
565
678
|
})
|
|
566
679
|
),
|
|
567
|
-
|
|
680
|
+
// Nested Account interface
|
|
681
|
+
authorizedWithdrawer: {
|
|
682
|
+
args: {
|
|
683
|
+
commitment: type(commitmentInputType()),
|
|
684
|
+
dataSlice: type(dataSliceInputType()),
|
|
685
|
+
encoding: type(accountEncodingInputType()),
|
|
686
|
+
minContextSlot: bigint()
|
|
687
|
+
},
|
|
688
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
689
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedWithdrawer }, info),
|
|
690
|
+
type: accountInterface()
|
|
691
|
+
},
|
|
568
692
|
commission: number(),
|
|
569
693
|
epochCredits: list(
|
|
570
694
|
object("VoteEpochCredits", {
|
|
@@ -577,7 +701,18 @@ var accountVoteAccount = () => {
|
|
|
577
701
|
slot: bigint(),
|
|
578
702
|
timestamp: bigint()
|
|
579
703
|
}),
|
|
580
|
-
|
|
704
|
+
// Nested Account interface
|
|
705
|
+
node: {
|
|
706
|
+
args: {
|
|
707
|
+
commitment: type(commitmentInputType()),
|
|
708
|
+
dataSlice: type(dataSliceInputType()),
|
|
709
|
+
encoding: type(accountEncodingInputType()),
|
|
710
|
+
minContextSlot: bigint()
|
|
711
|
+
},
|
|
712
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
713
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.nodePubkey }, info),
|
|
714
|
+
type: accountInterface()
|
|
715
|
+
},
|
|
581
716
|
priorVoters: list(string()),
|
|
582
717
|
rootSlot: bigint(),
|
|
583
718
|
votes: list(
|
|
@@ -617,7 +752,8 @@ var accountQuery = () => ({
|
|
|
617
752
|
encoding: type(accountEncodingInputType()),
|
|
618
753
|
minContextSlot: bigint()
|
|
619
754
|
},
|
|
620
|
-
|
|
755
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
756
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
621
757
|
type: accountInterface()
|
|
622
758
|
}
|
|
623
759
|
});
|
|
@@ -2146,15 +2282,6 @@ var blockQuery = () => ({
|
|
|
2146
2282
|
type: blockInterface()
|
|
2147
2283
|
}
|
|
2148
2284
|
});
|
|
2149
|
-
var programAccount = () => new graphql.GraphQLObjectType({
|
|
2150
|
-
fields: {
|
|
2151
|
-
account: type(accountInterface()),
|
|
2152
|
-
pubkey: string()
|
|
2153
|
-
},
|
|
2154
|
-
name: "ProgramAccount"
|
|
2155
|
-
});
|
|
2156
|
-
|
|
2157
|
-
// src/schema/program-accounts/query.ts
|
|
2158
2285
|
var programAccountsQuery = () => ({
|
|
2159
2286
|
programAccounts: {
|
|
2160
2287
|
args: {
|
|
@@ -2167,7 +2294,7 @@ var programAccountsQuery = () => ({
|
|
|
2167
2294
|
withContext: string()
|
|
2168
2295
|
},
|
|
2169
2296
|
resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
|
|
2170
|
-
type: new graphql.GraphQLList(
|
|
2297
|
+
type: new graphql.GraphQLList(accountInterface())
|
|
2171
2298
|
}
|
|
2172
2299
|
});
|
|
2173
2300
|
|