@xyo-network/chain-orchestration 1.18.0 → 1.18.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/dist/neutral/ChainInitializableParams.d.ts +1 -1
- package/dist/neutral/ChainInitializableParams.d.ts.map +1 -1
- package/dist/neutral/ConfigContext.d.ts +1 -1
- package/dist/neutral/ConfigContext.d.ts.map +1 -1
- package/dist/neutral/actor/BalanceActor.d.ts +3 -4
- package/dist/neutral/actor/BalanceActor.d.ts.map +1 -1
- package/dist/neutral/actor/ValidatorActor.d.ts +3 -4
- package/dist/neutral/actor/ValidatorActor.d.ts.map +1 -1
- package/dist/neutral/actor/index.d.ts +0 -1
- package/dist/neutral/actor/index.d.ts.map +1 -1
- package/dist/neutral/archivists/ChainFinalized/local.d.ts +1 -2
- package/dist/neutral/archivists/ChainFinalized/local.d.ts.map +1 -1
- package/dist/neutral/archivists/PendingBlocks/local.d.ts +1 -2
- package/dist/neutral/archivists/PendingBlocks/local.d.ts.map +1 -1
- package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts +1 -1
- package/dist/neutral/archivists/RejectedTransactions/archivist.d.ts.map +1 -1
- package/dist/neutral/archivists/RejectedTransactions/local.d.ts +1 -1
- package/dist/neutral/archivists/RejectedTransactions/local.d.ts.map +1 -1
- package/dist/neutral/archivists/StakeIntentState/archivist.d.ts +1 -1
- package/dist/neutral/archivists/StakeIntentState/archivist.d.ts.map +1 -1
- package/dist/neutral/archivists/StakeIntentState/local.d.ts +1 -1
- package/dist/neutral/archivists/StakeIntentState/local.d.ts.map +1 -1
- package/dist/neutral/buildTelemetryConfig.d.ts +2 -2
- package/dist/neutral/buildTelemetryConfig.d.ts.map +1 -1
- package/dist/neutral/createDeclarationIntentBlock.d.ts +23 -15
- package/dist/neutral/createDeclarationIntentBlock.d.ts.map +1 -1
- package/dist/neutral/evm/initChainId.d.ts +1 -1
- package/dist/neutral/evm/initChainId.d.ts.map +1 -1
- package/dist/neutral/evm/initEvmProvider.d.ts +1 -1
- package/dist/neutral/evm/initEvmProvider.d.ts.map +1 -1
- package/dist/neutral/evm/initInfuraProvider.d.ts +1 -1
- package/dist/neutral/evm/initInfuraProvider.d.ts.map +1 -1
- package/dist/neutral/evm/initJsonRpcProvider.d.ts +1 -1
- package/dist/neutral/evm/initJsonRpcProvider.d.ts.map +1 -1
- package/dist/neutral/health/initHealthEndpoints.d.ts +1 -2
- package/dist/neutral/health/initHealthEndpoints.d.ts.map +1 -1
- package/dist/neutral/index.mjs +124 -232
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/init/index.d.ts +1 -1
- package/dist/neutral/init/index.d.ts.map +1 -1
- package/dist/neutral/init/initBalanceSummaryMap.d.ts +1 -1
- package/dist/neutral/init/initBalanceSummaryMap.d.ts.map +1 -1
- package/dist/neutral/init/initBridgedModule.d.ts +1 -1
- package/dist/neutral/init/initBridgedModule.d.ts.map +1 -1
- package/dist/neutral/init/initChainStakeViewer.d.ts +1 -1
- package/dist/neutral/init/initChainStakeViewer.d.ts.map +1 -1
- package/dist/neutral/init/initFinalizedArchivist.d.ts +1 -1
- package/dist/neutral/init/initFinalizedArchivist.d.ts.map +1 -1
- package/dist/neutral/init/initProducerAccount.d.ts +1 -2
- package/dist/neutral/init/initProducerAccount.d.ts.map +1 -1
- package/dist/neutral/init/initServerNode.d.ts +1 -1
- package/dist/neutral/init/initServerNode.d.ts.map +1 -1
- package/dist/neutral/init/initStatusReporter.d.ts +1 -1
- package/dist/neutral/init/initStatusReporter.d.ts.map +1 -1
- package/dist/neutral/init/initTransferSummaryMap.d.ts +1 -1
- package/dist/neutral/init/initTransferSummaryMap.d.ts.map +1 -1
- package/dist/neutral/init/initWallet.d.ts +6 -0
- package/dist/neutral/init/initWallet.d.ts.map +1 -0
- package/dist/neutral/manifest/getLocator.d.ts +1 -1
- package/dist/neutral/manifest/getLocator.d.ts.map +1 -1
- package/dist/neutral/manifest/loadNode.d.ts +1 -1
- package/dist/neutral/manifest/loadNode.d.ts.map +1 -1
- package/dist/neutral/orchestrator/Orchestrator.d.ts +1 -1
- package/dist/neutral/orchestrator/Orchestrator.d.ts.map +1 -1
- package/package.json +31 -32
- package/src/ChainInitializableParams.ts +1 -1
- package/src/ConfigContext.ts +1 -1
- package/src/actor/BalanceActor.ts +4 -3
- package/src/actor/ValidatorActor.ts +6 -6
- package/src/actor/index.ts +0 -1
- package/src/archivists/ChainFinalized/archivist.ts +1 -1
- package/src/archivists/ChainFinalized/local.ts +1 -2
- package/src/archivists/PendingBlocks/archivist.ts +1 -1
- package/src/archivists/PendingBlocks/local.ts +1 -2
- package/src/archivists/RejectedTransactions/archivist.ts +2 -2
- package/src/archivists/RejectedTransactions/local.ts +1 -1
- package/src/archivists/StakeIntentState/archivist.ts +2 -2
- package/src/archivists/StakeIntentState/local.ts +1 -1
- package/src/buildTelemetryConfig.ts +4 -9
- package/src/createDeclarationIntentBlock.ts +2 -2
- package/src/evm/initChainId.ts +1 -1
- package/src/evm/initEvmProvider.ts +1 -1
- package/src/evm/initInfuraProvider.ts +1 -1
- package/src/evm/initJsonRpcProvider.ts +1 -1
- package/src/health/initHealthEndpoints.ts +3 -2
- package/src/init/index.ts +1 -1
- package/src/init/initBalanceSummaryMap.ts +2 -2
- package/src/init/initBridgedModule.ts +1 -1
- package/src/init/initChainStakeViewer.ts +3 -3
- package/src/init/initFinalizedArchivist.ts +1 -1
- package/src/init/initProducerAccount.ts +4 -3
- package/src/init/initServerNode.ts +1 -1
- package/src/init/initStatusReporter.ts +1 -1
- package/src/init/initTransferSummaryMap.ts +2 -2
- package/src/init/initWallet.ts +36 -0
- package/src/manifest/getLocator.ts +4 -3
- package/src/manifest/loadNode.ts +1 -1
- package/src/manifest/public/Pending.json +6 -1
- package/src/orchestrator/Orchestrator.ts +1 -2
- package/dist/neutral/actor/Actor.d.ts +0 -248
- package/dist/neutral/actor/Actor.d.ts.map +0 -1
- package/dist/neutral/init/initServerWallet.d.ts +0 -3
- package/dist/neutral/init/initServerWallet.d.ts.map +0 -1
- package/src/actor/Actor.ts +0 -199
- package/src/init/initServerWallet.ts +0 -17
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import type { CreatableInstance, CreatableParams, EmptyObject } from '@xylabs/sdk-js';
|
|
2
|
-
import { AbstractCreatable } from '@xylabs/sdk-js';
|
|
3
|
-
import { AccountInstance } from '@xyo-network/account-model';
|
|
4
|
-
import { type BaseContext, type Config, ProviderFactoryLocator, type ProviderFactoryLocatorInstance } from '@xyo-network/xl1-protocol-sdk';
|
|
5
|
-
import { Semaphore } from 'async-mutex';
|
|
6
|
-
export type ActorContext = BaseContext & {
|
|
7
|
-
config: Config;
|
|
8
|
-
locator: ProviderFactoryLocatorInstance;
|
|
9
|
-
};
|
|
10
|
-
export type ActorParams<T extends EmptyObject | void = void> = CreatableParams & {
|
|
11
|
-
account: AccountInstance;
|
|
12
|
-
context: ActorContext;
|
|
13
|
-
displayName?: string;
|
|
14
|
-
id: string;
|
|
15
|
-
} & (T extends void ? EmptyObject : T);
|
|
16
|
-
export type ActorInstance<T extends ActorParams = ActorParams> = CreatableInstance<T> & {
|
|
17
|
-
start(): Promise<boolean>;
|
|
18
|
-
stop(): Promise<boolean>;
|
|
19
|
-
};
|
|
20
|
-
export declare class Actor<TParams extends ActorParams = ActorParams> extends AbstractCreatable<TParams> {
|
|
21
|
-
protected readonly _intervals: Map<string, ReturnType<typeof setInterval>>;
|
|
22
|
-
protected readonly _semaphores: Map<string, Semaphore>;
|
|
23
|
-
protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>>;
|
|
24
|
-
private _active;
|
|
25
|
-
get displayName(): string;
|
|
26
|
-
get id(): string;
|
|
27
|
-
protected get account(): AccountInstance;
|
|
28
|
-
protected get config(): {
|
|
29
|
-
api: {
|
|
30
|
-
host: string;
|
|
31
|
-
initRewardsCache: boolean;
|
|
32
|
-
port: number;
|
|
33
|
-
mnemonic?: string | undefined;
|
|
34
|
-
};
|
|
35
|
-
bridge: {
|
|
36
|
-
chainRpcApiUrl: string;
|
|
37
|
-
feeFixed: import("@xylabs/sdk-js").Hex;
|
|
38
|
-
feeRateBasisPoints: number;
|
|
39
|
-
host: string;
|
|
40
|
-
maxBridgeAmount: import("@xylabs/sdk-js").Hex;
|
|
41
|
-
minBridgeAmount: import("@xylabs/sdk-js").Hex;
|
|
42
|
-
port: number;
|
|
43
|
-
redisHost: string;
|
|
44
|
-
redisPort: number;
|
|
45
|
-
remoteBridgeContractAddress: import("@xylabs/sdk-js").Address;
|
|
46
|
-
remoteChainId: import("@xylabs/sdk-js").Hex;
|
|
47
|
-
remoteTokenAddress: import("@xylabs/sdk-js").Hex;
|
|
48
|
-
remoteChainWalletPrivateKey: import("@xylabs/sdk-js").Hex;
|
|
49
|
-
escrowAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
50
|
-
feesAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
51
|
-
mnemonic?: string | undefined;
|
|
52
|
-
xl1ChainId?: import("@xylabs/sdk-js").Hex | undefined;
|
|
53
|
-
xl1TokenAddress?: import("@xylabs/sdk-js").Hex | undefined;
|
|
54
|
-
};
|
|
55
|
-
chain: {
|
|
56
|
-
id?: import("@xylabs/sdk-js").Hex | undefined;
|
|
57
|
-
genesisRewardAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
58
|
-
};
|
|
59
|
-
evm: {
|
|
60
|
-
chainId?: string | undefined;
|
|
61
|
-
infura?: {
|
|
62
|
-
projectId?: string | undefined;
|
|
63
|
-
projectSecret?: string | undefined;
|
|
64
|
-
} | undefined;
|
|
65
|
-
jsonRpc?: {
|
|
66
|
-
url?: string | undefined;
|
|
67
|
-
} | undefined;
|
|
68
|
-
};
|
|
69
|
-
mempool: {
|
|
70
|
-
enabled: boolean;
|
|
71
|
-
host: string;
|
|
72
|
-
port: number;
|
|
73
|
-
mnemonic?: string | undefined;
|
|
74
|
-
};
|
|
75
|
-
producer: {
|
|
76
|
-
heartbeatInterval: number;
|
|
77
|
-
minStake: number;
|
|
78
|
-
port: number;
|
|
79
|
-
allowlist?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
80
|
-
disableIntentRedeclaration?: boolean | undefined;
|
|
81
|
-
healthCheckPort?: number | undefined;
|
|
82
|
-
mnemonic?: string | undefined;
|
|
83
|
-
rewardAddress?: string | undefined;
|
|
84
|
-
};
|
|
85
|
-
rewardRedemptionApi: {
|
|
86
|
-
chainRpcApiUrl: string;
|
|
87
|
-
host: string;
|
|
88
|
-
port: number;
|
|
89
|
-
mnemonic?: string | undefined;
|
|
90
|
-
};
|
|
91
|
-
services: {
|
|
92
|
-
accountBalanceViewerEndpoint: string;
|
|
93
|
-
apiEndpoint: string;
|
|
94
|
-
};
|
|
95
|
-
storage: {
|
|
96
|
-
mongo?: {
|
|
97
|
-
connectionString?: string | undefined;
|
|
98
|
-
database?: string | undefined;
|
|
99
|
-
domain?: string | undefined;
|
|
100
|
-
password?: string | undefined;
|
|
101
|
-
username?: string | undefined;
|
|
102
|
-
} | undefined;
|
|
103
|
-
root?: string | undefined;
|
|
104
|
-
};
|
|
105
|
-
telemetry: {
|
|
106
|
-
metrics?: {
|
|
107
|
-
scrape: {
|
|
108
|
-
path: string;
|
|
109
|
-
port: number;
|
|
110
|
-
};
|
|
111
|
-
} | undefined;
|
|
112
|
-
otel?: {
|
|
113
|
-
otlpEndpoint?: string | undefined;
|
|
114
|
-
} | undefined;
|
|
115
|
-
};
|
|
116
|
-
validation: {
|
|
117
|
-
allowedRewardRedeemers?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
118
|
-
allowedRewardEscrowAccountSigners?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
119
|
-
};
|
|
120
|
-
logLevel: "info" | "error" | "warn" | "log" | "debug" | "trace";
|
|
121
|
-
silent: boolean;
|
|
122
|
-
};
|
|
123
|
-
protected get context(): ActorContext;
|
|
124
|
-
protected get locator(): ProviderFactoryLocatorInstance;
|
|
125
|
-
protected get logPrefix(): string;
|
|
126
|
-
static paramsHandler<T extends ActorParams>(params?: Partial<T>): Promise<{
|
|
127
|
-
account: T["account"];
|
|
128
|
-
context: T["context"] | {
|
|
129
|
-
config: {
|
|
130
|
-
api: {
|
|
131
|
-
host: string;
|
|
132
|
-
initRewardsCache: boolean;
|
|
133
|
-
port: number;
|
|
134
|
-
mnemonic?: string | undefined;
|
|
135
|
-
};
|
|
136
|
-
bridge: {
|
|
137
|
-
chainRpcApiUrl: string;
|
|
138
|
-
feeFixed: import("@xylabs/sdk-js").Hex;
|
|
139
|
-
feeRateBasisPoints: number;
|
|
140
|
-
host: string;
|
|
141
|
-
maxBridgeAmount: import("@xylabs/sdk-js").Hex;
|
|
142
|
-
minBridgeAmount: import("@xylabs/sdk-js").Hex;
|
|
143
|
-
port: number;
|
|
144
|
-
redisHost: string;
|
|
145
|
-
redisPort: number;
|
|
146
|
-
remoteBridgeContractAddress: import("@xylabs/sdk-js").Address;
|
|
147
|
-
remoteChainId: import("@xylabs/sdk-js").Hex;
|
|
148
|
-
remoteTokenAddress: import("@xylabs/sdk-js").Hex;
|
|
149
|
-
remoteChainWalletPrivateKey: import("@xylabs/sdk-js").Hex;
|
|
150
|
-
escrowAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
151
|
-
feesAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
152
|
-
mnemonic?: string | undefined;
|
|
153
|
-
xl1ChainId?: import("@xylabs/sdk-js").Hex | undefined;
|
|
154
|
-
xl1TokenAddress?: import("@xylabs/sdk-js").Hex | undefined;
|
|
155
|
-
};
|
|
156
|
-
chain: {
|
|
157
|
-
id?: import("@xylabs/sdk-js").Hex | undefined;
|
|
158
|
-
genesisRewardAddress?: import("@xylabs/sdk-js").Address | undefined;
|
|
159
|
-
};
|
|
160
|
-
evm: {
|
|
161
|
-
chainId?: string | undefined;
|
|
162
|
-
infura?: {
|
|
163
|
-
projectId?: string | undefined;
|
|
164
|
-
projectSecret?: string | undefined;
|
|
165
|
-
} | undefined;
|
|
166
|
-
jsonRpc?: {
|
|
167
|
-
url?: string | undefined;
|
|
168
|
-
} | undefined;
|
|
169
|
-
};
|
|
170
|
-
mempool: {
|
|
171
|
-
enabled: boolean;
|
|
172
|
-
host: string;
|
|
173
|
-
port: number;
|
|
174
|
-
mnemonic?: string | undefined;
|
|
175
|
-
};
|
|
176
|
-
producer: {
|
|
177
|
-
heartbeatInterval: number;
|
|
178
|
-
minStake: number;
|
|
179
|
-
port: number;
|
|
180
|
-
allowlist?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
181
|
-
disableIntentRedeclaration?: boolean | undefined;
|
|
182
|
-
healthCheckPort?: number | undefined;
|
|
183
|
-
mnemonic?: string | undefined;
|
|
184
|
-
rewardAddress?: string | undefined;
|
|
185
|
-
};
|
|
186
|
-
rewardRedemptionApi: {
|
|
187
|
-
chainRpcApiUrl: string;
|
|
188
|
-
host: string;
|
|
189
|
-
port: number;
|
|
190
|
-
mnemonic?: string | undefined;
|
|
191
|
-
};
|
|
192
|
-
services: {
|
|
193
|
-
accountBalanceViewerEndpoint: string;
|
|
194
|
-
apiEndpoint: string;
|
|
195
|
-
};
|
|
196
|
-
storage: {
|
|
197
|
-
mongo?: {
|
|
198
|
-
connectionString?: string | undefined;
|
|
199
|
-
database?: string | undefined;
|
|
200
|
-
domain?: string | undefined;
|
|
201
|
-
password?: string | undefined;
|
|
202
|
-
username?: string | undefined;
|
|
203
|
-
} | undefined;
|
|
204
|
-
root?: string | undefined;
|
|
205
|
-
};
|
|
206
|
-
telemetry: {
|
|
207
|
-
metrics?: {
|
|
208
|
-
scrape: {
|
|
209
|
-
path: string;
|
|
210
|
-
port: number;
|
|
211
|
-
};
|
|
212
|
-
} | undefined;
|
|
213
|
-
otel?: {
|
|
214
|
-
otlpEndpoint?: string | undefined;
|
|
215
|
-
} | undefined;
|
|
216
|
-
};
|
|
217
|
-
validation: {
|
|
218
|
-
allowedRewardRedeemers?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
219
|
-
allowedRewardEscrowAccountSigners?: import("@xylabs/sdk-js").Address[] | undefined;
|
|
220
|
-
};
|
|
221
|
-
logLevel: "info" | "error" | "warn" | "log" | "debug" | "trace";
|
|
222
|
-
silent: boolean;
|
|
223
|
-
};
|
|
224
|
-
locator: ProviderFactoryLocator;
|
|
225
|
-
};
|
|
226
|
-
displayName: import("@xylabs/sdk-js").CreatableName | NonNullable<T["displayName"]> | undefined;
|
|
227
|
-
id: import("@xylabs/sdk-js").CreatableName | T["id"] | undefined;
|
|
228
|
-
logger: import("@xylabs/sdk-js").Logger;
|
|
229
|
-
name?: import("@xylabs/sdk-js").CreatableName;
|
|
230
|
-
statusReporter?: import("@xylabs/sdk-js").CreatableStatusReporter<void> | undefined;
|
|
231
|
-
meterProvider?: import("@opentelemetry/api").MeterProvider;
|
|
232
|
-
traceProvider?: import("@opentelemetry/api").TracerProvider;
|
|
233
|
-
}>;
|
|
234
|
-
/**
|
|
235
|
-
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
236
|
-
*/
|
|
237
|
-
registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number): void;
|
|
238
|
-
/**
|
|
239
|
-
* Called by the Orchestrator when the actor is activated.
|
|
240
|
-
*/
|
|
241
|
-
startHandler(): Promise<void>;
|
|
242
|
-
/**
|
|
243
|
-
* Called by the Orchestrator when the actor is deactivated.
|
|
244
|
-
* Stop all running timers.
|
|
245
|
-
*/
|
|
246
|
-
stopHandler(): Promise<void>;
|
|
247
|
-
}
|
|
248
|
-
//# sourceMappingURL=Actor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Actor.d.ts","sourceRoot":"","sources":["../../../src/actor/Actor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAChD,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EACL,KAAK,WAAW,EAAE,KAAK,MAAM,EAE7B,sBAAsB,EACtB,KAAK,8BAA8B,EACpC,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACvC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,8BAA8B,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,WAAW,GAAG,IAAI,GAAG,IAAI,IAAI,eAAe,GAAG;IAC/E,OAAO,EAAE,eAAe,CAAA;IACxB,OAAO,EAAE,YAAY,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,EAAE,EAAE,MAAM,CAAA;CACX,GAAG,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;AAEtC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,iBAAiB,CAAC,CAAC,CAAC,GAAG;IACtF,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;IACzB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAA;CACzB,CAAA;AAED,qBACa,KAAK,CAAC,OAAO,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,iBAAiB,CAAC,OAAO,CAAC;IAC9F,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAY;IACtF,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAY;IAClE,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAY;IACpF,OAAO,CAAC,OAAO,CAAQ;IAEvB,IAAI,WAAW,WAEd;IAED,IAAI,EAAE,WAEL;IAED,SAAS,KAAK,OAAO,oBAEpB;IAED,SAAS,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEnB;IAED,SAAS,KAAK,OAAO,iBAEpB;IAED,SAAS,KAAK,OAAO,mCAEpB;IAED,SAAS,KAAK,SAAS,WAEtB;WAEqB,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAmB9E;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IA+DnG;;OAEG;IACY,YAAY;IAM3B;;;OAGG;IACY,WAAW;CA+B3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initServerWallet.d.ts","sourceRoot":"","sources":["../../../src/init/initServerWallet.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,wBAAsB,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,aAAa,+DASvE"}
|
package/src/actor/Actor.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CreatableInstance, CreatableParams, EmptyObject,
|
|
3
|
-
} from '@xylabs/sdk-js'
|
|
4
|
-
import {
|
|
5
|
-
AbstractCreatable,
|
|
6
|
-
assertEx,
|
|
7
|
-
Base, creatable, delay, IdLogger,
|
|
8
|
-
} from '@xylabs/sdk-js'
|
|
9
|
-
import { AccountInstance } from '@xyo-network/account-model'
|
|
10
|
-
import {
|
|
11
|
-
type BaseContext, type Config,
|
|
12
|
-
getDefaultConfig,
|
|
13
|
-
ProviderFactoryLocator,
|
|
14
|
-
type ProviderFactoryLocatorInstance,
|
|
15
|
-
} from '@xyo-network/xl1-protocol-sdk'
|
|
16
|
-
import { Semaphore } from 'async-mutex'
|
|
17
|
-
|
|
18
|
-
export type ActorContext = BaseContext & {
|
|
19
|
-
config: Config
|
|
20
|
-
locator: ProviderFactoryLocatorInstance
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ActorParams<T extends EmptyObject | void = void> = CreatableParams & {
|
|
24
|
-
account: AccountInstance
|
|
25
|
-
context: ActorContext
|
|
26
|
-
displayName?: string
|
|
27
|
-
id: string
|
|
28
|
-
} & (T extends void ? EmptyObject : T)
|
|
29
|
-
|
|
30
|
-
export type ActorInstance<T extends ActorParams = ActorParams> = CreatableInstance<T> & {
|
|
31
|
-
start(): Promise<boolean>
|
|
32
|
-
stop(): Promise<boolean>
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@creatable()
|
|
36
|
-
export class Actor<TParams extends ActorParams = ActorParams> extends AbstractCreatable<TParams> {
|
|
37
|
-
protected readonly _intervals: Map<string, ReturnType<typeof setInterval>> = new Map()
|
|
38
|
-
protected readonly _semaphores: Map<string, Semaphore> = new Map()
|
|
39
|
-
protected readonly _timeouts: Map<string, ReturnType<typeof setTimeout>> = new Map()
|
|
40
|
-
private _active = false
|
|
41
|
-
|
|
42
|
-
get displayName() {
|
|
43
|
-
return this.params.displayName!
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
get id() {
|
|
47
|
-
return this.params.id
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected get account() {
|
|
51
|
-
return this.params.account!
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected get config() {
|
|
55
|
-
return this.context.config
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected get context() {
|
|
59
|
-
return this.params.context
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected get locator() {
|
|
63
|
-
return this.context.locator
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected get logPrefix() {
|
|
67
|
-
return `[${this.displayName} (${this.id})] `
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static override async paramsHandler<T extends ActorParams>(params?: Partial<T>) {
|
|
71
|
-
const baseParams = await super.paramsHandler(params)
|
|
72
|
-
const id = params?.id ?? baseParams.name
|
|
73
|
-
const displayName = params?.displayName ?? baseParams.name
|
|
74
|
-
const account = assertEx(params?.account, () => `Account is required for actor ${id}.`)
|
|
75
|
-
const logger = baseParams.logger ?? new IdLogger(Base.defaultLogger ?? console, () => `[${displayName} (${id})] `)
|
|
76
|
-
const singletons = params?.context?.singletons ?? {}
|
|
77
|
-
const config = params?.context?.config ?? getDefaultConfig()
|
|
78
|
-
const context = params?.context ?? {
|
|
79
|
-
config,
|
|
80
|
-
locator: new ProviderFactoryLocator({
|
|
81
|
-
config, logger, singletons,
|
|
82
|
-
}),
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
...baseParams, account, context, displayName, id, logger,
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The timer runs until the actor is deactivated (or you manually stop it).
|
|
91
|
-
*/
|
|
92
|
-
registerTimer(timerName: string, callback: () => Promise<void>, dueTimeMs: number, periodMs: number) {
|
|
93
|
-
if (!this._active) {
|
|
94
|
-
this.logger?.warn(
|
|
95
|
-
`Cannot register timer '${timerName}' because actor is not active.`,
|
|
96
|
-
)
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
let running = false
|
|
101
|
-
|
|
102
|
-
this._semaphores.set(timerName, new Semaphore(1))
|
|
103
|
-
|
|
104
|
-
const timeoutId = setTimeout(() => {
|
|
105
|
-
const intervalId = setInterval(() => {
|
|
106
|
-
const semaphore = this._semaphores.get(timerName)
|
|
107
|
-
if (!this._active || !this._intervals.has(timerName) || !semaphore || running) return
|
|
108
|
-
if (semaphore.isLocked()) {
|
|
109
|
-
this.logger?.warn(
|
|
110
|
-
`Skipping timer '${this.name}:${timerName}' execution because previous execution is still running.`,
|
|
111
|
-
)
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
semaphore.acquire().then(([, release]) => {
|
|
115
|
-
const startTime = Date.now()
|
|
116
|
-
running = true
|
|
117
|
-
callback()
|
|
118
|
-
.then(() => {
|
|
119
|
-
const duration = Date.now() - startTime
|
|
120
|
-
if (duration > periodMs) {
|
|
121
|
-
this.logger?.warn(
|
|
122
|
-
`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than the period (${periodMs}ms).`,
|
|
123
|
-
)
|
|
124
|
-
} else if (duration > 5000) {
|
|
125
|
-
this.logger?.warn(
|
|
126
|
-
`Timer '${this.name}:${timerName}' execution took longer (${duration}ms) than 5000ms.`,
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
.catch((error) => {
|
|
131
|
-
this.logger?.error(`Error in timer '${this.name}:${timerName}': ${error}`)
|
|
132
|
-
this.logger?.error(error.stack)
|
|
133
|
-
})
|
|
134
|
-
.finally(() => {
|
|
135
|
-
release()
|
|
136
|
-
running = false
|
|
137
|
-
})
|
|
138
|
-
}).catch((error) => {
|
|
139
|
-
this.logger?.error(`Error acquiring semaphore for timer '${this.name}:${timerName}': ${error}`)
|
|
140
|
-
})
|
|
141
|
-
}, periodMs)
|
|
142
|
-
|
|
143
|
-
// store interval so we can clear it on stop()
|
|
144
|
-
this._intervals.set(timerName, intervalId)
|
|
145
|
-
}, dueTimeMs)
|
|
146
|
-
|
|
147
|
-
// store timeout so we can clear it on stop() if interval hasn't started yet
|
|
148
|
-
this._timeouts.set(timerName, timeoutId)
|
|
149
|
-
|
|
150
|
-
this.logger?.log(
|
|
151
|
-
`Timer '${this.name}:${timerName}' registered: first call after ${dueTimeMs}ms, recurring every ${periodMs}ms.`,
|
|
152
|
-
)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Called by the Orchestrator when the actor is activated.
|
|
157
|
-
*/
|
|
158
|
-
override async startHandler() {
|
|
159
|
-
await super.startHandler()
|
|
160
|
-
this._active = true
|
|
161
|
-
this.logger?.log('Started.')
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Called by the Orchestrator when the actor is deactivated.
|
|
166
|
-
* Stop all running timers.
|
|
167
|
-
*/
|
|
168
|
-
override async stopHandler() {
|
|
169
|
-
await super.stopHandler()
|
|
170
|
-
this._active = false
|
|
171
|
-
this.logger?.log('Stopping all timers...')
|
|
172
|
-
|
|
173
|
-
// wait for all semaphores to be free and acquire them to prevent new tasks from starting
|
|
174
|
-
await Promise.all(
|
|
175
|
-
[...this._semaphores.values()].map(async (semaphore) => {
|
|
176
|
-
// Wait for any running tasks to complete
|
|
177
|
-
while (semaphore.isLocked()) {
|
|
178
|
-
this.logger?.log('Waiting for running timer task to complete...')
|
|
179
|
-
await delay(500)
|
|
180
|
-
}
|
|
181
|
-
await semaphore.acquire()
|
|
182
|
-
}),
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
this._semaphores.clear()
|
|
186
|
-
|
|
187
|
-
for (const [, timeoutRef] of this._timeouts.entries()) {
|
|
188
|
-
clearTimeout(timeoutRef)
|
|
189
|
-
}
|
|
190
|
-
this._timeouts.clear()
|
|
191
|
-
|
|
192
|
-
for (const [, intervalRef] of this._intervals.entries()) {
|
|
193
|
-
clearInterval(intervalRef)
|
|
194
|
-
}
|
|
195
|
-
this._intervals.clear()
|
|
196
|
-
|
|
197
|
-
this.logger?.log('Stopped.')
|
|
198
|
-
}
|
|
199
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isDefined } from '@xylabs/sdk-js'
|
|
2
|
-
import { boot } from '@xyo-network/bios'
|
|
3
|
-
import { HDWallet } from '@xyo-network/wallet'
|
|
4
|
-
|
|
5
|
-
import type { ConfigContext } from '../ConfigContext.ts'
|
|
6
|
-
import { initSeedPhrase } from './initSeedPhrase.ts'
|
|
7
|
-
|
|
8
|
-
export async function initServerWallet({ config, logger }: ConfigContext) {
|
|
9
|
-
const { mnemonic } = config.api
|
|
10
|
-
const bios = await boot()
|
|
11
|
-
const seedPhrase = isDefined(mnemonic)
|
|
12
|
-
? mnemonic
|
|
13
|
-
: await initSeedPhrase({
|
|
14
|
-
bios, config, logger,
|
|
15
|
-
})
|
|
16
|
-
return await HDWallet.fromPhrase(seedPhrase)
|
|
17
|
-
}
|