@open-captable-protocol/canton 0.0.30 → 0.0.31
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIssuerAsOcf.d.ts","sourceRoot":"","sources":["../../../src/functions/issuer/getIssuerAsOcf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,QAAQ,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"getIssuerAsOcf.d.ts","sourceRoot":"","sources":["../../../src/functions/issuer/getIssuerAsOcf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,QAAQ,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE;QACN,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;QACpC,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5C,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,4BAA4B;IAC5B,MAAM,EAAE,SAAS,CAAC;IAClB,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,mBAAmB,EAC3B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAiF/B"}
|
|
@@ -51,6 +51,17 @@ async function getIssuerAsOcf(client, params) {
|
|
|
51
51
|
const issuerData = createArgument.issuer_data;
|
|
52
52
|
// Helper function to convert DAML Optional to JavaScript undefined
|
|
53
53
|
const toUndefined = (value) => value === null ? undefined : value;
|
|
54
|
+
// Helper function to convert DAML email type to OCF schema email type
|
|
55
|
+
const convertEmailType = (damlEmailType) => {
|
|
56
|
+
switch (damlEmailType) {
|
|
57
|
+
case 'OcfEmailTypePersonal':
|
|
58
|
+
return 'PERSONAL';
|
|
59
|
+
case 'OcfEmailTypeBusiness':
|
|
60
|
+
return 'BUSINESS';
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Unknown email type: ${damlEmailType}`);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
54
65
|
// Transform DAML issuer data to OCF format
|
|
55
66
|
const ocfIssuer = {
|
|
56
67
|
object_type: 'ISSUER',
|
|
@@ -63,7 +74,12 @@ async function getIssuerAsOcf(client, params) {
|
|
|
63
74
|
country_subdivision_of_formation: issuerData.country_subdivision_of_formation
|
|
64
75
|
}),
|
|
65
76
|
...(issuerData.tax_ids && { tax_ids: issuerData.tax_ids }),
|
|
66
|
-
...(issuerData.email && {
|
|
77
|
+
...(issuerData.email && {
|
|
78
|
+
email: {
|
|
79
|
+
email_type: convertEmailType(issuerData.email.email_type),
|
|
80
|
+
email_address: issuerData.email.email_address
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
67
83
|
...(issuerData.phone && { phone: issuerData.phone }),
|
|
68
84
|
...(issuerData.address && {
|
|
69
85
|
address: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIssuerAsOcf.js","sourceRoot":"","sources":["../../../src/functions/issuer/getIssuerAsOcf.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"getIssuerAsOcf.js","sourceRoot":"","sources":["../../../src/functions/issuer/getIssuerAsOcf.ts"],"names":[],"mappings":";;AA4EA,wCAoFC;AAhHD;;;;;;;;;;;;;;;;;;;;;;;;;;;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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AAC,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"}
|
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.31",
|
|
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",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"@daml/ledger": "^2.10.2",
|
|
21
21
|
"@daml/types": "^2.10.2",
|
|
22
22
|
"@fairmint/canton-node-sdk": "^0.0.85",
|
|
23
|
-
"@fairmint/open-captable-protocol-daml-js": "^0.0.
|
|
23
|
+
"@fairmint/open-captable-protocol-daml-js": "^0.0.36"
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
"devDependencies": {
|
package/README.md
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
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
|