@aephia/atlas-kit 0.6.0-next.107 → 0.6.0-next.108

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 (33) hide show
  1. package/dist/cargo/actions/deposit.d.ts.map +1 -1
  2. package/dist/cargo/actions/deposit.js +22 -125
  3. package/dist/cargo/actions/deposit.js.map +1 -1
  4. package/dist/cargo/actions/wallet-context.d.ts +51 -2
  5. package/dist/cargo/actions/wallet-context.d.ts.map +1 -1
  6. package/dist/cargo/actions/wallet-context.js +125 -2
  7. package/dist/cargo/actions/wallet-context.js.map +1 -1
  8. package/dist/cargo/actions/wallet-token.d.ts +1 -6
  9. package/dist/cargo/actions/wallet-token.d.ts.map +1 -1
  10. package/dist/cargo/actions/wallet-token.js +0 -45
  11. package/dist/cargo/actions/wallet-token.js.map +1 -1
  12. package/dist/cargo/actions/withdrawal.d.ts.map +1 -1
  13. package/dist/cargo/actions/withdrawal.js +35 -162
  14. package/dist/cargo/actions/withdrawal.js.map +1 -1
  15. package/dist/fleets/actions/ship-import.d.ts.map +1 -1
  16. package/dist/fleets/actions/ship-import.js +31 -77
  17. package/dist/fleets/actions/ship-import.js.map +1 -1
  18. package/dist/internal/planning/original-token.d.ts +34 -0
  19. package/dist/internal/planning/original-token.d.ts.map +1 -0
  20. package/dist/internal/planning/original-token.js +98 -0
  21. package/dist/internal/planning/original-token.js.map +1 -0
  22. package/dist/internal/planning/ship-token.d.ts +1 -5
  23. package/dist/internal/planning/ship-token.d.ts.map +1 -1
  24. package/dist/internal/planning/ship-token.js +0 -36
  25. package/dist/internal/planning/ship-token.js.map +1 -1
  26. package/dist/internal/planning/starbase-player-owner.d.ts.map +1 -1
  27. package/dist/internal/planning/starbase-player-owner.js +5 -13
  28. package/dist/internal/planning/starbase-player-owner.js.map +1 -1
  29. package/dist/internal/planning/wallet-starbase.d.ts +34 -0
  30. package/dist/internal/planning/wallet-starbase.d.ts.map +1 -0
  31. package/dist/internal/planning/wallet-starbase.js +39 -0
  32. package/dist/internal/planning/wallet-starbase.js.map +1 -0
  33. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ import { AccountRole, getAddressDecoder, getAddressEncoder, getProgramDerivedAddress, } from '@solana/kit';
