@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.native.js
CHANGED
|
@@ -34,7 +34,19 @@ function createGraphQLCache() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// src/context.ts
|
|
37
|
-
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc) {
|
|
37
|
+
async function resolveAccount({ address, encoding = "jsonParsed", ...config }, cache, rpc, info) {
|
|
38
|
+
if (info && info.fieldNodes[0].selectionSet) {
|
|
39
|
+
const selectionSet = info.fieldNodes[0].selectionSet;
|
|
40
|
+
const requestedFields = selectionSet.selections.map((field) => {
|
|
41
|
+
if (field.kind === "Field") {
|
|
42
|
+
return field.name.value;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
});
|
|
46
|
+
if (requestedFields && requestedFields.length === 1 && requestedFields[0] === "address") {
|
|
47
|
+
return { address };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
38
50
|
const requestConfig = { encoding, ...config };
|
|
39
51
|
const cached = cache.get(address, requestConfig);
|
|
40
52
|
if (cached !== null) {
|
|
@@ -85,13 +97,14 @@ async function resolveProgramAccounts({ programAddress, encoding = "jsonParsed",
|
|
|
85
97
|
}).catch((e) => {
|
|
86
98
|
throw e;
|
|
87
99
|
});
|
|
88
|
-
const queryResponse = programAccounts.map((
|
|
89
|
-
const [data, responseEncoding] = Array.isArray(
|
|
90
|
-
const pubkey =
|
|
91
|
-
const account = { ...programAccount2.account, data, encoding: responseEncoding };
|
|
100
|
+
const queryResponse = programAccounts.map((programAccount) => {
|
|
101
|
+
const [data, responseEncoding] = Array.isArray(programAccount.account.data) ? encoding === "jsonParsed" ? [programAccount.account.data[0], "base64"] : [programAccount.account.data[0], encoding] : [programAccount.account.data, "jsonParsed"];
|
|
102
|
+
const pubkey = programAccount.pubkey;
|
|
92
103
|
return {
|
|
93
|
-
account,
|
|
94
|
-
pubkey
|
|
104
|
+
...programAccount.account,
|
|
105
|
+
address: pubkey,
|
|
106
|
+
data,
|
|
107
|
+
encoding: responseEncoding
|
|
95
108
|
};
|
|
96
109
|
});
|
|
97
110
|
cache.insert(programAddress, requestConfig, queryResponse);
|
|
@@ -126,8 +139,8 @@ function createSolanaGraphQLContext(rpc) {
|
|
|
126
139
|
const cache = createGraphQLCache();
|
|
127
140
|
return {
|
|
128
141
|
cache,
|
|
129
|
-
resolveAccount(args) {
|
|
130
|
-
return resolveAccount(args, this.cache, this.rpc);
|
|
142
|
+
resolveAccount(args, info) {
|
|
143
|
+
return resolveAccount(args, this.cache, this.rpc, info);
|
|
131
144
|
},
|
|
132
145
|
resolveBlock(args) {
|
|
133
146
|
return resolveBlock(args, this.cache, this.rpc);
|
|
@@ -269,7 +282,7 @@ var dataSliceInputType = () => {
|
|
|
269
282
|
length: number(),
|
|
270
283
|
offset: number()
|
|
271
284
|
},
|
|
272
|
-
name: "
|
|
285
|
+
name: "DataSlice"
|
|
273
286
|
});
|
|
274
287
|
return memoisedDataSliceInputType;
|
|
275
288
|
};
|
|
@@ -404,6 +417,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
404
417
|
fields: {
|
|
405
418
|
...accountInterfaceFields(),
|
|
406
419
|
data,
|
|
420
|
+
// Nested Account interface
|
|
407
421
|
owner: {
|
|
408
422
|
args: {
|
|
409
423
|
commitment: type(commitmentInputType()),
|
|
@@ -411,7 +425,7 @@ var accountType = (name, description, data) => new GraphQLObjectType({
|
|
|
411
425
|
encoding: type(accountEncodingInputType()),
|
|
412
426
|
minContextSlot: bigint()
|
|
413
427
|
},
|
|
414
|
-
resolve: (parent, args, context) => context.resolveAccount({ ...args, address: parent.owner }),
|
|
428
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
415
429
|
type: accountInterface()
|
|
416
430
|
}
|
|
417
431
|
},
|
|
@@ -455,7 +469,18 @@ var accountNonceAccount = () => {
|
|
|
455
469
|
"NonceAccount",
|
|
456
470
|
"A nonce account",
|
|
457
471
|
accountDataJsonParsed("Nonce", {
|
|
458
|
-
|
|
472
|
+
// Nested Account interface
|
|
473
|
+
authority: {
|
|
474
|
+
args: {
|
|
475
|
+
commitment: type(commitmentInputType()),
|
|
476
|
+
dataSlice: type(dataSliceInputType()),
|
|
477
|
+
encoding: type(accountEncodingInputType()),
|
|
478
|
+
minContextSlot: bigint()
|
|
479
|
+
},
|
|
480
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
481
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
482
|
+
type: accountInterface()
|
|
483
|
+
},
|
|
459
484
|
blockhash: string(),
|
|
460
485
|
feeCalculator: object("NonceFeeCalculator", {
|
|
461
486
|
lamportsPerSignature: string()
|
|
@@ -472,7 +497,18 @@ var accountLookupTable = () => {
|
|
|
472
497
|
"An address lookup table account",
|
|
473
498
|
accountDataJsonParsed("LookupTable", {
|
|
474
499
|
addresses: list(string()),
|
|
475
|
-
|
|
500
|
+
// Nested Account interface
|
|
501
|
+
authority: {
|
|
502
|
+
args: {
|
|
503
|
+
commitment: type(commitmentInputType()),
|
|
504
|
+
dataSlice: type(dataSliceInputType()),
|
|
505
|
+
encoding: type(accountEncodingInputType()),
|
|
506
|
+
minContextSlot: bigint()
|
|
507
|
+
},
|
|
508
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
509
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authority }, info),
|
|
510
|
+
type: accountInterface()
|
|
511
|
+
},
|
|
476
512
|
deactivationSlot: string(),
|
|
477
513
|
lastExtendedSlot: string(),
|
|
478
514
|
lastExtendedSlotStartIndex: number()
|
|
@@ -490,7 +526,18 @@ var accountMint = () => {
|
|
|
490
526
|
decimals: number(),
|
|
491
527
|
freezeAuthority: string(),
|
|
492
528
|
isInitialized: boolean(),
|
|
493
|
-
|
|
529
|
+
// Nested Account interface
|
|
530
|
+
mintAuthority: {
|
|
531
|
+
args: {
|
|
532
|
+
commitment: type(commitmentInputType()),
|
|
533
|
+
dataSlice: type(dataSliceInputType()),
|
|
534
|
+
encoding: type(accountEncodingInputType()),
|
|
535
|
+
minContextSlot: bigint()
|
|
536
|
+
},
|
|
537
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
538
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.mintAuthority }, info),
|
|
539
|
+
type: accountInterface()
|
|
540
|
+
},
|
|
494
541
|
supply: string()
|
|
495
542
|
})
|
|
496
543
|
);
|
|
@@ -505,7 +552,18 @@ var accountTokenAccount = () => {
|
|
|
505
552
|
accountDataJsonParsed("TokenAccount", {
|
|
506
553
|
isNative: boolean(),
|
|
507
554
|
mint: string(),
|
|
508
|
-
|
|
555
|
+
// Nested Account interface
|
|
556
|
+
owner: {
|
|
557
|
+
args: {
|
|
558
|
+
commitment: type(commitmentInputType()),
|
|
559
|
+
dataSlice: type(dataSliceInputType()),
|
|
560
|
+
encoding: type(accountEncodingInputType()),
|
|
561
|
+
minContextSlot: bigint()
|
|
562
|
+
},
|
|
563
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
564
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.owner }, info),
|
|
565
|
+
type: accountInterface()
|
|
566
|
+
},
|
|
509
567
|
state: string(),
|
|
510
568
|
tokenAmount: type(tokenAmountType())
|
|
511
569
|
})
|
|
@@ -521,11 +579,44 @@ var accountStakeAccount = () => {
|
|
|
521
579
|
accountDataJsonParsed("Stake", {
|
|
522
580
|
meta: object("StakeMeta", {
|
|
523
581
|
authorized: object("StakeMetaAuthorized", {
|
|
524
|
-
|
|
525
|
-
|
|
582
|
+
// Nested Account interface
|
|
583
|
+
staker: {
|
|
584
|
+
args: {
|
|
585
|
+
commitment: type(commitmentInputType()),
|
|
586
|
+
dataSlice: type(dataSliceInputType()),
|
|
587
|
+
encoding: type(accountEncodingInputType()),
|
|
588
|
+
minContextSlot: bigint()
|
|
589
|
+
},
|
|
590
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
591
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.staker }, info),
|
|
592
|
+
type: accountInterface()
|
|
593
|
+
},
|
|
594
|
+
// Nested Account interface
|
|
595
|
+
withdrawer: {
|
|
596
|
+
args: {
|
|
597
|
+
commitment: type(commitmentInputType()),
|
|
598
|
+
dataSlice: type(dataSliceInputType()),
|
|
599
|
+
encoding: type(accountEncodingInputType()),
|
|
600
|
+
minContextSlot: bigint()
|
|
601
|
+
},
|
|
602
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
603
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.withdrawer }, info),
|
|
604
|
+
type: accountInterface()
|
|
605
|
+
}
|
|
526
606
|
}),
|
|
527
607
|
lockup: object("StakeMetaLockup", {
|
|
528
|
-
|
|
608
|
+
// Nested Account interface
|
|
609
|
+
custodian: {
|
|
610
|
+
args: {
|
|
611
|
+
commitment: type(commitmentInputType()),
|
|
612
|
+
dataSlice: type(dataSliceInputType()),
|
|
613
|
+
encoding: type(accountEncodingInputType()),
|
|
614
|
+
minContextSlot: bigint()
|
|
615
|
+
},
|
|
616
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
617
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.custodian }, info),
|
|
618
|
+
type: accountInterface()
|
|
619
|
+
},
|
|
529
620
|
epoch: bigint(),
|
|
530
621
|
unixTimestamp: bigint()
|
|
531
622
|
}),
|
|
@@ -537,7 +628,18 @@ var accountStakeAccount = () => {
|
|
|
537
628
|
activationEpoch: bigint(),
|
|
538
629
|
deactivationEpoch: bigint(),
|
|
539
630
|
stake: string(),
|
|
540
|
-
|
|
631
|
+
// Nested Account interface
|
|
632
|
+
voter: {
|
|
633
|
+
args: {
|
|
634
|
+
commitment: type(commitmentInputType()),
|
|
635
|
+
dataSlice: type(dataSliceInputType()),
|
|
636
|
+
encoding: type(accountEncodingInputType()),
|
|
637
|
+
minContextSlot: bigint()
|
|
638
|
+
},
|
|
639
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
640
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.voter }, info),
|
|
641
|
+
type: accountInterface()
|
|
642
|
+
},
|
|
541
643
|
warmupCooldownRate: number()
|
|
542
644
|
})
|
|
543
645
|
})
|
|
@@ -554,11 +656,33 @@ var accountVoteAccount = () => {
|
|
|
554
656
|
accountDataJsonParsed("Vote", {
|
|
555
657
|
authorizedVoters: list(
|
|
556
658
|
object("VoteAuthorizedVoter", {
|
|
557
|
-
|
|
659
|
+
// Nested Account interface
|
|
660
|
+
authorizedVoter: {
|
|
661
|
+
args: {
|
|
662
|
+
commitment: type(commitmentInputType()),
|
|
663
|
+
dataSlice: type(dataSliceInputType()),
|
|
664
|
+
encoding: type(accountEncodingInputType()),
|
|
665
|
+
minContextSlot: bigint()
|
|
666
|
+
},
|
|
667
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
668
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedVoter }, info),
|
|
669
|
+
type: accountInterface()
|
|
670
|
+
},
|
|
558
671
|
epoch: bigint()
|
|
559
672
|
})
|
|
560
673
|
),
|
|
561
|
-
|
|
674
|
+
// Nested Account interface
|
|
675
|
+
authorizedWithdrawer: {
|
|
676
|
+
args: {
|
|
677
|
+
commitment: type(commitmentInputType()),
|
|
678
|
+
dataSlice: type(dataSliceInputType()),
|
|
679
|
+
encoding: type(accountEncodingInputType()),
|
|
680
|
+
minContextSlot: bigint()
|
|
681
|
+
},
|
|
682
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
683
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.authorizedWithdrawer }, info),
|
|
684
|
+
type: accountInterface()
|
|
685
|
+
},
|
|
562
686
|
commission: number(),
|
|
563
687
|
epochCredits: list(
|
|
564
688
|
object("VoteEpochCredits", {
|
|
@@ -571,7 +695,18 @@ var accountVoteAccount = () => {
|
|
|
571
695
|
slot: bigint(),
|
|
572
696
|
timestamp: bigint()
|
|
573
697
|
}),
|
|
574
|
-
|
|
698
|
+
// Nested Account interface
|
|
699
|
+
node: {
|
|
700
|
+
args: {
|
|
701
|
+
commitment: type(commitmentInputType()),
|
|
702
|
+
dataSlice: type(dataSliceInputType()),
|
|
703
|
+
encoding: type(accountEncodingInputType()),
|
|
704
|
+
minContextSlot: bigint()
|
|
705
|
+
},
|
|
706
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
707
|
+
resolve: (parent, args, context, info) => context.resolveAccount({ ...args, address: parent.nodePubkey }, info),
|
|
708
|
+
type: accountInterface()
|
|
709
|
+
},
|
|
575
710
|
priorVoters: list(string()),
|
|
576
711
|
rootSlot: bigint(),
|
|
577
712
|
votes: list(
|
|
@@ -611,7 +746,8 @@ var accountQuery = () => ({
|
|
|
611
746
|
encoding: type(accountEncodingInputType()),
|
|
612
747
|
minContextSlot: bigint()
|
|
613
748
|
},
|
|
614
|
-
|
|
749
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
750
|
+
resolve: (_parent, args, context, info) => context.resolveAccount(args, info),
|
|
615
751
|
type: accountInterface()
|
|
616
752
|
}
|
|
617
753
|
});
|
|
@@ -2140,15 +2276,6 @@ var blockQuery = () => ({
|
|
|
2140
2276
|
type: blockInterface()
|
|
2141
2277
|
}
|
|
2142
2278
|
});
|
|
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
2279
|
var programAccountsQuery = () => ({
|
|
2153
2280
|
programAccounts: {
|
|
2154
2281
|
args: {
|
|
@@ -2161,7 +2288,7 @@ var programAccountsQuery = () => ({
|
|
|
2161
2288
|
withContext: string()
|
|
2162
2289
|
},
|
|
2163
2290
|
resolve: (_parent, args, context) => context.resolveProgramAccounts(args),
|
|
2164
|
-
type: new GraphQLList(
|
|
2291
|
+
type: new GraphQLList(accountInterface())
|
|
2165
2292
|
}
|
|
2166
2293
|
});
|
|
2167
2294
|
|