@occa/sdk 0.4.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.
- package/CHANGELOG.md +238 -0
- package/LICENSE +21 -0
- package/README.md +102 -0
- package/dist/chunk-N7LNBSDD.js +658 -0
- package/dist/chunk-N7LNBSDD.js.map +1 -0
- package/dist/chunk-X6FBCGHU.js +97 -0
- package/dist/chunk-X6FBCGHU.js.map +1 -0
- package/dist/chunk-YCSBYRSH.js +75 -0
- package/dist/chunk-YCSBYRSH.js.map +1 -0
- package/dist/constants.cjs +121 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +53 -0
- package/dist/constants.d.ts +53 -0
- package/dist/constants.js +51 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.cjs +870 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/instructions.cjs +785 -0
- package/dist/instructions.cjs.map +1 -0
- package/dist/instructions.d.cts +442 -0
- package/dist/instructions.d.ts +442 -0
- package/dist/instructions.js +51 -0
- package/dist/instructions.js.map +1 -0
- package/dist/pda.cjs +146 -0
- package/dist/pda.cjs.map +1 -0
- package/dist/pda.d.cts +116 -0
- package/dist/pda.d.ts +116 -0
- package/dist/pda.js +24 -0
- package/dist/pda.js.map +1 -0
- package/package.json +80 -0
- package/src/constants.ts +93 -0
- package/src/idl/registry.json +1415 -0
- package/src/idl/treasury.json +1627 -0
- package/src/index.ts +18 -0
- package/src/instructions.ts +1171 -0
- package/src/pda.ts +199 -0
package/dist/pda.d.cts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { OperationsKind } from './constants.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Encode a u32 as little-endian 4 bytes (matches Anchor / Borsh on-chain
|
|
6
|
+
* representation when using a u32 in a PDA seed).
|
|
7
|
+
*/
|
|
8
|
+
declare function u32LeBytes(value: number): Buffer;
|
|
9
|
+
/**
|
|
10
|
+
* CompanyAccount PDA.
|
|
11
|
+
*
|
|
12
|
+
* seeds = ["company", owner, nonce_le_u32]
|
|
13
|
+
*
|
|
14
|
+
* Wallet-bound seed: a wallet's companies can be enumerated directly
|
|
15
|
+
* from chain by probing `(owner, nonce=0..N)`. The owner is also the
|
|
16
|
+
* sole authority for state-changing ix on this account.
|
|
17
|
+
*/
|
|
18
|
+
declare function deriveCompanyPda(owner: PublicKey, nonce: number, programId?: PublicKey): {
|
|
19
|
+
pda: PublicKey;
|
|
20
|
+
bump: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* AgentIdentity PDA.
|
|
24
|
+
*
|
|
25
|
+
* seeds = ["agent_identity", agent_pubkey]
|
|
26
|
+
*
|
|
27
|
+
* `agent_pubkey` is a stable identity key chosen by the caller (typically
|
|
28
|
+
* a fresh keypair generated client-side). Identity is independent of any
|
|
29
|
+
* company — the same identity may be deployed multiple times across the
|
|
30
|
+
* same owner's companies.
|
|
31
|
+
*/
|
|
32
|
+
declare function deriveAgentIdentityPda(agentPubkey: PublicKey, programId?: PublicKey): {
|
|
33
|
+
pda: PublicKey;
|
|
34
|
+
bump: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Deployment PDA.
|
|
38
|
+
*
|
|
39
|
+
* seeds = ["deployment", company_pda, deployment_index_le_u32]
|
|
40
|
+
*
|
|
41
|
+
* `deployment_index` is a per-company u32 counter. Maintained by the
|
|
42
|
+
* caller — pick the next free index. Same `agent_identity` may have
|
|
43
|
+
* multiple deployments under the same company (e.g. retired then
|
|
44
|
+
* re-deployed); each deployment gets its own index.
|
|
45
|
+
*/
|
|
46
|
+
declare function deriveDeploymentPda(companyPda: PublicKey, deploymentIndex: number, programId?: PublicKey): {
|
|
47
|
+
pda: PublicKey;
|
|
48
|
+
bump: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* TreasuryAccount PDA — owned by Treasury program.
|
|
52
|
+
*
|
|
53
|
+
* seeds = ["treasury", company_pda]
|
|
54
|
+
*
|
|
55
|
+
* Initialized atomically with PolicyAccount via Registry's `create_company`
|
|
56
|
+
* CPI to `treasury::init_treasury` (design doc §6).
|
|
57
|
+
*/
|
|
58
|
+
declare function deriveTreasuryPda(companyPda: PublicKey, programId?: PublicKey): {
|
|
59
|
+
pda: PublicKey;
|
|
60
|
+
bump: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* PolicyAccount PDA — owned by Treasury program.
|
|
64
|
+
*
|
|
65
|
+
* seeds = ["policy", company_pda]
|
|
66
|
+
*
|
|
67
|
+
* Initialized atomically with TreasuryAccount via the same `create_company`
|
|
68
|
+
* CPI flow.
|
|
69
|
+
*/
|
|
70
|
+
declare function derivePolicyPda(companyPda: PublicKey, programId?: PublicKey): {
|
|
71
|
+
pda: PublicKey;
|
|
72
|
+
bump: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* ProtocolFeeAccount PDA — owned by Treasury program. Singleton: one
|
|
76
|
+
* per program deployment, collects the Agent Operating Fee from every
|
|
77
|
+
* intra-company agent disbursement.
|
|
78
|
+
*
|
|
79
|
+
* seeds = ["protocol_fees"]
|
|
80
|
+
*/
|
|
81
|
+
declare function deriveProtocolFeePda(programId?: PublicKey): {
|
|
82
|
+
pda: PublicKey;
|
|
83
|
+
bump: number;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* OperationsAccount PDA — owned by Treasury program. One per
|
|
87
|
+
* (company, kind) pair, so Disbursement and Anchor capabilities never
|
|
88
|
+
* share a key.
|
|
89
|
+
*
|
|
90
|
+
* seeds = ["operations", company_pda, kind_byte]
|
|
91
|
+
*
|
|
92
|
+
* `kind_byte` is the single-byte discriminator from `OPERATIONS_KIND`
|
|
93
|
+
* (Disbursement=0, Anchor=1). Order MUST NOT change once any account
|
|
94
|
+
* exists.
|
|
95
|
+
*/
|
|
96
|
+
declare function deriveOperationsPda(companyPda: PublicKey, kind: OperationsKind, programId?: PublicKey): {
|
|
97
|
+
pda: PublicKey;
|
|
98
|
+
bump: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* DailyAnchorAccount PDA — owned by Registry program. One per
|
|
102
|
+
* (deployment, UTC day) — captures the Merkle root over that day's
|
|
103
|
+
* task hashes.
|
|
104
|
+
*
|
|
105
|
+
* seeds = ["daily_anchor", deployment_pda, day_unix_le_i64]
|
|
106
|
+
*
|
|
107
|
+
* `dayUnix` must be aligned to 00:00:00 UTC (multiple of 86400). The
|
|
108
|
+
* on-chain handler enforces alignment; passing an unaligned value will
|
|
109
|
+
* fail with a constraint error.
|
|
110
|
+
*/
|
|
111
|
+
declare function deriveDailyAnchorPda(deploymentPda: PublicKey, dayUnix: bigint, programId?: PublicKey): {
|
|
112
|
+
pda: PublicKey;
|
|
113
|
+
bump: number;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTreasuryPda, u32LeBytes };
|
package/dist/pda.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { OperationsKind } from './constants.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Encode a u32 as little-endian 4 bytes (matches Anchor / Borsh on-chain
|
|
6
|
+
* representation when using a u32 in a PDA seed).
|
|
7
|
+
*/
|
|
8
|
+
declare function u32LeBytes(value: number): Buffer;
|
|
9
|
+
/**
|
|
10
|
+
* CompanyAccount PDA.
|
|
11
|
+
*
|
|
12
|
+
* seeds = ["company", owner, nonce_le_u32]
|
|
13
|
+
*
|
|
14
|
+
* Wallet-bound seed: a wallet's companies can be enumerated directly
|
|
15
|
+
* from chain by probing `(owner, nonce=0..N)`. The owner is also the
|
|
16
|
+
* sole authority for state-changing ix on this account.
|
|
17
|
+
*/
|
|
18
|
+
declare function deriveCompanyPda(owner: PublicKey, nonce: number, programId?: PublicKey): {
|
|
19
|
+
pda: PublicKey;
|
|
20
|
+
bump: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* AgentIdentity PDA.
|
|
24
|
+
*
|
|
25
|
+
* seeds = ["agent_identity", agent_pubkey]
|
|
26
|
+
*
|
|
27
|
+
* `agent_pubkey` is a stable identity key chosen by the caller (typically
|
|
28
|
+
* a fresh keypair generated client-side). Identity is independent of any
|
|
29
|
+
* company — the same identity may be deployed multiple times across the
|
|
30
|
+
* same owner's companies.
|
|
31
|
+
*/
|
|
32
|
+
declare function deriveAgentIdentityPda(agentPubkey: PublicKey, programId?: PublicKey): {
|
|
33
|
+
pda: PublicKey;
|
|
34
|
+
bump: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Deployment PDA.
|
|
38
|
+
*
|
|
39
|
+
* seeds = ["deployment", company_pda, deployment_index_le_u32]
|
|
40
|
+
*
|
|
41
|
+
* `deployment_index` is a per-company u32 counter. Maintained by the
|
|
42
|
+
* caller — pick the next free index. Same `agent_identity` may have
|
|
43
|
+
* multiple deployments under the same company (e.g. retired then
|
|
44
|
+
* re-deployed); each deployment gets its own index.
|
|
45
|
+
*/
|
|
46
|
+
declare function deriveDeploymentPda(companyPda: PublicKey, deploymentIndex: number, programId?: PublicKey): {
|
|
47
|
+
pda: PublicKey;
|
|
48
|
+
bump: number;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* TreasuryAccount PDA — owned by Treasury program.
|
|
52
|
+
*
|
|
53
|
+
* seeds = ["treasury", company_pda]
|
|
54
|
+
*
|
|
55
|
+
* Initialized atomically with PolicyAccount via Registry's `create_company`
|
|
56
|
+
* CPI to `treasury::init_treasury` (design doc §6).
|
|
57
|
+
*/
|
|
58
|
+
declare function deriveTreasuryPda(companyPda: PublicKey, programId?: PublicKey): {
|
|
59
|
+
pda: PublicKey;
|
|
60
|
+
bump: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* PolicyAccount PDA — owned by Treasury program.
|
|
64
|
+
*
|
|
65
|
+
* seeds = ["policy", company_pda]
|
|
66
|
+
*
|
|
67
|
+
* Initialized atomically with TreasuryAccount via the same `create_company`
|
|
68
|
+
* CPI flow.
|
|
69
|
+
*/
|
|
70
|
+
declare function derivePolicyPda(companyPda: PublicKey, programId?: PublicKey): {
|
|
71
|
+
pda: PublicKey;
|
|
72
|
+
bump: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* ProtocolFeeAccount PDA — owned by Treasury program. Singleton: one
|
|
76
|
+
* per program deployment, collects the Agent Operating Fee from every
|
|
77
|
+
* intra-company agent disbursement.
|
|
78
|
+
*
|
|
79
|
+
* seeds = ["protocol_fees"]
|
|
80
|
+
*/
|
|
81
|
+
declare function deriveProtocolFeePda(programId?: PublicKey): {
|
|
82
|
+
pda: PublicKey;
|
|
83
|
+
bump: number;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* OperationsAccount PDA — owned by Treasury program. One per
|
|
87
|
+
* (company, kind) pair, so Disbursement and Anchor capabilities never
|
|
88
|
+
* share a key.
|
|
89
|
+
*
|
|
90
|
+
* seeds = ["operations", company_pda, kind_byte]
|
|
91
|
+
*
|
|
92
|
+
* `kind_byte` is the single-byte discriminator from `OPERATIONS_KIND`
|
|
93
|
+
* (Disbursement=0, Anchor=1). Order MUST NOT change once any account
|
|
94
|
+
* exists.
|
|
95
|
+
*/
|
|
96
|
+
declare function deriveOperationsPda(companyPda: PublicKey, kind: OperationsKind, programId?: PublicKey): {
|
|
97
|
+
pda: PublicKey;
|
|
98
|
+
bump: number;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* DailyAnchorAccount PDA — owned by Registry program. One per
|
|
102
|
+
* (deployment, UTC day) — captures the Merkle root over that day's
|
|
103
|
+
* task hashes.
|
|
104
|
+
*
|
|
105
|
+
* seeds = ["daily_anchor", deployment_pda, day_unix_le_i64]
|
|
106
|
+
*
|
|
107
|
+
* `dayUnix` must be aligned to 00:00:00 UTC (multiple of 86400). The
|
|
108
|
+
* on-chain handler enforces alignment; passing an unaligned value will
|
|
109
|
+
* fail with a constraint error.
|
|
110
|
+
*/
|
|
111
|
+
declare function deriveDailyAnchorPda(deploymentPda: PublicKey, dayUnix: bigint, programId?: PublicKey): {
|
|
112
|
+
pda: PublicKey;
|
|
113
|
+
bump: number;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { deriveAgentIdentityPda, deriveCompanyPda, deriveDailyAnchorPda, deriveDeploymentPda, deriveOperationsPda, derivePolicyPda, deriveProtocolFeePda, deriveTreasuryPda, u32LeBytes };
|
package/dist/pda.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deriveAgentIdentityPda,
|
|
3
|
+
deriveCompanyPda,
|
|
4
|
+
deriveDailyAnchorPda,
|
|
5
|
+
deriveDeploymentPda,
|
|
6
|
+
deriveOperationsPda,
|
|
7
|
+
derivePolicyPda,
|
|
8
|
+
deriveProtocolFeePda,
|
|
9
|
+
deriveTreasuryPda,
|
|
10
|
+
u32LeBytes
|
|
11
|
+
} from "./chunk-X6FBCGHU.js";
|
|
12
|
+
import "./chunk-YCSBYRSH.js";
|
|
13
|
+
export {
|
|
14
|
+
deriveAgentIdentityPda,
|
|
15
|
+
deriveCompanyPda,
|
|
16
|
+
deriveDailyAnchorPda,
|
|
17
|
+
deriveDeploymentPda,
|
|
18
|
+
deriveOperationsPda,
|
|
19
|
+
derivePolicyPda,
|
|
20
|
+
deriveProtocolFeePda,
|
|
21
|
+
deriveTreasuryPda,
|
|
22
|
+
u32LeBytes
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=pda.js.map
|
package/dist/pda.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@occa/sdk",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "OCCA on-chain protocol SDK — PDA helpers, instruction builders, and types for the OCCA Registry + Treasury programs on Solana.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "OCCA",
|
|
7
|
+
"homepage": "https://github.com/Occa-Labs/occa-core/tree/main/packages/occa-sdk#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Occa-Labs/occa-core.git",
|
|
11
|
+
"directory": "packages/occa-sdk"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Occa-Labs/occa-core/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"solana",
|
|
18
|
+
"anchor",
|
|
19
|
+
"occa",
|
|
20
|
+
"agent",
|
|
21
|
+
"agent-identity",
|
|
22
|
+
"ai-agents",
|
|
23
|
+
"registry",
|
|
24
|
+
"deployment",
|
|
25
|
+
"web3"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"main": "./dist/index.cjs",
|
|
29
|
+
"module": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./pda": {
|
|
38
|
+
"types": "./dist/pda.d.ts",
|
|
39
|
+
"import": "./dist/pda.js",
|
|
40
|
+
"require": "./dist/pda.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./constants": {
|
|
43
|
+
"types": "./dist/constants.d.ts",
|
|
44
|
+
"import": "./dist/constants.js",
|
|
45
|
+
"require": "./dist/constants.cjs"
|
|
46
|
+
},
|
|
47
|
+
"./instructions": {
|
|
48
|
+
"types": "./dist/instructions.d.ts",
|
|
49
|
+
"import": "./dist/instructions.js",
|
|
50
|
+
"require": "./dist/instructions.cjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"src",
|
|
56
|
+
"README.md",
|
|
57
|
+
"LICENSE",
|
|
58
|
+
"CHANGELOG.md"
|
|
59
|
+
],
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@solana/web3.js": "^1.98.4"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@types/node": "^20",
|
|
65
|
+
"tsup": "^8.0.0",
|
|
66
|
+
"tsx": "^4.0.0",
|
|
67
|
+
"typescript": "^5.0.0"
|
|
68
|
+
},
|
|
69
|
+
"publishConfig": {
|
|
70
|
+
"access": "public"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=18"
|
|
74
|
+
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"build": "tsup",
|
|
77
|
+
"sync-idl": "cp ../../../occa-programs/target/idl/registry.json src/idl/registry.json && cp ../../../occa-programs/target/idl/treasury.json src/idl/treasury.json",
|
|
78
|
+
"devnet-smoke": "tsx scripts/devnet-smoke.ts"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
|
|
3
|
+
// Registry program ID. The vanity-grinded program keypair lives at
|
|
4
|
+
// `occa-programs/programs/registry/registry-keypair.json` (gitignored,
|
|
5
|
+
// sibling repo). Public key is committed here so clients (server +
|
|
6
|
+
// web) can derive PDAs without loading the keypair.
|
|
7
|
+
//
|
|
8
|
+
// NOTE: this is the devnet program ID. Mainnet will likely have a
|
|
9
|
+
// different program ID — when that day comes, swap via env or config.
|
|
10
|
+
export const REGISTRY_PROGRAM_ID_BASE58 =
|
|
11
|
+
"occaTHMv5eYG5aZ85jimxTvHkBfsDCvndXC6J2k8kxr";
|
|
12
|
+
|
|
13
|
+
export const REGISTRY_PROGRAM_ID = new PublicKey(REGISTRY_PROGRAM_ID_BASE58);
|
|
14
|
+
|
|
15
|
+
// Treasury program ID — devnet. Registry's `create_company` CPIs into
|
|
16
|
+
// `treasury::init_treasury` to atomically initialize the company's
|
|
17
|
+
// TreasuryAccount + PolicyAccount PDAs (per design doc §6).
|
|
18
|
+
export const TREASURY_PROGRAM_ID_BASE58 =
|
|
19
|
+
"occaxyVLnurdjedWCBPrvDCCto8wGYadtTZ3nAmcVzh";
|
|
20
|
+
|
|
21
|
+
export const TREASURY_PROGRAM_ID = new PublicKey(TREASURY_PROGRAM_ID_BASE58);
|
|
22
|
+
|
|
23
|
+
// PDA seed prefixes. Must match `occa-programs/programs/registry/src/lib.rs` exactly.
|
|
24
|
+
export const COMPANY_SEED = Buffer.from("company");
|
|
25
|
+
export const AGENT_IDENTITY_SEED = Buffer.from("agent_identity");
|
|
26
|
+
export const DEPLOYMENT_SEED = Buffer.from("deployment");
|
|
27
|
+
// Treasury PDA seeds (owned by treasury program). Must match
|
|
28
|
+
// `occa-programs/programs/treasury/src/lib.rs`.
|
|
29
|
+
export const TREASURY_SEED = Buffer.from("treasury");
|
|
30
|
+
export const POLICY_SEED = Buffer.from("policy");
|
|
31
|
+
export const PROTOCOL_FEES_SEED = Buffer.from("protocol_fees");
|
|
32
|
+
export const OPERATIONS_SEED = Buffer.from("operations");
|
|
33
|
+
// DailyAnchor PDA seed (owned by registry program). Seeds:
|
|
34
|
+
// ["daily_anchor", deployment_pda, day_unix_le_i64_8bytes].
|
|
35
|
+
export const DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
|
|
36
|
+
|
|
37
|
+
// OperationsKind discriminator byte — must match the Rust enum order in
|
|
38
|
+
// `treasury/src/lib.rs`. Used as the 3rd seed byte of an OperationsAccount
|
|
39
|
+
// PDA and as a u8 wire arg to `register_company_operations`.
|
|
40
|
+
export const OPERATIONS_KIND = {
|
|
41
|
+
/** Disbursement Wallet — operator-held only, signs `disburse_routine`. */
|
|
42
|
+
Disbursement: 0,
|
|
43
|
+
/** Anchor Wallet — operator+OCCA shared, signs `commit_daily_anchor`. */
|
|
44
|
+
Anchor: 1,
|
|
45
|
+
} as const;
|
|
46
|
+
export type OperationsKind =
|
|
47
|
+
(typeof OPERATIONS_KIND)[keyof typeof OPERATIONS_KIND];
|
|
48
|
+
|
|
49
|
+
// SOL has no real SPL mint — lamports live directly on accounts. The
|
|
50
|
+
// treasury program uses the default (all-zero) pubkey as the SOL marker
|
|
51
|
+
// in accepted-asset lists and disbursement mint args.
|
|
52
|
+
export const SOL_PSEUDO_MINT = new PublicKey(new Uint8Array(32));
|
|
53
|
+
|
|
54
|
+
// On-chain bounds — must match `occa-programs/programs/registry/src/lib.rs`.
|
|
55
|
+
export const MAX_NAME_LEN = 64;
|
|
56
|
+
export const MAX_LOCALE_LEN = 8;
|
|
57
|
+
export const MAX_ROLE_LEN = 32;
|
|
58
|
+
export const MAX_METADATA_URI_LEN = 200;
|
|
59
|
+
export const MAX_REPUTATION_URI_LEN = 200;
|
|
60
|
+
|
|
61
|
+
// Status encodings — must match the on-chain constants.
|
|
62
|
+
export const COMPANY_STATUS = {
|
|
63
|
+
Active: 0,
|
|
64
|
+
Paused: 1,
|
|
65
|
+
} as const;
|
|
66
|
+
export type CompanyStatus =
|
|
67
|
+
(typeof COMPANY_STATUS)[keyof typeof COMPANY_STATUS];
|
|
68
|
+
|
|
69
|
+
export const DEPLOYMENT_STATUS = {
|
|
70
|
+
Active: 0,
|
|
71
|
+
Paused: 1,
|
|
72
|
+
/** Terminal — retired deployments cannot be reactivated. */
|
|
73
|
+
Retired: 2,
|
|
74
|
+
} as const;
|
|
75
|
+
export type DeploymentStatus =
|
|
76
|
+
(typeof DEPLOYMENT_STATUS)[keyof typeof DEPLOYMENT_STATUS];
|
|
77
|
+
|
|
78
|
+
// Account discriminators (Anchor sha256("account:<Name>")[..8]).
|
|
79
|
+
export const ACCOUNT_DISCRIMINATOR = {
|
|
80
|
+
AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),
|
|
81
|
+
CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),
|
|
82
|
+
Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),
|
|
83
|
+
DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254]),
|
|
84
|
+
} as const;
|
|
85
|
+
|
|
86
|
+
// Treasury program account discriminators — from
|
|
87
|
+
// `occa-programs/target/idl/treasury.json`.
|
|
88
|
+
export const TREASURY_ACCOUNT_DISCRIMINATOR = {
|
|
89
|
+
TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),
|
|
90
|
+
PolicyAccount: Buffer.from([218, 201, 183, 164, 156, 127, 81, 175]),
|
|
91
|
+
ProtocolFeeAccount: Buffer.from([5, 171, 24, 9, 150, 135, 135, 201]),
|
|
92
|
+
OperationsAccount: Buffer.from([185, 55, 148, 90, 151, 227, 104, 158]),
|
|
93
|
+
} as const;
|