@fairmint/canton-fairmint-sdk 0.0.63 → 0.0.64
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/fairmintOcpClient.d.ts +16 -5
- package/dist/fairmintOcpClient.d.ts.map +1 -1
- package/dist/fairmintOcpClient.js +14 -3
- package/dist/fairmintOcpClient.js.map +1 -1
- package/dist/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.d.ts +14 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.d.ts.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.js +67 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.js.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.d.ts +25 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.d.ts.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.js +74 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.js.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/index.d.ts +4 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/index.d.ts.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/index.js +20 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/index.js.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.d.ts +14 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.d.ts.map +1 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.js +69 -0
- package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.js.map +1 -0
- package/dist/functions/OpenCapTableReports/index.d.ts +2 -0
- package/dist/functions/OpenCapTableReports/index.d.ts.map +1 -0
- package/dist/functions/OpenCapTableReports/index.js +18 -0
- package/dist/functions/OpenCapTableReports/index.js.map +1 -0
- package/package.json +5 -3
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* {@link FairmintOcpClient} — same as {@link OcpClient} from `@open-captable-protocol/canton` plus Fairmint-only
|
|
3
|
-
* `
|
|
3
|
+
* `OpenCapTableReports` (company valuation reports, via `@fairmint/open-captable-protocol-daml-js`), `CouponMinter`,
|
|
4
|
+
* `CantonPayments`, and `PaymentStreams` namespaces.
|
|
4
5
|
*
|
|
5
|
-
* Prefer {@link createFairmintOcpClient}
|
|
6
|
-
* {@link OcpClient} when you only need public OCP cap-table APIs.
|
|
6
|
+
* Prefer {@link createFairmintOcpClient} when you need reports, payment streams, airdrops, or coupon minter rate
|
|
7
|
+
* limits; use plain {@link OcpClient} when you only need **public** OCP cap-table APIs (no Fairmint DAML JS types).
|
|
7
8
|
*
|
|
8
9
|
* @module
|
|
9
10
|
*/
|
|
10
11
|
import type { ValidatorApiClient } from '@fairmint/canton-node-sdk';
|
|
11
12
|
import type { DisclosedContract } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/schemas/api/commands';
|
|
12
|
-
import { OcpClient, type OcpClientDependencies } from '@open-captable-protocol/canton';
|
|
13
|
+
import { OcpClient, type CommandWithDisclosedContracts, type OcpClientDependencies } from '@open-captable-protocol/canton';
|
|
13
14
|
import { type CantonPaymentsMethods, type PaymentStreamsMethods } from './extensions';
|
|
14
15
|
import type { CanMintResult, CouponMinterPayload, MintWithRateLimitOptions, MintWithRateLimitResult, WaitUntilCanMintOptions } from './functions/CouponMinter';
|
|
16
|
+
import { type AddObserversToCompanyValuationReportParams, type AddObserversToCompanyValuationReportResult, type CreateCompanyValuationReportParams, type CreateCompanyValuationReportResult, type UpdateCompanyValuationParams, type UpdateCompanyValuationResult } from './functions/OpenCapTableReports';
|
|
15
17
|
interface CouponMinterMethods {
|
|
16
18
|
canMintCouponsNow: (payload: CouponMinterPayload, now?: Date) => CanMintResult;
|
|
17
19
|
getRateLimitStatus: (payload: CouponMinterPayload, now?: Date) => CanMintResult & {
|
|
@@ -30,8 +32,17 @@ export interface PaymentStreamsMethodsWithClient extends Omit<PaymentStreamsMeth
|
|
|
30
32
|
buildPaymentContextWithAmulets: (validatorClient: ValidatorApiClient, payerParty: string, requestedAmount: string, provider: string) => Promise<import('./functions/PaymentStreams/utils/paymentContext').PaymentContextWithAmuletsAndDisclosed>;
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
interface OpenCapTableReportsMethods {
|
|
36
|
+
companyValuationReport: {
|
|
37
|
+
buildCreate: (params: CreateCompanyValuationReportParams) => CommandWithDisclosedContracts;
|
|
38
|
+
addObservers: (params: AddObserversToCompanyValuationReportParams) => Promise<AddObserversToCompanyValuationReportResult>;
|
|
39
|
+
create: (params: CreateCompanyValuationReportParams) => Promise<CreateCompanyValuationReportResult>;
|
|
40
|
+
update: (params: UpdateCompanyValuationParams) => Promise<UpdateCompanyValuationResult>;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** OCP client including Fairmint-only namespaces (reports, payments, payment streams, coupon minter). */
|
|
34
44
|
export type FairmintOcpClient = OcpClient & {
|
|
45
|
+
readonly OpenCapTableReports: OpenCapTableReportsMethods;
|
|
35
46
|
readonly CouponMinter: CouponMinterMethods;
|
|
36
47
|
readonly CantonPayments: CantonPaymentsMethods;
|
|
37
48
|
readonly PaymentStreams: PaymentStreamsMethodsWithClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fairmintOcpClient.d.ts","sourceRoot":"","sources":["../src/fairmintOcpClient.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fairmintOcpClient.d.ts","sourceRoot":"","sources":["../src/fairmintOcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,KAAK,EA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AgC,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* {@link FairmintOcpClient} — same as {@link OcpClient} from `@open-captable-protocol/canton` plus Fairmint-only
|
|
4
|
-
* `
|
|
4
|
+
* `OpenCapTableReports` (company valuation reports, via `@fairmint/open-captable-protocol-daml-js`), `CouponMinter`,
|
|
5
|
+
* `CantonPayments`, and `PaymentStreams` namespaces.
|
|
5
6
|
*
|
|
6
|
-
* Prefer {@link createFairmintOcpClient}
|
|
7
|
-
* {@link OcpClient} when you only need public OCP cap-table APIs.
|
|
7
|
+
* Prefer {@link createFairmintOcpClient} when you need reports, payment streams, airdrops, or coupon minter rate
|
|
8
|
+
* limits; use plain {@link OcpClient} when you only need **public** OCP cap-table APIs (no Fairmint DAML JS types).
|
|
8
9
|
*
|
|
9
10
|
* @module
|
|
10
11
|
*/
|
|
@@ -13,6 +14,7 @@ exports.createFairmintOcpClient = createFairmintOcpClient;
|
|
|
13
14
|
const canton_1 = require("@open-captable-protocol/canton");
|
|
14
15
|
const extensions_1 = require("./extensions");
|
|
15
16
|
const CouponMinter_1 = require("./functions/CouponMinter");
|
|
17
|
+
const OpenCapTableReports_1 = require("./functions/OpenCapTableReports");
|
|
16
18
|
function createPaymentStreamsMethodsWithClient(ledger) {
|
|
17
19
|
const baseExtension = (0, extensions_1.createPaymentStreamsExtension)();
|
|
18
20
|
return {
|
|
@@ -35,6 +37,14 @@ function createPaymentStreamsMethodsWithClient(ledger) {
|
|
|
35
37
|
*/
|
|
36
38
|
function createFairmintOcpClient(dependencies) {
|
|
37
39
|
const ocp = new canton_1.OcpClient(dependencies);
|
|
40
|
+
const openCapTableReports = {
|
|
41
|
+
companyValuationReport: {
|
|
42
|
+
buildCreate: params => (0, OpenCapTableReports_1.buildCreateCompanyValuationReportCommand)(ocp.ledger, params),
|
|
43
|
+
addObservers: async (params) => (0, OpenCapTableReports_1.addObserversToCompanyValuationReport)(ocp.ledger, params),
|
|
44
|
+
create: async (params) => (0, OpenCapTableReports_1.createCompanyValuationReport)(ocp.ledger, params),
|
|
45
|
+
update: async (params) => (0, OpenCapTableReports_1.updateCompanyValuationReport)(ocp.ledger, params),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
38
48
|
const couponMinter = {
|
|
39
49
|
canMintCouponsNow: (payload, now) => (0, CouponMinter_1.canMintCouponsNow)(payload, now),
|
|
40
50
|
getRateLimitStatus: (payload, now) => (0, CouponMinter_1.getRateLimitStatus)(payload, now),
|
|
@@ -44,6 +54,7 @@ function createFairmintOcpClient(dependencies) {
|
|
|
44
54
|
const cantonPayments = (0, extensions_1.createCantonPaymentsExtension)();
|
|
45
55
|
const paymentStreams = createPaymentStreamsMethodsWithClient(ocp.ledger);
|
|
46
56
|
return Object.assign(ocp, {
|
|
57
|
+
OpenCapTableReports: openCapTableReports,
|
|
47
58
|
CouponMinter: couponMinter,
|
|
48
59
|
CantonPayments: cantonPayments,
|
|
49
60
|
PaymentStreams: paymentStreams,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fairmintOcpClient.js","sourceRoot":"","sources":["../src/fairmintOcpClient.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"fairmintOcpClient.js","sourceRoot":"","sources":["../src/fairmintOcpClient.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAsJH,0DAkCC;AAnLD,2DAIwC;AAExC,6CAKsB;AAQtB,2DAKkC;AAClC,yEAWyC;AAkDzC,SAAS,qCAAqC,CAC5C,MAA2B;IAE3B,MAAM,aAAa,GAAG,IAAA,0CAA6B,GAAE,CAAC;IAEtD,OAAO;QACL,GAAG,aAAa;QAChB,KAAK,EAAE;YACL,GAAG,aAAa,CAAC,KAAK;YACtB,4BAA4B,EAAE,GAAG,EAAE,CACjC,aAAa,CAAC,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC;YAC1D,0CAA0C,EAAE,KAAK,EAC/C,+BAAuC,EACvC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,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CACpD,IAAA,gCAAiB,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;KAC9C,CAAC;IAEF,MAAM,cAAc,GAAG,IAAA,0CAA6B,GAAE,CAAC;IACvD,MAAM,cAAc,GAAG,qCAAqC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEzE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;QACxB,mBAAmB,EAAE,mBAAmB;QACxC,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,cAAc;QAC9B,cAAc,EAAE,cAAc;KAC/B,CAAsB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
|
|
2
|
+
import type { SubmitAndWaitForTransactionTreeResponse } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/operations';
|
|
3
|
+
export interface AddObserversToCompanyValuationReportParams {
|
|
4
|
+
companyValuationReportContractId: string;
|
|
5
|
+
added: string[];
|
|
6
|
+
}
|
|
7
|
+
export interface AddObserversToCompanyValuationReportResult {
|
|
8
|
+
contractId: string;
|
|
9
|
+
updateId: string;
|
|
10
|
+
response: SubmitAndWaitForTransactionTreeResponse;
|
|
11
|
+
}
|
|
12
|
+
/** Add observers to a CompanyValuationReport by exercising AddObservers. */
|
|
13
|
+
export declare function addObserversToCompanyValuationReport(client: LedgerJsonApiClient, params: AddObserversToCompanyValuationReportParams): Promise<AddObserversToCompanyValuationReportResult>;
|
|
14
|
+
//# sourceMappingURL=addObserversToCompanyValuationReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addObserversToCompanyValuationReport.d.ts","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,wEAAwE,CAAC;AAStI,MAAM,WAAW,0CAA0C;IACzD,gCAAgC,EAAE,MAAM,CAAC;IACzC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,0CAA0C;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,uCAAuC,CAAC;CACnD;AAmBD,4EAA4E;AAC5E,wBAAsB,oCAAoC,CACxD,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,0CAA0C,GACjD,OAAO,CAAC,0CAA0C,CAAC,CAsErD"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addObserversToCompanyValuationReport = addObserversToCompanyValuationReport;
|
|
4
|
+
const findCreatedEvent_1 = require("@fairmint/canton-node-sdk/build/src/utils/contracts/findCreatedEvent");
|
|
5
|
+
const open_captable_protocol_daml_js_1 = require("@fairmint/open-captable-protocol-daml-js");
|
|
6
|
+
const canton_1 = require("@open-captable-protocol/canton");
|
|
7
|
+
function hasSystemOperator(arg) {
|
|
8
|
+
return (Boolean(arg) &&
|
|
9
|
+
typeof arg === 'object' &&
|
|
10
|
+
typeof arg
|
|
11
|
+
.system_operator === 'string');
|
|
12
|
+
}
|
|
13
|
+
/** Add observers to a CompanyValuationReport by exercising AddObservers. */
|
|
14
|
+
async function addObserversToCompanyValuationReport(client, params) {
|
|
15
|
+
// Determine the acting party (system_operator) from the created event
|
|
16
|
+
const eventsResponse = await client.getEventsByContractId({
|
|
17
|
+
contractId: params.companyValuationReportContractId,
|
|
18
|
+
});
|
|
19
|
+
const createdEvent = eventsResponse.created?.createdEvent;
|
|
20
|
+
if (!createdEvent?.createArgument) {
|
|
21
|
+
throw new canton_1.OcpContractError('Invalid contract events response: missing created event or create argument', {
|
|
22
|
+
contractId: params.companyValuationReportContractId,
|
|
23
|
+
code: canton_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const { createArgument } = createdEvent;
|
|
27
|
+
if (!hasSystemOperator(createArgument)) {
|
|
28
|
+
throw new canton_1.OcpParseError('System operator not found in contract create argument', {
|
|
29
|
+
source: 'CompanyValuationReport.createArgument',
|
|
30
|
+
code: canton_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const systemOperator = createArgument.system_operator;
|
|
34
|
+
const choiceArguments = {
|
|
35
|
+
added: params.added,
|
|
36
|
+
};
|
|
37
|
+
const response = await client.submitAndWaitForTransactionTree({
|
|
38
|
+
actAs: [systemOperator],
|
|
39
|
+
commands: [
|
|
40
|
+
{
|
|
41
|
+
ExerciseCommand: {
|
|
42
|
+
templateId: open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport
|
|
43
|
+
.CompanyValuationReport.templateId,
|
|
44
|
+
contractId: params.companyValuationReportContractId,
|
|
45
|
+
choice: 'AddObservers',
|
|
46
|
+
choiceArgument: choiceArguments,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
const created = (0, findCreatedEvent_1.findCreatedEventByTemplateId)(response, open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport.CompanyValuationReport
|
|
52
|
+
.templateId);
|
|
53
|
+
if (!created) {
|
|
54
|
+
throw new canton_1.OcpContractError('Expected CreatedTreeEvent not found', {
|
|
55
|
+
templateId: open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport
|
|
56
|
+
.CompanyValuationReport.templateId,
|
|
57
|
+
choice: 'AddObservers',
|
|
58
|
+
code: canton_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
contractId: created.CreatedTreeEvent.value.contractId,
|
|
63
|
+
updateId: response.transactionTree.updateId,
|
|
64
|
+
response,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=addObserversToCompanyValuationReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addObserversToCompanyValuationReport.js","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/addObserversToCompanyValuationReport.ts"],"names":[],"mappings":";;AAuCA,oFAyEC;AA9GD,2GAAoH;AACpH,6FAAoE;AACpE,2DAIwC;AAiBxC,SAAS,iBAAiB,CACxB,GAAY;IAIZ,OAAO,CACL,OAAO,CAAC,GAAG,CAAC;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAQ,GAAiD;aACtD,eAAe,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC;AAED,4EAA4E;AACrE,KAAK,UAAU,oCAAoC,CACxD,MAA2B,EAC3B,MAAkD;IAElD,sEAAsE;IACtE,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC;QACxD,UAAU,EAAE,MAAM,CAAC,gCAAgC;KACpD,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC;QAClC,MAAM,IAAI,yBAAgB,CACxB,4EAA4E,EAC5E;YACE,UAAU,EAAE,MAAM,CAAC,gCAAgC;YACnD,IAAI,EAAE,sBAAa,CAAC,gBAAgB;SACrC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,CAAC;IACxC,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,sBAAa,CACrB,uDAAuD,EACvD;YACE,MAAM,EAAE,uCAAuC;YAC/C,IAAI,EAAE,sBAAa,CAAC,eAAe;SACpC,CACF,CAAC;IACJ,CAAC;IACD,MAAM,cAAc,GAAG,cAAc,CAAC,eAAe,CAAC;IAEtD,MAAM,eAAe,GACnB;QACE,KAAK,EAAE,MAAM,CAAC,KAAK;KACpB,CAAC;IAEJ,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,+BAA+B,CAAC;QAC5D,KAAK,EAAE,CAAC,cAAc,CAAC;QACvB,QAAQ,EAAE;YACR;gBACE,eAAe,EAAE;oBACf,UAAU,EACR,yCAAQ,CAAC,mBAAmB,CAAC,sBAAsB;yBAChD,sBAAsB,CAAC,UAAU;oBACtC,UAAU,EAAE,MAAM,CAAC,gCAAgC;oBACnD,MAAM,EAAE,cAAc;oBACtB,cAAc,EAAE,eAAe;iBAChC;aACF;SACF;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,IAAA,+CAA4B,EAC1C,QAAQ,EACR,yCAAQ,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,sBAAsB;SACvE,UAAU,CACd,CAAC;IACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,yBAAgB,CAAC,qCAAqC,EAAE;YAChE,UAAU,EACR,yCAAQ,CAAC,mBAAmB,CAAC,sBAAsB;iBAChD,sBAAsB,CAAC,UAAU;YACtC,MAAM,EAAE,cAAc;YACtB,IAAI,EAAE,sBAAa,CAAC,gBAAgB;SACrC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU;QACrD,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,QAAQ;QAC3C,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
|
|
2
|
+
import type { SubmitAndWaitForTransactionTreeResponse } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/operations';
|
|
3
|
+
import type { DisclosedContract } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/schemas';
|
|
4
|
+
import { type CommandWithDisclosedContracts } from '@open-captable-protocol/canton';
|
|
5
|
+
export interface CreateCompanyValuationReportParams {
|
|
6
|
+
companyId: string;
|
|
7
|
+
companyValuation: string | number;
|
|
8
|
+
observers?: string[];
|
|
9
|
+
/** Details of the FeaturedAppRight contract for disclosed contracts */
|
|
10
|
+
featuredAppRightContractDetails: DisclosedContract;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateCompanyValuationReportResult {
|
|
13
|
+
contractId: string;
|
|
14
|
+
updateId: string;
|
|
15
|
+
response: SubmitAndWaitForTransactionTreeResponse;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a CompanyValuationReport by exercising the CreateCompanyValuationReport choice on the OCP Factory contract.
|
|
19
|
+
*
|
|
20
|
+
* This function requires the FeaturedAppRight contract details to be provided for disclosed contracts, which is
|
|
21
|
+
* necessary for cross-domain contract interactions in Canton.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createCompanyValuationReport(client: LedgerJsonApiClient, params: CreateCompanyValuationReportParams): Promise<CreateCompanyValuationReportResult>;
|
|
24
|
+
export declare function buildCreateCompanyValuationReportCommand(client: LedgerJsonApiClient, params: CreateCompanyValuationReportParams): CommandWithDisclosedContracts;
|
|
25
|
+
//# sourceMappingURL=createCompanyValuationReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCompanyValuationReport.d.ts","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,wEAAwE,CAAC;AACtI,OAAO,KAAK,EAEV,iBAAiB,EAClB,MAAM,qEAAqE,CAAC;AAI7E,OAAO,EAIL,KAAK,6BAA6B,EACnC,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,kCAAkC;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,uEAAuE;IACvE,+BAA+B,EAAE,iBAAiB,CAAC;CACpD;AAED,MAAM,WAAW,kCAAkC;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,uCAAuC,CAAC;CACnD;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,kCAAkC,CAAC,CA6B7C;AAED,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,kCAAkC,GACzC,6BAA6B,CA2C/B"}
|
package/dist/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createCompanyValuationReport = createCompanyValuationReport;
|
|
7
|
+
exports.buildCreateCompanyValuationReportCommand = buildCreateCompanyValuationReportCommand;
|
|
8
|
+
const findCreatedEvent_1 = require("@fairmint/canton-node-sdk/build/src/utils/contracts/findCreatedEvent");
|
|
9
|
+
const open_captable_protocol_daml_js_1 = require("@fairmint/open-captable-protocol-daml-js");
|
|
10
|
+
const reports_factory_contract_id_json_1 = __importDefault(require("@fairmint/open-captable-protocol-daml-js/reports-factory-contract-id.json"));
|
|
11
|
+
const canton_1 = require("@open-captable-protocol/canton");
|
|
12
|
+
/**
|
|
13
|
+
* Create a CompanyValuationReport by exercising the CreateCompanyValuationReport choice on the OCP Factory contract.
|
|
14
|
+
*
|
|
15
|
+
* This function requires the FeaturedAppRight contract details to be provided for disclosed contracts, which is
|
|
16
|
+
* necessary for cross-domain contract interactions in Canton.
|
|
17
|
+
*/
|
|
18
|
+
async function createCompanyValuationReport(client, params) {
|
|
19
|
+
const { command, disclosedContracts } = buildCreateCompanyValuationReportCommand(client, params);
|
|
20
|
+
const response = (await client.submitAndWaitForTransactionTree({
|
|
21
|
+
commands: [command],
|
|
22
|
+
disclosedContracts,
|
|
23
|
+
}));
|
|
24
|
+
const created = (0, findCreatedEvent_1.findCreatedEventByTemplateId)(response, open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport.CompanyValuationReport
|
|
25
|
+
.templateId);
|
|
26
|
+
if (!created) {
|
|
27
|
+
throw new canton_1.OcpContractError('Expected CreatedTreeEvent not found', {
|
|
28
|
+
templateId: open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport
|
|
29
|
+
.CompanyValuationReport.templateId,
|
|
30
|
+
choice: 'CreateCompanyValuationReport',
|
|
31
|
+
code: canton_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
contractId: created.CreatedTreeEvent.value.contractId,
|
|
36
|
+
updateId: response.transactionTree.updateId,
|
|
37
|
+
response,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function buildCreateCompanyValuationReportCommand(client, params) {
|
|
41
|
+
const network = client.getNetwork();
|
|
42
|
+
const networkData = reports_factory_contract_id_json_1.default[network];
|
|
43
|
+
if (!networkData) {
|
|
44
|
+
throw new canton_1.OcpValidationError('network', `Unsupported network: ${network}`, {
|
|
45
|
+
code: canton_1.OcpErrorCodes.INVALID_FORMAT,
|
|
46
|
+
receivedValue: network,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const choiceArguments = {
|
|
50
|
+
company_id: params.companyId,
|
|
51
|
+
company_valuation: typeof params.companyValuation === 'number'
|
|
52
|
+
? params.companyValuation.toString()
|
|
53
|
+
: params.companyValuation,
|
|
54
|
+
observers: params.observers ?? [],
|
|
55
|
+
};
|
|
56
|
+
const command = {
|
|
57
|
+
ExerciseCommand: {
|
|
58
|
+
templateId: networkData.templateId,
|
|
59
|
+
contractId: networkData.reportsFactoryContractId,
|
|
60
|
+
choice: 'CreateCompanyValuationReport',
|
|
61
|
+
choiceArgument: choiceArguments,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const disclosedContracts = [
|
|
65
|
+
{
|
|
66
|
+
templateId: params.featuredAppRightContractDetails.templateId,
|
|
67
|
+
contractId: params.featuredAppRightContractDetails.contractId,
|
|
68
|
+
createdEventBlob: params.featuredAppRightContractDetails.createdEventBlob,
|
|
69
|
+
synchronizerId: params.featuredAppRightContractDetails.synchronizerId,
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
return { command, disclosedContracts };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=createCompanyValuationReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createCompanyValuationReport.js","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/createCompanyValuationReport.ts"],"names":[],"mappings":";;;;;AAoCA,oEAgCC;AAED,4FA8CC;AA9GD,2GAAoH;AACpH,6FAAoE;AACpE,iJAA8G;AAC9G,2DAKwC;AAgBxC;;;;;GAKG;AACI,KAAK,UAAU,4BAA4B,CAChD,MAA2B,EAC3B,MAA0C;IAE1C,MAAM,EAAE,OAAO,EAAE,kBAAkB,EAAE,GACnC,wCAAwC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3D,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,+BAA+B,CAAC;QAC7D,QAAQ,EAAE,CAAC,OAAO,CAAC;QACnB,kBAAkB;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AAY;QACvB,eAAe,EAAE;YACf,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,UAAU,EAAE,WAAW,CAAC,wBAAwB;YAChD,MAAM,EAAE,8BAA8B;YACtC,cAAc,EAAE,eAAe;SAChC;KACF,CAAC;IAEF,MAAM,kBAAkB,GAAwB;QAC9C;YACE,UAAU,EAAE,MAAM,CAAC,+BAA+B,CAAC,UAAU;YAC7D,UAAU,EAAE,MAAM,CAAC,+BAA+B,CAAC,UAAU;YAC7D,gBAAgB,EAAE,MAAM,CAAC,+BAA+B,CAAC,gBAAgB;YACzE,cAAc,EAAE,MAAM,CAAC,+BAA+B,CAAC,cAAc;SACtE;KACF,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./addObserversToCompanyValuationReport"), exports);
|
|
18
|
+
__exportStar(require("./createCompanyValuationReport"), exports);
|
|
19
|
+
__exportStar(require("./updateCompanyValuationReport"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yEAAuD;AACvD,iEAA+C;AAC/C,iEAA+C"}
|
package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
|
|
2
|
+
import type { SubmitAndWaitForTransactionTreeResponse } from '@fairmint/canton-node-sdk/build/src/clients/ledger-json-api/operations';
|
|
3
|
+
export interface UpdateCompanyValuationParams {
|
|
4
|
+
companyValuationReportContractId: string;
|
|
5
|
+
newCompanyValuation: string | number;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateCompanyValuationResult {
|
|
8
|
+
contractId: string;
|
|
9
|
+
updateId: string;
|
|
10
|
+
response: SubmitAndWaitForTransactionTreeResponse;
|
|
11
|
+
}
|
|
12
|
+
/** Update the company valuation on a CompanyValuationReport by exercising SetCompanyValuation. */
|
|
13
|
+
export declare function updateCompanyValuationReport(client: LedgerJsonApiClient, params: UpdateCompanyValuationParams): Promise<UpdateCompanyValuationResult>;
|
|
14
|
+
//# sourceMappingURL=updateCompanyValuationReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyValuationReport.d.ts","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,wEAAwE,CAAC;AAStI,MAAM,WAAW,4BAA4B;IAC3C,gCAAgC,EAAE,MAAM,CAAC;IACzC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,uCAAuC,CAAC;CACnD;AAmBD,kGAAkG;AAClG,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,4BAA4B,CAAC,CAyEvC"}
|
package/dist/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateCompanyValuationReport = updateCompanyValuationReport;
|
|
4
|
+
const findCreatedEvent_1 = require("@fairmint/canton-node-sdk/build/src/utils/contracts/findCreatedEvent");
|
|
5
|
+
const open_captable_protocol_daml_js_1 = require("@fairmint/open-captable-protocol-daml-js");
|
|
6
|
+
const canton_1 = require("@open-captable-protocol/canton");
|
|
7
|
+
function hasSystemOperator(arg) {
|
|
8
|
+
return (Boolean(arg) &&
|
|
9
|
+
typeof arg === 'object' &&
|
|
10
|
+
typeof arg
|
|
11
|
+
.system_operator === 'string');
|
|
12
|
+
}
|
|
13
|
+
/** Update the company valuation on a CompanyValuationReport by exercising SetCompanyValuation. */
|
|
14
|
+
async function updateCompanyValuationReport(client, params) {
|
|
15
|
+
// Determine the acting party (system_operator) from the created event
|
|
16
|
+
const eventsResponse = await client.getEventsByContractId({
|
|
17
|
+
contractId: params.companyValuationReportContractId,
|
|
18
|
+
});
|
|
19
|
+
const createdEvent = eventsResponse.created?.createdEvent;
|
|
20
|
+
if (!createdEvent?.createArgument) {
|
|
21
|
+
throw new canton_1.OcpContractError('Invalid contract events response: missing created event or create argument', {
|
|
22
|
+
contractId: params.companyValuationReportContractId,
|
|
23
|
+
code: canton_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const { createArgument } = createdEvent;
|
|
27
|
+
if (!hasSystemOperator(createArgument)) {
|
|
28
|
+
throw new canton_1.OcpParseError('System operator not found in contract create argument', {
|
|
29
|
+
source: 'CompanyValuationReport.createArgument',
|
|
30
|
+
code: canton_1.OcpErrorCodes.SCHEMA_MISMATCH,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const systemOperator = createArgument.system_operator;
|
|
34
|
+
const choiceArguments = {
|
|
35
|
+
new_company_valuation: typeof params.newCompanyValuation === 'number'
|
|
36
|
+
? params.newCompanyValuation.toString()
|
|
37
|
+
: params.newCompanyValuation,
|
|
38
|
+
};
|
|
39
|
+
const response = await client.submitAndWaitForTransactionTree({
|
|
40
|
+
actAs: [systemOperator],
|
|
41
|
+
commands: [
|
|
42
|
+
{
|
|
43
|
+
ExerciseCommand: {
|
|
44
|
+
templateId: open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport
|
|
45
|
+
.CompanyValuationReport.templateId,
|
|
46
|
+
contractId: params.companyValuationReportContractId,
|
|
47
|
+
choice: 'SetCompanyValuation',
|
|
48
|
+
choiceArgument: choiceArguments,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
const created = (0, findCreatedEvent_1.findCreatedEventByTemplateId)(response, open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport.CompanyValuationReport
|
|
54
|
+
.templateId);
|
|
55
|
+
if (!created) {
|
|
56
|
+
throw new canton_1.OcpContractError('Expected CreatedTreeEvent not found', {
|
|
57
|
+
templateId: open_captable_protocol_daml_js_1.Fairmint.OpenCapTableReports.CompanyValuationReport
|
|
58
|
+
.CompanyValuationReport.templateId,
|
|
59
|
+
choice: 'SetCompanyValuation',
|
|
60
|
+
code: canton_1.OcpErrorCodes.RESULT_NOT_FOUND,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
contractId: created.CreatedTreeEvent.value.contractId,
|
|
65
|
+
updateId: response.transactionTree.updateId,
|
|
66
|
+
response,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=updateCompanyValuationReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateCompanyValuationReport.js","sourceRoot":"","sources":["../../../../src/functions/OpenCapTableReports/companyValuationReport/updateCompanyValuationReport.ts"],"names":[],"mappings":";;AAuCA,oEA4EC;AAjHD,2GAAoH;AACpH,6FAAoE;AACpE,2DAIwC;AAiBxC,SAAS,iBAAiB,CACxB,GAAY;IAIZ,OAAO,CACL,OAAO,CAAC,GAAG,CAAC;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,OAAQ,GAAiD;aACtD,eAAe,KAAK,QAAQ,CAChC,CAAC;AACJ,CAAC;AAED,kGAAkG;AAC3F,KAAK,UAAU,4BAA4B,CAChD,MAA2B,EAC3B,MAAoC;IAEpC,sEAAsE;IACtE,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC;QACxD,UAAU,EAAE,MAAM,CAAC,gCAAgC;KACpD,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC;IAC1D,IAAI,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC;QAClC,MAAM,IAAI,yBAAgB,CACxB,4EAA4E,EAC5E;YACE,UAAU,EAAE,MAAM,CAAC,gCAAgC;YACnD,IAAI,EAAE,sBAAa,CAAC,gBAAgB;SACrC,CACF,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,cAAc,EAAE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,gBAAgB,CAAC,KAAK,CAAC,UAAU;QACrD,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAAC,QAAQ;QAC3C,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/OpenCapTableReports/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./companyValuationReport"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/OpenCapTableReports/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fairmint/canton-fairmint-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.64",
|
|
4
4
|
"description": "Shared SDK utilities for Canton blockchain integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,13 +52,15 @@
|
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@fairmint/canton-node-sdk": "0.0.203",
|
|
54
54
|
"@fairmint/daml-js": ">=0.1.1",
|
|
55
|
-
"@open-captable-protocol
|
|
55
|
+
"@fairmint/open-captable-protocol-daml-js": ">=0.2.160 <0.3.0",
|
|
56
|
+
"@open-captable-protocol/canton": ">=0.5.0 <0.6.0"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@eslint/eslintrc": "3.3.5",
|
|
59
60
|
"@fairmint/canton-node-sdk": "0.0.203",
|
|
60
61
|
"@fairmint/daml-js": "0.1.1",
|
|
61
|
-
"@open-captable-protocol
|
|
62
|
+
"@fairmint/open-captable-protocol-daml-js": "0.2.161",
|
|
63
|
+
"@open-captable-protocol/canton": "0.5.3",
|
|
62
64
|
"@types/jest": "30.0.0",
|
|
63
65
|
"@types/node": "25.6.0",
|
|
64
66
|
"@types/pg": "8.20.0",
|