2
+ import { readContextRawAccounts } from '../../client/reconciliation.js';
3
+ import { SYSTEM_PROGRAM } from '../system-program.js';
4
+ import { RENT_ADDRESS, readRent } from './rent.js';
5
+ export const ORIGINAL_TOKEN_PROGRAM = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
6
+ export const ATA_PROGRAM = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
7
+ const TOKEN_2022_PROGRAM = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
8
+ /** What a wallet token transfer Plan rechecks and leaves to the chain. */
9
+ export const TOKEN_TRANSFER_DISCLOSURE = 'System identity, active Starbase generation and applicable CSS requirements are rechecked before signing; unrelated System combat, shield, health and hab activity is not equality-bound. Execution access checks remain chain-authoritative, not a client-side atomicity guarantee. Mint supply and authorities may change; initialized original Token mint layout and decimals are rechecked before signing.';
10
+ /** The canonical associated token account of `owner` for an original Token `mint`. */
11
+ export async function deriveAssociatedTokenAddress(owner, mint) {
12
+ const encoder = getAddressEncoder();
13
+ const [address] = await getProgramDerivedAddress({
14
+ programAddress: ATA_PROGRAM,
15
+ seeds: [
16
+ encoder.encode(owner),
17
+ encoder.encode(ORIGINAL_TOKEN_PROGRAM),
18
+ encoder.encode(mint),
19
+ ],
20
+ });
21
+ return address;
22
+ }
23
+ /** Whether a wallet is an original or Token-2022 multisig authority, which
24
+ * needs signer semantics outside the single-owner wallet planners. */
25
+ export function isTokenMultisig(account) {
26
+ return (account !== undefined &&
27
+ account.data.length === 355 &&
28
+ (account.owner === ORIGINAL_TOKEN_PROGRAM ||
29
+ account.owner === TOKEN_2022_PROGRAM));
30
+ }
31
+ /** Requires an initialized, unfrozen original Token account of `mint` owned
32
+ * by `owner` and returns its raw balance. A recorded delegate does not prevent
33
+ * the owner from transferring, so it is accepted. */
34
+ export function readTokenAccount(account, mint, owner, fail) {
35
+ const { address, data } = account;
36
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
37
+ if (account.executable ||
38
+ account.owner !== ORIGINAL_TOKEN_PROGRAM ||
39
+ data.length !== 165 ||
40
+ [72, 109, 129].some((offset) => view.getUint32(offset, true) > 1))
41
+ fail(`Account ${address} must be a well-formed original Token account of exactly 165 bytes; Token-2022 and multisig layouts are unsupported.`, address);
42
+ const decoder = getAddressDecoder();
43
+ if (view.getUint8(108) !== 1 ||
44
+ decoder.decode(data.subarray(0, 32)) !== mint ||
45
+ decoder.decode(data.subarray(32, 64)) !== owner)
46
+ fail(`Token account ${address} must be initialized, unfrozen and hold mint ${mint} under owner ${owner}; delegated spending is unsupported.`, address);
47
+ return view.getBigUint64(64, true);
48
+ }
49
+ /** Validates an explicit payer for idempotent canonical ATA creation and
50
+ * returns the creation instruction, its storage funding, and the payer, Rent
51
+ * and program observations. Reads Rent unless the caller already holds it. */
52
+ export async function resolveAssociatedTokenCreation(ctx, request, fail, observe) {
53
+ const addresses = [
54
+ request.payer,
55
+ ATA_PROGRAM,
56
+ SYSTEM_PROGRAM,
57
+ ORIGINAL_TOKEN_PROGRAM,
58
+ ...(request.rent === undefined ? [RENT_ADDRESS] : []),
59
+ ];
60
+ const accounts = (await readContextRawAccounts(ctx, addresses)).map((account, index) => account ??
61
+ fail(`ATA creation prerequisite ${addresses[index]} is missing. Create or fund it separately.`, addresses[index]));
62
+ const [payer, ...programs] = accounts.slice(0, 4);
63
+ const rent = request.rent ?? accounts[4];
64
+ if (programs.some((program) => !program.executable))
65
+ fail('ATA creation requires executable associated-token, System and original Token programs in this deployment.', ATA_PROGRAM);
66
+ // Original Token accounts occupy 165 bytes; the shared Rent reader includes
67
+ // the 128-byte account overhead and validates the full sysvar.
68
+ const storageFunding = readRent(rent)(165);
69
+ if (payer.owner !== SYSTEM_PROGRAM ||
70
+ payer.executable ||
71
+ payer.data.length !== 0 ||
72
+ payer.lamports < storageFunding)
73
+ fail(`ATA payer must be a System wallet with at least ${storageFunding} lamports for storage, in addition to transaction fees.`, request.payer);
74
+ const roles = [
75
+ 'ATA payer identity',
76
+ 'Associated-token program',
77
+ 'System program',
78
+ 'Token program',
79
+ 'Rent configuration',
80
+ ];
81
+ return {
82
+ instruction: {
83
+ programAddress: ATA_PROGRAM,
84
+ accounts: [
85
+ { address: request.payer, role: AccountRole.WRITABLE_SIGNER },
86
+ { address: request.address, role: AccountRole.WRITABLE },
87
+ { address: request.owner, role: AccountRole.READONLY },
88
+ { address: request.mint, role: AccountRole.READONLY },
89
+ { address: SYSTEM_PROGRAM, role: AccountRole.READONLY },
90
+ { address: ORIGINAL_TOKEN_PROGRAM, role: AccountRole.READONLY },
91
+ ],
92
+ data: Uint8Array.of(1),
93
+ },
94
+ preconditions: await Promise.all(accounts.map((account, index) => observe(account, roles[index]))),
95
+ storageFunding,
96
+ };
97
+ }
98
+ //# sourceMappingURL=original-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"original-token.js","sourceRoot":"","sources":["../../../src/internal/planning/original-token.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GAGzB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,sBAAsB,GACjC,6CAAwD,CAAC;AAC3D,MAAM,CAAC,MAAM,WAAW,GACtB,8CAAyD,CAAC;AAC5D,MAAM,kBAAkB,GACtB,6CAAwD,CAAC;AAK3D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,yBAAyB,GACpC,gZAAgZ,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,CAAC;SACvB;QACD,aAAa,EAAE,MAAM,OAAO,CAAC,GAAG,CAC9B,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC,CAClE;QACD,cAAc;KACf,CAAC;AACJ,CAAC"}
@@ -1,9 +1,5 @@
1
- import { type Address } from '@solana/kit';
1
+ import type { Address } from '@solana/kit';
2
2
  import type { RawAccount } from '../../client/contracts.js';
