@thru/programs 0.3.18 → 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.
Files changed (96) hide show
  1. package/README.md +9 -0
  2. package/dist/abi-manager/index.cjs +153 -32
  3. package/dist/abi-manager/index.cjs.map +1 -1
  4. package/dist/abi-manager/index.d.cts +1 -1
  5. package/dist/abi-manager/index.d.ts +1 -1
  6. package/dist/abi-manager/index.js +3 -2
  7. package/dist/amm/index.cjs +81 -47
  8. package/dist/amm/index.cjs.map +1 -1
  9. package/dist/amm/index.js +2 -3
  10. package/dist/amm/index.js.map +1 -1
  11. package/dist/bootstrap-addresses/index.cjs +58 -20
  12. package/dist/bootstrap-addresses/index.cjs.map +1 -1
  13. package/dist/bootstrap-addresses/index.d.cts +38 -19
  14. package/dist/bootstrap-addresses/index.d.ts +38 -19
  15. package/dist/bootstrap-addresses/index.js +2 -3
  16. package/dist/{chunk-UPB725FV.js → chunk-2NNQJFKS.js} +5 -4
  17. package/dist/chunk-2NNQJFKS.js.map +1 -0
  18. package/dist/{chunk-FQDO6J6E.js → chunk-A2BWZE2D.js} +12 -10
  19. package/dist/chunk-A2BWZE2D.js.map +1 -0
  20. package/dist/{chunk-PRU4KGQO.js → chunk-JHINXDSG.js} +43 -4
  21. package/dist/chunk-JHINXDSG.js.map +1 -0
  22. package/dist/{chunk-Q6762F4G.js → chunk-QGOAPK5X.js} +3 -3
  23. package/dist/{chunk-Q6762F4G.js.map → chunk-QGOAPK5X.js.map} +1 -1
  24. package/dist/chunk-S3UTJHRO.js +77 -0
  25. package/dist/chunk-S3UTJHRO.js.map +1 -0
  26. package/dist/{chunk-NMPO53TW.js → chunk-ZOFTRAAH.js} +4 -4
  27. package/dist/{chunk-NMPO53TW.js.map → chunk-ZOFTRAAH.js.map} +1 -1
  28. package/dist/{chunk-IGZZOZ73.js → chunk-ZP7A3GHV.js} +3 -4
  29. package/dist/chunk-ZP7A3GHV.js.map +1 -0
  30. package/dist/clob/index.cjs +164 -130
  31. package/dist/clob/index.cjs.map +1 -1
  32. package/dist/clob/index.js +4 -5
  33. package/dist/clob/index.js.map +1 -1
  34. package/dist/deploy/index.cjs +240 -168
  35. package/dist/deploy/index.cjs.map +1 -1
  36. package/dist/deploy/index.d.cts +5 -0
  37. package/dist/deploy/index.d.ts +5 -0
  38. package/dist/deploy/index.js +66 -37
  39. package/dist/deploy/index.js.map +1 -1
  40. package/dist/manager/index.cjs +14 -1
  41. package/dist/manager/index.cjs.map +1 -1
  42. package/dist/manager/index.d.cts +5 -1
  43. package/dist/manager/index.d.ts +5 -1
  44. package/dist/manager/index.js +2 -3
  45. package/dist/multicall/index.cjs +57 -23
  46. package/dist/multicall/index.cjs.map +1 -1
  47. package/dist/multicall/index.js +3 -4
  48. package/dist/oracle/index.cjs +64 -30
  49. package/dist/oracle/index.cjs.map +1 -1
  50. package/dist/oracle/index.js +2 -3
  51. package/dist/oracle/index.js.map +1 -1
  52. package/dist/passkey-manager/index.cjs +52 -18
  53. package/dist/passkey-manager/index.cjs.map +1 -1
  54. package/dist/passkey-manager/index.js +2 -3
  55. package/dist/passkey-manager/index.js.map +1 -1
  56. package/dist/perp/index.cjs +12 -2
  57. package/dist/perp/index.cjs.map +1 -1
  58. package/dist/perp/index.js +2 -3
  59. package/dist/perp/index.js.map +1 -1
  60. package/dist/uploader/index.cjs +45 -7
  61. package/dist/uploader/index.cjs.map +1 -1
  62. package/dist/uploader/index.d.cts +2 -1
  63. package/dist/uploader/index.d.ts +2 -1
  64. package/dist/uploader/index.js +2 -2
  65. package/package.json +2 -2
  66. package/src/abi-manager/constants.ts +2 -1
  67. package/src/abi-manager/index.test.ts +2 -2
  68. package/src/bootstrap-addresses/index.test.ts +70 -18
  69. package/src/bootstrap-addresses/index.ts +56 -19
  70. package/src/deploy/accounts.ts +7 -3
  71. package/src/deploy/chain.ts +1 -1
  72. package/src/deploy/constants.ts +3 -4
  73. package/src/deploy/deploy.test.ts +11 -10
  74. package/src/deploy/inspection.ts +3 -2
  75. package/src/deploy/types.ts +5 -0
  76. package/src/deploy/uploader.ts +5 -4
  77. package/src/deploy/workflows.test.ts +74 -5
  78. package/src/deploy/workflows.ts +55 -17
  79. package/src/manager/constants.ts +14 -2
  80. package/src/manager/derivation.ts +3 -3
  81. package/src/manager/index.test.ts +3 -3
  82. package/src/manager/index.ts +3 -0
  83. package/src/manager/types.ts +1 -1
  84. package/src/multicall/index.test.ts +1 -1
  85. package/src/passkey-manager/validate.test.ts +1 -1
  86. package/src/uploader/constants.ts +5 -4
  87. package/src/uploader/index.test.ts +2 -2
  88. package/src/uploader/index.ts +1 -0
  89. package/dist/chunk-FHYZQ5R3.js +0 -37
  90. package/dist/chunk-FHYZQ5R3.js.map +0 -1
  91. package/dist/chunk-FQDO6J6E.js.map +0 -1
  92. package/dist/chunk-IGZZOZ73.js.map +0 -1
  93. package/dist/chunk-O2ONVSHW.js +0 -51
  94. package/dist/chunk-O2ONVSHW.js.map +0 -1
  95. package/dist/chunk-PRU4KGQO.js.map +0 -1
  96. package/dist/chunk-UPB725FV.js.map +0 -1
