@nosana/kit 2.0.18 → 2.0.23
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/README.md +96 -24
- package/dist/NosanaClient.d.ts +5 -5
- package/dist/NosanaClient.js +6 -5
- package/dist/NosanaClient.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/services/programs/jobs/JobsProgram.d.ts +152 -0
- package/dist/services/programs/{JobsProgram.js → jobs/JobsProgram.js} +133 -224
- package/dist/services/programs/jobs/JobsProgram.js.map +1 -0
- package/dist/services/programs/jobs/index.d.ts +1 -0
- package/dist/services/programs/jobs/index.js +2 -0
- package/dist/services/programs/jobs/index.js.map +1 -0
- package/dist/services/programs/jobs/instructions/delist.d.ts +9 -0
- package/dist/services/programs/jobs/instructions/delist.js +29 -0
- package/dist/services/programs/jobs/instructions/delist.js.map +1 -0
- package/dist/services/programs/jobs/instructions/end.d.ts +9 -0
- package/dist/services/programs/jobs/instructions/end.js +36 -0
- package/dist/services/programs/jobs/instructions/end.js.map +1 -0
- package/dist/services/programs/jobs/instructions/extend.d.ts +11 -0
- package/dist/services/programs/jobs/instructions/extend.js +27 -0
- package/dist/services/programs/jobs/instructions/extend.js.map +1 -0
- package/dist/services/programs/jobs/instructions/index.d.ts +4 -0
- package/dist/services/programs/jobs/instructions/index.js +5 -0
- package/dist/services/programs/jobs/instructions/index.js.map +1 -0
- package/dist/services/programs/jobs/instructions/post.d.ts +13 -0
- package/dist/services/programs/jobs/instructions/post.js +36 -0
- package/dist/services/programs/jobs/instructions/post.js.map +1 -0
- package/dist/services/programs/jobs/instructions/types.d.ts +16 -0
- package/dist/services/programs/jobs/instructions/types.js +2 -0
- package/dist/services/programs/jobs/instructions/types.js.map +1 -0
- package/dist/services/programs/jobs/monitor/index.d.ts +3 -0
- package/dist/services/programs/jobs/monitor/index.js +3 -0
- package/dist/services/programs/jobs/monitor/index.js.map +1 -0
- package/dist/services/programs/jobs/monitor/monitor.d.ts +22 -0
- package/dist/services/programs/jobs/monitor/monitor.js +180 -0
- package/dist/services/programs/jobs/monitor/monitor.js.map +1 -0
- package/dist/services/programs/jobs/monitor/types.d.ts +27 -0
- package/dist/services/programs/jobs/monitor/types.js +9 -0
- package/dist/services/programs/jobs/monitor/types.js.map +1 -0
- package/dist/services/programs/{MerkleDistributorProgram.d.ts → merkleDistributor/MerkleDistributorProgram.d.ts} +4 -4
- package/dist/services/programs/{MerkleDistributorProgram.js → merkleDistributor/MerkleDistributorProgram.js} +3 -3
- package/dist/services/programs/merkleDistributor/MerkleDistributorProgram.js.map +1 -0
- package/dist/services/programs/merkleDistributor/index.d.ts +1 -0
- package/dist/services/programs/merkleDistributor/index.js +2 -0
- package/dist/services/programs/merkleDistributor/index.js.map +1 -0
- package/dist/services/programs/{StakeProgram.d.ts → stake/StakeProgram.d.ts} +4 -4
- package/dist/services/programs/{StakeProgram.js → stake/StakeProgram.js} +2 -2
- package/dist/services/programs/stake/StakeProgram.js.map +1 -0
- package/dist/services/programs/stake/index.d.ts +1 -0
- package/dist/services/programs/stake/index.js +2 -0
- package/dist/services/programs/stake/index.js.map +1 -0
- package/dist/services/{SolanaService.d.ts → solana/SolanaService.d.ts} +31 -3
- package/dist/services/{SolanaService.js → solana/SolanaService.js} +84 -3
- package/dist/services/solana/SolanaService.js.map +1 -0
- package/dist/services/solana/index.d.ts +1 -0
- package/dist/services/solana/index.js +2 -0
- package/dist/services/solana/index.js.map +1 -0
- package/dist/services/token/TokenService.d.ts +63 -0
- package/dist/services/{TokenService.js → token/TokenService.js} +69 -2
- package/dist/services/token/TokenService.js.map +1 -0
- package/dist/services/token/index.d.ts +1 -0
- package/dist/services/token/index.js +2 -0
- package/dist/services/token/index.js.map +1 -0
- package/dist/types.d.ts +3 -1
- package/dist/utils/convertHttpToWebSocketUrl.d.ts +28 -0
- package/dist/utils/convertHttpToWebSocketUrl.js +37 -0
- package/dist/utils/convertHttpToWebSocketUrl.js.map +1 -0
- package/dist/utils/getStaticAccounts.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/services/SolanaService.js.map +0 -1
- package/dist/services/TokenService.d.ts +0 -41
- package/dist/services/TokenService.js.map +0 -1
- package/dist/services/programs/JobsProgram.d.ts +0 -106
- package/dist/services/programs/JobsProgram.js.map +0 -1
- package/dist/services/programs/MerkleDistributorProgram.js.map +0 -1
- package/dist/services/programs/StakeProgram.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { generateKeyPairSigner, parseBase64RpcAccount, } from '@solana/kit';
|
|
2
|
-
import { ErrorCodes, NosanaError } from '../../errors/NosanaError.js';
|
|
3
|
-
import * as programClient from '../../generated_clients/jobs/index.js';
|
|
4
|
-
import { findAssociatedTokenPda, TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
|
|
5
1
|
import bs58 from 'bs58';
|
|
6
2
|
import { solBytesArrayToIpfsHash } from '@nosana/ipfs';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { parseBase64RpcAccount } from '@solana/kit';
|
|
4
|
+
import { ErrorCodes, NosanaError } from '../../../errors/NosanaError.js';
|
|
5
|
+
import { convertBigIntToNumber } from '../../../utils/index.js';
|
|
6
|
+
import { getStaticAccounts as getStaticAccountsFn, } from '../../../utils/getStaticAccounts.js';
|
|
7
|
+
import * as Instructions from './instructions/index.js';
|
|
8
|
+
import * as programClient from '../../../generated_clients/jobs/index.js';
|
|
9
|
+
import { createMonitorFunctions } from './monitor/index.js';
|
|
9
10
|
export var JobState;
|
|
10
11
|
(function (JobState) {
|
|
11
12
|
JobState[JobState["QUEUED"] = 0] = "QUEUED";
|
|
@@ -18,6 +19,28 @@ export var MarketQueueType;
|
|
|
18
19
|
MarketQueueType[MarketQueueType["JOB_QUEUE"] = 0] = "JOB_QUEUE";
|
|
19
20
|
MarketQueueType[MarketQueueType["NODE_QUEUE"] = 1] = "NODE_QUEUE";
|
|
20
21
|
})(MarketQueueType || (MarketQueueType = {}));
|
|
22
|
+
// Re-export monitor types for convenience
|
|
23
|
+
export { MonitorEventType } from './monitor/index.js';
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new JobsProgram instance.
|
|
26
|
+
*
|
|
27
|
+
* @param deps - Program dependencies (config, logger, solana service, wallet getter)
|
|
28
|
+
* @returns A JobsProgram instance with methods to interact with the jobs program
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* import { createJobsProgram } from '@nosana/kit';
|
|
33
|
+
*
|
|
34
|
+
* const jobsProgram = createJobsProgram({
|
|
35
|
+
* config,
|
|
36
|
+
* logger,
|
|
37
|
+
* solana,
|
|
38
|
+
* getWallet,
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* const job = await jobsProgram.get('job-address');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
21
44
|
export function createJobsProgram(deps, config) {
|
|
22
45
|
const programId = config.jobsAddress;
|
|
23
46
|
const client = programClient;
|
|
@@ -58,6 +81,18 @@ export function createJobsProgram(deps, config) {
|
|
|
58
81
|
...convertBigIntToNumber(runAccountData),
|
|
59
82
|
};
|
|
60
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Merge run account data into a job account.
|
|
86
|
+
* Updates the job state to RUNNING and sets node and timeStart from the run account.
|
|
87
|
+
*/
|
|
88
|
+
function mergeRunIntoJob(job, run) {
|
|
89
|
+
return {
|
|
90
|
+
...job,
|
|
91
|
+
state: JobState.RUNNING,
|
|
92
|
+
node: run.node,
|
|
93
|
+
timeStart: run.time,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
61
96
|
/**
|
|
62
97
|
* Transform market account to include address and convert types
|
|
63
98
|
*/
|
|
@@ -71,131 +106,29 @@ export function createJobsProgram(deps, config) {
|
|
|
71
106
|
};
|
|
72
107
|
}
|
|
73
108
|
/**
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
async function setupSubscription(abortController) {
|
|
77
|
-
try {
|
|
78
|
-
// Set up the subscription using the correct API pattern
|
|
79
|
-
const subscriptionIterable = await deps.solana.rpcSubscriptions
|
|
80
|
-
.programNotifications(programId, { encoding: 'base64' })
|
|
81
|
-
.subscribe({ abortSignal: abortController.signal });
|
|
82
|
-
return subscriptionIterable;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
throw new Error(`Failed to setup subscription: ${error}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Handle job account update
|
|
90
|
-
*/
|
|
91
|
-
async function handleJobAccount(jobAccount, onJobAccount, _isMonitoring) {
|
|
92
|
-
if (onJobAccount) {
|
|
93
|
-
try {
|
|
94
|
-
await onJobAccount(transformJobAccount(jobAccount));
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
deps.logger.error(`Error in onJobAccount callback: ${error}`);
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
deps.logger.debug(`Processed job account ${jobAccount.address.toString()}`);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Handle market account update
|
|
105
|
-
*/
|
|
106
|
-
async function handleMarketAccount(marketAccount, onMarketAccount, _isMonitoring) {
|
|
107
|
-
if (onMarketAccount) {
|
|
108
|
-
try {
|
|
109
|
-
await onMarketAccount(transformMarketAccount(marketAccount));
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
deps.logger.error(`Error in onMarketAccount callback: ${error}`);
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
deps.logger.debug(`Processed market account ${marketAccount.address.toString()}`);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Handle run account update
|
|
109
|
+
* Get the required wallet or throw an error if not available
|
|
120
110
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
deps.logger.error(`Error in onRunAccount callback: ${error}`);
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
111
|
+
function getRequiredWallet() {
|
|
112
|
+
const wallet = deps.getWallet();
|
|
113
|
+
if (!wallet) {
|
|
114
|
+
throw new NosanaError('Wallet is required for this operation', ErrorCodes.NO_WALLET);
|
|
130
115
|
}
|
|
131
|
-
|
|
116
|
+
return wallet;
|
|
132
117
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*/
|
|
136
|
-
async function handleAccountUpdate(accountData, options, isMonitoring) {
|
|
137
|
-
try {
|
|
138
|
-
const { account, pubkey } = accountData;
|
|
139
|
-
const encodedAccount = parseBase64RpcAccount(pubkey, account);
|
|
140
|
-
const accountType = client.identifyNosanaJobsAccount(encodedAccount);
|
|
141
|
-
switch (accountType) {
|
|
142
|
-
case client.NosanaJobsAccount.JobAccount: {
|
|
143
|
-
const jobAccount = client.decodeJobAccount(encodedAccount);
|
|
144
|
-
await handleJobAccount(jobAccount, options.onJobAccount, isMonitoring);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
case client.NosanaJobsAccount.MarketAccount: {
|
|
148
|
-
const marketAccount = client.decodeMarketAccount(encodedAccount);
|
|
149
|
-
await handleMarketAccount(marketAccount, options.onMarketAccount, isMonitoring);
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case client.NosanaJobsAccount.RunAccount: {
|
|
153
|
-
const runAccount = client.decodeRunAccount(encodedAccount);
|
|
154
|
-
await handleRunAccount(runAccount, options.onRunAccount, isMonitoring);
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
default:
|
|
158
|
-
deps.logger.error(`No support yet for account type: ${accountType}`);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
deps.logger.error(`Error in handleAccountUpdate: ${error}`);
|
|
164
|
-
}
|
|
118
|
+
function getStaticAccounts() {
|
|
119
|
+
return getStaticAccountsFn(config, deps.solana, staticAccountsCache);
|
|
165
120
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
try {
|
|
178
|
-
const { value } = notification;
|
|
179
|
-
await handleAccountUpdate(value, options, isMonitoring);
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
deps.logger.error(`Error handling account update notification: ${error}`);
|
|
183
|
-
if (options.onError) {
|
|
184
|
-
try {
|
|
185
|
-
await options.onError(error instanceof Error ? error : new Error(String(error)));
|
|
186
|
-
}
|
|
187
|
-
catch (callbackError) {
|
|
188
|
-
deps.logger.error(`Error in onError callback: ${callbackError}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
catch (error) {
|
|
195
|
-
deps.logger.error(`Subscription error: ${error}`);
|
|
196
|
-
// Throw the error so the calling function can restart the subscription
|
|
197
|
-
throw error;
|
|
198
|
-
}
|
|
121
|
+
function createInstructionsHelper(get, getRuns) {
|
|
122
|
+
return {
|
|
123
|
+
deps,
|
|
124
|
+
config,
|
|
125
|
+
client,
|
|
126
|
+
get,
|
|
127
|
+
getRuns,
|
|
128
|
+
getRequiredWallet,
|
|
129
|
+
getStaticAccounts,
|
|
130
|
+
getNosATA: deps.nos.getATA,
|
|
131
|
+
};
|
|
199
132
|
}
|
|
200
133
|
return {
|
|
201
134
|
/**
|
|
@@ -469,115 +402,91 @@ export function createJobsProgram(deps, config) {
|
|
|
469
402
|
* Post a new job to the marketplace
|
|
470
403
|
*/
|
|
471
404
|
async post(params) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
405
|
+
return Instructions.post(params, createInstructionsHelper(this.get, this.runs));
|
|
406
|
+
},
|
|
407
|
+
async extend(params) {
|
|
408
|
+
return Instructions.extend(params, createInstructionsHelper(this.get, this.runs));
|
|
409
|
+
},
|
|
410
|
+
async delist(params) {
|
|
411
|
+
return Instructions.delist(params, createInstructionsHelper(this.get, this.runs));
|
|
412
|
+
},
|
|
413
|
+
async end(params) {
|
|
414
|
+
return Instructions.end(params, createInstructionsHelper(this.get, this.runs));
|
|
415
|
+
},
|
|
416
|
+
/**
|
|
417
|
+
* Monitor program account updates using async iterators.
|
|
418
|
+
* Automatically merges run account data into job account updates.
|
|
419
|
+
* Uses WebSocket subscriptions with automatic restart on failure.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* // Example: Simple monitoring - run accounts are automatically merged into job updates
|
|
424
|
+
* const [eventStream, stop] = await jobsProgram.monitor();
|
|
425
|
+
* for await (const event of eventStream) {
|
|
426
|
+
* if (event.type === MonitorEventType.JOB) {
|
|
427
|
+
* console.log('Job updated:', event.data.address.toString());
|
|
428
|
+
* // event.data will have state, node, and timeStart from run account if it exists
|
|
429
|
+
* } else if (event.type === MonitorEventType.MARKET) {
|
|
430
|
+
* console.log('Market updated:', event.data.address.toString());
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* // Stop monitoring when done
|
|
434
|
+
* stop();
|
|
435
|
+
* ```
|
|
436
|
+
*
|
|
437
|
+
* @returns A tuple of [eventStream, stopFunction]
|
|
438
|
+
*/
|
|
439
|
+
async monitor() {
|
|
440
|
+
const monitorFunctions = createMonitorFunctions(this.get, this.runs, {
|
|
441
|
+
deps,
|
|
442
|
+
config,
|
|
443
|
+
client,
|
|
444
|
+
transformJobAccount,
|
|
445
|
+
transformRunAccount,
|
|
446
|
+
transformMarketAccount,
|
|
447
|
+
mergeRunIntoJob,
|
|
478
448
|
});
|
|
479
|
-
|
|
480
|
-
const staticAccounts = await getStaticAccounts(config, deps.solana, staticAccountsCache);
|
|
481
|
-
// Create the list instruction
|
|
482
|
-
const instruction = client.getListInstruction({
|
|
483
|
-
job: jobKey,
|
|
484
|
-
market: params.market,
|
|
485
|
-
run: runKey,
|
|
486
|
-
user: associatedTokenAddress,
|
|
487
|
-
vault: await deps.solana.pda([params.market, config.nosTokenAddress], staticAccounts.jobsProgram),
|
|
488
|
-
payer: deps.getWallet(),
|
|
489
|
-
rewardsReflection: staticAccounts.rewardsReflection,
|
|
490
|
-
rewardsVault: staticAccounts.rewardsVault,
|
|
491
|
-
authority: deps.getWallet(),
|
|
492
|
-
rewardsProgram: staticAccounts.rewardsProgram,
|
|
493
|
-
ipfsJob: bs58.decode(params.ipfsHash).subarray(2),
|
|
494
|
-
timeout: params.timeout,
|
|
495
|
-
});
|
|
496
|
-
return instruction;
|
|
497
|
-
}
|
|
498
|
-
catch (err) {
|
|
499
|
-
const errorMessage = `Failed to create list instruction: ${err instanceof Error ? err.message : String(err)}`;
|
|
500
|
-
deps.logger.error(errorMessage);
|
|
501
|
-
throw new Error(errorMessage);
|
|
502
|
-
}
|
|
449
|
+
return monitorFunctions.monitor();
|
|
503
450
|
},
|
|
504
451
|
/**
|
|
505
|
-
* Monitor program account updates
|
|
506
|
-
* Uses WebSocket subscriptions with automatic restart on failure
|
|
452
|
+
* Monitor program account updates with detailed events for each account type.
|
|
453
|
+
* Uses WebSocket subscriptions with automatic restart on failure.
|
|
454
|
+
* Provides separate events for job, market, and run accounts.
|
|
507
455
|
*
|
|
508
456
|
* @example
|
|
509
457
|
* ```typescript
|
|
510
458
|
* // Example: Monitor job accounts and save to file
|
|
511
|
-
* const
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
459
|
+
* const [eventStream, stop] = await jobsProgram.monitorDetailed();
|
|
460
|
+
* for await (const event of eventStream) {
|
|
461
|
+
* switch (event.type) {
|
|
462
|
+
* case MonitorEventType.JOB:
|
|
463
|
+
* console.log('Job updated:', event.data.address.toString());
|
|
464
|
+
* break;
|
|
465
|
+
* case MonitorEventType.MARKET:
|
|
466
|
+
* console.log('Market updated:', event.data.address.toString());
|
|
467
|
+
* break;
|
|
468
|
+
* case MonitorEventType.RUN:
|
|
469
|
+
* console.log('Run updated:', event.data.address.toString());
|
|
470
|
+
* break;
|
|
521
471
|
* }
|
|
522
|
-
* }
|
|
523
|
-
*
|
|
472
|
+
* }
|
|
524
473
|
* // Stop monitoring when done
|
|
525
|
-
*
|
|
474
|
+
* stop();
|
|
526
475
|
* ```
|
|
527
476
|
*
|
|
528
|
-
* @
|
|
529
|
-
* @returns A function to stop monitoring
|
|
477
|
+
* @returns A tuple of [eventStream, stopFunction]
|
|
530
478
|
*/
|
|
531
|
-
async
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
deps.logger.info(`Stopped monitoring job program account updates`);
|
|
544
|
-
};
|
|
545
|
-
// Function to start/restart subscription with retry logic
|
|
546
|
-
const startSubscription = async () => {
|
|
547
|
-
while (isMonitoring) {
|
|
548
|
-
try {
|
|
549
|
-
deps.logger.info('Attempting to establish WebSocket subscription...');
|
|
550
|
-
abortController = new AbortController();
|
|
551
|
-
const subscriptionIterable = await setupSubscription(abortController);
|
|
552
|
-
deps.logger.info('Successfully established WebSocket subscription');
|
|
553
|
-
// Start processing subscription notifications
|
|
554
|
-
await processSubscriptionNotifications(subscriptionIterable, { onJobAccount, onMarketAccount, onRunAccount, onError }, () => isMonitoring);
|
|
555
|
-
}
|
|
556
|
-
catch (error) {
|
|
557
|
-
deps.logger.warn(`WebSocket subscription failed: ${error}`);
|
|
558
|
-
// Clean up current subscription
|
|
559
|
-
if (abortController) {
|
|
560
|
-
abortController.abort();
|
|
561
|
-
abortController = null;
|
|
562
|
-
}
|
|
563
|
-
if (isMonitoring) {
|
|
564
|
-
deps.logger.info('Retrying WebSocket subscription in 5 seconds...');
|
|
565
|
-
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
// Start the subscription loop
|
|
571
|
-
startSubscription().catch((error) => {
|
|
572
|
-
deps.logger.error(`Failed to start subscription loop: ${error}`);
|
|
573
|
-
});
|
|
574
|
-
deps.logger.info(`Successfully started monitoring job program account updates`);
|
|
575
|
-
return stopMonitoring;
|
|
576
|
-
}
|
|
577
|
-
catch (error) {
|
|
578
|
-
deps.logger.error(`Failed to start monitoring job program accounts: ${error}`);
|
|
579
|
-
throw new NosanaError('Failed to start monitoring job program accounts', ErrorCodes.RPC_ERROR, error);
|
|
580
|
-
}
|
|
479
|
+
async monitorDetailed() {
|
|
480
|
+
const monitorFunctions = createMonitorFunctions(this.get, this.runs, {
|
|
481
|
+
deps,
|
|
482
|
+
config,
|
|
483
|
+
client,
|
|
484
|
+
transformJobAccount,
|
|
485
|
+
transformRunAccount,
|
|
486
|
+
transformMarketAccount,
|
|
487
|
+
mergeRunIntoJob,
|
|
488
|
+
});
|
|
489
|
+
return monitorFunctions.monitorDetailed();
|
|
581
490
|
},
|
|
582
491
|
};
|
|
583
492
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JobsProgram.js","sourceRoot":"","sources":["../../../../src/services/programs/jobs/JobsProgram.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAA0B,MAAM,yBAAyB,CAAC;AAUxF,OA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BAAwB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjF,CAAC;QACD;;;;;;;;;;;;;;;;;;;;;;WAsBG;QACH,KAAK,CAAC,OAAO;YACX,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE;gBACnE,IAAI;gBACJ,MAAM;gBACN,MAAM;gBACN,mBAAmB;gBACnB,mBAAmB;gBACnB,sBAAsB;gBACtB,eAAe;aAChB,CAAC,CAAC;YACH,OAAO,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACpC,CAAC;QACD;;;;;;;;;;;;;;;;;;;;;;;;;;;WA2BG;QACH,KAAK,CAAC,eAAe;YACnB,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE;gBACnE,IAAI;gBACJ,MAAM;gBACN,MAAM;gBACN,mBAAmB;gBACnB,mBAAmB;gBACnB,sBAAsB;gBACtB,eAAe;aAChB,CAAC,CAAC;YACH,OAAO,gBAAgB,CAAC,eAAe,EAAE,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './JobsProgram.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/programs/jobs/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Address } from '@solana/kit';
|
|
2
|
+
import type { getDelistInstruction } from '../../../../generated_clients/jobs/index.js';
|
|
3
|
+
import type { InstructionsHelperParams } from './types.js';
|
|
4
|
+
export type DelistParams = {
|
|
5
|
+
job: Address;
|
|
6
|
+
};
|
|
7
|
+
export type DelistInstruction = ReturnType<typeof getDelistInstruction>;
|
|
8
|
+
export type Delist = (params: DelistParams) => Promise<DelistInstruction>;
|
|
9
|
+
export declare function delist({ job }: DelistParams, { config, deps, client, get, getRequiredWallet, getStaticAccounts, getNosATA, }: InstructionsHelperParams): Promise<DelistInstruction>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export async function delist({ job }, { config, deps, client, get, getRequiredWallet, getStaticAccounts, getNosATA, }) {
|
|
2
|
+
try {
|
|
3
|
+
const wallet = getRequiredWallet();
|
|
4
|
+
// Get Required accounts
|
|
5
|
+
const [{ market, payer }, { jobsProgram }] = await Promise.all([
|
|
6
|
+
get(job, false),
|
|
7
|
+
getStaticAccounts(),
|
|
8
|
+
]);
|
|
9
|
+
// Get associated token address for the job's payer
|
|
10
|
+
const [payerATA, vault] = await Promise.all([
|
|
11
|
+
getNosATA(payer),
|
|
12
|
+
deps.solana.pda([market, config.nosTokenAddress], jobsProgram),
|
|
13
|
+
]);
|
|
14
|
+
return client.getDelistInstruction({
|
|
15
|
+
job,
|
|
16
|
+
market,
|
|
17
|
+
vault,
|
|
18
|
+
deposit: payerATA, // Associated token address for the job's payer
|
|
19
|
+
payer,
|
|
20
|
+
authority: wallet,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
const errorMessage = `Failed to create delist instruction: ${err instanceof Error ? err.message : String(err)}`;
|
|
25
|
+
deps.logger.error(errorMessage);
|
|
26
|
+
throw new Error(errorMessage);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=delist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delist.js","sourceRoot":"","sources":["../../../../../src/services/programs/jobs/instructions/delist.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,EAAE,GAAG,EAAgB,EACrB,EACE,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,EACH,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,GACgB;IAE3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;QACnC,wBAAwB;QACxB,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC7D,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC;YACf,iBAAiB,EAAE;SACpB,CAAC,CAAC;QAEH,mDAAmD;QACnD,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1C,SAAS,CAAC,KAAK,CAAC;YAChB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC;SAC/D,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC,oBAAoB,CAAC;YACjC,GAAG;YACH,MAAM;YACN,KAAK;YACL,OAAO,EAAE,QAAQ,EAAE,+CAA+C;YAClE,KAAK;YACL,SAAS,EAAE,MAAM;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,wCAAwC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAChH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Address } from '@solana/kit';
|
|
2
|
+
import type { getEndInstruction } from '../../../../generated_clients/jobs/index.js';
|
|
3
|
+
import type { InstructionsHelperParams } from './types.js';
|
|
4
|
+
export type EndParams = {
|
|
5
|
+
job: Address;
|
|
6
|
+
};
|
|
7
|
+
export type EndInstruction = ReturnType<typeof getEndInstruction>;
|
|
8
|
+
export type End = (params: EndParams) => Promise<EndInstruction>;
|
|
9
|
+
export declare function end({ job }: EndParams, { config, deps, client, get, getRuns, getRequiredWallet, getStaticAccounts, getNosATA, }: InstructionsHelperParams): Promise<EndInstruction>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export async function end({ job }, { config, deps, client, get, getRuns, getRequiredWallet, getStaticAccounts, getNosATA, }) {
|
|
2
|
+
try {
|
|
3
|
+
const wallet = getRequiredWallet();
|
|
4
|
+
// Get Required accounts
|
|
5
|
+
const [{ market, payer }, [run], { jobsProgram }] = await Promise.all([
|
|
6
|
+
get(job, false),
|
|
7
|
+
getRuns({ job }),
|
|
8
|
+
getStaticAccounts(),
|
|
9
|
+
]);
|
|
10
|
+
if (!run) {
|
|
11
|
+
throw new Error('No job run account found for the specified job');
|
|
12
|
+
}
|
|
13
|
+
// Get associated token addresses
|
|
14
|
+
const [payerATA, nodeATA] = await Promise.all([
|
|
15
|
+
getNosATA(payer), // ATA for the job's payer (for deposit)
|
|
16
|
+
getNosATA(run.node), // ATA for the node (for user)
|
|
17
|
+
]);
|
|
18
|
+
const vault = await deps.solana.pda([market, config.nosTokenAddress], jobsProgram);
|
|
19
|
+
return client.getEndInstruction({
|
|
20
|
+
job,
|
|
21
|
+
market: market,
|
|
22
|
+
run: run.address,
|
|
23
|
+
deposit: payerATA, // ATA of the job payer
|
|
24
|
+
user: nodeATA, // ATA of the node (from run account)
|
|
25
|
+
vault: vault,
|
|
26
|
+
payer: payer, // Use payer from the job account
|
|
27
|
+
authority: wallet,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
const errorMessage = `Failed to create end instruction: ${err instanceof Error ? err.message : String(err)}`;
|
|
32
|
+
deps.logger.error(errorMessage);
|
|
33
|
+
throw new Error(errorMessage);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=end.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"end.js","s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,EAAE,KAAK,EAAE,iCAAiC;YAC/C,SAAS,EAAE,MAAM;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,qCAAqC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7G,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Address, TransactionSigner } from '@solana/kit';
|
|
2
|
+
import type { getExtendInstruction } from '../../../../generated_clients/jobs/index.js';
|
|
3
|
+
import type { InstructionsHelperParams } from './types.js';
|
|
4
|
+
export type ExtendParams = {
|
|
5
|
+
job: Address;
|
|
6
|
+
timeout: number | bigint;
|
|
7
|
+
payer?: TransactionSigner;
|
|
8
|
+
};
|
|
9
|
+
export type ExtendInstruction = ReturnType<typeof getExtendInstruction>;
|
|
10
|
+
export type Extend = (params: ExtendParams) => Promise<ExtendInstruction>;
|
|
11
|
+
export declare function extend({ job, timeout, payer }: ExtendParams, { config, deps, client, get, getRequiredWallet, getStaticAccounts, getNosATA, }: InstructionsHelperParams): Promise<ExtendInstruction>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export async function extend({ job, timeout, payer }, { config, deps, client, get, getRequiredWallet, getStaticAccounts, getNosATA, }) {
|
|
2
|
+
try {
|
|
3
|
+
const wallet = getRequiredWallet();
|
|
4
|
+
// Use provided payer or fall back to wallet
|
|
5
|
+
const nosPayer = payer ?? wallet;
|
|
6
|
+
// Get Required accounts
|
|
7
|
+
const [{ market, timeout: currentTimeout }, associatedTokenAddress, { jobsProgram, ...staticAccounts },] = await Promise.all([get(job, false), getNosATA(nosPayer.address), getStaticAccounts()]);
|
|
8
|
+
const vault = await deps.solana.pda([market, config.nosTokenAddress], jobsProgram);
|
|
9
|
+
// Create the extend instruction
|
|
10
|
+
return client.getExtendInstruction({
|
|
11
|
+
job,
|
|
12
|
+
timeout: BigInt(currentTimeout) + BigInt(timeout),
|
|
13
|
+
market: market,
|
|
14
|
+
vault,
|
|
15
|
+
payer: nosPayer,
|
|
16
|
+
authority: wallet,
|
|
17
|
+
user: associatedTokenAddress,
|
|
18
|
+
...staticAccounts,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
const errorMessage = `Failed to create extend instruction: ${err instanceof Error ? err.message : String(err)}`;
|
|
23
|
+
deps.logger.error(errorMessage);
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=extend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend.js","sourceRoot":"","sources":["../../../../../src/services/programs/jobs/instructions/extend.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAgB,EACrC,EACE,MAAM,EACN,IAAI,EACJ,MAAM,EACN,GAAG,EACH,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,GACgB;IAE3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,iBAAiB,EAAE,CAAC;QACnC,4CAA4C;QAC5C,MAAM,QAAQ,GAAG,KAAK,IAAI,MAAM,CAAC;QAEjC,wBAAwB;QACxB,MAAM,CACJ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,EACnC,sBAAsB,EACtB,EAAE,WAAW,EAAE,GAAG,cAAc,EAAE,EACnC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC;QAC3F,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,EAAE,WAAW,CAAC,CAAC;QAEnF,gCAAgC;QAChC,OAAO,MAAM,CAAC,oBAAoB,CAAC;YACjC,GAAG;YACH,OAAO,EAAE,MAAM,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;YACjD,MAAM,EAAE,MAAM;YACd,KAAK;YACL,KAAK,EAAE,QAAQ;YACf,SAAS,EAAE,MAAM;YACjB,IAAI,EAAE,sBAAsB;YAC5B,GAAG,cAAc;SAClB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,wCAAwC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAChH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/programs/jobs/instructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Address, type TransactionSigner } from '@solana/kit';
|
|
2
|
+
import type { getListInstruction } from '../../../../generated_clients/jobs/index.js';
|
|
3
|
+
import type { InstructionsHelperParams } from './types.js';
|
|
4
|
+
export type PostParams = {
|
|
5
|
+
market: Address;
|
|
6
|
+
timeout: number | bigint;
|
|
7
|
+
ipfsHash: string;
|
|
8
|
+
node?: Address;
|
|
9
|
+
payer?: TransactionSigner;
|
|
10
|
+
};
|
|
11
|
+
export type PostInstruction = ReturnType<typeof getListInstruction>;
|
|
12
|
+
export type Post = (params: PostParams) => Promise<PostInstruction>;
|
|
13
|
+
export declare function post({ market, timeout, ipfsHash, payer }: PostParams, { config, deps, client, getRequiredWallet, getStaticAccounts, getNosATA, }: InstructionsHelperParams): Promise<PostInstruction>;
|