3
- export declare const ORIGINAL_TOKEN_PROGRAM: Address;
4
- export declare const ATA_PROGRAM: Address;
5
3
  export declare function failShipImport(message: string, address: Address): never;
6
- export declare function deriveShipTokenAddress(owner: Address, mint: Address): Promise<Address>;
7
4
  export declare function validateShipMint(account: RawAccount): void;
8
- export declare function validateShipToken(account: RawAccount, mint: Address, owner: Address): bigint;
9
5
  //# sourceMappingURL=ship-token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ship-token.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/ship-token.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,eAAO,MAAM,sBAAsB,EACgB,OAAO,CAAC;AAC3D,eAAO,MAAM,WAAW,EAC4B,OAAO,CAAC;AAC5D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAMvE;AACD,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAYlB;AAwBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAM1D;AACD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO,GACb,MAAM,CAcR"}
1
+ {"version":3,"file":"ship-token.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/ship-token.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAMvE;AACD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAM1D"}
@@ -1,46 +1,10 @@
1
1
  import { validateTokenMint } from './token-mint.js';
2
- import { getAddressDecoder, getAddressEncoder, getProgramDerivedAddress, } from '@solana/kit';
3
2
  import { SageSdkError } from '../../client/errors.js';
4
- export const ORIGINAL_TOKEN_PROGRAM = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
5
- export const ATA_PROGRAM = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
6
3
  export function failShipImport(message, address) {
7
4
  throw new SageSdkError('ACTION_PRECONDITION_FAILED', `${message} Refresh the relevant accounts and prepare a new ship import Plan.`, { address });
8
5
  }
9
- export async function deriveShipTokenAddress(owner, mint) {
10
- const encoder = getAddressEncoder();
11
- return (await getProgramDerivedAddress({
12
- programAddress: ATA_PROGRAM,
13
- seeds: [
14
- encoder.encode(owner),
15
- encoder.encode(ORIGINAL_TOKEN_PROGRAM),
16
- encoder.encode(mint),
17
- ],
18
- }))[0];
19
- }
20
- function bytes(account, length) {
21
- if (account.executable ||
22
- account.owner !== ORIGINAL_TOKEN_PROGRAM ||
23
- account.data.length !== length)
24
- failShipImport(`Account ${account.address} must be an original Token account with exactly ${length} bytes; Token-2022 is unsupported.`, account.address);
25
- return new DataView(account.data.buffer, account.data.byteOffset, account.data.byteLength);
26
- }
27
- function option(view, offset, account) {
28
- if (view.getUint32(offset, true) > 1)
29
- failShipImport('The Token account has malformed optional fields.', account.address);
30
- }
31
6
  export function validateShipMint(account) {
32
7
  if (validateTokenMint(account) !== 0)
33
8
  failShipImport('Ship import requires an initialized zero-decimal mint so each token is one ship.', account.address);
34
9
  }
