ironq-sdk 0.1.0

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.
@@ -0,0 +1,11 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ /** IronQ program ID (Devnet) */
3
+ export declare const PROGRAM_ID: PublicKey;
4
+ /** PDA seed constants matching the on-chain program */
5
+ export declare const SEEDS: {
6
+ readonly QUEUE: Buffer<ArrayBuffer>;
7
+ readonly VAULT: Buffer<ArrayBuffer>;
8
+ readonly JOB: Buffer<ArrayBuffer>;
9
+ readonly WORKER: Buffer<ArrayBuffer>;
10
+ readonly RESULT: Buffer<ArrayBuffer>;
11
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SEEDS = exports.PROGRAM_ID = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ /** IronQ program ID (Devnet) */
6
+ exports.PROGRAM_ID = new web3_js_1.PublicKey("J6GjTDeKugyMhFEuTYnEbsBCVSHsPimmbHcURbJ3wtrQ");
7
+ /** PDA seed constants matching the on-chain program */
8
+ exports.SEEDS = {
9
+ QUEUE: Buffer.from("queue"),
10
+ VAULT: Buffer.from("vault"),
11
+ JOB: Buffer.from("job"),
12
+ WORKER: Buffer.from("worker"),
13
+ RESULT: Buffer.from("result"),
14
+ };
@@ -0,0 +1,3 @@
1
+ export { PROGRAM_ID } from "./constants";
2
+ export { findQueuePDA, findVaultPDA, findJobPDA, findWorkerPDA, findResultPDA, } from "./pda";
3
+ export type { JobStatus, QueueConfig, Job, Worker, JobResult, } from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findResultPDA = exports.findWorkerPDA = exports.findJobPDA = exports.findVaultPDA = exports.findQueuePDA = exports.PROGRAM_ID = void 0;
4
+ var constants_1 = require("./constants");
5
+ Object.defineProperty(exports, "PROGRAM_ID", { enumerable: true, get: function () { return constants_1.PROGRAM_ID; } });
6
+ var pda_1 = require("./pda");
7
+ Object.defineProperty(exports, "findQueuePDA", { enumerable: true, get: function () { return pda_1.findQueuePDA; } });
8
+ Object.defineProperty(exports, "findVaultPDA", { enumerable: true, get: function () { return pda_1.findVaultPDA; } });
9
+ Object.defineProperty(exports, "findJobPDA", { enumerable: true, get: function () { return pda_1.findJobPDA; } });
10
+ Object.defineProperty(exports, "findWorkerPDA", { enumerable: true, get: function () { return pda_1.findWorkerPDA; } });
11
+ Object.defineProperty(exports, "findResultPDA", { enumerable: true, get: function () { return pda_1.findResultPDA; } });
package/dist/pda.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ /** Derive the QueueConfig PDA for a given authority. */
4
+ export declare function findQueuePDA(authority: PublicKey): [PublicKey, number];
5
+ /** Derive the vault token account PDA for a given queue. */
6
+ export declare function findVaultPDA(queue: PublicKey): [PublicKey, number];
7
+ /** Derive the Job PDA from queue key and job ID. */
8
+ export declare function findJobPDA(queue: PublicKey, jobId: BN | number): [PublicKey, number];
9
+ /** Derive the Worker PDA from queue key and worker wallet. */
10
+ export declare function findWorkerPDA(queue: PublicKey, wallet: PublicKey): [PublicKey, number];
11
+ /** Derive the JobResult PDA from a job key. */
12
+ export declare function findResultPDA(job: PublicKey): [PublicKey, number];
package/dist/pda.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findQueuePDA = findQueuePDA;
4
+ exports.findVaultPDA = findVaultPDA;
5
+ exports.findJobPDA = findJobPDA;
6
+ exports.findWorkerPDA = findWorkerPDA;
7
+ exports.findResultPDA = findResultPDA;
8
+ const web3_js_1 = require("@solana/web3.js");
9
+ const constants_1 = require("./constants");
10
+ /** Derive the QueueConfig PDA for a given authority. */
11
+ function findQueuePDA(authority) {
12
+ return web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.QUEUE, authority.toBuffer()], constants_1.PROGRAM_ID);
13
+ }
14
+ /** Derive the vault token account PDA for a given queue. */
15
+ function findVaultPDA(queue) {
16
+ return web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.VAULT, queue.toBuffer()], constants_1.PROGRAM_ID);
17
+ }
18
+ /** Derive the Job PDA from queue key and job ID. */
19
+ function findJobPDA(queue, jobId) {
20
+ const buf = Buffer.alloc(8);
21
+ buf.writeBigUInt64LE(BigInt(jobId.toString()));
22
+ return web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.JOB, queue.toBuffer(), buf], constants_1.PROGRAM_ID);
23
+ }
24
+ /** Derive the Worker PDA from queue key and worker wallet. */
25
+ function findWorkerPDA(queue, wallet) {
26
+ return web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.WORKER, queue.toBuffer(), wallet.toBuffer()], constants_1.PROGRAM_ID);
27
+ }
28
+ /** Derive the JobResult PDA from a job key. */
29
+ function findResultPDA(job) {
30
+ return web3_js_1.PublicKey.findProgramAddressSync([constants_1.SEEDS.RESULT, job.toBuffer()], constants_1.PROGRAM_ID);
31
+ }
@@ -0,0 +1,78 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ /** Job lifecycle status variants (Anchor enum format). */
4
+ export type JobStatus = {
5
+ open: {};
6
+ } | {
7
+ claimed: {};
8
+ } | {
9
+ submitted: {};
10
+ } | {
11
+ completed: {};
12
+ } | {
13
+ disputed: {};
14
+ } | {
15
+ expired: {};
16
+ } | {
17
+ cancelled: {};
18
+ };
19
+ /** Deserialized QueueConfig account. */
20
+ export interface QueueConfig {
21
+ version: number;
22
+ authority: PublicKey;
23
+ rewardMint: PublicKey;
24
+ arbiter: PublicKey;
25
+ vault: PublicKey;
26
+ minWorkerStake: BN;
27
+ jobTimeout: BN;
28
+ slashRateBps: number;
29
+ crankRewardBps: number;
30
+ totalJobsCreated: BN;
31
+ totalActiveWorkers: number;
32
+ isPaused: boolean;
33
+ maxConcurrentJobs: number;
34
+ pendingAuthority: PublicKey | null;
35
+ bump: number;
36
+ }
37
+ /** Deserialized Job account. */
38
+ export interface Job {
39
+ version: number;
40
+ queue: PublicKey;
41
+ jobId: BN;
42
+ creator: PublicKey;
43
+ worker: PublicKey;
44
+ status: JobStatus;
45
+ rewardAmount: BN;
46
+ dataHash: number[];
47
+ createdAt: BN;
48
+ claimedAt: BN;
49
+ deadline: BN;
50
+ priority: number;
51
+ maxRetries: number;
52
+ retryCount: number;
53
+ bump: number;
54
+ }
55
+ /** Deserialized Worker account. */
56
+ export interface Worker {
57
+ version: number;
58
+ queue: PublicKey;
59
+ wallet: PublicKey;
60
+ stakeAmount: BN;
61
+ jobsCompleted: number;
62
+ jobsFailed: number;
63
+ totalEarned: BN;
64
+ activeJobs: number;
65
+ maxConcurrentJobs: number;
66
+ isActive: boolean;
67
+ registeredAt: BN;
68
+ bump: number;
69
+ }
70
+ /** Deserialized JobResult account. */
71
+ export interface JobResult {
72
+ version: number;
73
+ job: PublicKey;
74
+ worker: PublicKey;
75
+ resultHash: number[];
76
+ submittedAt: BN;
77
+ bump: number;
78
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "ironq-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the IronQ on-chain job queue on Solana",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build"
10
+ },
11
+ "files": [
12
+ "dist/",
13
+ "src/"
14
+ ],
15
+ "keywords": ["solana", "anchor", "job-queue", "ironq"],
16
+ "license": "ISC",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/amanhij/IronQ.git",
20
+ "directory": "ironq/sdk"
21
+ },
22
+ "homepage": "https://github.com/amanhij/IronQ",
23
+ "bugs": {
24
+ "url": "https://github.com/amanhij/IronQ/issues"
25
+ },
26
+ "peerDependencies": {
27
+ "@coral-xyz/anchor": ">=0.30.0",
28
+ "@solana/web3.js": ">=1.90.0"
29
+ },
30
+ "devDependencies": {
31
+ "typescript": "^5.0.0",
32
+ "@coral-xyz/anchor": "^0.31.1",
33
+ "@solana/web3.js": "^1.95.0"
34
+ }
35
+ }
@@ -0,0 +1,15 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+
3
+ /** IronQ program ID (Devnet) */
4
+ export const PROGRAM_ID = new PublicKey(
5
+ "J6GjTDeKugyMhFEuTYnEbsBCVSHsPimmbHcURbJ3wtrQ"
6
+ );
7
+
8
+ /** PDA seed constants matching the on-chain program */
9
+ export const SEEDS = {
10
+ QUEUE: Buffer.from("queue"),
11
+ VAULT: Buffer.from("vault"),
12
+ JOB: Buffer.from("job"),
13
+ WORKER: Buffer.from("worker"),
14
+ RESULT: Buffer.from("result"),
15
+ } as const;
package/src/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ export { PROGRAM_ID } from "./constants";
2
+ export {
3
+ findQueuePDA,
4
+ findVaultPDA,
5
+ findJobPDA,
6
+ findWorkerPDA,
7
+ findResultPDA,
8
+ } from "./pda";
9
+ export type {
10
+ JobStatus,
11
+ QueueConfig,
12
+ Job,
13
+ Worker,
14
+ JobResult,
15
+ } from "./types";
package/src/pda.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+ import { PROGRAM_ID, SEEDS } from "./constants";
4
+
5
+ /** Derive the QueueConfig PDA for a given authority. */
6
+ export function findQueuePDA(authority: PublicKey): [PublicKey, number] {
7
+ return PublicKey.findProgramAddressSync(
8
+ [SEEDS.QUEUE, authority.toBuffer()],
9
+ PROGRAM_ID
10
+ );
11
+ }
12
+
13
+ /** Derive the vault token account PDA for a given queue. */
14
+ export function findVaultPDA(queue: PublicKey): [PublicKey, number] {
15
+ return PublicKey.findProgramAddressSync(
16
+ [SEEDS.VAULT, queue.toBuffer()],
17
+ PROGRAM_ID
18
+ );
19
+ }
20
+
21
+ /** Derive the Job PDA from queue key and job ID. */
22
+ export function findJobPDA(
23
+ queue: PublicKey,
24
+ jobId: BN | number
25
+ ): [PublicKey, number] {
26
+ const buf = Buffer.alloc(8);
27
+ buf.writeBigUInt64LE(BigInt(jobId.toString()));
28
+ return PublicKey.findProgramAddressSync(
29
+ [SEEDS.JOB, queue.toBuffer(), buf],
30
+ PROGRAM_ID
31
+ );
32
+ }
33
+
34
+ /** Derive the Worker PDA from queue key and worker wallet. */
35
+ export function findWorkerPDA(
36
+ queue: PublicKey,
37
+ wallet: PublicKey
38
+ ): [PublicKey, number] {
39
+ return PublicKey.findProgramAddressSync(
40
+ [SEEDS.WORKER, queue.toBuffer(), wallet.toBuffer()],
41
+ PROGRAM_ID
42
+ );
43
+ }
44
+
45
+ /** Derive the JobResult PDA from a job key. */
46
+ export function findResultPDA(job: PublicKey): [PublicKey, number] {
47
+ return PublicKey.findProgramAddressSync(
48
+ [SEEDS.RESULT, job.toBuffer()],
49
+ PROGRAM_ID
50
+ );
51
+ }
package/src/types.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import { BN } from "@coral-xyz/anchor";
3
+
4
+ /** Job lifecycle status variants (Anchor enum format). */
5
+ export type JobStatus =
6
+ | { open: {} }
7
+ | { claimed: {} }
8
+ | { submitted: {} }
9
+ | { completed: {} }
10
+ | { disputed: {} }
11
+ | { expired: {} }
12
+ | { cancelled: {} };
13
+
14
+ /** Deserialized QueueConfig account. */
15
+ export interface QueueConfig {
16
+ version: number;
17
+ authority: PublicKey;
18
+ rewardMint: PublicKey;
19
+ arbiter: PublicKey;
20
+ vault: PublicKey;
21
+ minWorkerStake: BN;
22
+ jobTimeout: BN;
23
+ slashRateBps: number;
24
+ crankRewardBps: number;
25
+ totalJobsCreated: BN;
26
+ totalActiveWorkers: number;
27
+ isPaused: boolean;
28
+ maxConcurrentJobs: number;
29
+ pendingAuthority: PublicKey | null;
30
+ bump: number;
31
+ }
32
+
33
+ /** Deserialized Job account. */
34
+ export interface Job {
35
+ version: number;
36
+ queue: PublicKey;
37
+ jobId: BN;
38
+ creator: PublicKey;
39
+ worker: PublicKey;
40
+ status: JobStatus;
41
+ rewardAmount: BN;
42
+ dataHash: number[];
43
+ createdAt: BN;
44
+ claimedAt: BN;
45
+ deadline: BN;
46
+ priority: number;
47
+ maxRetries: number;
48
+ retryCount: number;
49
+ bump: number;
50
+ }
51
+
52
+ /** Deserialized Worker account. */
53
+ export interface Worker {
54
+ version: number;
55
+ queue: PublicKey;
56
+ wallet: PublicKey;
57
+ stakeAmount: BN;
58
+ jobsCompleted: number;
59
+ jobsFailed: number;
60
+ totalEarned: BN;
61
+ activeJobs: number;
62
+ maxConcurrentJobs: number;
63
+ isActive: boolean;
64
+ registeredAt: BN;
65
+ bump: number;
66
+ }
67
+
68
+ /** Deserialized JobResult account. */
69
+ export interface JobResult {
70
+ version: number;
71
+ job: PublicKey;
72
+ worker: PublicKey;
73
+ resultHash: number[];
74
+ submittedAt: BN;
75
+ bump: number;
76
+ }