@@ -22,6 +22,9 @@ interface DeployProgressEvent {
22
22
  }
23
23
  interface DeploymentRequestBase {
24
24
  seed: string;
25
+ /** Parent Manager executable. Use root to upgrade the managed main Manager.
26
+ * Non-default parents support program binaries, not official ABI publication. */
27
+ managerProgramAddress?: string;
25
28
  signer: DeploymentSigner;
26
29
  client?: Thru;
27
30
  ephemeral?: boolean;
@@ -98,6 +101,8 @@ type UpgradeProgramABIResult = ProgramABIMutationResult;
98
101
  interface InspectProgramDeploymentRequest {
99
102
  client: Thru;
100
103
  seed: string;
104
+ /** Parent Manager executable used for derivation and ownership checks. */
105
+ managerProgramAddress?: string;
101
106
  ephemeral?: boolean;
102
107
  authorityAddress?: string;
103
108
  expectedProgramBytes?: Uint8Array;
@@ -22,6 +22,9 @@ interface DeployProgressEvent {
22
22
  }
23
23
  interface DeploymentRequestBase {
24
24
  seed: string;
25
+ /** Parent Manager executable. Use root to upgrade the managed main Manager.
26
+ * Non-default parents support program binaries, not official ABI publication. */
27
+ managerProgramAddress?: string;
25
28
  signer: DeploymentSigner;
26
29
  client?: Thru;
27
30
  ephemeral?: boolean;
@@ -98,6 +101,8 @@ type UpgradeProgramABIResult = ProgramABIMutationResult;
98
101
  interface InspectProgramDeploymentRequest {
99
102
  client: Thru;
100
103
  seed: string;
104
+ /** Parent Manager executable used for derivation and ownership checks. */
105
+ managerProgramAddress?: string;
101
106
  ephemeral?: boolean;
102
107
  authorityAddress?: string;
103
108
  expectedProgramBytes?: Uint8Array;
@@ -1,11 +1,10 @@
1
- import { deriveProgramABIAddresses, ABI_MANAGER_PROGRAM_ADDRESS, parseABIMetaAccount, parseABIAccount, createOfficialABIMetaInstruction, createOfficialABIInstruction, ABI_STATE_FINALIZED, ABI_STATE_OPEN, createUpgradeOfficialABIInstruction } from '../chunk-UPB725FV.js';
2
- import { deriveUploadAddresses, UPLOADER_DEFAULT_CHUNK_SIZE, UPLOADER_MIN_CHUNK_SIZE, UPLOADER_MAX_CHUNK_SIZE, createUploadBufferInstruction, UPLOADER_PROGRAM_ADDRESS, UPLOADER_STATE_FINALIZED, createWriteUploadInstruction, createFinalizeUploadInstruction, createDestroyUploadInstruction, UPLOADER_STATE_OPEN, parseUploaderProgramMeta } from '../chunk-FQDO6J6E.js';
1
+ import { deriveProgramABIAddresses, ABI_MANAGER_PROGRAM_ADDRESS, ABI_ACCOUNT_HEADER_SIZE, parseABIMetaAccount, parseABIAccount, createOfficialABIMetaInstruction, createOfficialABIInstruction, ABI_STATE_FINALIZED, ABI_STATE_OPEN, createUpgradeOfficialABIInstruction } from '../chunk-2NNQJFKS.js';
2
+ import { deriveUploadAddresses, UPLOADER_DEFAULT_CHUNK_SIZE, UPLOADER_MIN_CHUNK_SIZE, UPLOADER_MAX_CHUNK_SIZE, createUploadBufferInstruction, UPLOADER_PROGRAM_ADDRESS, UPLOADER_STATE_FINALIZED, createWriteUploadInstruction, createFinalizeUploadInstruction, createDestroyUploadInstruction, UPLOADER_STATE_OPEN, parseUploaderProgramMeta } from '../chunk-A2BWZE2D.js';
3
3
  import { bytesEqual, sha256, bytesToHex } from '../chunk-7FBCBZIY.js';
4
- import { GENESIS_MULTICALL_PROGRAM_ADDRESS, buildMulticallInstruction } from '../chunk-NMPO53TW.js';
5
- import '../chunk-O2ONVSHW.js';
6
- import { validateManagerProgramImage, parseManagerProgramMeta, createEphemeralProgramInstruction, createPermanentProgramInstruction, createUpgradeProgramInstruction } from '../chunk-IGZZOZ73.js';
7
- import { deriveManagedProgramAddresses, MANAGER_PROGRAM_ADDRESS, MANAGER_STATE_FINALIZED, MANAGER_STATE_OPEN } from '../chunk-FHYZQ5R3.js';
8
- import { normalizeSeed } from '../chunk-PRU4KGQO.js';
4
+ import { MULTICALL_PROGRAM_ADDRESS, buildMulticallInstruction } from '../chunk-ZOFTRAAH.js';
5
+ import '../chunk-S3UTJHRO.js';
6
+ import { validateManagerProgramImage, parseManagerProgramMeta, createEphemeralProgramInstruction, createPermanentProgramInstruction, createUpgradeProgramInstruction } from '../chunk-ZP7A3GHV.js';
7
+ import { deriveManagedProgramAddresses, MANAGER_PROGRAM_ADDRESS, normalizeSeed, MANAGER_STATE_FINALIZED, MANAGER_STATE_OPEN } from '../chunk-JHINXDSG.js';
9
8
  import { Pubkey, createThruClient, Signature, SubmissionStatus, ConsensusStatus } from '@thru/sdk';
10
9
  import { StateProofType } from '@thru/sdk/proto';
11
10
  import { resolveImports, OnchainFetcher, buildLayoutIrWithManifest } from '@thru/sdk/abi';
@@ -60,7 +59,7 @@ async function temporarySeed(seed, suffix) {
60
59
  }
61
60
 
62
61
  // src/deploy/constants.ts
63
- var DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS = GENESIS_MULTICALL_PROGRAM_ADDRESS;
62
+ var DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS = MULTICALL_PROGRAM_ADDRESS;
64
63
  var TRANSACTION_TIMEOUT_MS = 6e4;
65
64
 
66
65
  // src/deploy/accounts.ts
@@ -90,14 +89,14 @@ function assertOwner(account, owner, label) {
90
89
  );
91
90
  }
92
91
  }
93
- function assertManagedProgramAccount(account, label = "managed program account") {
94
- assertOwner(account, MANAGER_PROGRAM_ADDRESS, label);
92
+ function assertManagedProgramAccount(account, label = "managed program account", managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
93
+ assertOwner(account, managerProgramAddress, label);
95
94
  if (!account.meta?.flags.isProgram) {
96
95
  throw new DeployError("VERIFICATION_FAILED", `${label} is not executable`);
97
96
  }
98
97
  }
99
- function parseManagerMeta(account) {
100
- assertOwner(account, MANAGER_PROGRAM_ADDRESS, "program metadata account");
98
+ function parseManagerMeta(account, managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
99
+ assertOwner(account, managerProgramAddress, "program metadata account");
101
100
  try {
102
101
  const parsed = parseManagerProgramMeta(account);
103
102
  return {
@@ -244,7 +243,7 @@ async function submitTransaction(client, signer, operation, phase, transaction)
244
243
  header: {
245
244
  fee: 0n,
246
245
  computeUnits: transaction.computeUnits ?? 5e8,
247
- stateUnits: transaction.stateUnits ?? 5e3,
246
+ stateUnits: transaction.stateUnits ?? 1,
248
247
  memoryUnits: transaction.memoryUnits ?? 5e3,
249
248
  expiryAfter: transaction.expiryAfter ?? 1e4
250
249
  },
@@ -448,7 +447,8 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
448
447
  seed: upload.seed
449
448
  }),
450
449
  computeUnits: 5e4 + upload.bytes.length * 2,
451
- stateUnits: 1e4,
450
+ // One metadata account plus the meta-inclusive buffer footprint.
451
+ stateUnits: 1 + Math.ceil((64 + upload.bytes.length) / 4096),
452
452
  memoryUnits: 1e4,
453
453
  expiryAfter: 10
454
454
  }
@@ -543,7 +543,7 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
543
543
  offset
544
544
  }),
545
545
  computeUnits: 5e8,
546
- stateUnits: 5e3,
546
+ stateUnits: 1,
547
547
  memoryUnits: 5e3,
548
548
  expiryAfter: 1e4
549
549
  }
@@ -629,7 +629,7 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
629
629
  expectedHash: upload.hash
630
630
  }),
