@subsquid/solana-ingest 0.1.2 → 0.2.0
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/lib/ingest.d.ts +1 -0
- package/lib/ingest.d.ts.map +1 -1
- package/lib/ingest.js +37 -2
- package/lib/ingest.js.map +1 -1
- package/lib/mapping.d.ts +192 -4
- package/lib/mapping.d.ts.map +1 -1
- package/lib/mapping.js +18 -27
- package/lib/mapping.js.map +1 -1
- package/package.json +3 -3
- package/src/ingest.ts +31 -4
- package/src/mapping.ts +16 -29
package/lib/ingest.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare class SolanaIngest extends Ingest<Options> {
|
|
|
6
6
|
protected getLoggingNamespace(): string;
|
|
7
7
|
protected hasRpc(): 'required' | boolean;
|
|
8
8
|
protected setUpProgram(program: Command): void;
|
|
9
|
+
private mapping;
|
|
9
10
|
protected getBlocks(range: Range): AsyncIterable<object[]>;
|
|
10
11
|
protected getBlockHeight(block: any): number;
|
|
11
12
|
protected getBlockTimestamp(block: any): number;
|
package/lib/ingest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../src/ingest.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../src/ingest.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAC,MAAM,oCAAoC,CAAA;AAOxF,UAAU,OAAQ,SAAQ,aAAa;IACnC,KAAK,EAAE,OAAO,CAAA;CACjB;AAGD,qBAAa,YAAa,SAAQ,MAAM,CAAC,OAAO,CAAC;IAC7C,SAAS,CAAC,mBAAmB,IAAI,MAAM;IAIvC,SAAS,CAAC,MAAM,IAAI,UAAU,GAAG,OAAO;IAIxC,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO;IAWvC,OAAO,CAAC,OAAO;cAuBE,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC;IAmBjE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM;IAI5C,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM;CAGlD"}
|
package/lib/ingest.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.SolanaIngest = void 0;
|
|
4
13
|
const util_internal_1 = require("@subsquid/util-internal");
|
|
5
14
|
const util_internal_ingest_cli_1 = require("@subsquid/util-internal-ingest-cli");
|
|
6
15
|
const util_internal_json_1 = require("@subsquid/util-internal-json");
|
|
7
16
|
const mapping_1 = require("./mapping");
|
|
17
|
+
const util_internal_validation_1 = require("@subsquid/util-internal-validation");
|
|
18
|
+
const solana_normalization_1 = require("@subsquid/solana-normalization");
|
|
8
19
|
class SolanaIngest extends util_internal_ingest_cli_1.Ingest {
|
|
9
20
|
getLoggingNamespace() {
|
|
10
21
|
return 'sqd:solana-ingest';
|
|
@@ -21,12 +32,30 @@ class SolanaIngest extends util_internal_ingest_cli_1.Ingest {
|
|
|
21
32
|
});
|
|
22
33
|
program.option('--no-votes', 'Exclude vote transactions');
|
|
23
34
|
}
|
|
24
|
-
|
|
35
|
+
mapping() {
|
|
25
36
|
let votes = this.options().votes;
|
|
37
|
+
return function mapRawBlock(raw) {
|
|
38
|
+
(0, util_internal_validation_1.assertValidity)(mapping_1.RawBlock, raw);
|
|
39
|
+
if (!votes) {
|
|
40
|
+
(0, mapping_1.removeVoteTransactions)(raw.block);
|
|
41
|
+
}
|
|
42
|
+
let normalized = (0, solana_normalization_1.mapRpcBlock)(raw, {
|
|
43
|
+
warn: function (props, msg) {
|
|
44
|
+
throw (0, util_internal_1.addErrorContext)(new Error(msg), props);
|
|
45
|
+
},
|
|
46
|
+
error: function (props, msg) {
|
|
47
|
+
throw (0, util_internal_1.addErrorContext)(new Error(msg), props);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
return normalized;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async *getBlocks(range) {
|
|
54
|
+
let mapping = this.mapping();
|
|
26
55
|
for await (let blocks of this.archive().getRawBlocks(range)) {
|
|
27
56
|
yield blocks.map(raw => {
|
|
28
57
|
try {
|
|
29
|
-
let block = (
|
|
58
|
+
let block = mapping(raw);
|
|
30
59
|
return (0, util_internal_json_1.toJSON)(block);
|
|
31
60
|
}
|
|
32
61
|
catch (err) {
|
|
@@ -47,4 +76,10 @@ class SolanaIngest extends util_internal_ingest_cli_1.Ingest {
|
|
|
47
76
|
}
|
|
48
77
|
}
|
|
49
78
|
exports.SolanaIngest = SolanaIngest;
|
|
79
|
+
__decorate([
|
|
80
|
+
util_internal_1.def,
|
|
81
|
+
__metadata("design:type", Function),
|
|
82
|
+
__metadata("design:paramtypes", []),
|
|
83
|
+
__metadata("design:returntype", Function)
|
|
84
|
+
], SolanaIngest.prototype, "mapping", null);
|
|
50
85
|
//# sourceMappingURL=ingest.js.map
|
package/lib/ingest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../src/ingest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ingest.js","sourceRoot":"","sources":["../src/ingest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAA4D;AAC5D,iFAAwF;AACxF,qEAAmD;AACnD,uCAA0D;AAC1D,iFAAiE;AACjE,yEAA0D;AAQ1D,MAAa,YAAa,SAAQ,iCAAe;IACnC,mBAAmB;QACzB,OAAO,mBAAmB,CAAA;IAC9B,CAAC;IAES,MAAM;QACZ,OAAO,KAAK,CAAA;IAChB,CAAC;IAES,YAAY,CAAC,OAAgB;QACnC,OAAO,CAAC,WAAW,CAAC,gCAAgC,CAAC,CAAA;QACrD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YAC7B,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,YAAY,EAAE,CAAC;gBACzC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAA;YAC1B,CAAC;QACL,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAA;IAC7D,CAAC;IAGO,OAAO;QACX,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAA;QAEhC,OAAO,SAAS,WAAW,CAAC,GAAY;YACpC,IAAA,yCAAc,EAAC,kBAAQ,EAAE,GAAG,CAAC,CAAA;YAE7B,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,IAAA,gCAAsB,EAAC,GAAG,CAAC,KAAK,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,UAAU,GAAG,IAAA,kCAAW,EAAC,GAAG,EAAE;gBAC9B,IAAI,EAAE,UAAS,KAAU,EAAE,GAAW;oBAClC,MAAM,IAAA,+BAAe,EAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;gBAChD,CAAC;gBACD,KAAK,EAAE,UAAS,KAAU,EAAE,GAAW;oBACnC,MAAM,IAAA,+BAAe,EAAC,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;gBAChD,CAAC;aACJ,CAAC,CAAA;YAEF,OAAO,UAAU,CAAA;QACrB,CAAC,CAAA;IACL,CAAC;IAES,KAAK,CAAC,CAAC,SAAS,CAAC,KAAY;QACnC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAE5B,IAAI,KAAK,EAAE,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,YAAY,CAAW,KAAK,CAAC,EAAE,CAAC;YACpE,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBACnB,IAAI,CAAC;oBACD,IAAI,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;oBACxB,OAAO,IAAA,2BAAM,EAAC,KAAK,CAAC,CAAA;gBACxB,CAAC;gBAAC,OAAM,GAAQ,EAAE,CAAC;oBACf,MAAM,IAAA,+BAAe,EAAC,GAAG,EAAE;wBACvB,SAAS,EAAE,GAAG,CAAC,IAAI;wBACnB,WAAW,EAAE,GAAG,CAAC,MAAM;wBACvB,SAAS,EAAE,GAAG,CAAC,IAAI;qBACtB,CAAC,CAAA;gBACN,CAAC;YACL,CAAC,CAAC,CAAA;QACN,CAAC;IACL,CAAC;IAES,cAAc,CAAC,KAAU;QAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;IAES,iBAAiB,CAAC,KAAU;QAClC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;CACJ;AArED,oCAqEC;AAjDW;IADP,mBAAG;;;;2CAsBH"}
|
package/lib/mapping.d.ts
CHANGED
|
@@ -1,6 +1,192 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Transaction } from '@subsquid/solana-rpc-data';
|
|
2
2
|
import { GetSrcType } from '@subsquid/util-internal-validation';
|
|
3
|
-
declare const
|
|
3
|
+
export declare const GetBlock: import("@subsquid/util-internal-validation").Validator<{
|
|
4
|
+
blockHeight: number;
|
|
5
|
+
blockTime: number;
|
|
6
|
+
blockhash: string;
|
|
7
|
+
parentSlot: number;
|
|
8
|
+
previousBlockhash: string;
|
|
9
|
+
transactions: {
|
|
10
|
+
meta: {
|
|
11
|
+
fee: bigint;
|
|
12
|
+
preBalances: bigint[];
|
|
13
|
+
postBalances: bigint[];
|
|
14
|
+
logMessages: string[] | null;
|
|
15
|
+
computeUnitsConsumed?: bigint | undefined;
|
|
16
|
+
err?: any;
|
|
17
|
+
preTokenBalances?: {
|
|
18
|
+
accountIndex: number;
|
|
19
|
+
mint: string;
|
|
20
|
+
uiTokenAmount: {
|
|
21
|
+
amount: bigint;
|
|
22
|
+
decimals: number;
|
|
23
|
+
};
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
programId?: string | undefined;
|
|
26
|
+
}[] | undefined;
|
|
27
|
+
postTokenBalances?: {
|
|
28
|
+
accountIndex: number;
|
|
29
|
+
mint: string;
|
|
30
|
+
uiTokenAmount: {
|
|
31
|
+
amount: bigint;
|
|
32
|
+
decimals: number;
|
|
33
|
+
};
|
|
34
|
+
owner?: string | undefined;
|
|
35
|
+
programId?: string | undefined;
|
|
36
|
+
}[] | undefined;
|
|
37
|
+
innerInstructions?: {
|
|
38
|
+
index: number;
|
|
39
|
+
instructions: {
|
|
40
|
+
accounts: number[];
|
|
41
|
+
data: string;
|
|
42
|
+
programIdIndex: number;
|
|
43
|
+
stackHeight: number | null;
|
|
44
|
+
}[];
|
|
45
|
+
}[] | undefined;
|
|
46
|
+
loadedAddresses?: {
|
|
47
|
+
readonly: string[];
|
|
48
|
+
writable: string[];
|
|
49
|
+
} | undefined;
|
|
50
|
+
rewards?: {
|
|
51
|
+
pubkey: string;
|
|
52
|
+
lamports: number;
|
|
53
|
+
postBalance: bigint;
|
|
54
|
+
rewardType?: string | undefined;
|
|
55
|
+
commission?: number | undefined;
|
|
56
|
+
}[] | undefined;
|
|
57
|
+
returnData?: {
|
|
58
|
+
programId: string;
|
|
59
|
+
data: [string, "base64"];
|
|
60
|
+
} | undefined;
|
|
61
|
+
};
|
|
62
|
+
transaction: {
|
|
63
|
+
message: {
|
|
64
|
+
accountKeys: string[];
|
|
65
|
+
header: {
|
|
66
|
+
numReadonlySignedAccounts: number;
|
|
67
|
+
numReadonlyUnsignedAccounts: number;
|
|
68
|
+
numRequiredSignatures: number;
|
|
69
|
+
};
|
|
70
|
+
instructions: {
|
|
71
|
+
accounts: number[];
|
|
72
|
+
data: string;
|
|
73
|
+
programIdIndex: number;
|
|
74
|
+
stackHeight: number | null;
|
|
75
|
+
}[];
|
|
76
|
+
recentBlockhash: string;
|
|
77
|
+
addressTableLookups?: {
|
|
78
|
+
accountKey: string;
|
|
79
|
+
readonlyIndexes: number[];
|
|
80
|
+
writableIndexes: number[];
|
|
81
|
+
}[] | undefined;
|
|
82
|
+
};
|
|
83
|
+
signatures: string[];
|
|
84
|
+
};
|
|
85
|
+
version: number | "legacy";
|
|
86
|
+
_index?: number | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
rewards: {
|
|
89
|
+
pubkey: string;
|
|
90
|
+
lamports: number;
|
|
91
|
+
postBalance: bigint;
|
|
92
|
+
rewardType?: string | undefined;
|
|
93
|
+
commission?: number | undefined;
|
|
94
|
+
}[];
|
|
95
|
+
}, {
|
|
96
|
+
blockHeight: number;
|
|
97
|
+
blockTime: number;
|
|
98
|
+
blockhash: string;
|
|
99
|
+
parentSlot: number;
|
|
100
|
+
previousBlockhash: string;
|
|
101
|
+
transactions: {
|
|
102
|
+
meta: {
|
|
103
|
+
fee: string | number;
|
|
104
|
+
preBalances: (string | number)[];
|
|
105
|
+
postBalances: (string | number)[];
|
|
106
|
+
logMessages: string[] | null;
|
|
107
|
+
computeUnitsConsumed?: string | number | null | undefined;
|
|
108
|
+
err?: any;
|
|
109
|
+
preTokenBalances?: {
|
|
110
|
+
accountIndex: number;
|
|
111
|
+
mint: string;
|
|
112
|
+
uiTokenAmount: {
|
|
113
|
+
amount: string;
|
|
114
|
+
decimals: number;
|
|
115
|
+
};
|
|
116
|
+
owner?: string | null | undefined;
|
|
117
|
+
programId?: string | null | undefined;
|
|
118
|
+
}[] | null | undefined;
|
|
119
|
+
postTokenBalances?: {
|
|
120
|
+
accountIndex: number;
|
|
121
|
+
mint: string;
|
|
122
|
+
uiTokenAmount: {
|
|
123
|
+
amount: string;
|
|
124
|
+
decimals: number;
|
|
125
|
+
};
|
|
126
|
+
owner?: string | null | undefined;
|
|
127
|
+
programId?: string | null | undefined;
|
|
128
|
+
}[] | null | undefined;
|
|
129
|
+
innerInstructions?: {
|
|
130
|
+
index: number;
|
|
131
|
+
instructions: {
|
|
132
|
+
accounts: number[];
|
|
133
|
+
data: string;
|
|
134
|
+
programIdIndex: number;
|
|
135
|
+
stackHeight: number | null;
|
|
136
|
+
}[];
|
|
137
|
+
}[] | null | undefined;
|
|
138
|
+
loadedAddresses?: {
|
|
139
|
+
readonly: string[];
|
|
140
|
+
writable: string[];
|
|
141
|
+
} | null | undefined;
|
|
142
|
+
rewards?: {
|
|
143
|
+
pubkey: string;
|
|
144
|
+
lamports: number;
|
|
145
|
+
postBalance: string | number;
|
|
146
|
+
rewardType?: string | null | undefined;
|
|
147
|
+
commission?: number | null | undefined;
|
|
148
|
+
}[] | null | undefined;
|
|
149
|
+
returnData?: {
|
|
150
|
+
programId: string;
|
|
151
|
+
data: [string, "base64"];
|
|
152
|
+
} | null | undefined;
|
|
153
|
+
};
|
|
154
|
+
transaction: {
|
|
155
|
+
message: {
|
|
156
|
+
accountKeys: string[];
|
|
157
|
+
header: {
|
|
158
|
+
numReadonlySignedAccounts: number;
|
|
159
|
+
numReadonlyUnsignedAccounts: number;
|
|
160
|
+
numRequiredSignatures: number;
|
|
161
|
+
};
|
|
162
|
+
instructions: {
|
|
163
|
+
accounts: number[];
|
|
164
|
+
data: string;
|
|
165
|
+
programIdIndex: number;
|
|
166
|
+
stackHeight: number | null;
|
|
167
|
+
}[];
|
|
168
|
+
recentBlockhash: string;
|
|
169
|
+
addressTableLookups?: {
|
|
170
|
+
accountKey: string;
|
|
171
|
+
readonlyIndexes: number[];
|
|
172
|
+
writableIndexes: number[];
|
|
173
|
+
}[] | null | undefined;
|
|
174
|
+
};
|
|
175
|
+
signatures: string[];
|
|
176
|
+
};
|
|
177
|
+
version: number | "legacy";
|
|
178
|
+
_index?: number | null | undefined;
|
|
179
|
+
}[];
|
|
180
|
+
rewards: {
|
|
181
|
+
pubkey: string;
|
|
182
|
+
lamports: number;
|
|
183
|
+
postBalance: string | number;
|
|
184
|
+
rewardType?: string | null | undefined;
|
|
185
|
+
commission?: number | null | undefined;
|
|
186
|
+
}[];
|
|
187
|
+
}>;
|
|
188
|
+
export type GetBlock = GetSrcType<typeof GetBlock>;
|
|
189
|
+
export declare const RawBlock: import("@subsquid/util-internal-validation").Validator<{
|
|
4
190
|
hash: string;
|
|
5
191
|
height: number;
|
|
6
192
|
slot: number;
|
|
@@ -87,6 +273,7 @@ declare const RawBlock: import("@subsquid/util-internal-validation").Validator<{
|
|
|
87
273
|
signatures: string[];
|
|
88
274
|
};
|
|
89
275
|
version: number | "legacy";
|
|
276
|
+
_index?: number | undefined;
|
|
90
277
|
}[];
|
|
91
278
|
rewards: {
|
|
92
279
|
pubkey: string;
|
|
@@ -183,6 +370,7 @@ declare const RawBlock: import("@subsquid/util-internal-validation").Validator<{
|
|
|
183
370
|
signatures: string[];
|
|
184
371
|
};
|
|
185
372
|
version: number | "legacy";
|
|
373
|
+
_index?: number | null | undefined;
|
|
186
374
|
}[];
|
|
187
375
|
rewards: {
|
|
188
376
|
pubkey: string;
|
|
@@ -194,6 +382,6 @@ declare const RawBlock: import("@subsquid/util-internal-validation").Validator<{
|
|
|
194
382
|
};
|
|
195
383
|
}>;
|
|
196
384
|
export type RawBlock = GetSrcType<typeof RawBlock>;
|
|
197
|
-
export declare function
|
|
198
|
-
export
|
|
385
|
+
export declare function isVoteTransaction(tx: Transaction): boolean;
|
|
386
|
+
export declare function removeVoteTransactions(block: GetBlock): void;
|
|
199
387
|
//# sourceMappingURL=mapping.d.ts.map
|
package/lib/mapping.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAC,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAa,UAAU,EAAc,MAAM,oCAAoC,CAAA;AAGtF,eAAO,MAAM,QAAQ;;;;;;;;;;;;gCAuCi7J,CAAC;eAAiC,CAAC;4BAA+B,CAAC;;;;;;;qBAA+L,CAAC;yBAA2C,CAAC;;6BAAwE,CAAC;;;;;;;qBAA+L,CAAC;yBAA2C,CAAC;;6BAAwE,CAAC;;;;;;;;;2BAAkR,CAAC;;;;mBAA0G,CAAC;;;;0BAAqH,CAAC;0BAA4C,CAAC;;sBAAiE,CAAC;;;;;;;;;;;;;;;;;;;;mCAAmnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAAkd,CAAC;eAAiD,CAAC;4BAA+B,CAAC;;;;;;;qBAA+L,CAAC;yBAAkD,CAAC;;6BAAsF,CAAC;;;;;;;qBAA+L,CAAC;yBAAkD,CAAC;;6BAAsF,CAAC;;;;;;;;;2BAAyR,CAAC;;;;mBAAiH,CAAC;;;;0BAA8H,CAAC;0BAAmD,CAAC;;sBAA+E,CAAC;;;;;;;;;;;;;;;;;;;;mCAA0nB,CAAC;;;;;;;;;;;;;;;;;;EA/B3wS,CAAA;AAGF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAGlD,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;oCAyBi7J,CAAC;mBAAiC,CAAC;gCAA+B,CAAC;;;;;;;yBAA+L,CAAC;6BAA2C,CAAC;;iCAAwE,CAAC;;;;;;;yBAA+L,CAAC;6BAA2C,CAAC;;iCAAwE,CAAC;;;;;;;;;+BAAkR,CAAC;;;;uBAA0G,CAAC;;;;8BAAqH,CAAC;8BAA4C,CAAC;;0BAAiE,CAAC;;;;;;;;;;;;;;;;;;;;uCAAmnB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAAkd,CAAC;mBAAiD,CAAC;gCAA+B,CAAC;;;;;;;yBAA+L,CAAC;6BAAkD,CAAC;;iCAAsF,CAAC;;;;;;;yBAA+L,CAAC;6BAAkD,CAAC;;iCAAsF,CAAC;;;;;;;;;+BAAyR,CAAC;;;;uBAAiH,CAAC;;;;8BAA8H,CAAC;8BAAmD,CAAC;;0BAA+E,CAAC;;;;;;;;;;;;;;;;;;;;uCAA0nB,CAAC;;;;;;;;;;;;;;;;;;;EApB3wS,CAAA;AAGF,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;AAGlD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAI1D;AAGD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAM5D"}
|
package/lib/mapping.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.RawBlock = exports.GetBlock = void 0;
|
|
4
|
+
exports.isVoteTransaction = isVoteTransaction;
|
|
5
|
+
exports.removeVoteTransactions = removeVoteTransactions;
|
|
5
6
|
const solana_rpc_data_1 = require("@subsquid/solana-rpc-data");
|
|
6
7
|
const util_internal_validation_1 = require("@subsquid/util-internal-validation");
|
|
7
|
-
|
|
8
|
+
exports.GetBlock = (0, util_internal_validation_1.object)({
|
|
8
9
|
blockHeight: util_internal_validation_1.NAT,
|
|
9
10
|
blockTime: util_internal_validation_1.NAT,
|
|
10
11
|
blockhash: util_internal_validation_1.B58,
|
|
@@ -13,34 +14,24 @@ const GetBlock = (0, util_internal_validation_1.object)({
|
|
|
13
14
|
transactions: (0, util_internal_validation_1.array)(solana_rpc_data_1.Transaction),
|
|
14
15
|
rewards: (0, util_internal_validation_1.array)(solana_rpc_data_1.Reward)
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
+
exports.RawBlock = (0, util_internal_validation_1.object)({
|
|
17
18
|
hash: util_internal_validation_1.B58,
|
|
18
19
|
height: util_internal_validation_1.NAT,
|
|
19
20
|
slot: util_internal_validation_1.NAT,
|
|
20
|
-
block: GetBlock
|
|
21
|
+
block: exports.GetBlock
|
|
21
22
|
});
|
|
22
|
-
function
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return block;
|
|
23
|
+
function isVoteTransaction(tx) {
|
|
24
|
+
if (tx.transaction.message.instructions.length != 1)
|
|
25
|
+
return false;
|
|
26
|
+
let ins = tx.transaction.message.instructions[0];
|
|
27
|
+
return tx.transaction.message.accountKeys[ins.programIdIndex] === 'Vote111111111111111111111111111111111111111';
|
|
29
28
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
function kept(item) {
|
|
38
|
-
return !removed.has(item.transactionIndex);
|
|
39
|
-
}
|
|
40
|
-
block.transactions = block.transactions.filter(kept);
|
|
41
|
-
block.instructions = block.instructions.filter(kept);
|
|
42
|
-
block.logs = block.logs.filter(kept);
|
|
43
|
-
block.balances = block.balances.filter(kept);
|
|
44
|
-
block.tokenBalances = block.tokenBalances.filter(kept);
|
|
29
|
+
function removeVoteTransactions(block) {
|
|
30
|
+
if (!block.transactions)
|
|
31
|
+
return;
|
|
32
|
+
block.transactions = block.transactions.filter((tx, index) => {
|
|
33
|
+
tx._index = tx._index ?? index;
|
|
34
|
+
return !isVoteTransaction(tx);
|
|
35
|
+
});
|
|
45
36
|
}
|
|
46
37
|
//# sourceMappingURL=mapping.js.map
|
package/lib/mapping.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapping.js","sourceRoot":"","sources":["../src/mapping.ts"],"names":[],"mappings":";;;AA6BA,8CAIC;AAGD,wDAMC;AA1CD,+DAA6D;AAC7D,iFAAsF;AAGzE,QAAA,QAAQ,GAAG,IAAA,iCAAM,EAAC;IAC3B,WAAW,EAAE,8BAAG;IAChB,SAAS,EAAE,8BAAG;IACd,SAAS,EAAE,8BAAG;IACd,UAAU,EAAE,8BAAG;IACf,iBAAiB,EAAE,8BAAG;IACtB,YAAY,EAAE,IAAA,gCAAK,EAAC,6BAAW,CAAC;IAChC,OAAO,EAAE,IAAA,gCAAK,EAAC,wBAAM,CAAC;CACzB,CAAC,CAAA;AAMW,QAAA,QAAQ,GAAG,IAAA,iCAAM,EAAC;IAC3B,IAAI,EAAE,8BAAG;IACT,MAAM,EAAE,8BAAG;IACX,IAAI,EAAE,8BAAG;IACT,KAAK,EAAE,gBAAQ;CAClB,CAAC,CAAA;AAMF,SAAgB,iBAAiB,CAAC,EAAe;IAC7C,IAAI,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IACjE,IAAI,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;IAChD,OAAO,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,6CAA6C,CAAA;AACnH,CAAC;AAGD,SAAgB,sBAAsB,CAAC,KAAe;IAClD,IAAI,CAAC,KAAK,CAAC,YAAY;QAAE,OAAM;IAC/B,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,EAAe,EAAE,KAAK,EAAE,EAAE;QACtE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,IAAI,KAAK,CAAA;QAC9B,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;IACjC,CAAC,CAAC,CAAA;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subsquid/solana-ingest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Data fetcher and normalizer for Solana",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": "git@github.com:subsquid/squid.git",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@subsquid/solana-normalization": "^0.0
|
|
20
|
-
"@subsquid/solana-rpc-data": "^0.
|
|
19
|
+
"@subsquid/solana-normalization": "^0.1.0",
|
|
20
|
+
"@subsquid/solana-rpc-data": "^0.2.0",
|
|
21
21
|
"@subsquid/util-internal": "^3.2.0",
|
|
22
22
|
"@subsquid/util-internal-ingest-cli": "^0.2.0",
|
|
23
23
|
"@subsquid/util-internal-json": "^1.2.3",
|
package/src/ingest.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {addErrorContext} from '@subsquid/util-internal'
|
|
1
|
+
import {addErrorContext, def} from '@subsquid/util-internal'
|
|
2
2
|
import {Command, Ingest, IngestOptions, Range} from '@subsquid/util-internal-ingest-cli'
|
|
3
3
|
import {toJSON} from '@subsquid/util-internal-json'
|
|
4
|
-
import {
|
|
4
|
+
import {RawBlock, removeVoteTransactions} from './mapping'
|
|
5
|
+
import {assertValidity} from '@subsquid/util-internal-validation'
|
|
6
|
+
import {mapRpcBlock} from '@subsquid/solana-normalization'
|
|
5
7
|
|
|
6
8
|
|
|
7
9
|
interface Options extends IngestOptions {
|
|
@@ -28,12 +30,37 @@ export class SolanaIngest extends Ingest<Options> {
|
|
|
28
30
|
program.option('--no-votes', 'Exclude vote transactions')
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
@def
|
|
34
|
+
private mapping(): (raw: unknown) => object {
|
|
32
35
|
let votes = this.options().votes
|
|
36
|
+
|
|
37
|
+
return function mapRawBlock(raw: unknown): object {
|
|
38
|
+
assertValidity(RawBlock, raw)
|
|
39
|
+
|
|
40
|
+
if (!votes) {
|
|
41
|
+
removeVoteTransactions(raw.block)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let normalized = mapRpcBlock(raw, {
|
|
45
|
+
warn: function(props: any, msg: string): void {
|
|
46
|
+
throw addErrorContext(new Error(msg), props)
|
|
47
|
+
},
|
|
48
|
+
error: function(props: any, msg: string): void {
|
|
49
|
+
throw addErrorContext(new Error(msg), props)
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return normalized
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected async *getBlocks(range: Range): AsyncIterable<object[]> {
|
|
58
|
+
let mapping = this.mapping()
|
|
59
|
+
|
|
33
60
|
for await (let blocks of this.archive().getRawBlocks<RawBlock>(range)) {
|
|
34
61
|
yield blocks.map(raw => {
|
|
35
62
|
try {
|
|
36
|
-
let block =
|
|
63
|
+
let block = mapping(raw)
|
|
37
64
|
return toJSON(block)
|
|
38
65
|
} catch(err: any) {
|
|
39
66
|
throw addErrorContext(err, {
|
package/src/mapping.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {Block, mapRpcBlock} from '@subsquid/solana-normalization'
|
|
2
1
|
import {Reward, Transaction} from '@subsquid/solana-rpc-data'
|
|
3
|
-
import {array,
|
|
2
|
+
import {array, B58, GetSrcType, NAT, object} from '@subsquid/util-internal-validation'
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
const GetBlock = object({
|
|
5
|
+
export const GetBlock = object({
|
|
7
6
|
blockHeight: NAT,
|
|
8
7
|
blockTime: NAT,
|
|
9
8
|
blockhash: B58,
|
|
@@ -14,7 +13,10 @@ const GetBlock = object({
|
|
|
14
13
|
})
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
export type GetBlock = GetSrcType<typeof GetBlock>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
export const RawBlock = object({
|
|
18
20
|
hash: B58,
|
|
19
21
|
height: NAT,
|
|
20
22
|
slot: NAT,
|
|
@@ -25,32 +27,17 @@ const RawBlock = object({
|
|
|
25
27
|
export type RawBlock = GetSrcType<typeof RawBlock>
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
export function
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
removeVotes(block)
|
|
33
|
-
}
|
|
34
|
-
return block
|
|
30
|
+
export function isVoteTransaction(tx: Transaction): boolean {
|
|
31
|
+
if (tx.transaction.message.instructions.length != 1) return false
|
|
32
|
+
let ins = tx.transaction.message.instructions[0]
|
|
33
|
+
return tx.transaction.message.accountKeys[ins.programIdIndex] === 'Vote111111111111111111111111111111111111111'
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function kept(item: {transactionIndex: number}): boolean {
|
|
48
|
-
return !removed.has(item.transactionIndex)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
block.transactions = block.transactions.filter(kept)
|
|
52
|
-
block.instructions = block.instructions.filter(kept)
|
|
53
|
-
block.logs = block.logs.filter(kept)
|
|
54
|
-
block.balances = block.balances.filter(kept)
|
|
55
|
-
block.tokenBalances = block.tokenBalances.filter(kept)
|
|
37
|
+
export function removeVoteTransactions(block: GetBlock): void {
|
|
38
|
+
if (!block.transactions) return
|
|
39
|
+
block.transactions = block.transactions.filter((tx: Transaction, index) => {
|
|
40
|
+
tx._index = tx._index ?? index
|
|
41
|
+
return !isVoteTransaction(tx)
|
|
42
|
+
})
|
|
56
43
|
}
|