@solana/rpc-graphql 2.0.0-experimental.fbd3974 → 2.0.0-experimental.fcff844

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.
Files changed (82) hide show
  1. package/README.md +193 -277
  2. package/dist/index.browser.cjs +2370 -4782
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +2357 -4774
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.native.js +2357 -4770
  7. package/dist/index.native.js.map +1 -1
  8. package/dist/index.node.cjs +2361 -4769
  9. package/dist/index.node.cjs.map +1 -1
  10. package/dist/index.node.js +2357 -4770
  11. package/dist/index.node.js.map +1 -1
  12. package/dist/types/context.d.ts +17 -16
  13. package/dist/types/context.d.ts.map +1 -1
  14. package/dist/types/loaders/account.d.ts +7 -0
  15. package/dist/types/loaders/account.d.ts.map +1 -0
  16. package/dist/types/loaders/block.d.ts +7 -0
  17. package/dist/types/loaders/block.d.ts.map +1 -0
  18. package/dist/types/loaders/common/resolve-info.d.ts +3 -0
  19. package/dist/types/loaders/common/resolve-info.d.ts.map +1 -0
  20. package/dist/types/loaders/program-accounts.d.ts +9 -0
  21. package/dist/types/loaders/program-accounts.d.ts.map +1 -0
  22. package/dist/types/loaders/transaction.d.ts +7 -0
  23. package/dist/types/loaders/transaction.d.ts.map +1 -0
  24. package/dist/types/loaders/transformers/account.d.ts +8 -0
  25. package/dist/types/loaders/transformers/account.d.ts.map +1 -0
  26. package/dist/types/loaders/transformers/block.d.ts +6 -0
  27. package/dist/types/loaders/transformers/block.d.ts.map +1 -0
  28. package/dist/types/loaders/transformers/transaction.d.ts +5 -0
  29. package/dist/types/loaders/transformers/transaction.d.ts.map +1 -0
  30. package/dist/types/resolvers/account.d.ts +8 -0
  31. package/dist/types/resolvers/account.d.ts.map +1 -0
  32. package/dist/types/rpc.d.ts +5 -3
  33. package/dist/types/rpc.d.ts.map +1 -1
  34. package/dist/types/schema/account.d.ts +112 -0
  35. package/dist/types/schema/account.d.ts.map +1 -0
  36. package/dist/types/schema/block.d.ts +17 -0
  37. package/dist/types/schema/block.d.ts.map +1 -0
  38. package/dist/types/schema/common/inputs.d.ts +3 -0
  39. package/dist/types/schema/common/inputs.d.ts.map +1 -0
  40. package/dist/types/schema/common/scalars.d.ts +45 -0
  41. package/dist/types/schema/common/scalars.d.ts.map +1 -0
  42. package/dist/types/schema/common/types.d.ts +27 -0
  43. package/dist/types/schema/common/types.d.ts.map +1 -0
  44. package/dist/types/schema/index.d.ts +2 -0
  45. package/dist/types/schema/index.d.ts.map +1 -0
  46. package/dist/types/schema/instruction.d.ts +949 -0
  47. package/dist/types/schema/instruction.d.ts.map +1 -0
  48. package/dist/types/schema/program-accounts.d.ts +12 -0
  49. package/dist/types/schema/program-accounts.d.ts.map +1 -0
  50. package/dist/types/schema/transaction.d.ts +16 -0
  51. package/dist/types/schema/transaction.d.ts.map +1 -0
  52. package/package.json +14 -10
  53. package/dist/types/cache.d.ts +0 -7
  54. package/dist/types/cache.d.ts.map +0 -1
  55. package/dist/types/schema/account/index.d.ts +0 -3
  56. package/dist/types/schema/account/index.d.ts.map +0 -1
  57. package/dist/types/schema/account/query.d.ts +0 -38
  58. package/dist/types/schema/account/query.d.ts.map +0 -1
  59. package/dist/types/schema/account/types.d.ts +0 -5
  60. package/dist/types/schema/account/types.d.ts.map +0 -1
  61. package/dist/types/schema/block/index.d.ts +0 -3
  62. package/dist/types/schema/block/index.d.ts.map +0 -1
  63. package/dist/types/schema/block/query.d.ts +0 -42
  64. package/dist/types/schema/block/query.d.ts.map +0 -1
  65. package/dist/types/schema/block/types.d.ts +0 -7
  66. package/dist/types/schema/block/types.d.ts.map +0 -1
  67. package/dist/types/schema/inputs.d.ts +0 -9
  68. package/dist/types/schema/inputs.d.ts.map +0 -1
  69. package/dist/types/schema/picks.d.ts +0 -36
  70. package/dist/types/schema/picks.d.ts.map +0 -1
  71. package/dist/types/schema/program-accounts/index.d.ts +0 -2
  72. package/dist/types/schema/program-accounts/index.d.ts.map +0 -1
  73. package/dist/types/schema/program-accounts/query.d.ts +0 -47
  74. package/dist/types/schema/program-accounts/query.d.ts.map +0 -1
  75. package/dist/types/schema/scalars.d.ts +0 -3
  76. package/dist/types/schema/scalars.d.ts.map +0 -1
  77. package/dist/types/schema/transaction/index.d.ts +0 -3
  78. package/dist/types/schema/transaction/index.d.ts.map +0 -1
  79. package/dist/types/schema/transaction/query.d.ts +0 -33
  80. package/dist/types/schema/transaction/query.d.ts.map +0 -1
  81. package/dist/types/schema/transaction/types.d.ts +0 -12
  82. package/dist/types/schema/transaction/types.d.ts.map +0 -1
