forked from Open-Captable-Protocol/ocp
-
Notifications
You must be signed in to change notification settings - Fork 1
POC Canton demo integration #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
57497a1
POC Canton demo integration
HardlyDifficult 9e51b4e
Ignores Canton chain
HardlyDifficult aafd1b6
Switch to submodules
HardlyDifficult 6a94d28
Update submodule
HardlyDifficult 2610cab
Bump dep
HardlyDifficult 9bd6b42
Canton env config
HardlyDifficult 5dde47d
Stub create stakeholders
HardlyDifficult c17a8be
Complete issuer/create POC
HardlyDifficult 7c5468c
Rename var
HardlyDifficult 3c86522
CAIP-7 TODO
HardlyDifficult 0283778
Save issuerContractId
HardlyDifficult 92e4c2b
Switch to partyId
HardlyDifficult a9a1806
Save stakeholder
HardlyDifficult 225a0bf
Create stock class
HardlyDifficult 522d179
Create issuance
HardlyDifficult 63b32d8
Transfer
HardlyDifficult 785a636
Bump lib
HardlyDifficult 29b23fa
Bug fixes
HardlyDifficult 40b1fca
Fix
HardlyDifficult 53fd589
Fix
HardlyDifficult 2435acd
Error checking
HardlyDifficult 492cc19
Add error checks
HardlyDifficult f17fa68
Bug fix
HardlyDifficult 2db3398
Bump for mainnet
HardlyDifficult aa4597c
Bump to mainnet
HardlyDifficult File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { TransferAgentConfig } from "./lib/fairmint-canton/scripts/src/helpers/config"; | ||
| import { FairmintClient } from "./lib/fairmint-canton/scripts/src/helpers/fairmintClient"; | ||
|
|
||
| const config = new TransferAgentConfig(true); | ||
| const client = new FairmintClient(config); | ||
|
|
||
| export { config, client }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // TODO https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-7.md | ||
| // Once changed from chainId: number to CAIP-7: string, use `canton:mainnet` and `canton:devnet` | ||
|
|
||
| export const CANTON_MAINNET_CHAIN_ID = 6765788401; | ||
| export const CANTON_DEVNET_CHAIN_ID = 6765788402; | ||
|
|
||
| export function isCantonChainId(chainId) { | ||
| return chainId == CANTON_MAINNET_CHAIN_ID || chainId == CANTON_DEVNET_CHAIN_ID; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { client } from "./clientConfig"; | ||
|
|
||
| // eslint-disable-next-line no-unused-vars | ||
| export async function deployCapTableCanton(issuerId, initial_shares_authorized, chainId, issuer) { | ||
| console.log("🗽 | Deploying cap table on Canton..."); | ||
|
|
||
| // Create FairmintAdminService [One time] | ||
| const { contractId } = await client.createFairmintAdminService(); | ||
|
|
||
| // Create new party for issuer [Once per issuer] | ||
| const { partyId: issuerPartyId } = await client.createParty(issuerId); | ||
|
|
||
| // Authorize issuer [Once per issuer] | ||
| const authorizationContractId = await client.authorizeIssuer(contractId, issuerPartyId); | ||
|
|
||
| // Issuer accepts authorization [Once per issuer] | ||
| const issuerContractId = await client.acceptIssuerAuthorization( | ||
| authorizationContractId, | ||
| issuer.legal_name, | ||
| initial_shares_authorized, | ||
| issuerPartyId | ||
| ); | ||
|
|
||
| return { | ||
| partyId: issuerPartyId, | ||
| // deployId: updateId, // TODO | ||
| address: issuerContractId, | ||
| }; | ||
| } |
Submodule fairmint-canton
added at
9be911
11 changes: 11 additions & 0 deletions
11
src/chain-operations/canton/stakeholderControllerCanton.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { client } from "./clientConfig"; | ||
|
|
||
| // eslint-disable-next-line no-unused-vars | ||
| export const convertAndReflectStakeholderOnchainCanton = async (stakeholderId) => { | ||
| console.log("🗽 | Converting and reflecting stakeholder onchain Canton..."); | ||
|
|
||
| // Create new party for stakeholder [Once per stakeholder] | ||
| const { partyId } = await client.createParty(stakeholderId); | ||
|
|
||
| return { partyId, updateId: null /* TODO */ }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { client } from "./clientConfig"; | ||
|
|
||
| export const convertAndReflectStockClassOnchainCanton = async (stockClass, issuer) => { | ||
| const classType = stockClass.class_type === "COMMON" ? "Common" : "Unknown"; | ||
| const { stockClassContractId, updatedIssuerContractId } = await client.createStockClass( | ||
| issuer.deployed_to, | ||
| classType, | ||
| stockClass.initial_shares_authorized, | ||
| issuer.party_id | ||
| ); | ||
|
|
||
| return { stockClassContractId, updatedIssuerContractId }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { client } from "./clientConfig"; | ||
|
|
||
| export const convertAndCreateTransferStockOnchainCanton = async (contract, transfer) => { | ||
| const { transferorPartyId, transferorStockPositionContractId, transfereePartyId, quantity } = transfer; | ||
|
|
||
| // Transferer proposes share transfer to transferee | ||
| const { transferProposalContractId, updatedStockPositionContractId } = await client.proposeTransfer( | ||
| transferorStockPositionContractId, | ||
| transfereePartyId, | ||
| quantity, | ||
| transferorPartyId | ||
| ); | ||
|
|
||
| // Transferee accepts the transfer proposal and receives shares | ||
| const transfereeStockPositionContractId = await client.acceptTransfer(transferProposalContractId, transfereePartyId); | ||
|
|
||
| return { | ||
| transferorUpdatedStockPositionContractId: updatedStockPositionContractId, | ||
| transfereeStockPositionContractId: transfereeStockPositionContractId, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { client } from "./canton/clientConfig"; | ||
|
|
||
| export const convertAndCreateIssuanceStockOnchainCanton = async ({ stockClassContractId, stakeholderPartyId, quantity, issuerPartyId }) => { | ||
| // Issuer proposes quantity shares to stakeholder | ||
| const { proposalContractId, updatedStockClassContractId } = await client.proposeIssueStock( | ||
| stockClassContractId, | ||
| stakeholderPartyId, | ||
| quantity, | ||
| issuerPartyId | ||
| ); | ||
|
|
||
| // Stakeholder accepts the proposal and receives shares | ||
| const stakeholderStockPositionContractId = await client.acceptIssueStockProposal(proposalContractId, stakeholderPartyId); | ||
|
|
||
| return { | ||
| stakeholderStockPositionContractId, | ||
| updatedStockClassContractId, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.