@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
|
@@ -0,0 +1,785 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/instructions.ts
|
|
21
|
+
var instructions_exports = {};
|
|
22
|
+
__export(instructions_exports, {
|
|
23
|
+
INSTRUCTION_DISCRIMINATOR: () => INSTRUCTION_DISCRIMINATOR,
|
|
24
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR: () => TREASURY_INSTRUCTION_DISCRIMINATOR,
|
|
25
|
+
buildCloseOperationsInstruction: () => buildCloseOperationsInstruction,
|
|
26
|
+
buildCommitDailyAnchorInstruction: () => buildCommitDailyAnchorInstruction,
|
|
27
|
+
buildCreateCompanyInstruction: () => buildCreateCompanyInstruction,
|
|
28
|
+
buildCreateDeploymentInstruction: () => buildCreateDeploymentInstruction,
|
|
29
|
+
buildDisburseDiscretionaryInstruction: () => buildDisburseDiscretionaryInstruction,
|
|
30
|
+
buildDisbursePrivilegedInstruction: () => buildDisbursePrivilegedInstruction,
|
|
31
|
+
buildDisburseRoutineInstruction: () => buildDisburseRoutineInstruction,
|
|
32
|
+
buildInitProtocolFeeAccountInstruction: () => buildInitProtocolFeeAccountInstruction,
|
|
33
|
+
buildRegisterAgentIdentityInstruction: () => buildRegisterAgentIdentityInstruction,
|
|
34
|
+
buildRegisterCompanyOperationsInstruction: () => buildRegisterCompanyOperationsInstruction,
|
|
35
|
+
buildRetireDeploymentInstruction: () => buildRetireDeploymentInstruction,
|
|
36
|
+
buildRevokeOperationsInstruction: () => buildRevokeOperationsInstruction,
|
|
37
|
+
buildSetPolicyInstruction: () => buildSetPolicyInstruction,
|
|
38
|
+
buildSetReceivingAddressInstruction: () => buildSetReceivingAddressInstruction,
|
|
39
|
+
buildUpdateAgentIdentityMetadataInstruction: () => buildUpdateAgentIdentityMetadataInstruction,
|
|
40
|
+
buildUpdateCompanyMetadataInstruction: () => buildUpdateCompanyMetadataInstruction,
|
|
41
|
+
buildUpdateCompanyStatusInstruction: () => buildUpdateCompanyStatusInstruction,
|
|
42
|
+
buildUpdateDeploymentMetadataInstruction: () => buildUpdateDeploymentMetadataInstruction,
|
|
43
|
+
buildUpdateDeploymentStatusInstruction: () => buildUpdateDeploymentStatusInstruction,
|
|
44
|
+
buildUpdateOperationsCapabilityInstruction: () => buildUpdateOperationsCapabilityInstruction
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(instructions_exports);
|
|
47
|
+
var import_web33 = require("@solana/web3.js");
|
|
48
|
+
|
|
49
|
+
// src/constants.ts
|
|
50
|
+
var import_web3 = require("@solana/web3.js");
|
|
51
|
+
var REGISTRY_PROGRAM_ID_BASE58 = "occaTHMv5eYG5aZ85jimxTvHkBfsDCvndXC6J2k8kxr";
|
|
52
|
+
var REGISTRY_PROGRAM_ID = new import_web3.PublicKey(REGISTRY_PROGRAM_ID_BASE58);
|
|
53
|
+
var TREASURY_PROGRAM_ID_BASE58 = "occaxyVLnurdjedWCBPrvDCCto8wGYadtTZ3nAmcVzh";
|
|
54
|
+
var TREASURY_PROGRAM_ID = new import_web3.PublicKey(TREASURY_PROGRAM_ID_BASE58);
|
|
55
|
+
var COMPANY_SEED = Buffer.from("company");
|
|
56
|
+
var AGENT_IDENTITY_SEED = Buffer.from("agent_identity");
|
|
57
|
+
var DEPLOYMENT_SEED = Buffer.from("deployment");
|
|
58
|
+
var TREASURY_SEED = Buffer.from("treasury");
|
|
59
|
+
var POLICY_SEED = Buffer.from("policy");
|
|
60
|
+
var PROTOCOL_FEES_SEED = Buffer.from("protocol_fees");
|
|
61
|
+
var OPERATIONS_SEED = Buffer.from("operations");
|
|
62
|
+
var DAILY_ANCHOR_SEED = Buffer.from("daily_anchor");
|
|
63
|
+
var SOL_PSEUDO_MINT = new import_web3.PublicKey(new Uint8Array(32));
|
|
64
|
+
var ACCOUNT_DISCRIMINATOR = {
|
|
65
|
+
AgentIdentity: Buffer.from([11, 149, 31, 27, 186, 76, 241, 72]),
|
|
66
|
+
CompanyAccount: Buffer.from([37, 215, 171, 200, 8, 141, 69, 96]),
|
|
67
|
+
Deployment: Buffer.from([66, 90, 104, 89, 183, 130, 64, 178]),
|
|
68
|
+
DailyAnchorAccount: Buffer.from([218, 106, 107, 94, 194, 48, 111, 254])
|
|
69
|
+
};
|
|
70
|
+
var TREASURY_ACCOUNT_DISCRIMINATOR = {
|
|
71
|
+
TreasuryAccount: Buffer.from([204, 140, 18, 173, 90, 152, 134, 123]),
|
|
72
|
+
PolicyAccount: Buffer.from([218, 201, 183, 164, 156, 127, 81, 175]),
|
|
73
|
+
ProtocolFeeAccount: Buffer.from([5, 171, 24, 9, 150, 135, 135, 201]),
|
|
74
|
+
OperationsAccount: Buffer.from([185, 55, 148, 90, 151, 227, 104, 158])
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/pda.ts
|
|
78
|
+
var import_web32 = require("@solana/web3.js");
|
|
79
|
+
function u32LeBytes(value) {
|
|
80
|
+
if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
|
|
81
|
+
throw new RangeError(`u32 out of range: ${value}`);
|
|
82
|
+
}
|
|
83
|
+
const buf = Buffer.alloc(4);
|
|
84
|
+
buf.writeUInt32LE(value, 0);
|
|
85
|
+
return buf;
|
|
86
|
+
}
|
|
87
|
+
function deriveCompanyPda(owner, nonce, programId = REGISTRY_PROGRAM_ID) {
|
|
88
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
89
|
+
[COMPANY_SEED, owner.toBuffer(), u32LeBytes(nonce)],
|
|
90
|
+
programId
|
|
91
|
+
);
|
|
92
|
+
return { pda, bump };
|
|
93
|
+
}
|
|
94
|
+
function deriveAgentIdentityPda(agentPubkey, programId = REGISTRY_PROGRAM_ID) {
|
|
95
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
96
|
+
[AGENT_IDENTITY_SEED, agentPubkey.toBuffer()],
|
|
97
|
+
programId
|
|
98
|
+
);
|
|
99
|
+
return { pda, bump };
|
|
100
|
+
}
|
|
101
|
+
function deriveDeploymentPda(companyPda, deploymentIndex, programId = REGISTRY_PROGRAM_ID) {
|
|
102
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
103
|
+
[DEPLOYMENT_SEED, companyPda.toBuffer(), u32LeBytes(deploymentIndex)],
|
|
104
|
+
programId
|
|
105
|
+
);
|
|
106
|
+
return { pda, bump };
|
|
107
|
+
}
|
|
108
|
+
function deriveTreasuryPda(companyPda, programId = TREASURY_PROGRAM_ID) {
|
|
109
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
110
|
+
[TREASURY_SEED, companyPda.toBuffer()],
|
|
111
|
+
programId
|
|
112
|
+
);
|
|
113
|
+
return { pda, bump };
|
|
114
|
+
}
|
|
115
|
+
function derivePolicyPda(companyPda, programId = TREASURY_PROGRAM_ID) {
|
|
116
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
117
|
+
[POLICY_SEED, companyPda.toBuffer()],
|
|
118
|
+
programId
|
|
119
|
+
);
|
|
120
|
+
return { pda, bump };
|
|
121
|
+
}
|
|
122
|
+
function deriveProtocolFeePda(programId = TREASURY_PROGRAM_ID) {
|
|
123
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
124
|
+
[PROTOCOL_FEES_SEED],
|
|
125
|
+
programId
|
|
126
|
+
);
|
|
127
|
+
return { pda, bump };
|
|
128
|
+
}
|
|
129
|
+
function deriveOperationsPda(companyPda, kind, programId = TREASURY_PROGRAM_ID) {
|
|
130
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
131
|
+
[OPERATIONS_SEED, companyPda.toBuffer(), Buffer.from([kind])],
|
|
132
|
+
programId
|
|
133
|
+
);
|
|
134
|
+
return { pda, bump };
|
|
135
|
+
}
|
|
136
|
+
function i64LeBytes(value) {
|
|
137
|
+
const buf = Buffer.alloc(8);
|
|
138
|
+
buf.writeBigInt64LE(value, 0);
|
|
139
|
+
return buf;
|
|
140
|
+
}
|
|
141
|
+
function deriveDailyAnchorPda(deploymentPda, dayUnix, programId = REGISTRY_PROGRAM_ID) {
|
|
142
|
+
const [pda, bump] = import_web32.PublicKey.findProgramAddressSync(
|
|
143
|
+
[DAILY_ANCHOR_SEED, deploymentPda.toBuffer(), i64LeBytes(dayUnix)],
|
|
144
|
+
programId
|
|
145
|
+
);
|
|
146
|
+
return { pda, bump };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/instructions.ts
|
|
150
|
+
var INSTRUCTION_DISCRIMINATOR = {
|
|
151
|
+
createCompany: Buffer.from([36, 192, 217, 147, 233, 129, 198, 18]),
|
|
152
|
+
updateCompanyMetadata: Buffer.from([186, 229, 190, 16, 234, 141, 170, 89]),
|
|
153
|
+
updateCompanyStatus: Buffer.from([61, 6, 101, 120, 141, 13, 125, 75]),
|
|
154
|
+
registerAgentIdentity: Buffer.from([57, 31, 242, 205, 57, 129, 123, 35]),
|
|
155
|
+
updateAgentIdentityMetadata: Buffer.from([
|
|
156
|
+
250,
|
|
157
|
+
182,
|
|
158
|
+
24,
|
|
159
|
+
200,
|
|
160
|
+
201,
|
|
161
|
+
147,
|
|
162
|
+
60,
|
|
163
|
+
183
|
|
164
|
+
]),
|
|
165
|
+
createDeployment: Buffer.from([55, 207, 186, 101, 21, 218, 102, 171]),
|
|
166
|
+
updateDeploymentMetadata: Buffer.from([100, 135, 41, 32, 16, 41, 29, 76]),
|
|
167
|
+
updateDeploymentStatus: Buffer.from([225, 195, 150, 254, 178, 203, 53, 147]),
|
|
168
|
+
retireDeployment: Buffer.from([45, 188, 162, 197, 136, 180, 202, 153]),
|
|
169
|
+
setReceivingAddress: Buffer.from([70, 63, 44, 87, 16, 6, 156, 200]),
|
|
170
|
+
commitDailyAnchor: Buffer.from([18, 7, 3, 65, 58, 148, 164, 0])
|
|
171
|
+
};
|
|
172
|
+
function encodeString(s) {
|
|
173
|
+
const utf8 = Buffer.from(s, "utf8");
|
|
174
|
+
const len = Buffer.alloc(4);
|
|
175
|
+
len.writeUInt32LE(utf8.length, 0);
|
|
176
|
+
return Buffer.concat([len, utf8]);
|
|
177
|
+
}
|
|
178
|
+
function encodePubkey(pk) {
|
|
179
|
+
return Buffer.from(pk.toBytes());
|
|
180
|
+
}
|
|
181
|
+
function encodeU8(n) {
|
|
182
|
+
if (!Number.isInteger(n) || n < 0 || n > 255) {
|
|
183
|
+
throw new RangeError(`u8 out of range: ${n}`);
|
|
184
|
+
}
|
|
185
|
+
return Buffer.from([n]);
|
|
186
|
+
}
|
|
187
|
+
function encodeMetadataHash(hash) {
|
|
188
|
+
if (hash.length !== 32) {
|
|
189
|
+
throw new RangeError(`metadata_hash must be 32 bytes, got ${hash.length}`);
|
|
190
|
+
}
|
|
191
|
+
return Buffer.from(hash);
|
|
192
|
+
}
|
|
193
|
+
function encodeOptionU32(value) {
|
|
194
|
+
if (value === null || value === void 0) {
|
|
195
|
+
return Buffer.from([0]);
|
|
196
|
+
}
|
|
197
|
+
return Buffer.concat([Buffer.from([1]), u32LeBytes(value)]);
|
|
198
|
+
}
|
|
199
|
+
function buildCreateCompanyInstruction(params) {
|
|
200
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
201
|
+
const { pda: companyPda, bump } = deriveCompanyPda(
|
|
202
|
+
params.owner,
|
|
203
|
+
params.nonce,
|
|
204
|
+
programId
|
|
205
|
+
);
|
|
206
|
+
const { pda: treasuryPda } = deriveTreasuryPda(companyPda);
|
|
207
|
+
const { pda: policyPda } = derivePolicyPda(companyPda);
|
|
208
|
+
const data = Buffer.concat([
|
|
209
|
+
INSTRUCTION_DISCRIMINATOR.createCompany,
|
|
210
|
+
u32LeBytes(params.nonce),
|
|
211
|
+
encodeString(params.name),
|
|
212
|
+
encodeString(params.locale),
|
|
213
|
+
encodeString(params.metadataUri),
|
|
214
|
+
encodeMetadataHash(params.metadataHash)
|
|
215
|
+
]);
|
|
216
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
217
|
+
programId,
|
|
218
|
+
// Order MUST match registry/lib.rs `CreateCompany` accounts struct:
|
|
219
|
+
// company, owner, payer, treasury, policy, treasury_program, system_program.
|
|
220
|
+
keys: [
|
|
221
|
+
{ pubkey: companyPda, isSigner: false, isWritable: true },
|
|
222
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false },
|
|
223
|
+
{ pubkey: params.payer, isSigner: true, isWritable: true },
|
|
224
|
+
{ pubkey: treasuryPda, isSigner: false, isWritable: true },
|
|
225
|
+
{ pubkey: policyPda, isSigner: false, isWritable: true },
|
|
226
|
+
{ pubkey: TREASURY_PROGRAM_ID, isSigner: false, isWritable: false },
|
|
227
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
228
|
+
],
|
|
229
|
+
data
|
|
230
|
+
});
|
|
231
|
+
return { instruction, companyPda, treasuryPda, policyPda, bump };
|
|
232
|
+
}
|
|
233
|
+
function buildUpdateCompanyMetadataInstruction(params) {
|
|
234
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
235
|
+
const data = Buffer.concat([
|
|
236
|
+
INSTRUCTION_DISCRIMINATOR.updateCompanyMetadata,
|
|
237
|
+
encodeString(params.name),
|
|
238
|
+
encodeString(params.locale),
|
|
239
|
+
encodeString(params.metadataUri),
|
|
240
|
+
encodeMetadataHash(params.metadataHash)
|
|
241
|
+
]);
|
|
242
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
243
|
+
programId,
|
|
244
|
+
keys: [
|
|
245
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: true },
|
|
246
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
247
|
+
],
|
|
248
|
+
data
|
|
249
|
+
});
|
|
250
|
+
return { instruction };
|
|
251
|
+
}
|
|
252
|
+
function buildUpdateCompanyStatusInstruction(params) {
|
|
253
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
254
|
+
const data = Buffer.concat([
|
|
255
|
+
INSTRUCTION_DISCRIMINATOR.updateCompanyStatus,
|
|
256
|
+
encodeU8(params.newStatus)
|
|
257
|
+
]);
|
|
258
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
259
|
+
programId,
|
|
260
|
+
keys: [
|
|
261
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: true },
|
|
262
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
263
|
+
],
|
|
264
|
+
data
|
|
265
|
+
});
|
|
266
|
+
return { instruction };
|
|
267
|
+
}
|
|
268
|
+
function buildRegisterAgentIdentityInstruction(params) {
|
|
269
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
270
|
+
const { pda: identityPda, bump } = deriveAgentIdentityPda(
|
|
271
|
+
params.agentPubkey,
|
|
272
|
+
programId
|
|
273
|
+
);
|
|
274
|
+
const data = Buffer.concat([
|
|
275
|
+
INSTRUCTION_DISCRIMINATOR.registerAgentIdentity,
|
|
276
|
+
encodePubkey(params.agentPubkey),
|
|
277
|
+
encodeString(params.name),
|
|
278
|
+
encodeString(params.metadataUri),
|
|
279
|
+
encodeMetadataHash(params.metadataHash)
|
|
280
|
+
]);
|
|
281
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
282
|
+
programId,
|
|
283
|
+
keys: [
|
|
284
|
+
{ pubkey: identityPda, isSigner: false, isWritable: true },
|
|
285
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false },
|
|
286
|
+
{ pubkey: params.payer, isSigner: true, isWritable: true },
|
|
287
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
288
|
+
],
|
|
289
|
+
data
|
|
290
|
+
});
|
|
291
|
+
return { instruction, identityPda, bump };
|
|
292
|
+
}
|
|
293
|
+
function buildUpdateAgentIdentityMetadataInstruction(params) {
|
|
294
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
295
|
+
const data = Buffer.concat([
|
|
296
|
+
INSTRUCTION_DISCRIMINATOR.updateAgentIdentityMetadata,
|
|
297
|
+
encodeString(params.name),
|
|
298
|
+
encodeString(params.metadataUri),
|
|
299
|
+
encodeMetadataHash(params.metadataHash)
|
|
300
|
+
]);
|
|
301
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
302
|
+
programId,
|
|
303
|
+
keys: [
|
|
304
|
+
{ pubkey: params.identityPda, isSigner: false, isWritable: true },
|
|
305
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
306
|
+
],
|
|
307
|
+
data
|
|
308
|
+
});
|
|
309
|
+
return { instruction };
|
|
310
|
+
}
|
|
311
|
+
function buildCreateDeploymentInstruction(params) {
|
|
312
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
313
|
+
const { pda: deploymentPda, bump } = deriveDeploymentPda(
|
|
314
|
+
params.companyPda,
|
|
315
|
+
params.deploymentIndex,
|
|
316
|
+
programId
|
|
317
|
+
);
|
|
318
|
+
const data = Buffer.concat([
|
|
319
|
+
INSTRUCTION_DISCRIMINATOR.createDeployment,
|
|
320
|
+
u32LeBytes(params.deploymentIndex),
|
|
321
|
+
encodeString(params.role),
|
|
322
|
+
encodeOptionU32(params.parentDeploymentIndex),
|
|
323
|
+
encodePubkey(params.adapterId),
|
|
324
|
+
encodeString(params.metadataUri),
|
|
325
|
+
encodeMetadataHash(params.metadataHash)
|
|
326
|
+
]);
|
|
327
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
328
|
+
programId,
|
|
329
|
+
keys: [
|
|
330
|
+
// Order matches the on-chain `CreateDeployment` accounts struct.
|
|
331
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
332
|
+
{ pubkey: params.identityPda, isSigner: false, isWritable: false },
|
|
333
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false },
|
|
334
|
+
{ pubkey: deploymentPda, isSigner: false, isWritable: true },
|
|
335
|
+
{ pubkey: params.payer, isSigner: true, isWritable: true },
|
|
336
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
337
|
+
],
|
|
338
|
+
data
|
|
339
|
+
});
|
|
340
|
+
return { instruction, deploymentPda, bump };
|
|
341
|
+
}
|
|
342
|
+
function buildUpdateDeploymentMetadataInstruction(params) {
|
|
343
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
344
|
+
const data = Buffer.concat([
|
|
345
|
+
INSTRUCTION_DISCRIMINATOR.updateDeploymentMetadata,
|
|
346
|
+
encodeString(params.role),
|
|
347
|
+
encodeString(params.metadataUri),
|
|
348
|
+
encodeMetadataHash(params.metadataHash)
|
|
349
|
+
]);
|
|
350
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
351
|
+
programId,
|
|
352
|
+
keys: [
|
|
353
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: true },
|
|
354
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
355
|
+
],
|
|
356
|
+
data
|
|
357
|
+
});
|
|
358
|
+
return { instruction };
|
|
359
|
+
}
|
|
360
|
+
function buildUpdateDeploymentStatusInstruction(params) {
|
|
361
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
362
|
+
const data = Buffer.concat([
|
|
363
|
+
INSTRUCTION_DISCRIMINATOR.updateDeploymentStatus,
|
|
364
|
+
encodeU8(params.newStatus)
|
|
365
|
+
]);
|
|
366
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
367
|
+
programId,
|
|
368
|
+
keys: [
|
|
369
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: true },
|
|
370
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
371
|
+
],
|
|
372
|
+
data
|
|
373
|
+
});
|
|
374
|
+
return { instruction };
|
|
375
|
+
}
|
|
376
|
+
function buildRetireDeploymentInstruction(params) {
|
|
377
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
378
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
379
|
+
programId,
|
|
380
|
+
keys: [
|
|
381
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: true },
|
|
382
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
383
|
+
],
|
|
384
|
+
data: Buffer.from(INSTRUCTION_DISCRIMINATOR.retireDeployment)
|
|
385
|
+
});
|
|
386
|
+
return { instruction };
|
|
387
|
+
}
|
|
388
|
+
function buildSetReceivingAddressInstruction(params) {
|
|
389
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
390
|
+
const data = Buffer.concat([
|
|
391
|
+
INSTRUCTION_DISCRIMINATOR.setReceivingAddress,
|
|
392
|
+
encodePubkey(params.newReceivingAddress)
|
|
393
|
+
]);
|
|
394
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
395
|
+
programId,
|
|
396
|
+
keys: [
|
|
397
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: true },
|
|
398
|
+
{ pubkey: params.owner, isSigner: true, isWritable: false }
|
|
399
|
+
],
|
|
400
|
+
data
|
|
401
|
+
});
|
|
402
|
+
return { instruction };
|
|
403
|
+
}
|
|
404
|
+
var TREASURY_INSTRUCTION_DISCRIMINATOR = {
|
|
405
|
+
setPolicy: Buffer.from([40, 133, 12, 157, 235, 202, 2, 132]),
|
|
406
|
+
disburseDiscretionary: Buffer.from([102, 176, 14, 127, 210, 4, 96, 175]),
|
|
407
|
+
initProtocolFeeAccount: Buffer.from([214, 27, 184, 174, 155, 79, 141, 114]),
|
|
408
|
+
registerCompanyOperations: Buffer.from([212, 173, 142, 23, 28, 221, 55, 99]),
|
|
409
|
+
updateOperationsCapability: Buffer.from([21, 13, 197, 41, 92, 229, 142, 202]),
|
|
410
|
+
revokeOperations: Buffer.from([141, 196, 241, 103, 182, 146, 117, 183]),
|
|
411
|
+
closeOperations: Buffer.from([2, 52, 136, 225, 80, 230, 222, 120]),
|
|
412
|
+
disburseRoutine: Buffer.from([45, 152, 225, 130, 133, 73, 62, 202]),
|
|
413
|
+
disbursePrivileged: Buffer.from([173, 78, 248, 158, 76, 46, 88, 167])
|
|
414
|
+
};
|
|
415
|
+
function encodeU16(n) {
|
|
416
|
+
if (!Number.isInteger(n) || n < 0 || n > 65535) {
|
|
417
|
+
throw new RangeError(`u16 out of range: ${n}`);
|
|
418
|
+
}
|
|
419
|
+
const buf = Buffer.alloc(2);
|
|
420
|
+
buf.writeUInt16LE(n, 0);
|
|
421
|
+
return buf;
|
|
422
|
+
}
|
|
423
|
+
function encodeU64(n) {
|
|
424
|
+
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
425
|
+
throw new RangeError(`u64 out of range: ${n}`);
|
|
426
|
+
}
|
|
427
|
+
const buf = Buffer.alloc(8);
|
|
428
|
+
buf.writeBigUInt64LE(n, 0);
|
|
429
|
+
return buf;
|
|
430
|
+
}
|
|
431
|
+
function encodeAssetBudget(b) {
|
|
432
|
+
return Buffer.concat([encodePubkey(b.mint), encodeU64(b.amount)]);
|
|
433
|
+
}
|
|
434
|
+
function encodeVec(items, encodeItem) {
|
|
435
|
+
return Buffer.concat([u32LeBytes(items.length), ...items.map(encodeItem)]);
|
|
436
|
+
}
|
|
437
|
+
function encodeOption(value, encodeSome) {
|
|
438
|
+
if (value === null || value === void 0) return Buffer.from([0]);
|
|
439
|
+
return Buffer.concat([Buffer.from([1]), encodeSome(value)]);
|
|
440
|
+
}
|
|
441
|
+
function buildSetPolicyInstruction(params) {
|
|
442
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
443
|
+
function encodeSecondarySigner(v) {
|
|
444
|
+
if (v === void 0) return Buffer.from([0]);
|
|
445
|
+
if (v === null) return Buffer.from([1, 0]);
|
|
446
|
+
return Buffer.concat([Buffer.from([1, 1]), encodePubkey(v)]);
|
|
447
|
+
}
|
|
448
|
+
const data = Buffer.concat([
|
|
449
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.setPolicy,
|
|
450
|
+
// 1. routine_budget_per_month: Option<Vec<AssetBudget>>
|
|
451
|
+
encodeOption(
|
|
452
|
+
params.routineBudgetPerMonth,
|
|
453
|
+
(v) => encodeVec(v, encodeAssetBudget)
|
|
454
|
+
),
|
|
455
|
+
// 2. discretionary_budget_per_month: Option<Vec<AssetBudget>>
|
|
456
|
+
encodeOption(
|
|
457
|
+
params.discretionaryBudgetPerMonth,
|
|
458
|
+
(v) => encodeVec(v, encodeAssetBudget)
|
|
459
|
+
),
|
|
460
|
+
// 3. privileged_threshold_lamports: Option<u64>
|
|
461
|
+
encodeOption(params.privilegedThresholdLamports, encodeU64),
|
|
462
|
+
// 4. privileged_threshold_per_token: Option<Vec<AssetBudget>>
|
|
463
|
+
encodeOption(
|
|
464
|
+
params.privilegedThresholdPerToken,
|
|
465
|
+
(v) => encodeVec(v, encodeAssetBudget)
|
|
466
|
+
),
|
|
467
|
+
// 5. secondary_signer: Option<Option<Pubkey>>
|
|
468
|
+
encodeSecondarySigner(params.secondarySigner),
|
|
469
|
+
// 6. agent_operating_fee_bps: Option<u16>
|
|
470
|
+
encodeOption(params.agentOperatingFeeBps, encodeU16),
|
|
471
|
+
// 7. accepted_assets: Option<Vec<Pubkey>>
|
|
472
|
+
encodeOption(params.acceptedAssets, (v) => encodeVec(v, encodePubkey))
|
|
473
|
+
]);
|
|
474
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
475
|
+
programId,
|
|
476
|
+
// Order: company, controlling_authority, treasury, policy.
|
|
477
|
+
keys: [
|
|
478
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
479
|
+
{
|
|
480
|
+
pubkey: params.controllingAuthority,
|
|
481
|
+
isSigner: true,
|
|
482
|
+
isWritable: false
|
|
483
|
+
},
|
|
484
|
+
{ pubkey: params.treasuryPda, isSigner: false, isWritable: true },
|
|
485
|
+
{ pubkey: params.policyPda, isSigner: false, isWritable: true }
|
|
486
|
+
],
|
|
487
|
+
data
|
|
488
|
+
});
|
|
489
|
+
return { instruction };
|
|
490
|
+
}
|
|
491
|
+
function buildDisburseDiscretionaryInstruction(params) {
|
|
492
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
493
|
+
const mint = params.mint ?? SOL_PSEUDO_MINT;
|
|
494
|
+
const { pda: protocolFeePda } = deriveProtocolFeePda();
|
|
495
|
+
const data = Buffer.concat([
|
|
496
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.disburseDiscretionary,
|
|
497
|
+
encodePubkey(mint),
|
|
498
|
+
encodeU64(params.amountLamports)
|
|
499
|
+
]);
|
|
500
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
501
|
+
programId,
|
|
502
|
+
// Order: company, controlling_authority, treasury, policy,
|
|
503
|
+
// deployment, destination, protocol_fee_account.
|
|
504
|
+
keys: [
|
|
505
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
506
|
+
{
|
|
507
|
+
pubkey: params.controllingAuthority,
|
|
508
|
+
isSigner: true,
|
|
509
|
+
isWritable: false
|
|
510
|
+
},
|
|
511
|
+
{ pubkey: params.treasuryPda, isSigner: false, isWritable: true },
|
|
512
|
+
{ pubkey: params.policyPda, isSigner: false, isWritable: true },
|
|
513
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: false },
|
|
514
|
+
{ pubkey: params.destination, isSigner: false, isWritable: true },
|
|
515
|
+
{ pubkey: protocolFeePda, isSigner: false, isWritable: true }
|
|
516
|
+
],
|
|
517
|
+
data
|
|
518
|
+
});
|
|
519
|
+
return { instruction };
|
|
520
|
+
}
|
|
521
|
+
function encodeI64(n) {
|
|
522
|
+
const buf = Buffer.alloc(8);
|
|
523
|
+
buf.writeBigInt64LE(n, 0);
|
|
524
|
+
return buf;
|
|
525
|
+
}
|
|
526
|
+
function encodeBool(b) {
|
|
527
|
+
return Buffer.from([b ? 1 : 0]);
|
|
528
|
+
}
|
|
529
|
+
function encodeAction(disc) {
|
|
530
|
+
if (disc.length !== 8) {
|
|
531
|
+
throw new RangeError(`action_whitelist entry must be 8 bytes, got ${disc.length}`);
|
|
532
|
+
}
|
|
533
|
+
return Buffer.from(disc);
|
|
534
|
+
}
|
|
535
|
+
function buildInitProtocolFeeAccountInstruction(params) {
|
|
536
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
537
|
+
const programAccount = params.program ?? programId;
|
|
538
|
+
const { pda: protocolFeePda } = deriveProtocolFeePda(programId);
|
|
539
|
+
const data = Buffer.concat([
|
|
540
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.initProtocolFeeAccount,
|
|
541
|
+
encodePubkey(params.governance)
|
|
542
|
+
]);
|
|
543
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
544
|
+
programId,
|
|
545
|
+
keys: [
|
|
546
|
+
{ pubkey: protocolFeePda, isSigner: false, isWritable: true },
|
|
547
|
+
{ pubkey: params.authority, isSigner: true, isWritable: true },
|
|
548
|
+
{ pubkey: programAccount, isSigner: false, isWritable: false },
|
|
549
|
+
{ pubkey: params.programData, isSigner: false, isWritable: false },
|
|
550
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
551
|
+
],
|
|
552
|
+
data
|
|
553
|
+
});
|
|
554
|
+
return { instruction };
|
|
555
|
+
}
|
|
556
|
+
function buildRegisterCompanyOperationsInstruction(params) {
|
|
557
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
558
|
+
const { pda: operationsPda } = deriveOperationsPda(
|
|
559
|
+
params.companyPda,
|
|
560
|
+
params.kind,
|
|
561
|
+
programId
|
|
562
|
+
);
|
|
563
|
+
const data = Buffer.concat([
|
|
564
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.registerCompanyOperations,
|
|
565
|
+
// kind: u8 enum byte
|
|
566
|
+
Buffer.from([params.kind]),
|
|
567
|
+
encodePubkey(params.signer),
|
|
568
|
+
encodeVec(params.actionWhitelist, encodeAction),
|
|
569
|
+
u32LeBytes(params.rateLimitPerPeriod),
|
|
570
|
+
encodeI64(params.expiryUnix)
|
|
571
|
+
]);
|
|
572
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
573
|
+
programId,
|
|
574
|
+
keys: [
|
|
575
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
576
|
+
{
|
|
577
|
+
pubkey: params.controllingAuthority,
|
|
578
|
+
isSigner: true,
|
|
579
|
+
isWritable: false
|
|
580
|
+
},
|
|
581
|
+
{ pubkey: operationsPda, isSigner: false, isWritable: true },
|
|
582
|
+
{ pubkey: params.payer, isSigner: true, isWritable: true },
|
|
583
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
584
|
+
],
|
|
585
|
+
data
|
|
586
|
+
});
|
|
587
|
+
return { instruction };
|
|
588
|
+
}
|
|
589
|
+
function buildUpdateOperationsCapabilityInstruction(params) {
|
|
590
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
591
|
+
const { pda: operationsPda } = deriveOperationsPda(
|
|
592
|
+
params.companyPda,
|
|
593
|
+
params.kind,
|
|
594
|
+
programId
|
|
595
|
+
);
|
|
596
|
+
const argBody = Buffer.concat([
|
|
597
|
+
encodeOption(params.actionWhitelist, (v) => encodeVec(v, encodeAction)),
|
|
598
|
+
encodeOption(params.rateLimitPerPeriod, u32LeBytes),
|
|
599
|
+
encodeOption(params.expiryUnix, encodeI64)
|
|
600
|
+
]);
|
|
601
|
+
const data = Buffer.concat([
|
|
602
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.updateOperationsCapability,
|
|
603
|
+
argBody
|
|
604
|
+
]);
|
|
605
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
606
|
+
programId,
|
|
607
|
+
keys: [
|
|
608
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
609
|
+
{
|
|
610
|
+
pubkey: params.controllingAuthority,
|
|
611
|
+
isSigner: true,
|
|
612
|
+
isWritable: false
|
|
613
|
+
},
|
|
614
|
+
{ pubkey: operationsPda, isSigner: false, isWritable: true }
|
|
615
|
+
],
|
|
616
|
+
data
|
|
617
|
+
});
|
|
618
|
+
return { instruction };
|
|
619
|
+
}
|
|
620
|
+
function buildRevokeOperationsInstruction(params) {
|
|
621
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
622
|
+
const { pda: operationsPda } = deriveOperationsPda(
|
|
623
|
+
params.companyPda,
|
|
624
|
+
params.kind,
|
|
625
|
+
programId
|
|
626
|
+
);
|
|
627
|
+
const data = Buffer.from(TREASURY_INSTRUCTION_DISCRIMINATOR.revokeOperations);
|
|
628
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
629
|
+
programId,
|
|
630
|
+
keys: [
|
|
631
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
632
|
+
{
|
|
633
|
+
pubkey: params.controllingAuthority,
|
|
634
|
+
isSigner: true,
|
|
635
|
+
isWritable: false
|
|
636
|
+
},
|
|
637
|
+
{ pubkey: operationsPda, isSigner: false, isWritable: true }
|
|
638
|
+
],
|
|
639
|
+
data
|
|
640
|
+
});
|
|
641
|
+
return { instruction };
|
|
642
|
+
}
|
|
643
|
+
function buildCloseOperationsInstruction(params) {
|
|
644
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
645
|
+
const { pda: operationsPda } = deriveOperationsPda(
|
|
646
|
+
params.companyPda,
|
|
647
|
+
params.kind,
|
|
648
|
+
programId
|
|
649
|
+
);
|
|
650
|
+
const data = Buffer.from(TREASURY_INSTRUCTION_DISCRIMINATOR.closeOperations);
|
|
651
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
652
|
+
programId,
|
|
653
|
+
keys: [
|
|
654
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
655
|
+
{
|
|
656
|
+
pubkey: params.controllingAuthority,
|
|
657
|
+
isSigner: true,
|
|
658
|
+
isWritable: true
|
|
659
|
+
},
|
|
660
|
+
{ pubkey: operationsPda, isSigner: false, isWritable: true }
|
|
661
|
+
],
|
|
662
|
+
data
|
|
663
|
+
});
|
|
664
|
+
return { instruction };
|
|
665
|
+
}
|
|
666
|
+
function buildDisburseRoutineInstruction(params) {
|
|
667
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
668
|
+
const mint = params.mint ?? SOL_PSEUDO_MINT;
|
|
669
|
+
const { pda: protocolFeePda } = deriveProtocolFeePda(programId);
|
|
670
|
+
const data = Buffer.concat([
|
|
671
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.disburseRoutine,
|
|
672
|
+
encodePubkey(mint),
|
|
673
|
+
encodeU64(params.amountLamports)
|
|
674
|
+
]);
|
|
675
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
676
|
+
programId,
|
|
677
|
+
// Order: company, treasury, policy, operations, operations_signer,
|
|
678
|
+
// deployment, destination, protocol_fee_account.
|
|
679
|
+
keys: [
|
|
680
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
681
|
+
{ pubkey: params.treasuryPda, isSigner: false, isWritable: true },
|
|
682
|
+
{ pubkey: params.policyPda, isSigner: false, isWritable: true },
|
|
683
|
+
{ pubkey: params.operationsPda, isSigner: false, isWritable: true },
|
|
684
|
+
{ pubkey: params.operationsSigner, isSigner: true, isWritable: false },
|
|
685
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: false },
|
|
686
|
+
{ pubkey: params.destination, isSigner: false, isWritable: true },
|
|
687
|
+
{ pubkey: protocolFeePda, isSigner: false, isWritable: true }
|
|
688
|
+
],
|
|
689
|
+
data
|
|
690
|
+
});
|
|
691
|
+
return { instruction };
|
|
692
|
+
}
|
|
693
|
+
function buildDisbursePrivilegedInstruction(params) {
|
|
694
|
+
const programId = params.programId ?? TREASURY_PROGRAM_ID;
|
|
695
|
+
const mint = params.mint ?? SOL_PSEUDO_MINT;
|
|
696
|
+
const { pda: protocolFeePda } = deriveProtocolFeePda(programId);
|
|
697
|
+
const data = Buffer.concat([
|
|
698
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR.disbursePrivileged,
|
|
699
|
+
encodePubkey(mint),
|
|
700
|
+
encodeU64(params.amountLamports),
|
|
701
|
+
encodeBool(params.isAgentDestination)
|
|
702
|
+
]);
|
|
703
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
704
|
+
programId,
|
|
705
|
+
// Order: company, controlling_authority, secondary_signer, treasury,
|
|
706
|
+
// policy, deployment, destination, protocol_fee_account.
|
|
707
|
+
keys: [
|
|
708
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
709
|
+
{
|
|
710
|
+
pubkey: params.controllingAuthority,
|
|
711
|
+
isSigner: true,
|
|
712
|
+
isWritable: false
|
|
713
|
+
},
|
|
714
|
+
{ pubkey: params.secondarySigner, isSigner: true, isWritable: false },
|
|
715
|
+
{ pubkey: params.treasuryPda, isSigner: false, isWritable: true },
|
|
716
|
+
{ pubkey: params.policyPda, isSigner: false, isWritable: false },
|
|
717
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: false },
|
|
718
|
+
{ pubkey: params.destination, isSigner: false, isWritable: true },
|
|
719
|
+
{ pubkey: protocolFeePda, isSigner: false, isWritable: true }
|
|
720
|
+
],
|
|
721
|
+
data
|
|
722
|
+
});
|
|
723
|
+
return { instruction };
|
|
724
|
+
}
|
|
725
|
+
function buildCommitDailyAnchorInstruction(params) {
|
|
726
|
+
const programId = params.programId ?? REGISTRY_PROGRAM_ID;
|
|
727
|
+
if (params.merkleRoot.length !== 32) {
|
|
728
|
+
throw new RangeError(
|
|
729
|
+
`merkleRoot must be 32 bytes, got ${params.merkleRoot.length}`
|
|
730
|
+
);
|
|
731
|
+
}
|
|
732
|
+
const { pda: dailyAnchorPda } = deriveDailyAnchorPda(
|
|
733
|
+
params.deploymentPda,
|
|
734
|
+
params.dayUnix,
|
|
735
|
+
programId
|
|
736
|
+
);
|
|
737
|
+
const data = Buffer.concat([
|
|
738
|
+
INSTRUCTION_DISCRIMINATOR.commitDailyAnchor,
|
|
739
|
+
encodeI64(params.dayUnix),
|
|
740
|
+
Buffer.from(params.merkleRoot),
|
|
741
|
+
u32LeBytes(params.taskCount)
|
|
742
|
+
]);
|
|
743
|
+
const instruction = new import_web33.TransactionInstruction({
|
|
744
|
+
programId,
|
|
745
|
+
// Order: deployment, company, anchor_signer, operations, daily_anchor,
|
|
746
|
+
// payer, system_program.
|
|
747
|
+
keys: [
|
|
748
|
+
{ pubkey: params.deploymentPda, isSigner: false, isWritable: false },
|
|
749
|
+
{ pubkey: params.companyPda, isSigner: false, isWritable: false },
|
|
750
|
+
{ pubkey: params.anchorSigner, isSigner: true, isWritable: false },
|
|
751
|
+
{ pubkey: params.operationsPda, isSigner: false, isWritable: false },
|
|
752
|
+
{ pubkey: dailyAnchorPda, isSigner: false, isWritable: true },
|
|
753
|
+
{ pubkey: params.payer, isSigner: true, isWritable: true },
|
|
754
|
+
{ pubkey: import_web33.SystemProgram.programId, isSigner: false, isWritable: false }
|
|
755
|
+
],
|
|
756
|
+
data
|
|
757
|
+
});
|
|
758
|
+
return { instruction };
|
|
759
|
+
}
|
|
760
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
761
|
+
0 && (module.exports = {
|
|
762
|
+
INSTRUCTION_DISCRIMINATOR,
|
|
763
|
+
TREASURY_INSTRUCTION_DISCRIMINATOR,
|
|
764
|
+
buildCloseOperationsInstruction,
|
|
765
|
+
buildCommitDailyAnchorInstruction,
|
|
766
|
+
buildCreateCompanyInstruction,
|
|
767
|
+
buildCreateDeploymentInstruction,
|
|
768
|
+
buildDisburseDiscretionaryInstruction,
|
|
769
|
+
buildDisbursePrivilegedInstruction,
|
|
770
|
+
buildDisburseRoutineInstruction,
|
|
771
|
+
buildInitProtocolFeeAccountInstruction,
|
|
772
|
+
buildRegisterAgentIdentityInstruction,
|
|
773
|
+
buildRegisterCompanyOperationsInstruction,
|
|
774
|
+
buildRetireDeploymentInstruction,
|
|
775
|
+
buildRevokeOperationsInstruction,
|
|
776
|
+
buildSetPolicyInstruction,
|
|
777
|
+
buildSetReceivingAddressInstruction,
|
|
778
|
+
buildUpdateAgentIdentityMetadataInstruction,
|
|
779
|
+
buildUpdateCompanyMetadataInstruction,
|
|
780
|
+
buildUpdateCompanyStatusInstruction,
|
|
781
|
+
buildUpdateDeploymentMetadataInstruction,
|
|
782
|
+
buildUpdateDeploymentStatusInstruction,
|
|
783
|
+
buildUpdateOperationsCapabilityInstruction
|
|
784
|
+
});
|
|
785
|
+
//# sourceMappingURL=instructions.cjs.map
|