@thru/programs 0.3.5 → 0.3.7

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 (68) hide show
  1. package/README.md +2 -3
  2. package/dist/amm/index.cjs +133 -32
  3. package/dist/amm/index.cjs.map +1 -1
  4. package/dist/amm/index.d.cts +1 -1
  5. package/dist/amm/index.d.ts +1 -1
  6. package/dist/amm/index.js +4 -1
  7. package/dist/amm/index.js.map +1 -1
  8. package/dist/bootstrap-addresses/index.cjs +118 -0
  9. package/dist/bootstrap-addresses/index.cjs.map +1 -0
  10. package/dist/bootstrap-addresses/index.d.cts +44 -0
  11. package/dist/bootstrap-addresses/index.d.ts +44 -0
  12. package/dist/bootstrap-addresses/index.js +5 -0
  13. package/dist/bootstrap-addresses/index.js.map +1 -0
  14. package/dist/chunk-7DHFYBRW.js +51 -0
  15. package/dist/chunk-7DHFYBRW.js.map +1 -0
  16. package/dist/{chunk-J7B7XYOI.js → chunk-CYG4PB65.js} +14 -41
  17. package/dist/chunk-CYG4PB65.js.map +1 -0
  18. package/dist/chunk-VNTPD4AR.js +37 -0
  19. package/dist/chunk-VNTPD4AR.js.map +1 -0
  20. package/dist/{chunk-OODN6LJA.js → chunk-ZHF2PH5H.js} +5 -36
  21. package/dist/chunk-ZHF2PH5H.js.map +1 -0
  22. package/dist/clob/index.cjs +225 -151
  23. package/dist/clob/index.cjs.map +1 -1
  24. package/dist/clob/index.d.cts +1 -1
  25. package/dist/clob/index.d.ts +1 -1
  26. package/dist/clob/index.js +5 -2
  27. package/dist/clob/index.js.map +1 -1
  28. package/dist/deploy/index.cjs +55 -38
  29. package/dist/deploy/index.cjs.map +1 -1
  30. package/dist/deploy/index.js +9 -6
  31. package/dist/deploy/index.js.map +1 -1
  32. package/dist/manager/index.js +2 -1
  33. package/dist/multicall/index.cjs +117 -40
  34. package/dist/multicall/index.cjs.map +1 -1
  35. package/dist/multicall/index.d.cts +5 -2
  36. package/dist/multicall/index.d.ts +5 -2
  37. package/dist/multicall/index.js +4 -1
  38. package/dist/oracle/index.cjs +122 -14
  39. package/dist/oracle/index.cjs.map +1 -1
  40. package/dist/oracle/index.d.cts +3 -1
  41. package/dist/oracle/index.d.ts +3 -1
  42. package/dist/oracle/index.js +7 -1
  43. package/dist/oracle/index.js.map +1 -1
  44. package/dist/passkey-manager/index.cjs +103 -1
  45. package/dist/passkey-manager/index.cjs.map +1 -1
  46. package/dist/passkey-manager/index.d.cts +1 -1
  47. package/dist/passkey-manager/index.d.ts +1 -1
  48. package/dist/passkey-manager/index.js +4 -1
  49. package/dist/passkey-manager/index.js.map +1 -1
  50. package/package.json +7 -2
  51. package/src/amm/index.test.ts +2 -12
  52. package/src/amm/index.ts +2 -2
  53. package/src/bootstrap-addresses/index.test.ts +59 -0
  54. package/src/bootstrap-addresses/index.ts +58 -0
  55. package/src/clob/index.test.ts +6 -0
  56. package/src/clob/index.ts +2 -2
  57. package/src/deploy/constants.ts +6 -1
  58. package/src/deploy/deploy.test.ts +3 -3
  59. package/src/deploy/workflows.test.ts +2 -2
  60. package/src/deploy/workflows.ts +4 -4
  61. package/src/multicall/index.test.ts +11 -2
  62. package/src/multicall/index.ts +12 -5
  63. package/src/oracle/index.ts +4 -0
  64. package/src/passkey-manager/constants.ts +2 -1
  65. package/src/passkey-manager/validate.test.ts +2 -2
  66. package/tsup.config.ts +1 -0
  67. package/dist/chunk-J7B7XYOI.js.map +0 -1
  68. package/dist/chunk-OODN6LJA.js.map +0 -1
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@thru/programs",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "type": "module",
5
5
  "exports": {
6
+ "./bootstrap-addresses": {
7
+ "types": "./dist/bootstrap-addresses/index.d.ts",
8
+ "import": "./dist/bootstrap-addresses/index.js",
9
+ "require": "./dist/bootstrap-addresses/index.cjs"
10
+ },
6
11
  "./token": {
7
12
  "types": "./dist/token/index.d.ts",
8
13
  "import": "./dist/token/index.js",
@@ -55,7 +60,7 @@
55
60
  }
56
61
  },
