@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.
Files changed (98) hide show
  1. package/.gitlab-ci.yml +21 -0
  2. package/README.md +159 -0
  3. package/dist/config/defaultConfigs.d.ts +2 -0
  4. package/dist/config/defaultConfigs.js +47 -0
  5. package/dist/config/index.d.ts +3 -0
  6. package/dist/config/index.js +19 -0
  7. package/dist/config/types.d.ts +43 -0
  8. package/dist/config/types.js +16 -0
  9. package/dist/config/utils.d.ts +3 -0
  10. package/dist/config/utils.js +35 -0
  11. package/dist/errors/NosanaError.d.ts +16 -0
  12. package/dist/errors/NosanaError.js +22 -0
  13. package/dist/generated_clients/jobs/accounts/index.d.ts +10 -0
  14. package/dist/generated_clients/jobs/accounts/index.js +26 -0
  15. package/dist/generated_clients/jobs/accounts/jobAccount.d.ts +47 -0
  16. package/dist/generated_clients/jobs/accounts/jobAccount.js +86 -0
  17. package/dist/generated_clients/jobs/accounts/marketAccount.d.ts +46 -0
  18. package/dist/generated_clients/jobs/accounts/marketAccount.js +82 -0
  19. package/dist/generated_clients/jobs/accounts/runAccount.d.ts +35 -0
  20. package/dist/generated_clients/jobs/accounts/runAccount.js +74 -0
  21. package/dist/generated_clients/jobs/errors/index.d.ts +8 -0
  22. package/dist/generated_clients/jobs/errors/index.js +24 -0
  23. package/dist/generated_clients/jobs/errors/nosanaJobs.d.ts +57 -0
  24. package/dist/generated_clients/jobs/errors/nosanaJobs.js +85 -0
  25. package/dist/generated_clients/jobs/index.d.ts +12 -0
  26. package/dist/generated_clients/jobs/index.js +28 -0
  27. package/dist/generated_clients/jobs/instructions/claim.d.ts +60 -0
  28. package/dist/generated_clients/jobs/instructions/claim.js +102 -0
  29. package/dist/generated_clients/jobs/instructions/clean.d.ts +42 -0
  30. package/dist/generated_clients/jobs/instructions/clean.js +79 -0
  31. package/dist/generated_clients/jobs/instructions/cleanAdmin.d.ts +42 -0
  32. package/dist/generated_clients/jobs/instructions/cleanAdmin.js +79 -0
  33. package/dist/generated_clients/jobs/instructions/close.d.ts +48 -0
  34. package/dist/generated_clients/jobs/instructions/close.js +90 -0
  35. package/dist/generated_clients/jobs/instructions/closeAdmin.d.ts +48 -0
  36. package/dist/generated_clients/jobs/instructions/closeAdmin.js +90 -0
  37. package/dist/generated_clients/jobs/instructions/complete.d.ts +43 -0
  38. package/dist/generated_clients/jobs/instructions/complete.js +82 -0
  39. package/dist/generated_clients/jobs/instructions/delist.d.ts +54 -0
  40. package/dist/generated_clients/jobs/instructions/delist.js +96 -0
  41. package/dist/generated_clients/jobs/instructions/end.d.ts +60 -0
  42. package/dist/generated_clients/jobs/instructions/end.js +102 -0
  43. package/dist/generated_clients/jobs/instructions/extend.d.ts +64 -0
  44. package/dist/generated_clients/jobs/instructions/extend.js +111 -0
  45. package/dist/generated_clients/jobs/instructions/finish.d.ts +67 -0
  46. package/dist/generated_clients/jobs/instructions/finish.js +111 -0
  47. package/dist/generated_clients/jobs/instructions/index.d.ts +25 -0
  48. package/dist/generated_clients/jobs/instructions/index.js +41 -0
  49. package/dist/generated_clients/jobs/instructions/list.d.ts +76 -0
  50. package/dist/generated_clients/jobs/instructions/list.js +126 -0
  51. package/dist/generated_clients/jobs/instructions/open.d.ts +73 -0
  52. package/dist/generated_clients/jobs/instructions/open.js +121 -0
  53. package/dist/generated_clients/jobs/instructions/quit.d.ts +45 -0
  54. package/dist/generated_clients/jobs/instructions/quit.js +82 -0
  55. package/dist/generated_clients/jobs/instructions/quitAdmin.d.ts +42 -0
  56. package/dist/generated_clients/jobs/instructions/quitAdmin.js +79 -0
  57. package/dist/generated_clients/jobs/instructions/recover.d.ts +54 -0
  58. package/dist/generated_clients/jobs/instructions/recover.js +96 -0
  59. package/dist/generated_clients/jobs/instructions/stop.d.ts +42 -0
  60. package/dist/generated_clients/jobs/instructions/stop.js +79 -0
  61. package/dist/generated_clients/jobs/instructions/update.d.ts +58 -0
  62. package/dist/generated_clients/jobs/instructions/update.js +93 -0
  63. package/dist/generated_clients/jobs/instructions/work.d.ts +57 -0
  64. package/dist/generated_clients/jobs/instructions/work.js +99 -0
  65. package/dist/generated_clients/jobs/programs/index.d.ts +8 -0
  66. package/dist/generated_clients/jobs/programs/index.js +24 -0
  67. package/dist/generated_clients/jobs/programs/nosanaJobs.d.ts +78 -0
  68. package/dist/generated_clients/jobs/programs/nosanaJobs.js +112 -0
  69. package/dist/generated_clients/jobs/shared/index.d.ts +49 -0
  70. package/dist/generated_clients/jobs/shared/index.js +94 -0
  71. package/dist/generated_clients/jobs/types/index.d.ts +10 -0
  72. package/dist/generated_clients/jobs/types/index.js +26 -0
  73. package/dist/generated_clients/jobs/types/jobState.d.ts +18 -0
  74. package/dist/generated_clients/jobs/types/jobState.js +30 -0
  75. package/dist/generated_clients/jobs/types/jobType.d.ts +21 -0
  76. package/dist/generated_clients/jobs/types/jobType.js +33 -0
  77. package/dist/generated_clients/jobs/types/queueType.d.ts +18 -0
  78. package/dist/generated_clients/jobs/types/queueType.js +30 -0
  79. package/dist/index.d.ts +19 -0
  80. package/dist/index.js +43 -0
  81. package/dist/ipfs/IPFS.d.ts +19 -0
  82. package/dist/ipfs/IPFS.js +47 -0
  83. package/dist/logger/Logger.d.ts +24 -0
  84. package/dist/logger/Logger.js +63 -0
  85. package/dist/programs/BaseProgram.d.ts +20 -0
  86. package/dist/programs/BaseProgram.js +39 -0
  87. package/dist/programs/JobsProgram.d.ts +118 -0
  88. package/dist/programs/JobsProgram.js +611 -0
  89. package/dist/solana/SolanaUtils.d.ts +15 -0
  90. package/dist/solana/SolanaUtils.js +48 -0
  91. package/dist/utils/index.d.ts +19 -0
  92. package/dist/utils/index.js +17 -0
  93. package/examples/node/monitor.ts +143 -0
  94. package/examples/node/package-lock.json +245 -0
  95. package/examples/node/package.json +16 -0
  96. package/examples/node/retrieve.ts +18 -0
  97. package/package.json +47 -0
  98. package/scripts/generate-clients.ts +9 -0
