psyche-indexer-codecs 0.0.1
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/.prettierrc +13 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +17 -0
- package/src/features/CoordinatorRun.ts +126 -0
- package/src/features/MiningPool.ts +56 -0
- package/src/index.ts +3 -0
- package/src/utils.ts +40 -0
- package/tsconfig.json +27 -0
package/.prettierrc
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"arrowParens": "always",
|
|
3
|
+
"bracketSpacing": true,
|
|
4
|
+
"bracketSameLine": false,
|
|
5
|
+
"printWidth": 80,
|
|
6
|
+
"proseWrap": "always",
|
|
7
|
+
"semi": true,
|
|
8
|
+
"singleQuote": false,
|
|
9
|
+
"tabWidth": 2,
|
|
10
|
+
"trailingComma": "all",
|
|
11
|
+
"useTabs": false,
|
|
12
|
+
"plugins": ["prettier-plugin-organize-imports"]
|
|
13
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as solana_kiss from 'solana-kiss';
|
|
2
|
+
import { JsonCodecContent, JsonCodec, Pubkey } from 'solana-kiss';
|
|
3
|
+
|
|
4
|
+
type CoordinatorRunOnchain = JsonCodecContent<typeof coordinatorRunOnchainJsonCodec>;
|
|
5
|
+
type CoordinatorRunSample = JsonCodecContent<typeof coordinatorRunSampleJsonCodec>;
|
|
6
|
+
type CoordinatorRunAnalysis = JsonCodecContent<typeof coordinatorRunAnalysisJsonCodec>;
|
|
7
|
+
declare const coordinatorRunOnchainJsonCodec: solana_kiss.JsonCodec<{
|
|
8
|
+
runId: string;
|
|
9
|
+
mainAuthority: solana_kiss.Pubkey;
|
|
10
|
+
joinAuthority: solana_kiss.Pubkey;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
status: string;
|
|
14
|
+
numParameters: bigint;
|
|
15
|
+
joinedClients: {
|
|
16
|
+
signer: solana_kiss.Pubkey;
|
|
17
|
+
earned: bigint;
|
|
18
|
+
slashed: bigint;
|
|
19
|
+
}[];
|
|
20
|
+
epochClients: {
|
|
21
|
+
signer: solana_kiss.Pubkey;
|
|
22
|
+
state: string;
|
|
23
|
+
}[];
|
|
24
|
+
progress: {
|
|
25
|
+
epoch: number;
|
|
26
|
+
step: number;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
declare const coordinatorRunSampleJsonCodec: solana_kiss.JsonCodec<{
|
|
30
|
+
maxOrdinal: bigint;
|
|
31
|
+
step: number;
|
|
32
|
+
sumValue: number;
|
|
33
|
+
numValue: number;
|
|
34
|
+
time: Date | null;
|
|
35
|
+
}>;
|
|
36
|
+
declare const coordinatorRunAnalysisJsonCodec: solana_kiss.JsonCodec<{
|
|
37
|
+
latestKnownChangeOrdinal: bigint;
|
|
38
|
+
latestUpdateFetchOrdinal: bigint;
|
|
39
|
+
latestOnchainSnapshot: {
|
|
40
|
+
parsed: {
|
|
41
|
+
runId: string;
|
|
42
|
+
mainAuthority: solana_kiss.Pubkey;
|
|
43
|
+
joinAuthority: solana_kiss.Pubkey;
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
status: string;
|
|
47
|
+
numParameters: bigint;
|
|
48
|
+
joinedClients: {
|
|
49
|
+
signer: solana_kiss.Pubkey;
|
|
50
|
+
earned: bigint;
|
|
51
|
+
slashed: bigint;
|
|
52
|
+
}[];
|
|
53
|
+
epochClients: {
|
|
54
|
+
signer: solana_kiss.Pubkey;
|
|
55
|
+
state: string;
|
|
56
|
+
}[];
|
|
57
|
+
progress: {
|
|
58
|
+
epoch: number;
|
|
59
|
+
step: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
native: {
|
|
63
|
+
coordinatorInstance: solana_kiss.JsonValue;
|
|
64
|
+
coordinatorAccount: solana_kiss.JsonValue;
|
|
65
|
+
};
|
|
66
|
+
updatedAt: Date;
|
|
67
|
+
} | null;
|
|
68
|
+
lastWitnessByUser: Map<solana_kiss.Pubkey, {
|
|
69
|
+
ordinal: bigint;
|
|
70
|
+
step: number;
|
|
71
|
+
}>;
|
|
72
|
+
samplesByStatName: Map<string, {
|
|
73
|
+
maxOrdinal: bigint;
|
|
74
|
+
step: number;
|
|
75
|
+
sumValue: number;
|
|
76
|
+
numValue: number;
|
|
77
|
+
time: Date | null;
|
|
78
|
+
}[]>;
|
|
79
|
+
adminHistory: {
|
|
80
|
+
blockTime: Date | null;
|
|
81
|
+
instructionOrdinal: bigint;
|
|
82
|
+
instructionName: string;
|
|
83
|
+
instructionAddresses: Record<string, solana_kiss.Pubkey>;
|
|
84
|
+
instructionPayload: solana_kiss.JsonValue;
|
|
85
|
+
}[];
|
|
86
|
+
joinHistory: {
|
|
87
|
+
blockTime: Date | null;
|
|
88
|
+
instructionOrdinal: bigint;
|
|
89
|
+
user: solana_kiss.Pubkey;
|
|
90
|
+
p2pIdentity: solana_kiss.Pubkey;
|
|
91
|
+
}[];
|
|
92
|
+
checkpointHistory: {
|
|
93
|
+
blockTime: Date | null;
|
|
94
|
+
instructionOrdinal: bigint;
|
|
95
|
+
user: solana_kiss.Pubkey;
|
|
96
|
+
repo: {
|
|
97
|
+
repoId: string;
|
|
98
|
+
revision: string | null;
|
|
99
|
+
};
|
|
100
|
+
}[];
|
|
101
|
+
finishesOrdinals: bigint[];
|
|
102
|
+
}>;
|
|
103
|
+
|
|
104
|
+
type MiningPoolOnchain = JsonCodecContent<typeof miningPoolOnchainJsonCodec>;
|
|
105
|
+
type MiningPoolAnalysis = JsonCodecContent<typeof miningPoolAnalysisJsonCodec>;
|
|
106
|
+
declare const miningPoolOnchainJsonCodec: solana_kiss.JsonCodec<{
|
|
107
|
+
bump: number;
|
|
108
|
+
index: bigint;
|
|
109
|
+
authority: solana_kiss.Pubkey;
|
|
110
|
+
collateralMint: solana_kiss.Pubkey;
|
|
111
|
+
maxDepositCollateralAmount: bigint;
|
|
112
|
+
totalDepositedCollateralAmount: bigint;
|
|
113
|
+
totalExtractedCollateralAmount: bigint;
|
|
114
|
+
claimingEnabled: boolean;
|
|
115
|
+
redeemableMint: solana_kiss.Pubkey;
|
|
116
|
+
totalClaimedRedeemableAmount: bigint;
|
|
117
|
+
freeze: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
declare const miningPoolAnalysisJsonCodec: solana_kiss.JsonCodec<{
|
|
120
|
+
latestKnownChangeOrdinal: bigint;
|
|
121
|
+
latestUpdateFetchOrdinal: bigint;
|
|
122
|
+
latestOnchainSnapshot: {
|
|
123
|
+
parsed: {
|
|
124
|
+
bump: number;
|
|
125
|
+
index: bigint;
|
|
126
|
+
authority: solana_kiss.Pubkey;
|
|
127
|
+
collateralMint: solana_kiss.Pubkey;
|
|
128
|
+
maxDepositCollateralAmount: bigint;
|
|
129
|
+
totalDepositedCollateralAmount: bigint;
|
|
130
|
+
totalExtractedCollateralAmount: bigint;
|
|
131
|
+
claimingEnabled: boolean;
|
|
132
|
+
redeemableMint: solana_kiss.Pubkey;
|
|
133
|
+
totalClaimedRedeemableAmount: bigint;
|
|
134
|
+
freeze: boolean;
|
|
135
|
+
};
|
|
136
|
+
native: solana_kiss.JsonValue;
|
|
137
|
+
updatedAt: Date;
|
|
138
|
+
} | null;
|
|
139
|
+
depositCollateralAmountPerUser: Map<solana_kiss.Pubkey, bigint>;
|
|
140
|
+
claimRedeemableAmountPerUser: Map<solana_kiss.Pubkey, bigint>;
|
|
141
|
+
totalDepositCollateralAmount: bigint;
|
|
142
|
+
totalClaimRedeemableAmount: bigint;
|
|
143
|
+
totalExtractCollateralAmount: bigint;
|
|
144
|
+
adminHistory: {
|
|
145
|
+
blockTime: Date | null;
|
|
146
|
+
instructionOrdinal: bigint;
|
|
147
|
+
instructionName: string;
|
|
148
|
+
instructionAddresses: Record<string, solana_kiss.Pubkey>;
|
|
149
|
+
instructionPayload: solana_kiss.JsonValue;
|
|
150
|
+
}[];
|
|
151
|
+
}>;
|
|
152
|
+
|
|
153
|
+
declare function jsonCodecObjectToMapByPubkey<T>(valueCodec: JsonCodec<T>): JsonCodec<Map<Pubkey, T>>;
|
|
154
|
+
type IndexedInstruction = JsonCodecContent<typeof indexedInstructionJsonCodec>;
|
|
155
|
+
declare const indexedInstructionJsonCodec: JsonCodec<{
|
|
156
|
+
blockTime: Date | null;
|
|
157
|
+
instructionOrdinal: bigint;
|
|
158
|
+
instructionName: string;
|
|
159
|
+
instructionAddresses: Record<string, Pubkey>;
|
|
160
|
+
instructionPayload: solana_kiss.JsonValue;
|
|
161
|
+
}>;
|
|
162
|
+
|
|
163
|
+
export { type CoordinatorRunAnalysis, type CoordinatorRunOnchain, type CoordinatorRunSample, type IndexedInstruction, type MiningPoolAnalysis, type MiningPoolOnchain, coordinatorRunAnalysisJsonCodec, coordinatorRunOnchainJsonCodec, indexedInstructionJsonCodec, jsonCodecObjectToMapByPubkey, miningPoolAnalysisJsonCodec, miningPoolOnchainJsonCodec };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var j=(t,s)=>{for(var d in s)i(t,d,{get:s[d],enumerable:!0})},b=(t,s,d,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of m(s))!y.call(t,r)&&r!==d&&i(t,r,{get:()=>s[r],enumerable:!(l=u(s,r))||l.enumerable});return t};var O=t=>b(i({},"__esModule",{value:!0}),t);var h={};j(h,{coordinatorRunAnalysisJsonCodec:()=>J,coordinatorRunOnchainJsonCodec:()=>C,indexedInstructionJsonCodec:()=>c,jsonCodecObjectToMapByPubkey:()=>a,miningPoolAnalysisJsonCodec:()=>x,miningPoolOnchainJsonCodec:()=>p});module.exports=O(h);var o=require("solana-kiss");var n=require("solana-kiss");function a(t){return(0,n.jsonCodecObjectToMap)({keyCodec:{decoder:n.pubkeyFromBase58,encoder:n.pubkeyToBase58},valueCodec:t})}var c=(0,n.jsonCodecObjectToObject)({blockTime:(0,n.jsonCodecNullable)(n.jsonCodecDateTime),instructionOrdinal:n.jsonCodecBigInt,instructionName:n.jsonCodecString,instructionAddresses:(0,n.jsonCodecObjectToRecord)(n.jsonCodecPubkey),instructionPayload:n.jsonCodecValue});var C=(0,o.jsonCodecObjectToObject)({runId:o.jsonCodecString,mainAuthority:o.jsonCodecPubkey,joinAuthority:o.jsonCodecPubkey,name:o.jsonCodecString,description:o.jsonCodecString,status:o.jsonCodecString,numParameters:o.jsonCodecBigInt,joinedClients:(0,o.jsonCodecArrayToArray)((0,o.jsonCodecObjectToObject)({signer:o.jsonCodecPubkey,earned:o.jsonCodecBigInt,slashed:o.jsonCodecBigInt})),epochClients:(0,o.jsonCodecArrayToArray)((0,o.jsonCodecObjectToObject)({signer:o.jsonCodecPubkey,state:o.jsonCodecString})),progress:(0,o.jsonCodecObjectToObject)({epoch:o.jsonCodecNumber,step:o.jsonCodecNumber})}),A=(0,o.jsonCodecArrayToObject)({maxOrdinal:o.jsonCodecBigInt,step:o.jsonCodecNumber,sumValue:o.jsonCodecNumber,numValue:o.jsonCodecNumber,time:(0,o.jsonCodecNullable)(o.jsonCodecDateTime)}),J=(0,o.jsonCodecObjectToObject)({latestKnownChangeOrdinal:o.jsonCodecBigInt,latestUpdateFetchOrdinal:o.jsonCodecBigInt,latestOnchainSnapshot:(0,o.jsonCodecNullable)((0,o.jsonCodecObjectToObject)({parsed:C,native:(0,o.jsonCodecObjectToObject)({coordinatorInstance:o.jsonCodecValue,coordinatorAccount:o.jsonCodecValue}),updatedAt:o.jsonCodecDateTime})),lastWitnessByUser:a((0,o.jsonCodecObjectToObject)({ordinal:o.jsonCodecBigInt,step:o.jsonCodecNumber})),samplesByStatName:(0,o.jsonCodecObjectToMap)({keyCodec:{decoder:t=>t,encoder:t=>t},valueCodec:(0,o.jsonCodecArrayToArray)(A)}),adminHistory:(0,o.jsonCodecArrayToArray)(c),joinHistory:(0,o.jsonCodecArrayToArray)((0,o.jsonCodecObjectToObject)({blockTime:(0,o.jsonCodecNullable)(o.jsonCodecDateTime),instructionOrdinal:o.jsonCodecBigInt,user:o.jsonCodecPubkey,p2pIdentity:o.jsonCodecPubkey})),checkpointHistory:(0,o.jsonCodecArrayToArray)((0,o.jsonCodecObjectToObject)({blockTime:(0,o.jsonCodecNullable)(o.jsonCodecDateTime),instructionOrdinal:o.jsonCodecBigInt,user:o.jsonCodecPubkey,repo:(0,o.jsonCodecObjectToObject)({repoId:o.jsonCodecString,revision:(0,o.jsonCodecNullable)(o.jsonCodecString)})})),finishesOrdinals:(0,o.jsonCodecArrayToArray)(o.jsonCodecBigInt)});var e=require("solana-kiss");var p=(0,e.jsonCodecObjectToObject)({bump:e.jsonCodecNumber,index:e.jsonCodecBigInt,authority:e.jsonCodecPubkey,collateralMint:e.jsonCodecPubkey,maxDepositCollateralAmount:e.jsonCodecBigInt,totalDepositedCollateralAmount:e.jsonCodecBigInt,totalExtractedCollateralAmount:e.jsonCodecBigInt,claimingEnabled:e.jsonCodecBoolean,redeemableMint:e.jsonCodecPubkey,totalClaimedRedeemableAmount:e.jsonCodecBigInt,freeze:e.jsonCodecBoolean}),x=(0,e.jsonCodecObjectToObject)({latestKnownChangeOrdinal:e.jsonCodecBigInt,latestUpdateFetchOrdinal:e.jsonCodecBigInt,latestOnchainSnapshot:(0,e.jsonCodecNullable)((0,e.jsonCodecObjectToObject)({parsed:p,native:e.jsonCodecValue,updatedAt:e.jsonCodecDateTime})),depositCollateralAmountPerUser:a(e.jsonCodecBigInt),claimRedeemableAmountPerUser:a(e.jsonCodecBigInt),totalDepositCollateralAmount:e.jsonCodecBigInt,totalClaimRedeemableAmount:e.jsonCodecBigInt,totalExtractCollateralAmount:e.jsonCodecBigInt,adminHistory:(0,e.jsonCodecArrayToArray)(c)});0&&(module.exports={coordinatorRunAnalysisJsonCodec,coordinatorRunOnchainJsonCodec,indexedInstructionJsonCodec,jsonCodecObjectToMapByPubkey,miningPoolAnalysisJsonCodec,miningPoolOnchainJsonCodec});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/features/CoordinatorRun.ts","../src/utils.ts","../src/features/MiningPool.ts"],"sourcesContent":["export * from \"./features/CoordinatorRun\";\nexport * from \"./features/MiningPool\";\nexport * from \"./utils\";\n","import {\n jsonCodecArrayToArray,\n jsonCodecArrayToObject,\n jsonCodecBigInt,\n JsonCodecContent,\n jsonCodecDateTime,\n jsonCodecNullable,\n jsonCodecNumber,\n jsonCodecObjectToMap,\n jsonCodecObjectToObject,\n jsonCodecPubkey,\n jsonCodecString,\n jsonCodecValue,\n} from \"solana-kiss\";\nimport {\n indexedInstructionJsonCodec,\n jsonCodecObjectToMapByPubkey,\n} from \"../utils\";\n\nexport type CoordinatorRunOnchain = JsonCodecContent<\n typeof coordinatorRunOnchainJsonCodec\n>;\n\nexport type CoordinatorRunSample = JsonCodecContent<\n typeof coordinatorRunSampleJsonCodec\n>;\n\nexport type CoordinatorRunAnalysis = JsonCodecContent<\n typeof coordinatorRunAnalysisJsonCodec\n>;\n\nexport const coordinatorRunOnchainJsonCodec = jsonCodecObjectToObject({\n runId: jsonCodecString,\n mainAuthority: jsonCodecPubkey,\n joinAuthority: jsonCodecPubkey,\n name: jsonCodecString,\n description: jsonCodecString,\n status: jsonCodecString,\n numParameters: jsonCodecBigInt,\n joinedClients: jsonCodecArrayToArray(\n jsonCodecObjectToObject({\n signer: jsonCodecPubkey,\n earned: jsonCodecBigInt,\n slashed: jsonCodecBigInt,\n }),\n ),\n epochClients: jsonCodecArrayToArray(\n jsonCodecObjectToObject({\n signer: jsonCodecPubkey,\n state: jsonCodecString,\n }),\n ),\n /*\n epochRates: jsonCodecObjectToObject({\n current: jsonCodecObjectToObject({\n earningRate: jsonCodecBigInt,\n slashingRate: jsonCodecBigInt,\n }),\n future: jsonCodecObjectToObject({\n earningRate: jsonCodecBigInt,\n slashingRate: jsonCodecBigInt,\n }),\n }),\n */\n progress: jsonCodecObjectToObject({\n epoch: jsonCodecNumber,\n step: jsonCodecNumber,\n }),\n});\n\nconst coordinatorRunSampleJsonCodec = jsonCodecArrayToObject({\n maxOrdinal: jsonCodecBigInt,\n step: jsonCodecNumber,\n sumValue: jsonCodecNumber,\n numValue: jsonCodecNumber,\n time: jsonCodecNullable(jsonCodecDateTime),\n});\n\nexport const coordinatorRunAnalysisJsonCodec = jsonCodecObjectToObject({\n latestKnownChangeOrdinal: jsonCodecBigInt,\n latestUpdateFetchOrdinal: jsonCodecBigInt,\n latestOnchainSnapshot: jsonCodecNullable(\n jsonCodecObjectToObject({\n parsed: coordinatorRunOnchainJsonCodec,\n native: jsonCodecObjectToObject({\n coordinatorInstance: jsonCodecValue,\n coordinatorAccount: jsonCodecValue,\n }),\n updatedAt: jsonCodecDateTime,\n }),\n ),\n lastWitnessByUser: jsonCodecObjectToMapByPubkey(\n jsonCodecObjectToObject({\n ordinal: jsonCodecBigInt,\n step: jsonCodecNumber,\n }),\n ),\n samplesByStatName: jsonCodecObjectToMap({\n keyCodec: {\n decoder: (name) => name,\n encoder: (name) => name,\n },\n valueCodec: jsonCodecArrayToArray(coordinatorRunSampleJsonCodec),\n }),\n adminHistory: jsonCodecArrayToArray(indexedInstructionJsonCodec),\n joinHistory: jsonCodecArrayToArray(\n jsonCodecObjectToObject({\n blockTime: jsonCodecNullable(jsonCodecDateTime),\n instructionOrdinal: jsonCodecBigInt,\n user: jsonCodecPubkey,\n p2pIdentity: jsonCodecPubkey,\n }),\n ),\n checkpointHistory: jsonCodecArrayToArray(\n jsonCodecObjectToObject({\n blockTime: jsonCodecNullable(jsonCodecDateTime),\n instructionOrdinal: jsonCodecBigInt,\n user: jsonCodecPubkey,\n repo: jsonCodecObjectToObject({\n repoId: jsonCodecString,\n revision: jsonCodecNullable(jsonCodecString),\n }),\n }),\n ),\n finishesOrdinals: jsonCodecArrayToArray(jsonCodecBigInt),\n});\n","import {\n JsonCodec,\n JsonCodecContent,\n Pubkey,\n jsonCodecBigInt,\n jsonCodecDateTime,\n jsonCodecNullable,\n jsonCodecObjectToMap,\n jsonCodecObjectToObject,\n jsonCodecObjectToRecord,\n jsonCodecPubkey,\n jsonCodecString,\n jsonCodecValue,\n pubkeyFromBase58,\n pubkeyToBase58,\n} from \"solana-kiss\";\n\nexport function jsonCodecObjectToMapByPubkey<T>(\n valueCodec: JsonCodec<T>,\n): JsonCodec<Map<Pubkey, T>> {\n return jsonCodecObjectToMap({\n keyCodec: {\n decoder: pubkeyFromBase58,\n encoder: pubkeyToBase58,\n },\n valueCodec,\n });\n}\n\nexport type IndexedInstruction = JsonCodecContent<\n typeof indexedInstructionJsonCodec\n>;\n\nexport const indexedInstructionJsonCodec = jsonCodecObjectToObject({\n blockTime: jsonCodecNullable(jsonCodecDateTime),\n instructionOrdinal: jsonCodecBigInt,\n instructionName: jsonCodecString,\n instructionAddresses: jsonCodecObjectToRecord(jsonCodecPubkey),\n instructionPayload: jsonCodecValue,\n});\n","import {\n jsonCodecArrayToArray,\n jsonCodecBigInt,\n jsonCodecBoolean,\n JsonCodecContent,\n jsonCodecDateTime,\n jsonCodecNullable,\n jsonCodecNumber,\n jsonCodecObjectToObject,\n jsonCodecPubkey,\n jsonCodecValue,\n} from \"solana-kiss\";\nimport {\n indexedInstructionJsonCodec,\n jsonCodecObjectToMapByPubkey,\n} from \"../utils\";\n\nexport type MiningPoolOnchain = JsonCodecContent<\n typeof miningPoolOnchainJsonCodec\n>;\n\nexport type MiningPoolAnalysis = JsonCodecContent<\n typeof miningPoolAnalysisJsonCodec\n>;\n\nexport const miningPoolOnchainJsonCodec = jsonCodecObjectToObject({\n bump: jsonCodecNumber,\n index: jsonCodecBigInt,\n authority: jsonCodecPubkey,\n collateralMint: jsonCodecPubkey,\n maxDepositCollateralAmount: jsonCodecBigInt,\n totalDepositedCollateralAmount: jsonCodecBigInt,\n totalExtractedCollateralAmount: jsonCodecBigInt,\n claimingEnabled: jsonCodecBoolean,\n redeemableMint: jsonCodecPubkey,\n totalClaimedRedeemableAmount: jsonCodecBigInt,\n freeze: jsonCodecBoolean,\n});\n\nexport const miningPoolAnalysisJsonCodec = jsonCodecObjectToObject({\n latestKnownChangeOrdinal: jsonCodecBigInt,\n latestUpdateFetchOrdinal: jsonCodecBigInt,\n latestOnchainSnapshot: jsonCodecNullable(\n jsonCodecObjectToObject({\n parsed: miningPoolOnchainJsonCodec,\n native: jsonCodecValue,\n updatedAt: jsonCodecDateTime,\n }),\n ),\n depositCollateralAmountPerUser: jsonCodecObjectToMapByPubkey(jsonCodecBigInt),\n claimRedeemableAmountPerUser: jsonCodecObjectToMapByPubkey(jsonCodecBigInt),\n totalDepositCollateralAmount: jsonCodecBigInt,\n totalClaimRedeemableAmount: jsonCodecBigInt,\n totalExtractCollateralAmount: jsonCodecBigInt,\n adminHistory: jsonCodecArrayToArray(indexedInstructionJsonCodec),\n});\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,EAAA,mCAAAC,EAAA,gCAAAC,EAAA,iCAAAC,EAAA,gCAAAC,EAAA,+BAAAC,IAAA,eAAAC,EAAAR,GCAA,IAAAS,EAaO,uBCbP,IAAAC,EAeO,uBAEA,SAASC,EACdC,EAC2B,CAC3B,SAAO,wBAAqB,CAC1B,SAAU,CACR,QAAS,mBACT,QAAS,gBACX,EACA,WAAAA,CACF,CAAC,CACH,CAMO,IAAMC,KAA8B,2BAAwB,CACjE,aAAW,qBAAkB,mBAAiB,EAC9C,mBAAoB,kBACpB,gBAAiB,kBACjB,wBAAsB,2BAAwB,iBAAe,EAC7D,mBAAoB,gBACtB,CAAC,EDRM,IAAMC,KAAiC,2BAAwB,CACpE,MAAO,kBACP,cAAe,kBACf,cAAe,kBACf,KAAM,kBACN,YAAa,kBACb,OAAQ,kBACR,cAAe,kBACf,iBAAe,4BACb,2BAAwB,CACtB,OAAQ,kBACR,OAAQ,kBACR,QAAS,iBACX,CAAC,CACH,EACA,gBAAc,4BACZ,2BAAwB,CACtB,OAAQ,kBACR,MAAO,iBACT,CAAC,CACH,EAaA,YAAU,2BAAwB,CAChC,MAAO,kBACP,KAAM,iBACR,CAAC,CACH,CAAC,EAEKC,KAAgC,0BAAuB,CAC3D,WAAY,kBACZ,KAAM,kBACN,SAAU,kBACV,SAAU,kBACV,QAAM,qBAAkB,mBAAiB,CAC3C,CAAC,EAEYC,KAAkC,2BAAwB,CACrE,yBAA0B,kBAC1B,yBAA0B,kBAC1B,yBAAuB,wBACrB,2BAAwB,CACtB,OAAQF,EACR,UAAQ,2BAAwB,CAC9B,oBAAqB,iBACrB,mBAAoB,gBACtB,CAAC,EACD,UAAW,mBACb,CAAC,CACH,EACA,kBAAmBG,KACjB,2BAAwB,CACtB,QAAS,kBACT,KAAM,iBACR,CAAC,CACH,EACA,qBAAmB,wBAAqB,CACtC,SAAU,CACR,QAAUC,GAASA,EACnB,QAAUA,GAASA,CACrB,EACA,cAAY,yBAAsBH,CAA6B,CACjE,CAAC,EACD,gBAAc,yBAAsBI,CAA2B,EAC/D,eAAa,4BACX,2BAAwB,CACtB,aAAW,qBAAkB,mBAAiB,EAC9C,mBAAoB,kBACpB,KAAM,kBACN,YAAa,iBACf,CAAC,CACH,EACA,qBAAmB,4BACjB,2BAAwB,CACtB,aAAW,qBAAkB,mBAAiB,EAC9C,mBAAoB,kBACpB,KAAM,kBACN,QAAM,2BAAwB,CAC5B,OAAQ,kBACR,YAAU,qBAAkB,iBAAe,CAC7C,CAAC,CACH,CAAC,CACH,EACA,oBAAkB,yBAAsB,iBAAe,CACzD,CAAC,EE7HD,IAAAC,EAWO,uBAcA,IAAMC,KAA6B,2BAAwB,CAChE,KAAM,kBACN,MAAO,kBACP,UAAW,kBACX,eAAgB,kBAChB,2BAA4B,kBAC5B,+BAAgC,kBAChC,+BAAgC,kBAChC,gBAAiB,mBACjB,eAAgB,kBAChB,6BAA8B,kBAC9B,OAAQ,kBACV,CAAC,EAEYC,KAA8B,2BAAwB,CACjE,yBAA0B,kBAC1B,yBAA0B,kBAC1B,yBAAuB,wBACrB,2BAAwB,CACtB,OAAQD,EACR,OAAQ,iBACR,UAAW,mBACb,CAAC,CACH,EACA,+BAAgCE,EAA6B,iBAAe,EAC5E,6BAA8BA,EAA6B,iBAAe,EAC1E,6BAA8B,kBAC9B,2BAA4B,kBAC5B,6BAA8B,kBAC9B,gBAAc,yBAAsBC,CAA2B,CACjE,CAAC","names":["index_exports","__export","coordinatorRunAnalysisJsonCodec","coordinatorRunOnchainJsonCodec","indexedInstructionJsonCodec","jsonCodecObjectToMapByPubkey","miningPoolAnalysisJsonCodec","miningPoolOnchainJsonCodec","__toCommonJS","import_solana_kiss","import_solana_kiss","jsonCodecObjectToMapByPubkey","valueCodec","indexedInstructionJsonCodec","coordinatorRunOnchainJsonCodec","coordinatorRunSampleJsonCodec","coordinatorRunAnalysisJsonCodec","jsonCodecObjectToMapByPubkey","name","indexedInstructionJsonCodec","import_solana_kiss","miningPoolOnchainJsonCodec","miningPoolAnalysisJsonCodec","jsonCodecObjectToMapByPubkey","indexedInstructionJsonCodec"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "psyche-indexer-codecs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"devDependencies": {
|
|
5
|
+
"prettier": "^3.5.3",
|
|
6
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
7
|
+
"tsup": "^8.5.0"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"solana-kiss": "0.2.10"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsup src/index.ts --dts --clean --minify --sourcemap --out-dir dist",
|
|
14
|
+
"fmt": "prettier --write src",
|
|
15
|
+
"publish": "npm run build && npm publish"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsonCodecArrayToArray,
|
|
3
|
+
jsonCodecArrayToObject,
|
|
4
|
+
jsonCodecBigInt,
|
|
5
|
+
JsonCodecContent,
|
|
6
|
+
jsonCodecDateTime,
|
|
7
|
+
jsonCodecNullable,
|
|
8
|
+
jsonCodecNumber,
|
|
9
|
+
jsonCodecObjectToMap,
|
|
10
|
+
jsonCodecObjectToObject,
|
|
11
|
+
jsonCodecPubkey,
|
|
12
|
+
jsonCodecString,
|
|
13
|
+
jsonCodecValue,
|
|
14
|
+
} from "solana-kiss";
|
|
15
|
+
import {
|
|
16
|
+
indexedInstructionJsonCodec,
|
|
17
|
+
jsonCodecObjectToMapByPubkey,
|
|
18
|
+
} from "../utils";
|
|
19
|
+
|
|
20
|
+
export type CoordinatorRunOnchain = JsonCodecContent<
|
|
21
|
+
typeof coordinatorRunOnchainJsonCodec
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type CoordinatorRunSample = JsonCodecContent<
|
|
25
|
+
typeof coordinatorRunSampleJsonCodec
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export type CoordinatorRunAnalysis = JsonCodecContent<
|
|
29
|
+
typeof coordinatorRunAnalysisJsonCodec
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export const coordinatorRunOnchainJsonCodec = jsonCodecObjectToObject({
|
|
33
|
+
runId: jsonCodecString,
|
|
34
|
+
mainAuthority: jsonCodecPubkey,
|
|
35
|
+
joinAuthority: jsonCodecPubkey,
|
|
36
|
+
name: jsonCodecString,
|
|
37
|
+
description: jsonCodecString,
|
|
38
|
+
status: jsonCodecString,
|
|
39
|
+
numParameters: jsonCodecBigInt,
|
|
40
|
+
joinedClients: jsonCodecArrayToArray(
|
|
41
|
+
jsonCodecObjectToObject({
|
|
42
|
+
signer: jsonCodecPubkey,
|
|
43
|
+
earned: jsonCodecBigInt,
|
|
44
|
+
slashed: jsonCodecBigInt,
|
|
45
|
+
}),
|
|
46
|
+
),
|
|
47
|
+
epochClients: jsonCodecArrayToArray(
|
|
48
|
+
jsonCodecObjectToObject({
|
|
49
|
+
signer: jsonCodecPubkey,
|
|
50
|
+
state: jsonCodecString,
|
|
51
|
+
}),
|
|
52
|
+
),
|
|
53
|
+
/*
|
|
54
|
+
epochRates: jsonCodecObjectToObject({
|
|
55
|
+
current: jsonCodecObjectToObject({
|
|
56
|
+
earningRate: jsonCodecBigInt,
|
|
57
|
+
slashingRate: jsonCodecBigInt,
|
|
58
|
+
}),
|
|
59
|
+
future: jsonCodecObjectToObject({
|
|
60
|
+
earningRate: jsonCodecBigInt,
|
|
61
|
+
slashingRate: jsonCodecBigInt,
|
|
62
|
+
}),
|
|
63
|
+
}),
|
|
64
|
+
*/
|
|
65
|
+
progress: jsonCodecObjectToObject({
|
|
66
|
+
epoch: jsonCodecNumber,
|
|
67
|
+
step: jsonCodecNumber,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const coordinatorRunSampleJsonCodec = jsonCodecArrayToObject({
|
|
72
|
+
maxOrdinal: jsonCodecBigInt,
|
|
73
|
+
step: jsonCodecNumber,
|
|
74
|
+
sumValue: jsonCodecNumber,
|
|
75
|
+
numValue: jsonCodecNumber,
|
|
76
|
+
time: jsonCodecNullable(jsonCodecDateTime),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export const coordinatorRunAnalysisJsonCodec = jsonCodecObjectToObject({
|
|
80
|
+
latestKnownChangeOrdinal: jsonCodecBigInt,
|
|
81
|
+
latestUpdateFetchOrdinal: jsonCodecBigInt,
|
|
82
|
+
latestOnchainSnapshot: jsonCodecNullable(
|
|
83
|
+
jsonCodecObjectToObject({
|
|
84
|
+
parsed: coordinatorRunOnchainJsonCodec,
|
|
85
|
+
native: jsonCodecObjectToObject({
|
|
86
|
+
coordinatorInstance: jsonCodecValue,
|
|
87
|
+
coordinatorAccount: jsonCodecValue,
|
|
88
|
+
}),
|
|
89
|
+
updatedAt: jsonCodecDateTime,
|
|
90
|
+
}),
|
|
91
|
+
),
|
|
92
|
+
lastWitnessByUser: jsonCodecObjectToMapByPubkey(
|
|
93
|
+
jsonCodecObjectToObject({
|
|
94
|
+
ordinal: jsonCodecBigInt,
|
|
95
|
+
step: jsonCodecNumber,
|
|
96
|
+
}),
|
|
97
|
+
),
|
|
98
|
+
samplesByStatName: jsonCodecObjectToMap({
|
|
99
|
+
keyCodec: {
|
|
100
|
+
decoder: (name) => name,
|
|
101
|
+
encoder: (name) => name,
|
|
102
|
+
},
|
|
103
|
+
valueCodec: jsonCodecArrayToArray(coordinatorRunSampleJsonCodec),
|
|
104
|
+
}),
|
|
105
|
+
adminHistory: jsonCodecArrayToArray(indexedInstructionJsonCodec),
|
|
106
|
+
joinHistory: jsonCodecArrayToArray(
|
|
107
|
+
jsonCodecObjectToObject({
|
|
108
|
+
blockTime: jsonCodecNullable(jsonCodecDateTime),
|
|
109
|
+
instructionOrdinal: jsonCodecBigInt,
|
|
110
|
+
user: jsonCodecPubkey,
|
|
111
|
+
p2pIdentity: jsonCodecPubkey,
|
|
112
|
+
}),
|
|
113
|
+
),
|
|
114
|
+
checkpointHistory: jsonCodecArrayToArray(
|
|
115
|
+
jsonCodecObjectToObject({
|
|
116
|
+
blockTime: jsonCodecNullable(jsonCodecDateTime),
|
|
117
|
+
instructionOrdinal: jsonCodecBigInt,
|
|
118
|
+
user: jsonCodecPubkey,
|
|
119
|
+
repo: jsonCodecObjectToObject({
|
|
120
|
+
repoId: jsonCodecString,
|
|
121
|
+
revision: jsonCodecNullable(jsonCodecString),
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
),
|
|
125
|
+
finishesOrdinals: jsonCodecArrayToArray(jsonCodecBigInt),
|
|
126
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsonCodecArrayToArray,
|
|
3
|
+
jsonCodecBigInt,
|
|
4
|
+
jsonCodecBoolean,
|
|
5
|
+
JsonCodecContent,
|
|
6
|
+
jsonCodecDateTime,
|
|
7
|
+
jsonCodecNullable,
|
|
8
|
+
jsonCodecNumber,
|
|
9
|
+
jsonCodecObjectToObject,
|
|
10
|
+
jsonCodecPubkey,
|
|
11
|
+
jsonCodecValue,
|
|
12
|
+
} from "solana-kiss";
|
|
13
|
+
import {
|
|
14
|
+
indexedInstructionJsonCodec,
|
|
15
|
+
jsonCodecObjectToMapByPubkey,
|
|
16
|
+
} from "../utils";
|
|
17
|
+
|
|
18
|
+
export type MiningPoolOnchain = JsonCodecContent<
|
|
19
|
+
typeof miningPoolOnchainJsonCodec
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export type MiningPoolAnalysis = JsonCodecContent<
|
|
23
|
+
typeof miningPoolAnalysisJsonCodec
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
export const miningPoolOnchainJsonCodec = jsonCodecObjectToObject({
|
|
27
|
+
bump: jsonCodecNumber,
|
|
28
|
+
index: jsonCodecBigInt,
|
|
29
|
+
authority: jsonCodecPubkey,
|
|
30
|
+
collateralMint: jsonCodecPubkey,
|
|
31
|
+
maxDepositCollateralAmount: jsonCodecBigInt,
|
|
32
|
+
totalDepositedCollateralAmount: jsonCodecBigInt,
|
|
33
|
+
totalExtractedCollateralAmount: jsonCodecBigInt,
|
|
34
|
+
claimingEnabled: jsonCodecBoolean,
|
|
35
|
+
redeemableMint: jsonCodecPubkey,
|
|
36
|
+
totalClaimedRedeemableAmount: jsonCodecBigInt,
|
|
37
|
+
freeze: jsonCodecBoolean,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const miningPoolAnalysisJsonCodec = jsonCodecObjectToObject({
|
|
41
|
+
latestKnownChangeOrdinal: jsonCodecBigInt,
|
|
42
|
+
latestUpdateFetchOrdinal: jsonCodecBigInt,
|
|
43
|
+
latestOnchainSnapshot: jsonCodecNullable(
|
|
44
|
+
jsonCodecObjectToObject({
|
|
45
|
+
parsed: miningPoolOnchainJsonCodec,
|
|
46
|
+
native: jsonCodecValue,
|
|
47
|
+
updatedAt: jsonCodecDateTime,
|
|
48
|
+
}),
|
|
49
|
+
),
|
|
50
|
+
depositCollateralAmountPerUser: jsonCodecObjectToMapByPubkey(jsonCodecBigInt),
|
|
51
|
+
claimRedeemableAmountPerUser: jsonCodecObjectToMapByPubkey(jsonCodecBigInt),
|
|
52
|
+
totalDepositCollateralAmount: jsonCodecBigInt,
|
|
53
|
+
totalClaimRedeemableAmount: jsonCodecBigInt,
|
|
54
|
+
totalExtractCollateralAmount: jsonCodecBigInt,
|
|
55
|
+
adminHistory: jsonCodecArrayToArray(indexedInstructionJsonCodec),
|
|
56
|
+
});
|
package/src/index.ts
ADDED
package/src/utils.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
JsonCodec,
|
|
3
|
+
JsonCodecContent,
|
|
4
|
+
Pubkey,
|
|
5
|
+
jsonCodecBigInt,
|
|
6
|
+
jsonCodecDateTime,
|
|
7
|
+
jsonCodecNullable,
|
|
8
|
+
jsonCodecObjectToMap,
|
|
9
|
+
jsonCodecObjectToObject,
|
|
10
|
+
jsonCodecObjectToRecord,
|
|
11
|
+
jsonCodecPubkey,
|
|
12
|
+
jsonCodecString,
|
|
13
|
+
jsonCodecValue,
|
|
14
|
+
pubkeyFromBase58,
|
|
15
|
+
pubkeyToBase58,
|
|
16
|
+
} from "solana-kiss";
|
|
17
|
+
|
|
18
|
+
export function jsonCodecObjectToMapByPubkey<T>(
|
|
19
|
+
valueCodec: JsonCodec<T>,
|
|
20
|
+
): JsonCodec<Map<Pubkey, T>> {
|
|
21
|
+
return jsonCodecObjectToMap({
|
|
22
|
+
keyCodec: {
|
|
23
|
+
decoder: pubkeyFromBase58,
|
|
24
|
+
encoder: pubkeyToBase58,
|
|
25
|
+
},
|
|
26
|
+
valueCodec,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type IndexedInstruction = JsonCodecContent<
|
|
31
|
+
typeof indexedInstructionJsonCodec
|
|
32
|
+
>;
|
|
33
|
+
|
|
34
|
+
export const indexedInstructionJsonCodec = jsonCodecObjectToObject({
|
|
35
|
+
blockTime: jsonCodecNullable(jsonCodecDateTime),
|
|
36
|
+
instructionOrdinal: jsonCodecBigInt,
|
|
37
|
+
instructionName: jsonCodecString,
|
|
38
|
+
instructionAddresses: jsonCodecObjectToRecord(jsonCodecPubkey),
|
|
39
|
+
instructionPayload: jsonCodecValue,
|
|
40
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"alwaysStrict": true,
|
|
12
|
+
"noImplicitOverride": true,
|
|
13
|
+
"noImplicitAny": true,
|
|
14
|
+
"noImplicitThis": true,
|
|
15
|
+
"noImplicitReturns": true,
|
|
16
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"noUncheckedIndexedAccess": true,
|
|
21
|
+
"exactOptionalPropertyTypes": true,
|
|
22
|
+
"useUnknownInCatchVariables": true,
|
|
23
|
+
"erasableSyntaxOnly": true,
|
|
24
|
+
"forceConsistentCasingInFileNames": true
|
|
25
|
+
},
|
|
26
|
+
"include": ["src", "tests"]
|
|
27
|
+
}
|