@nosana/kit 0.1.1 → 0.1.3

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 (71) hide show
  1. package/.gitlab-ci.yml +6 -5
  2. package/dist/config/defaultConfigs.js +15 -18
  3. package/dist/config/index.js +3 -19
  4. package/dist/config/types.d.ts +1 -3
  5. package/dist/config/types.js +4 -7
  6. package/dist/config/utils.js +8 -13
  7. package/dist/errors/NosanaError.d.ts +1 -0
  8. package/dist/errors/NosanaError.js +3 -6
  9. package/dist/generated_clients/jobs/accounts/index.js +3 -19
  10. package/dist/generated_clients/jobs/accounts/jobAccount.js +46 -59
  11. package/dist/generated_clients/jobs/accounts/marketAccount.js +45 -57
  12. package/dist/generated_clients/jobs/accounts/runAccount.js +36 -49
  13. package/dist/generated_clients/jobs/errors/index.js +1 -17
  14. package/dist/generated_clients/jobs/errors/nosanaJobs.js +43 -48
  15. package/dist/generated_clients/jobs/index.js +5 -21
  16. package/dist/generated_clients/jobs/instructions/claim.js +17 -26
  17. package/dist/generated_clients/jobs/instructions/clean.js +17 -26
  18. package/dist/generated_clients/jobs/instructions/cleanAdmin.js +17 -26
  19. package/dist/generated_clients/jobs/instructions/close.js +17 -26
  20. package/dist/generated_clients/jobs/instructions/closeAdmin.js +17 -26
  21. package/dist/generated_clients/jobs/instructions/complete.js +21 -30
  22. package/dist/generated_clients/jobs/instructions/delist.js +17 -26
  23. package/dist/generated_clients/jobs/instructions/end.js +17 -26
  24. package/dist/generated_clients/jobs/instructions/extend.js +21 -30
  25. package/dist/generated_clients/jobs/instructions/finish.js +21 -30
  26. package/dist/generated_clients/jobs/instructions/index.js +18 -34
  27. package/dist/generated_clients/jobs/instructions/list.js +23 -32
  28. package/dist/generated_clients/jobs/instructions/open.js +29 -38
  29. package/dist/generated_clients/jobs/instructions/quit.js +17 -26
  30. package/dist/generated_clients/jobs/instructions/quitAdmin.js +17 -26
  31. package/dist/generated_clients/jobs/instructions/recover.js +17 -26
  32. package/dist/generated_clients/jobs/instructions/stop.js +17 -26
  33. package/dist/generated_clients/jobs/instructions/update.js +29 -38
  34. package/dist/generated_clients/jobs/instructions/work.js +17 -26
  35. package/dist/generated_clients/jobs/programs/index.js +1 -17
  36. package/dist/generated_clients/jobs/programs/nosanaJobs.js +29 -34
  37. package/dist/generated_clients/jobs/shared/index.js +13 -21
  38. package/dist/generated_clients/jobs/types/index.js +3 -19
  39. package/dist/generated_clients/jobs/types/jobState.js +9 -15
  40. package/dist/generated_clients/jobs/types/jobType.js +9 -15
  41. package/dist/generated_clients/jobs/types/queueType.js +9 -15
  42. package/dist/index.d.ts +5 -1
  43. package/dist/index.js +152 -36
  44. package/dist/ipfs/IPFS.js +5 -12
  45. package/dist/logger/Logger.js +1 -5
  46. package/dist/programs/BaseProgram.js +1 -5
  47. package/dist/programs/JobsProgram.d.ts +2 -3
  48. package/dist/programs/JobsProgram.js +35 -99
  49. package/dist/solana/SolanaUtils.d.ts +15 -1
  50. package/dist/solana/SolanaUtils.js +78 -14
  51. package/dist/utils/index.js +1 -4
  52. package/examples/browser/.gitlab-ci.yml +78 -0
  53. package/examples/browser/FEATURES.md +141 -0
  54. package/examples/browser/QUICK_START.md +76 -0
  55. package/examples/browser/README.md +182 -0
  56. package/examples/browser/app.vue +1840 -0
  57. package/examples/browser/assets/css/main.css +7 -0
  58. package/examples/browser/nuxt.config.ts +24 -0
  59. package/examples/browser/package-lock.json +11467 -0
  60. package/examples/browser/package.json +31 -0
  61. package/examples/browser/public/favicon.ico +0 -0
  62. package/examples/browser/public/robots.txt +2 -0
  63. package/examples/browser/start.sh +38 -0
  64. package/examples/browser/tailwind.config.js +26 -0
  65. package/examples/node/README.md +146 -0
  66. package/examples/node/example-keypair.json +1 -0
  67. package/examples/node/package-lock.json +500 -156
  68. package/examples/node/package.json +5 -3
  69. package/examples/node/post-job.ts +160 -0
  70. package/examples/node/set-wallet.ts +87 -0
  71. package/package.json +3 -1
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "nosana-sdk-browser-playground",
3
+ "description": "Interactive documentation and testing environment for the Nosana SDK",
4
+ "version": "1.0.0",
5
+ "private": true,
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "nuxt build",
9
+ "dev": "nuxt dev",
10
+ "generate": "nuxt generate",
11
+ "preview": "nuxt preview",
12
+ "postinstall": "nuxt prepare",
13
+ "start": "nuxt dev"
14
+ },
15
+ "dependencies": {
16
+ "@headlessui/vue": "^1.7.23",
17
+ "@heroicons/vue": "^2.2.0",
18
+ "@nosana/kit": "file:../../",
19
+ "@nuxtjs/tailwindcss": "^7.0.0-beta.0",
20
+ "@tailwindcss/typography": "^0.5.16",
21
+ "nuxt": "^3.17.4",
22
+ "vue": "^3.5.15",
23
+ "vue-router": "^4.5.1"
24
+ },
25
+ "devDependencies": {
26
+ "@tailwindcss/postcss": "^4.1.8",
27
+ "autoprefixer": "^10.4.21",
28
+ "postcss": "^8.5.4",
29
+ "tailwindcss": "^4.1.8"
30
+ }
31
+ }
@@ -0,0 +1,2 @@
1
+ User-Agent: *
2
+ Disallow:
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+
3
+ echo "🚀 Starting Nosana SDK Browser Playground..."
4
+ echo ""
5
+
6
+ # Check if Node.js is installed
7
+ if ! command -v node &> /dev/null; then
8
+ echo "❌ Node.js is not installed. Please install Node.js 20.18.0 or higher."
9
+ exit 1
10
+ fi
11
+
12
+ # Check Node.js version
13
+ NODE_VERSION=$(node -v | cut -d'v' -f2)
14
+ REQUIRED_VERSION="20.18.0"
15
+
16
+ if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$NODE_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
17
+ echo "⚠️ Warning: Node.js version $NODE_VERSION detected. Recommended version is $REQUIRED_VERSION or higher."
18
+ fi
19
+
20
+ # Check if we're in the right directory
21
+ if [ ! -f "package.json" ]; then
22
+ echo "❌ Please run this script from the examples/browser directory"
23
+ exit 1
24
+ fi
25
+
26
+ # Install dependencies if node_modules doesn't exist
27
+ if [ ! -d "node_modules" ]; then
28
+ echo "📦 Installing dependencies..."
29
+ npm install
30
+ echo ""
31
+ fi
32
+
33
+ echo "🌐 Starting development server..."
34
+ echo "📖 Open http://localhost:3000 in your browser"
35
+ echo "🛑 Press Ctrl+C to stop the server"
36
+ echo ""
37
+
38
+ npm run dev
@@ -0,0 +1,26 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: [
4
+ "./components/**/*.{js,vue,ts}",
5
+ "./layouts/**/*.vue",
6
+ "./pages/**/*.vue",
7
+ "./plugins/**/*.{js,ts}",
8
+ "./app.vue",
9
+ "./error.vue"
10
+ ],
11
+ theme: {
12
+ extend: {
13
+ colors: {
14
+ terminal: {
15
+ bg: '#1a202c',
16
+ text: '#68d391',
17
+ error: '#fc8181',
18
+ success: '#68d391',
19
+ info: '#63b3ed',
20
+ warning: '#f6e05e'
21
+ }
22
+ }
23
+ },
24
+ },
25
+ plugins: [],
26
+ }
@@ -0,0 +1,146 @@
1
+ # Nosana Kit Node.js Examples
2
+
3
+ This directory contains Node.js examples for using the Nosana Kit.
4
+
5
+ ## Set Wallet Example
6
+
7
+ The `set-wallet.ts` example demonstrates various ways to initialize and set a wallet for the Nosana Client.
8
+
9
+ ### Supported Wallet Formats
10
+
11
+ The `setWallet` method supports the following input formats:
12
+
13
+ 1. **File Path**: Path to a JSON file containing a keypair array
14
+ 2. **JSON Array String**: A string containing a JSON array of numbers representing the keypair
15
+ 3. **Number Array**: A direct array of numbers representing the keypair
16
+ 4. **Base58 String**: A base58-encoded private key
17
+ 5. **Environment Variable**: Name of an environment variable containing the keypair data
18
+ 6. **KeyPairSigner Object**: An existing KeyPairSigner instance
19
+
20
+ ### Running the Example
21
+
22
+ ```bash
23
+ # Navigate to the examples/node directory
24
+ cd examples/node
25
+
26
+ # Install dependencies
27
+ npm install
28
+
29
+ # Run the set-wallet example
30
+ npx ts-node set-wallet.ts
31
+ ```
32
+
33
+ ### Example Usage
34
+
35
+ ```typescript
36
+ import { NosanaClient, NosanaNetwork } from '@nosana/kit';
37
+
38
+ const client = new NosanaClient(NosanaNetwork.DEVNET);
39
+
40
+ // From file path
41
+ await client.setWallet('./path/to/keypair.json');
42
+
43
+ // From JSON string
44
+ await client.setWallet('[174,47,154,16,...]');
45
+
46
+ // From number array
47
+ await client.setWallet([174, 47, 154, 16, ...]);
48
+
49
+ // From base58 string
50
+ await client.setWallet('base58EncodedPrivateKey');
51
+
52
+ // From environment variable
53
+ process.env.WALLET_KEY = '[174,47,154,16,...]';
54
+ await client.setWallet('WALLET_KEY');
55
+ ```
56
+
57
+ ### Quick Test
58
+
59
+ You can test the setWallet functionality manually by creating a simple test file:
60
+
61
+ ```javascript
62
+ // test-setwallet.js
63
+ const { NosanaClient, NosanaNetwork } = require('@nosana/kit');
64
+
65
+ async function testSetWallet() {
66
+ const client = new NosanaClient(NosanaNetwork.DEVNET);
67
+
68
+ // Test with a sample keypair array
69
+ const sampleKeypair = [
70
+ 174, 47, 154, 16, 202, 193, 206, 113, 199, 190, 53, 133, 169, 175, 31, 56, 222, 53, 138,
71
+ 189, 224, 216, 117, 173, 10, 149, 53, 45, 73, 251, 237, 246, 15, 185, 186, 82, 177, 240,
72
+ 148, 69, 241, 227, 167, 80, 141, 89, 240, 121, 121, 35, 172, 247, 68, 251, 226, 218, 48,
73
+ 63, 176, 109, 168, 89, 238, 135,
74
+ ];
75
+
76
+ try {
77
+ const wallet = await client.setWallet(sampleKeypair);
78
+ console.log('✅ Wallet set successfully!');
79
+ console.log('Address:', wallet?.address);
80
+ } catch (error) {
81
+ console.error('❌ Error:', error.message);
82
+ }
83
+ }
84
+
85
+ testSetWallet();
86
+ ```
87
+
88
+ Run it with: `node test-setwallet.js`
89
+
90
+ ### Error Handling
91
+
92
+ The `setWallet` method tries multiple conversion methods in sequence. If all methods fail, it throws a `NosanaError` with the code `WALLET_CONVERSION_ERROR`.
93
+
94
+ ```typescript
95
+ try {
96
+ await client.setWallet(walletData);
97
+ console.log('Wallet set successfully:', client.wallet?.address);
98
+ } catch (error) {
99
+ if (error instanceof NosanaError && error.code === ErrorCodes.WALLET_CONVERSION_ERROR) {
100
+ console.error('Failed to set wallet:', error.message);
101
+ }
102
+ }
103
+ ```
104
+
105
+ ### Implementation Details
106
+
107
+ The `setWallet` method in `src/index.ts` implements the following logic:
108
+
109
+ 1. **KeyPairSigner Check**: If the input is already a KeyPairSigner object, it's used directly
110
+ 2. **File Path Processing**: For strings that look like file paths (absolute, `./`, or `../`), it attempts to load the keypair from file
111
+ 3. **Environment Variable**: Tries to load from environment variables (both JSON and base58 formats)
112
+ 4. **JSON Parsing**: Attempts to parse JSON array strings
113
+ 5. **Base58 Decoding**: Tries to decode base58-encoded strings
114
+ 6. **Array Processing**: Converts number arrays to Uint8Array for keypair creation
115
+
116
+ ### Unit Tests
117
+
118
+ Comprehensive unit tests have been created in `src/__tests__/setWallet.test.ts` to cover:
119
+
120
+ - ✅ KeyPairSigner input handling
121
+ - ✅ File path validation and loading
122
+ - ✅ Environment variable processing
123
+ - ✅ JSON array string parsing
124
+ - ✅ Base58 string decoding
125
+ - ✅ Number array conversion
126
+ - ✅ Error handling for invalid inputs
127
+ - ✅ File path validation (absolute vs relative paths)
128
+
129
+ **Note**: Due to Jest/TypeScript configuration complexities with the `gill/dist/node` imports, running the tests may require additional setup. The functionality works correctly at runtime.
130
+
131
+ ## Other Examples
132
+
133
+ - `retrieve.ts` - Example of retrieving job data
134
+ - `monitor.ts` - Example of monitoring jobs
135
+
136
+ ## Running Tests
137
+
138
+ To run all tests:
139
+ ```bash
140
+ npm test
141
+ ```
142
+
143
+ To run specific tests:
144
+ ```bash
145
+ npm test -- --testNamePattern="setWallet"
146
+ ```
@@ -0,0 +1 @@
1
+ [66,240,117,68,169,30,179,62,57,123,28,249,122,218,186,173,196,222,208,58,126,168,32,91,126,64,102,33,220,51,49,97,6,197,228,206,210,117,23,184,89,48,217,110,194,137,242,129,112,23,140,120,148,249,210,18,105,192,40,197,250,132,40,149]