35
- export function validateShipToken(account, mint, owner) {
36
- const view = bytes(account, 165);
37
- for (const offset of [72, 109, 129])
38
- option(view, offset, account);
39
- const decoder = getAddressDecoder();
40
- if (view.getUint8(108) !== 1 ||
41
- decoder.decode(account.data.subarray(0, 32)) !== mint ||
42
- decoder.decode(account.data.subarray(32, 64)) !== owner)
43
- failShipImport(`The token account must be initialized, unfrozen and hold ship mint ${mint} under authority ${owner}. Delegated token spending is unsupported.`, account.address);
44
- return view.getBigUint64(64, true);
45
- }
46
10
  //# sourceMappingURL=ship-token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ship-token.js","sourceRoot":"","sources":["../../../src/internal/planning/ship-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,GAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,MAAM,CAAC,MAAM,sBAAsB,GACjC,6CAAwD,CAAC;AAC3D,MAAM,CAAC,MAAM,WAAW,GACtB,8CAAyD,CAAC;AAC5D,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,OAAgB;IAC9D,MAAM,IAAI,YAAY,CACpB,4BAA4B,EAC5B,GAAG,OAAO,oEAAoE,EAC9E,EAAE,OAAO,EAAE,CACZ,CAAC;AACJ,CAAC;AACD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAc,EACd,IAAa;IAEb,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,OAAO,CACL,MAAM,wBAAwB,CAAC;QAC7B,cAAc,EAAE,WAAW;QAC3B,KAAK,EAAE;YACL,O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AAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,IACE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;QACxB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI;QACrD,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK;QAEvD,cAAc,CACZ,sEAAsE,IAAI,oBAAoB,KAAK,4CAA4C,EAC/I,OAAO,CAAC,OAAO,CAChB,CAAC;IACJ,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"ship-token.js","sourceRoot":"","sources":["../../../src/internal/planning/ship-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,OAAgB;IAC9D,MAAM,IAAI,YAAY,CACpB,4BAA4B,EAC5B,GAAG,OAAO,oEAAoE,EAC9E,EAAE,OAAO,EAAE,CACZ,CAAC;AACJ,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,OAAmB;IAClD,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC;QAClC,cAAc,CACZ,kFAAkF,EAClF,OAAO,CAAC,OAAO,CAChB,CAAC;AACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"starbase-player-owner.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/starbase-player-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAM3C,gEAAgE;AAChE,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACtD,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAChD;AAMD;;;mBAGmB;AACnB,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAwBlB"}
1
+ {"version":3,"file":"starbase-player-owner.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/starbase-player-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAM3C,gEAAgE;AAChE,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACtD,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAChD;AAED;;;mBAGmB;AACnB,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,sBAAsB,EAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,OAAO,CAAC,CAclB"}
@@ -1,25 +1,17 @@
1
1
  import { SageSdkError } from '../../client/errors.js';
2
2
  import { findCharacterPda } from '../c4/character.js';
3
3
  import { deriveStarbasePlayerAddress } from '../c4/starbase.js';
4
- function fail(message, address) {
5
- throw new SageSdkError('ACTION_PRECONDITION_FAILED', message, { address });
6
- }
7
4
  /** Requires a loaded Starbase Player to belong to the authorization Profile,
8
5
  * reference that Profile's canonical Character in the configured Game, and sit
9
6
  * at its canonical address; returns the Character. Fresh-state checks remain
10
7
  * the caller's. */