631
631
  computeUnits: 5e4 + upload.bytes.length * 200,
632
- stateUnits: 5e3,
632
+ stateUnits: 1,
633
633
  memoryUnits: 5e3,
634
634
  expiryAfter: 1e4
635
635
  }
@@ -700,7 +700,7 @@ async function cleanupUpload(client, signer, upload, onProgress) {
700
700
  metaAccount: upload.addresses.metaAccountBytes
701
701
  }),
702
702
  computeUnits: 5e4,
703
- stateUnits: 5e3,
703
+ stateUnits: 1,
704
704
  memoryUnits: 5e3,
705
705
  expiryAfter: 1e4
706
706
  }
@@ -952,6 +952,14 @@ function progress(context, phase, status, fields = {}) {
952
952
  });
953
953
  }
954
954
  async function createContext(operation, request, programAddressAssertion) {
955
+ let managerProgramAddress;
956
+ try {
957
+ const manager = Pubkey.from(request.managerProgramAddress ?? MANAGER_PROGRAM_ADDRESS);
958
+ if (manager.toBytes().every((byte) => byte === 0)) throw new Error("zero parent");
959
+ managerProgramAddress = manager.toThruFmt();
960
+ } catch (error) {
961
+ throw asDeployError(error, "INVALID_INPUT", "managerProgramAddress must be a nonzero Thru address");
962
+ }
955
963
  const client = request.client ?? createThruClient();
956
964
  const chunkSize = validateSeedAndChunkSize(request.seed, request.chunkSize);
957
965
  const signer = await resolveSigner(
@@ -960,7 +968,7 @@ async function createContext(operation, request, programAddressAssertion) {
960
968
  request.signer.privateKey
961
969
  );
962
970
  const ephemeral = request.ephemeral ?? false;
963
- const program = deriveManagedProgramAddresses(request.seed, ephemeral);
971
+ const program = deriveManagedProgramAddresses(request.seed, ephemeral, managerProgramAddress);
964
972
  if (programAddressAssertion) {
965
973
  let supplied;
966
974
  try {
@@ -988,6 +996,7 @@ async function createContext(operation, request, programAddressAssertion) {
988
996
  client,
989
997
  signer,
990
998
  seed: request.seed,
999
+ managerProgramAddress,
991
1000
  ephemeral,
992
1001
  chunkSize,
993
1002
  program,
@@ -995,6 +1004,11 @@ async function createContext(operation, request, programAddressAssertion) {
995
1004
  onProgress: request.onProgress
996
1005
  };
997
1006
  }
1007
+ function assertOfficialABIParent(context) {
1008
+ if (context.managerProgramAddress !== MANAGER_PROGRAM_ADDRESS) {
1009
+ throw new DeployError("INVALID_INPUT", "official ABI publication requires the canonical main Manager parent");
1010
+ }
1011
+ }
998
1012
  function addressDetails(context) {
999
1013
  return {
1000
1014
  programMetaAccountAddress: context.program.programMetaAccountAddress,
@@ -1039,7 +1053,7 @@ async function requireProgram(context) {
1039
1053
  }
1040
1054
  );
1041
1055
  }
1042
- const meta = parseManagerMeta(metaAccount);
1056
+ const meta = parseManagerMeta(metaAccount, context.managerProgramAddress);
1043
1057
  assertManagerOpen(meta);
1044
1058
  if (!bytesEqual(meta.authority, context.signer.publicKey)) {
1045
1059
  throw new DeployError(
@@ -1052,8 +1066,8 @@ async function requireProgram(context) {
1052
1066
  }
1053
1067
  );
1054
1068
  }
1055
- assertManagedProgramAccount(programAccount);
1056
- return { meta };
1069
+ assertManagedProgramAccount(programAccount, void 0, context.managerProgramAddress);
1070
+ return { meta, dataSize: requireAccountData(programAccount, "managed program account").length };
1057
1071
  }
1058
1072
  async function requireABI(context) {
1059
1073
  const [metaAccount, abiAccount] = await Promise.all([
@@ -1100,7 +1114,7 @@ async function verifyProgram(context, expectedBytes, expectedVersion) {
1100
1114
  "managed program readback is missing"
1101
1115
  );
1102
1116
  }
1103
- const meta = parseManagerMeta(metaAccount);
1117
+ const meta = parseManagerMeta(metaAccount, context.managerProgramAddress);
1104
1118
  assertManagerOpen(meta);
1105
1119
  assertPubkeyBytes(
1106
1120
  meta.authority,
@@ -1113,7 +1127,7 @@ async function verifyProgram(context, expectedBytes, expectedVersion) {
1113
1127
  `program version mismatch: expected ${expectedVersion}, got ${meta.version}`
1114
1128
  );
1115
1129
  }
1116
- assertManagedProgramAccount(programAccount);
1130
+ assertManagedProgramAccount(programAccount, void 0, context.managerProgramAddress);
1117
1131
  if (expectedBytes && !bytesEqual(
1118
1132
  requireAccountData(programAccount, "program account"),
1119
1133
  expectedBytes
@@ -1318,7 +1332,10 @@ async function deployProgram(request) {
1318
1332
  const abiBytes = request.abi === void 0 ? void 0 : normalizeBytes(request.abi, "abi");
1319
1333
  validateProgramImage(programBytes);
1320
1334
  const context = await createContext(operation, request);
1321
- if (abiBytes) await validateABI(abiBytes, context.client);
1335
+ if (abiBytes) {
1336
+ assertOfficialABIParent(context);
1337
+ await validateABI(abiBytes, context.client);
1338
+ }
1322
1339
  progress(context, "validation", "succeeded");
1323
1340
  progress(context, "preflight", "started");
1324
1341
  const absent = [
@@ -1378,7 +1395,8 @@ async function deployProgram(request) {
1378
1395
  let transaction;
1379
1396
  if (!abiBytes || !abiUpload) {
1380
1397
  transaction = {
1381
- program: MANAGER_PROGRAM_ADDRESS,
1398
+ program: context.managerProgramAddress,
1399
+ stateUnits: 1 + Math.ceil((64 + programBytes.length) / 4096),
1382
1400
  readWrite: [
1383
1401
  context.program.programMetaAccountAddress,
1384
1402
  context.program.programAccountAddress
@@ -1407,7 +1425,7 @@ async function deployProgram(request) {
1407
1425
  ]);
1408
1426
  transaction = {
1409
1427
  program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
1410
- stateUnits: 1e4,
1428
+ stateUnits: 2 + Math.ceil((64 + programBytes.length) / 4096) + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096),
1411
1429
  memoryUnits: 1e4,
1412
1430
  readWrite: [
1413
1431
  context.program.programMetaAccountAddress,
@@ -1416,14 +1434,14 @@ async function deployProgram(request) {
1416
1434
  context.abi.abiAccountAddress
1417
1435
  ],
1418
1436
  readOnly: [
1419
- MANAGER_PROGRAM_ADDRESS,
1437
+ context.managerProgramAddress,
1420
1438
  ABI_MANAGER_PROGRAM_ADDRESS,
1421
1439
  programUpload.result.bufferAccountAddress,
1422
1440
  abiUpload.result.bufferAccountAddress
1423
1441
  ],
1424
1442
  instructionData: (tx) => multicall(tx, [
1425
1443
  {
1426
- program: MANAGER_PROGRAM_ADDRESS,
1444
+ program: context.managerProgramAddress,
1427
1445
  instructionData: createProgramInstruction(
1428
1446
  context,
1429
1447
  programUpload,
@@ -1472,6 +1490,7 @@ async function deployProgramABI(request) {
1472
1490
  request,
1473
1491
  request.programAddress
1474
1492
  );
1493
+ assertOfficialABIParent(context);
1475
1494
  await validateABI(abiBytes, context.client);
1476
1495
  progress(context, "validation", "succeeded");
1477
1496
  progress(context, "preflight", "started");
@@ -1512,7 +1531,7 @@ async function deployProgramABI(request) {
1512
1531
  ]);
1513
1532
  const transaction = {
1514
1533
  program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
1515
- stateUnits: 1e4,
1534
+ stateUnits: 1 + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096),
1516
1535
  memoryUnits: 1e4,
1517
1536
  readWrite: [
1518
1537
  context.abi.abiMetaAccountAddress,
@@ -1568,7 +1587,10 @@ async function upgradeProgram(request) {
1568
1587
  request,
1569
1588
  request.programAddress
1570
1589
  );
1571
- if (abiBytes) await validateABI(abiBytes, context.client);
1590
+ if (abiBytes) {
1591
+ assertOfficialABIParent(context);
1592
+ await validateABI(abiBytes, context.client);
1593
+ }
1572
1594
  progress(context, "validation", "succeeded");
1573
1595
  progress(context, "preflight", "started");
1574
1596
  const programState = await requireProgram(context);
@@ -1608,7 +1630,10 @@ async function upgradeProgram(request) {
1608
1630
  }
1609
1631
  const transaction = abiBytes && abiUpload ? {
1610
1632
  program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
1611
- stateUnits: 1e4,
1633
+ stateUnits: Math.max(
1634
+ 0,
1635
+ Math.ceil((64 + programBytes.length) / 4096) - Math.ceil((64 + programState.dataSize) / 4096) + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096) - Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiState.abi.content.length) / 4096)
1636
+ ),
1612
1637
  memoryUnits: 1e4,
1613
1638
  readWrite: [
1614
1639
  context.program.programMetaAccountAddress,
@@ -1616,7 +1641,7 @@ async function upgradeProgram(request) {
1616
1641
  context.abi.abiAccountAddress
1617
1642
  ],
1618
1643
  readOnly: [
1619
- MANAGER_PROGRAM_ADDRESS,
1644
+ context.managerProgramAddress,
1620
1645
  ABI_MANAGER_PROGRAM_ADDRESS,
1621
1646
  context.abi.abiMetaAccountAddress,
1622
1647
  programUpload.result.bufferAccountAddress,
@@ -1624,7 +1649,7 @@ async function upgradeProgram(request) {
1624
1649
  ],
1625
1650
  instructionData: (tx) => multicall(tx, [
1626
1651
  {
1627
- program: MANAGER_PROGRAM_ADDRESS,
1652
+ program: context.managerProgramAddress,
1628
1653
  instructionData: upgradeProgramInstruction(
1629
1654
  context,
1630
1655
  programUpload,
@@ -1641,7 +1666,8 @@ async function upgradeProgram(request) {
1641
1666
  }
1642
1667
  ])
1643
1668
  } : {
1644
- program: MANAGER_PROGRAM_ADDRESS,
1669
+ program: context.managerProgramAddress,
1670
+ stateUnits: Math.max(0, Math.ceil((64 + programBytes.length) / 4096) - Math.ceil((64 + programState.dataSize) / 4096)),
1645
1671
  readWrite: [
1646
1672
  context.program.programMetaAccountAddress,
1647
1673
  context.program.programAccountAddress
@@ -1677,6 +1703,7 @@ async function upgradeProgramABI(request) {
1677
1703
  request,
1678
1704
  request.programAddress
1679
1705
  );
1706
+ assertOfficialABIParent(context);
1680
1707
  await validateABI(abiBytes, context.client);
1681
1708
  progress(context, "validation", "succeeded");
1682
1709
  progress(context, "preflight", "started");
@@ -1703,6 +1730,7 @@ async function upgradeProgramABI(request) {
1703
1730
  );
1704
1731
  const transaction = {
1705
1732
  program: ABI_MANAGER_PROGRAM_ADDRESS,
1733
+ stateUnits: Math.max(0, Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096) - Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiState.abi.content.length) / 4096)),
1706
1734
  readWrite: [context.abi.abiAccountAddress],
1707
1735
  readOnly: [
1708
1736
  context.abi.abiMetaAccountAddress,
@@ -1742,7 +1770,8 @@ async function inspectProgramDeployment(request) {
1742
1770
  const ephemeral = request.ephemeral ?? false;
1743
1771
  const programAddresses = deriveManagedProgramAddresses(
1744
1772
  request.seed,
1745
- ephemeral
1773
+ ephemeral,
1774
+ request.managerProgramAddress
1746
1775
  );
1747
1776
  const abiAddresses = deriveProgramABIAddresses(
1748
1777
  programAddresses.programAccountAddress,
@@ -1765,8 +1794,8 @@ async function inspectProgramDeployment(request) {
1765
1794
  if (!metadataAccount || !programAccount) {
1766
1795
  program = absentPair(!!metadataAccount, !!programAccount);
1767
1796
  } else {
1768
- const metadata = parseManagerMeta(metadataAccount);
1769
- assertManagedProgramAccount(programAccount);
1797
+ const metadata = parseManagerMeta(metadataAccount, request.managerProgramAddress);
1798
+ assertManagedProgramAccount(programAccount, void 0, request.managerProgramAddress);
1770
1799
  const authorityAddress = Pubkey.from(metadata.authority).toThruFmt();
1771
1800
  if (request.authorityAddress !== void 0) {
1772
1801
  let expectedAuthority;