@nosana/kit 0.1.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/.gitlab-ci.yml +21 -0
- package/README.md +159 -0
- package/dist/config/defaultConfigs.d.ts +2 -0
- package/dist/config/defaultConfigs.js +47 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.js +19 -0
- package/dist/config/types.d.ts +43 -0
- package/dist/config/types.js +16 -0
- package/dist/config/utils.d.ts +3 -0
- package/dist/config/utils.js +35 -0
- package/dist/errors/NosanaError.d.ts +16 -0
- package/dist/errors/NosanaError.js +22 -0
- package/dist/generated_clients/jobs/accounts/index.d.ts +10 -0
- package/dist/generated_clients/jobs/accounts/index.js +26 -0
- package/dist/generated_clients/jobs/accounts/jobAccount.d.ts +47 -0
- package/dist/generated_clients/jobs/accounts/jobAccount.js +86 -0
- package/dist/generated_clients/jobs/accounts/marketAccount.d.ts +46 -0
- package/dist/generated_clients/jobs/accounts/marketAccount.js +82 -0
- package/dist/generated_clients/jobs/accounts/runAccount.d.ts +35 -0
- package/dist/generated_clients/jobs/accounts/runAccount.js +74 -0
- package/dist/generated_clients/jobs/errors/index.d.ts +8 -0
- package/dist/generated_clients/jobs/errors/index.js +24 -0
- package/dist/generated_clients/jobs/errors/nosanaJobs.d.ts +57 -0
- package/dist/generated_clients/jobs/errors/nosanaJobs.js +85 -0
- package/dist/generated_clients/jobs/index.d.ts +12 -0
- package/dist/generated_clients/jobs/index.js +28 -0
- package/dist/generated_clients/jobs/instructions/claim.d.ts +60 -0
- package/dist/generated_clients/jobs/instructions/claim.js +102 -0
- package/dist/generated_clients/jobs/instructions/clean.d.ts +42 -0
- package/dist/generated_clients/jobs/instructions/clean.js +79 -0
- package/dist/generated_clients/jobs/instructions/cleanAdmin.d.ts +42 -0
- package/dist/generated_clients/jobs/instructions/cleanAdmin.js +79 -0
- package/dist/generated_clients/jobs/instructions/close.d.ts +48 -0
- package/dist/generated_clients/jobs/instructions/close.js +90 -0
- package/dist/generated_clients/jobs/instructions/closeAdmin.d.ts +48 -0
- package/dist/generated_clients/jobs/instructions/closeAdmin.js +90 -0
- package/dist/generated_clients/jobs/instructions/complete.d.ts +43 -0
- package/dist/generated_clients/jobs/instructions/complete.js +82 -0
- package/dist/generated_clients/jobs/instructions/delist.d.ts +54 -0
- package/dist/generated_clients/jobs/instructions/delist.js +96 -0
- package/dist/generated_clients/jobs/instructions/end.d.ts +60 -0
- package/dist/generated_clients/jobs/instructions/end.js +102 -0
- package/dist/generated_clients/jobs/instructions/extend.d.ts +64 -0
- package/dist/generated_clients/jobs/instructions/extend.js +111 -0
- package/dist/generated_clients/jobs/instructions/finish.d.ts +67 -0
- package/dist/generated_clients/jobs/instructions/finish.js +111 -0
- package/dist/generated_clients/jobs/instructions/index.d.ts +25 -0
- package/dist/generated_clients/jobs/instructions/index.js +41 -0
- package/dist/generated_clients/jobs/instructions/list.d.ts +76 -0
- package/dist/generated_clients/jobs/instructions/list.js +126 -0
- package/dist/generated_clients/jobs/instructions/open.d.ts +73 -0
- package/dist/generated_clients/jobs/instructions/open.js +121 -0
- package/dist/generated_clients/jobs/instructions/quit.d.ts +45 -0
- package/dist/generated_clients/jobs/instructions/quit.js +82 -0
- package/dist/generated_clients/jobs/instructions/quitAdmin.d.ts +42 -0
- package/dist/generated_clients/jobs/instructions/quitAdmin.js +79 -0
- package/dist/generated_clients/jobs/instructions/recover.d.ts +54 -0
- package/dist/generated_clients/jobs/instructions/recover.js +96 -0
- package/dist/generated_clients/jobs/instructions/stop.d.ts +42 -0
- package/dist/generated_clients/jobs/instructions/stop.js +79 -0
- package/dist/generated_clients/jobs/instructions/update.d.ts +58 -0
- package/dist/generated_clients/jobs/instructions/update.js +93 -0
- package/dist/generated_clients/jobs/instructions/work.d.ts +57 -0
- package/dist/generated_clients/jobs/instructions/work.js +99 -0
- package/dist/generated_clients/jobs/programs/index.d.ts +8 -0
- package/dist/generated_clients/jobs/programs/index.js +24 -0
- package/dist/generated_clients/jobs/programs/nosanaJobs.d.ts +78 -0
- package/dist/generated_clients/jobs/programs/nosanaJobs.js +112 -0
- package/dist/generated_clients/jobs/shared/index.d.ts +49 -0
- package/dist/generated_clients/jobs/shared/index.js +94 -0
- package/dist/generated_clients/jobs/types/index.d.ts +10 -0
- package/dist/generated_clients/jobs/types/index.js +26 -0
- package/dist/generated_clients/jobs/types/jobState.d.ts +18 -0
- package/dist/generated_clients/jobs/types/jobState.js +30 -0
- package/dist/generated_clients/jobs/types/jobType.d.ts +21 -0
- package/dist/generated_clients/jobs/types/jobType.js +33 -0
- package/dist/generated_clients/jobs/types/queueType.d.ts +18 -0
- package/dist/generated_clients/jobs/types/queueType.js +30 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +43 -0
- package/dist/ipfs/IPFS.d.ts +19 -0
- package/dist/ipfs/IPFS.js +47 -0
- package/dist/logger/Logger.d.ts +24 -0
- package/dist/logger/Logger.js +63 -0
- package/dist/programs/BaseProgram.d.ts +20 -0
- package/dist/programs/BaseProgram.js +39 -0
- package/dist/programs/JobsProgram.d.ts +118 -0
- package/dist/programs/JobsProgram.js +611 -0
- package/dist/solana/SolanaUtils.d.ts +15 -0
- package/dist/solana/SolanaUtils.js +48 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.js +17 -0
- package/examples/node/monitor.ts +143 -0
- package/examples/node/package-lock.json +245 -0
- package/examples/node/package.json +16 -0
- package/examples/node/retrieve.ts +18 -0
- package/package.json +47 -0
- package/scripts/generate-clients.ts +9 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertBigIntToNumber = convertBigIntToNumber;
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to convert bigint values to numbers in an object
|
|
6
|
+
* @param obj Object that may contain bigint values
|
|
7
|
+
* @returns Object with all bigint values converted to numbers
|
|
8
|
+
*/
|
|
9
|
+
function convertBigIntToNumber(obj) {
|
|
10
|
+
const result = { ...obj };
|
|
11
|
+
for (const [key, value] of Object.entries(result)) {
|
|
12
|
+
if (typeof value === 'bigint') {
|
|
13
|
+
result[key] = Number(value);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { NosanaClient, NosanaNetwork, Job, Market, Run } from '@nosana/kit';
|
|
2
|
+
import { promises as fs } from 'fs';
|
|
3
|
+
|
|
4
|
+
// Type for storing accounts in a more readable format
|
|
5
|
+
type AccountData = {
|
|
6
|
+
address: string;
|
|
7
|
+
data: Job | Run | Market;
|
|
8
|
+
lastUpdated: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
// Initialize the Nosana client
|
|
13
|
+
const client = new NosanaClient(NosanaNetwork.MAINNET);
|
|
14
|
+
|
|
15
|
+
console.log('Starting job account monitoring...');
|
|
16
|
+
|
|
17
|
+
// Storage for accounts
|
|
18
|
+
const jobAccounts = new Map<string, AccountData>();
|
|
19
|
+
const runAccounts = new Map<string, AccountData>();
|
|
20
|
+
const marketAccounts = new Map<string, AccountData>();
|
|
21
|
+
|
|
22
|
+
// Helper function to save accounts to file
|
|
23
|
+
const saveAccountsToFile = async () => {
|
|
24
|
+
const data = {
|
|
25
|
+
jobAccounts: Object.fromEntries(jobAccounts),
|
|
26
|
+
runAccounts: Object.fromEntries(runAccounts),
|
|
27
|
+
marketAccounts: Object.fromEntries(marketAccounts),
|
|
28
|
+
lastUpdated: new Date().toISOString(),
|
|
29
|
+
totalAccounts: jobAccounts.size + runAccounts.size + marketAccounts.size
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await fs.writeFile('accounts.json', JSON.stringify(data, null, 2));
|
|
34
|
+
console.log(`💾 Saved ${data.totalAccounts} accounts to accounts.json`);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Failed to save accounts to file:', error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Load existing accounts if file exists
|
|
41
|
+
try {
|
|
42
|
+
const existingData = await fs.readFile('accounts.json', 'utf-8');
|
|
43
|
+
const parsed = JSON.parse(existingData);
|
|
44
|
+
|
|
45
|
+
if (parsed.jobAccounts) {
|
|
46
|
+
for (const [key, value] of Object.entries(parsed.jobAccounts)) {
|
|
47
|
+
jobAccounts.set(key, value as AccountData);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (parsed.runAccounts) {
|
|
51
|
+
for (const [key, value] of Object.entries(parsed.runAccounts)) {
|
|
52
|
+
runAccounts.set(key, value as AccountData);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (parsed.marketAccounts) {
|
|
56
|
+
for (const [key, value] of Object.entries(parsed.marketAccounts)) {
|
|
57
|
+
marketAccounts.set(key, value as AccountData);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
console.log(`📂 Loaded existing accounts: ${jobAccounts.size} jobs, ${runAccounts.size} runs, ${marketAccounts.size} markets`);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.log('📝 Starting with empty account storage (no existing file found)');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
// Start monitoring job account updates with callback functions
|
|
68
|
+
const stopMonitoring = await client.jobs.monitor({
|
|
69
|
+
onJobAccount: async (jobAccount: Job) => {
|
|
70
|
+
const accountData: AccountData = {
|
|
71
|
+
address: jobAccount.address.toString(),
|
|
72
|
+
data: jobAccount,
|
|
73
|
+
lastUpdated: new Date().toISOString()
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
jobAccounts.set(jobAccount.address.toString(), accountData);
|
|
77
|
+
console.log(`🔄 Job account updated: ${jobAccount.address.toString()}`);
|
|
78
|
+
|
|
79
|
+
// Save to file after each update
|
|
80
|
+
await saveAccountsToFile();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
onRunAccount: async (runAccount: Run) => {
|
|
84
|
+
const accountData: AccountData = {
|
|
85
|
+
address: runAccount.address.toString(),
|
|
86
|
+
data: runAccount,
|
|
87
|
+
lastUpdated: new Date().toISOString()
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
runAccounts.set(runAccount.address.toString(), accountData);
|
|
91
|
+
console.log(`🏃 Run account updated: ${runAccount.address.toString()}`);
|
|
92
|
+
|
|
93
|
+
// Save to file after each update
|
|
94
|
+
await saveAccountsToFile();
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
onMarketAccount: async (marketAccount: Market) => {
|
|
98
|
+
const accountData: AccountData = {
|
|
99
|
+
address: marketAccount.address.toString(),
|
|
100
|
+
data: marketAccount,
|
|
101
|
+
lastUpdated: new Date().toISOString()
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
marketAccounts.set(marketAccount.address.toString(), accountData);
|
|
105
|
+
console.log(`🏪 Market account updated: ${marketAccount.address.toString()}`);
|
|
106
|
+
|
|
107
|
+
// Save to file after each update
|
|
108
|
+
await saveAccountsToFile();
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
onError: async (error: Error, accountType?: string) => {
|
|
112
|
+
console.error(`❌ Error processing ${accountType || 'unknown'} account:`, error.message);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
console.log('✅ Job account monitoring started successfully!');
|
|
117
|
+
console.log('📊 Monitoring will save account updates to accounts.json');
|
|
118
|
+
console.log('🔍 Watching for job, run, and market account updates...');
|
|
119
|
+
console.log('⏹️ Press Ctrl+C to stop monitoring...');
|
|
120
|
+
|
|
121
|
+
// Handle graceful shutdown
|
|
122
|
+
process.on('SIGINT', async () => {
|
|
123
|
+
console.log('\n🛑 Stopping job account monitoring...');
|
|
124
|
+
stopMonitoring();
|
|
125
|
+
|
|
126
|
+
// Final save
|
|
127
|
+
await saveAccountsToFile();
|
|
128
|
+
|
|
129
|
+
console.log('✅ Monitoring stopped. Final data saved. Exiting...');
|
|
130
|
+
process.exit(0);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Keep the process running
|
|
134
|
+
await new Promise(() => { });
|
|
135
|
+
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error('❌ Failed to start job account monitoring:', error);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Run the example
|
|
143
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nosana-sdk-node-examples",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "nosana-sdk-node-examples",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@nosana/kit": "file:../.."
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"ts-node": "^10.9.1",
|
|
15
|
+
"typescript": "^5.0.0"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"../..": {
|
|
19
|
+
"name": "@nosana/sdk",
|
|
20
|
+
"version": "0.1.0",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"gill": "^0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/jest": "^29.5.12",
|
|
27
|
+
"@types/node": "^20.11.24",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
29
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
30
|
+
"eslint": "^8.57.0",
|
|
31
|
+
"jest": "^29.7.0",
|
|
32
|
+
"prettier": "^3.2.5",
|
|
33
|
+
"ts-jest": "^29.1.2",
|
|
34
|
+
"typescript": "^5.3.3"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.18.0"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"node_modules/@cspotcode/source-map-support": {
|
|
41
|
+
"version": "0.8.1",
|
|
42
|
+
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
|
|
43
|
+
"integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
|
|
44
|
+
"dev": true,
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@jridgewell/trace-mapping": "0.3.9"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=12"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"node_modules/@jridgewell/resolve-uri": {
|
|
53
|
+
"version": "3.1.2",
|
|
54
|
+
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
|
55
|
+
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
|
56
|
+
"dev": true,
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=6.0.0"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"node_modules/@jridgewell/sourcemap-codec": {
|
|
62
|
+
"version": "1.5.0",
|
|
63
|
+
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz",
|
|
64
|
+
"integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==",
|
|
65
|
+
"dev": true
|
|
66
|
+
},
|
|
67
|
+
"node_modules/@jridgewell/trace-mapping": {
|
|
68
|
+
"version": "0.3.9",
|
|
69
|
+
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
|
|
70
|
+
"integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
|
|
71
|
+
"dev": true,
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@jridgewell/resolve-uri": "^3.0.3",
|
|
74
|
+
"@jridgewell/sourcemap-codec": "^1.4.10"
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"node_modules/@nosana/kit": {
|
|
78
|
+
"resolved": "../..",
|
|
79
|
+
"link": true
|
|
80
|
+
},
|
|
81
|
+
"node_modules/@tsconfig/node10": {
|
|
82
|
+
"version": "1.0.11",
|
|
83
|
+
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
|
84
|
+
"integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==",
|
|
85
|
+
"dev": true
|
|
86
|
+
},
|
|
87
|
+
"node_modules/@tsconfig/node12": {
|
|
88
|
+
"version": "1.0.11",
|
|
89
|
+
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
|
|
90
|
+
"integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
|
|
91
|
+
"dev": true
|
|
92
|
+
},
|
|
93
|
+
"node_modules/@tsconfig/node14": {
|
|
94
|
+
"version": "1.0.3",
|
|
95
|
+
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
|
|
96
|
+
"integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
|
|
97
|
+
"dev": true
|
|
98
|
+
},
|
|
99
|
+
"node_modules/@tsconfig/node16": {
|
|
100
|
+
"version": "1.0.4",
|
|
101
|
+
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz",
|
|
102
|
+
"integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==",
|
|
103
|
+
"dev": true
|
|
104
|
+
},
|
|
105
|
+
"node_modules/@types/node": {
|
|
106
|
+
"version": "22.15.18",
|
|
107
|
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.18.tgz",
|
|
108
|
+
"integrity": "sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==",
|
|
109
|
+
"dev": true,
|
|
110
|
+
"peer": true,
|
|
111
|
+
"dependencies": {
|
|
112
|
+
"undici-types": "~6.21.0"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"node_modules/acorn": {
|
|
116
|
+
"version": "8.14.1",
|
|
117
|
+
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.1.tgz",
|
|
118
|
+
"integrity": "sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==",
|
|
119
|
+
"dev": true,
|
|
120
|
+
"bin": {
|
|
121
|
+
"acorn": "bin/acorn"
|
|
122
|
+
},
|
|
123
|
+
"engines": {
|
|
124
|
+
"node": ">=0.4.0"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"node_modules/acorn-walk": {
|
|
128
|
+
"version": "8.3.4",
|
|
129
|
+
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz",
|
|
130
|
+
"integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==",
|
|
131
|
+
"dev": true,
|
|
132
|
+
"dependencies": {
|
|
133
|
+
"acorn": "^8.11.0"
|
|
134
|
+
},
|
|
135
|
+
"engines": {
|
|
136
|
+
"node": ">=0.4.0"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"node_modules/arg": {
|
|
140
|
+
"version": "4.1.3",
|
|
141
|
+
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
|
142
|
+
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
|
|
143
|
+
"dev": true
|
|
144
|
+
},
|
|
145
|
+
"node_modules/create-require": {
|
|
146
|
+
"version": "1.1.1",
|
|
147
|
+
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
|
148
|
+
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
|
149
|
+
"dev": true
|
|
150
|
+
},
|
|
151
|
+
"node_modules/diff": {
|
|
152
|
+
"version": "4.0.2",
|
|
153
|
+
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
|
154
|
+
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
|
155
|
+
"dev": true,
|
|
156
|
+
"engines": {
|
|
157
|
+
"node": ">=0.3.1"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"node_modules/make-error": {
|
|
161
|
+
"version": "1.3.6",
|
|
162
|
+
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
|
163
|
+
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
|
164
|
+
"dev": true
|
|
165
|
+
},
|
|
166
|
+
"node_modules/ts-node": {
|
|
167
|
+
"version": "10.9.2",
|
|
168
|
+
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz",
|
|
169
|
+
"integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==",
|
|
170
|
+
"dev": true,
|
|
171
|
+
"dependencies": {
|
|
172
|
+
"@cspotcode/source-map-support": "^0.8.0",
|
|
173
|
+
"@tsconfig/node10": "^1.0.7",
|
|
174
|
+
"@tsconfig/node12": "^1.0.7",
|
|
175
|
+
"@tsconfig/node14": "^1.0.0",
|
|
176
|
+
"@tsconfig/node16": "^1.0.2",
|
|
177
|
+
"acorn": "^8.4.1",
|
|
178
|
+
"acorn-walk": "^8.1.1",
|
|
179
|
+
"arg": "^4.1.0",
|
|
180
|
+
"create-require": "^1.1.0",
|
|
181
|
+
"diff": "^4.0.1",
|
|
182
|
+
"make-error": "^1.1.1",
|
|
183
|
+
"v8-compile-cache-lib": "^3.0.1",
|
|
184
|
+
"yn": "3.1.1"
|
|
185
|
+
},
|
|
186
|
+
"bin": {
|
|
187
|
+
"ts-node": "dist/bin.js",
|
|
188
|
+
"ts-node-cwd": "dist/bin-cwd.js",
|
|
189
|
+
"ts-node-esm": "dist/bin-esm.js",
|
|
190
|
+
"ts-node-script": "dist/bin-script.js",
|
|
191
|
+
"ts-node-transpile-only": "dist/bin-transpile.js",
|
|
192
|
+
"ts-script": "dist/bin-script-deprecated.js"
|
|
193
|
+
},
|
|
194
|
+
"peerDependencies": {
|
|
195
|
+
"@swc/core": ">=1.2.50",
|
|
196
|
+
"@swc/wasm": ">=1.2.50",
|
|
197
|
+
"@types/node": "*",
|
|
198
|
+
"typescript": ">=2.7"
|
|
199
|
+
},
|
|
200
|
+
"peerDependenciesMeta": {
|
|
201
|
+
"@swc/core": {
|
|
202
|
+
"optional": true
|
|
203
|
+
},
|
|
204
|
+
"@swc/wasm": {
|
|
205
|
+
"optional": true
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
"node_modules/typescript": {
|
|
210
|
+
"version": "5.8.3",
|
|
211
|
+
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
|
212
|
+
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
|
213
|
+
"dev": true,
|
|
214
|
+
"bin": {
|
|
215
|
+
"tsc": "bin/tsc",
|
|
216
|
+
"tsserver": "bin/tsserver"
|
|
217
|
+
},
|
|
218
|
+
"engines": {
|
|
219
|
+
"node": ">=14.17"
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"node_modules/undici-types": {
|
|
223
|
+
"version": "6.21.0",
|
|
224
|
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
|
225
|
+
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
|
226
|
+
"dev": true,
|
|
227
|
+
"peer": true
|
|
228
|
+
},
|
|
229
|
+
"node_modules/v8-compile-cache-lib": {
|
|
230
|
+
"version": "3.0.1",
|
|
231
|
+
"resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
|
|
232
|
+
"integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
|
|
233
|
+
"dev": true
|
|
234
|
+
},
|
|
235
|
+
"node_modules/yn": {
|
|
236
|
+
"version": "3.1.1",
|
|
237
|
+
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
|
|
238
|
+
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
|
|
239
|
+
"dev": true,
|
|
240
|
+
"engines": {
|
|
241
|
+
"node": ">=6"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nosana-sdk-node-examples",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Example scripts for using the Nosana SDK",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"retrieve": "ts-node retrieve.ts",
|
|
7
|
+
"monitor": "ts-node monitor.ts"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@nosana/kit": "file:../.."
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"ts-node": "^10.9.1",
|
|
14
|
+
"typescript": "^5.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { address, NosanaClient, NosanaNetwork } from '@nosana/kit';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
// Initialize the client with devnet for testing
|
|
5
|
+
const client = new NosanaClient(NosanaNetwork.MAINNET);
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
// Example: Get job details
|
|
9
|
+
const jobAddress = 'BwBURHTRMM3Ckzo2Dzmw99hv6gV8Ve12b6iw4sm9qeyR'; // Replace with actual job address
|
|
10
|
+
const jobDetails = await client.jobs.get(address(jobAddress));
|
|
11
|
+
console.log('Job details:', jobDetails);
|
|
12
|
+
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error('Error:', error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nosana/kit",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Nosana KIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"generate-clients": "ts-node scripts/generate-clients.ts",
|
|
11
|
+
"lint": "eslint . --ext .ts",
|
|
12
|
+
"format": "prettier --write \"**/*.ts\"",
|
|
13
|
+
"publish:public": "npm version patch && npm run build && npm publish --access public"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"nosana",
|
|
17
|
+
"solana",
|
|
18
|
+
"sdk",
|
|
19
|
+
"kit",
|
|
20
|
+
"blockchain"
|
|
21
|
+
],
|
|
22
|
+
"author": "Nosana",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@solana-program/token": "^0.5.1",
|
|
26
|
+
"bs58": "^6.0.0",
|
|
27
|
+
"gill": "^0.9.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@codama/nodes-from-anchor": "^1.2.0",
|
|
31
|
+
"@codama/renderers-js": "^1.2.14",
|
|
32
|
+
"@types/jest": "^29.5.12",
|
|
33
|
+
"@types/node": "^20.11.24",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
|
35
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
36
|
+
"codama": "^1.3.0",
|
|
37
|
+
"eslint": "^8.57.0",
|
|
38
|
+
"jest": "^29.7.0",
|
|
39
|
+
"prettier": "^3.2.5",
|
|
40
|
+
"ts-jest": "^29.1.2",
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
|
+
"typescript": "^5.3.3"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=20.18.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createFromRoot } from "codama";
|
|
2
|
+
import { rootNodeFromAnchor, AnchorIdl } from "@codama/nodes-from-anchor";
|
|
3
|
+
import { renderVisitor as renderJavaScriptVisitor } from "@codama/renderers-js";
|
|
4
|
+
import anchorIdl from "../../spl/target/idl/nosana_jobs.json";
|
|
5
|
+
import path from "path";
|
|
6
|
+
|
|
7
|
+
const codama = createFromRoot(rootNodeFromAnchor(anchorIdl as AnchorIdl));
|
|
8
|
+
|
|
9
|
+
codama.accept(renderJavaScriptVisitor(path.join(__dirname, "..", "src", "generated_clients", "jobs")));
|