@aephia/atlas-kit 0.6.0-next.132 → 0.6.0-next.134
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/dist/cargo/actions/deposit.d.ts +3 -0
- package/dist/cargo/actions/deposit.d.ts.map +1 -1
- package/dist/cargo/actions/deposit.js +39 -14
- package/dist/cargo/actions/deposit.js.map +1 -1
- package/dist/cargo/actions/index.d.ts +11 -5
- package/dist/cargo/actions/index.d.ts.map +1 -1
- package/dist/cargo/actions/index.js +68 -14
- package/dist/cargo/actions/index.js.map +1 -1
- package/dist/fleets/actions/add-ship.d.ts +12 -4
- package/dist/fleets/actions/add-ship.d.ts.map +1 -1
- package/dist/fleets/actions/add-ship.js +15 -7
- package/dist/fleets/actions/add-ship.js.map +1 -1
- package/dist/identity/actions/research-unlock.d.ts +11 -7
- package/dist/identity/actions/research-unlock.d.ts.map +1 -1
- package/dist/identity/actions/research-unlock.js +11 -7
- package/dist/identity/actions/research-unlock.js.map +1 -1
- package/dist/internal/c4/cargo-instructions.d.ts +24 -0
- package/dist/internal/c4/cargo-instructions.d.ts.map +1 -0
- package/dist/internal/c4/cargo-instructions.js +30 -0
- package/dist/internal/c4/cargo-instructions.js.map +1 -0
- package/dist/internal/c4/discriminators.d.ts +2 -0
- package/dist/internal/c4/discriminators.d.ts.map +1 -1
- package/dist/internal/c4/discriminators.js +5 -1
- package/dist/internal/c4/discriminators.js.map +1 -1
- package/dist/internal/c4/fleet-ship-assembly.d.ts +19 -3
- package/dist/internal/c4/fleet-ship-assembly.d.ts.map +1 -1
- package/dist/internal/c4/fleet-ship-assembly.js +57 -7
- package/dist/internal/c4/fleet-ship-assembly.js.map +1 -1
- package/dist/internal/planning/cargo-storage.d.ts +71 -0
- package/dist/internal/planning/cargo-storage.d.ts.map +1 -0
- package/dist/internal/planning/cargo-storage.js +274 -0
- package/dist/internal/planning/cargo-storage.js.map +1 -0
- package/dist/internal/planning/fleet-ship-assembly.d.ts.map +1 -1
- package/dist/internal/planning/fleet-ship-assembly.js +58 -29
- package/dist/internal/planning/fleet-ship-assembly.js.map +1 -1
- package/dist/internal/planning/own-starbase-facts.d.ts +7 -3
- package/dist/internal/planning/own-starbase-facts.d.ts.map +1 -1
- package/dist/internal/planning/own-starbase-facts.js +8 -5
- package/dist/internal/planning/own-starbase-facts.js.map +1 -1
- package/dist/internal/planning/plan-guards.d.ts.map +1 -1
- package/dist/internal/planning/plan-guards.js +2 -0
- package/dist/internal/planning/plan-guards.js.map +1 -1
- package/dist/internal/planning/profile-storage-funding-guard.d.ts +21 -0
- package/dist/internal/planning/profile-storage-funding-guard.d.ts.map +1 -0
- package/dist/internal/planning/profile-storage-funding-guard.js +98 -0
- package/dist/internal/planning/profile-storage-funding-guard.js.map +1 -0
- package/dist/internal/planning/profile-storage-funding.d.ts +46 -0
- package/dist/internal/planning/profile-storage-funding.d.ts.map +1 -0
- package/dist/internal/planning/profile-storage-funding.js +62 -0
- package/dist/internal/planning/profile-storage-funding.js.map +1 -0
- package/dist/internal/planning/research-unlock.d.ts.map +1 -1
- package/dist/internal/planning/research-unlock.js +40 -16
- package/dist/internal/planning/research-unlock.js.map +1 -1
- package/dist/planning/execution.d.ts.map +1 -1
- package/dist/planning/execution.js +58 -6
- package/dist/planning/execution.js.map +1 -1
- package/dist/planning/index.d.ts +22 -1
- package/dist/planning/index.d.ts.map +1 -1
- package/dist/planning/index.js +2 -2
- package/dist/planning/index.js.map +1 -1
- package/dist/planning/plan-construction.js +1 -1
- package/dist/planning/plan-validation.d.ts.map +1 -1
- package/dist/planning/plan-validation.js +4 -0
- package/dist/planning/plan-validation.js.map +1 -1
- package/dist/registry/cargo.d.ts +2 -2
- package/dist/registry/cargo.d.ts.map +1 -1
- package/dist/registry/cargo.js +1 -2
- package/dist/registry/cargo.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { getAddressDecoder } from '@solana/kit';
|
|
2
|
+
import { SageSdkError } from '../../client/errors.js';
|
|
3
|
+
import { decodeDepositCargoData, decodeStarbaseTransferData, decodeWithinFleetTransferData, } from '../c4/cargo-instructions.js';
|
|
4
|
+
import { fleetAccountDefinition } from '../c4/fleet.js';
|
|
5
|
+
import { starbasePlayerAccountDefinition } from '../c4/starbase.js';
|
|
6
|
+
import { CARGO_LINE_BYTES, cargoStorageInstruction, } from './profile-storage-funding-guard.js';
|
|
7
|
+
import { checkProfileStorageFunding, profileStorageFundingGuard, } from './profile-storage-funding.js';
|
|
8
|
+
import { RENT_ADDRESS, readRent } from './rent.js';
|
|
9
|
+
const NONE = new Map();
|
|
10
|
+
function fail(address, message) {
|
|
11
|
+
throw new SageSdkError('ACTION_PRECONDITION_FAILED', message, { address });
|
|
12
|
+
}
|
|
13
|
+
function totals(entries) {
|
|
14
|
+
const sums = new Map();
|
|
15
|
+
for (const [cargoId, amount] of entries)
|
|
16
|
+
if (amount !== undefined && amount > 0n)
|
|
17
|
+
sums.set(cargoId, (sums.get(cargoId) ?? 0n) + amount);
|
|
18
|
+
return sums;
|
|
19
|
+
}
|
|
20
|
+
function present(accounts, address) {
|
|
21
|
+
const raw = accounts.get(address);
|
|
22
|
+
if (!raw || raw.executable)
|
|
23
|
+
fail(address, `Account ${address} is missing or executable, so the cargo action's storage funding cannot be checked. Refresh it and replan the cargo action.`);
|
|
24
|
+
return raw;
|
|
25
|
+
}
|
|
26
|
+
/** Fresh accounts a cargo instruction's storage reads, besides the Profile,
|
|
27
|
+
* Rent sysvar and Game. */
|
|
28
|
+
export function cargoStorageAccounts(kind, instruction) {
|
|
29
|
+
const at = (index) => instruction.accounts[index].address;
|
|
30
|
+
if (kind === 'deposit')
|
|
31
|
+
return [at(5), at(10)];
|
|
32
|
+
if (kind === 'starbase-transfer')
|
|
33
|
+
return [at(4), at(8)];
|
|
34
|
+
return [at(4)];
|
|
35
|
+
}
|
|
36
|
+
/** Reads one cargo instruction's storage effect from its bytes and the fresh
|
|
37
|
+
* Fleet and token accounts. `cargoIdForMint` resolves a deposit's cargo id from
|
|
38
|
+
* its source token mint, as the program does. */
|
|
39
|
+
export function readCargoStorageAction(instruction, accounts, cargoIdForMint) {
|
|
40
|
+
const kind = cargoStorageInstruction(instruction);
|
|
41
|
+
const metas = instruction.accounts;
|
|
42
|
+
const data = instruction.data;
|
|
43
|
+
const signer = {
|
|
44
|
+
profile: metas[1].address,
|
|
45
|
+
authority: metas[0].address,
|
|
46
|
+
};
|
|
47
|
+
if (kind === 'deposit') {
|
|
48
|
+
const { amount, keyIndex } = decodeDepositCargoData(data);
|
|
49
|
+
const source = present(accounts, metas[10].address);
|
|
50
|
+
// Deposit callers always resolve the mint. One the Game does not list
|
|
51
|
+
// matches no held line, so the deposit counts as adding one: a
|
|
52
|
+
// conservative bound. The Plan's cargo-definition guards refuse such a
|
|
53
|
+
// deposit before this estimate runs.
|
|
54
|
+
const cargoId = cargoIdForMint(getAddressDecoder().decode(source.data.slice(0, 32)));
|
|
55
|
+
return {
|
|
56
|
+
...signer,
|
|
57
|
+
keyIndex,
|
|
58
|
+
settlement: 'each',
|
|
59
|
+
accounts: [
|
|
60
|
+
{
|
|
61
|
+
address: metas[5].address,
|
|
62
|
+
pod: 'starbase',
|
|
63
|
+
added: totals([[cargoId, amount]]),
|
|
64
|
+
removed: NONE,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const fleetAddress = metas[4].address;
|
|
70
|
+
if (kind === 'within-fleet-transfer') {
|
|
71
|
+
const { amount, cargoId, intoHold, outOfHold, keyIndex } = decodeWithinFleetTransferData(data);
|
|
72
|
+
const moved = totals([[cargoId, amount]]);
|
|
73
|
+
return {
|
|
74
|
+
...signer,
|
|
75
|
+
keyIndex,
|
|
76
|
+
settlement: 'each',
|
|
77
|
+
accounts: [
|
|
78
|
+
{
|
|
79
|
+
address: fleetAddress,
|
|
80
|
+
pod: 'fleet-hold',
|
|
81
|
+
added: intoHold ? moved : NONE,
|
|
82
|
+
removed: outOfHold ? moved : NONE,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const { ammo, fuel, loads, unloads, keyIndex } = decodeStarbaseTransferData(data);
|
|
88
|
+
const fleet = fleetAccountDefinition.decode(present(accounts, fleetAddress));
|
|
89
|
+
// Positive ammo and fuel load the Fleet from the Starbase Player; the
|
|
90
|
+
// Fleet's ammo bank and fuel tank are fixed slots.
|
|
91
|
+
const fromStarbase = totals([
|
|
92
|
+
[fleet.ammoBank.cargoId, ammo > 0n ? ammo : undefined],
|
|
93
|
+
[fleet.fuelTank.cargoId, fuel > 0n ? fuel : undefined],
|
|
94
|
+
...loads,
|
|
95
|
+
]);
|
|
96
|
+
const toStarbase = totals([
|
|
97
|
+
[fleet.ammoBank.cargoId, ammo < 0n ? -ammo : undefined],
|
|
98
|
+
[fleet.fuelTank.cargoId, fuel < 0n ? -fuel : undefined],
|
|
99
|
+
...unloads,
|
|
100
|
+
]);
|
|
101
|
+
return {
|
|
102
|
+
...signer,
|
|
103
|
+
keyIndex,
|
|
104
|
+
settlement: 'pair',
|
|
105
|
+
accounts: [
|
|
106
|
+
{
|
|
107
|
+
address: fleetAddress,
|
|
108
|
+
pod: 'fleet-hold',
|
|
109
|
+
added: totals(loads),
|
|
110
|
+
removed: totals(unloads),
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
address: metas[8].address,
|
|
114
|
+
pod: 'starbase',
|
|
115
|
+
added: toStarbase,
|
|
116
|
+
removed: fromStarbase,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function podLines(raw, pod) {
|
|
122
|
+
const amounts = pod === 'fleet-hold'
|
|
123
|
+
? fleetAccountDefinition.decode(raw).cargoHold.amounts
|
|
124
|
+
: starbasePlayerAccountDefinition.decode(raw).cargo.amounts;
|
|
125
|
+
return new Map(amounts.map(({ cargoId, amount }) => [cargoId, amount]));
|
|
126
|
+
}
|
|
127
|
+
/** Evaluates cargo actions in order, as the program runs them: each pod adds a
|
|
128
|
+
* line for a cargo id it lacks and drops a line its consumption empties, and
|
|
129
|
+
* after each action every resized account holds exactly the rent minimum of its
|
|
130
|
+
* new size. Later actions therefore see the storage earlier ones used. */
|
|
131
|
+
export function evaluateCargoStorage(actions, accounts) {
|
|
132
|
+
const rent = readRent(present(accounts, RENT_ADDRESS));
|
|
133
|
+
const state = new Map();
|
|
134
|
+
return actions.map((action) => {
|
|
135
|
+
let deficit = 0n;
|
|
136
|
+
let excess = 0n;
|
|
137
|
+
const resizes = action.accounts.map((account) => {
|
|
138
|
+
let current = state.get(account.address);
|
|
139
|
+
if (!current) {
|
|
140
|
+
const raw = present(accounts, account.address);
|
|
141
|
+
current = { raw, lines: podLines(raw, account.pod) };
|
|
142
|
+
state.set(account.address, current);
|
|
143
|
+
}
|
|
144
|
+
let lines = 0;
|
|
145
|
+
for (const cargoId of new Set([
|
|
146
|
+
...account.added.keys(),
|
|
147
|
+
...account.removed.keys(),
|
|
148
|
+
])) {
|
|
149
|
+
const held = current.lines.get(cargoId);
|
|
150
|
+
const after = (held ?? 0n) +
|
|
151
|
+
(account.added.get(cargoId) ?? 0n) -
|
|
152
|
+
(account.removed.get(cargoId) ?? 0n);
|
|
153
|
+
if (held === undefined && after > 0n)
|
|
154
|
+
lines += 1;
|
|
155
|
+
else if (held !== undefined &&
|
|
156
|
+
after <= 0n &&
|
|
157
|
+
account.removed.has(cargoId))
|
|
158
|
+
lines -= 1;
|
|
159
|
+
// Only consumption can empty a line; an added line stays positive.
|
|
160
|
+
if (after > 0n)
|
|
161
|
+
current.lines.set(cargoId, after);
|
|
162
|
+
else
|
|
163
|
+
current.lines.delete(cargoId);
|
|
164
|
+
}
|
|
165
|
+
const before = current.raw;
|
|
166
|
+
const growthBytes = lines * CARGO_LINE_BYTES;
|
|
167
|
+
const length = before.data.length + growthBytes;
|
|
168
|
+
// The program leaves a zero-lamport account unchanged.
|
|
169
|
+
if (before.lamports !== 0n) {
|
|
170
|
+
const minimum = rent(length);
|
|
171
|
+
if (before.lamports < minimum)
|
|
172
|
+
deficit += minimum - before.lamports;
|
|
173
|
+
else
|
|
174
|
+
excess += before.lamports - minimum;
|
|
175
|
+
}
|
|
176
|
+
current.raw = {
|
|
177
|
+
...before,
|
|
178
|
+
data: new Uint8Array(length),
|
|
179
|
+
lamports: before.lamports === 0n ? 0n : rent(length),
|
|
180
|
+
};
|
|
181
|
+
return { raw: before, growthBytes };
|
|
182
|
+
});
|
|
183
|
+
const profileDebit = action.settlement === 'each'
|
|
184
|
+
? deficit
|
|
185
|
+
: deficit > excess
|
|
186
|
+
? deficit - excess
|
|
187
|
+
: 0n;
|
|
188
|
+
return { resizes, profileDebit };
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/** The cargo steps of a Plan, in order. */
|
|
192
|
+
export function cargoStorageSteps(steps) {
|
|
193
|
+
return steps.flatMap((step) => {
|
|
194
|
+
const kind = cargoStorageInstruction(step.instruction);
|
|
195
|
+
return kind ? [{ ...step, kind }] : [];
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** Rechecks every cargo action's storage funding before signing. Each guard's
|
|
199
|
+
* resized accounts, sizes and byte changes must equal what its instruction does
|
|
200
|
+
* to the fresh accounts, so a saved Plan cannot weaken them. The actions are then
|
|
201
|
+
* evaluated in order, and each guard's debit is the one its action meets after
|
|
202
|
+
* the earlier actions. Returns each guard's funding, or the failure to report
|
|
203
|
+
* for it. */
|
|
204
|
+
export function validateCargoStorageFunding(steps, guards, accounts, cargoIdForMint) {
|
|
205
|
+
const results = new Map();
|
|
206
|
+
const remaining = [...guards];
|
|
207
|
+
const bound = [];
|
|
208
|
+
for (const step of cargoStorageSteps(steps)) {
|
|
209
|
+
const action = readCargoStorageAction(step.instruction, accounts, cargoIdForMint);
|
|
210
|
+
// Plan validation already bound each instruction to exactly one guard.
|
|
211
|
+
const index = remaining.findIndex((guard) => guard.profile === action.profile &&
|
|
212
|
+
guard.authority === action.authority &&
|
|
213
|
+
guard.keyIndex === action.keyIndex &&
|
|
214
|
+
guard.address === action.accounts[0].address &&
|
|
215
|
+
guard.paired === action.accounts[1]?.address);
|
|
216
|
+
bound.push({ guard: remaining[index], action });
|
|
217
|
+
remaining.splice(index, 1);
|
|
218
|
+
}
|
|
219
|
+
const ordered = evaluateCargoStorage(bound.map(({ action }) => action), accounts);
|
|
220
|
+
bound.forEach(({ guard, action }, index) => {
|
|
221
|
+
try {
|
|
222
|
+
const [solo] = evaluateCargoStorage([action], accounts);
|
|
223
|
+
const [first, second] = solo.resizes;
|
|
224
|
+
const planned = [
|
|
225
|
+
[guard.length, guard.growth],
|
|
226
|
+
guard.paired ? [guard.pairedLength, guard.pairedGrowth] : undefined,
|
|
227
|
+
];
|
|
228
|
+
[first, second].forEach((resize, at) => {
|
|
229
|
+
if (!resize)
|
|
230
|
+
return;
|
|
231
|
+
const [, growth] = planned[at];
|
|
232
|
+
if (resize.growthBytes !== growth)
|
|
233
|
+
fail(resize.raw.address, `The cargo action grows account ${resize.raw.address} by ${resize.growthBytes} bytes, not the ${growth} bytes its storage funding guard records. Recreate the Plan with its cargo planner.`);
|
|
234
|
+
});
|
|
235
|
+
results.set(guard, {
|
|
236
|
+
funding: checkProfileStorageFunding({
|
|
237
|
+
profileRaw: present(accounts, guard.profile),
|
|
238
|
+
rentRaw: present(accounts, RENT_ADDRESS),
|
|
239
|
+
authority: guard.authority,
|
|
240
|
+
keyIndex: guard.keyIndex,
|
|
241
|
+
profileDebit: ordered[index].profileDebit,
|
|
242
|
+
action: 'cargo action',
|
|
243
|
+
maximumProfileDebit: guard.maximumProfileDebit,
|
|
244
|
+
}),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
results.set(guard, { error });
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return results;
|
|
252
|
+
}
|
|
253
|
+
/** Plans one cargo instruction's storage funding from the same derivation
|
|
254
|
+
* execution repeats: its guard and the Plan summary sentence. */
|
|
255
|
+
export function planCargoStorageFunding(input) {
|
|
256
|
+
const action = readCargoStorageAction(input.instruction, input.accounts, input.cargoIdForMint);
|
|
257
|
+
const [evaluated] = evaluateCargoStorage([action], input.accounts);
|
|
258
|
+
return profileStorageFundingGuard({
|
|
259
|
+
profile: action.profile,
|
|
260
|
+
authority: action.authority,
|
|
261
|
+
keyIndex: action.keyIndex,
|
|
262
|
+
resizes: evaluated.resizes,
|
|
263
|
+
settlement: action.settlement,
|
|
264
|
+
funding: checkProfileStorageFunding({
|
|
265
|
+
profileRaw: present(input.accounts, input.profile),
|
|
266
|
+
rentRaw: present(input.accounts, RENT_ADDRESS),
|
|
267
|
+
authority: action.authority,
|
|
268
|
+
keyIndex: action.keyIndex,
|
|
269
|
+
profileDebit: evaluated.profileDebit,
|
|
270
|
+
action: input.action,
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=cargo-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cargo-storage.js","sourceRoot":"","sources":["../../../src/internal/planning/cargo-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkC,MAAM,aAAa,CAAC;AAGhF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,gBAAgB,EAChB,uBAAuB,GAGxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAK3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA+Bn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Q,EAAE,KAAK,CAAC,OAAO,CAAC;YAClD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC;YAC9C,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,SAAU,CAAC,YAAY;YACrC,MAAM,EAAE,KAAK,CAAC,MAAM;SACrB,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-ship-assembly.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/fleet-ship-assembly.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fleet-ship-assembly.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/fleet-ship-assembly.ts"],"names":[],"mappings":"AAYA,OAAO,EAGL,KAAK,mBAAmB,EACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,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,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,yBAAyB;IACxC,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,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AACD,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,yBAAyB,CAAC,CAkBpC;AAID,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,uBAAuB,EAC9B,QAAQ,EAAE,yBAAyB,EACnC,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAC,EACtD,QAAQ,CAAC,EAAE;IACT,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACtC,EACD,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC;IACT,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CA+ND"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SYSTEM_PROGRAM } from '../system-program.js';
|
|
2
2
|
import { fleetAccountDefinition, deriveFleetAddress } from '../c4/fleet.js';
|
|
3
|
-
import { fleetShipAssemblySize,
|
|
3
|
+
import { MAX_COMMANDERS_AND_TITANS_PER_FLEET, MAX_TITANS_PER_FLEET, fleetCapacityPoints, fleetShipAssemblySize, prospectiveShipCounts, shipSizeName, shipSizeRank, starbasePlayerEscrowGrowth, } from '../c4/fleet-ship-assembly.js';
|
|
4
4
|
import { decodeGameShipAssemblyCatalog, hashShipAssemblyConfiguration, } from '../../registry/ships.js';
|
|
5
5
|
import { isOffCurveAddress } from '@solana/kit';
|
|
6
6
|
import { SageSdkError } from '../../client/errors.js';
|
|
@@ -46,12 +46,14 @@ export async function validateFleetShipAssembly(input, resolved, accounts, expec
|
|
|
46
46
|
fail(address, `${name} ${address} is executable. Refresh valid account state before assembling ships.`);
|
|
47
47
|
return raw;
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
// The program assembles at any Starbase where the Character has a current
|
|
50
|
+
// StarbasePlayer of the Fleet's faction, whoever owns the Starbase.
|
|
51
|
+
const { profileRaw, profile, character, faction, system, player } = await readOwnStarbaseFacts(intent, resolved, required, {
|
|
50
52
|
replan: 'replan ship assembly',
|
|
51
53
|
before: 'before assembling ships',
|
|
52
|
-
});
|
|
53
|
-
if (
|
|
54
|
-
fail(resolved.
|
|
54
|
+
}, { anyStarbase: true });
|
|
55
|
+
if (player.sequenceId !== system.sequenceId)
|
|
56
|
+
fail(resolved.starbasePlayer, `The StarbasePlayer belongs to Starbase generation ${String(player.sequenceId)}, but the Starbase is at generation ${String(system.sequenceId)}; the program treats it as destroyed. Register a current StarbasePlayer at this Starbase and replan ship assembly.`);
|
|
55
57
|
const fleetRaw = required(resolved.fleet, 'Fleet');
|
|
56
58
|
const fleet = fleetAccountDefinition.decode(fleetRaw);
|
|
57
59
|
if ((await deriveFleetAddress(fleet)) !== intent.address ||
|
|
@@ -61,7 +63,7 @@ export async function validateFleetShipAssembly(input, resolved, accounts, expec
|
|
|
61
63
|
fleet.npcFactionId !== 0)
|
|
62
64
|
fail(resolved.fleet, 'The Fleet has a noncanonical address or different Game, Profile, faction or NPC affiliation. Select a canonical owned player Fleet and replan ship assembly.');
|
|
63
65
|
if (fleet.state.kind !== 'docked' || fleet.state.system !== intent.system)
|
|
64
|
-
fail(resolved.fleet, 'Ship assembly requires the Fleet to remain Docked at the selected System. Dock at
|
|
66
|
+
fail(resolved.fleet, 'Ship assembly requires the Fleet to remain Docked at the selected System. Dock at a Starbase where the Character has a current StarbasePlayer and replan.');
|
|
65
67
|
// A Fleet with a sub-profile is rented (or a rental was invalidated), and
|
|
66
68
|
// the program never adds ships to it.
|
|
67
69
|
if (fleet.subProfile !== SYSTEM_PROGRAM)
|
|
@@ -75,39 +77,65 @@ export async function validateFleetShipAssembly(input, resolved, accounts, expec
|
|
|
75
77
|
const gameRaw = required(resolved.game, 'Game');
|
|
76
78
|
const definitions = catalog ?? decodeGameShipAssemblyCatalog(gameRaw);
|
|
77
79
|
if (fleet.shipDefinitionsSeqId !== definitions.sequenceId)
|
|
78
|
-
fail(resolved.fleet, '
|
|
80
|
+
fail(resolved.fleet, 'The Fleet was built under older ship definitions. The program resynchronizes it inside the assembly, which can change its stats, and this SDK plans current Fleets only. Run any action that updates the Fleet, or the permissionless Fleet sync, then replan.');
|
|
79
81
|
const selected = definitions.rows.find((row) => row.id === intent.shipId);
|
|
80
|
-
if (!
|
|
81
|
-
fail(resolved.game,
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
if (!selected)
|
|
83
|
+
fail(resolved.game, `Ship configuration ${String(intent.shipId)} is not in the current Game ship definitions. Select a defined configuration and replan.`);
|
|
84
|
+
// Components move from the StarbasePlayer into the Fleet's components pod;
|
|
85
|
+
// that route and its storage are not planned yet.
|
|
86
|
+
if (selected.componentRequirements.size > 0)
|
|
87
|
+
fail(resolved.game, `Ship configuration ${String(intent.shipId)} needs ship components, which this SDK does not plan yet. Select a configuration without component requirements, or use the game client.`);
|
|
88
|
+
const size = shipSizeName(selected.sizeClass);
|
|
89
|
+
const maxSize = character.modifiers.values.maxShipSize;
|
|
90
|
+
if (selected.sizeClass > shipSizeRank(maxSize))
|
|
91
|
+
fail(resolved.character, `Ship configuration ${String(intent.shipId)} is ${size}, above the Character's maximum ship size ${maxSize}. Unlock research that raises the maximum ship size, then replan.`);
|
|
92
|
+
const tags = character.modifiers.values.researchTags;
|
|
93
|
+
const missing = selected.researchRequirements.filter((tag) => !tags.includes(tag));
|
|
94
|
+
if (missing.length > 0)
|
|
95
|
+
fail(resolved.character, `Ship configuration ${String(intent.shipId)} requires every research tag in [${selected.researchRequirements.join(', ')}]; the Character lacks [${missing.join(', ')}]. Unlock the research nodes that grant them, then replan.`);
|
|
91
96
|
const current = fleet.fleetShips.find((entry) => entry.shipId === intent.shipId)
|
|
92
97
|
?.quantity ?? 0n;
|
|
93
98
|
if (current + intent.amount > 18446744073709551615n)
|
|
94
99
|
fail(resolved.fleet, 'The resulting Fleet ship quantity exceeds the stored u64 limit. Select a smaller valid quantity and replan.');
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
// The program checks the Fleet's stored ship counts plus the added ships,
|
|
101
|
+
// never the requirements of ships already aboard.
|
|
102
|
+
const classes = prospectiveShipCounts(fleet.shipCounts, selected.sizeClass, Number(intent.amount));
|
|
103
|
+
const points = fleetCapacityPoints(classes);
|
|
104
|
+
if (points > character.modifiers.values.fleetSize)
|
|
105
|
+
fail(resolved.character, `The resulting Fleet uses ${String(points)} Fleet points, above the Character's Fleet size ${String(character.modifiers.values.fleetSize)}. Reduce the amount or unlock Fleet-size research, then replan.`);
|
|
106
|
+
if (points > definitions.maxFleetSize)
|
|
107
|
+
fail(resolved.game, `The resulting Fleet uses ${String(points)} Fleet points, above the Game's ${String(definitions.maxFleetSize)}-point Fleet limit. Reduce the resulting Fleet composition, then replan; a larger Character allowance does not override it.`);
|
|
108
|
+
const [commanders, titans] = [classes[6], classes[7]];
|
|
109
|
+
if (titans > MAX_TITANS_PER_FLEET)
|
|
110
|
+
fail(resolved.fleet, `The resulting Fleet would hold ${String(titans)} Titans; a Fleet holds at most ${String(MAX_TITANS_PER_FLEET)}. Add the Titan to another Fleet and replan.`);
|
|
111
|
+
if (commanders + titans > MAX_COMMANDERS_AND_TITANS_PER_FLEET)
|
|
112
|
+
fail(resolved.fleet, `The resulting Fleet would hold ${String(commanders + titans)} Commander and Titan ships; a Fleet holds at most ${String(MAX_COMMANDERS_AND_TITANS_PER_FLEET)} together. Add the ship to another Fleet and replan.`);
|
|
113
|
+
// Escrowed hulls of any configuration of the same ship count: the program
|
|
114
|
+
// re-tags them to the selected configuration.
|
|
115
|
+
const siblings = new Set(definitions.rows
|
|
116
|
+
.filter((row) => row.mint === selected.mint)
|
|
117
|
+
.map((row) => row.id));
|
|
118
|
+
const entitlement = player.shipsInEscrow
|
|
119
|
+
.filter((entry) => siblings.has(entry.shipId))
|
|
120
|
+
.reduce((total, entry) => total + entry.quantityRaw, 0n);
|
|
101
121
|
if (entitlement < intent.amount)
|
|
102
|
-
fail(resolved.starbasePlayer,
|
|
122
|
+
fail(resolved.starbasePlayer, `The StarbasePlayer holds ${String(entitlement)} escrowed hulls of this ship across its configurations, fewer than the ${String(intent.amount)} requested. Explicitly import more of this ship or reduce the amount, then replan.`);
|
|
103
123
|
const configHash = await hashShipAssemblyConfiguration(definitions, selected);
|
|
104
124
|
if (expected && expected.configHash !== configHash)
|
|
105
125
|
fail(resolved.game, 'The selected ship configuration has changed. Replan and inspect its current configuration before signing.');
|
|
106
126
|
const rent = readRent(required(resolved.rent, 'Rent sysvar'));
|
|
107
127
|
const now = readClock(required(resolved.clock, 'Clock sysvar'));
|
|
108
128
|
const fleetRent = rent(fleetShipAssemblySize(fleetRaw, intent.shipId, intent.amount));
|
|
109
|
-
const
|
|
110
|
-
|
|
129
|
+
const shortfall = (raw, minimum) => raw.lamports < minimum ? minimum - raw.lamports : 0n;
|
|
130
|
+
// The program funds the Fleet, StarbasePlayer and Character as one group.
|
|
131
|
+
// Re-tagging adds an escrow entry when the configuration has none, and its
|
|
132
|
+
// cost is counted in full. A StarbasePlayer already below its rent minimum
|
|
133
|
+
// is left out, as a combined ship import funds that shortfall first.
|
|
134
|
+
const playerRaw = required(resolved.starbasePlayer, 'StarbasePlayer');
|
|
135
|
+
const profileDebit = shortfall(fleetRaw, fleetRent) +
|
|
136
|
+
rent(playerRaw.data.length +
|
|
137
|
+
starbasePlayerEscrowGrowth(playerRaw, intent.shipId)) -
|
|
138
|
+
rent(playerRaw.data.length);
|
|
111
139
|
if (expected !== undefined && profileDebit > expected.maximumProfileDebit)
|
|
112
140
|
fail(resolved.profile, 'Ship assembly now requires a larger Profile debit than this Plan approved. Replan and inspect the updated rent shortfall before signing.');
|
|
113
141
|
const profileReserve = rent(profileRaw.data.length);
|
|
@@ -119,9 +147,10 @@ export async function validateFleetShipAssembly(input, resolved, accounts, expec
|
|
|
119
147
|
if (profileKeyExpired(key, now))
|
|
120
148
|
fail(resolved.profile, 'The selected Profile key has expired. Renew it or select a current direct key and replan ship assembly.');
|
|
121
149
|
const auth = grantsPermission(key, PROFILE_SCOPE, 0n);
|
|
122
|
-
const manages = grantsPermission(key, SAGE_SCOPE, 18n)
|
|
150
|
+
const manages = grantsPermission(key, SAGE_SCOPE, 18n) ||
|
|
151
|
+
grantsPermission(key, intent.address, 18n);
|
|
123
152
|
if (!auth && !manages)
|
|
124
|
-
fail(resolved.profile, 'The selected key cannot manage Fleets. Use a direct Profile AUTH key or a
|
|
153
|
+
fail(resolved.profile, 'The selected key cannot manage Fleets. Use a direct Profile AUTH key or a manageFleet key scoped to SAGE or this Fleet, and replan.');
|
|
125
154
|
if (profileDebit > 0n && !auth && !hasPermissionBit(key, 63n))
|
|
126
155
|
fail(resolved.profile, 'The selected manageFleet key cannot fund the Fleet from the Profile vault. Explicitly prefund the target or choose an authorized vault-funding key, then replan; drainSolVault grants vault withdrawal authority.');
|
|
127
156
|
return { profileDebit, profileReserve, fleetRent, configHash };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fleet-ship-assembly.js","sourceRoot":"","sources":["../../../src/internal/planning/fleet-ship-assembly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC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AAC,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC7C,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO;QACnB,IAAI,CACF,QAAQ,CAAC,OAAO,EAChB,qIAAqI,CACtI,CAAC;IACJ,IAAI,YAAY,GAAG,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC;QAC3D,IAAI,CACF,QAAQ,CAAC,OAAO,EAChB,mNAAmN,CACpN,CAAC;IACJ,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;AACjE,CAAC"}
|
|
@@ -10,8 +10,9 @@ export interface OwnStarbaseAction {
|
|
|
10
10
|
/** Decodes and relates the Profile, Character, faction membership, Star System
|
|
11
11
|
* and StarbasePlayer that Fleet creation and ship assembly both require: one
|
|
12
12
|
* canonical Character and membership for the Profile, a canonical Starbase
|
|
13
|
-
* System
|
|
14
|
-
*
|
|
13
|
+
* System, and the StarbasePlayer joining them. Unless `anyStarbase` is set, the
|
|
14
|
+
* Starbase must belong to the Profile's faction. `required` reads each account
|
|
15
|
+
* with the planner's own wording. */
|
|
15
16
|
export declare function readOwnStarbaseFacts(intent: {
|
|
16
17
|
readonly game: Address;
|
|
17
18
|
readonly profile: Address;
|
|
@@ -22,11 +23,14 @@ export declare function readOwnStarbaseFacts(intent: {
|
|
|
22
23
|
readonly profileFaction: Address;
|
|
23
24
|
readonly system: Address;
|
|
24
25
|
readonly starbasePlayer: Address;
|
|
25
|
-
}, required: (address: Address, name: string) => RawAccount, action: OwnStarbaseAction
|
|
26
|
+
}, required: (address: Address, name: string) => RawAccount, action: OwnStarbaseAction, options?: {
|
|
27
|
+
readonly anyStarbase?: true;
|
|
28
|
+
}): Promise<{
|
|
26
29
|
profileRaw: RawAccount;
|
|
27
30
|
profile: Readonly<import("../c4/identity.js").ProfileAccountData>;
|
|
28
31
|
character: Readonly<import("../c4/character.js").CharacterAccountData>;
|
|
29
32
|
faction: Readonly<import("../c4/profile-faction.js").ProfileFactionAccountData>;
|
|
33
|
+
system: Readonly<import("../c4/world.js").StarSystemAccountData>;
|
|
30
34
|
starbase: import("../c4/world.js").WorldStarbaseData;
|
|
31
35
|
player: Readonly<import("../c4/starbase.js").StarbasePlayerAccountData>;
|
|
32
36
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"own-starbase-facts.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/own-starbase-facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAW5D,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAMD
|
|
1
|
+
{"version":3,"file":"own-starbase-facts.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/own-starbase-facts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAW5D,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sFAAsF;IACtF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAMD;;;;;qCAKqC;AACrC,wBAAsB,oBAAoB,CACxC,MAAM,EAAE;IACN,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B,EACD,QAAQ,EAAE;IACR,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC,EACD,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,UAAU,EACxD,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;CAAO;;;;;;;;GAmE9C"}
|
|
@@ -10,9 +10,10 @@ function fail(address, message) {
|
|
|
10
10
|
/** Decodes and relates the Profile, Character, faction membership, Star System
|
|
11
11
|
* and StarbasePlayer that Fleet creation and ship assembly both require: one
|
|
12
12
|
* canonical Character and membership for the Profile, a canonical Starbase
|
|
13
|
-
* System
|
|
14
|
-
*
|
|
15
|
-
|
|
13
|
+
* System, and the StarbasePlayer joining them. Unless `anyStarbase` is set, the
|
|
14
|
+
* Starbase must belong to the Profile's faction. `required` reads each account
|
|
15
|
+
* with the planner's own wording. */
|
|
16
|
+
export async function readOwnStarbaseFacts(intent, resolved, required, action, options = {}) {
|
|
16
17
|
const profileRaw = required(resolved.profile, 'Profile');
|
|
17
18
|
const profile = profileAccountDefinition.decode(profileRaw);
|
|
18
19
|
const character = characterAccountDefinition.decode(required(resolved.character, 'Character'));
|
|
@@ -34,14 +35,16 @@ export async function readOwnStarbaseFacts(intent, resolved, required, action) {
|
|
|
34
35
|
player.system !== intent.system ||
|
|
35
36
|
player.faction !== faction.faction)
|
|
36
37
|
fail(resolved.starbasePlayer, 'The StarbasePlayer has a different Profile, Character, System or faction relationship. Refresh the canonical StarbasePlayer and replan.');
|
|
37
|
-
if (
|
|
38
|
-
|
|
38
|
+
if (!options.anyStarbase &&
|
|
39
|
+
(faction.faction === 'unaligned' ||
|
|
40
|
+
system.starbase.owner !== faction.faction))
|
|
39
41
|
fail(resolved.system, 'This planner supports an existing own-faction StarbasePlayer only. Select an own-faction Starbase; other diplomacy or access routes require separate supported planning.');
|
|
40
42
|
return {
|
|
41
43
|
profileRaw,
|
|
42
44
|
profile,
|
|
43
45
|
character,
|
|
44
46
|
faction,
|
|
47
|
+
system,
|
|
45
48
|
starbase: system.starbase,
|
|
46
49
|
player,
|
|
47
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"own-starbase-facts.js","sourceRoot":"","sources":["../../../src/internal/planning/own-starbase-facts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EACL,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAUxB,SAAS,IAAI,CAAC,OAAgB,EAAE,OAAe;IAC7C,MAAM,IAAI,YAAY,CAAC,4BAA4B,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"own-starbase-facts.js","sourceRoot":"","sources":["../../../src/internal/planning/own-starbase-facts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAA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AM,CAAC,MAAM,GAAG,CAC5G,CAAC;IACJ,IACE,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;QAC3B,CAAC,MAAM,uBAAuB,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3D,MAAM,CAAC,MAAM;QACf,CAAC,MAAM,CAAC,QAAQ;QAEhB,IAAI,CACF,QAAQ,CAAC,MAAM,EACf,mHAAmH,CACpH,CAAC;IACJ,IACE,MAAM,CAAC,aAAa,KAAK,MAAM,CAAC,OAAO;QACvC,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC,SAAS;QACvC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAC/B,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;QAElC,IAAI,CACF,QAAQ,CAAC,cAAc,EACvB,yIAAyI,CAC1I,CAAC;IACJ,IACE,CAAC,OAAO,CAAC,WAAW;QACpB,CAAC,OAAO,CAAC,OAAO,KAAK,WAAW;YAC9B,MAAM,CAAC,QAAQ,CAAC,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC;QAE5C,IAAI,CACF,QAAQ,CAAC,MAAM,EACf,0KAA0K,CAC3K,CAAC;IACJ,OAAO;QACL,UAAU;QACV,OAAO;QACP,SAAS;QACT,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-guards.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/plan-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"plan-guards.d.ts","sourceRoot":"","sources":["../../../src/internal/planning/plan-guards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAqVhE,mEAAmE;AACnE,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,EACb,IAAI,UAAQ,GACX,gBAAgB,CAkBlB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeArrivalGuard } from './arrival-guards.js';
|
|
2
2
|
import { FLEET_DOCK_FUNDING_SCHEMA } from './fleet-dock-funding-guard.js';
|
|
3
3
|
import { LOCAL_MARKET_ORDER_SCHEMA } from './local-market-order.js';
|
|
4
|
+
import { PROFILE_STORAGE_FUNDING_SCHEMA } from './profile-storage-funding-guard.js';
|
|
4
5
|
import { MAX_U64, invalid, normalizeSchemaGuard, readRecord, } from './plan-fields.js';
|
|
5
6
|
import { isRuntimeGuard, normalizeRuntimeGuard } from './runtime-guards.js';
|
|
6
7
|
import { scanCompletionDiscriminators } from './scan-completion-guard.js';
|
|
@@ -159,6 +160,7 @@ const GUARD_SCHEMAS = {
|
|
|
159
160
|
'account-state': schema(address('address'), ['dataHash', 'hash'], DESCRIBES),
|
|
160
161
|
'fleet-dock-funding': FLEET_DOCK_FUNDING_SCHEMA,
|
|
161
162
|
'local-market-order': LOCAL_MARKET_ORDER_SCHEMA,
|
|
163
|
+
'profile-storage-funding': PROFILE_STORAGE_FUNDING_SCHEMA,
|
|
162
164
|
};
|
|
163
165
|
/** Validates one Plan guard; `wire` decodes its Plan JSON form. */
|
|
164
166
|
export function normalizePrecondition(value, field, wire = false) {
|