11
8
  export async function requireProfileStarbasePlayer(player, profile, game) {
12
- if (player.playerProfile.address !== profile) {
13
- fail(`Starbase Player ${player.address} does not belong to authorization Profile ${profile}. Refresh the Starbase Player for that Profile and retry.`, player.address);
14
- }
15
9
  const character = await findCharacterPda(profile, game);
16
- if (player.character.address !== character) {
17
- fail(`Starbase Player ${player.address} does not reference the canonical Character ${character} for authorization Profile ${profile}. Refresh the Starbase Player and retry.`, player.address);
18
- }
19
- if ((await deriveStarbasePlayerAddress(player.system.address, character)) !==
20
- player.address) {
21
- fail(`Starbase Player ${player.address} is not canonical for its Character and System. Refresh the Starbase Player through this context and retry.`, player.address);
22
- }
10
+ if (player.playerProfile.address !== profile ||
11
+ player.character.address !== character ||
12
+ (await deriveStarbasePlayerAddress(player.system.address, character)) !==
13
+ player.address)
14
+ throw new SageSdkError('ACTION_PRECONDITION_FAILED', `Starbase Player ${player.address} is not the canonical registration of authorization Profile ${profile} with its canonical Character ${character} in Star System ${player.system.address}. Load that Profile's Starbase Player through this context and retry.`, { address: player.address });
23
15
  return character;
24
16
  }
25
17
  //# sourceMappingURL=starbase-player-owner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"starbase-player-owner.js","sourceRoot":"","sources":["../../../src/internal/planning/starbase-player-owner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAUhE,SAAS,IAAI,CAAC,OAAe,EAAE,OAAgB;IAC7C,MAAM,IAAI,YAAY,CAAC,4BAA4B,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED;;;mBAGmB;AACnB,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAA8B,EAC9B,OAAgB,EAChB,IAAa;IAEb,IAAI,MAAM,CAAC,aAAa,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAC7C,IAAI,CACF,mBAAmB,MAAM,CAAC,OAAO,6CAA6C,OAAO,2DAA2D,EAChJ,MAAM,CAAC,OAAO,CACf,CAAC;IACJ,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,IAAI,MAAM,CAAC,SAAS,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3C,IAAI,CACF,mBAAmB,MAAM,CAAC,OAAO,+CAA+C,SAAS,8BAA8B,OAAO,0CAA0C,EACxK,MAAM,CAAC,OAAO,CACf,CAAC;IACJ,CAAC;IACD,IACE,CAAC,MAAM,2BAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACrE,MAAM,CAAC,OAAO,EACd,CAAC;QACD,IAAI,CACF,mBAAmB,MAAM,CAAC,OAAO,6GAA6G,EAC9I,MAAM,CAAC,OAAO,CACf,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"starbase-player-owner.js","sourceRoot":"","sources":["../../../src/internal/planning/starbase-player-owner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAUhE;;;mBAGmB;AACnB,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,MAA8B,EAC9B,OAAgB,EAChB,IAAa;IAEb,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACxD,IACE,MAAM,CAAC,aAAa,CAAC,OAAO,KAAK,OAAO;QACxC,MAAM,CAAC,SAAS,CAAC,OAAO,KAAK,SAAS;QACtC,CAAC,MAAM,2BAA2B,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YACnE,MAAM,CAAC,OAAO;QAEhB,MAAM,IAAI,YAAY,CACpB,4BAA4B,EAC5B,mBAAmB,MAAM,CAAC,OAAO,+DAA+D,OAAO,iCAAiC,SAAS,mBAAmB,MAAM,CAAC,MAAM,CAAC,OAAO,uEAAuE,EAChQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAC5B,CAAC;IACJ,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { Address } from '@solana/kit';
