@sentio/sdk 2.44.0 → 2.44.1-rc.2
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/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +10 -2
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +4 -4
- package/lib/utils/price.d.ts +4 -338
- package/lib/utils/price.d.ts.map +1 -1
- package/lib/utils/price.js +14 -18
- package/lib/utils/price.js.map +1 -1
- package/package.json +4 -3
- package/src/fuel/fuel-plugin.ts +9 -2
- package/src/utils/price.ts +19 -27
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-plugin.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACxH,OAAO,EAEL,cAAc,EACd,aAAa,EACb,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,YAAY,EACb,MAAM,gBAAgB,CAAA;AASvB,UAAU,QAAQ;IAChB,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAA;IAClE,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAA;CACrE;AAED,qBAAa,UAAW,SAAQ,MAAM;IACpC,IAAI,EAAE,MAAM,CAAe;IAC3B,QAAQ,EAAE,QAAQ,CAGjB;IAEK,SAAS,CAAC,MAAM,EAAE,qBAAqB;
|
1
|
+
{"version":3,"file":"fuel-plugin.d.ts","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmD,MAAM,EAAiC,MAAM,iBAAiB,CAAA;AACxH,OAAO,EAEL,cAAc,EACd,aAAa,EACb,WAAW,EACX,WAAW,EACX,qBAAqB,EACrB,aAAa,EACb,YAAY,EACb,MAAM,gBAAgB,CAAA;AASvB,UAAU,QAAQ;IAChB,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAA;IAClE,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC,EAAE,CAAA;CACrE;AAED,qBAAa,UAAW,SAAQ,MAAM;IACpC,IAAI,EAAE,MAAM,CAAe;IAC3B,QAAQ,EAAE,QAAQ,CAGjB;IAEK,SAAS,CAAC,MAAM,EAAE,qBAAqB;IAqE7C,iBAAiB,gBAAkD;IAEnE,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAWtD,KAAK,CAAC,OAAO,EAAE,YAAY;IAUjC,SAAS,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO;IAI3C,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAuBhE,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;CAsBjE"}
|
package/lib/fuel/fuel-plugin.js
CHANGED
@@ -18,7 +18,6 @@ export class FuelPlugin extends Plugin {
|
|
18
18
|
blockHandlers: []
|
19
19
|
};
|
20
20
|
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
21
|
-
await processor.configure();
|
22
21
|
const contractConfig = ContractConfig.fromPartial({
|
23
22
|
processorType: USER_PROCESSOR,
|
24
23
|
contract: {
|
@@ -91,7 +90,16 @@ export class FuelPlugin extends Plugin {
|
|
91
90
|
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType);
|
92
91
|
}
|
93
92
|
}
|
94
|
-
async start(request) {
|
93
|
+
async start(request) {
|
94
|
+
try {
|
95
|
+
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
96
|
+
await processor.configure();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
catch (e) {
|
100
|
+
throw new ServerError(Status.INTERNAL, 'error starting FuelPlugin: ' + errorString(e));
|
101
|
+
}
|
102
|
+
}
|
95
103
|
stateDiff(config) {
|
96
104
|
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length;
|
97
105
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"fuel-plugin.js","sourceRoot":"","sources":["../../src/fuel/fuel-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACxH,OAAO,EACL,cAAc,EAId,WAAW,EAIZ,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAO3D,MAAM,OAAO,UAAW,SAAQ,MAAM;IACpC,IAAI,GAAW,YAAY,CAAA;IAC3B,QAAQ,GAAa;QACnB,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;KAClB,CAAA;IAED,KAAK,CAAC,SAAS,CAAC,MAA6B;QAC3C,MAAM,QAAQ,GAAa;YACzB,YAAY,EAAE,EAAE;YAChB,aAAa,EAAE,EAAE;SAClB,CAAA;QAED,KAAK,MAAM,SAAS,IAAI,kBAAkB,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YAChE,MAAM,
|
1
|
+
{"version":3,"file":"fuel-plugin.js","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AAC,YAAY,CAAC,OAAoB;QACrC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;YACpC,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAA;QACxE,CAAC;QACD,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAA;QAEvC,MAAM,QAAQ,GAA6B,EAAE,CAAA;QAC7C,KAAK,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBAC3E,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAA;gBAC5C,MAAM,IAAI,WAAW,CACnB,MAAM,CAAC,QAAQ,EACf,0BAA0B,GAAG,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAC5E,CAAA;YACH,CAAC,CAAC,CAAA;YACF,IAAI,aAAa,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;gBACvC,MAAM,OAAO,CAAA;YACf,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;QACD,OAAO,mBAAmB,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;IACzD,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC,CAAA"}
|
@@ -74,8 +74,8 @@ declare const InitializeMultisig: import("superstruct_solana").Struct<{
|
|
74
74
|
}>;
|
75
75
|
export type Transfer = Infer<typeof Transfer>;
|
76
76
|
export declare const Transfer: import("superstruct_solana").Struct<{
|
77
|
-
source: String;
|
78
77
|
amount: string | number;
|
78
|
+
source: String;
|
79
79
|
destination: String;
|
80
80
|
signers?: String[] | undefined;
|
81
81
|
authority?: String | undefined;
|
@@ -90,8 +90,8 @@ export declare const Transfer: import("superstruct_solana").Struct<{
|
|
90
90
|
}>;
|
91
91
|
export type Approve = Infer<typeof Approve>;
|
92
92
|
declare const Approve: import("superstruct_solana").Struct<{
|
93
|
-
source: String;
|
94
93
|
amount: string | number;
|
94
|
+
source: String;
|
95
95
|
delegate: String;
|
96
96
|
owner?: String | undefined;
|
97
97
|
signers?: String[] | undefined;
|
@@ -213,8 +213,8 @@ declare const ThawAccount: import("superstruct_solana").Struct<{
|
|
213
213
|
}>;
|
214
214
|
export type TransferChecked = Infer<typeof TransferChecked>;
|
215
215
|
export declare const TransferChecked: import("superstruct_solana").Struct<{
|
216
|
-
source: String;
|
217
216
|
mint: String;
|
217
|
+
source: String;
|
218
218
|
destination: String;
|
219
219
|
tokenAmount: {
|
220
220
|
decimals: number;
|
@@ -243,8 +243,8 @@ export declare const TransferChecked: import("superstruct_solana").Struct<{
|
|
243
243
|
}>;
|
244
244
|
export type ApproveChecked = Infer<typeof ApproveChecked>;
|
245
245
|
declare const ApproveChecked: import("superstruct_solana").Struct<{
|
246
|
-
source: String;
|
247
246
|
mint: String;
|
247
|
+
source: String;
|
248
248
|
delegate: String;
|
249
249
|
tokenAmount: {
|
250
250
|
decimals: number;
|
package/lib/utils/price.d.ts
CHANGED
@@ -1,345 +1,11 @@
|
|
1
|
-
import { PriceServiceClient } from '@sentio/protos/price';
|
2
1
|
import { CoinID } from '@sentio/protos';
|
3
|
-
import { RetryOptions } from 'nice-grpc-client-middleware-retry';
|
4
2
|
import { ChainId } from '@sentio/chain';
|
5
|
-
|
6
|
-
|
7
|
-
readonly fullName: "price_service.PriceService";
|
8
|
-
readonly methods: {
|
9
|
-
readonly getPrice: {
|
10
|
-
readonly name: "GetPrice";
|
11
|
-
readonly requestType: {
|
12
|
-
encode(message: import("@sentio/protos/price").GetPriceRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
13
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").GetPriceRequest;
|
14
|
-
fromJSON(object: any): import("@sentio/protos/price").GetPriceRequest;
|
15
|
-
toJSON(message: import("@sentio/protos/price").GetPriceRequest): unknown;
|
16
|
-
create(base?: {
|
17
|
-
timestamp?: Date | undefined;
|
18
|
-
coinId?: {
|
19
|
-
symbol?: string | undefined;
|
20
|
-
address?: {
|
21
|
-
address?: string | undefined;
|
22
|
-
chain?: string | undefined;
|
23
|
-
} | undefined;
|
24
|
-
} | undefined;
|
25
|
-
source?: string | undefined;
|
26
|
-
}): import("@sentio/protos/price").GetPriceRequest;
|
27
|
-
fromPartial(object: {
|
28
|
-
timestamp?: Date | undefined;
|
29
|
-
coinId?: {
|
30
|
-
symbol?: string | undefined;
|
31
|
-
address?: {
|
32
|
-
address?: string | undefined;
|
33
|
-
chain?: string | undefined;
|
34
|
-
} | undefined;
|
35
|
-
} | undefined;
|
36
|
-
source?: string | undefined;
|
37
|
-
}): import("@sentio/protos/price").GetPriceRequest;
|
38
|
-
};
|
39
|
-
readonly requestStream: false;
|
40
|
-
readonly responseType: {
|
41
|
-
encode(message: import("@sentio/protos/price").GetPriceResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
42
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").GetPriceResponse;
|
43
|
-
fromJSON(object: any): import("@sentio/protos/price").GetPriceResponse;
|
44
|
-
toJSON(message: import("@sentio/protos/price").GetPriceResponse): unknown;
|
45
|
-
create(base?: {
|
46
|
-
price?: number | undefined;
|
47
|
-
timestamp?: Date | undefined;
|
48
|
-
}): import("@sentio/protos/price").GetPriceResponse;
|
49
|
-
fromPartial(object: {
|
50
|
-
price?: number | undefined;
|
51
|
-
timestamp?: Date | undefined;
|
52
|
-
}): import("@sentio/protos/price").GetPriceResponse;
|
53
|
-
};
|
54
|
-
readonly responseStream: false;
|
55
|
-
readonly options: {
|
56
|
-
readonly _unknownFields: {
|
57
|
-
readonly 578365826: readonly [Uint8Array];
|
58
|
-
};
|
59
|
-
};
|
60
|
-
};
|
61
|
-
readonly batchGetPrices: {
|
62
|
-
readonly name: "BatchGetPrices";
|
63
|
-
readonly requestType: {
|
64
|
-
encode(message: import("@sentio/protos/price").BatchGetPricesRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
65
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BatchGetPricesRequest;
|
66
|
-
fromJSON(object: any): import("@sentio/protos/price").BatchGetPricesRequest;
|
67
|
-
toJSON(message: import("@sentio/protos/price").BatchGetPricesRequest): unknown;
|
68
|
-
create(base?: {
|
69
|
-
timestamps?: Date[] | undefined;
|
70
|
-
coinIds?: {
|
71
|
-
symbol?: string | undefined;
|
72
|
-
address?: {
|
73
|
-
address?: string | undefined;
|
74
|
-
chain?: string | undefined;
|
75
|
-
} | undefined;
|
76
|
-
}[] | undefined;
|
77
|
-
}): import("@sentio/protos/price").BatchGetPricesRequest;
|
78
|
-
fromPartial(object: {
|
79
|
-
timestamps?: Date[] | undefined;
|
80
|
-
coinIds?: {
|
81
|
-
symbol?: string | undefined;
|
82
|
-
address?: {
|
83
|
-
address?: string | undefined;
|
84
|
-
chain?: string | undefined;
|
85
|
-
} | undefined;
|
86
|
-
}[] | undefined;
|
87
|
-
}): import("@sentio/protos/price").BatchGetPricesRequest;
|
88
|
-
};
|
89
|
-
readonly requestStream: false;
|
90
|
-
readonly responseType: {
|
91
|
-
encode(message: import("@sentio/protos/price").BatchGetPricesResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
92
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BatchGetPricesResponse;
|
93
|
-
fromJSON(object: any): import("@sentio/protos/price").BatchGetPricesResponse;
|
94
|
-
toJSON(message: import("@sentio/protos/price").BatchGetPricesResponse): unknown;
|
95
|
-
create(base?: {
|
96
|
-
prices?: {
|
97
|
-
coinId?: {
|
98
|
-
symbol?: string | undefined;
|
99
|
-
address?: {
|
100
|
-
address?: string | undefined;
|
101
|
-
chain?: string | undefined;
|
102
|
-
} | undefined;
|
103
|
-
} | undefined;
|
104
|
-
price?: {
|
105
|
-
results?: {
|
106
|
-
price?: number | undefined;
|
107
|
-
timestamp?: Date | undefined;
|
108
|
-
}[] | undefined;
|
109
|
-
} | undefined;
|
110
|
-
error?: string | undefined;
|
111
|
-
}[] | undefined;
|
112
|
-
}): import("@sentio/protos/price").BatchGetPricesResponse;
|
113
|
-
fromPartial(object: {
|
114
|
-
prices?: {
|
115
|
-
coinId?: {
|
116
|
-
symbol?: string | undefined;
|
117
|
-
address?: {
|
118
|
-
address?: string | undefined;
|
119
|
-
chain?: string | undefined;
|
120
|
-
} | undefined;
|
121
|
-
} | undefined;
|
122
|
-
price?: {
|
123
|
-
results?: {
|
124
|
-
price?: number | undefined;
|
125
|
-
timestamp?: Date | undefined;
|
126
|
-
}[] | undefined;
|
127
|
-
} | undefined;
|
128
|
-
error?: string | undefined;
|
129
|
-
}[] | undefined;
|
130
|
-
}): import("@sentio/protos/price").BatchGetPricesResponse;
|
131
|
-
};
|
132
|
-
readonly responseStream: false;
|
133
|
-
readonly options: {
|
134
|
-
readonly _unknownFields: {
|
135
|
-
readonly 578365826: readonly [Uint8Array];
|
136
|
-
};
|
137
|
-
};
|
138
|
-
};
|
139
|
-
readonly listCoins: {
|
140
|
-
readonly name: "ListCoins";
|
141
|
-
readonly requestType: {
|
142
|
-
encode(message: import("@sentio/protos/price").ListCoinsRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
143
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").ListCoinsRequest;
|
144
|
-
fromJSON(object: any): import("@sentio/protos/price").ListCoinsRequest;
|
145
|
-
toJSON(message: import("@sentio/protos/price").ListCoinsRequest): unknown;
|
146
|
-
create(base?: {
|
147
|
-
limit?: number | undefined;
|
148
|
-
offset?: number | undefined;
|
149
|
-
searchQuery?: string | undefined;
|
150
|
-
chain?: string | undefined;
|
151
|
-
}): import("@sentio/protos/price").ListCoinsRequest;
|
152
|
-
fromPartial(object: {
|
153
|
-
limit?: number | undefined;
|
154
|
-
offset?: number | undefined;
|
155
|
-
searchQuery?: string | undefined;
|
156
|
-
chain?: string | undefined;
|
157
|
-
}): import("@sentio/protos/price").ListCoinsRequest;
|
158
|
-
};
|
159
|
-
readonly requestStream: false;
|
160
|
-
readonly responseType: {
|
161
|
-
encode(message: import("@sentio/protos/price").ListCoinsResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
162
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").ListCoinsResponse;
|
163
|
-
fromJSON(object: any): import("@sentio/protos/price").ListCoinsResponse;
|
164
|
-
toJSON(message: import("@sentio/protos/price").ListCoinsResponse): unknown;
|
165
|
-
create(base?: {
|
166
|
-
coins?: {
|
167
|
-
symbol?: string | undefined;
|
168
|
-
address?: {
|
169
|
-
address?: string | undefined;
|
170
|
-
chain?: string | undefined;
|
171
|
-
} | undefined;
|
172
|
-
}[] | undefined;
|
173
|
-
coinAddressesInChain?: {
|
174
|
-
[x: string]: {
|
175
|
-
symbol?: string | undefined;
|
176
|
-
address?: {
|
177
|
-
address?: string | undefined;
|
178
|
-
chain?: string | undefined;
|
179
|
-
} | undefined;
|
180
|
-
} | undefined;
|
181
|
-
} | undefined;
|
182
|
-
}): import("@sentio/protos/price").ListCoinsResponse;
|
183
|
-
fromPartial(object: {
|
184
|
-
coins?: {
|
185
|
-
symbol?: string | undefined;
|
186
|
-
address?: {
|
187
|
-
address?: string | undefined;
|
188
|
-
chain?: string | undefined;
|
189
|
-
} | undefined;
|
190
|
-
}[] | undefined;
|
191
|
-
coinAddressesInChain?: {
|
192
|
-
[x: string]: {
|
193
|
-
symbol?: string | undefined;
|
194
|
-
address?: {
|
195
|
-
address?: string | undefined;
|
196
|
-
chain?: string | undefined;
|
197
|
-
} | undefined;
|
198
|
-
} | undefined;
|
199
|
-
} | undefined;
|
200
|
-
}): import("@sentio/protos/price").ListCoinsResponse;
|
201
|
-
};
|
202
|
-
readonly responseStream: false;
|
203
|
-
readonly options: {
|
204
|
-
readonly _unknownFields: {
|
205
|
-
readonly 578365826: readonly [Uint8Array];
|
206
|
-
};
|
207
|
-
};
|
208
|
-
};
|
209
|
-
readonly checkLatestPrice: {
|
210
|
-
readonly name: "CheckLatestPrice";
|
211
|
-
readonly requestType: {
|
212
|
-
encode(_: import("@sentio/protos").Empty, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
213
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos").Empty;
|
214
|
-
fromJSON(_: any): import("@sentio/protos").Empty;
|
215
|
-
toJSON(_: import("@sentio/protos").Empty): unknown;
|
216
|
-
create(base?: {}): import("@sentio/protos").Empty;
|
217
|
-
fromPartial(_: {}): import("@sentio/protos").Empty;
|
218
|
-
};
|
219
|
-
readonly requestStream: false;
|
220
|
-
readonly responseType: {
|
221
|
-
encode(message: import("@sentio/protos/price").CheckLatestPriceResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
222
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").CheckLatestPriceResponse;
|
223
|
-
fromJSON(object: any): import("@sentio/protos/price").CheckLatestPriceResponse;
|
224
|
-
toJSON(message: import("@sentio/protos/price").CheckLatestPriceResponse): unknown;
|
225
|
-
create(base?: {
|
226
|
-
prices?: {
|
227
|
-
coinId?: {
|
228
|
-
symbol?: string | undefined;
|
229
|
-
address?: {
|
230
|
-
address?: string | undefined;
|
231
|
-
chain?: string | undefined;
|
232
|
-
} | undefined;
|
233
|
-
} | undefined;
|
234
|
-
price?: number | undefined;
|
235
|
-
timestamp?: Date | undefined;
|
236
|
-
}[] | undefined;
|
237
|
-
latestPrice?: {
|
238
|
-
coinId?: {
|
239
|
-
symbol?: string | undefined;
|
240
|
-
address?: {
|
241
|
-
address?: string | undefined;
|
242
|
-
chain?: string | undefined;
|
243
|
-
} | undefined;
|
244
|
-
} | undefined;
|
245
|
-
price?: number | undefined;
|
246
|
-
timestamp?: Date | undefined;
|
247
|
-
} | undefined;
|
248
|
-
}): import("@sentio/protos/price").CheckLatestPriceResponse;
|
249
|
-
fromPartial(object: {
|
250
|
-
prices?: {
|
251
|
-
coinId?: {
|
252
|
-
symbol?: string | undefined;
|
253
|
-
address?: {
|
254
|
-
address?: string | undefined;
|
255
|
-
chain?: string | undefined;
|
256
|
-
} | undefined;
|
257
|
-
} | undefined;
|
258
|
-
price?: number | undefined;
|
259
|
-
timestamp?: Date | undefined;
|
260
|
-
}[] | undefined;
|
261
|
-
latestPrice?: {
|
262
|
-
coinId?: {
|
263
|
-
symbol?: string | undefined;
|
264
|
-
address?: {
|
265
|
-
address?: string | undefined;
|
266
|
-
chain?: string | undefined;
|
267
|
-
} | undefined;
|
268
|
-
} | undefined;
|
269
|
-
price?: number | undefined;
|
270
|
-
timestamp?: Date | undefined;
|
271
|
-
} | undefined;
|
272
|
-
}): import("@sentio/protos/price").CheckLatestPriceResponse;
|
273
|
-
};
|
274
|
-
readonly responseStream: false;
|
275
|
-
readonly options: {
|
276
|
-
readonly _unknownFields: {
|
277
|
-
readonly 578365826: readonly [Uint8Array];
|
278
|
-
};
|
279
|
-
};
|
280
|
-
};
|
281
|
-
readonly backfillCoin: {
|
282
|
-
readonly name: "BackfillCoin";
|
283
|
-
readonly requestType: {
|
284
|
-
encode(message: import("@sentio/protos/price").BackfillCoinRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
285
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BackfillCoinRequest;
|
286
|
-
fromJSON(object: any): import("@sentio/protos/price").BackfillCoinRequest;
|
287
|
-
toJSON(message: import("@sentio/protos/price").BackfillCoinRequest): unknown;
|
288
|
-
create(base?: {
|
289
|
-
name?: string | undefined;
|
290
|
-
symbol?: string | undefined;
|
291
|
-
chain?: string | undefined;
|
292
|
-
address?: string | undefined;
|
293
|
-
coingeckoId?: string | undefined;
|
294
|
-
decimals?: number | undefined;
|
295
|
-
logoUrl?: string | undefined;
|
296
|
-
projectUrl?: string | undefined;
|
297
|
-
accountAddress?: string | undefined;
|
298
|
-
moduleName?: string | undefined;
|
299
|
-
structName?: string | undefined;
|
300
|
-
}): import("@sentio/protos/price").BackfillCoinRequest;
|
301
|
-
fromPartial(object: {
|
302
|
-
name?: string | undefined;
|
303
|
-
symbol?: string | undefined;
|
304
|
-
chain?: string | undefined;
|
305
|
-
address?: string | undefined;
|
306
|
-
coingeckoId?: string | undefined;
|
307
|
-
decimals?: number | undefined;
|
308
|
-
logoUrl?: string | undefined;
|
309
|
-
projectUrl?: string | undefined;
|
310
|
-
accountAddress?: string | undefined;
|
311
|
-
moduleName?: string | undefined;
|
312
|
-
structName?: string | undefined;
|
313
|
-
}): import("@sentio/protos/price").BackfillCoinRequest;
|
314
|
-
};
|
315
|
-
readonly requestStream: false;
|
316
|
-
readonly responseType: {
|
317
|
-
encode(message: import("@sentio/protos/price").BackfillCoinResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
|
318
|
-
decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BackfillCoinResponse;
|
319
|
-
fromJSON(object: any): import("@sentio/protos/price").BackfillCoinResponse;
|
320
|
-
toJSON(message: import("@sentio/protos/price").BackfillCoinResponse): unknown;
|
321
|
-
create(base?: {
|
322
|
-
symbol?: string | undefined;
|
323
|
-
message?: string | undefined;
|
324
|
-
}): import("@sentio/protos/price").BackfillCoinResponse;
|
325
|
-
fromPartial(object: {
|
326
|
-
symbol?: string | undefined;
|
327
|
-
message?: string | undefined;
|
328
|
-
}): import("@sentio/protos/price").BackfillCoinResponse;
|
329
|
-
};
|
330
|
-
readonly responseStream: false;
|
331
|
-
readonly options: {
|
332
|
-
readonly _unknownFields: {
|
333
|
-
readonly 578365826: readonly [Uint8Array];
|
334
|
-
};
|
335
|
-
};
|
336
|
-
};
|
337
|
-
};
|
338
|
-
}>, RetryOptions>;
|
3
|
+
import { PriceApi } from '@sentio/api';
|
4
|
+
export declare function getPriceClient(address?: string): PriceApi;
|
339
5
|
interface PriceOptions {
|
340
6
|
toleranceInDays?: number;
|
341
7
|
}
|
342
|
-
export declare function getPriceByTypeOrSymbolInternal(priceClient:
|
8
|
+
export declare function getPriceByTypeOrSymbolInternal(priceClient: PriceApi, date: Date, coinId: CoinID, options?: PriceOptions): Promise<number | undefined>;
|
343
9
|
/**
|
344
10
|
*
|
345
11
|
* @param chainId chain id refers to CHAIN_MAP
|
@@ -358,6 +24,6 @@ export declare function getPriceBySymbol(symbol: string, date: Date, options?: P
|
|
358
24
|
* get coins that has price, return results are list of coin id with both symbol and address field set
|
359
25
|
* @param chainId
|
360
26
|
*/
|
361
|
-
export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<import("@sentio/
|
27
|
+
export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<import("@sentio/api").PriceServiceCoinID[]>;
|
362
28
|
export {};
|
363
29
|
//# sourceMappingURL=price.d.ts.map
|
package/lib/utils/price.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,YAM9C;AASD,UAAU,YAAY;IACpB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAQD,wBAAsB,8BAA8B,CAClD,WAAW,EAAE,QAAQ,EACrB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAyD7B;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAW7B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B;AAMD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,uDAgB1D"}
|
package/lib/utils/price.js
CHANGED
@@ -1,18 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import { createChannel, createClientFactory, Status } from 'nice-grpc';
|
3
|
-
import { prometheusClientMiddleware } from 'nice-grpc-prometheus';
|
4
|
-
import { retryMiddleware } from 'nice-grpc-client-middleware-retry';
|
5
|
-
import { Endpoints } from '@sentio/runtime';
|
1
|
+
import { Status } from 'nice-grpc';
|
6
2
|
import { LRUCache } from 'lru-cache';
|
3
|
+
import { Configuration, PriceApi } from '@sentio/api';
|
7
4
|
export function getPriceClient(address) {
|
8
|
-
|
9
|
-
|
10
|
-
}
|
11
|
-
const
|
12
|
-
return
|
13
|
-
.use(prometheusClientMiddleware())
|
14
|
-
.use(retryMiddleware)
|
15
|
-
.create(PriceServiceDefinition, channel);
|
5
|
+
const config = new Configuration({
|
6
|
+
apiKey: process.env.SENTIO_API_KEY
|
7
|
+
});
|
8
|
+
const api = new PriceApi(config);
|
9
|
+
return api;
|
16
10
|
}
|
17
11
|
const priceMap = new LRUCache({
|
18
12
|
max: 100000,
|
@@ -41,10 +35,9 @@ export async function getPriceByTypeOrSymbolInternal(priceClient, date, coinId,
|
|
41
35
|
}
|
42
36
|
const response = priceClient.getPrice({
|
43
37
|
timestamp: date,
|
44
|
-
coinId
|
45
|
-
|
46
|
-
|
47
|
-
retryMaxAttempts: 5
|
38
|
+
coinIdSymbol: coinId.symbol,
|
39
|
+
coinIdAddressAddress: coinId.address?.address,
|
40
|
+
coinIdAddressChain: coinId.address?.chain
|
48
41
|
});
|
49
42
|
price = response
|
50
43
|
.then((res) => {
|
@@ -118,10 +111,13 @@ export async function getCoinsThatHasPrice(chainId) {
|
|
118
111
|
if (!priceClient) {
|
119
112
|
priceClient = getPriceClient();
|
120
113
|
}
|
121
|
-
const response = await priceClient.
|
114
|
+
const response = await priceClient.priceListCoins({
|
122
115
|
chain: chainId,
|
123
116
|
limit: 1000
|
124
117
|
});
|
118
|
+
if (!response.coinAddressesInChain) {
|
119
|
+
return [];
|
120
|
+
}
|
125
121
|
return Object.entries(response.coinAddressesInChain).map(([symbol, coin]) => {
|
126
122
|
coin.symbol = symbol;
|
127
123
|
return coin;
|
package/lib/utils/price.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC;QAC/B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;KACnC,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,IAAI,QAA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QACd,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnC,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.44.
|
3
|
+
"version": "2.44.1-rc.2",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -54,6 +54,7 @@
|
|
54
54
|
"@mysten/sui.js": "~0.54.1",
|
55
55
|
"@project-serum/anchor": "^0.26.0",
|
56
56
|
"@sentio/abi-wan-kanabi": "2.2.2-1",
|
57
|
+
"@sentio/api": "1.0.2-rc.11",
|
57
58
|
"@sentio/bigdecimal": "9.1.1-patch.3",
|
58
59
|
"@sentio/chain": "^2.1.9",
|
59
60
|
"@sentio/ethers-v6": "^1.0.29",
|
@@ -84,8 +85,8 @@
|
|
84
85
|
"typechain": "^8.3.2",
|
85
86
|
"utility-types": "^3.11.0",
|
86
87
|
"yaml": "^2.3.4",
|
87
|
-
"@sentio/
|
88
|
-
"@sentio/
|
88
|
+
"@sentio/protos": "2.44.1-rc.2",
|
89
|
+
"@sentio/runtime": "^2.44.1-rc.2"
|
89
90
|
},
|
90
91
|
"peerDependencies": {
|
91
92
|
"tsup": "npm:@sentio/tsup@^6.7.5"
|
package/src/fuel/fuel-plugin.ts
CHANGED
@@ -36,7 +36,6 @@ export class FuelPlugin extends Plugin {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
39
|
-
await processor.configure()
|
40
39
|
const contractConfig = ContractConfig.fromPartial({
|
41
40
|
processorType: USER_PROCESSOR,
|
42
41
|
contract: {
|
@@ -112,7 +111,15 @@ export class FuelPlugin extends Plugin {
|
|
112
111
|
}
|
113
112
|
}
|
114
113
|
|
115
|
-
async start(request: StartRequest) {
|
114
|
+
async start(request: StartRequest) {
|
115
|
+
try {
|
116
|
+
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
117
|
+
await processor.configure()
|
118
|
+
}
|
119
|
+
} catch (e) {
|
120
|
+
throw new ServerError(Status.INTERNAL, 'error starting FuelPlugin: ' + errorString(e))
|
121
|
+
}
|
122
|
+
}
|
116
123
|
|
117
124
|
stateDiff(config: ProcessConfigResponse): boolean {
|
118
125
|
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
package/src/utils/price.ts
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
import { PriceServiceClient, PriceServiceDefinition } from '@sentio/protos/price'
|
2
1
|
import { CoinID } from '@sentio/protos'
|
3
|
-
import {
|
4
|
-
import { prometheusClientMiddleware } from 'nice-grpc-prometheus'
|
5
|
-
import { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'
|
6
|
-
import { Endpoints } from '@sentio/runtime'
|
2
|
+
import { Status } from 'nice-grpc'
|
7
3
|
import { ChainId } from '@sentio/chain'
|
8
4
|
import { LRUCache } from 'lru-cache'
|
5
|
+
import { Configuration, PriceApi } from '@sentio/api'
|
9
6
|
|
10
7
|
export function getPriceClient(address?: string) {
|
11
|
-
|
12
|
-
|
13
|
-
}
|
14
|
-
const
|
15
|
-
|
16
|
-
return createClientFactory()
|
17
|
-
.use(prometheusClientMiddleware())
|
18
|
-
.use(retryMiddleware)
|
19
|
-
.create(PriceServiceDefinition, channel)
|
8
|
+
const config = new Configuration({
|
9
|
+
apiKey: process.env.SENTIO_API_KEY
|
10
|
+
})
|
11
|
+
const api = new PriceApi(config)
|
12
|
+
return api
|
20
13
|
}
|
21
14
|
|
22
15
|
const priceMap = new LRUCache<string, Promise<number | undefined>>({
|
@@ -24,7 +17,7 @@ const priceMap = new LRUCache<string, Promise<number | undefined>>({
|
|
24
17
|
ttl: 1000 * 60 * 60 // 1 hour
|
25
18
|
})
|
26
19
|
|
27
|
-
let priceClient:
|
20
|
+
let priceClient: PriceApi
|
28
21
|
|
29
22
|
interface PriceOptions {
|
30
23
|
toleranceInDays?: number
|
@@ -37,7 +30,7 @@ async function getPriceByTypeOrSymbol(date: Date, coinId: CoinID, options?: Pric
|
|
37
30
|
}
|
38
31
|
|
39
32
|
export async function getPriceByTypeOrSymbolInternal(
|
40
|
-
priceClient:
|
33
|
+
priceClient: PriceApi,
|
41
34
|
date: Date,
|
42
35
|
coinId: CoinID,
|
43
36
|
options?: PriceOptions
|
@@ -56,16 +49,12 @@ export async function getPriceByTypeOrSymbolInternal(
|
|
56
49
|
return price
|
57
50
|
}
|
58
51
|
|
59
|
-
const response = priceClient.getPrice(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
retry: true,
|
66
|
-
retryMaxAttempts: 5
|
67
|
-
}
|
68
|
-
)
|
52
|
+
const response = priceClient.getPrice({
|
53
|
+
timestamp: date,
|
54
|
+
coinIdSymbol: coinId.symbol,
|
55
|
+
coinIdAddressAddress: coinId.address?.address,
|
56
|
+
coinIdAddressChain: coinId.address?.chain
|
57
|
+
})
|
69
58
|
price = response
|
70
59
|
.then((res) => {
|
71
60
|
if (res.timestamp) {
|
@@ -154,11 +143,14 @@ export async function getCoinsThatHasPrice(chainId: ChainId) {
|
|
154
143
|
if (!priceClient) {
|
155
144
|
priceClient = getPriceClient()
|
156
145
|
}
|
157
|
-
const response = await priceClient.
|
146
|
+
const response = await priceClient.priceListCoins({
|
158
147
|
chain: chainId,
|
159
148
|
limit: 1000
|
160
149
|
})
|
161
150
|
|
151
|
+
if (!response.coinAddressesInChain) {
|
152
|
+
return []
|
153
|
+
}
|
162
154
|
return Object.entries(response.coinAddressesInChain).map(([symbol, coin]) => {
|
163
155
|
coin.symbol = symbol
|
164
156
|
return coin
|