package/README.md CHANGED
@@ -130,11 +130,12 @@ The `Account` interface contains common fields across all accounts.
130
130
 
131
131
  ```graphql
132
132
  interface Account {
133
- encoding: String,
134
- executable: Boolean,
135
- lamports: BigInt,
136
- owner: Account, # Interface
137
- rentEpoch: BigInt,
133
+ address: String
134
+ encoding: String
135
+ executable: Boolean
136
+ lamports: BigInt
137
+ owner: Account
138
+ rentEpoch: BigInt
138
139
  }
139
140
  ```
140
141
 
@@ -202,14 +203,10 @@ const source = `
202
203
  account(address: $address) {
203
204
  ... on MintAccount {
204
205
  data {
205
- parsed {
206
- info {
207
- decimals
208
- isInitialized
209
- mintAuthority
210
- supply
211
- }
212
- }
206
+ decimals
207
+ isInitialized
208
+ mintAuthority
209
+ supply
213
210
  }
214
211
  }
215
212
  }
@@ -222,9 +219,7 @@ for (const address of maybeMintAddresses) {
222
219
  const {
223
220
  data: {
224
221
  account: {
225
- data: {
226
- parsed: { info: mintInfo },
227
- },
222
+ data: mintInfo,
228
223
  },
229
224
  },
230
225
  } = result;
@@ -251,26 +246,22 @@ const source = `
251
246
  account(address: $address) {
252
247
  ... on MintAccount {
253
248
  data {
254
- parsed {
255
- info {
256
- decimals
257
- isInitialized
258
- supply
259
- }
260
- type
261
- }
249
+ decimals
250
+ isInitialized
251
+ supply
252
+ }
253
+ meta {
254
+ type
262
255
  }
263
256
  }
264
257
  ... on TokenAccount {
265
258
  data {
266
- parsed {
267
- info {
268
- isNative
269
- mint
270
- state
271
- }
272
- type
273
- }
259
+ isNative
260
+ mint
261
+ state
262
+ }
263
+ meta {
264
+ type
274
265
  }
275
266
  }
276
267
  }