package/.gitlab-ci.yml ADDED
@@ -0,0 +1,21 @@
1
+ # _ __ ___ ___ __ _ _ __ __ _
2
+ # | '_ \ / _ \/ __|/ _` | '_ \ / _` |
3
+ # | | | | (_) \__ \ (_| | | | | (_| |
4
+ # |_| |_|\___/|___/\__,_|_| |_|\__,_|
5
+
6
+ image: node:22.8.0
7
+
8
+ stages:
9
+ - deploy
10
+
11
+ deploy:
12
+ stage: deploy
13
+ only:
14
+ - main
15
+ script:
16
+ - npm ci
17
+ - git config --global user.email "dev@nosana.io"
18
+ - git config --global user.name "Nosana"
19
+ - npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
20
+ - npm run publish:public
21
+ # - git push # todo: fix, not working
package/README.md ADDED
@@ -0,0 +1,159 @@
1
+ # Nosana Kit
2
+
3
+ A TypeScript SDK for interacting with the Nosana Network on Solana. This kit provides a comprehensive set of tools for managing jobs, markets, runs, and other Nosana protocol operations.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Full TypeScript Support** - Complete type safety and IntelliSense
8
+ - 🔗 **Solana Integration** - Built on top of the new Solana Kit client
9
+ - 📦 **Jobs Management** - Create, manage, and monitor nosana jobs
10
+ - 🌐 **IPFS** - Seamless IPFS hash handling and conversions, uploading and retrieving
11
+ - ⚙️ **Configurable Networks** - Support for mainnet and devnet
12
+ - 🧪 **Comprehensive Testing** - Well-tested with high coverage
13
+ - 📝 **Rich Logging** - Built-in logging with configurable levels
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @nosana/kit
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { NosanaClient, NosanaNetwork } from '@nosana/kit';
25
+
26
+ // Initialize client with default mainnet configuration
27
+ const client = new NosanaClient();
28
+
29
+ // Or specify network and custom configuration
30
+ const client = new NosanaClient(NosanaNetwork.DEVNET, {
31
+ solana: {
32
+ rpcEndpoint: 'https://your-custom-rpc.com',
33
+ commitment: 'confirmed'
34
+ }
35
+ });
36
+
37
+ // Fetch a job
38
+ const job = await client.jobs.get('your-job-address');
39
+ console.log('Job state:', job.state);
40
+
41
+ // Get all completed jobs for a market
42
+ const jobs = await client.jobs.all({
43
+ market: 'market-address',
44
+ state: 2 // completed jobs
45
+ });
46
+ ```
47
+
48
+ ## Configuration
49
+
50
+ ### Network Configuration
51
+
52
+ The SDK supports two networks:
53
+
54
+ - `NosanaNetwork.MAINNET` - Production network
55
+ - `NosanaNetwork.DEVNET` - Development network
56
+
57
+ ### Custom Configuration
58
+
59
+ ```typescript
60
+ import { NosanaClient, NosanaNetwork, NosanaLogLevel } from '@nosana/kit';
61
+
62
+ const client = new NosanaClient(NosanaNetwork.MAINNET, {
63
+ solana: {
64
+ cluster: 'mainnet-beta',
65
+ rpcEndpoint: 'https://your-rpc-endpoint.com',
66
+ commitment: 'confirmed'
67
+ },
68
+ ipfs: {
69
+ api: 'https://your-ipfs-api.com',
70
+ jwt: 'your-jwt-token',
71
+ gateway: 'https://your-ipfs-gateway.com'
72
+ },
73
+ logLevel: NosanaLogLevel.DEBUG
74
+ });
75
+ ```
76
+
77
+ ## API Reference
78
+
79
+ ### NosanaClient
80
+
81
+ The main client class that provides access to all Nosana protocol features.
82
+
83
+ ```typescript
84
+ class NosanaClient {
85
+ constructor(network?: NosanaNetwork, customConfig?: PartialClientConfig)
86
+
87
+ readonly config: ClientConfig
88
+ readonly jobs: JobsProgram
89
+ readonly solana: SolanaUtils
90
+ readonly logger: Logger
91
+ }
92
+ ```
93
+
94
+ ### JobsProgram
95
+
96
+ Manages job-related operations on the Nosana network.
97
+
98
+ #### Methods
99
+
100
+ ```typescript
101
+ // Fetch a single job
102
+ async get(address: Address, checkRun?: boolean): Promise<Job>
103
+
104
+ // Fetch a run
105
+ async run(address: Address): Promise<Run>
106
+
107
+ // Fetch a market
108
+ async market(address: Address): Promise<Market>
109
+
110
+ // Fetch multiple jobs
111
+ async multiple(addresses: Address[], checkRuns?: boolean): Promise<Job[]>
112
+
113
+ // Fetch all jobs with optional filters
114
+ async all(filters?: {
115
+ state?: number,
116
+ market?: Address,
117
+ node?: Address,
118
+ project?: Address,
119
+ }, checkRuns?: boolean): Promise<Job[]>
120
+
121
+ // Get runs with optional filters
122
+ async runs(filters?: {
123
+ job?: Address,
124
+ node?: Address,
125
+ }): Promise<Run[]>
126
+
127
+ // Get markets with optional filters
128
+ async markets(filters?: {
129
+ project?: Address,
130
+ }): Promise<Market[]>
131
+ ```
132
+
133
+ #### Account Types
134
+ ...
135
+
136
+ ## Error Handling
137
+
138
+ The SDK provides structured error handling with specific error codes:
139
+
140
+ ```typescript
141
+ import { NosanaError, ErrorCodes } from '@nosana/kit';
142
+
143
+ try {
144
+ const job = await client.jobs.get('invalid-address');
145
+ } catch (error) {
146
+ if (error instanceof NosanaError) {
147
+ switch (error.code) {
148
+ case ErrorCodes.RPC_ERROR:
149
+ console.log('RPC connection failed');
150
+ break;
151
+ case ErrorCodes.INVALID_CONFIG:
152
+ console.log('Invalid configuration');
153
+ break;
154
+ default:
155
+ console.log('Unknown error:', error.message);
156
+ }
157
+ }
158
+ }
159
+ ```
@@ -0,0 +1,2 @@
1
+ import { ClientConfig, NosanaNetwork } from "./types";
2
+ export declare const DEFAULT_CONFIGS: Record<NosanaNetwork, ClientConfig>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONFIGS = void 0;
4
+ const gill_1 = require("gill");
5
+ const types_1 = require("./types");
6
+ exports.DEFAULT_CONFIGS = {
7
+ mainnet: {
8
+ solana: {
9
+ cluster: 'mainnet-beta',
10
+ rpcEndpoint: 'https://rpc.ironforge.network/mainnet?apiKey=01J4RYMAWZC65B6CND9DTZZ5BK',
11
+ commitment: 'confirmed',
12
+ },
13
+ ipfs: {
14
+ api: 'https://api.pinata.cloud',
15
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiJmZDUwODE1NS1jZDJhLTRlMzYtYWI4MC0wNmMxNjRmZWY1MTkiLCJlbWFpbCI6Implc3NlQG5vc2FuYS5pbyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJwaW5fcG9saWN5Ijp7InJlZ2lvbnMiOlt7ImlkIjoiRlJBMSIsImRlc2lyZWRSZXBsaWNhdGlvbkNvdW50IjoxfV0sInZlcnNpb24iOjF9LCJtZmFfZW5hYmxlZCI6ZmFsc2UsInN0YXR1cyI6IkFDVElWRSJ9LCJhdXRoZW50aWNhdGlvblR5cGUiOiJzY29wZWRLZXkiLCJzY29wZWRLZXlLZXkiOiI1YzVhNWM2N2RlYWU2YzNhNzEwOCIsInNjb3BlZEtleVNlY3JldCI6ImYxOWFjZDUyZDk4ZTczNjU5MmEyY2IzZjQwYWUxNGE2ZmYyYTkxNDJjZTRiN2EzZGQ5OTYyOTliMmJkN2IzYzEiLCJpYXQiOjE2ODY3NzE5Nzl9.r4_pWCCT79Jis6L3eegjdBdAt5MpVd1ymDkBuNE25g8',
16
+ gateway: 'https://nosana.mypinata.cloud/ipfs/',
17
+ },
18
+ programs: {
19
+ nosTokenAddress: (0, gill_1.address)('nosXBVoaCTtYdLvKY6Csb4AC8JCdQKKAaWYtx2ZMoo7'),
20
+ jobsAddress: (0, gill_1.address)('nosJhNRqr2bc9g1nfGDcXXTXvYUmxD4cVwy2pMWhrYM'),
21
+ rewardsAddress: (0, gill_1.address)('nosRB8DUV67oLNrL45bo2pFLrmsWPiewe2Lk2DRNYCp'),
22
+ stakeAddress: (0, gill_1.address)('nosScmHY2uR24Zh751PmGj9ww9QRNHewh9H59AfrTJE'),
23
+ poolsAddress: (0, gill_1.address)('nosPdZrfDzND1LAR28FLMDEATUPK53K8xbRBXAirevD'),
24
+ },
25
+ logLevel: types_1.NosanaLogLevel.ERROR,
26
+ },
27
+ devnet: {
28
+ solana: {
29
+ cluster: 'devnet',
30
+ rpcEndpoint: 'https://api.devnet.solana.com',
31
+ commitment: 'confirmed',
32
+ },
33
+ ipfs: {
34
+ api: 'https://api.pinata.cloud',
35
+ jwt: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySW5mb3JtYXRpb24iOnsiaWQiOiJmZDUwODE1NS1jZDJhLTRlMzYtYWI4MC0wNmMxNjRmZWY1MTkiLCJlbWFpbCI6Implc3NlQG5vc2FuYS5pbyIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJwaW5fcG9saWN5Ijp7InJlZ2lvbnMiOlt7ImlkIjoiRlJBMSIsImRlc2lyZWRSZXBsaWNhdGlvbkNvdW50IjoxfV0sInZlcnNpb24iOjF9LCJtZmFfZW5hYmxlZCI6ZmFsc2UsInN0YXR1cyI6IkFDVElWRSJ9LCJhdXRoZW50aWNhdGlvblR5cGUiOiJzY29wZWRLZXkiLCJzY29wZWRLZXlLZXkiOiI1YzVhNWM2N2RlYWU2YzNhNzEwOCIsInNjb3BlZEtleVNlY3JldCI6ImYxOWFjZDUyZDk4ZTczNjU5MmEyY2IzZjQwYWUxNGE2ZmYyYTkxNDJjZTRiN2EzZGQ5OTYyOTliMmJkN2IzYzEiLCJpYXQiOjE2ODY3NzE5Nzl9.r4_pWCCT79Jis6L3eegjdBdAt5MpVd1ymDkBuNE25g8',
36
+ gateway: 'https://nosana.mypinata.cloud/ipfs/',
37
+ },
38
+ programs: {
39
+ nosTokenAddress: (0, gill_1.address)('devr1BGQndEW5k5zfvG5FsLyZv1Ap73vNgAHcQ9sUVP'),
40
+ jobsAddress: (0, gill_1.address)('nosJTmGQxvwXy23vng5UjkTbfv91Bzf9jEuro78dAGR'),
41
+ rewardsAddress: (0, gill_1.address)('nosRB8DUV67oLNrL45bo2pFLrmsWPiewe2Lk2DRNYCp'),
42
+ stakeAddress: (0, gill_1.address)('nosScmHY2uR24Zh751PmGj9ww9QRNHewh9H59AfrTJE'),
43
+ poolsAddress: (0, gill_1.address)('nosPdZrfDzND1LAR28FLMDEATUPK53K8xbRBXAirevD'),
44
+ },
45
+ logLevel: types_1.NosanaLogLevel.DEBUG,
46
+ },
47
+ };
@@ -0,0 +1,3 @@
1
+ export * from './types.js';
2
+ export * from './defaultConfigs.js';
3
+ export * from './utils.js';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types.js"), exports);
18
+ __exportStar(require("./defaultConfigs.js"), exports);
19
+ __exportStar(require("./utils.js"), exports);
@@ -0,0 +1,43 @@
1
+ import { Address, KeyPairSigner, SolanaClusterMoniker } from 'gill';
2
+ export declare enum NosanaNetwork {
3
+ MAINNET = "mainnet",
4
+ DEVNET = "devnet"
5
+ }
6
+ export declare enum NosanaLogLevel {
7
+ NONE = 0,
8
+ ERROR = 1,
9
+ WARN = 2,
10
+ INFO = 3,
11
+ DEBUG = 4
12
+ }
13
+ export interface SolanaConfig {
14
+ cluster: SolanaClusterMoniker | "mainnet-beta" | "localhost";
15
+ rpcEndpoint: string;
16
+ wsEndpoint?: string;
17
+ commitment?: 'processed' | 'confirmed' | 'finalized';
18
+ }
19
+ export interface WalletConfig {
20
+ signer: KeyPairSigner;
21
+ }
22
+ export interface IpfsConfig {
23
+ api: string;
24
+ jwt: string;
25
+ gateway: string;
26
+ }
27
+ export interface ClientConfig {
28
+ solana: SolanaConfig;
29
+ wallet?: WalletConfig;
30
+ logLevel: NosanaLogLevel;
31
+ ipfs: IpfsConfig;
32
+ programs: {
33
+ nosTokenAddress: Address;
34
+ jobsAddress: Address;
35
+ rewardsAddress: Address;
36
+ stakeAddress: Address;
37
+ poolsAddress: Address;
38
+ };
39
+ }
40
+ export interface PartialClientConfig {
41
+ solana?: Partial<SolanaConfig>;
42
+ wallet?: WalletConfig;
43
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NosanaLogLevel = exports.NosanaNetwork = void 0;
4
+ var NosanaNetwork;
5
+ (function (NosanaNetwork) {
6
+ NosanaNetwork["MAINNET"] = "mainnet";
7
+ NosanaNetwork["DEVNET"] = "devnet";
8
+ })(NosanaNetwork || (exports.NosanaNetwork = NosanaNetwork = {}));
9
+ var NosanaLogLevel;
10
+ (function (NosanaLogLevel) {
11
+ NosanaLogLevel[NosanaLogLevel["NONE"] = 0] = "NONE";
12
+ NosanaLogLevel[NosanaLogLevel["ERROR"] = 1] = "ERROR";
13
+ NosanaLogLevel[NosanaLogLevel["WARN"] = 2] = "WARN";
14
+ NosanaLogLevel[NosanaLogLevel["INFO"] = 3] = "INFO";
15
+ NosanaLogLevel[NosanaLogLevel["DEBUG"] = 4] = "DEBUG";
16
+ })(NosanaLogLevel || (exports.NosanaLogLevel = NosanaLogLevel = {}));
@@ -0,0 +1,3 @@
1
+ import { ClientConfig, NosanaNetwork, PartialClientConfig } from "./types.js";
2
+ export declare const mergeConfigs: (defaultConfig: ClientConfig, customConfig?: PartialClientConfig) => ClientConfig;
3
+ export declare const getNosanaConfig: (network?: NosanaNetwork, config?: PartialClientConfig) => ClientConfig;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNosanaConfig = exports.mergeConfigs = void 0;
4
+ const NosanaError_js_1 = require("../errors/NosanaError.js");
5
+ const defaultConfigs_js_1 = require("./defaultConfigs.js");
6
+ const types_js_1 = require("./types.js");
7
+ const mergeConfigs = (defaultConfig, customConfig) => {
8
+ if (!customConfig)
9
+ return defaultConfig;
10
+ return {
11
+ ...defaultConfig,
12
+ ...customConfig,
13
+ solana: {
14
+ ...defaultConfig.solana,
15
+ ...customConfig.solana,
16
+ },
17
+ };
18
+ };
19
+ exports.mergeConfigs = mergeConfigs;
20
+ const getNosanaConfig = (network = types_js_1.NosanaNetwork.MAINNET, config) => {
21
+ const defaultConfig = defaultConfigs_js_1.DEFAULT_CONFIGS[network];
22
+ if (!defaultConfig) {
23
+ throw new NosanaError_js_1.NosanaError(`Unsupported Nosana network: ${network}`, NosanaError_js_1.ErrorCodes.INVALID_NETWORK);
24
+ }
25
+ return (0, exports.mergeConfigs)(defaultConfig, config);
26
+ };
27
+ exports.getNosanaConfig = getNosanaConfig;
28
+ // Example: Initialize with default (Mainnet) or specific network, or custom config
29
+ // const defaultConfig = getNosanaConfig();
30
+ // const devConfig = getNosanaConfig(NosanaNetwork.DEVNET);
31
+ // const customConfig = getNosanaConfig(NosanaNetwork.MAINNET, {
32
+ // solana: {
33
+ // rpcEndpoint: 'your-custom-rpc-endpoint-url',
34
+ // },
35
+ // });
@@ -0,0 +1,16 @@
1
+ export declare class NosanaError extends Error {
2
+ readonly code: string;
3
+ readonly details?: unknown | undefined;
4
+ constructor(message: string, code: string, details?: unknown | undefined);
5
+ }
6
+ export declare const ErrorCodes: {
7
+ readonly INVALID_NETWORK: "INVALID_NETWORK";
8
+ readonly INVALID_CONFIG: "INVALID_CONFIG";
9
+ readonly RPC_ERROR: "RPC_ERROR";
10
+ readonly TRANSACTION_ERROR: "TRANSACTION_ERROR";
11
+ readonly PROGRAM_ERROR: "PROGRAM_ERROR";
12
+ readonly VALIDATION_ERROR: "VALIDATION_ERROR";
13
+ readonly NO_WALLET: "NO_WALLET";
14
+ readonly FILE_ERROR: "FILE_ERROR";
15
+ };
16
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCodes = exports.NosanaError = void 0;
4
+ class NosanaError extends Error {
5
+ constructor(message, code, details) {
6
+ super(message);
7
+ this.code = code;
8
+ this.details = details;
9
+ this.name = 'NosanaError';
10
+ }
11
+ }
12
+ exports.NosanaError = NosanaError;
13
+ exports.ErrorCodes = {
14
+ INVALID_NETWORK: 'INVALID_NETWORK',
15
+ INVALID_CONFIG: 'INVALID_CONFIG',
16
+ RPC_ERROR: 'RPC_ERROR',
17
+ TRANSACTION_ERROR: 'TRANSACTION_ERROR',
18
+ PROGRAM_ERROR: 'PROGRAM_ERROR',
19
+ VALIDATION_ERROR: 'VALIDATION_ERROR',
20
+ NO_WALLET: 'NO_WALLET',
21
+ FILE_ERROR: 'FILE_ERROR',
22
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ export * from './jobAccount';
9
+ export * from './marketAccount';
10
+ export * from './runAccount';
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ __exportStar(require("./jobAccount"), exports);
25
+ __exportStar(require("./marketAccount"), exports);
26
+ __exportStar(require("./runAccount"), exports);
@@ -0,0 +1,47 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
9
+ export declare const JOB_ACCOUNT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
10
+ export declare function getJobAccountDiscriminatorBytes(): ReadonlyUint8Array;
11
+ export type JobAccount = {
12
+ discriminator: ReadonlyUint8Array;
13
+ ipfsJob: ReadonlyUint8Array;
14
+ ipfsResult: ReadonlyUint8Array;
15
+ market: Address;
16
+ node: Address;
17
+ payer: Address;
18
+ price: bigint;
19
+ project: Address;
20
+ state: number;
21
+ timeEnd: bigint;
22
+ timeStart: bigint;
23
+ timeout: bigint;
24
+ };
25
+ export type JobAccountArgs = {
26
+ ipfsJob: ReadonlyUint8Array;
27
+ ipfsResult: ReadonlyUint8Array;
28
+ market: Address;
29
+ node: Address;
30
+ payer: Address;
31
+ price: number | bigint;
32
+ project: Address;
33
+ state: number;
34
+ timeEnd: number | bigint;
35
+ timeStart: number | bigint;
36
+ timeout: number | bigint;
37
+ };
38
+ export declare function getJobAccountEncoder(): Encoder<JobAccountArgs>;
39
+ export declare function getJobAccountDecoder(): Decoder<JobAccount>;
40
+ export declare function getJobAccountCodec(): Codec<JobAccountArgs, JobAccount>;
41
+ export declare function decodeJobAccount<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<JobAccount, TAddress>;
42
+ export declare function decodeJobAccount<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<JobAccount, TAddress>;
43
+ export declare function fetchJobAccount<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<JobAccount, TAddress>>;
44
+ export declare function fetchMaybeJobAccount<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<JobAccount, TAddress>>;
45
+ export declare function fetchAllJobAccount(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<JobAccount>[]>;
46
+ export declare function fetchAllMaybeJobAccount(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<JobAccount>[]>;
47
+ export declare function getJobAccountSize(): number;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ /**
3
+ * This code was AUTOGENERATED using the codama library.
4
+ * Please DO NOT EDIT THIS FILE, instead use visitors
5
+ * to add features, then rerun codama to update it.
6
+ *
7
+ * @see https://github.com/codama-idl/codama
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.JOB_ACCOUNT_DISCRIMINATOR = void 0;
11
+ exports.getJobAccountDiscriminatorBytes = getJobAccountDiscriminatorBytes;
12
+ exports.getJobAccountEncoder = getJobAccountEncoder;
13
+ exports.getJobAccountDecoder = getJobAccountDecoder;
14
+ exports.getJobAccountCodec = getJobAccountCodec;
15
+ exports.decodeJobAccount = decodeJobAccount;
16
+ exports.fetchJobAccount = fetchJobAccount;
17
+ exports.fetchMaybeJobAccount = fetchMaybeJobAccount;
18
+ exports.fetchAllJobAccount = fetchAllJobAccount;
19
+ exports.fetchAllMaybeJobAccount = fetchAllMaybeJobAccount;
20
+ exports.getJobAccountSize = getJobAccountSize;
21
+ const kit_1 = require("@solana/kit");
22
+ exports.JOB_ACCOUNT_DISCRIMINATOR = new Uint8Array([
23
+ 91, 16, 162, 5, 45, 210, 125, 65,
24
+ ]);
25
+ function getJobAccountDiscriminatorBytes() {
26
+ return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.JOB_ACCOUNT_DISCRIMINATOR);
27
+ }
28
+ function getJobAccountEncoder() {
29
+ return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
30
+ ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
31
+ ['ipfsJob', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32)],
32
+ ['ipfsResult', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 32)],
33
+ ['market', (0, kit_1.getAddressEncoder)()],
34
+ ['node', (0, kit_1.getAddressEncoder)()],
35
+ ['payer', (0, kit_1.getAddressEncoder)()],
36
+ ['price', (0, kit_1.getU64Encoder)()],
37
+ ['project', (0, kit_1.getAddressEncoder)()],
38
+ ['state', (0, kit_1.getU8Encoder)()],
39
+ ['timeEnd', (0, kit_1.getI64Encoder)()],
40
+ ['timeStart', (0, kit_1.getI64Encoder)()],
41
+ ['timeout', (0, kit_1.getI64Encoder)()],
42
+ ]), (value) => ({ ...value, discriminator: exports.JOB_ACCOUNT_DISCRIMINATOR }));
43
+ }
44
+ function getJobAccountDecoder() {
45
+ return (0, kit_1.getStructDecoder)([
46
+ ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
47
+ ['ipfsJob', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32)],
48
+ ['ipfsResult', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 32)],
49
+ ['market', (0, kit_1.getAddressDecoder)()],
50
+ ['node', (0, kit_1.getAddressDecoder)()],
51
+ ['payer', (0, kit_1.getAddressDecoder)()],
52
+ ['price', (0, kit_1.getU64Decoder)()],
53
+ ['project', (0, kit_1.getAddressDecoder)()],
54
+ ['state', (0, kit_1.getU8Decoder)()],
55
+ ['timeEnd', (0, kit_1.getI64Decoder)()],
56
+ ['timeStart', (0, kit_1.getI64Decoder)()],
57
+ ['timeout', (0, kit_1.getI64Decoder)()],
58
+ ]);
59
+ }
60
+ function getJobAccountCodec() {
61
+ return (0, kit_1.combineCodec)(getJobAccountEncoder(), getJobAccountDecoder());
62
+ }
63
+ function decodeJobAccount(encodedAccount) {
64
+ return (0, kit_1.decodeAccount)(encodedAccount, getJobAccountDecoder());
65
+ }
66
+ async function fetchJobAccount(rpc, address, config) {
67
+ const maybeAccount = await fetchMaybeJobAccount(rpc, address, config);
68
+ (0, kit_1.assertAccountExists)(maybeAccount);
69
+ return maybeAccount;
70
+ }
71
+ async function fetchMaybeJobAccount(rpc, address, config) {
72
+ const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config);
73
+ return decodeJobAccount(maybeAccount);
74
+ }
75
+ async function fetchAllJobAccount(rpc, addresses, config) {
76
+ const maybeAccounts = await fetchAllMaybeJobAccount(rpc, addresses, config);
77
+ (0, kit_1.assertAccountsExist)(maybeAccounts);
78
+ return maybeAccounts;
79
+ }
80
+ async function fetchAllMaybeJobAccount(rpc, addresses, config) {
81
+ const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
82
+ return maybeAccounts.map((maybeAccount) => decodeJobAccount(maybeAccount));
83
+ }
84
+ function getJobAccountSize() {
85
+ return 233;
86
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type Codec, type Decoder, type EncodedAccount, type Encoder, type FetchAccountConfig, type FetchAccountsConfig, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
9
+ export declare const MARKET_ACCOUNT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
10
+ export declare function getMarketAccountDiscriminatorBytes(): ReadonlyUint8Array;
11
+ export type MarketAccount = {
12
+ discriminator: ReadonlyUint8Array;
13
+ authority: Address;
14
+ jobExpiration: bigint;
15
+ jobPrice: bigint;
16
+ jobTimeout: bigint;
17
+ jobType: number;
18
+ vault: Address;
19
+ vaultBump: number;
20
+ nodeAccessKey: Address;
21
+ nodeXnosMinimum: bigint;
22
+ queueType: number;
23
+ queue: Array<Address>;
24
+ };
25
+ export type MarketAccountArgs = {
26
+ authority: Address;
27
+ jobExpiration: number | bigint;
28
+ jobPrice: number | bigint;
29
+ jobTimeout: number | bigint;
30
+ jobType: number;
31
+ vault: Address;
32
+ vaultBump: number;
33
+ nodeAccessKey: Address;
34
+ nodeXnosMinimum: number | bigint;
35
+ queueType: number;
36
+ queue: Array<Address>;
37
+ };
38
+ export declare function getMarketAccountEncoder(): Encoder<MarketAccountArgs>;
39
+ export declare function getMarketAccountDecoder(): Decoder<MarketAccount>;
40
+ export declare function getMarketAccountCodec(): Codec<MarketAccountArgs, MarketAccount>;
41
+ export declare function decodeMarketAccount<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<MarketAccount, TAddress>;
42
+ export declare function decodeMarketAccount<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<MarketAccount, TAddress>;
43
+ export declare function fetchMarketAccount<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<MarketAccount, TAddress>>;
44
+ export declare function fetchMaybeMarketAccount<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<MarketAccount, TAddress>>;
45
+ export declare function fetchAllMarketAccount(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<MarketAccount>[]>;
46
+ export declare function fetchAllMaybeMarketAccount(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<MarketAccount>[]>;