@thecorporation/corp-tools 26.3.35 → 26.3.37

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/browser.js CHANGED
@@ -1276,11 +1276,35 @@ async function issueEquity(client, args) {
1276
1276
  steps
1277
1277
  };
1278
1278
  }
1279
- const instrument = resolveInstrumentForGrant(
1280
- instruments,
1281
- args.grantType,
1282
- args.instrumentId
1283
- );
1279
+ let instrument;
1280
+ try {
1281
+ instrument = resolveInstrumentForGrant(
1282
+ instruments,
1283
+ args.grantType,
1284
+ args.instrumentId
1285
+ );
1286
+ } catch (resolveErr) {
1287
+ const kinds = expectedInstrumentKinds(args.grantType);
1288
+ if (kinds.includes("option_grant") && !args.instrumentId) {
1289
+ const issuerLegalEntityId2 = capTable.issuer_legal_entity_id;
1290
+ if (!issuerLegalEntityId2) throw resolveErr;
1291
+ const created = await client.createInstrument({
1292
+ entity_id: args.entityId,
1293
+ issuer_legal_entity_id: issuerLegalEntityId2,
1294
+ kind: "option_grant",
1295
+ symbol: "OPTION-PLAN",
1296
+ authorized_units: 1e7
1297
+ });
1298
+ instrument = created;
1299
+ steps.push({
1300
+ name: "auto_create_instrument",
1301
+ status: "ok",
1302
+ detail: `Auto-created option_grant instrument OPTION-PLAN`
1303
+ });
1304
+ } else {
1305
+ throw resolveErr;
1306
+ }
1307
+ }
1284
1308
  const instrumentId = instrument.instrument_id;
1285
1309
  steps.push({
1286
1310
  name: "resolve_instrument",