@@ -283,11 +274,9 @@ for (const address of mintOrTokenAccountAddresses) {
283
274
  const {
284
275
  data: {
285
276
  account: {
286
- data: {
287
- parsed: {
288
- info: accountParsedInfo,
289
- type: accountType,
290
- }
277
+ data: accountParsedInfo,
278
+ meta: {
279
+ type: accountType,
291
280
  }
292
281
  }
293
282
  }
@@ -427,13 +416,9 @@ const source = `
427
416
  ... on MintAccount {
428
417
  address
429
418
  data {
430
- parsed {
431
- info {
432
- mintAuthority {
433
- address
434
- lamports
435
- }
436
- }
419
+ mintAuthority {
420
+ address
421
+ lamports
437
422
  }
438
423
  }
439
424
  }
@@ -453,13 +438,9 @@ data: {
453
438
  account: {
454
439
  address: 'AyGCwnwxQMCqaU4ixReHt8h5W4dwmxU7eM3BEQBdWVca',
455
440
  data: {
456
- parsed: {
457
- info: {
458
- mintAuthority: {
459
- address: 'DpfJkNonoVB3sor9H9ceajhex4XHVPrDAGAq2ahdG4JZ',
460
- lamports: 10290815n,
461
- }
462
- }
441
+ mintAuthority: {
442
+ address: 'DpfJkNonoVB3sor9H9ceajhex4XHVPrDAGAq2ahdG4JZ',
443
+ lamports: 10290815n,
463
444
  }
464
445
  },
465
446
  },
@@ -524,26 +505,24 @@ const source = `
524
505
  programAccounts(programAddress: $address) {
525
506
  ... on MintAccount {
526
507
  data {
527
- parsed {
528
- info {
529
- decimals
530
- isInitialized
531
- mintAuthority
532
- supply
533
- }
534
- }
508
+ decimals
509
+ isInitialized
510
+ mintAuthority
511
+ supply
512
+ }
513
+ meta {
514
+ type
535
515
  }
536
516
  }
537
517
  ... on TokenAccount {
538
518
  data {
539
- parsed {
540
- info {
541
- isNative
542
- mint
543
- owner
544
- state
545
- }
546
- }
519
+ isNative
520
+ mint
521
+ owner
522
+ state
523
+ }
524
+ meta {
525
+ type
547
526
  }
548
527
  }
549
528
  }
@@ -559,11 +538,9 @@ const result = await rpcGraphQL.query(source, variableValues);
559
538
  const { mints, tokenAccounts } = result.data.programAccounts.reduce(
560
539
  (acc: { mints: any[]; tokenAccounts: any[] }, account) => {
561
540
  const {
562
- data: {
563
- parsed: {
564
- info: accountParsedInfo,
565
- type: accountType,
566
- }
541
+ data: accountParsedInfo,
542
+ meta: {
543
+ type: accountType,
567
544
  }
568
545
  } = account;
569
546
  if (accountType === "mint") {
@@ -639,13 +616,9 @@ const source = `
639
616
  programAccounts(programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") {
640
617
  ... on TokenAccount {
641
618
  data {
642
- parsed {
643
- info {
644
- owner {
645
- owner {
646
- lamports
647
- }
648
- }
619
+ owner {
620
+ owner {
621
+ lamports
649
622
  }
650
623
  }
651
624
  }
@@ -657,7 +630,7 @@ const source = `
657
630
  const result = await rpcGraphQL.query(source);
658
631
 
659
632
  const sumOfAllLamportsOfOwnersOfOwnersOfTokenAccounts = result.data
660
- .map(o => o.account.data.parsed.info.owner.owner.lamports)
633
+ .map(o => o.account.data.owner.owner.lamports)
661
634
  .reduce((acc, lamports) => acc + lamports, 0);
662
635
  ```
663
636
 
@@ -669,38 +642,13 @@ The `Transaction` interface contains common fields across all transactions.
669
642
 
670
643
  ```graphql
671
644
  interface Transaction {
672
- blocktime: BigInt,
673
- encoding: String,
674
- meta: TransactionMeta, # Interface
675
- slot: BigInt,
676
- }
677
- ```
678
-
679
- Notice the `TransactionMetaInterface` type present in the transaction
680
- interface.
681
-
682
- ```graphql
683
- interface TransactionMeta {
684
- computeUnitsConsumed: BigInt,
685
- err: String,
686
- fee: BigInt,
687
- format: String,
688
- loadedAddresses: TransactionMetaLoadedAddresses,
689
- logMessages: [String],
690
- postBalances: [BigInt],
691
- postTokenBalances: [TokenBalance],
692
- preBalances: [BigInt],
693
- preTokenBalances: [TokenBalance],
694
- returnData: ReturnData,
695
- rewards: [Reward],
696
- status: TransactionStatus,
645
+ blockTime: String
646
+ encoding: String
647
+ meta: TransactionMeta
648
+ slot: BigInt
697
649
  }
698
650
  ```
699
651
 
700
- The `TransactionMeta` interface is required since the field `innerInstructions`
701
- will depend on the encoding level requested for the transaction. This also
702
- applies to the actual `transaction` object itself.
703
-
704
652
  Similar to account types, any transaction can be queried by these fields
705
653
  without specifying the specific transaction type or the transaction meta
706
654
  type.
@@ -773,28 +721,26 @@ Similar to accounts, transactions with encoded data are also supported.
773
721
 
774
722
  Specific instruction types can be used in the transaction's instructions. The
775
723
  default instruction if it cannot be parsed using `jsonParsed` is the JSON
776
- version dubbed `PartiallyDecodedInstruction`.
724
+ version dubbed `GenericInstruction`.
777
725
 
778
726
  ```typescript
779
727
  const source = `
780
728
  query myQuery($signature: String!, $commitment: Commitment) {
781
729
  transaction(signature: $signature, commitment: $commitment) {
782
- ... on TransactionJsonParsed {
783
- transaction {
730
+ ... on TransactionParsed {
731
+ data {
784
732
  message {
785
- ... on TransactionMessageParsed {
786
- accountKeys {
787
- pubkey
788
- signer
789
- source
790
- writable
791
- }
792
- instructions {
793
- ... on PartiallyDecodedInstruction {
794
- accounts
795
- data
796
- programId
797
- }
733
+ accountKeys {
734
+ pubkey
735
+ signer
736
+ source
737
+ writable
738
+ }
739
+ instructions {
740
+ ... on GenericInstruction {
741
+ accounts
742
+ data
743
+ programId
798
744
  }
799
745
  }
800
746
  }
@@ -815,7 +761,7 @@ const result = await rpcGraphQL.query(source, variableValues);
815
761
  ```
816
762
  data: {
817
763
  transaction: {
818
- transaction: {
764
+ data: {
819
765
  message: {
820
766
  accountKeys: [
821
767
  {
@@ -854,19 +800,17 @@ instructions, they can be queried using specific instruction types.
854
800
  const source = `
855
801
  query myQuery($signature: String!, $commitment: Commitment) {
856
802
  transaction(signature: $signature, commitment: $commitment) {
857
- ... on TransactionJsonParsed {
858
- transaction {
803
+ ... on TransactionParsed {
804
+ data {
859
805
  message {
860
- ... on TransactionMessageParsed {
861
- instructions {
862
- ... on CreateAccountInstruction {
863
- parsed {
864
- info {
865
- lamports
866
- space
867
- }
868
- program
869
- }
806
+ instructions {
807
+ ... on CreateAccountInstruction {
808
+ data {
809
+ lamports
810
+ space
811
+ }
812
+ meta {
813
+ program
870
814
  }
871
815
  }
872
816
  }
@@ -888,15 +832,15 @@ const result = await rpcGraphQL.query(source, variableValues);
888
832
  ```
889
833
  data: {
890
834
  transaction: {
891
- transaction: {
835
+ data: {
892
836
  message: {
893
837
  instructions: [
894
838
  {
895
- parsed: {
896
- info: {
897
- lamports: 890880n,
898
- space: 0n,
899
- },
839
+ data: {
840
+ lamports: 890880n,
841
+ space: 0n,
842
+ },
843
+ meta: {
900
844
  program: 'system',
901
845
  },
902
846
  }
@@ -923,7 +867,7 @@ const source = `
923
867
  encoding: $encoding,
924
868
  ) {
925
869
  ... on TransactionBase64 {
926
- transaction
870
+ data
927
871
  }
928
872
  }
929
873
  }
@@ -941,7 +885,7 @@ const result = await rpcGraphQL.query(source, variableValues);
941
885
  ```
942
886
  data: {
943
887
  transaction: {
944
- transaction: 'WzIsIDU0LCA5LCAgNzYsIDM1LCA2NCwgOCwgOCwgNCwgMywgMiwgNV0=',
888
+ data: 'WzIsIDU0LCA5LCAgNzYsIDM1LCA2NCwgOCwgOCwgNCwgMywgMiwgNV0=',
945
889
  },
946
890
  }
947
891
  ```
@@ -959,77 +903,59 @@ in the transaction response.
959
903
  const source = `
960
904
  query myQuery($signature: String!, $commitment: Commitment) {
961
905
  transaction(signature: $signature, commitment: $commitment) {
962
- ... on TransactionJsonParsed {
963
- transaction {
906
+ ... on TransactionParsed {
907
+ data {
964
908
  message {
965
- ... on TransactionMessageParsed {
966
- instructions {
967
- ... on SplTokenTransferInstruction {
968
- parsed {
969
- info {
970
- amount
971
- authority {
909
+ instructions {
910
+ ... on SplTokenTransferInstruction {
911
+ data {
912
+ amount
913
+ authority {
914
+ address
915
+ lamports
916
+ }
917
+ destination {
918
+ ... on TokenAccount {
919
+ data {
972
920
  address
973
- lamports
974
- }
975
- destination {
976
- ... on TokenAccount {
977
- data {
978
- parsed {
979
- info {
980
- address
981
- mint {
982
- ... on MintAccount {
983
- data {
984
- parsed {
985
- info {
986
- address
987
- decimals
988
- }
989
- }
990
- }
991
- }
992
- }
993
- owner {
994
- address
995
- lamports
996
- }
997
- }
921
+ mint {
922
+ ... on MintAccount {
923
+ data {
924
+ address
925
+ decimals
998
926
  }
999
927
  }
1000
928
  }
929
+ owner {
930
+ address
931
+ lamports
932
+ }
1001
933
  }
1002
- source {
1003
- ... on TokenAccount {
1004
- data {
1005
- parsed {
1006
- info {
1007
- address
1008
- mint {
1009
- ... on MintAccount {
1010
- data {
1011
- parsed {
1012
- info {
1013
- address
1014
- decimals
1015
- }
1016
- }
1017
- }
1018
- }
1019
- }
1020
- owner {
1021
- address
1022
- lamports
1023
- }
1024
- }
934
+ }
935
+ }
936
+ source {
937
+ ... on TokenAccount {
938
+ data {
939
+ address
940
+ mint {
941
+ ... on MintAccount {
942
+ data {
943
+ address
944
+ decimals
1025
945
  }
1026
946
  }
1027
947
  }
948
+ owner {
949
+ address
950
+ lamports
951
+ }
1028
952
  }
1029
953
  }
1030
- program
1031
954
  }
1032
955
  }
956
+ meta {
957
+ program
958
+ }
1033
959
  }
1034
960
  }
1035
961
  }
@@ -1050,62 +976,50 @@ const result = await rpcGraphQL.query(source, variableValues);
1050
976
  ```
1051
977
  data: {
1052
978
  transaction: {
1053
- transaction: {
979
+ data: {
1054
980
  message: {
1055
981
  instructions: [
1056
982
  {
1057
- parsed: {
1058
- info: {
1059
- amount: '50',
1060
- authority: {
1061
- address: 'AHPPMhzDQix9sKULBqeaQ5BUZgrKdz8tg6DzPxsofB12',
1062
- lamports: 890880n,
1063
- },
1064
- destination: {
1065
- data: {
1066
- parsed: {
1067
- info: {
1068
- address: '2W8mUY75zxqwAcpirn75r3Cc7TStMirFyHwKqo13fmB1',
1069
- mint: data: {
1070
- parsed: {
1071
- info: {
1072
- address: '8poKMotB2cEYVv5sbjrdyssASZj1vwYCe7GJFeXo2QP7',
1073
- decimals: 6,
1074
- }
1075
- }
1076
- },
1077
- owner: {
1078
- address: '7tRxJ2znbTFpwW9XaMMiDsXDudoPEUXRcpDpm8qjWgAZ',
1079
- lamports: 890880n,
1080
- },
1081
- }
1082
- }
1083
- }
1084
- },
1085
- source: {
1086
- data: {
1087
- parsed: {
1088
- info: {
1089
- address: 'BqFCPqXUm4cq6jaZZx1TDTvUR1wdEuNNwAHBEVR6mJhM',
1090
- mint: data: {
1091
- parsed: {
1092
- info: {
1093
- address: '8poKMotB2cEYVv5sbjrdyssASZj1vwYCe7GJFeXo2QP7',
1094
- decimals: 6,
1095
- }
1096
- }
1097
- },
1098
- owner: {
1099
- address: '3dPmVLMD7PC5faZNyJUH9WFrUxAsbjydJfoozwmR1wDG',
1100
- lamports: e890880n,
1101
- },
1102
- }
983
+ data: {
984
+ amount: '50',
985
+ authority: {
986
+ address: 'AHPPMhzDQix9sKULBqeaQ5BUZgrKdz8tg6DzPxsofB12',
987
+ lamports: 890880n,
988
+ },
989
+ destination: {
990
+ data: {
991
+ address: '2W8mUY75zxqwAcpirn75r3Cc7TStMirFyHwKqo13fmB1',
992
+ mint: data: {
993
+ address: '8poKMotB2cEYVv5sbjrdyssASZj1vwYCe7GJFeXo2QP7',
994
+ decimals: 6,
995
+ },
996
+ owner: {
997
+ address: '7tRxJ2znbTFpwW9XaMMiDsXDudoPEUXRcpDpm8qjWgAZ',
998
+ lamports: 890880n,
999
+ },
1000
+ }
1001
+ },
1002
+ source: {
1003
+ data: {
1004
+ parsed: {
1005
+ info: {
1006
+ address: 'BqFCPqXUm4cq6jaZZx1TDTvUR1wdEuNNwAHBEVR6mJhM',
1007
+ mint: data: {
1008
+ address: '8poKMotB2cEYVv5sbjrdyssASZj1vwYCe7GJFeXo2QP7',
1009
+ decimals: 6,
1010
+ },
1011
+ owner: {
1012
+ address: '3dPmVLMD7PC5faZNyJUH9WFrUxAsbjydJfoozwmR1wDG',
1013
+ lamports: e890880n,
1014
+ },
1103
1015
  }
1104
1016
  }
1105
- },
1017
+ }
1106
1018
  },
1107
- program: 'spl-token',
1108
1019
  },
1020
+ meta: {
1021
+ program: 'spl-token',
1022
+ }
1109
1023
  }
1110
1024
  ]
1111
1025
  },
@@ -1130,22 +1044,22 @@ const source = `
1130
1044
  blockhash
1131
1045
  parentSlot
1132
1046
  rewards {
1133
- //
1047
+ commission
1048
+ lamports
1049
+ rewardType
1134
1050
  }
1135
1051
  transactions {
1136
- ... on TransactionJsonParsed {
1137
- transaction {
1052
+ ... on TransactionParsed {
1053
+ data {
1138
1054
  message {
1139
- ... on TransactionMessageParsed {
1140
- instructions {
1141
- ... on CreateAccountInstruction {
1142
- parsed {
1143
- info {
1144
- lamports
1145
- space
1146
- }
1147
- program
1148
- }
1055
+ instructions {
1056
+ ... on CreateAccountInstruction {
1057
+ data {
1058
+ lamports
1059
+ space
1060
+ }
1061
+ meta {
1062
+ program
1149
1063
  }
1150
1064
  }
1151
1065
  }
@@ -1184,20 +1098,22 @@ data: {
1184
1098
  }
1185
1099
  ],
1186
1100
  transactions: [
1187
- {
1188
- message: {
1189
- instructions: [
1190
- {
1191
- parsed: {
1192
- info: {
1101
+ data: {
1102
+ {
1103
+ message: {
1104
+ instructions: [
1105
+ {
1106
+ data: {
1193
1107
  lamports: 890880n,
1194
1108
  space: 0n,
1195
1109
  },
1196
- program: 'system',
1197
- },
1198
- }
1199
- ]
1200
- },
1110
+ meta: {
1111
+ program: 'system',
1112
+ },
1113
+ }
1114
+ ]
1115
+ },
1116
+ }
1201
1117
  }
1202
1118
  ],
1203
1119
  },