57
62
  "dependencies": {
58
- "@thru/sdk": "0.3.5"
63
+ "@thru/sdk": "0.3.7"
59
64
  },
60
65
  "devDependencies": {
61
66
  "@types/node": "^25.9.1",
@@ -1,6 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { Pubkey, deriveAddress, deriveProgramAddress } from '@thru/sdk';
3
3
  import type { Thru } from '@thru/sdk/client';
4
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
4
5
  import {
5
6
  AMM_PROGRAM_ADDRESS,
6
7
  AMM_INSTRUCTION_ADD_LIQUIDITY,
@@ -46,18 +47,7 @@ function writeU64(target: Uint8Array, offset: number, value: bigint): void {
46
47
 
47
48
  describe('amm helpers', () => {
48
49
  it('exports the standardized AMM program address', () => {
49
- const managerProgramAddress =
50
- 'taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQE';
51
- const metaAccount = deriveProgramAddress({
52
- programAddress: managerProgramAddress,
53
- seed: 'tn_amm_program',
54
- });
55
- expect(AMM_PROGRAM_ADDRESS).toBe(
56
- deriveProgramAddress({
57
- programAddress: managerProgramAddress,
58
- seed: metaAccount.bytes,
59
- }).address
60
- );
50
+ expect(AMM_PROGRAM_ADDRESS).toBe(BOOTSTRAP_PROGRAM_ADDRESSES.amm);
61
51
  });
62
52
 
63
53
  it('sorts mint addresses lexicographically', () => {
package/src/amm/index.ts CHANGED
@@ -2,6 +2,7 @@ import { Pubkey } from '@thru/sdk';
2
2
  import { encodeAddress } from '@thru/sdk/helpers';
3
3
  import type { Account } from '@thru/sdk';
4
4
  import type { Thru } from '@thru/sdk/client';
5
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
5
6
  import { compareBytes } from '../helpers/bytes';
6
7
  import {
7
8
  AmmAddLiquidityInstructionBuilder,
@@ -60,8 +61,7 @@ export const AMM_MINIMUM_LIQUIDITY = 1_000n;
60
61
  export const AMM_LP_DECIMALS = 6;
61
62
  export const AMM_LP_SCALE = 1_000_000n;
62
63
  export const AMM_POOL_METADATA_SIZE = 203;
63
- export const AMM_PROGRAM_ADDRESS =
64
- 'tajAMCTNZAhObSZDTl_biRg1nq8lIaLfl1AkALK0i5k5ZT';
64
+ export const AMM_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.amm;
65
65
 
66
66
  type AmmInstructionVariant = 'init_pool' | 'add_liquidity' | 'withdraw_liquidity' | 'swap';
67
67
 
@@ -0,0 +1,59 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { deriveManagedProgramAddresses } from '../manager';
4
+ import {
5
+ BOOTSTRAP_PROGRAM_ADDRESSES,
6
+ BOOTSTRAP_PROGRAM_SEEDS,
7
+ CREDITS_MINT_ADDRESS,
8
+ CREDITS_MINT_AUTHORITY_ADDRESS,
9
+ CREDITS_MINT_SEED_HEX,
10
+ } from './index';
11
+ import { createThruClient } from '@thru/sdk/client';
12
+ import { deriveMintAddress } from '../token';
13
+
14
+ const EXPECTED_ADDRESSES = {
15
+ noop: 'ta48QIbkvBw1wIeVkFpWwOq8nGdu0uMLvMMHCgIvYZo6qG',
16
+ faucet: 'taWpJIo6Ez5_3QdzfDiaj5Ppq5smU-pLftQD9Rkg8jrgdx',
17
+ name_service: 'taLhNfLFi8p6hqNg3JGcnNuuuhWM7rcLRGSF7qEZbBuWIo',
18
+ oracle: 'taQlmNDxbXJUeInC24XEAhKw66BpqtcAraLMeA4PgBwPTq',
19
+ multicall: 'tatPH9XJbriBMntQG_GU6r4YWZCcco1wEGgPw2gY3iFaj8',
20
+ abi_manager: 'tarnqUz4l-LKmRchPuw_YxLetE17HSq-KK8My4RdCYyzZE',
21
+ token: 'tazba_zSI-DTiFPvtpLNo_dDkuAWaY1sWX0VeHu_d44RH3',
22
+ amm: 'tapCRj8RCYWSaG_NQO4Oyl8VjGTKkVkTXJAN4ERrDMnz9C',
23
+ clob: 'ta82hwN3KNQJKXdTq7nX347ajiKDBg04cbcqsUas5NEY3e',
24
+ thru_registrar: 'taTbSR9Cb4xzC7lLtnEMwTFLuUkSEqwzH4FtWWvCInoflG',
25
+ wthru: 'taJ4Z3Mz4prd3yuLFmoyGbNHfWLlpfyzUmNn9k-9UemJIn',
26
+ passkey_manager: 'taPPDWMTxzvQyA1jOO4fdHU_dOhBpOlpzItJsvf2vaIi3w',
27
+ nft: 'taVRt8dNq3B1IGXWpYx17GWEfFcpmU8LF9uWy75XIIcA03',
28
+ block_producer: 'ta66mgj0z_nzqJZURi_1OFWMnkAZWK7h7fOy8ry2MCi4o8',
29
+ consensus_validator: 'tapezQswb_GBLkEPDzdn3F0YFntwbTk-8z7hwAY8slYHL_',
30
+ } as const;
31
+
32
+ describe('bootstrap-managed program addresses', () => {
33
+ it('matches the canonical deployed address registry', () => {
34
+ expect(BOOTSTRAP_PROGRAM_ADDRESSES).toEqual(EXPECTED_ADDRESSES);
35
+ });
36
+
37
+ it('derives every address from its permanent bootstrap seed', () => {
38
+ for (const name of Object.keys(BOOTSTRAP_PROGRAM_SEEDS) as Array<
39
+ keyof typeof BOOTSTRAP_PROGRAM_SEEDS
40
+ >) {
41
+ expect(
42
+ deriveManagedProgramAddresses(BOOTSTRAP_PROGRAM_SEEDS[name])
43
+ .programAccountAddress,
44
+ ).toBe(BOOTSTRAP_PROGRAM_ADDRESSES[name]);
45
+ }
46
+ });
47
+
48
+ it('derives the canonical CREDITS mint under managed Token', () => {
49
+ const client = createThruClient({ baseUrl: 'https://rpc.test' });
50
+ expect(
51
+ deriveMintAddress(
52
+ client,
53
+ CREDITS_MINT_AUTHORITY_ADDRESS,
54
+ CREDITS_MINT_SEED_HEX,
55
+ BOOTSTRAP_PROGRAM_ADDRESSES.token,
56
+ ).address,
57
+ ).toBe(CREDITS_MINT_ADDRESS);
58
+ });
59
+ });
@@ -0,0 +1,58 @@
1
+ import { deriveManagedProgramAddresses } from '../manager/derivation';
2
+
3
+ /** Permanent seeds used by programs/bootstrap. Changing a seed changes every
4
+ * managed program and ABI address derived from it. */
5
+ export const BOOTSTRAP_PROGRAM_SEEDS = Object.freeze({
6
+ noop: 'thru-noop',
7
+ faucet: 'thru-faucet',
8
+ name_service: 'thru-name_service',
9
+ oracle: 'thru-oracle',
10
+ multicall: 'thru-multicall',
11
+ abi_manager: 'thru-abi_manager',
12
+ token: 'thru-token',
13
+ amm: 'thru-amm',
14
+ clob: 'thru-clob',
15
+ thru_registrar: 'thru-thru_registrar',
16
+ wthru: 'thru-wthru',
17
+ passkey_manager: 'thru-passkey_manager',
18
+ nft: 'thru-nft',
19
+ block_producer: 'thru-block_producer',
20
+ consensus_validator: 'thru-consensus_validator',
21
+ } as const);
22
+
23
+ function managedProgramAddress(seed: string): string {
24
+ return deriveManagedProgramAddresses(seed).programAccountAddress;
25
+ }
26
+
27
+ /** Canonical application-facing addresses for bootstrap-managed programs. */
28
+ export const BOOTSTRAP_PROGRAM_ADDRESSES = Object.freeze({
29
+ noop: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.noop),
30
+ faucet: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.faucet),
31
+ name_service: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.name_service),
32
+ oracle: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.oracle),
33
+ multicall: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.multicall),
34
+ abi_manager: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.abi_manager),
35
+ token: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.token),
36
+ amm: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.amm),
37
+ clob: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.clob),
38
+ thru_registrar: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.thru_registrar),
39
+ wthru: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.wthru),
40
+ passkey_manager: managedProgramAddress(
41
+ BOOTSTRAP_PROGRAM_SEEDS.passkey_manager,
42
+ ),
43
+ nft: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.nft),
44
+ block_producer: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.block_producer),
45
+ consensus_validator: managedProgramAddress(
46
+ BOOTSTRAP_PROGRAM_SEEDS.consensus_validator,
47
+ ),
48
+ } as const);
49
+
50
+ /** Permanent CREDITS mint contract recreated by Token bootstrap setup. */
51
+ export const CREDITS_MINT_AUTHORITY_ADDRESS =
52
+ 'taDOTQyYDVPvYqIFKNBFbOIstmBXeY7Ne06JnUAjmHa4VI';
53
+ export const CREDITS_MINT_SEED_HEX =
54
+ '746872752d637265646974730000000000000000000000000000000000000000';
55
+ export const CREDITS_MINT_ADDRESS =
56
+ 'taYtAFmBxSxFlrTQ4Xhv4l6CoG0wH8wbSCMV80KnBGbal5';
57
+
58
+ export type BootstrapProgramName = keyof typeof BOOTSTRAP_PROGRAM_SEEDS;
@@ -1,6 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { encodeAddress } from '@thru/sdk/helpers';
3
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
3
4
  import {
5
+ CLOB_PROGRAM_ADDRESS,
4
6
  CLOB_INSTRUCTION_MARKET_RECORD,
5
7
  CLOB_NULL_INDEX,
6
8
  CLOB_INSTRUCTION_CREATE_ORDER_ENTRY,
@@ -66,6 +68,10 @@ function context(indexes: Record<string, number>) {
66
68
  }
67
69
 
68
70
  describe('clob helpers', () => {
71
+ it('uses the bootstrap-managed CLOB program address', () => {
72
+ expect(CLOB_PROGRAM_ADDRESS).toBe(BOOTSTRAP_PROGRAM_ADDRESSES.clob);
73
+ });
74
+
69
75
  it('validates market-record seat indices before ABI serialization', async () => {
70
76
  const accounts = Array.from({ length: 8 }, (_, index) => key(index + 1));
71
77
  const args = {
package/src/clob/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Pubkey, deriveProgramAddress } from '@thru/sdk';
2
2
  import { encodeAddress } from '@thru/sdk/helpers';
3
3
  import type { Account } from '@thru/sdk';
4
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
4
5
  import {
5
6
  ArenaHeader,
6
7
  CbookAccount,
@@ -157,8 +158,7 @@ export const CLOB_STATUS_FLAG_MASK =
157
158
  CLOB_STATUS_FLAG_WITHDRAWALS_FROZEN |
158
159
  CLOB_STATUS_FLAG_DEPOSITS_FROZEN;
159
160
 
160
- export const CLOB_PROGRAM_ADDRESS =
161
- 'tamjQOFxFORIZhqbJjN83oAkRmSbKhLmULpvSHblK4GGIg';
161
+ export const CLOB_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.clob;
162
162
 
163
163
  export const CLOB_ORDER_TYPE_GTC = 0;
164
164
  export const CLOB_ORDER_TYPE_MTL = 1;
@@ -1,3 +1,5 @@
1
+ import { GENESIS_MULTICALL_PROGRAM_ADDRESS } from "../multicall";
2
+
1
3
  export {
2
4
  MANAGER_META_SIZE,
3
5
  MANAGER_PROGRAM_ADDRESS,
@@ -11,7 +13,10 @@ export {
11
13
  ABI_STATE_FINALIZED,
12
14
  ABI_STATE_OPEN,
13
15
  } from "../abi-manager";
14
- export { MULTICALL_PROGRAM_ADDRESS } from "../multicall";
16
+ /** Genesis Multicall remains a deployment dependency because managed
17
+ * Multicall cannot be used to deploy itself. */
18
+ export const DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS =
19
+ GENESIS_MULTICALL_PROGRAM_ADDRESS;
15
20
  export {
16
21
  UPLOADER_DEFAULT_CHUNK_SIZE as DEFAULT_CHUNK_SIZE,
17
22
  UPLOADER_MAX_CHUNK_SIZE as MAX_CHUNK_SIZE,
@@ -13,7 +13,7 @@ import {
13
13
  import {
14
14
  ABI_MANAGER_PROGRAM_ADDRESS,
15
15
  MANAGER_PROGRAM_ADDRESS,
16
- MULTICALL_PROGRAM_ADDRESS,
16
+ DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
17
17
  UPLOADER_PROGRAM_ADDRESS,
18
18
  } from "./constants";
19
19
  import { DeployError } from "./errors";
@@ -82,7 +82,7 @@ describe("deployment address derivation", () => {
82
82
  it("uses canonical built-in addresses", () => {
83
83
  expect(UPLOADER_PROGRAM_ADDRESS).toBe(address(2));
84
84
  expect(MANAGER_PROGRAM_ADDRESS).toBe(address(4));
85
- expect(MULTICALL_PROGRAM_ADDRESS).toBe(address(9));
85
+ expect(DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS).toBe(address(9));
86
86
  expect(ABI_MANAGER_PROGRAM_ADDRESS).toBe(
87
87
  "taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACrG7",
88
88
  );
@@ -196,7 +196,7 @@ describe("deployment transaction composition", () => {
196
196
  let observed: number[] = [];
197
197
  await client.transactions.buildAndSign({
198
198
  feePayer: { publicKey, privateKey },
199
- program: MULTICALL_PROGRAM_ADDRESS,
199
+ program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
200
200
  header: { fee: 0n, nonce: 0n, startSlot: 1n, chainId: 1 },
201
201
  accounts: {
202
202
  readWrite: [high, low],
@@ -12,7 +12,7 @@ import { deriveManagedProgramAddresses } from "../manager";
12
12
  import {
13
13
  ABI_MANAGER_PROGRAM_ADDRESS,
14
14
  MANAGER_PROGRAM_ADDRESS,
15
- MULTICALL_PROGRAM_ADDRESS,
15
+ DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
16
16
  } from "./constants";
17
17
  import { DeployError } from "./errors";
18
18
  import type { DeploymentTransaction } from "./chain";
@@ -319,7 +319,7 @@ describe("deployment workflows", () => {
319
319
  });
320
320
 
321
321
  expect(mocks.submitTransaction).toHaveBeenCalledTimes(1);
322
- expect(harness.state.transaction?.program).toBe(MULTICALL_PROGRAM_ADDRESS);
322
+ expect(harness.state.transaction?.program).toBe(DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS);
323
323
  const calls = MulticallArgs.from_array(harness.state.encoded!)?.get_calls();
324
324
  expect(calls).toHaveLength(3);
325
325
  expect(calls?.map((call) => call.get_data()[0])).toEqual([0, 0, 4]);
@@ -39,8 +39,8 @@ import {
39
39
  } from "./chain";
40
40
  import {
41
41
  ABI_MANAGER_PROGRAM_ADDRESS,
42
+ DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
42
43
  MANAGER_PROGRAM_ADDRESS,
43
- MULTICALL_PROGRAM_ADDRESS,
44
44
  } from "./constants";
45
45
  import { DeployError, asDeployError } from "./errors";
46
46
  import type {
@@ -725,7 +725,7 @@ export async function deployProgram(
725
725
  ),
726
726
  ]);
727
727
  transaction = {
728
- program: MULTICALL_PROGRAM_ADDRESS,
728
+ program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
729
729
  stateUnits: 10_000,
730
730
  memoryUnits: 10_000,
731
731
  readWrite: [
@@ -838,7 +838,7 @@ export async function deployProgramABI(
838
838
  ),
839
839
  ]);
840
840
  const transaction: DeploymentTransaction = {
841
- program: MULTICALL_PROGRAM_ADDRESS,
841
+ program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
842
842
  stateUnits: 10_000,
843
843
  memoryUnits: 10_000,
844
844
  readWrite: [
@@ -946,7 +946,7 @@ export async function upgradeProgram(
946
946
  const transaction: DeploymentTransaction =
947
947
  abiBytes && abiUpload
948
948
  ? {
949
- program: MULTICALL_PROGRAM_ADDRESS,
949
+ program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
950
950
  stateUnits: 10_000,
951
951
  memoryUnits: 10_000,
952
952
  readWrite: [
@@ -1,5 +1,8 @@
1
1
  import { describe, expect, it } from 'vitest';
2
+ import { encodeAddress } from '@thru/sdk/helpers';
2
3
  import {
4
+ GENESIS_MULTICALL_PROGRAM_ADDRESS,
5
+ GENESIS_MULTICALL_PROGRAM_PUBKEY,
3
6
  MULTICALL_PROGRAM_ADDRESS,
4
7
  MULTICALL_PROGRAM_PUBKEY,
5
8
  InstructionDataBuilder,
@@ -17,9 +20,15 @@ function instructionData(programIdx: number, data: Uint8Array): number[] {
17
20
  describe('multicall helpers', () => {
18
21
  it('encodes calls with generated InstructionData views', () => {
19
22
  expect(MULTICALL_PROGRAM_ADDRESS).toBe(
20
- 'taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkJ'
23
+ 'tatPH9XJbriBMntQG_GU6r4YWZCcco1wEGgPw2gY3iFaj8'
24
+ );
25
+ expect(MULTICALL_PROGRAM_PUBKEY).toHaveLength(32);
26
+ expect(GENESIS_MULTICALL_PROGRAM_PUBKEY).toEqual(
27
+ new Uint8Array([...new Uint8Array(31), 0x09])
28
+ );
29
+ expect(GENESIS_MULTICALL_PROGRAM_ADDRESS).toBe(
30
+ encodeAddress(GENESIS_MULTICALL_PROGRAM_PUBKEY)
21
31
  );
22
- expect(MULTICALL_PROGRAM_PUBKEY[31]).toBe(9);
23
32
 
24
33
  const encoded = buildMulticallInstruction([
25
34
  { programIdx: 2, instructionData: new Uint8Array([0xaa]) },
@@ -1,4 +1,6 @@
1
- import { encodeAddress } from '@thru/sdk/helpers';
1
+ import { decodeAddress, encodeAddress } from '@thru/sdk/helpers';
2
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
3
+ import { systemProgramPubkey } from '../utils/helpers';
2
4
  import {
3
5
  InstructionData,
4
6
  InstructionDataBuilder,
@@ -23,11 +25,16 @@ export type MulticallCall = {
23
25
  instructionData: Uint8Array;
24
26
  };
25
27
 
26
- export const MULTICALL_PROGRAM_PUBKEY = new Uint8Array([
27
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
28
- ]);
28
+ /** Genesis Multicall remains available on networks that do not run bootstrap. */
29
+ export const GENESIS_MULTICALL_PROGRAM_PUBKEY = systemProgramPubkey(0x09);
30
+ export const GENESIS_MULTICALL_PROGRAM_ADDRESS = encodeAddress(
31
+ GENESIS_MULTICALL_PROGRAM_PUBKEY,
32
+ );
29
33
 
30
- export const MULTICALL_PROGRAM_ADDRESS = encodeAddress(MULTICALL_PROGRAM_PUBKEY);
34
+ export const MULTICALL_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.multicall;
35
+ export const MULTICALL_PROGRAM_PUBKEY = decodeAddress(
36
+ MULTICALL_PROGRAM_ADDRESS,
37
+ );
31
38
 
32
39
  function assertProgramIdx(programIdx: number): void {
33
40
  if (!Number.isInteger(programIdx) || programIdx < 0 || programIdx > 0xffff) {
@@ -1,3 +1,7 @@
1
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from "../bootstrap-addresses";
2
+
3
+ export const ORACLE_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.oracle;
4
+
1
5
  export { parseOracleFeedAccount } from "./accounts";
2
6
  export { deriveOracleFeedAddress, normalizeOracleFeedSeed } from "./derivation";
3
7
  export { oracleProgramErrorFromCode, OracleProgramError } from "./errors";
@@ -2,9 +2,10 @@ import {
2
2
  Authority,
3
3
  AuthorityRecord,
4
4
  } from './abi/thru/program/passkey_manager/types';
5
+ import { BOOTSTRAP_PROGRAM_ADDRESSES } from '../bootstrap-addresses';
5
6
 
6
7
  export const PASSKEY_MANAGER_PROGRAM_ADDRESS =
7
- 'tabsq39mzj3DZlutXOGG6VtfMj8fUvI0HIOXfZm7TLLY6N';
8
+ BOOTSTRAP_PROGRAM_ADDRESSES.passkey_manager;
8
9
 
9
10
  // Instruction discriminants
10
11
  export const INSTRUCTION_CREATE = 0x00;
@@ -221,9 +221,9 @@ describe('passkey manager validate helpers', () => {
221
221
 
222
222
  it('encodes multicall instructions with the known program address', () => {
223
223
  expect(MULTICALL_PROGRAM_ADDRESS).toBe(
224
- 'taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkJ'
224
+ 'tatPH9XJbriBMntQG_GU6r4YWZCcco1wEGgPw2gY3iFaj8'
225
225
  );
226
- expect(MULTICALL_PROGRAM_PUBKEY[31]).toBe(9);
226
+ expect(MULTICALL_PROGRAM_PUBKEY).toHaveLength(32);
227
227
 
228
228
  const encoded = buildMulticallInstruction([
229
229
  { programIdx: 2, instructionData: new Uint8Array([0xaa]) },
package/tsup.config.ts CHANGED
@@ -2,6 +2,7 @@ import { defineConfig } from "tsup";
2
2
 
3
3
  export default defineConfig({
4
4
  entry: {
5
+ "bootstrap-addresses/index": "src/bootstrap-addresses/index.ts",
5
6
  "token/index": "src/token/index.ts",
6
7
  "passkey-manager/index": "src/passkey-manager/index.ts",
7
8
  "multicall/index": "src/multicall/index.ts",