@open-captable-protocol/canton 0.0.29 → 0.0.30
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/README.md +189 -0
- package/dist/OcpClient.d.ts +2 -1
- package/dist/OcpClient.d.ts.map +1 -1
- package/dist/OcpClient.js +2 -1
- package/dist/OcpClient.js.map +1 -1
- package/dist/functions/issuer/getIssuerAsOcf.d.ts +70 -0
- package/dist/functions/issuer/getIssuerAsOcf.d.ts.map +1 -0
- package/dist/functions/issuer/getIssuerAsOcf.js +89 -0
- package/dist/functions/issuer/getIssuerAsOcf.js.map +1 -0
- package/dist/functions/issuer/index.d.ts +1 -0
- package/dist/functions/issuer/index.d.ts.map +1 -1
- package/dist/functions/issuer/index.js +1 -0
- package/dist/functions/issuer/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# OCP Canton SDK
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with the Open CapTable Protocol (OCP) on Canton blockchain.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @open-captable-protocol/canton
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Setup
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { OcpClient } from '@open-captable-protocol/canton';
|
|
17
|
+
|
|
18
|
+
const client = new OcpClient();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Issuer Operations
|
|
22
|
+
|
|
23
|
+
#### Get Issuer as OCF Object
|
|
24
|
+
|
|
25
|
+
Retrieve an issuer contract by ID and convert it to the Open Cap Table Coalition (OCF) format.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { OcpClient } from '@open-captable-protocol/canton';
|
|
29
|
+
|
|
30
|
+
const client = new OcpClient();
|
|
31
|
+
|
|
32
|
+
// Get issuer as OCF object
|
|
33
|
+
const result = await client.issuer.getIssuerAsOcf({
|
|
34
|
+
contractId: "1234567890abcdef"
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log(result.issuer);
|
|
38
|
+
// {
|
|
39
|
+
// object_type: "ISSUER",
|
|
40
|
+
// legal_name: "My Company Inc.",
|
|
41
|
+
// country_of_formation: "US",
|
|
42
|
+
// formation_date: "2020-01-15",
|
|
43
|
+
// // ... other fields according to OCF schema
|
|
44
|
+
// }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The returned object follows the [OCF Issuer schema](https://schema.opencaptablecoalition.com/v/1.2.0/objects/Issuer.schema.json).
|
|
48
|
+
|
|
49
|
+
#### Create Issuer
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const result = await client.issuer.createIssuer({
|
|
53
|
+
issuerAuthorizationContractDetails: {
|
|
54
|
+
contractId: "auth_contract_id",
|
|
55
|
+
createdEventBlob: "serialized_blob",
|
|
56
|
+
synchronizerId: "sync_id",
|
|
57
|
+
templateId: "template_id"
|
|
58
|
+
},
|
|
59
|
+
featuredAppRightContractDetails: {
|
|
60
|
+
contractId: "featured_contract_id",
|
|
61
|
+
createdEventBlob: "serialized_blob",
|
|
62
|
+
synchronizerId: "sync_id",
|
|
63
|
+
templateId: "template_id"
|
|
64
|
+
},
|
|
65
|
+
issuerParty: "issuer_party_id",
|
|
66
|
+
issuerData: {
|
|
67
|
+
legal_name: "My Company Inc.",
|
|
68
|
+
country_of_formation: "US",
|
|
69
|
+
formation_date: "2020-01-15"
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Update Issuer Data
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
const result = await client.issuer.updateIssuerData({
|
|
78
|
+
issuerContractId: "issuer_contract_id",
|
|
79
|
+
newIssuerData: {
|
|
80
|
+
legal_name: "Updated Company Name",
|
|
81
|
+
country_of_formation: "US"
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### Authorize Issuer
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
const result = await client.issuer.authorizeIssuer({
|
|
90
|
+
issuer: "issuer_party_id"
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Company Valuation Report Operations
|
|
95
|
+
|
|
96
|
+
#### Create Company Valuation Report
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const result = await client.companyValuationReport.createCompanyValuationReport({
|
|
100
|
+
companyId: "company123",
|
|
101
|
+
companyValuation: "1000000",
|
|
102
|
+
observers: ["observer1", "observer2"],
|
|
103
|
+
featuredAppRightContractDetails: {
|
|
104
|
+
contractId: "featured_contract_id",
|
|
105
|
+
createdEventBlob: "serialized_blob",
|
|
106
|
+
synchronizerId: "sync_id",
|
|
107
|
+
templateId: "template_id"
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Update Company Valuation
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
const result = await client.companyValuationReport.updateCompanyValuation({
|
|
116
|
+
companyValuationReportContractId: "report_contract_id",
|
|
117
|
+
newCompanyValuation: "1500000"
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Add Observers to Company Valuation Report
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
const result = await client.companyValuationReport.addObserversToCompanyValuationReport({
|
|
125
|
+
companyValuationReportContractId: "report_contract_id",
|
|
126
|
+
added: ["new_observer1", "new_observer2"]
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Scripts
|
|
131
|
+
|
|
132
|
+
The SDK includes several utility scripts for common operations:
|
|
133
|
+
|
|
134
|
+
### Get Issuer as OCF
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm run script:get-issuer-ocf <issuer-contract-id>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Or set the environment variable:
|
|
141
|
+
```bash
|
|
142
|
+
export ISSUER_CONTRACT_ID="your_contract_id"
|
|
143
|
+
npm run script:get-issuer-ocf
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Create Issuer
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm run script:create-issuer <issuer-auth-contract-id> <legal-name> <country-of-formation> <issuer-auth-created-event-blob> <issuer-auth-synchronizer-id> <issuer-party-id> <featured-app-right-contract-id> <featured-app-right-created-event-blob> <featured-app-right-synchronizer-id> <featured-app-right-template-id>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Authorize Issuer
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm run script:authorize <issuer-party-id>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## OCF Schema Compliance
|
|
159
|
+
|
|
160
|
+
The `getIssuerAsOcf` function returns data that conforms to the [Open Cap Table Coalition Issuer schema](https://schema.opencaptablecoalition.com/v/1.2.0/objects/Issuer.schema.json). The function handles the conversion from DAML types to OCF format, including:
|
|
161
|
+
|
|
162
|
+
- Converting DAML `Optional<T>` types to JavaScript `T | undefined`
|
|
163
|
+
- Mapping field names from DAML conventions to OCF schema requirements
|
|
164
|
+
- Ensuring all required fields are present
|
|
165
|
+
- Using the contract ID as the OCF object ID
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
### Build
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm run build
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Development Mode
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
npm run dev
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Clean
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm run clean
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## License
|
|
188
|
+
|
|
189
|
+
MIT
|
package/dist/OcpClient.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { ClientConfig } from '@fairmint/canton-node-sdk';
|
|
2
|
-
import { AuthorizeIssuerParams, AuthorizeIssuerResult, CreateIssuerParams, CreateIssuerResult, UpdateIssuerDataParams, UpdateIssuerDataResult, CreateCompanyValuationReportParams, CreateCompanyValuationReportResult, UpdateCompanyValuationParams, UpdateCompanyValuationResult, AddObserversToCompanyValuationReportParams, AddObserversToCompanyValuationReportResult } from './functions';
|
|
2
|
+
import { AuthorizeIssuerParams, AuthorizeIssuerResult, CreateIssuerParams, CreateIssuerResult, UpdateIssuerDataParams, UpdateIssuerDataResult, GetIssuerAsOcfParams, GetIssuerAsOcfResult, CreateCompanyValuationReportParams, CreateCompanyValuationReportResult, UpdateCompanyValuationParams, UpdateCompanyValuationResult, AddObserversToCompanyValuationReportParams, AddObserversToCompanyValuationReportResult } from './functions';
|
|
3
3
|
export declare class OcpClient {
|
|
4
4
|
private client;
|
|
5
5
|
issuer: {
|
|
6
6
|
authorizeIssuer: (params: AuthorizeIssuerParams) => Promise<AuthorizeIssuerResult>;
|
|
7
7
|
createIssuer: (params: CreateIssuerParams) => Promise<CreateIssuerResult>;
|
|
8
8
|
updateIssuerData: (params: UpdateIssuerDataParams) => Promise<UpdateIssuerDataResult>;
|
|
9
|
+
getIssuerAsOcf: (params: GetIssuerAsOcfParams) => Promise<GetIssuerAsOcfResult>;
|
|
9
10
|
};
|
|
10
11
|
companyValuationReport: {
|
|
11
12
|
createCompanyValuationReport: (params: CreateCompanyValuationReportParams) => Promise<CreateCompanyValuationReportResult>;
|
package/dist/OcpClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OcpClient.d.ts","sourceRoot":"","sources":["../src/OcpClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAmB,qBAAqB,EAAE,qBAAqB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AC,0CAA0C,CAAC,CAAC;KAC1D,CAAC;gBAEU,MAAM,CAAC,EAAE,YAAY;CAoBlC"}
|
package/dist/OcpClient.js
CHANGED
|
@@ -9,7 +9,8 @@ class OcpClient {
|
|
|
9
9
|
this.issuer = {
|
|
10
10
|
authorizeIssuer: (params) => (0, functions_1.authorizeIssuer)(this.client, params),
|
|
11
11
|
createIssuer: (params) => (0, functions_1.createIssuer)(this.client, params),
|
|
12
|
-
updateIssuerData: (params) => (0, functions_1.updateIssuerData)(this.client, params)
|
|
12
|
+
updateIssuerData: (params) => (0, functions_1.updateIssuerData)(this.client, params),
|
|
13
|
+
getIssuerAsOcf: (params) => (0, functions_1.getIssuerAsOcf)(this.client, params)
|
|
13
14
|
};
|
|
14
15
|
this.companyValuationReport = {
|
|
15
16
|
createCompanyValuationReport: (params) => (0, functions_1.createCompanyValuationReport)(this.client, params),
|
package/dist/OcpClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OcpClient.js","sourceRoot":"","sources":["../src/OcpClient.ts"],"names":[],"mappings":";;;AAAA,+DAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"OcpClient.js","sourceRoot":"","sources":["../src/OcpClient.ts"],"names":[],"mappings":";;;AAAA,+DAA8E;AAC9E,2CAAukB;AAEvkB,MAAa,SAAS;IAsBpB,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,qCAAmB,CAAC,MAAM,CAAC,CAAC;QAE9C,IAAI,CAAC,MAAM,GAAG;YACZ,eAAe,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,IAAA,2BAAe,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YACxF,YAAY,EAAE,CAAC,MAA0B,EAAE,EAAE,CAAC,IAAA,wBAAY,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YAC/E,gBAAgB,EAAE,CAAC,MAA8B,EAAE,EAAE,CAAC,IAAA,4BAAgB,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YAC3F,cAAc,EAAE,CAAC,MAA4B,EAAE,EAAE,CAAC,IAAA,0BAAc,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;SACtF,CAAC;QAEF,IAAI,CAAC,sBAAsB,GAAG;YAC5B,4BAA4B,EAAE,CAAC,MAA0C,EAAE,EAAE,CAC3E,IAAA,wCAA4B,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YACnD,sBAAsB,EAAE,CAAC,MAAoC,EAAE,EAAE,CAC/D,IAAA,kCAAsB,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;YAC7C,oCAAoC,EAAE,CACpC,MAAkD,EAClD,EAAE,CAAC,IAAA,gDAAoC,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF;AA1CD,8BA0CC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { LedgerJsonApiClient } from '@fairmint/canton-node-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* OCF Issuer object according to the Open Cap Table Coalition schema
|
|
4
|
+
* @see https://schema.opencaptablecoalition.com/v/1.2.0/objects/Issuer.schema.json
|
|
5
|
+
*/
|
|
6
|
+
export interface OcfIssuer {
|
|
7
|
+
object_type: 'ISSUER';
|
|
8
|
+
legal_name: string;
|
|
9
|
+
dba?: string;
|
|
10
|
+
formation_date?: string;
|
|
11
|
+
country_of_formation: string;
|
|
12
|
+
country_subdivision_of_formation?: string;
|
|
13
|
+
tax_ids?: Array<{
|
|
14
|
+
tax_id_type: string;
|
|
15
|
+
tax_id: string;
|
|
16
|
+
}>;
|
|
17
|
+
email?: string;
|
|
18
|
+
phone?: string;
|
|
19
|
+
address?: {
|
|
20
|
+
line1?: string;
|
|
21
|
+
line2?: string;
|
|
22
|
+
city?: string;
|
|
23
|
+
state?: string;
|
|
24
|
+
postal_code?: string;
|
|
25
|
+
country?: string;
|
|
26
|
+
};
|
|
27
|
+
initial_shares_authorized?: string | number;
|
|
28
|
+
id?: string;
|
|
29
|
+
comments?: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface GetIssuerAsOcfParams {
|
|
32
|
+
/** Contract ID of the Issuer contract to retrieve */
|
|
33
|
+
contractId: string;
|
|
34
|
+
}
|
|
35
|
+
export interface GetIssuerAsOcfResult {
|
|
36
|
+
/** The OCF Issuer object */
|
|
37
|
+
issuer: OcfIssuer;
|
|
38
|
+
/** The original contract ID */
|
|
39
|
+
contractId: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve an issuer contract by ID and return it as an OCF JSON object
|
|
43
|
+
*
|
|
44
|
+
* This function fetches the issuer contract data from the ledger and transforms it
|
|
45
|
+
* into the Open Cap Table Coalition (OCF) format according to the official schema.
|
|
46
|
+
*
|
|
47
|
+
* @see https://schema.opencaptablecoalition.com/v/1.2.0/objects/Issuer.schema.json
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const result = await getIssuerAsOcf(client, {
|
|
52
|
+
* contractId: "1234567890abcdef"
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* console.log(result.issuer);
|
|
56
|
+
* // {
|
|
57
|
+
* // object_type: "ISSUER",
|
|
58
|
+
* // legal_name: "My Company Inc.",
|
|
59
|
+
* // country_of_formation: "US",
|
|
60
|
+
* // formation_date: "2020-01-15",
|
|
61
|
+
* // // ... other fields
|
|
62
|
+
* // }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param client - The ledger JSON API client
|
|
66
|
+
* @param params - Parameters for retrieving the issuer
|
|
67
|
+
* @returns Promise resolving to the OCF Issuer object
|
|
68
|
+
*/
|
|
69
|
+
export declare function getIssuerAsOcf(client: LedgerJsonApiClient, params: GetIssuerAsOcfParams): Promise<GetIssuerAsOcfResult>;
|
|
70
|
+
//# sourceMappingURL=getIssuerAsOcf.d.ts.map
|
|
@@ -0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,cAAc,CAClC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAgE/B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIssuerAsOcf = getIssuerAsOcf;
|
|
4
|
+
/**
|
|
5
|
+
* Retrieve an issuer contract by ID and return it as an OCF JSON object
|
|
6
|
+
*
|
|
7
|
+
* This function fetches the issuer contract data from the ledger and transforms it
|
|
8
|
+
* into the Open Cap Table Coalition (OCF) format according to the official schema.
|
|
9
|
+
*
|
|
10
|
+
* @see https://schema.opencaptablecoalition.com/v/1.2.0/objects/Issuer.schema.json
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const result = await getIssuerAsOcf(client, {
|
|
15
|
+
* contractId: "1234567890abcdef"
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* console.log(result.issuer);
|
|
19
|
+
* // {
|
|
20
|
+
* // object_type: "ISSUER",
|
|
21
|
+
* // legal_name: "My Company Inc.",
|
|
22
|
+
* // country_of_formation: "US",
|
|
23
|
+
* // formation_date: "2020-01-15",
|
|
24
|
+
* // // ... other fields
|
|
25
|
+
* // }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param client - The ledger JSON API client
|
|
29
|
+
* @param params - Parameters for retrieving the issuer
|
|
30
|
+
* @returns Promise resolving to the OCF Issuer object
|
|
31
|
+
*/
|
|
32
|
+
async function getIssuerAsOcf(client, params) {
|
|
33
|
+
// Get the events for the Issuer contract
|
|
34
|
+
const eventsResponse = await client.getEventsByContractId({
|
|
35
|
+
contractId: params.contractId
|
|
36
|
+
});
|
|
37
|
+
if (!eventsResponse.created?.createdEvent?.createArgument) {
|
|
38
|
+
throw new Error('Invalid contract events response: missing created event or create argument');
|
|
39
|
+
}
|
|
40
|
+
const createArgument = eventsResponse.created.createdEvent.createArgument;
|
|
41
|
+
// Type guard to ensure we have the expected issuer data structure
|
|
42
|
+
function hasIssuerData(arg) {
|
|
43
|
+
return typeof arg === 'object' &&
|
|
44
|
+
arg !== null &&
|
|
45
|
+
'issuer_data' in arg &&
|
|
46
|
+
typeof arg.issuer_data === 'object';
|
|
47
|
+
}
|
|
48
|
+
if (!hasIssuerData(createArgument)) {
|
|
49
|
+
throw new Error('Issuer data not found in contract create argument');
|
|
50
|
+
}
|
|
51
|
+
const issuerData = createArgument.issuer_data;
|
|
52
|
+
// Helper function to convert DAML Optional to JavaScript undefined
|
|
53
|
+
const toUndefined = (value) => value === null ? undefined : value;
|
|
54
|
+
// Transform DAML issuer data to OCF format
|
|
55
|
+
const ocfIssuer = {
|
|
56
|
+
object_type: 'ISSUER',
|
|
57
|
+
legal_name: issuerData.legal_name || '',
|
|
58
|
+
country_of_formation: issuerData.country_of_formation || '',
|
|
59
|
+
// Optional fields
|
|
60
|
+
...(issuerData.dba && { dba: issuerData.dba }),
|
|
61
|
+
...(issuerData.formation_date && { formation_date: issuerData.formation_date }),
|
|
62
|
+
...(issuerData.country_subdivision_of_formation && {
|
|
63
|
+
country_subdivision_of_formation: issuerData.country_subdivision_of_formation
|
|
64
|
+
}),
|
|
65
|
+
...(issuerData.tax_ids && { tax_ids: issuerData.tax_ids }),
|
|
66
|
+
...(issuerData.email && { email: issuerData.email }),
|
|
67
|
+
...(issuerData.phone && { phone: issuerData.phone }),
|
|
68
|
+
...(issuerData.address && {
|
|
69
|
+
address: {
|
|
70
|
+
...(issuerData.address.line1 && { line1: toUndefined(issuerData.address.line1) }),
|
|
71
|
+
...(issuerData.address.line2 && { line2: toUndefined(issuerData.address.line2) }),
|
|
72
|
+
...(issuerData.address.city && { city: toUndefined(issuerData.address.city) }),
|
|
73
|
+
...(issuerData.address.state && { state: toUndefined(issuerData.address.state) }),
|
|
74
|
+
...(issuerData.address.postal_code && { postal_code: toUndefined(issuerData.address.postal_code) }),
|
|
75
|
+
...(issuerData.address.country && { country: toUndefined(issuerData.address.country) })
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
...(issuerData.initial_shares_authorized && {
|
|
79
|
+
initial_shares_authorized: issuerData.initial_shares_authorized
|
|
80
|
+
}),
|
|
81
|
+
// Use contract ID as the OCF object ID
|
|
82
|
+
id: params.contractId
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
issuer: ocfIssuer,
|
|
86
|
+
contractId: params.contractId
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=getIssuerAsOcf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getIssuerAsOcf.js","sourceRoot":"","sources":["../../../src/functions/issuer/getIssuerAsOcf.ts"],"names":[],"mappings":";;AAyEA,wCAmEC;AA/FD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,UAAU,cAAc,CAClC,MAA2B,EAC3B,MAA4B;IAE5B,yCAAyC;IACzC,MAAM,cAAc,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC;QACxD,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC,CAAC;IAEH,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAChG,CAAC;IAED,MAAM,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC;IAE1E,kEAAkE;IAClE,SAAS,aAAa,CAAC,GAAY;QACjC,OAAO,OAAO,GAAG,KAAK,QAAQ;YACvB,GAAG,KAAK,IAAI;YACZ,aAAa,IAAI,GAAG;YACpB,OAAQ,GAAW,CAAC,WAAW,KAAK,QAAQ,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,mD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C,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjF,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC9E,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjF,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,WAAW,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;gBACnG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;aACxF;SACF,CAAC;QACF,GAAG,CAAC,UAAU,CAAC,yBAAyB,IAAI;YAC1C,yBAAyB,EAAE,UAAU,CAAC,yBAAyB;SAChE,CAAC;QACF,uCAAuC;QACvC,EAAE,EAAE,MAAM,CAAC,UAAU;KACtB,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/issuer/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/functions/issuer/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./authorizeIssuer"), exports);
|
|
18
18
|
__exportStar(require("./createIssuer"), exports);
|
|
19
19
|
__exportStar(require("./updateIssuerData"), exports);
|
|
20
|
+
__exportStar(require("./getIssuerAsOcf"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/issuer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/issuer/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-captable-protocol/canton",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"description": "A TypeScript SDK for interacting with the Open CapTable Protocol (OCP) Factory contract on Canton blockchain",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"dev": "tsc --watch",
|
|
14
14
|
"clean": "rm -rf dist",
|
|
15
15
|
"script:authorize": "ts-node scripts/authorizeIssuer.ts",
|
|
16
|
-
"script:create-issuer": "ts-node scripts/createIssuer.ts"
|
|
16
|
+
"script:create-issuer": "ts-node scripts/createIssuer.ts",
|
|
17
|
+
"script:get-issuer-ocf": "ts-node scripts/getIssuerAsOcf.ts"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@daml/ledger": "^2.10.2",
|