2
+ import type { RawAccount } from '../../client/contracts.js';
3
+ /** Rejects with the calling planner's wording and remedy. */
4
+ type Fail = (message: string, address: Address) => never;
5
+ /** Requires the fresh Profile, Character, Starbase Player and System of a
6
+ * wallet transfer to be decodable account state of the configured Game and
7
+ * authorization Profile, and the System to be canonical with an active
8
+ * Starbase (a Central Space Station when `requireCss`). Returns the decoded
9
+ * Profile and Starbase Player and the matching System guard. */
10
+ export declare function validateWalletStarbase(accounts: {
11
+ readonly profile: RawAccount;
12
+ readonly character: RawAccount;
13
+ readonly player: RawAccount;
14
+ readonly system: RawAccount;
15
+ }, facts: {
16
+ readonly game: Address;
17
+ readonly profile: Address;
18
+ readonly character: Address;
19
+ readonly system: Address;
20
+ readonly requireCss: boolean;
21
+ }, fail: Fail): Promise<{
22
+ playerData: Readonly<import("../c4/starbase.js").StarbasePlayerAccountData>;
23
+ profileData: Readonly<import("../c4/identity.js").ProfileAccountData>;
24
+ systemGuard: {
25
+ describes: string;
26
+ requireCss?: true;
27
+ kind: "starbase-system";
28
+ address: import("../../client/contracts.js").Address;
29
+ game: Address;
30
+ starbaseSequenceId: bigint;
31
+ };
32
+ }>;
33
+ export {};
34
+ //# sourceMappingURL=wallet-starbase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-starbase.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/wallet-starbase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAU5D,6DAA6D;AAC7D,KAAK,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,KAAK,CAAC;AAEzD;;;;gEAIgE;AAChE,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE;IACR,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,EACD,KAAK,EAAE;IACL,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;CAC9B,EACD,IAAI,EAAE,IAAI;;;;;;;;;;;GAoCX"}
@@ -0,0 +1,39 @@
1
+ import { characterAccountDefinition } from '../c4/character.js';
2
+ import { profileAccountDefinition } from '../c4/identity.js';
3
+ import { starbasePlayerAccountDefinition } from '../c4/starbase.js';
4
+ import { deriveStarSystemAddress, starSystemAccountDefinition, } from '../c4/world.js';
5
+ import { validateStarbaseSystem } from './starbase-system.js';
6
+ /** Requires the fresh Profile, Character, Starbase Player and System of a
7
+ * wallet transfer to be decodable account state of the configured Game and
8
+ * authorization Profile, and the System to be canonical with an active
9
+ * Starbase (a Central Space Station when `requireCss`). Returns the decoded
10
+ * Profile and Starbase Player and the matching System guard. */
11
+ export async function validateWalletStarbase(accounts, facts, fail) {
12
+ for (const account of Object.values(accounts))
13
+ if (account.executable)
14
+ fail('A gameplay prerequisite is executable rather than account state.', account.address);
15
+ const profileData = profileAccountDefinition.decode(accounts.profile);
16
+ const characterData = characterAccountDefinition.decode(accounts.character);
17
+ const playerData = starbasePlayerAccountDefinition.decode(accounts.player);
18
+ const systemData = starSystemAccountDefinition.decode(accounts.system);
19
+ if (characterData.game !== facts.game ||
20
+ characterData.playerProfile !== facts.profile ||
21
+ playerData.playerProfile !== facts.profile ||
22
+ playerData.character !== facts.character ||
23
+ playerData.system !== facts.system ||
24
+ systemData.game !== facts.game ||
25
+ (await deriveStarSystemAddress(facts.game, systemData.systemId)) !==
26
+ facts.system)
27
+ fail('Fresh Character, Starbase Player and System must belong to the configured Game and authorized Profile.', accounts.player.address);
28
+ const systemGuard = {
29
+ kind: 'starbase-system',
30
+ address: accounts.system.address,
31
+ game: facts.game,
32
+ starbaseSequenceId: systemData.sequenceId,
33
+ ...(facts.requireCss ? { requireCss: true } : {}),
34
+ describes: `The canonical Star System retains its active Starbase and generation${facts.requireCss ? ' as a Central Space Station' : ''}; unrelated shared activity may change.`,
35
+ };
36
+ await validateStarbaseSystem(accounts.system, systemGuard);
37
+ return { playerData, profileData, systemGuard };
38
+ }
39
+ //# sourceMappingURL=wallet-starbase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-starbase.js","sourceRoot":"","sources":["../../../src/internal/planning/wallet-starbase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA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,IAAI;QAChB,kBAAkB,EAAE,UAAU,CAAC,UAAU;QACzC,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1D,SAAS,EAAE,uEAAuE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,yCAAyC;KACjL,CAAC;IACF,MAAM,sBAAsB,CAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAClD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aephia/atlas-kit",
3
- "version": "0.6.0-next.107",
3
+ "version": "0.6.0-next.108",
4
4
  "description": "Community-maintained non-custodial TypeScript SDK for Star Atlas SAGE C4.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Aephia contributors",