@polymeshassociation/polymesh-sdk 14.0.0-beta.11
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/AccountManagement.d.ts +89 -0
- package/AccountManagement.d.ts.map +1 -0
- package/AccountManagement.js +116 -0
- package/AccountManagement.js.map +1 -0
- package/Assets.d.ts +68 -0
- package/Assets.d.ts.map +1 -0
- package/Assets.js +114 -0
- package/Assets.js.map +1 -0
- package/CHANGELOG.md +6 -0
- package/Claims.d.ts +123 -0
- package/Claims.d.ts.map +1 -0
- package/Claims.js +247 -0
- package/Claims.js.map +1 -0
- package/Identities.d.ts +45 -0
- package/Identities.d.ts.map +1 -0
- package/Identities.js +34 -0
- package/Identities.js.map +1 -0
- package/Network.d.ts +104 -0
- package/Network.d.ts.map +1 -0
- package/Network.js +203 -0
- package/Network.js.map +1 -0
- package/Polymesh.d.ts +111 -0
- package/Polymesh.d.ts.map +1 -0
- package/Polymesh.js +219 -0
- package/Polymesh.js.map +1 -0
- package/Settlements.d.ts +44 -0
- package/Settlements.d.ts.map +1 -0
- package/Settlements.js +93 -0
- package/Settlements.js.map +1 -0
- package/api/entities/Account.d.ts +102 -0
- package/api/entities/Account.d.ts.map +1 -0
- package/api/entities/Account.js +375 -0
- package/api/entities/Account.js.map +1 -0
- package/api/entities/Asset/AssetHolders.d.ts +14 -0
- package/api/entities/Asset/AssetHolders.d.ts.map +1 -0
- package/api/entities/Asset/AssetHolders.js +45 -0
- package/api/entities/Asset/AssetHolders.js.map +1 -0
- package/api/entities/Asset/Checkpoints/Schedules.d.ts +50 -0
- package/api/entities/Asset/Checkpoints/Schedules.d.ts.map +1 -0
- package/api/entities/Asset/Checkpoints/Schedules.js +103 -0
- package/api/entities/Asset/Checkpoints/Schedules.js.map +1 -0
- package/api/entities/Asset/Checkpoints/index.d.ts +33 -0
- package/api/entities/Asset/Checkpoints/index.d.ts.map +1 -0
- package/api/entities/Asset/Checkpoints/index.js +90 -0
- package/api/entities/Asset/Checkpoints/index.js.map +1 -0
- package/api/entities/Asset/Checkpoints/types.d.ts +20 -0
- package/api/entities/Asset/Checkpoints/types.d.ts.map +1 -0
- package/api/entities/Asset/Checkpoints/types.js +9 -0
- package/api/entities/Asset/Checkpoints/types.js.map +1 -0
- package/api/entities/Asset/Compliance/Requirements.d.ts +68 -0
- package/api/entities/Asset/Compliance/Requirements.d.ts.map +1 -0
- package/api/entities/Asset/Compliance/Requirements.js +114 -0
- package/api/entities/Asset/Compliance/Requirements.js.map +1 -0
- package/api/entities/Asset/Compliance/TrustedClaimIssuers.d.ts +33 -0
- package/api/entities/Asset/Compliance/TrustedClaimIssuers.d.ts.map +1 -0
- package/api/entities/Asset/Compliance/TrustedClaimIssuers.js +70 -0
- package/api/entities/Asset/Compliance/TrustedClaimIssuers.js.map +1 -0
- package/api/entities/Asset/Compliance/index.d.ts +15 -0
- package/api/entities/Asset/Compliance/index.d.ts.map +1 -0
- package/api/entities/Asset/Compliance/index.js +21 -0
- package/api/entities/Asset/Compliance/index.js.map +1 -0
- package/api/entities/Asset/CorporateActions/Distributions.d.ts +32 -0
- package/api/entities/Asset/CorporateActions/Distributions.d.ts.map +1 -0
- package/api/entities/Asset/CorporateActions/Distributions.js +74 -0
- package/api/entities/Asset/CorporateActions/Distributions.js.map +1 -0
- package/api/entities/Asset/CorporateActions/index.d.ts +58 -0
- package/api/entities/Asset/CorporateActions/index.d.ts.map +1 -0
- package/api/entities/Asset/CorporateActions/index.js +85 -0
- package/api/entities/Asset/CorporateActions/index.js.map +1 -0
- package/api/entities/Asset/CorporateActions/types.d.ts +8 -0
- package/api/entities/Asset/CorporateActions/types.d.ts.map +1 -0
- package/api/entities/Asset/CorporateActions/types.js +3 -0
- package/api/entities/Asset/CorporateActions/types.js.map +1 -0
- package/api/entities/Asset/Documents.d.ts +24 -0
- package/api/entities/Asset/Documents.d.ts.map +1 -0
- package/api/entities/Asset/Documents.js +49 -0
- package/api/entities/Asset/Documents.js.map +1 -0
- package/api/entities/Asset/Issuance.d.ts +21 -0
- package/api/entities/Asset/Issuance.d.ts.map +1 -0
- package/api/entities/Asset/Issuance.js +20 -0
- package/api/entities/Asset/Issuance.js.map +1 -0
- package/api/entities/Asset/Offerings.d.ts +37 -0
- package/api/entities/Asset/Offerings.d.ts.map +1 -0
- package/api/entities/Asset/Offerings.js +79 -0
- package/api/entities/Asset/Offerings.js.map +1 -0
- package/api/entities/Asset/Permissions.d.ts +50 -0
- package/api/entities/Asset/Permissions.d.ts.map +1 -0
- package/api/entities/Asset/Permissions.js +83 -0
- package/api/entities/Asset/Permissions.js.map +1 -0
- package/api/entities/Asset/Settlements.d.ts +48 -0
- package/api/entities/Asset/Settlements.d.ts.map +1 -0
- package/api/entities/Asset/Settlements.js +108 -0
- package/api/entities/Asset/Settlements.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/Count.d.ts +36 -0
- package/api/entities/Asset/TransferRestrictions/Count.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/Count.js +16 -0
- package/api/entities/Asset/TransferRestrictions/Count.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/Percentage.d.ts +36 -0
- package/api/entities/Asset/TransferRestrictions/Percentage.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/Percentage.js +16 -0
- package/api/entities/Asset/TransferRestrictions/Percentage.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.d.ts +44 -0
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.js +99 -0
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/index.d.ts +15 -0
- package/api/entities/Asset/TransferRestrictions/index.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/index.js +21 -0
- package/api/entities/Asset/TransferRestrictions/index.js.map +1 -0
- package/api/entities/Asset/index.d.ts +166 -0
- package/api/entities/Asset/index.d.ts.map +1 -0
- package/api/entities/Asset/index.js +306 -0
- package/api/entities/Asset/index.js.map +1 -0
- package/api/entities/Asset/types.d.ts +55 -0
- package/api/entities/Asset/types.d.ts.map +1 -0
- package/api/entities/Asset/types.js +19 -0
- package/api/entities/Asset/types.js.map +1 -0
- package/api/entities/AuthorizationRequest.d.ts +95 -0
- package/api/entities/AuthorizationRequest.d.ts.map +1 -0
- package/api/entities/AuthorizationRequest.js +128 -0
- package/api/entities/AuthorizationRequest.js.map +1 -0
- package/api/entities/Checkpoint.d.ts +71 -0
- package/api/entities/Checkpoint.d.ts.map +1 -0
- package/api/entities/Checkpoint.js +180 -0
- package/api/entities/Checkpoint.js.map +1 -0
- package/api/entities/CheckpointSchedule/index.d.ts +83 -0
- package/api/entities/CheckpointSchedule/index.d.ts.map +1 -0
- package/api/entities/CheckpointSchedule/index.js +137 -0
- package/api/entities/CheckpointSchedule/index.js.map +1 -0
- package/api/entities/CheckpointSchedule/types.d.ts +8 -0
- package/api/entities/CheckpointSchedule/types.d.ts.map +1 -0
- package/api/entities/CheckpointSchedule/types.js +3 -0
- package/api/entities/CheckpointSchedule/types.js.map +1 -0
- package/api/entities/CorporateAction.d.ts +40 -0
- package/api/entities/CorporateAction.d.ts.map +1 -0
- package/api/entities/CorporateAction.js +25 -0
- package/api/entities/CorporateAction.js.map +1 -0
- package/api/entities/CorporateActionBase/index.d.ts +106 -0
- package/api/entities/CorporateActionBase/index.d.ts.map +1 -0
- package/api/entities/CorporateActionBase/index.js +134 -0
- package/api/entities/CorporateActionBase/index.js.map +1 -0
- package/api/entities/CorporateActionBase/types.d.ts +30 -0
- package/api/entities/CorporateActionBase/types.d.ts.map +1 -0
- package/api/entities/CorporateActionBase/types.js +17 -0
- package/api/entities/CorporateActionBase/types.js.map +1 -0
- package/api/entities/CustomPermissionGroup.d.ts +43 -0
- package/api/entities/CustomPermissionGroup.d.ts.map +1 -0
- package/api/entities/CustomPermissionGroup.js +81 -0
- package/api/entities/CustomPermissionGroup.js.map +1 -0
- package/api/entities/DefaultPortfolio.d.ts +18 -0
- package/api/entities/DefaultPortfolio.d.ts.map +1 -0
- package/api/entities/DefaultPortfolio.js +35 -0
- package/api/entities/DefaultPortfolio.js.map +1 -0
- package/api/entities/DefaultTrustedClaimIssuer.d.ts +36 -0
- package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -0
- package/api/entities/DefaultTrustedClaimIssuer.js +88 -0
- package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -0
- package/api/entities/DividendDistribution/index.d.ts +158 -0
- package/api/entities/DividendDistribution/index.d.ts.map +1 -0
- package/api/entities/DividendDistribution/index.js +346 -0
- package/api/entities/DividendDistribution/index.js.map +1 -0
- package/api/entities/DividendDistribution/types.d.ts +24 -0
- package/api/entities/DividendDistribution/types.d.ts.map +1 -0
- package/api/entities/DividendDistribution/types.js +3 -0
- package/api/entities/DividendDistribution/types.js.map +1 -0
- package/api/entities/Entity.d.ts +43 -0
- package/api/entities/Entity.d.ts.map +1 -0
- package/api/entities/Entity.js +58 -0
- package/api/entities/Entity.js.map +1 -0
- package/api/entities/Identity/AssetPermissions.d.ts +76 -0
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -0
- package/api/entities/Identity/AssetPermissions.js +284 -0
- package/api/entities/Identity/AssetPermissions.js.map +1 -0
- package/api/entities/Identity/IdentityAuthorizations.d.ts +23 -0
- package/api/entities/Identity/IdentityAuthorizations.d.ts.map +1 -0
- package/api/entities/Identity/IdentityAuthorizations.js +79 -0
- package/api/entities/Identity/IdentityAuthorizations.js.map +1 -0
- package/api/entities/Identity/Portfolios.d.ts +43 -0
- package/api/entities/Identity/Portfolios.d.ts.map +1 -0
- package/api/entities/Identity/Portfolios.js +107 -0
- package/api/entities/Identity/Portfolios.js.map +1 -0
- package/api/entities/Identity/index.d.ts +152 -0
- package/api/entities/Identity/index.d.ts.map +1 -0
- package/api/entities/Identity/index.js +430 -0
- package/api/entities/Identity/index.js.map +1 -0
- package/api/entities/Instruction/index.d.ts +91 -0
- package/api/entities/Instruction/index.d.ts.map +1 -0
- package/api/entities/Instruction/index.js +261 -0
- package/api/entities/Instruction/index.js.map +1 -0
- package/api/entities/Instruction/types.d.ts +52 -0
- package/api/entities/Instruction/types.d.ts.map +1 -0
- package/api/entities/Instruction/types.js +21 -0
- package/api/entities/Instruction/types.js.map +1 -0
- package/api/entities/KnownPermissionGroup.d.ts +38 -0
- package/api/entities/KnownPermissionGroup.d.ts.map +1 -0
- package/api/entities/KnownPermissionGroup.js +100 -0
- package/api/entities/KnownPermissionGroup.js.map +1 -0
- package/api/entities/Namespace.d.ts +15 -0
- package/api/entities/Namespace.d.ts.map +1 -0
- package/api/entities/Namespace.js +19 -0
- package/api/entities/Namespace.js.map +1 -0
- package/api/entities/NumberedPortfolio.d.ts +48 -0
- package/api/entities/NumberedPortfolio.d.ts.map +1 -0
- package/api/entities/NumberedPortfolio.js +95 -0
- package/api/entities/NumberedPortfolio.js.map +1 -0
- package/api/entities/Offering/index.d.ts +93 -0
- package/api/entities/Offering/index.d.ts.map +1 -0
- package/api/entities/Offering/index.js +135 -0
- package/api/entities/Offering/index.js.map +1 -0
- package/api/entities/Offering/types.d.ts +83 -0
- package/api/entities/Offering/types.d.ts.map +1 -0
- package/api/entities/Offering/types.js +55 -0
- package/api/entities/Offering/types.js.map +1 -0
- package/api/entities/PermissionGroup.d.ts +26 -0
- package/api/entities/PermissionGroup.d.ts.map +1 -0
- package/api/entities/PermissionGroup.js +19 -0
- package/api/entities/PermissionGroup.js.map +1 -0
- package/api/entities/Portfolio/index.d.ts +112 -0
- package/api/entities/Portfolio/index.d.ts.map +1 -0
- package/api/entities/Portfolio/index.js +246 -0
- package/api/entities/Portfolio/index.js.map +1 -0
- package/api/entities/Portfolio/types.d.ts +21 -0
- package/api/entities/Portfolio/types.d.ts.map +1 -0
- package/api/entities/Portfolio/types.js +3 -0
- package/api/entities/Portfolio/types.js.map +1 -0
- package/api/entities/Subsidy/index.d.ts +80 -0
- package/api/entities/Subsidy/index.d.ts.map +1 -0
- package/api/entities/Subsidy/index.js +97 -0
- package/api/entities/Subsidy/index.js.map +1 -0
- package/api/entities/Subsidy/types.d.ts +21 -0
- package/api/entities/Subsidy/types.d.ts.map +1 -0
- package/api/entities/Subsidy/types.js +3 -0
- package/api/entities/Subsidy/types.js.map +1 -0
- package/api/entities/TickerReservation/index.d.ts +72 -0
- package/api/entities/TickerReservation/index.d.ts.map +1 -0
- package/api/entities/TickerReservation/index.js +118 -0
- package/api/entities/TickerReservation/index.js.map +1 -0
- package/api/entities/TickerReservation/types.d.ts +27 -0
- package/api/entities/TickerReservation/types.d.ts.map +1 -0
- package/api/entities/TickerReservation/types.js +19 -0
- package/api/entities/TickerReservation/types.js.map +1 -0
- package/api/entities/Venue/index.d.ts +77 -0
- package/api/entities/Venue/index.d.ts.map +1 -0
- package/api/entities/Venue/index.js +139 -0
- package/api/entities/Venue/index.js.map +1 -0
- package/api/entities/Venue/types.d.ts +22 -0
- package/api/entities/Venue/types.d.ts.map +1 -0
- package/api/entities/Venue/types.js +20 -0
- package/api/entities/Venue/types.js.map +1 -0
- package/api/entities/common/namespaces/Authorizations.d.ts +37 -0
- package/api/entities/common/namespaces/Authorizations.d.ts.map +1 -0
- package/api/entities/common/namespaces/Authorizations.js +91 -0
- package/api/entities/common/namespaces/Authorizations.js.map +1 -0
- package/api/entities/types.d.ts +30 -0
- package/api/entities/types.d.ts.map +1 -0
- package/api/entities/types.js +27 -0
- package/api/entities/types.js.map +1 -0
- package/api/procedures/addAssetRequirement.d.ts +30 -0
- package/api/procedures/addAssetRequirement.d.ts.map +1 -0
- package/api/procedures/addAssetRequirement.js +70 -0
- package/api/procedures/addAssetRequirement.js.map +1 -0
- package/api/procedures/addInstruction.d.ts +70 -0
- package/api/procedures/addInstruction.d.ts.map +1 -0
- package/api/procedures/addInstruction.js +266 -0
- package/api/procedures/addInstruction.js.map +1 -0
- package/api/procedures/addInvestorUniquenessClaim.d.ts +23 -0
- package/api/procedures/addInvestorUniquenessClaim.d.ts.map +1 -0
- package/api/procedures/addInvestorUniquenessClaim.js +80 -0
- package/api/procedures/addInvestorUniquenessClaim.js.map +1 -0
- package/api/procedures/addTransferRestriction.d.ts +29 -0
- package/api/procedures/addTransferRestriction.d.ts.map +1 -0
- package/api/procedures/addTransferRestriction.js +102 -0
- package/api/procedures/addTransferRestriction.js.map +1 -0
- package/api/procedures/claimClassicTicker.d.ts +22 -0
- package/api/procedures/claimClassicTicker.d.ts.map +1 -0
- package/api/procedures/claimClassicTicker.js +112 -0
- package/api/procedures/claimClassicTicker.js.map +1 -0
- package/api/procedures/claimDividends.d.ts +16 -0
- package/api/procedures/claimDividends.d.ts.map +1 -0
- package/api/procedures/claimDividends.js +58 -0
- package/api/procedures/claimDividends.js.map +1 -0
- package/api/procedures/closeOffering.d.ts +23 -0
- package/api/procedures/closeOffering.d.ts.map +1 -0
- package/api/procedures/closeOffering.js +59 -0
- package/api/procedures/closeOffering.js.map +1 -0
- package/api/procedures/configureDividendDistribution.d.ts +69 -0
- package/api/procedures/configureDividendDistribution.d.ts.map +1 -0
- package/api/procedures/configureDividendDistribution.js +158 -0
- package/api/procedures/configureDividendDistribution.js.map +1 -0
- package/api/procedures/consumeAddMultiSigSignerAuthorization.d.ts +22 -0
- package/api/procedures/consumeAddMultiSigSignerAuthorization.d.ts.map +1 -0
- package/api/procedures/consumeAddMultiSigSignerAuthorization.js +102 -0
- package/api/procedures/consumeAddMultiSigSignerAuthorization.js.map +1 -0
- package/api/procedures/consumeAuthorizationRequests.d.ts +24 -0
- package/api/procedures/consumeAuthorizationRequests.d.ts.map +1 -0
- package/api/procedures/consumeAuthorizationRequests.js +124 -0
- package/api/procedures/consumeAuthorizationRequests.js.map +1 -0
- package/api/procedures/consumeJoinOrRotateAuthorization.d.ts +35 -0
- package/api/procedures/consumeJoinOrRotateAuthorization.d.ts.map +1 -0
- package/api/procedures/consumeJoinOrRotateAuthorization.js +136 -0
- package/api/procedures/consumeJoinOrRotateAuthorization.js.map +1 -0
- package/api/procedures/controllerTransfer.d.ts +40 -0
- package/api/procedures/controllerTransfer.d.ts.map +1 -0
- package/api/procedures/controllerTransfer.js +90 -0
- package/api/procedures/controllerTransfer.js.map +1 -0
- package/api/procedures/createAsset.d.ts +82 -0
- package/api/procedures/createAsset.d.ts.map +1 -0
- package/api/procedures/createAsset.js +178 -0
- package/api/procedures/createAsset.js.map +1 -0
- package/api/procedures/createCheckpoint.d.ts +26 -0
- package/api/procedures/createCheckpoint.d.ts.map +1 -0
- package/api/procedures/createCheckpoint.js +61 -0
- package/api/procedures/createCheckpoint.js.map +1 -0
- package/api/procedures/createCheckpointSchedule.d.ts +43 -0
- package/api/procedures/createCheckpointSchedule.d.ts.map +1 -0
- package/api/procedures/createCheckpointSchedule.js +70 -0
- package/api/procedures/createCheckpointSchedule.js.map +1 -0
- package/api/procedures/createGroup.d.ts +44 -0
- package/api/procedures/createGroup.d.ts.map +1 -0
- package/api/procedures/createGroup.js +90 -0
- package/api/procedures/createGroup.js.map +1 -0
- package/api/procedures/createPortfolio.d.ts +21 -0
- package/api/procedures/createPortfolio.d.ts.map +1 -0
- package/api/procedures/createPortfolio.js +64 -0
- package/api/procedures/createPortfolio.js.map +1 -0
- package/api/procedures/createVenue.d.ts +20 -0
- package/api/procedures/createVenue.d.ts.map +1 -0
- package/api/procedures/createVenue.js +56 -0
- package/api/procedures/createVenue.js.map +1 -0
- package/api/procedures/deletePortfolio.d.ts +20 -0
- package/api/procedures/deletePortfolio.d.ts.map +1 -0
- package/api/procedures/deletePortfolio.js +69 -0
- package/api/procedures/deletePortfolio.js.map +1 -0
- package/api/procedures/initiateCorporateAction.d.ts +60 -0
- package/api/procedures/initiateCorporateAction.d.ts.map +1 -0
- package/api/procedures/initiateCorporateAction.js +107 -0
- package/api/procedures/initiateCorporateAction.js.map +1 -0
- package/api/procedures/investInOffering.d.ts +66 -0
- package/api/procedures/investInOffering.d.ts.map +1 -0
- package/api/procedures/investInOffering.js +147 -0
- package/api/procedures/investInOffering.js.map +1 -0
- package/api/procedures/inviteAccount.d.ts +16 -0
- package/api/procedures/inviteAccount.d.ts.map +1 -0
- package/api/procedures/inviteAccount.js +92 -0
- package/api/procedures/inviteAccount.js.map +1 -0
- package/api/procedures/inviteExternalAgent.d.ts +46 -0
- package/api/procedures/inviteExternalAgent.d.ts.map +1 -0
- package/api/procedures/inviteExternalAgent.js +97 -0
- package/api/procedures/inviteExternalAgent.js.map +1 -0
- package/api/procedures/issueTokens.d.ts +27 -0
- package/api/procedures/issueTokens.d.ts.map +1 -0
- package/api/procedures/issueTokens.js +75 -0
- package/api/procedures/issueTokens.js.map +1 -0
- package/api/procedures/launchOffering.d.ts +81 -0
- package/api/procedures/launchOffering.d.ts.map +1 -0
- package/api/procedures/launchOffering.js +139 -0
- package/api/procedures/launchOffering.js.map +1 -0
- package/api/procedures/leaveIdentity.d.ts +10 -0
- package/api/procedures/leaveIdentity.d.ts.map +1 -0
- package/api/procedures/leaveIdentity.js +53 -0
- package/api/procedures/leaveIdentity.js.map +1 -0
- package/api/procedures/linkCaDocs.d.ts +30 -0
- package/api/procedures/linkCaDocs.d.ts.map +1 -0
- package/api/procedures/linkCaDocs.js +69 -0
- package/api/procedures/linkCaDocs.js.map +1 -0
- package/api/procedures/modifyAllowance.d.ts +42 -0
- package/api/procedures/modifyAllowance.d.ts.map +1 -0
- package/api/procedures/modifyAllowance.js +87 -0
- package/api/procedures/modifyAllowance.js.map +1 -0
- package/api/procedures/modifyAsset.d.ts +46 -0
- package/api/procedures/modifyAsset.d.ts.map +1 -0
- package/api/procedures/modifyAsset.js +130 -0
- package/api/procedures/modifyAsset.js.map +1 -0
- package/api/procedures/modifyAssetTrustedClaimIssuers.d.ts +35 -0
- package/api/procedures/modifyAssetTrustedClaimIssuers.d.ts.map +1 -0
- package/api/procedures/modifyAssetTrustedClaimIssuers.js +139 -0
- package/api/procedures/modifyAssetTrustedClaimIssuers.js.map +1 -0
- package/api/procedures/modifyCaCheckpoint.d.ts +25 -0
- package/api/procedures/modifyCaCheckpoint.d.ts.map +1 -0
- package/api/procedures/modifyCaCheckpoint.js +58 -0
- package/api/procedures/modifyCaCheckpoint.js.map +1 -0
- package/api/procedures/modifyCaDefaultConfig.d.ts +36 -0
- package/api/procedures/modifyCaDefaultConfig.d.ts.map +1 -0
- package/api/procedures/modifyCaDefaultConfig.js +119 -0
- package/api/procedures/modifyCaDefaultConfig.js.map +1 -0
- package/api/procedures/modifyClaims.d.ts +39 -0
- package/api/procedures/modifyClaims.d.ts.map +1 -0
- package/api/procedures/modifyClaims.js +205 -0
- package/api/procedures/modifyClaims.js.map +1 -0
- package/api/procedures/modifyComplianceRequirement.d.ts +35 -0
- package/api/procedures/modifyComplianceRequirement.d.ts.map +1 -0
- package/api/procedures/modifyComplianceRequirement.js +75 -0
- package/api/procedures/modifyComplianceRequirement.js.map +1 -0
- package/api/procedures/modifyCorporateActionsAgent.d.ts +31 -0
- package/api/procedures/modifyCorporateActionsAgent.d.ts.map +1 -0
- package/api/procedures/modifyCorporateActionsAgent.js +83 -0
- package/api/procedures/modifyCorporateActionsAgent.js.map +1 -0
- package/api/procedures/modifyDistributionCheckpoint.d.ts +25 -0
- package/api/procedures/modifyDistributionCheckpoint.d.ts.map +1 -0
- package/api/procedures/modifyDistributionCheckpoint.js +60 -0
- package/api/procedures/modifyDistributionCheckpoint.js.map +1 -0
- package/api/procedures/modifyInstructionAffirmation.d.ts +33 -0
- package/api/procedures/modifyInstructionAffirmation.d.ts.map +1 -0
- package/api/procedures/modifyInstructionAffirmation.js +158 -0
- package/api/procedures/modifyInstructionAffirmation.js.map +1 -0
- package/api/procedures/modifyOfferingTimes.d.ts +39 -0
- package/api/procedures/modifyOfferingTimes.d.ts.map +1 -0
- package/api/procedures/modifyOfferingTimes.js +103 -0
- package/api/procedures/modifyOfferingTimes.js.map +1 -0
- package/api/procedures/modifyPrimaryIssuanceAgent.d.ts +33 -0
- package/api/procedures/modifyPrimaryIssuanceAgent.d.ts.map +1 -0
- package/api/procedures/modifyPrimaryIssuanceAgent.js +87 -0
- package/api/procedures/modifyPrimaryIssuanceAgent.js.map +1 -0
- package/api/procedures/modifySignerPermissions.d.ts +35 -0
- package/api/procedures/modifySignerPermissions.d.ts.map +1 -0
- package/api/procedures/modifySignerPermissions.js +82 -0
- package/api/procedures/modifySignerPermissions.js.map +1 -0
- package/api/procedures/modifyVenue.d.ts +32 -0
- package/api/procedures/modifyVenue.d.ts.map +1 -0
- package/api/procedures/modifyVenue.js +81 -0
- package/api/procedures/modifyVenue.js.map +1 -0
- package/api/procedures/moveFunds.d.ts +33 -0
- package/api/procedures/moveFunds.d.ts.map +1 -0
- package/api/procedures/moveFunds.js +124 -0
- package/api/procedures/moveFunds.js.map +1 -0
- package/api/procedures/payDividends.d.ts +24 -0
- package/api/procedures/payDividends.d.ts.map +1 -0
- package/api/procedures/payDividends.js +90 -0
- package/api/procedures/payDividends.js.map +1 -0
- package/api/procedures/quitCustody.d.ts +28 -0
- package/api/procedures/quitCustody.d.ts.map +1 -0
- package/api/procedures/quitCustody.js +71 -0
- package/api/procedures/quitCustody.js.map +1 -0
- package/api/procedures/quitSubsidy.d.ts +20 -0
- package/api/procedures/quitSubsidy.d.ts.map +1 -0
- package/api/procedures/quitSubsidy.js +64 -0
- package/api/procedures/quitSubsidy.js.map +1 -0
- package/api/procedures/reclaimDividendDistributionFunds.d.ts +21 -0
- package/api/procedures/reclaimDividendDistributionFunds.d.ts.map +1 -0
- package/api/procedures/reclaimDividendDistributionFunds.js +69 -0
- package/api/procedures/reclaimDividendDistributionFunds.js.map +1 -0
- package/api/procedures/redeemTokens.d.ts +25 -0
- package/api/procedures/redeemTokens.d.ts.map +1 -0
- package/api/procedures/redeemTokens.js +70 -0
- package/api/procedures/redeemTokens.js.map +1 -0
- package/api/procedures/registerIdentity.d.ts +23 -0
- package/api/procedures/registerIdentity.d.ts.map +1 -0
- package/api/procedures/registerIdentity.js +70 -0
- package/api/procedures/registerIdentity.js.map +1 -0
- package/api/procedures/removeAssetRequirement.d.ts +26 -0
- package/api/procedures/removeAssetRequirement.d.ts.map +1 -0
- package/api/procedures/removeAssetRequirement.js +62 -0
- package/api/procedures/removeAssetRequirement.js.map +1 -0
- package/api/procedures/removeCheckpointSchedule.d.ts +28 -0
- package/api/procedures/removeCheckpointSchedule.d.ts.map +1 -0
- package/api/procedures/removeCheckpointSchedule.js +75 -0
- package/api/procedures/removeCheckpointSchedule.js.map +1 -0
- package/api/procedures/removeCorporateAction.d.ts +25 -0
- package/api/procedures/removeCorporateAction.d.ts.map +1 -0
- package/api/procedures/removeCorporateAction.js +98 -0
- package/api/procedures/removeCorporateAction.js.map +1 -0
- package/api/procedures/removeCorporateActionsAgent.d.ts +23 -0
- package/api/procedures/removeCorporateActionsAgent.d.ts.map +1 -0
- package/api/procedures/removeCorporateActionsAgent.js +60 -0
- package/api/procedures/removeCorporateActionsAgent.js.map +1 -0
- package/api/procedures/removeExternalAgent.d.ts +34 -0
- package/api/procedures/removeExternalAgent.d.ts.map +1 -0
- package/api/procedures/removeExternalAgent.js +83 -0
- package/api/procedures/removeExternalAgent.js.map +1 -0
- package/api/procedures/removePrimaryIssuanceAgent.d.ts +21 -0
- package/api/procedures/removePrimaryIssuanceAgent.d.ts.map +1 -0
- package/api/procedures/removePrimaryIssuanceAgent.js +58 -0
- package/api/procedures/removePrimaryIssuanceAgent.js.map +1 -0
- package/api/procedures/removeSecondaryAccounts.d.ts +14 -0
- package/api/procedures/removeSecondaryAccounts.d.ts.map +1 -0
- package/api/procedures/removeSecondaryAccounts.js +61 -0
- package/api/procedures/removeSecondaryAccounts.js.map +1 -0
- package/api/procedures/renamePortfolio.d.ts +26 -0
- package/api/procedures/renamePortfolio.d.ts.map +1 -0
- package/api/procedures/renamePortfolio.js +69 -0
- package/api/procedures/renamePortfolio.js.map +1 -0
- package/api/procedures/rescheduleInstruction.d.ts +17 -0
- package/api/procedures/rescheduleInstruction.d.ts.map +1 -0
- package/api/procedures/rescheduleInstruction.js +52 -0
- package/api/procedures/rescheduleInstruction.js.map +1 -0
- package/api/procedures/reserveTicker.d.ts +29 -0
- package/api/procedures/reserveTicker.d.ts.map +1 -0
- package/api/procedures/reserveTicker.js +94 -0
- package/api/procedures/reserveTicker.js.map +1 -0
- package/api/procedures/setAssetDocuments.d.ts +37 -0
- package/api/procedures/setAssetDocuments.d.ts.map +1 -0
- package/api/procedures/setAssetDocuments.js +103 -0
- package/api/procedures/setAssetDocuments.js.map +1 -0
- package/api/procedures/setAssetRequirements.d.ts +29 -0
- package/api/procedures/setAssetRequirements.d.ts.map +1 -0
- package/api/procedures/setAssetRequirements.js +81 -0
- package/api/procedures/setAssetRequirements.js.map +1 -0
- package/api/procedures/setCustodian.d.ts +27 -0
- package/api/procedures/setCustodian.d.ts.map +1 -0
- package/api/procedures/setCustodian.js +86 -0
- package/api/procedures/setCustodian.js.map +1 -0
- package/api/procedures/setGroupPermissions.d.ts +29 -0
- package/api/procedures/setGroupPermissions.d.ts.map +1 -0
- package/api/procedures/setGroupPermissions.js +61 -0
- package/api/procedures/setGroupPermissions.js.map +1 -0
- package/api/procedures/setPermissionGroup.d.ts +57 -0
- package/api/procedures/setPermissionGroup.d.ts.map +1 -0
- package/api/procedures/setPermissionGroup.js +108 -0
- package/api/procedures/setPermissionGroup.js.map +1 -0
- package/api/procedures/setTransferRestrictions.d.ts +50 -0
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -0
- package/api/procedures/setTransferRestrictions.js +204 -0
- package/api/procedures/setTransferRestrictions.js.map +1 -0
- package/api/procedures/subsidizeAccount.d.ts +21 -0
- package/api/procedures/subsidizeAccount.d.ts.map +1 -0
- package/api/procedures/subsidizeAccount.js +77 -0
- package/api/procedures/subsidizeAccount.js.map +1 -0
- package/api/procedures/toggleFreezeOffering.d.ts +21 -0
- package/api/procedures/toggleFreezeOffering.d.ts.map +1 -0
- package/api/procedures/toggleFreezeOffering.js +85 -0
- package/api/procedures/toggleFreezeOffering.js.map +1 -0
- package/api/procedures/toggleFreezeSecondaryAccounts.d.ts +18 -0
- package/api/procedures/toggleFreezeSecondaryAccounts.d.ts.map +1 -0
- package/api/procedures/toggleFreezeSecondaryAccounts.js +65 -0
- package/api/procedures/toggleFreezeSecondaryAccounts.js.map +1 -0
- package/api/procedures/toggleFreezeTransfers.d.ts +24 -0
- package/api/procedures/toggleFreezeTransfers.d.ts.map +1 -0
- package/api/procedures/toggleFreezeTransfers.js +72 -0
- package/api/procedures/toggleFreezeTransfers.js.map +1 -0
- package/api/procedures/togglePauseRequirements.d.ts +24 -0
- package/api/procedures/togglePauseRequirements.d.ts.map +1 -0
- package/api/procedures/togglePauseRequirements.js +63 -0
- package/api/procedures/togglePauseRequirements.js.map +1 -0
- package/api/procedures/transferAssetOwnership.d.ts +28 -0
- package/api/procedures/transferAssetOwnership.d.ts.map +1 -0
- package/api/procedures/transferAssetOwnership.js +61 -0
- package/api/procedures/transferAssetOwnership.js.map +1 -0
- package/api/procedures/transferPolyx.d.ts +30 -0
- package/api/procedures/transferPolyx.d.ts.map +1 -0
- package/api/procedures/transferPolyx.js +101 -0
- package/api/procedures/transferPolyx.js.map +1 -0
- package/api/procedures/transferTickerOwnership.d.ts +28 -0
- package/api/procedures/transferTickerOwnership.d.ts.map +1 -0
- package/api/procedures/transferTickerOwnership.js +70 -0
- package/api/procedures/transferTickerOwnership.js.map +1 -0
- package/api/procedures/utils.d.ts +103 -0
- package/api/procedures/utils.d.ts.map +1 -0
- package/api/procedures/utils.js +537 -0
- package/api/procedures/utils.js.map +1 -0
- package/api/procedures/waivePermissions.d.ts +34 -0
- package/api/procedures/waivePermissions.d.ts.map +1 -0
- package/api/procedures/waivePermissions.js +70 -0
- package/api/procedures/waivePermissions.js.map +1 -0
- package/base/Context.d.ts +287 -0
- package/base/Context.d.ts.map +1 -0
- package/base/Context.js +838 -0
- package/base/Context.js.map +1 -0
- package/base/PolymeshError.d.ts +17 -0
- package/base/PolymeshError.d.ts.map +1 -0
- package/base/PolymeshError.js +24 -0
- package/base/PolymeshError.js.map +1 -0
- package/base/PolymeshTransaction.d.ts +54 -0
- package/base/PolymeshTransaction.d.ts.map +1 -0
- package/base/PolymeshTransaction.js +84 -0
- package/base/PolymeshTransaction.js.map +1 -0
- package/base/PolymeshTransactionBase.d.ts +163 -0
- package/base/PolymeshTransactionBase.d.ts.map +1 -0
- package/base/PolymeshTransactionBase.js +322 -0
- package/base/PolymeshTransactionBase.js.map +1 -0
- package/base/PolymeshTransactionBatch.d.ts +51 -0
- package/base/PolymeshTransactionBatch.d.ts.map +1 -0
- package/base/PolymeshTransactionBatch.js +107 -0
- package/base/PolymeshTransactionBatch.js.map +1 -0
- package/base/PostTransactionValue.d.ts +45 -0
- package/base/PostTransactionValue.d.ts.map +1 -0
- package/base/PostTransactionValue.js +108 -0
- package/base/PostTransactionValue.js.map +1 -0
- package/base/Procedure.d.ts +92 -0
- package/base/Procedure.d.ts.map +1 -0
- package/base/Procedure.js +362 -0
- package/base/Procedure.js.map +1 -0
- package/base/TransactionQueue.d.ts +142 -0
- package/base/TransactionQueue.d.ts.map +1 -0
- package/base/TransactionQueue.js +420 -0
- package/base/TransactionQueue.js.map +1 -0
- package/base/types.d.ts +9 -0
- package/base/types.d.ts.map +1 -0
- package/base/types.js +4 -0
- package/base/types.js.map +1 -0
- package/generated/types.d.ts +253 -0
- package/generated/types.d.ts.map +1 -0
- package/generated/types.js +258 -0
- package/generated/types.js.map +1 -0
- package/generated/utils.d.ts +12 -0
- package/generated/utils.d.ts.map +1 -0
- package/generated/utils.js +767 -0
- package/generated/utils.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.d.ts.map +1 -0
- package/index.js +12 -0
- package/index.js.map +1 -0
- package/internal.d.ts +107 -0
- package/internal.d.ts.map +1 -0
- package/internal.js +219 -0
- package/internal.js.map +1 -0
- package/middleware/queries.d.ts +129 -0
- package/middleware/queries.d.ts.map +1 -0
- package/middleware/queries.js +701 -0
- package/middleware/queries.js.map +1 -0
- package/middleware/types.d.ts +1624 -0
- package/middleware/types.d.ts.map +1 -0
- package/middleware/types.js +866 -0
- package/middleware/types.js.map +1 -0
- package/npm-package/polymeshassociation-polymesh-sdk-14.0.0-beta.11.tgz +0 -0
- package/package.json +131 -0
- package/polkadot/asset/definitions.d.ts +25 -0
- package/polkadot/asset/definitions.d.ts.map +1 -0
- package/polkadot/asset/definitions.js +96 -0
- package/polkadot/asset/definitions.js.map +1 -0
- package/polkadot/asset/index.d.ts +2 -0
- package/polkadot/asset/index.d.ts.map +1 -0
- package/polkadot/asset/index.js +20 -0
- package/polkadot/asset/index.js.map +1 -0
- package/polkadot/asset/types.d.ts +2 -0
- package/polkadot/asset/types.d.ts.map +1 -0
- package/polkadot/asset/types.js +5 -0
- package/polkadot/asset/types.js.map +1 -0
- package/polkadot/augment-api-consts.d.ts +178 -0
- package/polkadot/augment-api-consts.d.ts.map +1 -0
- package/polkadot/augment-api-consts.js +5 -0
- package/polkadot/augment-api-consts.js.map +1 -0
- package/polkadot/augment-api-errors.d.ts +1638 -0
- package/polkadot/augment-api-errors.d.ts.map +1 -0
- package/polkadot/augment-api-errors.js +5 -0
- package/polkadot/augment-api-errors.js.map +1 -0
- package/polkadot/augment-api-events.d.ts +1671 -0
- package/polkadot/augment-api-events.d.ts.map +1 -0
- package/polkadot/augment-api-events.js +5 -0
- package/polkadot/augment-api-events.js.map +1 -0
- package/polkadot/augment-api-query.d.ts +1993 -0
- package/polkadot/augment-api-query.d.ts.map +1 -0
- package/polkadot/augment-api-query.js +5 -0
- package/polkadot/augment-api-query.js.map +1 -0
- package/polkadot/augment-api-rpc.d.ts +695 -0
- package/polkadot/augment-api-rpc.d.ts.map +1 -0
- package/polkadot/augment-api-rpc.js +5 -0
- package/polkadot/augment-api-rpc.js.map +1 -0
- package/polkadot/augment-api-tx.d.ts +5464 -0
- package/polkadot/augment-api-tx.d.ts.map +1 -0
- package/polkadot/augment-api-tx.js +5 -0
- package/polkadot/augment-api-tx.js.map +1 -0
- package/polkadot/augment-api.d.ts +8 -0
- package/polkadot/augment-api.d.ts.map +1 -0
- package/polkadot/augment-api.js +12 -0
- package/polkadot/augment-api.js.map +1 -0
- package/polkadot/augment-types.d.ts +3243 -0
- package/polkadot/augment-types.d.ts.map +1 -0
- package/polkadot/augment-types.js +5 -0
- package/polkadot/augment-types.js.map +1 -0
- package/polkadot/compliance/definitions.d.ts +16 -0
- package/polkadot/compliance/definitions.d.ts.map +1 -0
- package/polkadot/compliance/definitions.js +35 -0
- package/polkadot/compliance/definitions.js.map +1 -0
- package/polkadot/compliance/index.d.ts +2 -0
- package/polkadot/compliance/index.d.ts.map +1 -0
- package/polkadot/compliance/index.js +20 -0
- package/polkadot/compliance/index.js.map +1 -0
- package/polkadot/compliance/types.d.ts +2 -0
- package/polkadot/compliance/types.d.ts.map +1 -0
- package/polkadot/compliance/types.js +5 -0
- package/polkadot/compliance/types.js.map +1 -0
- package/polkadot/definitions.d.ts +8 -0
- package/polkadot/definitions.d.ts.map +1 -0
- package/polkadot/definitions.js +22 -0
- package/polkadot/definitions.js.map +1 -0
- package/polkadot/identity/definitions.d.ts +61 -0
- package/polkadot/identity/definitions.d.ts.map +1 -0
- package/polkadot/identity/definitions.js +120 -0
- package/polkadot/identity/definitions.js.map +1 -0
- package/polkadot/identity/index.d.ts +2 -0
- package/polkadot/identity/index.d.ts.map +1 -0
- package/polkadot/identity/index.js +20 -0
- package/polkadot/identity/index.js.map +1 -0
- package/polkadot/identity/types.d.ts +2 -0
- package/polkadot/identity/types.d.ts.map +1 -0
- package/polkadot/identity/types.js +5 -0
- package/polkadot/identity/types.js.map +1 -0
- package/polkadot/index.d.ts +2 -0
- package/polkadot/index.d.ts.map +1 -0
- package/polkadot/index.js +20 -0
- package/polkadot/index.js.map +1 -0
- package/polkadot/pips/definitions.d.ts +34 -0
- package/polkadot/pips/definitions.d.ts.map +1 -0
- package/polkadot/pips/definitions.js +57 -0
- package/polkadot/pips/definitions.js.map +1 -0
- package/polkadot/pips/index.d.ts +2 -0
- package/polkadot/pips/index.d.ts.map +1 -0
- package/polkadot/pips/index.js +20 -0
- package/polkadot/pips/index.js.map +1 -0
- package/polkadot/pips/types.d.ts +2 -0
- package/polkadot/pips/types.d.ts.map +1 -0
- package/polkadot/pips/types.js +5 -0
- package/polkadot/pips/types.js.map +1 -0
- package/polkadot/polymesh/definitions.d.ts +855 -0
- package/polkadot/polymesh/definitions.d.ts.map +1 -0
- package/polkadot/polymesh/definitions.js +1139 -0
- package/polkadot/polymesh/definitions.js.map +1 -0
- package/polkadot/polymesh/index.d.ts +2 -0
- package/polkadot/polymesh/index.d.ts.map +1 -0
- package/polkadot/polymesh/index.js +20 -0
- package/polkadot/polymesh/index.js.map +1 -0
- package/polkadot/polymesh/types.d.ts +1408 -0
- package/polkadot/polymesh/types.d.ts.map +1 -0
- package/polkadot/polymesh/types.js +5 -0
- package/polkadot/polymesh/types.js.map +1 -0
- package/polkadot/portfolio/definitions.d.ts +25 -0
- package/polkadot/portfolio/definitions.d.ts.map +1 -0
- package/polkadot/portfolio/definitions.js +31 -0
- package/polkadot/portfolio/definitions.js.map +1 -0
- package/polkadot/portfolio/index.d.ts +2 -0
- package/polkadot/portfolio/index.d.ts.map +1 -0
- package/polkadot/portfolio/index.js +20 -0
- package/polkadot/portfolio/index.js.map +1 -0
- package/polkadot/portfolio/types.d.ts +2 -0
- package/polkadot/portfolio/types.d.ts.map +1 -0
- package/polkadot/portfolio/types.js +5 -0
- package/polkadot/portfolio/types.js.map +1 -0
- package/polkadot/protocolFee/definitions.d.ts +16 -0
- package/polkadot/protocolFee/definitions.d.ts.map +1 -0
- package/polkadot/protocolFee/definitions.js +25 -0
- package/polkadot/protocolFee/definitions.js.map +1 -0
- package/polkadot/protocolFee/index.d.ts +2 -0
- package/polkadot/protocolFee/index.d.ts.map +1 -0
- package/polkadot/protocolFee/index.js +20 -0
- package/polkadot/protocolFee/index.js.map +1 -0
- package/polkadot/protocolFee/types.d.ts +2 -0
- package/polkadot/protocolFee/types.d.ts.map +1 -0
- package/polkadot/protocolFee/types.js +5 -0
- package/polkadot/protocolFee/types.js.map +1 -0
- package/polkadot/schema.d.ts +994 -0
- package/polkadot/schema.d.ts.map +1 -0
- package/polkadot/schema.js +1451 -0
- package/polkadot/schema.js.map +1 -0
- package/polkadot/staking/definitions.d.ts +16 -0
- package/polkadot/staking/definitions.d.ts.map +1 -0
- package/polkadot/staking/definitions.js +20 -0
- package/polkadot/staking/definitions.js.map +1 -0
- package/polkadot/staking/index.d.ts +2 -0
- package/polkadot/staking/index.d.ts.map +1 -0
- package/polkadot/staking/index.js +20 -0
- package/polkadot/staking/index.js.map +1 -0
- package/polkadot/staking/types.d.ts +2 -0
- package/polkadot/staking/types.d.ts.map +1 -0
- package/polkadot/staking/types.js +5 -0
- package/polkadot/staking/types.js.map +1 -0
- package/polkadot/types.d.ts +472 -0
- package/polkadot/types.d.ts.map +1 -0
- package/polkadot/types.js +531 -0
- package/polkadot/types.js.map +1 -0
- package/types/index.d.ts +1164 -0
- package/types/index.d.ts.map +1 -0
- package/types/index.js +506 -0
- package/types/index.js.map +1 -0
- package/types/internal.d.ts +304 -0
- package/types/internal.d.ts.map +1 -0
- package/types/internal.js +34 -0
- package/types/internal.js.map +1 -0
- package/types/utils/index.d.ts +47 -0
- package/types/utils/index.d.ts.map +1 -0
- package/types/utils/index.js +11 -0
- package/types/utils/index.js.map +1 -0
- package/utils/constants.d.ts +63 -0
- package/utils/constants.d.ts.map +1 -0
- package/utils/constants.js +109 -0
- package/utils/constants.js.map +1 -0
- package/utils/conversion.d.ts +584 -0
- package/utils/conversion.d.ts.map +1 -0
- package/utils/conversion.js +2649 -0
- package/utils/conversion.js.map +1 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.d.ts.map +1 -0
- package/utils/index.js +28 -0
- package/utils/index.js.map +1 -0
- package/utils/internal.d.ts +296 -0
- package/utils/internal.d.ts.map +1 -0
- package/utils/internal.js +786 -0
- package/utils/internal.js.map +1 -0
- package/utils/typeguards.d.ts +175 -0
- package/utils/typeguards.d.ts.map +1 -0
- package/utils/typeguards.js +312 -0
- package/utils/typeguards.js.map +1 -0
|
@@ -0,0 +1,2649 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.authorizationToAuthorizationData = exports.agentGroupToPermissionGroupIdentifier = exports.permissionGroupIdentifierToAgentGroup = exports.u8ToBigNumber = exports.u32ToBigNumber = exports.bigNumberToU32 = exports.meshPermissionsToPermissions = exports.extrinsicPermissionsToTransactionPermissions = exports.permissionsToMeshPermissions = exports.transactionPermissionsToExtrinsicPermissions = exports.transactionPermissionsToTxGroups = exports.txGroupToTxTags = exports.textToString = exports.stringToText = exports.portfolioIdToMeshPortfolioId = exports.portfolioLikeToPortfolio = exports.portfolioIdToPortfolio = exports.portfolioLikeToPortfolioId = exports.portfolioToPortfolioId = exports.meshPortfolioIdToPortfolio = exports.permillToBigNumber = exports.percentageToPermill = exports.bigNumberToU64 = exports.u64ToBigNumber = exports.signerToString = exports.signerValueToSigner = exports.signerToSignerValue = exports.signatoryToSignerValue = exports.signerValueToSignatory = exports.signatoryToAccount = exports.stringToEcdsaSignature = exports.identityIdToString = exports.stringToIdentityId = exports.stringToBlockHash = exports.stringToHash = exports.hashToString = exports.accountIdToString = exports.stringToAccountId = exports.momentToDate = exports.dateToMoment = exports.stringToInvestorZKProofData = exports.tickerToString = exports.stringToTicker = exports.bytesToString = exports.stringToBytes = exports.boolToBoolean = exports.booleanToBool = exports.assetNameToString = exports.stringToAssetName = exports.tickerToDid = void 0;
|
|
21
|
+
exports.extrinsicIdentifierToTxTag = exports.txTagToExtrinsicIdentifier = exports.txTagToProtocolOp = exports.complianceRequirementToRequirement = exports.complianceRequirementResultToRequirementCompliance = exports.requirementToComplianceRequirement = exports.trustedClaimIssuerToTrustedIssuer = exports.trustedIssuerToTrustedClaimIssuer = exports.meshClaimTypeToClaimType = exports.stringToTargetIdentity = exports.meshClaimToClaim = exports.middlewareEventToEventIdentifier = exports.scopeToMiddlewareScope = exports.middlewareScopeToScope = exports.claimToMeshClaim = exports.scopeIdToString = exports.stringToScopeId = exports.cddIdToString = exports.stringToCddId = exports.meshScopeToScope = exports.scopeToMeshScope = exports.canTransferResultToTransferStatus = exports.cddStatusToBoolean = exports.documentToAssetDocument = exports.assetDocumentToDocument = exports.documentHashToString = exports.stringToDocumentHash = exports.documentUriToString = exports.stringToDocumentUri = exports.documentTypeToString = exports.stringToDocumentType = exports.documentNameToString = exports.stringToDocumentName = exports.fundingRoundNameToString = exports.stringToFundingRoundName = exports.assetIdentifierToSecurityIdentifier = exports.securityIdentifierToAssetIdentifier = exports.isLeiValid = exports.isCusipValid = exports.isIsinValid = exports.posRatioToBigNumber = exports.assetTypeToKnownOrId = exports.internalAssetTypeToAssetType = exports.u8ToTransferStatus = exports.stringToMemo = exports.authorizationDataToAuthorization = exports.agentGroupToPermissionGroup = exports.balanceToBigNumber = exports.bigNumberToBalance = exports.authorizationTypeToMeshAuthorizationType = void 0;
|
|
22
|
+
exports.corporateActionIdentifierToCaId = exports.distributionToDividendDistributionParams = exports.targetsToTargetIdentities = exports.targetIdentitiesToCorporateActionTargets = exports.scopeClaimProofToMeshScopeClaimProof = exports.checkpointToRecordDateSpec = exports.stringToScalar = exports.corporateActionKindToCaKind = exports.stringToRistrettoPoint = exports.meshCorporateActionToCorporateActionParams = exports.stringToSignature = exports.storedScheduleToCheckpointScheduleParams = exports.scheduleSpecToMeshScheduleSpec = exports.meshCalendarPeriodToCalendarPeriod = exports.calendarPeriodToMeshCalendarPeriod = exports.fundraiserToOfferingDetails = exports.fundraiserTierToTier = exports.middlewarePortfolioToPortfolio = exports.permissionsLikeToPermissions = exports.offeringTierToPriceTier = exports.granularCanTransferResultToTransferBreakdown = exports.transferManagerToTransferRestriction = exports.transferRestrictionToTransferManager = exports.claimTypeToMeshClaimType = exports.portfolioMovementToMovePortfolioItem = exports.toIdentityWithClaimsArray = exports.endConditionToSettlementType = exports.meshAffirmationStatusToAffirmationStatus = exports.meshInstructionStatusToInstructionStatus = exports.venueDetailsToString = exports.stringToVenueDetails = exports.venueTypeToMeshVenueType = exports.meshVenueTypeToVenueType = exports.secondaryAccountToMeshSecondaryKey = exports.transactionToTxTag = exports.transactionHexToTxTag = exports.addressToKey = exports.keyToAddress = exports.moduleAddressToString = exports.assetComplianceResultToCompliance = void 0;
|
|
23
|
+
const util_1 = require("@polkadot/util");
|
|
24
|
+
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
25
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
26
|
+
const iso_7064_1 = require("iso-7064");
|
|
27
|
+
const lodash_1 = require("lodash");
|
|
28
|
+
const types_1 = require("../polkadot/types");
|
|
29
|
+
const utils_1 = require("../generated/utils");
|
|
30
|
+
const internal_1 = require("../internal");
|
|
31
|
+
const types_2 = require("../middleware/types");
|
|
32
|
+
const types_3 = require("../types");
|
|
33
|
+
const internal_2 = require("../types/internal");
|
|
34
|
+
const utils_2 = require("../types/utils");
|
|
35
|
+
const constants_1 = require("./constants");
|
|
36
|
+
const internal_3 = require("./internal");
|
|
37
|
+
const typeguards_1 = require("./typeguards");
|
|
38
|
+
__exportStar(require("../generated/utils"), exports);
|
|
39
|
+
/**
|
|
40
|
+
* Generate an Asset's DID from a ticker
|
|
41
|
+
*/
|
|
42
|
+
function tickerToDid(ticker) {
|
|
43
|
+
return (0, util_crypto_1.blake2AsHex)((0, util_1.u8aConcat)((0, util_1.stringToU8a)('SECURITY_TOKEN:'), (0, util_1.u8aFixLength)((0, util_1.stringToU8a)(ticker), 96, true)));
|
|
44
|
+
}
|
|
45
|
+
exports.tickerToDid = tickerToDid;
|
|
46
|
+
/**
|
|
47
|
+
* @hidden
|
|
48
|
+
*/
|
|
49
|
+
function stringToAssetName(name, context) {
|
|
50
|
+
return context.createType('AssetName', name);
|
|
51
|
+
}
|
|
52
|
+
exports.stringToAssetName = stringToAssetName;
|
|
53
|
+
/**
|
|
54
|
+
* @hidden
|
|
55
|
+
*/
|
|
56
|
+
function assetNameToString(name) {
|
|
57
|
+
return name.toString();
|
|
58
|
+
}
|
|
59
|
+
exports.assetNameToString = assetNameToString;
|
|
60
|
+
/**
|
|
61
|
+
* @hidden
|
|
62
|
+
*/
|
|
63
|
+
function booleanToBool(value, context) {
|
|
64
|
+
return context.createType('bool', value);
|
|
65
|
+
}
|
|
66
|
+
exports.booleanToBool = booleanToBool;
|
|
67
|
+
/**
|
|
68
|
+
* @hidden
|
|
69
|
+
*/
|
|
70
|
+
function boolToBoolean(value) {
|
|
71
|
+
return value.isTrue;
|
|
72
|
+
}
|
|
73
|
+
exports.boolToBoolean = boolToBoolean;
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
*/
|
|
77
|
+
function stringToBytes(bytes, context) {
|
|
78
|
+
return context.createType('Bytes', bytes);
|
|
79
|
+
}
|
|
80
|
+
exports.stringToBytes = stringToBytes;
|
|
81
|
+
/**
|
|
82
|
+
* @hidden
|
|
83
|
+
*/
|
|
84
|
+
function bytesToString(bytes) {
|
|
85
|
+
return (0, util_1.u8aToString)(bytes);
|
|
86
|
+
}
|
|
87
|
+
exports.bytesToString = bytesToString;
|
|
88
|
+
/**
|
|
89
|
+
* @hidden
|
|
90
|
+
*/
|
|
91
|
+
function stringToTicker(ticker, context) {
|
|
92
|
+
(0, internal_3.assertTickerValid)(ticker);
|
|
93
|
+
return context.createType('Ticker', (0, internal_3.padString)(ticker, constants_1.MAX_TICKER_LENGTH));
|
|
94
|
+
}
|
|
95
|
+
exports.stringToTicker = stringToTicker;
|
|
96
|
+
/**
|
|
97
|
+
* @hidden
|
|
98
|
+
*/
|
|
99
|
+
function tickerToString(ticker) {
|
|
100
|
+
return (0, internal_3.removePadding)((0, util_1.u8aToString)(ticker));
|
|
101
|
+
}
|
|
102
|
+
exports.tickerToString = tickerToString;
|
|
103
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
104
|
+
/**
|
|
105
|
+
* @hidden
|
|
106
|
+
*/
|
|
107
|
+
function stringToInvestorZKProofData(proof, context) {
|
|
108
|
+
return context.createType('InvestorZKProofData', proof);
|
|
109
|
+
}
|
|
110
|
+
exports.stringToInvestorZKProofData = stringToInvestorZKProofData;
|
|
111
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
112
|
+
/**
|
|
113
|
+
* @hidden
|
|
114
|
+
*/
|
|
115
|
+
function dateToMoment(date, context) {
|
|
116
|
+
return context.createType('Moment', date.getTime());
|
|
117
|
+
}
|
|
118
|
+
exports.dateToMoment = dateToMoment;
|
|
119
|
+
/**
|
|
120
|
+
* @hidden
|
|
121
|
+
*/
|
|
122
|
+
function momentToDate(moment) {
|
|
123
|
+
return new Date(moment.toNumber());
|
|
124
|
+
}
|
|
125
|
+
exports.momentToDate = momentToDate;
|
|
126
|
+
/**
|
|
127
|
+
* @hidden
|
|
128
|
+
*/
|
|
129
|
+
function stringToAccountId(accountId, context) {
|
|
130
|
+
(0, internal_3.assertAddressValid)(accountId, context.ss58Format);
|
|
131
|
+
return context.createType('AccountId', accountId);
|
|
132
|
+
}
|
|
133
|
+
exports.stringToAccountId = stringToAccountId;
|
|
134
|
+
/**
|
|
135
|
+
* @hidden
|
|
136
|
+
*/
|
|
137
|
+
function accountIdToString(accountId) {
|
|
138
|
+
return accountId.toString();
|
|
139
|
+
}
|
|
140
|
+
exports.accountIdToString = accountIdToString;
|
|
141
|
+
/**
|
|
142
|
+
* @hidden
|
|
143
|
+
*/
|
|
144
|
+
function hashToString(hash) {
|
|
145
|
+
return hash.toString();
|
|
146
|
+
}
|
|
147
|
+
exports.hashToString = hashToString;
|
|
148
|
+
/**
|
|
149
|
+
* @hidden
|
|
150
|
+
*/
|
|
151
|
+
function stringToHash(hash, context) {
|
|
152
|
+
return context.createType('Hash', hash);
|
|
153
|
+
}
|
|
154
|
+
exports.stringToHash = stringToHash;
|
|
155
|
+
/**
|
|
156
|
+
* @hidden
|
|
157
|
+
*/
|
|
158
|
+
function stringToBlockHash(blockHash, context) {
|
|
159
|
+
return context.createType('BlockHash', blockHash);
|
|
160
|
+
}
|
|
161
|
+
exports.stringToBlockHash = stringToBlockHash;
|
|
162
|
+
/**
|
|
163
|
+
* @hidden
|
|
164
|
+
*/
|
|
165
|
+
function stringToIdentityId(identityId, context) {
|
|
166
|
+
return context.createType('IdentityId', identityId);
|
|
167
|
+
}
|
|
168
|
+
exports.stringToIdentityId = stringToIdentityId;
|
|
169
|
+
/**
|
|
170
|
+
* @hidden
|
|
171
|
+
*/
|
|
172
|
+
function identityIdToString(identityId) {
|
|
173
|
+
return identityId.toString();
|
|
174
|
+
}
|
|
175
|
+
exports.identityIdToString = identityIdToString;
|
|
176
|
+
/**
|
|
177
|
+
* @hidden
|
|
178
|
+
*/
|
|
179
|
+
function stringToEcdsaSignature(signature, context) {
|
|
180
|
+
return context.createType('EcdsaSignature', signature);
|
|
181
|
+
}
|
|
182
|
+
exports.stringToEcdsaSignature = stringToEcdsaSignature;
|
|
183
|
+
/**
|
|
184
|
+
* @hidden
|
|
185
|
+
*/
|
|
186
|
+
function signatoryToAccount(signatory, context) {
|
|
187
|
+
if (signatory.isAccount) {
|
|
188
|
+
return new internal_1.Account({ address: accountIdToString(signatory.asAccount) }, context);
|
|
189
|
+
}
|
|
190
|
+
throw new internal_1.PolymeshError({
|
|
191
|
+
code: types_3.ErrorCode.UnexpectedError,
|
|
192
|
+
message: 'Received an Identity where an Account was expected. Please report this issue to the Polymath team',
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
exports.signatoryToAccount = signatoryToAccount;
|
|
196
|
+
/**
|
|
197
|
+
* @hidden
|
|
198
|
+
*/
|
|
199
|
+
function signerValueToSignatory(signer, context) {
|
|
200
|
+
return context.createType('Signatory', {
|
|
201
|
+
[signer.type]: signer.value,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
exports.signerValueToSignatory = signerValueToSignatory;
|
|
205
|
+
/**
|
|
206
|
+
* @hidden
|
|
207
|
+
*/
|
|
208
|
+
function createSignerValue(type, value) {
|
|
209
|
+
return {
|
|
210
|
+
type,
|
|
211
|
+
value,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* @hidden
|
|
216
|
+
*/
|
|
217
|
+
function signatoryToSignerValue(signatory) {
|
|
218
|
+
if (signatory.isAccount) {
|
|
219
|
+
return createSignerValue(types_3.SignerType.Account, accountIdToString(signatory.asAccount));
|
|
220
|
+
}
|
|
221
|
+
return createSignerValue(types_3.SignerType.Identity, identityIdToString(signatory.asIdentity));
|
|
222
|
+
}
|
|
223
|
+
exports.signatoryToSignerValue = signatoryToSignerValue;
|
|
224
|
+
/**
|
|
225
|
+
* @hidden
|
|
226
|
+
*/
|
|
227
|
+
function signerToSignerValue(signer) {
|
|
228
|
+
if (signer instanceof internal_1.Account) {
|
|
229
|
+
return createSignerValue(types_3.SignerType.Account, signer.address);
|
|
230
|
+
}
|
|
231
|
+
return createSignerValue(types_3.SignerType.Identity, signer.did);
|
|
232
|
+
}
|
|
233
|
+
exports.signerToSignerValue = signerToSignerValue;
|
|
234
|
+
/**
|
|
235
|
+
* @hidden
|
|
236
|
+
*/
|
|
237
|
+
function signerValueToSigner(signerValue, context) {
|
|
238
|
+
const { type, value } = signerValue;
|
|
239
|
+
if (type === types_3.SignerType.Account) {
|
|
240
|
+
return new internal_1.Account({ address: value }, context);
|
|
241
|
+
}
|
|
242
|
+
return new internal_1.Identity({ did: value }, context);
|
|
243
|
+
}
|
|
244
|
+
exports.signerValueToSigner = signerValueToSigner;
|
|
245
|
+
/**
|
|
246
|
+
* @hidden
|
|
247
|
+
*/
|
|
248
|
+
function signerToString(signer) {
|
|
249
|
+
if (typeof signer === 'string') {
|
|
250
|
+
return signer;
|
|
251
|
+
}
|
|
252
|
+
return signerToSignerValue(signer).value;
|
|
253
|
+
}
|
|
254
|
+
exports.signerToString = signerToString;
|
|
255
|
+
/**
|
|
256
|
+
* @hidden
|
|
257
|
+
*/
|
|
258
|
+
function u64ToBigNumber(value) {
|
|
259
|
+
return new bignumber_js_1.default(value.toString());
|
|
260
|
+
}
|
|
261
|
+
exports.u64ToBigNumber = u64ToBigNumber;
|
|
262
|
+
/**
|
|
263
|
+
* @hidden
|
|
264
|
+
*/
|
|
265
|
+
function bigNumberToU64(value, context) {
|
|
266
|
+
(0, internal_3.assertIsInteger)(value);
|
|
267
|
+
(0, internal_3.assertIsPositive)(value);
|
|
268
|
+
return context.createType('u64', value.toString());
|
|
269
|
+
}
|
|
270
|
+
exports.bigNumberToU64 = bigNumberToU64;
|
|
271
|
+
/**
|
|
272
|
+
* @hidden
|
|
273
|
+
*/
|
|
274
|
+
function percentageToPermill(value, context) {
|
|
275
|
+
(0, internal_3.assertIsPositive)(value);
|
|
276
|
+
if (value.gt(100)) {
|
|
277
|
+
throw new internal_1.PolymeshError({
|
|
278
|
+
code: types_3.ErrorCode.ValidationError,
|
|
279
|
+
message: "Percentage shouldn't exceed 100",
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return context.createType('Permill', value.shiftedBy(4).toString()); // (value : 100) * 10^6
|
|
283
|
+
}
|
|
284
|
+
exports.percentageToPermill = percentageToPermill;
|
|
285
|
+
/**
|
|
286
|
+
* @hidden
|
|
287
|
+
*
|
|
288
|
+
* @note returns a percentage value ([0, 100])
|
|
289
|
+
*/
|
|
290
|
+
function permillToBigNumber(value) {
|
|
291
|
+
return new bignumber_js_1.default(value.toString()).shiftedBy(-4); // (value : 10^6) * 100
|
|
292
|
+
}
|
|
293
|
+
exports.permillToBigNumber = permillToBigNumber;
|
|
294
|
+
/**
|
|
295
|
+
* @hidden
|
|
296
|
+
*/
|
|
297
|
+
function meshPortfolioIdToPortfolio(portfolioId, context) {
|
|
298
|
+
const { did, kind } = portfolioId;
|
|
299
|
+
const identityId = identityIdToString(did);
|
|
300
|
+
if (kind.isDefault) {
|
|
301
|
+
return new internal_1.DefaultPortfolio({ did: identityId }, context);
|
|
302
|
+
}
|
|
303
|
+
return new internal_1.NumberedPortfolio({ did: identityId, id: u64ToBigNumber(kind.asUser) }, context);
|
|
304
|
+
}
|
|
305
|
+
exports.meshPortfolioIdToPortfolio = meshPortfolioIdToPortfolio;
|
|
306
|
+
/**
|
|
307
|
+
* @hidden
|
|
308
|
+
*/
|
|
309
|
+
function portfolioToPortfolioId(portfolio) {
|
|
310
|
+
const { owner: { did }, } = portfolio;
|
|
311
|
+
if (portfolio instanceof internal_1.DefaultPortfolio) {
|
|
312
|
+
return { did };
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
const { id: number } = portfolio;
|
|
316
|
+
return { did, number };
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.portfolioToPortfolioId = portfolioToPortfolioId;
|
|
320
|
+
/**
|
|
321
|
+
* @hidden
|
|
322
|
+
*/
|
|
323
|
+
function portfolioLikeToPortfolioId(value) {
|
|
324
|
+
let did;
|
|
325
|
+
let number;
|
|
326
|
+
if (typeof value === 'string') {
|
|
327
|
+
did = value;
|
|
328
|
+
}
|
|
329
|
+
else if (value instanceof internal_1.Identity) {
|
|
330
|
+
({ did } = value);
|
|
331
|
+
}
|
|
332
|
+
else if (value instanceof internal_1.Portfolio) {
|
|
333
|
+
({ did, number } = portfolioToPortfolioId(value));
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
const { identity: valueIdentity } = value;
|
|
337
|
+
({ id: number } = value);
|
|
338
|
+
did = (0, internal_3.asDid)(valueIdentity);
|
|
339
|
+
}
|
|
340
|
+
return { did, number };
|
|
341
|
+
}
|
|
342
|
+
exports.portfolioLikeToPortfolioId = portfolioLikeToPortfolioId;
|
|
343
|
+
/**
|
|
344
|
+
* @hidden
|
|
345
|
+
*/
|
|
346
|
+
function portfolioIdToPortfolio(portfolioId, context) {
|
|
347
|
+
const { did, number } = portfolioId;
|
|
348
|
+
return number
|
|
349
|
+
? new internal_1.NumberedPortfolio({ did, id: number }, context)
|
|
350
|
+
: new internal_1.DefaultPortfolio({ did }, context);
|
|
351
|
+
}
|
|
352
|
+
exports.portfolioIdToPortfolio = portfolioIdToPortfolio;
|
|
353
|
+
/**
|
|
354
|
+
* @hidden
|
|
355
|
+
*/
|
|
356
|
+
function portfolioLikeToPortfolio(value, context) {
|
|
357
|
+
return portfolioIdToPortfolio(portfolioLikeToPortfolioId(value), context);
|
|
358
|
+
}
|
|
359
|
+
exports.portfolioLikeToPortfolio = portfolioLikeToPortfolio;
|
|
360
|
+
/**
|
|
361
|
+
* @hidden
|
|
362
|
+
*/
|
|
363
|
+
function portfolioIdToMeshPortfolioId(portfolioId, context) {
|
|
364
|
+
const { did, number } = portfolioId;
|
|
365
|
+
return context.createType('PortfolioId', {
|
|
366
|
+
did: stringToIdentityId(did, context),
|
|
367
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
368
|
+
kind: number ? { User: bigNumberToU64(number, context) } : 'Default',
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
exports.portfolioIdToMeshPortfolioId = portfolioIdToMeshPortfolioId;
|
|
372
|
+
/**
|
|
373
|
+
* @hidden
|
|
374
|
+
*/
|
|
375
|
+
function stringToText(text, context) {
|
|
376
|
+
return context.createType('Text', text);
|
|
377
|
+
}
|
|
378
|
+
exports.stringToText = stringToText;
|
|
379
|
+
/**
|
|
380
|
+
* @hidden
|
|
381
|
+
*/
|
|
382
|
+
function textToString(value) {
|
|
383
|
+
return value.toString();
|
|
384
|
+
}
|
|
385
|
+
exports.textToString = textToString;
|
|
386
|
+
/**
|
|
387
|
+
* Retrieve every Transaction Tag associated to a Transaction Group
|
|
388
|
+
*/
|
|
389
|
+
function txGroupToTxTags(group) {
|
|
390
|
+
switch (group) {
|
|
391
|
+
case types_3.TxGroup.PortfolioManagement: {
|
|
392
|
+
return [
|
|
393
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
394
|
+
types_1.TxTags.portfolio.MovePortfolioFunds,
|
|
395
|
+
types_1.TxTags.settlement.AddInstruction,
|
|
396
|
+
types_1.TxTags.settlement.AddAndAffirmInstruction,
|
|
397
|
+
types_1.TxTags.settlement.AffirmInstruction,
|
|
398
|
+
types_1.TxTags.settlement.RejectInstruction,
|
|
399
|
+
types_1.TxTags.settlement.CreateVenue,
|
|
400
|
+
];
|
|
401
|
+
}
|
|
402
|
+
case types_3.TxGroup.AssetManagement: {
|
|
403
|
+
return [
|
|
404
|
+
types_1.TxTags.asset.MakeDivisible,
|
|
405
|
+
types_1.TxTags.asset.RenameAsset,
|
|
406
|
+
types_1.TxTags.asset.SetFundingRound,
|
|
407
|
+
types_1.TxTags.asset.AddDocuments,
|
|
408
|
+
types_1.TxTags.asset.RemoveDocuments,
|
|
409
|
+
];
|
|
410
|
+
}
|
|
411
|
+
case types_3.TxGroup.AdvancedAssetManagement: {
|
|
412
|
+
return [
|
|
413
|
+
types_1.TxTags.asset.Freeze,
|
|
414
|
+
types_1.TxTags.asset.Unfreeze,
|
|
415
|
+
types_1.TxTags.identity.AddAuthorization,
|
|
416
|
+
types_1.TxTags.identity.RemoveAuthorization,
|
|
417
|
+
];
|
|
418
|
+
}
|
|
419
|
+
case types_3.TxGroup.Distribution: {
|
|
420
|
+
return [
|
|
421
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
422
|
+
types_1.TxTags.settlement.CreateVenue,
|
|
423
|
+
types_1.TxTags.settlement.AddInstruction,
|
|
424
|
+
types_1.TxTags.settlement.AddAndAffirmInstruction,
|
|
425
|
+
];
|
|
426
|
+
}
|
|
427
|
+
case types_3.TxGroup.Issuance: {
|
|
428
|
+
return [types_1.TxTags.asset.Issue];
|
|
429
|
+
}
|
|
430
|
+
case types_3.TxGroup.TrustedClaimIssuersManagement: {
|
|
431
|
+
return [
|
|
432
|
+
types_1.TxTags.complianceManager.AddDefaultTrustedClaimIssuer,
|
|
433
|
+
types_1.TxTags.complianceManager.RemoveDefaultTrustedClaimIssuer,
|
|
434
|
+
];
|
|
435
|
+
}
|
|
436
|
+
case types_3.TxGroup.ClaimsManagement: {
|
|
437
|
+
return [types_1.TxTags.identity.AddClaim, types_1.TxTags.identity.RevokeClaim];
|
|
438
|
+
}
|
|
439
|
+
case types_3.TxGroup.ComplianceRequirementsManagement: {
|
|
440
|
+
return [
|
|
441
|
+
types_1.TxTags.complianceManager.AddComplianceRequirement,
|
|
442
|
+
types_1.TxTags.complianceManager.RemoveComplianceRequirement,
|
|
443
|
+
types_1.TxTags.complianceManager.PauseAssetCompliance,
|
|
444
|
+
types_1.TxTags.complianceManager.ResumeAssetCompliance,
|
|
445
|
+
types_1.TxTags.complianceManager.ResetAssetCompliance,
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
case types_3.TxGroup.CorporateActionsManagement: {
|
|
449
|
+
return [
|
|
450
|
+
types_1.TxTags.checkpoint.CreateSchedule,
|
|
451
|
+
types_1.TxTags.checkpoint.RemoveSchedule,
|
|
452
|
+
types_1.TxTags.checkpoint.CreateCheckpoint,
|
|
453
|
+
types_1.TxTags.corporateAction.InitiateCorporateAction,
|
|
454
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
455
|
+
types_1.TxTags.capitalDistribution.Claim,
|
|
456
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
457
|
+
];
|
|
458
|
+
}
|
|
459
|
+
case types_3.TxGroup.StoManagement: {
|
|
460
|
+
return [
|
|
461
|
+
types_1.TxTags.sto.CreateFundraiser,
|
|
462
|
+
types_1.TxTags.sto.FreezeFundraiser,
|
|
463
|
+
types_1.TxTags.sto.Invest,
|
|
464
|
+
types_1.TxTags.sto.ModifyFundraiserWindow,
|
|
465
|
+
types_1.TxTags.sto.Stop,
|
|
466
|
+
types_1.TxTags.sto.UnfreezeFundraiser,
|
|
467
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
468
|
+
types_1.TxTags.asset.Issue,
|
|
469
|
+
types_1.TxTags.settlement.CreateVenue,
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
exports.txGroupToTxTags = txGroupToTxTags;
|
|
475
|
+
/**
|
|
476
|
+
* @hidden
|
|
477
|
+
*
|
|
478
|
+
* @note tags that don't belong to any group will be ignored.
|
|
479
|
+
* The same goes for tags that belong to a group that wasn't completed
|
|
480
|
+
*/
|
|
481
|
+
function transactionPermissionsToTxGroups(permissions) {
|
|
482
|
+
if (!permissions) {
|
|
483
|
+
return [];
|
|
484
|
+
}
|
|
485
|
+
const { values: transactionValues, type, exceptions = [] } = permissions;
|
|
486
|
+
let includedTags;
|
|
487
|
+
let excludedTags;
|
|
488
|
+
if (type === types_3.PermissionType.Include) {
|
|
489
|
+
includedTags = transactionValues;
|
|
490
|
+
excludedTags = exceptions;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
includedTags = exceptions;
|
|
494
|
+
excludedTags = transactionValues;
|
|
495
|
+
}
|
|
496
|
+
return (0, lodash_1.values)(types_3.TxGroup)
|
|
497
|
+
.sort()
|
|
498
|
+
.filter(group => {
|
|
499
|
+
const tagsInGroup = txGroupToTxTags(group);
|
|
500
|
+
return tagsInGroup.every(tag => {
|
|
501
|
+
const isExcluded = !!excludedTags.find(excluded => (0, internal_3.isModuleOrTagMatch)(excluded, tag));
|
|
502
|
+
if (isExcluded) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
return !!includedTags.find(included => (0, internal_3.isModuleOrTagMatch)(included, tag));
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
exports.transactionPermissionsToTxGroups = transactionPermissionsToTxGroups;
|
|
510
|
+
/**
|
|
511
|
+
* @hidden
|
|
512
|
+
*/
|
|
513
|
+
function splitTag(tag) {
|
|
514
|
+
const [modName, txName] = tag.split('.');
|
|
515
|
+
const palletName = (0, util_1.stringUpperFirst)(modName);
|
|
516
|
+
const dispatchableName = (0, lodash_1.snakeCase)(txName);
|
|
517
|
+
return { palletName, dispatchableName };
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* @hidden
|
|
521
|
+
*/
|
|
522
|
+
function initExtrinsicDict(txValues, message) {
|
|
523
|
+
const extrinsicDict = {};
|
|
524
|
+
(0, lodash_1.uniq)(txValues)
|
|
525
|
+
.sort()
|
|
526
|
+
.forEach(tag => {
|
|
527
|
+
if (tag.includes('.')) {
|
|
528
|
+
const { palletName, dispatchableName } = splitTag(tag);
|
|
529
|
+
let pallet = extrinsicDict[palletName];
|
|
530
|
+
if (pallet === null) {
|
|
531
|
+
throw new internal_1.PolymeshError({
|
|
532
|
+
code: types_3.ErrorCode.ValidationError,
|
|
533
|
+
message,
|
|
534
|
+
data: {
|
|
535
|
+
module: palletName,
|
|
536
|
+
transactions: [dispatchableName],
|
|
537
|
+
},
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
else if (pallet === undefined) {
|
|
541
|
+
pallet = extrinsicDict[palletName] = { tx: [] };
|
|
542
|
+
}
|
|
543
|
+
pallet.tx.push(dispatchableName);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
extrinsicDict[(0, util_1.stringUpperFirst)(tag)] = null;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
return extrinsicDict;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* @hidden
|
|
553
|
+
*/
|
|
554
|
+
function buildPalletPermissions(transactions) {
|
|
555
|
+
let extrinsic;
|
|
556
|
+
const message = 'Attempting to add permissions for specific transactions as well as the entire module';
|
|
557
|
+
const { values: txValues, exceptions = [], type } = transactions;
|
|
558
|
+
const extrinsicDict = initExtrinsicDict(txValues, message);
|
|
559
|
+
exceptions.forEach(exception => {
|
|
560
|
+
const { palletName, dispatchableName } = splitTag(exception);
|
|
561
|
+
const pallet = extrinsicDict[palletName];
|
|
562
|
+
if (pallet === undefined) {
|
|
563
|
+
throw new internal_1.PolymeshError({
|
|
564
|
+
code: types_3.ErrorCode.ValidationError,
|
|
565
|
+
message: 'Attempting to add a transaction permission exception without its corresponding module being included/excluded',
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
else if (pallet === null) {
|
|
569
|
+
extrinsicDict[palletName] = { tx: [dispatchableName], exception: true };
|
|
570
|
+
}
|
|
571
|
+
else if (pallet.exception) {
|
|
572
|
+
pallet.tx.push(dispatchableName);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
throw new internal_1.PolymeshError({
|
|
576
|
+
code: types_3.ErrorCode.ValidationError,
|
|
577
|
+
message: 'Cannot simultaneously include and exclude transactions belonging to the same module',
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
const pallets = (0, lodash_1.map)(extrinsicDict, (val, key) => {
|
|
582
|
+
let dispatchables;
|
|
583
|
+
if (val === null) {
|
|
584
|
+
dispatchables = 'Whole';
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
const { tx, exception } = val;
|
|
588
|
+
if (exception) {
|
|
589
|
+
dispatchables = {
|
|
590
|
+
Except: tx,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
dispatchables = {
|
|
595
|
+
These: tx,
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return {
|
|
600
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
601
|
+
pallet_name: key,
|
|
602
|
+
dispatchable_names: dispatchables,
|
|
603
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
604
|
+
};
|
|
605
|
+
});
|
|
606
|
+
if (type === types_3.PermissionType.Include) {
|
|
607
|
+
extrinsic = {
|
|
608
|
+
These: pallets,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
extrinsic = {
|
|
613
|
+
Except: pallets,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
return extrinsic;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* @hidden
|
|
620
|
+
*/
|
|
621
|
+
function transactionPermissionsToExtrinsicPermissions(transactionPermissions, context) {
|
|
622
|
+
return context.createType('ExtrinsicPermissions', transactionPermissions ? buildPalletPermissions(transactionPermissions) : 'Whole');
|
|
623
|
+
}
|
|
624
|
+
exports.transactionPermissionsToExtrinsicPermissions = transactionPermissionsToExtrinsicPermissions;
|
|
625
|
+
/**
|
|
626
|
+
* @hidden
|
|
627
|
+
*/
|
|
628
|
+
function permissionsToMeshPermissions(permissions, context) {
|
|
629
|
+
const { assets, transactions, portfolios } = permissions;
|
|
630
|
+
const extrinsic = transactionPermissionsToExtrinsicPermissions(transactions, context);
|
|
631
|
+
let asset = 'Whole';
|
|
632
|
+
if (assets) {
|
|
633
|
+
const { values: assetValues, type } = assets;
|
|
634
|
+
assetValues.sort(({ ticker: tickerA }, { ticker: tickerB }) => tickerA.localeCompare(tickerB));
|
|
635
|
+
const tickers = assetValues.map(({ ticker }) => stringToTicker(ticker, context));
|
|
636
|
+
if (type === types_3.PermissionType.Include) {
|
|
637
|
+
asset = {
|
|
638
|
+
These: tickers,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
asset = {
|
|
643
|
+
Except: tickers,
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
let portfolio = 'Whole';
|
|
648
|
+
if (portfolios) {
|
|
649
|
+
const { values: portfolioValues, type } = portfolios;
|
|
650
|
+
const portfolioIds = portfolioValues.map(pValue => portfolioIdToMeshPortfolioId(portfolioToPortfolioId(pValue), context));
|
|
651
|
+
if (type === types_3.PermissionType.Include) {
|
|
652
|
+
portfolio = {
|
|
653
|
+
These: portfolioIds,
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
else {
|
|
657
|
+
portfolio = {
|
|
658
|
+
Except: portfolioIds,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
const value = {
|
|
663
|
+
asset,
|
|
664
|
+
extrinsic,
|
|
665
|
+
portfolio,
|
|
666
|
+
};
|
|
667
|
+
return context.createType('Permissions', value);
|
|
668
|
+
}
|
|
669
|
+
exports.permissionsToMeshPermissions = permissionsToMeshPermissions;
|
|
670
|
+
/**
|
|
671
|
+
* @hidden
|
|
672
|
+
*/
|
|
673
|
+
function extrinsicPermissionsToTransactionPermissions(permissions) {
|
|
674
|
+
let extrinsicType;
|
|
675
|
+
let pallets;
|
|
676
|
+
if (permissions.isThese) {
|
|
677
|
+
extrinsicType = types_3.PermissionType.Include;
|
|
678
|
+
pallets = permissions.asThese;
|
|
679
|
+
}
|
|
680
|
+
else if (permissions.isExcept) {
|
|
681
|
+
extrinsicType = types_3.PermissionType.Exclude;
|
|
682
|
+
pallets = permissions.asExcept;
|
|
683
|
+
}
|
|
684
|
+
let txValues = [];
|
|
685
|
+
let exceptions = [];
|
|
686
|
+
const formatTxTag = (dispatchable, moduleName) => `${moduleName}.${(0, lodash_1.camelCase)(textToString(dispatchable))}`;
|
|
687
|
+
if (pallets) {
|
|
688
|
+
pallets.forEach(({ pallet_name: palletName, dispatchable_names: dispatchableNames }) => {
|
|
689
|
+
const moduleName = (0, util_1.stringLowerFirst)(textToString(palletName));
|
|
690
|
+
if (dispatchableNames.isExcept) {
|
|
691
|
+
const dispatchables = dispatchableNames.asExcept;
|
|
692
|
+
exceptions = [...exceptions, ...dispatchables.map(name => formatTxTag(name, moduleName))];
|
|
693
|
+
txValues = [...txValues, moduleName];
|
|
694
|
+
}
|
|
695
|
+
else if (dispatchableNames.isThese) {
|
|
696
|
+
const dispatchables = dispatchableNames.asThese;
|
|
697
|
+
txValues = [...txValues, ...dispatchables.map(name => formatTxTag(name, moduleName))];
|
|
698
|
+
}
|
|
699
|
+
else {
|
|
700
|
+
txValues = [...txValues, moduleName];
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
const result = {
|
|
704
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
705
|
+
type: extrinsicType,
|
|
706
|
+
values: txValues,
|
|
707
|
+
};
|
|
708
|
+
return exceptions.length ? Object.assign(Object.assign({}, result), { exceptions }) : result;
|
|
709
|
+
}
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
exports.extrinsicPermissionsToTransactionPermissions = extrinsicPermissionsToTransactionPermissions;
|
|
713
|
+
/**
|
|
714
|
+
* @hidden
|
|
715
|
+
*/
|
|
716
|
+
function meshPermissionsToPermissions(permissions, context) {
|
|
717
|
+
const { asset, extrinsic, portfolio } = permissions;
|
|
718
|
+
let assets = null;
|
|
719
|
+
let transactions = null;
|
|
720
|
+
let portfolios = null;
|
|
721
|
+
let assetsType;
|
|
722
|
+
let assetsPermissions;
|
|
723
|
+
if (asset.isThese) {
|
|
724
|
+
assetsType = types_3.PermissionType.Include;
|
|
725
|
+
assetsPermissions = asset.asThese;
|
|
726
|
+
}
|
|
727
|
+
else if (asset.isExcept) {
|
|
728
|
+
assetsType = types_3.PermissionType.Exclude;
|
|
729
|
+
assetsPermissions = asset.asExcept;
|
|
730
|
+
}
|
|
731
|
+
if (assetsPermissions) {
|
|
732
|
+
assets = {
|
|
733
|
+
values: assetsPermissions.map(ticker => new internal_1.Asset({ ticker: tickerToString(ticker) }, context)),
|
|
734
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
735
|
+
type: assetsType,
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
transactions = extrinsicPermissionsToTransactionPermissions(extrinsic);
|
|
739
|
+
let portfoliosType;
|
|
740
|
+
let portfolioIds;
|
|
741
|
+
if (portfolio.isThese) {
|
|
742
|
+
portfoliosType = types_3.PermissionType.Include;
|
|
743
|
+
portfolioIds = portfolio.asThese;
|
|
744
|
+
}
|
|
745
|
+
else if (portfolio.isExcept) {
|
|
746
|
+
portfoliosType = types_3.PermissionType.Exclude;
|
|
747
|
+
portfolioIds = portfolio.asExcept;
|
|
748
|
+
}
|
|
749
|
+
if (portfolioIds) {
|
|
750
|
+
portfolios = {
|
|
751
|
+
values: portfolioIds.map(portfolioId => meshPortfolioIdToPortfolio(portfolioId, context)),
|
|
752
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
753
|
+
type: portfoliosType,
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
return {
|
|
757
|
+
assets,
|
|
758
|
+
transactions,
|
|
759
|
+
transactionGroups: transactions ? transactionPermissionsToTxGroups(transactions) : [],
|
|
760
|
+
portfolios,
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
exports.meshPermissionsToPermissions = meshPermissionsToPermissions;
|
|
764
|
+
/**
|
|
765
|
+
* @hidden
|
|
766
|
+
*/
|
|
767
|
+
function bigNumberToU32(value, context) {
|
|
768
|
+
(0, internal_3.assertIsInteger)(value);
|
|
769
|
+
(0, internal_3.assertIsPositive)(value);
|
|
770
|
+
return context.createType('u32', value.toString());
|
|
771
|
+
}
|
|
772
|
+
exports.bigNumberToU32 = bigNumberToU32;
|
|
773
|
+
/**
|
|
774
|
+
* @hidden
|
|
775
|
+
*/
|
|
776
|
+
function u32ToBigNumber(value) {
|
|
777
|
+
return new bignumber_js_1.default(value.toString());
|
|
778
|
+
}
|
|
779
|
+
exports.u32ToBigNumber = u32ToBigNumber;
|
|
780
|
+
/**
|
|
781
|
+
* @hidden
|
|
782
|
+
*/
|
|
783
|
+
function u8ToBigNumber(value) {
|
|
784
|
+
return new bignumber_js_1.default(value.toString());
|
|
785
|
+
}
|
|
786
|
+
exports.u8ToBigNumber = u8ToBigNumber;
|
|
787
|
+
/**
|
|
788
|
+
* @hidden
|
|
789
|
+
*/
|
|
790
|
+
function permissionGroupIdentifierToAgentGroup(permissionGroup, context) {
|
|
791
|
+
return context.createType('AgentGroup', typeof permissionGroup !== 'object'
|
|
792
|
+
? permissionGroup
|
|
793
|
+
: { Custom: bigNumberToU32(permissionGroup.custom, context) });
|
|
794
|
+
}
|
|
795
|
+
exports.permissionGroupIdentifierToAgentGroup = permissionGroupIdentifierToAgentGroup;
|
|
796
|
+
/**
|
|
797
|
+
* @hidden
|
|
798
|
+
*/
|
|
799
|
+
function agentGroupToPermissionGroupIdentifier(agentGroup) {
|
|
800
|
+
if (agentGroup.isFull) {
|
|
801
|
+
return types_3.PermissionGroupType.Full;
|
|
802
|
+
}
|
|
803
|
+
else if (agentGroup.isExceptMeta) {
|
|
804
|
+
return types_3.PermissionGroupType.ExceptMeta;
|
|
805
|
+
}
|
|
806
|
+
else if (agentGroup.isPolymeshV1Caa) {
|
|
807
|
+
return types_3.PermissionGroupType.PolymeshV1Caa;
|
|
808
|
+
}
|
|
809
|
+
else if (agentGroup.isPolymeshV1Pia) {
|
|
810
|
+
return types_3.PermissionGroupType.PolymeshV1Pia;
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
return { custom: u32ToBigNumber(agentGroup.asCustom) };
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
exports.agentGroupToPermissionGroupIdentifier = agentGroupToPermissionGroupIdentifier;
|
|
817
|
+
/**
|
|
818
|
+
* @hidden
|
|
819
|
+
*/
|
|
820
|
+
function authorizationToAuthorizationData(auth, context) {
|
|
821
|
+
let value;
|
|
822
|
+
const { type } = auth;
|
|
823
|
+
if (type === types_3.AuthorizationType.RotatePrimaryKey) {
|
|
824
|
+
value = null;
|
|
825
|
+
}
|
|
826
|
+
else if (type === types_3.AuthorizationType.JoinIdentity) {
|
|
827
|
+
value = permissionsToMeshPermissions(auth.value, context);
|
|
828
|
+
}
|
|
829
|
+
else if (type === types_3.AuthorizationType.PortfolioCustody) {
|
|
830
|
+
value = portfolioIdToMeshPortfolioId(portfolioToPortfolioId(auth.value), context);
|
|
831
|
+
}
|
|
832
|
+
else if (auth.type === types_3.AuthorizationType.TransferAssetOwnership ||
|
|
833
|
+
auth.type === types_3.AuthorizationType.TransferTicker) {
|
|
834
|
+
value = stringToTicker(auth.value, context);
|
|
835
|
+
}
|
|
836
|
+
else if (type === types_3.AuthorizationType.RotatePrimaryKeyToSecondary) {
|
|
837
|
+
value = permissionsToMeshPermissions(auth.value, context);
|
|
838
|
+
}
|
|
839
|
+
else if (type === types_3.AuthorizationType.BecomeAgent) {
|
|
840
|
+
const ticker = stringToTicker(auth.value.asset.ticker, context);
|
|
841
|
+
if (auth.value instanceof internal_1.CustomPermissionGroup) {
|
|
842
|
+
const { id } = auth.value;
|
|
843
|
+
value = [ticker, permissionGroupIdentifierToAgentGroup({ custom: id }, context)];
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
const { type: groupType } = auth.value;
|
|
847
|
+
value = [ticker, permissionGroupIdentifierToAgentGroup(groupType, context)];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
else {
|
|
851
|
+
value = auth.value;
|
|
852
|
+
}
|
|
853
|
+
return context.createType('AuthorizationData', {
|
|
854
|
+
[type]: value,
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
exports.authorizationToAuthorizationData = authorizationToAuthorizationData;
|
|
858
|
+
/**
|
|
859
|
+
* @hidden
|
|
860
|
+
*/
|
|
861
|
+
function authorizationTypeToMeshAuthorizationType(authorizationType, context) {
|
|
862
|
+
return context.createType('AuthorizationType', authorizationType);
|
|
863
|
+
}
|
|
864
|
+
exports.authorizationTypeToMeshAuthorizationType = authorizationTypeToMeshAuthorizationType;
|
|
865
|
+
/**
|
|
866
|
+
* @hidden
|
|
867
|
+
*/
|
|
868
|
+
function bigNumberToBalance(value, context, divisible = true) {
|
|
869
|
+
(0, internal_3.assertIsPositive)(value);
|
|
870
|
+
if (value.isGreaterThan(constants_1.MAX_BALANCE)) {
|
|
871
|
+
throw new internal_1.PolymeshError({
|
|
872
|
+
code: types_3.ErrorCode.ValidationError,
|
|
873
|
+
message: 'The value exceeds the maximum possible balance',
|
|
874
|
+
data: {
|
|
875
|
+
currentValue: value,
|
|
876
|
+
amountLimit: constants_1.MAX_BALANCE,
|
|
877
|
+
},
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
if (divisible) {
|
|
881
|
+
if (value.decimalPlaces() > constants_1.MAX_DECIMALS) {
|
|
882
|
+
throw new internal_1.PolymeshError({
|
|
883
|
+
code: types_3.ErrorCode.ValidationError,
|
|
884
|
+
message: 'The value has more decimal places than allowed',
|
|
885
|
+
data: {
|
|
886
|
+
currentValue: value,
|
|
887
|
+
decimalsLimit: constants_1.MAX_DECIMALS,
|
|
888
|
+
},
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
if (value.decimalPlaces()) {
|
|
894
|
+
throw new internal_1.PolymeshError({
|
|
895
|
+
code: types_3.ErrorCode.ValidationError,
|
|
896
|
+
message: 'The value has decimals but the Asset is indivisible',
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
return context.createType('Balance', value.shiftedBy(6).toString());
|
|
901
|
+
}
|
|
902
|
+
exports.bigNumberToBalance = bigNumberToBalance;
|
|
903
|
+
/**
|
|
904
|
+
* @hidden
|
|
905
|
+
*/
|
|
906
|
+
function balanceToBigNumber(balance) {
|
|
907
|
+
return new bignumber_js_1.default(balance.toString()).shiftedBy(-6);
|
|
908
|
+
}
|
|
909
|
+
exports.balanceToBigNumber = balanceToBigNumber;
|
|
910
|
+
/**
|
|
911
|
+
* @hidden
|
|
912
|
+
*/
|
|
913
|
+
function agentGroupToPermissionGroup(agentGroup, ticker, context) {
|
|
914
|
+
const permissionGroupIdentifier = agentGroupToPermissionGroupIdentifier(agentGroup);
|
|
915
|
+
switch (permissionGroupIdentifier) {
|
|
916
|
+
case types_3.PermissionGroupType.ExceptMeta:
|
|
917
|
+
case types_3.PermissionGroupType.Full:
|
|
918
|
+
case types_3.PermissionGroupType.PolymeshV1Caa:
|
|
919
|
+
case types_3.PermissionGroupType.PolymeshV1Pia: {
|
|
920
|
+
return new internal_1.KnownPermissionGroup({ type: permissionGroupIdentifier, ticker }, context);
|
|
921
|
+
}
|
|
922
|
+
default: {
|
|
923
|
+
const { custom: id } = permissionGroupIdentifier;
|
|
924
|
+
return new internal_1.CustomPermissionGroup({ id, ticker }, context);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
exports.agentGroupToPermissionGroup = agentGroupToPermissionGroup;
|
|
929
|
+
/**
|
|
930
|
+
* @hidden
|
|
931
|
+
*/
|
|
932
|
+
function authorizationDataToAuthorization(auth, context) {
|
|
933
|
+
if (auth.isAttestPrimaryKeyRotation) {
|
|
934
|
+
return {
|
|
935
|
+
type: types_3.AuthorizationType.AttestPrimaryKeyRotation,
|
|
936
|
+
value: identityIdToString(auth.asAttestPrimaryKeyRotation),
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
if (auth.isRotatePrimaryKey) {
|
|
940
|
+
return {
|
|
941
|
+
type: types_3.AuthorizationType.RotatePrimaryKey,
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
if (auth.isTransferTicker) {
|
|
945
|
+
return {
|
|
946
|
+
type: types_3.AuthorizationType.TransferTicker,
|
|
947
|
+
value: tickerToString(auth.asTransferTicker),
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
if (auth.isAddMultiSigSigner) {
|
|
951
|
+
return {
|
|
952
|
+
type: types_3.AuthorizationType.AddMultiSigSigner,
|
|
953
|
+
value: accountIdToString(auth.asAddMultiSigSigner),
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
if (auth.isTransferAssetOwnership) {
|
|
957
|
+
return {
|
|
958
|
+
type: types_3.AuthorizationType.TransferAssetOwnership,
|
|
959
|
+
value: tickerToString(auth.asTransferAssetOwnership),
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
if (auth.isPortfolioCustody) {
|
|
963
|
+
return {
|
|
964
|
+
type: types_3.AuthorizationType.PortfolioCustody,
|
|
965
|
+
value: meshPortfolioIdToPortfolio(auth.asPortfolioCustody, context),
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
if (auth.isJoinIdentity) {
|
|
969
|
+
return {
|
|
970
|
+
type: types_3.AuthorizationType.JoinIdentity,
|
|
971
|
+
value: meshPermissionsToPermissions(auth.asJoinIdentity, context),
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
if (auth.isAddRelayerPayingKey) {
|
|
975
|
+
const [userKey, payingKey, polyxLimit] = auth.asAddRelayerPayingKey;
|
|
976
|
+
return {
|
|
977
|
+
type: types_3.AuthorizationType.AddRelayerPayingKey,
|
|
978
|
+
value: {
|
|
979
|
+
beneficiary: new internal_1.Account({ address: accountIdToString(userKey) }, context),
|
|
980
|
+
subsidizer: new internal_1.Account({ address: accountIdToString(payingKey) }, context),
|
|
981
|
+
allowance: balanceToBigNumber(polyxLimit),
|
|
982
|
+
},
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
if (auth.isBecomeAgent) {
|
|
986
|
+
const [ticker, agentGroup] = auth.asBecomeAgent;
|
|
987
|
+
return {
|
|
988
|
+
type: types_3.AuthorizationType.BecomeAgent,
|
|
989
|
+
value: agentGroupToPermissionGroup(agentGroup, tickerToString(ticker), context),
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
if (auth.isRotatePrimaryKeyToSecondary) {
|
|
993
|
+
return {
|
|
994
|
+
type: types_3.AuthorizationType.RotatePrimaryKeyToSecondary,
|
|
995
|
+
value: meshPermissionsToPermissions(auth.asRotatePrimaryKeyToSecondary, context),
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
throw new internal_1.PolymeshError({
|
|
999
|
+
code: types_3.ErrorCode.UnexpectedError,
|
|
1000
|
+
message: 'Unsupported Authorization Type. Please contact the Polymath team',
|
|
1001
|
+
data: {
|
|
1002
|
+
auth: JSON.stringify(auth, null, 2),
|
|
1003
|
+
},
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
exports.authorizationDataToAuthorization = authorizationDataToAuthorization;
|
|
1007
|
+
/**
|
|
1008
|
+
* @hidden
|
|
1009
|
+
*/
|
|
1010
|
+
function stringToMemo(value, context) {
|
|
1011
|
+
if (value.length > constants_1.MAX_MEMO_LENGTH) {
|
|
1012
|
+
throw new internal_1.PolymeshError({
|
|
1013
|
+
code: types_3.ErrorCode.ValidationError,
|
|
1014
|
+
message: 'Max memo length exceeded',
|
|
1015
|
+
data: {
|
|
1016
|
+
maxLength: constants_1.MAX_MEMO_LENGTH,
|
|
1017
|
+
},
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
return context.createType('Memo', (0, internal_3.padString)(value, constants_1.MAX_MEMO_LENGTH));
|
|
1021
|
+
}
|
|
1022
|
+
exports.stringToMemo = stringToMemo;
|
|
1023
|
+
/**
|
|
1024
|
+
* @hidden
|
|
1025
|
+
*/
|
|
1026
|
+
function u8ToTransferStatus(status) {
|
|
1027
|
+
const code = status.toNumber();
|
|
1028
|
+
switch (code) {
|
|
1029
|
+
case 81: {
|
|
1030
|
+
return types_3.TransferStatus.Success;
|
|
1031
|
+
}
|
|
1032
|
+
case 82: {
|
|
1033
|
+
return types_3.TransferStatus.InsufficientBalance;
|
|
1034
|
+
}
|
|
1035
|
+
case 83: {
|
|
1036
|
+
return types_3.TransferStatus.InsufficientAllowance;
|
|
1037
|
+
}
|
|
1038
|
+
case 84: {
|
|
1039
|
+
return types_3.TransferStatus.TransfersHalted;
|
|
1040
|
+
}
|
|
1041
|
+
case 85: {
|
|
1042
|
+
return types_3.TransferStatus.FundsLocked;
|
|
1043
|
+
}
|
|
1044
|
+
case 86: {
|
|
1045
|
+
return types_3.TransferStatus.InvalidSenderAddress;
|
|
1046
|
+
}
|
|
1047
|
+
case 87: {
|
|
1048
|
+
return types_3.TransferStatus.InvalidReceiverAddress;
|
|
1049
|
+
}
|
|
1050
|
+
case 88: {
|
|
1051
|
+
return types_3.TransferStatus.InvalidOperator;
|
|
1052
|
+
}
|
|
1053
|
+
case 160: {
|
|
1054
|
+
return types_3.TransferStatus.InvalidSenderIdentity;
|
|
1055
|
+
}
|
|
1056
|
+
case 161: {
|
|
1057
|
+
return types_3.TransferStatus.InvalidReceiverIdentity;
|
|
1058
|
+
}
|
|
1059
|
+
case 162: {
|
|
1060
|
+
return types_3.TransferStatus.ComplianceFailure;
|
|
1061
|
+
}
|
|
1062
|
+
case 163: {
|
|
1063
|
+
return types_3.TransferStatus.SmartExtensionFailure;
|
|
1064
|
+
}
|
|
1065
|
+
case 164: {
|
|
1066
|
+
return types_3.TransferStatus.InvalidGranularity;
|
|
1067
|
+
}
|
|
1068
|
+
case 165: {
|
|
1069
|
+
return types_3.TransferStatus.VolumeLimitReached;
|
|
1070
|
+
}
|
|
1071
|
+
case 166: {
|
|
1072
|
+
return types_3.TransferStatus.BlockedTransaction;
|
|
1073
|
+
}
|
|
1074
|
+
case 168: {
|
|
1075
|
+
return types_3.TransferStatus.FundsLimitReached;
|
|
1076
|
+
}
|
|
1077
|
+
case 169: {
|
|
1078
|
+
return types_3.TransferStatus.PortfolioFailure;
|
|
1079
|
+
}
|
|
1080
|
+
case 170: {
|
|
1081
|
+
return types_3.TransferStatus.CustodianError;
|
|
1082
|
+
}
|
|
1083
|
+
case 171: {
|
|
1084
|
+
return types_3.TransferStatus.ScopeClaimMissing;
|
|
1085
|
+
}
|
|
1086
|
+
case 172: {
|
|
1087
|
+
return types_3.TransferStatus.TransferRestrictionFailure;
|
|
1088
|
+
}
|
|
1089
|
+
case 80: {
|
|
1090
|
+
return types_3.TransferStatus.Failure;
|
|
1091
|
+
}
|
|
1092
|
+
default: {
|
|
1093
|
+
throw new internal_1.PolymeshError({
|
|
1094
|
+
code: types_3.ErrorCode.UnexpectedError,
|
|
1095
|
+
message: `Unsupported status code "${status.toString()}". Please report this issue to the Polymath team`,
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
exports.u8ToTransferStatus = u8ToTransferStatus;
|
|
1101
|
+
/**
|
|
1102
|
+
* @hidden
|
|
1103
|
+
*/
|
|
1104
|
+
function internalAssetTypeToAssetType(type, context) {
|
|
1105
|
+
return context.createType('AssetType', type);
|
|
1106
|
+
}
|
|
1107
|
+
exports.internalAssetTypeToAssetType = internalAssetTypeToAssetType;
|
|
1108
|
+
/**
|
|
1109
|
+
* @hidden
|
|
1110
|
+
*/
|
|
1111
|
+
function assetTypeToKnownOrId(assetType) {
|
|
1112
|
+
if (assetType.isEquityCommon) {
|
|
1113
|
+
return types_3.KnownAssetType.EquityCommon;
|
|
1114
|
+
}
|
|
1115
|
+
if (assetType.isEquityPreferred) {
|
|
1116
|
+
return types_3.KnownAssetType.EquityPreferred;
|
|
1117
|
+
}
|
|
1118
|
+
if (assetType.isCommodity) {
|
|
1119
|
+
return types_3.KnownAssetType.Commodity;
|
|
1120
|
+
}
|
|
1121
|
+
if (assetType.isFixedIncome) {
|
|
1122
|
+
return types_3.KnownAssetType.FixedIncome;
|
|
1123
|
+
}
|
|
1124
|
+
if (assetType.isReit) {
|
|
1125
|
+
return types_3.KnownAssetType.Reit;
|
|
1126
|
+
}
|
|
1127
|
+
if (assetType.isFund) {
|
|
1128
|
+
return types_3.KnownAssetType.Fund;
|
|
1129
|
+
}
|
|
1130
|
+
if (assetType.isRevenueShareAgreement) {
|
|
1131
|
+
return types_3.KnownAssetType.RevenueShareAgreement;
|
|
1132
|
+
}
|
|
1133
|
+
if (assetType.isStructuredProduct) {
|
|
1134
|
+
return types_3.KnownAssetType.StructuredProduct;
|
|
1135
|
+
}
|
|
1136
|
+
if (assetType.isDerivative) {
|
|
1137
|
+
return types_3.KnownAssetType.Derivative;
|
|
1138
|
+
}
|
|
1139
|
+
if (assetType.isStableCoin) {
|
|
1140
|
+
return types_3.KnownAssetType.StableCoin;
|
|
1141
|
+
}
|
|
1142
|
+
return u32ToBigNumber(assetType.asCustom);
|
|
1143
|
+
}
|
|
1144
|
+
exports.assetTypeToKnownOrId = assetTypeToKnownOrId;
|
|
1145
|
+
/**
|
|
1146
|
+
* @hidden
|
|
1147
|
+
*/
|
|
1148
|
+
function posRatioToBigNumber(postRatio) {
|
|
1149
|
+
const [numerator, denominator] = postRatio.map(u32ToBigNumber);
|
|
1150
|
+
return numerator.dividedBy(denominator);
|
|
1151
|
+
}
|
|
1152
|
+
exports.posRatioToBigNumber = posRatioToBigNumber;
|
|
1153
|
+
/**
|
|
1154
|
+
* @hidden
|
|
1155
|
+
*/
|
|
1156
|
+
function isIsinValid(isin) {
|
|
1157
|
+
isin = isin.toUpperCase();
|
|
1158
|
+
if (!/^[0-9A-Z]{12}$/.test(isin)) {
|
|
1159
|
+
return false;
|
|
1160
|
+
}
|
|
1161
|
+
const v = [];
|
|
1162
|
+
(0, lodash_1.rangeRight)(11).forEach(i => {
|
|
1163
|
+
const c = parseInt(isin.charAt(i));
|
|
1164
|
+
if (isNaN(c)) {
|
|
1165
|
+
const letterCode = isin.charCodeAt(i) - 55;
|
|
1166
|
+
v.push(letterCode % 10);
|
|
1167
|
+
v.push(Math.floor(letterCode / 10));
|
|
1168
|
+
}
|
|
1169
|
+
else {
|
|
1170
|
+
v.push(Number(c));
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
let sum = 0;
|
|
1174
|
+
(0, lodash_1.range)(v.length).forEach(i => {
|
|
1175
|
+
if (i % 2 === 0) {
|
|
1176
|
+
const d = v[i] * 2;
|
|
1177
|
+
sum += Math.floor(d / 10);
|
|
1178
|
+
sum += d % 10;
|
|
1179
|
+
}
|
|
1180
|
+
else {
|
|
1181
|
+
sum += v[i];
|
|
1182
|
+
}
|
|
1183
|
+
});
|
|
1184
|
+
return (10 - (sum % 10)) % 10 === Number(isin[isin.length - 1]);
|
|
1185
|
+
}
|
|
1186
|
+
exports.isIsinValid = isIsinValid;
|
|
1187
|
+
/**
|
|
1188
|
+
* @hidden
|
|
1189
|
+
*
|
|
1190
|
+
* @note CINS and CUSIP use the same validation
|
|
1191
|
+
*/
|
|
1192
|
+
function isCusipValid(cusip) {
|
|
1193
|
+
cusip = cusip.toUpperCase();
|
|
1194
|
+
if (!/^[0-9A-Z@#*]{9}$/.test(cusip)) {
|
|
1195
|
+
return false;
|
|
1196
|
+
}
|
|
1197
|
+
let sum = 0;
|
|
1198
|
+
// cSpell: disable-next-line
|
|
1199
|
+
const cusipChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ*@#'.split('');
|
|
1200
|
+
const cusipLength = cusip.length - 1;
|
|
1201
|
+
(0, lodash_1.range)(cusipLength).forEach(i => {
|
|
1202
|
+
const item = cusip[i];
|
|
1203
|
+
const code = item.charCodeAt(0);
|
|
1204
|
+
let num;
|
|
1205
|
+
if (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0)) {
|
|
1206
|
+
num = cusipChars.indexOf(item) + 10;
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
num = Number(item);
|
|
1210
|
+
}
|
|
1211
|
+
if (i % 2 !== 0) {
|
|
1212
|
+
num *= 2;
|
|
1213
|
+
}
|
|
1214
|
+
num = (num % 10) + Math.floor(num / 10);
|
|
1215
|
+
sum += num;
|
|
1216
|
+
});
|
|
1217
|
+
return (10 - (sum % 10)) % 10 === Number(cusip[cusip.length - 1]);
|
|
1218
|
+
}
|
|
1219
|
+
exports.isCusipValid = isCusipValid;
|
|
1220
|
+
/**
|
|
1221
|
+
* @hidden
|
|
1222
|
+
*/
|
|
1223
|
+
function isLeiValid(lei) {
|
|
1224
|
+
lei = lei.toUpperCase();
|
|
1225
|
+
if (!/^[0-9A-Z]{18}\d{2}$/.test(lei)) {
|
|
1226
|
+
return false;
|
|
1227
|
+
}
|
|
1228
|
+
return (0, iso_7064_1.computeWithoutCheck)(lei) === 1;
|
|
1229
|
+
}
|
|
1230
|
+
exports.isLeiValid = isLeiValid;
|
|
1231
|
+
/**
|
|
1232
|
+
* @hidden
|
|
1233
|
+
*/
|
|
1234
|
+
function securityIdentifierToAssetIdentifier(identifier, context) {
|
|
1235
|
+
const { type, value } = identifier;
|
|
1236
|
+
let error = false;
|
|
1237
|
+
switch (type) {
|
|
1238
|
+
case types_3.SecurityIdentifierType.Isin: {
|
|
1239
|
+
if (!isIsinValid(value)) {
|
|
1240
|
+
error = true;
|
|
1241
|
+
}
|
|
1242
|
+
break;
|
|
1243
|
+
}
|
|
1244
|
+
case types_3.SecurityIdentifierType.Lei: {
|
|
1245
|
+
if (!isLeiValid(value)) {
|
|
1246
|
+
error = true;
|
|
1247
|
+
}
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
// CINS and CUSIP use the same validation
|
|
1251
|
+
default: {
|
|
1252
|
+
if (!isCusipValid(value)) {
|
|
1253
|
+
error = true;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
if (error) {
|
|
1258
|
+
throw new internal_1.PolymeshError({
|
|
1259
|
+
code: types_3.ErrorCode.ValidationError,
|
|
1260
|
+
message: `Invalid security identifier ${value} of type ${type}`,
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
return context.createType('AssetIdentifier', { [type]: value });
|
|
1264
|
+
}
|
|
1265
|
+
exports.securityIdentifierToAssetIdentifier = securityIdentifierToAssetIdentifier;
|
|
1266
|
+
/**
|
|
1267
|
+
* @hidden
|
|
1268
|
+
*/
|
|
1269
|
+
function assetIdentifierToSecurityIdentifier(identifier) {
|
|
1270
|
+
if (identifier.isCusip) {
|
|
1271
|
+
return {
|
|
1272
|
+
type: types_3.SecurityIdentifierType.Cusip,
|
|
1273
|
+
value: (0, util_1.u8aToString)(identifier.asCusip),
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
if (identifier.isIsin) {
|
|
1277
|
+
return {
|
|
1278
|
+
type: types_3.SecurityIdentifierType.Isin,
|
|
1279
|
+
value: (0, util_1.u8aToString)(identifier.asIsin),
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
if (identifier.isCins) {
|
|
1283
|
+
return {
|
|
1284
|
+
type: types_3.SecurityIdentifierType.Cins,
|
|
1285
|
+
value: (0, util_1.u8aToString)(identifier.asCins),
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
type: types_3.SecurityIdentifierType.Lei,
|
|
1290
|
+
value: (0, util_1.u8aToString)(identifier.asLei),
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
exports.assetIdentifierToSecurityIdentifier = assetIdentifierToSecurityIdentifier;
|
|
1294
|
+
/**
|
|
1295
|
+
* @hidden
|
|
1296
|
+
*/
|
|
1297
|
+
function stringToFundingRoundName(roundName, context) {
|
|
1298
|
+
return context.createType('FundingRoundName', roundName);
|
|
1299
|
+
}
|
|
1300
|
+
exports.stringToFundingRoundName = stringToFundingRoundName;
|
|
1301
|
+
/**
|
|
1302
|
+
* @hidden
|
|
1303
|
+
*/
|
|
1304
|
+
function fundingRoundNameToString(roundName) {
|
|
1305
|
+
return roundName.toString();
|
|
1306
|
+
}
|
|
1307
|
+
exports.fundingRoundNameToString = fundingRoundNameToString;
|
|
1308
|
+
/**
|
|
1309
|
+
* @hidden
|
|
1310
|
+
*/
|
|
1311
|
+
function stringToDocumentName(docName, context) {
|
|
1312
|
+
return context.createType('DocumentName', docName);
|
|
1313
|
+
}
|
|
1314
|
+
exports.stringToDocumentName = stringToDocumentName;
|
|
1315
|
+
/**
|
|
1316
|
+
* @hidden
|
|
1317
|
+
*/
|
|
1318
|
+
function documentNameToString(docName) {
|
|
1319
|
+
return docName.toString();
|
|
1320
|
+
}
|
|
1321
|
+
exports.documentNameToString = documentNameToString;
|
|
1322
|
+
/**
|
|
1323
|
+
* @hidden
|
|
1324
|
+
*/
|
|
1325
|
+
function stringToDocumentType(docType, context) {
|
|
1326
|
+
return context.createType('DocumentType', docType);
|
|
1327
|
+
}
|
|
1328
|
+
exports.stringToDocumentType = stringToDocumentType;
|
|
1329
|
+
/**
|
|
1330
|
+
* @hidden
|
|
1331
|
+
*/
|
|
1332
|
+
function documentTypeToString(docType) {
|
|
1333
|
+
return docType.toString();
|
|
1334
|
+
}
|
|
1335
|
+
exports.documentTypeToString = documentTypeToString;
|
|
1336
|
+
/**
|
|
1337
|
+
* @hidden
|
|
1338
|
+
*/
|
|
1339
|
+
function stringToDocumentUri(docUri, context) {
|
|
1340
|
+
return context.createType('DocumentUri', docUri);
|
|
1341
|
+
}
|
|
1342
|
+
exports.stringToDocumentUri = stringToDocumentUri;
|
|
1343
|
+
/**
|
|
1344
|
+
* @hidden
|
|
1345
|
+
*/
|
|
1346
|
+
function documentUriToString(docUri) {
|
|
1347
|
+
return docUri.toString();
|
|
1348
|
+
}
|
|
1349
|
+
exports.documentUriToString = documentUriToString;
|
|
1350
|
+
/**
|
|
1351
|
+
* @hidden
|
|
1352
|
+
*/
|
|
1353
|
+
function stringToDocumentHash(docHash, context) {
|
|
1354
|
+
if (docHash === undefined) {
|
|
1355
|
+
return context.createType('DocumentHash', 'None');
|
|
1356
|
+
}
|
|
1357
|
+
if (!(0, util_1.isHex)(docHash, -1, true)) {
|
|
1358
|
+
throw new internal_1.PolymeshError({
|
|
1359
|
+
code: types_3.ErrorCode.ValidationError,
|
|
1360
|
+
message: 'Document hash must be a hexadecimal string prefixed by 0x',
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
const { length } = docHash;
|
|
1364
|
+
// array of Hash types (H128, H160, etc) and their corresponding hex lengths
|
|
1365
|
+
const hashTypes = [32, 40, 48, 56, 64, 80, 96, 128].map(max => ({
|
|
1366
|
+
maxLength: max + 2,
|
|
1367
|
+
key: `H${max * 4}`,
|
|
1368
|
+
}));
|
|
1369
|
+
const type = hashTypes.find(({ maxLength: max }) => length <= max);
|
|
1370
|
+
if (!type) {
|
|
1371
|
+
throw new internal_1.PolymeshError({
|
|
1372
|
+
code: types_3.ErrorCode.ValidationError,
|
|
1373
|
+
message: 'Document hash exceeds max length',
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
const { maxLength, key } = type;
|
|
1377
|
+
return context.createType('DocumentHash', {
|
|
1378
|
+
[key]: (0, util_1.hexToU8a)(docHash.padEnd(maxLength, '0')),
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
exports.stringToDocumentHash = stringToDocumentHash;
|
|
1382
|
+
/**
|
|
1383
|
+
* @hidden
|
|
1384
|
+
*/
|
|
1385
|
+
function documentHashToString(docHash) {
|
|
1386
|
+
if (docHash.isNone) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
if (docHash.isH128) {
|
|
1390
|
+
return (0, util_1.u8aToHex)(docHash.asH128);
|
|
1391
|
+
}
|
|
1392
|
+
if (docHash.isH160) {
|
|
1393
|
+
return (0, util_1.u8aToHex)(docHash.asH160);
|
|
1394
|
+
}
|
|
1395
|
+
if (docHash.isH192) {
|
|
1396
|
+
return (0, util_1.u8aToHex)(docHash.asH192);
|
|
1397
|
+
}
|
|
1398
|
+
if (docHash.isH224) {
|
|
1399
|
+
return (0, util_1.u8aToHex)(docHash.asH224);
|
|
1400
|
+
}
|
|
1401
|
+
if (docHash.isH256) {
|
|
1402
|
+
return (0, util_1.u8aToHex)(docHash.asH256);
|
|
1403
|
+
}
|
|
1404
|
+
if (docHash.isH320) {
|
|
1405
|
+
return (0, util_1.u8aToHex)(docHash.asH320);
|
|
1406
|
+
}
|
|
1407
|
+
if (docHash.isH384) {
|
|
1408
|
+
return (0, util_1.u8aToHex)(docHash.asH384);
|
|
1409
|
+
}
|
|
1410
|
+
return (0, util_1.u8aToHex)(docHash.asH512);
|
|
1411
|
+
}
|
|
1412
|
+
exports.documentHashToString = documentHashToString;
|
|
1413
|
+
/**
|
|
1414
|
+
* @hidden
|
|
1415
|
+
*/
|
|
1416
|
+
function assetDocumentToDocument({ uri, contentHash, name, filedAt, type }, context) {
|
|
1417
|
+
return context.createType('Document', {
|
|
1418
|
+
uri: stringToDocumentUri(uri, context),
|
|
1419
|
+
name: stringToDocumentName(name, context),
|
|
1420
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1421
|
+
content_hash: stringToDocumentHash(contentHash, context),
|
|
1422
|
+
doc_type: (0, internal_3.optionize)(stringToDocumentType)(type, context),
|
|
1423
|
+
filing_date: (0, internal_3.optionize)(dateToMoment)(filedAt, context),
|
|
1424
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
exports.assetDocumentToDocument = assetDocumentToDocument;
|
|
1428
|
+
/**
|
|
1429
|
+
* @hidden
|
|
1430
|
+
*/
|
|
1431
|
+
function documentToAssetDocument({ uri, content_hash: hash, name, doc_type: docType, filing_date: filingDate, }) {
|
|
1432
|
+
const filedAt = filingDate.unwrapOr(undefined);
|
|
1433
|
+
const type = docType.unwrapOr(undefined);
|
|
1434
|
+
const contentHash = documentHashToString(hash);
|
|
1435
|
+
let doc = {
|
|
1436
|
+
uri: documentUriToString(uri),
|
|
1437
|
+
name: documentNameToString(name),
|
|
1438
|
+
};
|
|
1439
|
+
if (contentHash) {
|
|
1440
|
+
doc = Object.assign(Object.assign({}, doc), { contentHash });
|
|
1441
|
+
}
|
|
1442
|
+
if (filedAt) {
|
|
1443
|
+
doc = Object.assign(Object.assign({}, doc), { filedAt: momentToDate(filedAt) });
|
|
1444
|
+
}
|
|
1445
|
+
if (type) {
|
|
1446
|
+
doc = Object.assign(Object.assign({}, doc), { type: documentTypeToString(type) });
|
|
1447
|
+
}
|
|
1448
|
+
return doc;
|
|
1449
|
+
}
|
|
1450
|
+
exports.documentToAssetDocument = documentToAssetDocument;
|
|
1451
|
+
/**
|
|
1452
|
+
* @hidden
|
|
1453
|
+
*/
|
|
1454
|
+
function cddStatusToBoolean(cddStatus) {
|
|
1455
|
+
if (cddStatus.isOk) {
|
|
1456
|
+
return true;
|
|
1457
|
+
}
|
|
1458
|
+
return false;
|
|
1459
|
+
}
|
|
1460
|
+
exports.cddStatusToBoolean = cddStatusToBoolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* @hidden
|
|
1463
|
+
*/
|
|
1464
|
+
function canTransferResultToTransferStatus(canTransferResult) {
|
|
1465
|
+
if (canTransferResult.isErr) {
|
|
1466
|
+
throw new internal_1.PolymeshError({
|
|
1467
|
+
code: types_3.ErrorCode.UnexpectedError,
|
|
1468
|
+
message: `Error while checking transfer validity: ${bytesToString(canTransferResult.asErr)}`,
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
return u8ToTransferStatus(canTransferResult.asOk);
|
|
1472
|
+
}
|
|
1473
|
+
exports.canTransferResultToTransferStatus = canTransferResultToTransferStatus;
|
|
1474
|
+
/**
|
|
1475
|
+
* @hidden
|
|
1476
|
+
*/
|
|
1477
|
+
function scopeToMeshScope(scope, context) {
|
|
1478
|
+
const { type, value } = scope;
|
|
1479
|
+
let scopeValue;
|
|
1480
|
+
switch (type) {
|
|
1481
|
+
case types_3.ScopeType.Ticker:
|
|
1482
|
+
scopeValue = stringToTicker(value, context);
|
|
1483
|
+
break;
|
|
1484
|
+
case types_3.ScopeType.Identity:
|
|
1485
|
+
scopeValue = stringToIdentityId(value, context);
|
|
1486
|
+
break;
|
|
1487
|
+
default:
|
|
1488
|
+
scopeValue = value;
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
return context.createType('Scope', {
|
|
1492
|
+
[type]: scopeValue,
|
|
1493
|
+
});
|
|
1494
|
+
}
|
|
1495
|
+
exports.scopeToMeshScope = scopeToMeshScope;
|
|
1496
|
+
/**
|
|
1497
|
+
* @hidden
|
|
1498
|
+
*/
|
|
1499
|
+
function meshScopeToScope(scope) {
|
|
1500
|
+
if (scope.isTicker) {
|
|
1501
|
+
return {
|
|
1502
|
+
type: types_3.ScopeType.Ticker,
|
|
1503
|
+
value: tickerToString(scope.asTicker),
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
if (scope.isIdentity) {
|
|
1507
|
+
return {
|
|
1508
|
+
type: types_3.ScopeType.Identity,
|
|
1509
|
+
value: identityIdToString(scope.asIdentity),
|
|
1510
|
+
};
|
|
1511
|
+
}
|
|
1512
|
+
return {
|
|
1513
|
+
type: types_3.ScopeType.Custom,
|
|
1514
|
+
value: (0, util_1.u8aToString)(scope.asCustom),
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
exports.meshScopeToScope = meshScopeToScope;
|
|
1518
|
+
/**
|
|
1519
|
+
* @hidden
|
|
1520
|
+
*/
|
|
1521
|
+
function stringToCddId(cddId, context) {
|
|
1522
|
+
return context.createType('CddId', cddId);
|
|
1523
|
+
}
|
|
1524
|
+
exports.stringToCddId = stringToCddId;
|
|
1525
|
+
/**
|
|
1526
|
+
* @hidden
|
|
1527
|
+
*/
|
|
1528
|
+
function cddIdToString(cddId) {
|
|
1529
|
+
return cddId.toString();
|
|
1530
|
+
}
|
|
1531
|
+
exports.cddIdToString = cddIdToString;
|
|
1532
|
+
/**
|
|
1533
|
+
* @hidden
|
|
1534
|
+
*/
|
|
1535
|
+
function stringToScopeId(scopeId, context) {
|
|
1536
|
+
return context.createType('ScopeId', scopeId);
|
|
1537
|
+
}
|
|
1538
|
+
exports.stringToScopeId = stringToScopeId;
|
|
1539
|
+
/**
|
|
1540
|
+
* @hidden
|
|
1541
|
+
*/
|
|
1542
|
+
function scopeIdToString(scopeId) {
|
|
1543
|
+
return scopeId.toString();
|
|
1544
|
+
}
|
|
1545
|
+
exports.scopeIdToString = scopeIdToString;
|
|
1546
|
+
/**
|
|
1547
|
+
* @hidden
|
|
1548
|
+
*/
|
|
1549
|
+
function claimToMeshClaim(claim, context) {
|
|
1550
|
+
let value;
|
|
1551
|
+
switch (claim.type) {
|
|
1552
|
+
case types_3.ClaimType.NoData: {
|
|
1553
|
+
value = null;
|
|
1554
|
+
break;
|
|
1555
|
+
}
|
|
1556
|
+
case types_3.ClaimType.CustomerDueDiligence: {
|
|
1557
|
+
value = stringToCddId(claim.id, context);
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
case types_3.ClaimType.Jurisdiction: {
|
|
1561
|
+
const { code, scope } = claim;
|
|
1562
|
+
value = (0, utils_2.tuple)(code, scopeToMeshScope(scope, context));
|
|
1563
|
+
break;
|
|
1564
|
+
}
|
|
1565
|
+
case types_3.ClaimType.InvestorUniqueness: {
|
|
1566
|
+
const { scope, cddId, scopeId } = claim;
|
|
1567
|
+
value = (0, utils_2.tuple)(scopeToMeshScope(scope, context), stringToScopeId(scopeId, context), stringToCddId(cddId, context));
|
|
1568
|
+
break;
|
|
1569
|
+
}
|
|
1570
|
+
case types_3.ClaimType.InvestorUniquenessV2: {
|
|
1571
|
+
value = stringToCddId(claim.cddId, context);
|
|
1572
|
+
break;
|
|
1573
|
+
}
|
|
1574
|
+
default: {
|
|
1575
|
+
value = scopeToMeshScope(claim.scope, context);
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
return context.createType('Claim', { [claim.type]: value });
|
|
1579
|
+
}
|
|
1580
|
+
exports.claimToMeshClaim = claimToMeshClaim;
|
|
1581
|
+
/**
|
|
1582
|
+
* @hidden
|
|
1583
|
+
*/
|
|
1584
|
+
function middlewareScopeToScope(scope) {
|
|
1585
|
+
const { type, value } = scope;
|
|
1586
|
+
switch (type) {
|
|
1587
|
+
case types_2.ClaimScopeTypeEnum.Ticker:
|
|
1588
|
+
// eslint-disable-next-line no-control-regex
|
|
1589
|
+
return { type: types_3.ScopeType.Ticker, value: (0, internal_3.removePadding)(value) };
|
|
1590
|
+
case types_2.ClaimScopeTypeEnum.Identity:
|
|
1591
|
+
case types_2.ClaimScopeTypeEnum.Custom:
|
|
1592
|
+
return { type: types_3.ScopeType[scope.type], value };
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
exports.middlewareScopeToScope = middlewareScopeToScope;
|
|
1596
|
+
/**
|
|
1597
|
+
* @hidden
|
|
1598
|
+
*/
|
|
1599
|
+
function scopeToMiddlewareScope(scope) {
|
|
1600
|
+
const { type, value } = scope;
|
|
1601
|
+
switch (type) {
|
|
1602
|
+
case types_3.ScopeType.Ticker:
|
|
1603
|
+
return { type: types_2.ClaimScopeTypeEnum.Ticker, value: (0, lodash_1.padEnd)(value, 12, '\0') };
|
|
1604
|
+
case types_3.ScopeType.Identity:
|
|
1605
|
+
case types_3.ScopeType.Custom:
|
|
1606
|
+
return { type: types_2.ClaimScopeTypeEnum[scope.type], value };
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
exports.scopeToMiddlewareScope = scopeToMiddlewareScope;
|
|
1610
|
+
/**
|
|
1611
|
+
* @hidden
|
|
1612
|
+
*/
|
|
1613
|
+
function middlewareEventToEventIdentifier(event) {
|
|
1614
|
+
const { block_id: blockNumber, block, event_idx: eventIndex } = event;
|
|
1615
|
+
return {
|
|
1616
|
+
blockNumber: new bignumber_js_1.default(blockNumber),
|
|
1617
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1618
|
+
blockDate: new Date(block.datetime),
|
|
1619
|
+
blockHash: block.hash,
|
|
1620
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
1621
|
+
eventIndex: new bignumber_js_1.default(eventIndex),
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
exports.middlewareEventToEventIdentifier = middlewareEventToEventIdentifier;
|
|
1625
|
+
/**
|
|
1626
|
+
* @hidden
|
|
1627
|
+
*/
|
|
1628
|
+
function meshClaimToClaim(claim) {
|
|
1629
|
+
if (claim.isJurisdiction) {
|
|
1630
|
+
const [code, scope] = claim.asJurisdiction;
|
|
1631
|
+
return {
|
|
1632
|
+
type: types_3.ClaimType.Jurisdiction,
|
|
1633
|
+
code: (0, utils_1.meshCountryCodeToCountryCode)(code),
|
|
1634
|
+
scope: meshScopeToScope(scope),
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
if (claim.isNoData) {
|
|
1638
|
+
return {
|
|
1639
|
+
type: types_3.ClaimType.NoData,
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
if (claim.isAccredited) {
|
|
1643
|
+
return {
|
|
1644
|
+
type: types_3.ClaimType.Accredited,
|
|
1645
|
+
scope: meshScopeToScope(claim.asAccredited),
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
if (claim.isAffiliate) {
|
|
1649
|
+
return {
|
|
1650
|
+
type: types_3.ClaimType.Affiliate,
|
|
1651
|
+
scope: meshScopeToScope(claim.asAffiliate),
|
|
1652
|
+
};
|
|
1653
|
+
}
|
|
1654
|
+
if (claim.isBuyLockup) {
|
|
1655
|
+
return {
|
|
1656
|
+
type: types_3.ClaimType.BuyLockup,
|
|
1657
|
+
scope: meshScopeToScope(claim.asBuyLockup),
|
|
1658
|
+
};
|
|
1659
|
+
}
|
|
1660
|
+
if (claim.isSellLockup) {
|
|
1661
|
+
return {
|
|
1662
|
+
type: types_3.ClaimType.SellLockup,
|
|
1663
|
+
scope: meshScopeToScope(claim.asSellLockup),
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
if (claim.isCustomerDueDiligence) {
|
|
1667
|
+
return {
|
|
1668
|
+
type: types_3.ClaimType.CustomerDueDiligence,
|
|
1669
|
+
id: cddIdToString(claim.asCustomerDueDiligence),
|
|
1670
|
+
};
|
|
1671
|
+
}
|
|
1672
|
+
if (claim.isKnowYourCustomer) {
|
|
1673
|
+
return {
|
|
1674
|
+
type: types_3.ClaimType.KnowYourCustomer,
|
|
1675
|
+
scope: meshScopeToScope(claim.asKnowYourCustomer),
|
|
1676
|
+
};
|
|
1677
|
+
}
|
|
1678
|
+
if (claim.isExempted) {
|
|
1679
|
+
return {
|
|
1680
|
+
type: types_3.ClaimType.Exempted,
|
|
1681
|
+
scope: meshScopeToScope(claim.asExempted),
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
if (claim.isInvestorUniqueness) {
|
|
1685
|
+
const [scope, scopeId, cddId] = claim.asInvestorUniqueness;
|
|
1686
|
+
return {
|
|
1687
|
+
type: types_3.ClaimType.InvestorUniqueness,
|
|
1688
|
+
scope: meshScopeToScope(scope),
|
|
1689
|
+
scopeId: scopeIdToString(scopeId),
|
|
1690
|
+
cddId: cddIdToString(cddId),
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
if (claim.isInvestorUniquenessV2) {
|
|
1694
|
+
return {
|
|
1695
|
+
type: types_3.ClaimType.InvestorUniquenessV2,
|
|
1696
|
+
cddId: cddIdToString(claim.asInvestorUniquenessV2),
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
return {
|
|
1700
|
+
type: types_3.ClaimType.Blocked,
|
|
1701
|
+
scope: meshScopeToScope(claim.asBlocked),
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
exports.meshClaimToClaim = meshClaimToClaim;
|
|
1705
|
+
/**
|
|
1706
|
+
* @hidden
|
|
1707
|
+
*/
|
|
1708
|
+
function stringToTargetIdentity(did, context) {
|
|
1709
|
+
return context.createType('TargetIdentity',
|
|
1710
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1711
|
+
did ? { Specific: stringToIdentityId(did, context) } : 'ExternalAgent');
|
|
1712
|
+
}
|
|
1713
|
+
exports.stringToTargetIdentity = stringToTargetIdentity;
|
|
1714
|
+
/**
|
|
1715
|
+
* @hidden
|
|
1716
|
+
*/
|
|
1717
|
+
function meshClaimTypeToClaimType(claimType) {
|
|
1718
|
+
if (claimType.isJurisdiction) {
|
|
1719
|
+
return types_3.ClaimType.Jurisdiction;
|
|
1720
|
+
}
|
|
1721
|
+
if (claimType.isNoData) {
|
|
1722
|
+
return types_3.ClaimType.NoData;
|
|
1723
|
+
}
|
|
1724
|
+
if (claimType.isAccredited) {
|
|
1725
|
+
return types_3.ClaimType.Accredited;
|
|
1726
|
+
}
|
|
1727
|
+
if (claimType.isAffiliate) {
|
|
1728
|
+
return types_3.ClaimType.Affiliate;
|
|
1729
|
+
}
|
|
1730
|
+
if (claimType.isBuyLockup) {
|
|
1731
|
+
return types_3.ClaimType.BuyLockup;
|
|
1732
|
+
}
|
|
1733
|
+
if (claimType.isSellLockup) {
|
|
1734
|
+
return types_3.ClaimType.SellLockup;
|
|
1735
|
+
}
|
|
1736
|
+
if (claimType.isCustomerDueDiligence) {
|
|
1737
|
+
return types_3.ClaimType.CustomerDueDiligence;
|
|
1738
|
+
}
|
|
1739
|
+
if (claimType.isKnowYourCustomer) {
|
|
1740
|
+
return types_3.ClaimType.KnowYourCustomer;
|
|
1741
|
+
}
|
|
1742
|
+
if (claimType.isExempted) {
|
|
1743
|
+
return types_3.ClaimType.Exempted;
|
|
1744
|
+
}
|
|
1745
|
+
return types_3.ClaimType.Blocked;
|
|
1746
|
+
}
|
|
1747
|
+
exports.meshClaimTypeToClaimType = meshClaimTypeToClaimType;
|
|
1748
|
+
/**
|
|
1749
|
+
* @hidden
|
|
1750
|
+
*/
|
|
1751
|
+
function trustedIssuerToTrustedClaimIssuer(trustedIssuer, context) {
|
|
1752
|
+
const { issuer, trusted_for: claimTypes } = trustedIssuer;
|
|
1753
|
+
const identity = new internal_1.Identity({ did: identityIdToString(issuer) }, context);
|
|
1754
|
+
let trustedFor = null;
|
|
1755
|
+
if (claimTypes.isSpecific) {
|
|
1756
|
+
trustedFor = claimTypes.asSpecific.map(meshClaimTypeToClaimType);
|
|
1757
|
+
}
|
|
1758
|
+
return {
|
|
1759
|
+
identity,
|
|
1760
|
+
trustedFor,
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
exports.trustedIssuerToTrustedClaimIssuer = trustedIssuerToTrustedClaimIssuer;
|
|
1764
|
+
/**
|
|
1765
|
+
* @hidden
|
|
1766
|
+
*/
|
|
1767
|
+
function trustedClaimIssuerToTrustedIssuer(issuer, context) {
|
|
1768
|
+
const { trustedFor: claimTypes, identity } = issuer;
|
|
1769
|
+
const did = signerToString(identity);
|
|
1770
|
+
let trustedFor;
|
|
1771
|
+
if (!claimTypes) {
|
|
1772
|
+
trustedFor = 'Any';
|
|
1773
|
+
}
|
|
1774
|
+
else {
|
|
1775
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1776
|
+
trustedFor = { Specific: claimTypes };
|
|
1777
|
+
}
|
|
1778
|
+
return context.createType('TrustedIssuer', {
|
|
1779
|
+
issuer: stringToIdentityId(did, context),
|
|
1780
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1781
|
+
trusted_for: trustedFor,
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
exports.trustedClaimIssuerToTrustedIssuer = trustedClaimIssuerToTrustedIssuer;
|
|
1785
|
+
/**
|
|
1786
|
+
* @hidden
|
|
1787
|
+
*/
|
|
1788
|
+
function requirementToComplianceRequirement(requirement, context) {
|
|
1789
|
+
const senderConditions = [];
|
|
1790
|
+
const receiverConditions = [];
|
|
1791
|
+
requirement.conditions.forEach(condition => {
|
|
1792
|
+
let conditionContent;
|
|
1793
|
+
let { type } = condition;
|
|
1794
|
+
if ((0, typeguards_1.isSingleClaimCondition)(condition)) {
|
|
1795
|
+
const { claim } = condition;
|
|
1796
|
+
conditionContent = claimToMeshClaim(claim, context);
|
|
1797
|
+
}
|
|
1798
|
+
else if ((0, typeguards_1.isMultiClaimCondition)(condition)) {
|
|
1799
|
+
const { claims } = condition;
|
|
1800
|
+
conditionContent = claims.map(claim => claimToMeshClaim(claim, context));
|
|
1801
|
+
}
|
|
1802
|
+
else if ((0, typeguards_1.isIdentityCondition)(condition)) {
|
|
1803
|
+
const { identity } = condition;
|
|
1804
|
+
conditionContent = stringToTargetIdentity(signerToString(identity), context);
|
|
1805
|
+
}
|
|
1806
|
+
else {
|
|
1807
|
+
// IsExternalAgent does not exist as a condition type in Polymesh, it's SDK sugar
|
|
1808
|
+
type = types_3.ConditionType.IsIdentity;
|
|
1809
|
+
conditionContent = stringToTargetIdentity(null, context);
|
|
1810
|
+
}
|
|
1811
|
+
const { target, trustedClaimIssuers = [] } = condition;
|
|
1812
|
+
const meshCondition = context.createType('Condition', {
|
|
1813
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1814
|
+
condition_type: {
|
|
1815
|
+
[type]: conditionContent,
|
|
1816
|
+
},
|
|
1817
|
+
issuers: trustedClaimIssuers.map(issuer => trustedClaimIssuerToTrustedIssuer(issuer, context)),
|
|
1818
|
+
});
|
|
1819
|
+
if ([types_3.ConditionTarget.Both, types_3.ConditionTarget.Receiver].includes(target)) {
|
|
1820
|
+
receiverConditions.push(meshCondition);
|
|
1821
|
+
}
|
|
1822
|
+
if ([types_3.ConditionTarget.Both, types_3.ConditionTarget.Sender].includes(target)) {
|
|
1823
|
+
senderConditions.push(meshCondition);
|
|
1824
|
+
}
|
|
1825
|
+
});
|
|
1826
|
+
return context.createType('ComplianceRequirement', {
|
|
1827
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1828
|
+
sender_conditions: senderConditions,
|
|
1829
|
+
receiver_conditions: receiverConditions,
|
|
1830
|
+
id: bigNumberToU32(requirement.id, context),
|
|
1831
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
exports.requirementToComplianceRequirement = requirementToComplianceRequirement;
|
|
1835
|
+
/**
|
|
1836
|
+
* @hidden
|
|
1837
|
+
*/
|
|
1838
|
+
function meshConditionTypeToCondition(meshConditionType, context) {
|
|
1839
|
+
if (meshConditionType.isIsPresent) {
|
|
1840
|
+
return {
|
|
1841
|
+
type: types_3.ConditionType.IsPresent,
|
|
1842
|
+
claim: meshClaimToClaim(meshConditionType.asIsPresent),
|
|
1843
|
+
};
|
|
1844
|
+
}
|
|
1845
|
+
if (meshConditionType.isIsAbsent) {
|
|
1846
|
+
return {
|
|
1847
|
+
type: types_3.ConditionType.IsAbsent,
|
|
1848
|
+
claim: meshClaimToClaim(meshConditionType.asIsAbsent),
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
if (meshConditionType.isIsAnyOf) {
|
|
1852
|
+
return {
|
|
1853
|
+
type: types_3.ConditionType.IsAnyOf,
|
|
1854
|
+
claims: meshConditionType.asIsAnyOf.map(claim => meshClaimToClaim(claim)),
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
if (meshConditionType.isIsIdentity) {
|
|
1858
|
+
const target = meshConditionType.asIsIdentity;
|
|
1859
|
+
if (target.isExternalAgent) {
|
|
1860
|
+
return {
|
|
1861
|
+
type: types_3.ConditionType.IsExternalAgent,
|
|
1862
|
+
};
|
|
1863
|
+
}
|
|
1864
|
+
return {
|
|
1865
|
+
type: types_3.ConditionType.IsIdentity,
|
|
1866
|
+
identity: new internal_1.Identity({ did: identityIdToString(target.asSpecific) }, context),
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
return {
|
|
1870
|
+
type: types_3.ConditionType.IsNoneOf,
|
|
1871
|
+
claims: meshConditionType.asIsNoneOf.map(claim => meshClaimToClaim(claim)),
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* @hidden
|
|
1876
|
+
*/
|
|
1877
|
+
function complianceRequirementResultToRequirementCompliance(complianceRequirement, context) {
|
|
1878
|
+
const conditions = [];
|
|
1879
|
+
const conditionCompliancesAreEqual = ({ condition: aCondition, complies: aComplies }, { condition: bCondition, complies: bComplies }) => (0, internal_3.conditionsAreEqual)(aCondition, bCondition) && aComplies === bComplies;
|
|
1880
|
+
complianceRequirement.sender_conditions.forEach(({ condition: { condition_type: conditionType, issuers }, result }) => {
|
|
1881
|
+
const newCondition = {
|
|
1882
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_3.ConditionTarget.Sender, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1883
|
+
complies: boolToBoolean(result),
|
|
1884
|
+
};
|
|
1885
|
+
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
1886
|
+
if (!existingCondition) {
|
|
1887
|
+
conditions.push(newCondition);
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
complianceRequirement.receiver_conditions.forEach(({ condition: { condition_type: conditionType, issuers }, result }) => {
|
|
1891
|
+
const newCondition = {
|
|
1892
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_3.ConditionTarget.Receiver, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1893
|
+
complies: boolToBoolean(result),
|
|
1894
|
+
};
|
|
1895
|
+
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
1896
|
+
if (existingCondition && existingCondition.condition.target === types_3.ConditionTarget.Sender) {
|
|
1897
|
+
existingCondition.condition.target = types_3.ConditionTarget.Both;
|
|
1898
|
+
}
|
|
1899
|
+
else {
|
|
1900
|
+
conditions.push(newCondition);
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
return {
|
|
1904
|
+
id: u32ToBigNumber(complianceRequirement.id),
|
|
1905
|
+
conditions,
|
|
1906
|
+
complies: boolToBoolean(complianceRequirement.result),
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
exports.complianceRequirementResultToRequirementCompliance = complianceRequirementResultToRequirementCompliance;
|
|
1910
|
+
/**
|
|
1911
|
+
* @hidden
|
|
1912
|
+
*/
|
|
1913
|
+
function complianceRequirementToRequirement(complianceRequirement, context) {
|
|
1914
|
+
const conditions = [];
|
|
1915
|
+
complianceRequirement.sender_conditions.forEach(({ condition_type: conditionType, issuers }) => {
|
|
1916
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_3.ConditionTarget.Sender });
|
|
1917
|
+
if (issuers.length) {
|
|
1918
|
+
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
1919
|
+
}
|
|
1920
|
+
const existingCondition = conditions.find(condition => (0, internal_3.conditionsAreEqual)(condition, newCondition));
|
|
1921
|
+
if (!existingCondition) {
|
|
1922
|
+
conditions.push(newCondition);
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
complianceRequirement.receiver_conditions.forEach(({ condition_type: conditionType, issuers }) => {
|
|
1926
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_3.ConditionTarget.Receiver });
|
|
1927
|
+
if (issuers.length) {
|
|
1928
|
+
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
1929
|
+
}
|
|
1930
|
+
const existingCondition = conditions.find(condition => (0, internal_3.conditionsAreEqual)(condition, newCondition));
|
|
1931
|
+
if (existingCondition && existingCondition.target === types_3.ConditionTarget.Sender) {
|
|
1932
|
+
existingCondition.target = types_3.ConditionTarget.Both;
|
|
1933
|
+
}
|
|
1934
|
+
else {
|
|
1935
|
+
conditions.push(newCondition);
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
return {
|
|
1939
|
+
id: u32ToBigNumber(complianceRequirement.id),
|
|
1940
|
+
conditions,
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
exports.complianceRequirementToRequirement = complianceRequirementToRequirement;
|
|
1944
|
+
/**
|
|
1945
|
+
* @hidden
|
|
1946
|
+
*/
|
|
1947
|
+
function txTagToProtocolOp(tag, context) {
|
|
1948
|
+
const protocolOpTags = [
|
|
1949
|
+
types_1.TxTags.asset.RegisterTicker,
|
|
1950
|
+
types_1.TxTags.asset.Issue,
|
|
1951
|
+
types_1.TxTags.asset.AddDocuments,
|
|
1952
|
+
types_1.TxTags.asset.CreateAsset,
|
|
1953
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
1954
|
+
types_1.TxTags.checkpoint.CreateSchedule,
|
|
1955
|
+
types_1.TxTags.complianceManager.AddComplianceRequirement,
|
|
1956
|
+
types_1.TxTags.identity.CddRegisterDid,
|
|
1957
|
+
types_1.TxTags.identity.AddClaim,
|
|
1958
|
+
types_1.TxTags.identity.AddSecondaryKeysWithAuthorization,
|
|
1959
|
+
types_1.TxTags.pips.Propose,
|
|
1960
|
+
types_1.TxTags.corporateBallot.AttachBallot,
|
|
1961
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
1962
|
+
];
|
|
1963
|
+
const [moduleName, extrinsicName] = tag.split('.');
|
|
1964
|
+
const value = `${(0, util_1.stringUpperFirst)(moduleName)}${(0, util_1.stringUpperFirst)(extrinsicName)}`;
|
|
1965
|
+
if (!(0, lodash_1.includes)(protocolOpTags, tag)) {
|
|
1966
|
+
throw new internal_1.PolymeshError({
|
|
1967
|
+
code: types_3.ErrorCode.ValidationError,
|
|
1968
|
+
message: `${value} does not match any ProtocolOp`,
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
return context.createType('ProtocolOp', value);
|
|
1972
|
+
}
|
|
1973
|
+
exports.txTagToProtocolOp = txTagToProtocolOp;
|
|
1974
|
+
/**
|
|
1975
|
+
* @hidden
|
|
1976
|
+
*/
|
|
1977
|
+
function txTagToExtrinsicIdentifier(tag) {
|
|
1978
|
+
const [moduleName, extrinsicName] = tag.split('.');
|
|
1979
|
+
return {
|
|
1980
|
+
moduleId: moduleName.toLowerCase(),
|
|
1981
|
+
callId: (0, lodash_1.snakeCase)(extrinsicName),
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
exports.txTagToExtrinsicIdentifier = txTagToExtrinsicIdentifier;
|
|
1985
|
+
/**
|
|
1986
|
+
* @hidden
|
|
1987
|
+
*/
|
|
1988
|
+
function extrinsicIdentifierToTxTag(extrinsicIdentifier) {
|
|
1989
|
+
const { moduleId, callId } = extrinsicIdentifier;
|
|
1990
|
+
let moduleName;
|
|
1991
|
+
for (const txTagItem in types_1.TxTags) {
|
|
1992
|
+
if (txTagItem.toLowerCase() === moduleId) {
|
|
1993
|
+
moduleName = txTagItem;
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return `${moduleName}.${(0, lodash_1.camelCase)(callId)}`;
|
|
1997
|
+
}
|
|
1998
|
+
exports.extrinsicIdentifierToTxTag = extrinsicIdentifierToTxTag;
|
|
1999
|
+
/**
|
|
2000
|
+
* @hidden
|
|
2001
|
+
*/
|
|
2002
|
+
function assetComplianceResultToCompliance(assetComplianceResult, context) {
|
|
2003
|
+
const { requirements: rawRequirements, result, paused } = assetComplianceResult;
|
|
2004
|
+
const requirements = rawRequirements.map(requirement => complianceRequirementResultToRequirementCompliance(requirement, context));
|
|
2005
|
+
return {
|
|
2006
|
+
requirements,
|
|
2007
|
+
complies: boolToBoolean(paused) || boolToBoolean(result),
|
|
2008
|
+
};
|
|
2009
|
+
}
|
|
2010
|
+
exports.assetComplianceResultToCompliance = assetComplianceResultToCompliance;
|
|
2011
|
+
/**
|
|
2012
|
+
* @hidden
|
|
2013
|
+
*/
|
|
2014
|
+
function moduleAddressToString(moduleAddress, context) {
|
|
2015
|
+
return (0, util_crypto_1.encodeAddress)((0, util_1.stringToU8a)((0, internal_3.padString)(moduleAddress, constants_1.MAX_MODULE_LENGTH)), context.ss58Format.toNumber());
|
|
2016
|
+
}
|
|
2017
|
+
exports.moduleAddressToString = moduleAddressToString;
|
|
2018
|
+
/**
|
|
2019
|
+
* @hidden
|
|
2020
|
+
*/
|
|
2021
|
+
function keyToAddress(key, context) {
|
|
2022
|
+
return (0, util_crypto_1.encodeAddress)(key, context.ss58Format.toNumber());
|
|
2023
|
+
}
|
|
2024
|
+
exports.keyToAddress = keyToAddress;
|
|
2025
|
+
/**
|
|
2026
|
+
* @hidden
|
|
2027
|
+
*/
|
|
2028
|
+
function addressToKey(address, context) {
|
|
2029
|
+
return (0, util_1.u8aToHex)((0, util_crypto_1.decodeAddress)(address, constants_1.IGNORE_CHECKSUM, context.ss58Format.toNumber()));
|
|
2030
|
+
}
|
|
2031
|
+
exports.addressToKey = addressToKey;
|
|
2032
|
+
/**
|
|
2033
|
+
* @hidden
|
|
2034
|
+
*/
|
|
2035
|
+
function transactionHexToTxTag(bytes, context) {
|
|
2036
|
+
const { section, method } = context.createType('Proposal', bytes);
|
|
2037
|
+
return extrinsicIdentifierToTxTag({
|
|
2038
|
+
moduleId: section.toLowerCase(),
|
|
2039
|
+
callId: method,
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
exports.transactionHexToTxTag = transactionHexToTxTag;
|
|
2043
|
+
/**
|
|
2044
|
+
* @hidden
|
|
2045
|
+
*/
|
|
2046
|
+
function transactionToTxTag(tx) {
|
|
2047
|
+
return `${tx.section}.${tx.method}`;
|
|
2048
|
+
}
|
|
2049
|
+
exports.transactionToTxTag = transactionToTxTag;
|
|
2050
|
+
/**
|
|
2051
|
+
* @hidden
|
|
2052
|
+
*/
|
|
2053
|
+
function secondaryAccountToMeshSecondaryKey(secondaryKey, context) {
|
|
2054
|
+
const { account, permissions } = secondaryKey;
|
|
2055
|
+
return context.createType('SecondaryKey', {
|
|
2056
|
+
signer: signerValueToSignatory(signerToSignerValue(account), context),
|
|
2057
|
+
permissions: permissionsToMeshPermissions(permissions, context),
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
exports.secondaryAccountToMeshSecondaryKey = secondaryAccountToMeshSecondaryKey;
|
|
2061
|
+
/**
|
|
2062
|
+
* @hidden
|
|
2063
|
+
*/
|
|
2064
|
+
function meshVenueTypeToVenueType(type) {
|
|
2065
|
+
if (type.isOther) {
|
|
2066
|
+
return types_3.VenueType.Other;
|
|
2067
|
+
}
|
|
2068
|
+
if (type.isDistribution) {
|
|
2069
|
+
return types_3.VenueType.Distribution;
|
|
2070
|
+
}
|
|
2071
|
+
if (type.isSto) {
|
|
2072
|
+
return types_3.VenueType.Sto;
|
|
2073
|
+
}
|
|
2074
|
+
return types_3.VenueType.Exchange;
|
|
2075
|
+
}
|
|
2076
|
+
exports.meshVenueTypeToVenueType = meshVenueTypeToVenueType;
|
|
2077
|
+
/**
|
|
2078
|
+
* @hidden
|
|
2079
|
+
*/
|
|
2080
|
+
function venueTypeToMeshVenueType(type, context) {
|
|
2081
|
+
return context.createType('VenueType', type);
|
|
2082
|
+
}
|
|
2083
|
+
exports.venueTypeToMeshVenueType = venueTypeToMeshVenueType;
|
|
2084
|
+
/**
|
|
2085
|
+
* @hidden
|
|
2086
|
+
*/
|
|
2087
|
+
function stringToVenueDetails(details, context) {
|
|
2088
|
+
return context.createType('VenueDetails', details);
|
|
2089
|
+
}
|
|
2090
|
+
exports.stringToVenueDetails = stringToVenueDetails;
|
|
2091
|
+
/**
|
|
2092
|
+
* @hidden
|
|
2093
|
+
*/
|
|
2094
|
+
function venueDetailsToString(details) {
|
|
2095
|
+
return details.toString();
|
|
2096
|
+
}
|
|
2097
|
+
exports.venueDetailsToString = venueDetailsToString;
|
|
2098
|
+
/**
|
|
2099
|
+
* @hidden
|
|
2100
|
+
*/
|
|
2101
|
+
function meshInstructionStatusToInstructionStatus(status) {
|
|
2102
|
+
if (status.isPending) {
|
|
2103
|
+
return internal_2.InstructionStatus.Pending;
|
|
2104
|
+
}
|
|
2105
|
+
if (status.isFailed) {
|
|
2106
|
+
return internal_2.InstructionStatus.Failed;
|
|
2107
|
+
}
|
|
2108
|
+
return internal_2.InstructionStatus.Unknown;
|
|
2109
|
+
}
|
|
2110
|
+
exports.meshInstructionStatusToInstructionStatus = meshInstructionStatusToInstructionStatus;
|
|
2111
|
+
/**
|
|
2112
|
+
* @hidden
|
|
2113
|
+
*/
|
|
2114
|
+
function meshAffirmationStatusToAffirmationStatus(status) {
|
|
2115
|
+
if (status.isUnknown) {
|
|
2116
|
+
return types_3.AffirmationStatus.Unknown;
|
|
2117
|
+
}
|
|
2118
|
+
if (status.isPending) {
|
|
2119
|
+
return types_3.AffirmationStatus.Pending;
|
|
2120
|
+
}
|
|
2121
|
+
return types_3.AffirmationStatus.Affirmed;
|
|
2122
|
+
}
|
|
2123
|
+
exports.meshAffirmationStatusToAffirmationStatus = meshAffirmationStatusToAffirmationStatus;
|
|
2124
|
+
/**
|
|
2125
|
+
* @hidden
|
|
2126
|
+
*/
|
|
2127
|
+
function endConditionToSettlementType(endCondition, context) {
|
|
2128
|
+
let value;
|
|
2129
|
+
if (endCondition.type === types_3.InstructionType.SettleOnAffirmation) {
|
|
2130
|
+
value = types_3.InstructionType.SettleOnAffirmation;
|
|
2131
|
+
}
|
|
2132
|
+
else {
|
|
2133
|
+
value = {
|
|
2134
|
+
[types_3.InstructionType.SettleOnBlock]: bigNumberToU32(endCondition.value, context),
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
return context.createType('SettlementType', value);
|
|
2138
|
+
}
|
|
2139
|
+
exports.endConditionToSettlementType = endConditionToSettlementType;
|
|
2140
|
+
/**
|
|
2141
|
+
* @hidden
|
|
2142
|
+
*/
|
|
2143
|
+
function toIdentityWithClaimsArray(data, context) {
|
|
2144
|
+
return data.map(({ did, claims }) => ({
|
|
2145
|
+
identity: new internal_1.Identity({ did }, context),
|
|
2146
|
+
claims: claims.map(({ targetDID: targetDid, issuer, issuance_date: issuanceDate, expiry, type, jurisdiction, scope: claimScope, cdd_id: cddId, }) => ({
|
|
2147
|
+
target: new internal_1.Identity({ did: targetDid }, context),
|
|
2148
|
+
issuer: new internal_1.Identity({ did: issuer }, context),
|
|
2149
|
+
issuedAt: new Date(issuanceDate),
|
|
2150
|
+
expiry: expiry ? new Date(expiry) : null,
|
|
2151
|
+
claim: (0, internal_3.createClaim)(type, jurisdiction, claimScope, cddId, undefined),
|
|
2152
|
+
})),
|
|
2153
|
+
}));
|
|
2154
|
+
}
|
|
2155
|
+
exports.toIdentityWithClaimsArray = toIdentityWithClaimsArray;
|
|
2156
|
+
/**
|
|
2157
|
+
* @hidden
|
|
2158
|
+
*/
|
|
2159
|
+
function portfolioMovementToMovePortfolioItem(portfolioItem, context) {
|
|
2160
|
+
const { asset, amount, memo } = portfolioItem;
|
|
2161
|
+
return context.createType('MovePortfolioItem', {
|
|
2162
|
+
ticker: stringToTicker((0, internal_3.asTicker)(asset), context),
|
|
2163
|
+
amount: bigNumberToBalance(amount, context),
|
|
2164
|
+
memo: (0, internal_3.optionize)(stringToMemo)(memo, context),
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
exports.portfolioMovementToMovePortfolioItem = portfolioMovementToMovePortfolioItem;
|
|
2168
|
+
/**
|
|
2169
|
+
* @hidden
|
|
2170
|
+
*/
|
|
2171
|
+
function claimTypeToMeshClaimType(claimType, context) {
|
|
2172
|
+
return context.createType('ClaimType', claimType);
|
|
2173
|
+
}
|
|
2174
|
+
exports.claimTypeToMeshClaimType = claimTypeToMeshClaimType;
|
|
2175
|
+
/**
|
|
2176
|
+
* @hidden
|
|
2177
|
+
*/
|
|
2178
|
+
function transferRestrictionToTransferManager(restriction, context) {
|
|
2179
|
+
const { type, value } = restriction;
|
|
2180
|
+
let tmType;
|
|
2181
|
+
let tmValue;
|
|
2182
|
+
if (type === types_3.TransferRestrictionType.Count) {
|
|
2183
|
+
tmType = 'CountTransferManager';
|
|
2184
|
+
tmValue = bigNumberToU64(value, context);
|
|
2185
|
+
}
|
|
2186
|
+
else {
|
|
2187
|
+
tmType = 'PercentageTransferManager';
|
|
2188
|
+
tmValue = percentageToPermill(value, context);
|
|
2189
|
+
}
|
|
2190
|
+
return context.createType('TransferManager', {
|
|
2191
|
+
[tmType]: tmValue,
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
exports.transferRestrictionToTransferManager = transferRestrictionToTransferManager;
|
|
2195
|
+
/**
|
|
2196
|
+
* @hidden
|
|
2197
|
+
*/
|
|
2198
|
+
function transferManagerToTransferRestriction(transferManager) {
|
|
2199
|
+
if (transferManager.isCountTransferManager) {
|
|
2200
|
+
return {
|
|
2201
|
+
type: types_3.TransferRestrictionType.Count,
|
|
2202
|
+
value: u64ToBigNumber(transferManager.asCountTransferManager),
|
|
2203
|
+
};
|
|
2204
|
+
}
|
|
2205
|
+
else {
|
|
2206
|
+
return {
|
|
2207
|
+
type: types_3.TransferRestrictionType.Percentage,
|
|
2208
|
+
value: permillToBigNumber(transferManager.asPercentageTransferManager),
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
exports.transferManagerToTransferRestriction = transferManagerToTransferRestriction;
|
|
2213
|
+
/**
|
|
2214
|
+
* @hidden
|
|
2215
|
+
*/
|
|
2216
|
+
function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
2217
|
+
const { invalid_granularity: invalidGranularity, self_transfer: selfTransfer, invalid_receiver_cdd: invalidReceiverCdd, invalid_sender_cdd: invalidSenderCdd, missing_scope_claim: missingScopeClaim, sender_insufficient_balance: insufficientBalance, asset_frozen: assetFrozen, portfolio_validity_result: { sender_portfolio_does_not_exist: senderPortfolioNotExists, receiver_portfolio_does_not_exist: receiverPortfolioNotExists, sender_insufficient_balance: senderInsufficientBalance, }, statistics_result: transferRestrictionResults, compliance_result: complianceResult, result: finalResult, } = result;
|
|
2218
|
+
const general = [];
|
|
2219
|
+
if (boolToBoolean(invalidGranularity)) {
|
|
2220
|
+
general.push(types_3.TransferError.InvalidGranularity);
|
|
2221
|
+
}
|
|
2222
|
+
if (boolToBoolean(selfTransfer)) {
|
|
2223
|
+
general.push(types_3.TransferError.SelfTransfer);
|
|
2224
|
+
}
|
|
2225
|
+
if (boolToBoolean(invalidReceiverCdd)) {
|
|
2226
|
+
general.push(types_3.TransferError.InvalidReceiverCdd);
|
|
2227
|
+
}
|
|
2228
|
+
if (boolToBoolean(invalidSenderCdd)) {
|
|
2229
|
+
general.push(types_3.TransferError.InvalidSenderCdd);
|
|
2230
|
+
}
|
|
2231
|
+
if (boolToBoolean(missingScopeClaim)) {
|
|
2232
|
+
general.push(types_3.TransferError.ScopeClaimMissing);
|
|
2233
|
+
}
|
|
2234
|
+
if (boolToBoolean(insufficientBalance)) {
|
|
2235
|
+
general.push(types_3.TransferError.InsufficientBalance);
|
|
2236
|
+
}
|
|
2237
|
+
if (boolToBoolean(assetFrozen)) {
|
|
2238
|
+
general.push(types_3.TransferError.TransfersFrozen);
|
|
2239
|
+
}
|
|
2240
|
+
if (boolToBoolean(senderPortfolioNotExists)) {
|
|
2241
|
+
general.push(types_3.TransferError.InvalidSenderPortfolio);
|
|
2242
|
+
}
|
|
2243
|
+
if (boolToBoolean(receiverPortfolioNotExists)) {
|
|
2244
|
+
general.push(types_3.TransferError.InvalidReceiverPortfolio);
|
|
2245
|
+
}
|
|
2246
|
+
if (boolToBoolean(senderInsufficientBalance)) {
|
|
2247
|
+
general.push(types_3.TransferError.InsufficientPortfolioBalance);
|
|
2248
|
+
}
|
|
2249
|
+
const restrictions = transferRestrictionResults.map(({ tm, result: tmResult }) => ({
|
|
2250
|
+
restriction: transferManagerToTransferRestriction(tm),
|
|
2251
|
+
result: boolToBoolean(tmResult),
|
|
2252
|
+
}));
|
|
2253
|
+
return {
|
|
2254
|
+
general,
|
|
2255
|
+
compliance: assetComplianceResultToCompliance(complianceResult, context),
|
|
2256
|
+
restrictions,
|
|
2257
|
+
result: boolToBoolean(finalResult),
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2260
|
+
exports.granularCanTransferResultToTransferBreakdown = granularCanTransferResultToTransferBreakdown;
|
|
2261
|
+
/**
|
|
2262
|
+
* @hidden
|
|
2263
|
+
*/
|
|
2264
|
+
function offeringTierToPriceTier(tier, context) {
|
|
2265
|
+
const { price, amount } = tier;
|
|
2266
|
+
return context.createType('PriceTier', {
|
|
2267
|
+
total: bigNumberToBalance(amount, context),
|
|
2268
|
+
price: bigNumberToBalance(price, context),
|
|
2269
|
+
});
|
|
2270
|
+
}
|
|
2271
|
+
exports.offeringTierToPriceTier = offeringTierToPriceTier;
|
|
2272
|
+
/**
|
|
2273
|
+
* @hidden
|
|
2274
|
+
*/
|
|
2275
|
+
function permissionsLikeToPermissions(permissionsLike, context) {
|
|
2276
|
+
let assetPermissions = {
|
|
2277
|
+
values: [],
|
|
2278
|
+
type: types_3.PermissionType.Include,
|
|
2279
|
+
};
|
|
2280
|
+
let transactionPermissions = {
|
|
2281
|
+
values: [],
|
|
2282
|
+
type: types_3.PermissionType.Include,
|
|
2283
|
+
};
|
|
2284
|
+
let transactionGroupPermissions = [];
|
|
2285
|
+
let portfolioPermissions = {
|
|
2286
|
+
values: [],
|
|
2287
|
+
type: types_3.PermissionType.Include,
|
|
2288
|
+
};
|
|
2289
|
+
let transactions;
|
|
2290
|
+
let transactionGroups;
|
|
2291
|
+
if ('transactions' in permissionsLike) {
|
|
2292
|
+
({ transactions } = permissionsLike);
|
|
2293
|
+
}
|
|
2294
|
+
if ('transactionGroups' in permissionsLike) {
|
|
2295
|
+
({ transactionGroups } = permissionsLike);
|
|
2296
|
+
}
|
|
2297
|
+
const { assets, portfolios } = permissionsLike;
|
|
2298
|
+
if (assets === null) {
|
|
2299
|
+
assetPermissions = null;
|
|
2300
|
+
}
|
|
2301
|
+
else if (assets) {
|
|
2302
|
+
assetPermissions = Object.assign(Object.assign({}, assets), { values: assets.values.map(ticker => typeof ticker !== 'string' ? ticker : new internal_1.Asset({ ticker }, context)) });
|
|
2303
|
+
}
|
|
2304
|
+
if (transactions !== undefined) {
|
|
2305
|
+
transactionPermissions = transactions;
|
|
2306
|
+
}
|
|
2307
|
+
else if (transactionGroups !== undefined) {
|
|
2308
|
+
transactionGroupPermissions = (0, lodash_1.uniq)(transactionGroups);
|
|
2309
|
+
const groupTags = (0, lodash_1.flatten)(transactionGroups.map(txGroupToTxTags));
|
|
2310
|
+
transactionPermissions = Object.assign(Object.assign({}, transactionPermissions), { values: groupTags });
|
|
2311
|
+
}
|
|
2312
|
+
if (portfolios === null) {
|
|
2313
|
+
portfolioPermissions = null;
|
|
2314
|
+
}
|
|
2315
|
+
else if (portfolios) {
|
|
2316
|
+
portfolioPermissions = Object.assign(Object.assign({}, portfolios), { values: portfolios.values.map(portfolio => portfolioLikeToPortfolio(portfolio, context)) });
|
|
2317
|
+
}
|
|
2318
|
+
return {
|
|
2319
|
+
assets: assetPermissions,
|
|
2320
|
+
transactions: transactionPermissions && Object.assign(Object.assign({}, transactionPermissions), { values: [...transactionPermissions.values].sort() }),
|
|
2321
|
+
transactionGroups: transactionGroupPermissions,
|
|
2322
|
+
portfolios: portfolioPermissions,
|
|
2323
|
+
};
|
|
2324
|
+
}
|
|
2325
|
+
exports.permissionsLikeToPermissions = permissionsLikeToPermissions;
|
|
2326
|
+
/**
|
|
2327
|
+
* @hidden
|
|
2328
|
+
*/
|
|
2329
|
+
function middlewarePortfolioToPortfolio(portfolio, context) {
|
|
2330
|
+
const { did, kind } = portfolio;
|
|
2331
|
+
if (kind.toLowerCase() === 'default' || kind === '0') {
|
|
2332
|
+
return new internal_1.DefaultPortfolio({ did }, context);
|
|
2333
|
+
}
|
|
2334
|
+
return new internal_1.NumberedPortfolio({ did, id: new bignumber_js_1.default(kind) }, context);
|
|
2335
|
+
}
|
|
2336
|
+
exports.middlewarePortfolioToPortfolio = middlewarePortfolioToPortfolio;
|
|
2337
|
+
/**
|
|
2338
|
+
* @hidden
|
|
2339
|
+
*/
|
|
2340
|
+
function fundraiserTierToTier(fundraiserTier) {
|
|
2341
|
+
const { total, price, remaining } = fundraiserTier;
|
|
2342
|
+
return {
|
|
2343
|
+
amount: balanceToBigNumber(total),
|
|
2344
|
+
price: balanceToBigNumber(price),
|
|
2345
|
+
remaining: balanceToBigNumber(remaining),
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
exports.fundraiserTierToTier = fundraiserTierToTier;
|
|
2349
|
+
/**
|
|
2350
|
+
* @hidden
|
|
2351
|
+
*/
|
|
2352
|
+
function fundraiserToOfferingDetails(fundraiser, name, context) {
|
|
2353
|
+
const { creator, offering_portfolio: offeringPortfolio, raising_portfolio: raisingPortfolio, raising_asset: raisingAsset, tiers: rawTiers, venue_id: venueId, start: rawStart, end: rawEnd, status: rawStatus, minimum_investment: rawMinInvestment, } = fundraiser;
|
|
2354
|
+
const tiers = [];
|
|
2355
|
+
let totalRemaining = new bignumber_js_1.default(0);
|
|
2356
|
+
let totalAmount = new bignumber_js_1.default(0);
|
|
2357
|
+
let totalRemainingValue = new bignumber_js_1.default(0);
|
|
2358
|
+
rawTiers.forEach(rawTier => {
|
|
2359
|
+
const tier = fundraiserTierToTier(rawTier);
|
|
2360
|
+
tiers.push(tier);
|
|
2361
|
+
const { amount, remaining, price } = tier;
|
|
2362
|
+
totalAmount = totalAmount.plus(amount);
|
|
2363
|
+
totalRemaining = totalRemaining.plus(remaining);
|
|
2364
|
+
totalRemainingValue = totalRemainingValue.plus(price.multipliedBy(remaining));
|
|
2365
|
+
});
|
|
2366
|
+
const start = momentToDate(rawStart);
|
|
2367
|
+
const end = rawEnd.isSome ? momentToDate(rawEnd.unwrap()) : null;
|
|
2368
|
+
const now = new Date();
|
|
2369
|
+
const isStarted = now > start;
|
|
2370
|
+
const isExpired = end && now > end;
|
|
2371
|
+
const minInvestment = balanceToBigNumber(rawMinInvestment);
|
|
2372
|
+
let timing = types_3.OfferingTimingStatus.NotStarted;
|
|
2373
|
+
let balance = types_3.OfferingBalanceStatus.Available;
|
|
2374
|
+
let sale = types_3.OfferingSaleStatus.Live;
|
|
2375
|
+
if (isExpired) {
|
|
2376
|
+
timing = types_3.OfferingTimingStatus.Expired;
|
|
2377
|
+
}
|
|
2378
|
+
else if (isStarted) {
|
|
2379
|
+
timing = types_3.OfferingTimingStatus.Started;
|
|
2380
|
+
}
|
|
2381
|
+
if (totalRemainingValue.isZero()) {
|
|
2382
|
+
balance = types_3.OfferingBalanceStatus.SoldOut;
|
|
2383
|
+
}
|
|
2384
|
+
else if (totalRemainingValue.lt(minInvestment)) {
|
|
2385
|
+
balance = types_3.OfferingBalanceStatus.Residual;
|
|
2386
|
+
}
|
|
2387
|
+
if (rawStatus.isClosedEarly) {
|
|
2388
|
+
sale = types_3.OfferingSaleStatus.ClosedEarly;
|
|
2389
|
+
}
|
|
2390
|
+
else if (rawStatus.isClosed) {
|
|
2391
|
+
sale = types_3.OfferingSaleStatus.Closed;
|
|
2392
|
+
}
|
|
2393
|
+
else if (rawStatus.isFrozen) {
|
|
2394
|
+
sale = types_3.OfferingSaleStatus.Frozen;
|
|
2395
|
+
}
|
|
2396
|
+
return {
|
|
2397
|
+
creator: new internal_1.Identity({ did: identityIdToString(creator) }, context),
|
|
2398
|
+
name: textToString(name),
|
|
2399
|
+
offeringPortfolio: meshPortfolioIdToPortfolio(offeringPortfolio, context),
|
|
2400
|
+
raisingPortfolio: meshPortfolioIdToPortfolio(raisingPortfolio, context),
|
|
2401
|
+
raisingCurrency: tickerToString(raisingAsset),
|
|
2402
|
+
tiers,
|
|
2403
|
+
venue: new internal_1.Venue({ id: u64ToBigNumber(venueId) }, context),
|
|
2404
|
+
start,
|
|
2405
|
+
end,
|
|
2406
|
+
status: {
|
|
2407
|
+
timing,
|
|
2408
|
+
balance,
|
|
2409
|
+
sale,
|
|
2410
|
+
},
|
|
2411
|
+
minInvestment,
|
|
2412
|
+
totalAmount,
|
|
2413
|
+
totalRemaining,
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
exports.fundraiserToOfferingDetails = fundraiserToOfferingDetails;
|
|
2417
|
+
/**
|
|
2418
|
+
* @hidden
|
|
2419
|
+
*/
|
|
2420
|
+
function calendarPeriodToMeshCalendarPeriod(period, context) {
|
|
2421
|
+
const { unit, amount } = period;
|
|
2422
|
+
if (amount.isNegative()) {
|
|
2423
|
+
throw new internal_1.PolymeshError({
|
|
2424
|
+
code: types_3.ErrorCode.ValidationError,
|
|
2425
|
+
message: 'Calendar period cannot have a negative amount',
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
return context.createType('CalendarPeriod', {
|
|
2429
|
+
unit: (0, util_1.stringUpperFirst)(unit),
|
|
2430
|
+
amount: bigNumberToU64(amount, context),
|
|
2431
|
+
});
|
|
2432
|
+
}
|
|
2433
|
+
exports.calendarPeriodToMeshCalendarPeriod = calendarPeriodToMeshCalendarPeriod;
|
|
2434
|
+
/**
|
|
2435
|
+
* @hidden
|
|
2436
|
+
*/
|
|
2437
|
+
function meshCalendarPeriodToCalendarPeriod(period) {
|
|
2438
|
+
const { unit: rawUnit, amount } = period;
|
|
2439
|
+
let unit;
|
|
2440
|
+
if (rawUnit.isSecond) {
|
|
2441
|
+
unit = types_3.CalendarUnit.Second;
|
|
2442
|
+
}
|
|
2443
|
+
else if (rawUnit.isMinute) {
|
|
2444
|
+
unit = types_3.CalendarUnit.Minute;
|
|
2445
|
+
}
|
|
2446
|
+
else if (rawUnit.isHour) {
|
|
2447
|
+
unit = types_3.CalendarUnit.Hour;
|
|
2448
|
+
}
|
|
2449
|
+
else if (rawUnit.isDay) {
|
|
2450
|
+
unit = types_3.CalendarUnit.Day;
|
|
2451
|
+
}
|
|
2452
|
+
else if (rawUnit.isWeek) {
|
|
2453
|
+
unit = types_3.CalendarUnit.Week;
|
|
2454
|
+
}
|
|
2455
|
+
else if (rawUnit.isMonth) {
|
|
2456
|
+
unit = types_3.CalendarUnit.Month;
|
|
2457
|
+
}
|
|
2458
|
+
else {
|
|
2459
|
+
unit = types_3.CalendarUnit.Year;
|
|
2460
|
+
}
|
|
2461
|
+
return {
|
|
2462
|
+
unit,
|
|
2463
|
+
amount: u64ToBigNumber(amount),
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
exports.meshCalendarPeriodToCalendarPeriod = meshCalendarPeriodToCalendarPeriod;
|
|
2467
|
+
/**
|
|
2468
|
+
* @hidden
|
|
2469
|
+
*/
|
|
2470
|
+
function scheduleSpecToMeshScheduleSpec(details, context) {
|
|
2471
|
+
const { start, period, repetitions } = details;
|
|
2472
|
+
return context.createType('ScheduleSpec', {
|
|
2473
|
+
start: start && dateToMoment(start, context),
|
|
2474
|
+
period: calendarPeriodToMeshCalendarPeriod(period || { unit: types_3.CalendarUnit.Month, amount: new bignumber_js_1.default(0) }, context),
|
|
2475
|
+
remaining: bigNumberToU64(repetitions || new bignumber_js_1.default(0), context),
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
exports.scheduleSpecToMeshScheduleSpec = scheduleSpecToMeshScheduleSpec;
|
|
2479
|
+
/**
|
|
2480
|
+
* @hidden
|
|
2481
|
+
*/
|
|
2482
|
+
function storedScheduleToCheckpointScheduleParams(storedSchedule) {
|
|
2483
|
+
const { schedule: { start, period }, id, at, remaining, } = storedSchedule;
|
|
2484
|
+
return {
|
|
2485
|
+
id: u64ToBigNumber(id),
|
|
2486
|
+
period: meshCalendarPeriodToCalendarPeriod(period),
|
|
2487
|
+
start: momentToDate(start),
|
|
2488
|
+
remaining: u32ToBigNumber(remaining),
|
|
2489
|
+
nextCheckpointDate: momentToDate(at),
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
exports.storedScheduleToCheckpointScheduleParams = storedScheduleToCheckpointScheduleParams;
|
|
2493
|
+
/**
|
|
2494
|
+
* @hidden
|
|
2495
|
+
*/
|
|
2496
|
+
function stringToSignature(signature, context) {
|
|
2497
|
+
return context.createType('Signature', signature);
|
|
2498
|
+
}
|
|
2499
|
+
exports.stringToSignature = stringToSignature;
|
|
2500
|
+
/**
|
|
2501
|
+
* @hidden
|
|
2502
|
+
*/
|
|
2503
|
+
function meshCorporateActionToCorporateActionParams(corporateAction, details, context) {
|
|
2504
|
+
const { kind: rawKind, decl_date: declDate, targets: { identities, treatment }, default_withholding_tax: defaultWithholdingTax, withholding_tax: withholdingTax, } = corporateAction;
|
|
2505
|
+
let kind;
|
|
2506
|
+
if (rawKind.isIssuerNotice) {
|
|
2507
|
+
kind = types_3.CorporateActionKind.IssuerNotice;
|
|
2508
|
+
}
|
|
2509
|
+
else if (rawKind.isPredictableBenefit) {
|
|
2510
|
+
kind = types_3.CorporateActionKind.PredictableBenefit;
|
|
2511
|
+
}
|
|
2512
|
+
else if (rawKind.isUnpredictableBenefit) {
|
|
2513
|
+
kind = types_3.CorporateActionKind.UnpredictableBenefit;
|
|
2514
|
+
}
|
|
2515
|
+
else if (rawKind.isReorganization) {
|
|
2516
|
+
kind = types_3.CorporateActionKind.Reorganization;
|
|
2517
|
+
}
|
|
2518
|
+
else {
|
|
2519
|
+
kind = types_3.CorporateActionKind.Other;
|
|
2520
|
+
}
|
|
2521
|
+
const targets = {
|
|
2522
|
+
identities: identities.map(identityId => new internal_1.Identity({ did: identityIdToString(identityId) }, context)),
|
|
2523
|
+
treatment: treatment.isExclude ? types_3.TargetTreatment.Exclude : types_3.TargetTreatment.Include,
|
|
2524
|
+
};
|
|
2525
|
+
const taxWithholdings = withholdingTax.map(([identityId, tax]) => ({
|
|
2526
|
+
identity: new internal_1.Identity({ did: identityIdToString(identityId) }, context),
|
|
2527
|
+
percentage: permillToBigNumber(tax),
|
|
2528
|
+
}));
|
|
2529
|
+
return {
|
|
2530
|
+
kind,
|
|
2531
|
+
declarationDate: momentToDate(declDate),
|
|
2532
|
+
description: textToString(details),
|
|
2533
|
+
targets,
|
|
2534
|
+
defaultTaxWithholding: permillToBigNumber(defaultWithholdingTax),
|
|
2535
|
+
taxWithholdings,
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
exports.meshCorporateActionToCorporateActionParams = meshCorporateActionToCorporateActionParams;
|
|
2539
|
+
/**
|
|
2540
|
+
* @hidden
|
|
2541
|
+
*/
|
|
2542
|
+
function stringToRistrettoPoint(ristrettoPoint, context) {
|
|
2543
|
+
return context.createType('RistrettoPoint', ristrettoPoint);
|
|
2544
|
+
}
|
|
2545
|
+
exports.stringToRistrettoPoint = stringToRistrettoPoint;
|
|
2546
|
+
/**
|
|
2547
|
+
* @hidden
|
|
2548
|
+
*/
|
|
2549
|
+
function corporateActionKindToCaKind(kind, context) {
|
|
2550
|
+
return context.createType('CAKind', kind);
|
|
2551
|
+
}
|
|
2552
|
+
exports.corporateActionKindToCaKind = corporateActionKindToCaKind;
|
|
2553
|
+
/**
|
|
2554
|
+
* @hidden
|
|
2555
|
+
*/
|
|
2556
|
+
function stringToScalar(scalar, context) {
|
|
2557
|
+
return context.createType('Scalar', scalar);
|
|
2558
|
+
}
|
|
2559
|
+
exports.stringToScalar = stringToScalar;
|
|
2560
|
+
/**
|
|
2561
|
+
* @hidden
|
|
2562
|
+
*/
|
|
2563
|
+
function checkpointToRecordDateSpec(checkpoint, context) {
|
|
2564
|
+
let value;
|
|
2565
|
+
if (checkpoint instanceof internal_1.Checkpoint) {
|
|
2566
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2567
|
+
value = { Existing: bigNumberToU64(checkpoint.id, context) };
|
|
2568
|
+
}
|
|
2569
|
+
else if (checkpoint instanceof Date) {
|
|
2570
|
+
value = { Scheduled: dateToMoment(checkpoint, context) };
|
|
2571
|
+
}
|
|
2572
|
+
else {
|
|
2573
|
+
value = { ExistingSchedule: bigNumberToU64(checkpoint.id, context) };
|
|
2574
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
2575
|
+
}
|
|
2576
|
+
return context.createType('RecordDateSpec', value);
|
|
2577
|
+
}
|
|
2578
|
+
exports.checkpointToRecordDateSpec = checkpointToRecordDateSpec;
|
|
2579
|
+
/**
|
|
2580
|
+
* @hidden
|
|
2581
|
+
*/
|
|
2582
|
+
function scopeClaimProofToMeshScopeClaimProof(proof, scopeId, context) {
|
|
2583
|
+
const { proofScopeIdWellFormed, proofScopeIdCddIdMatch: { challengeResponses, subtractExpressionsRes, blindedScopeDidHash }, } = proof;
|
|
2584
|
+
const zkProofData = context.createType('ZkProofData', {
|
|
2585
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2586
|
+
challenge_responses: challengeResponses.map(cr => stringToScalar(cr, context)),
|
|
2587
|
+
subtract_expressions_res: stringToRistrettoPoint(subtractExpressionsRes, context),
|
|
2588
|
+
blinded_scope_did_hash: stringToRistrettoPoint(blindedScopeDidHash, context),
|
|
2589
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
2590
|
+
});
|
|
2591
|
+
return context.createType('ScopeClaimProof', {
|
|
2592
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2593
|
+
proof_scope_id_wellformed: stringToSignature(proofScopeIdWellFormed, context),
|
|
2594
|
+
proof_scope_id_cdd_id_match: zkProofData,
|
|
2595
|
+
scope_id: stringToRistrettoPoint(scopeId, context),
|
|
2596
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
exports.scopeClaimProofToMeshScopeClaimProof = scopeClaimProofToMeshScopeClaimProof;
|
|
2600
|
+
/**
|
|
2601
|
+
* @hidden
|
|
2602
|
+
*/
|
|
2603
|
+
function targetIdentitiesToCorporateActionTargets(targetIdentities, context) {
|
|
2604
|
+
const { identities, treatment } = targetIdentities;
|
|
2605
|
+
return {
|
|
2606
|
+
identities: identities.map(identity => new internal_1.Identity({ did: identityIdToString(identity) }, context)),
|
|
2607
|
+
treatment: treatment.isInclude ? types_3.TargetTreatment.Include : types_3.TargetTreatment.Exclude,
|
|
2608
|
+
};
|
|
2609
|
+
}
|
|
2610
|
+
exports.targetIdentitiesToCorporateActionTargets = targetIdentitiesToCorporateActionTargets;
|
|
2611
|
+
/**
|
|
2612
|
+
* @hidden
|
|
2613
|
+
*/
|
|
2614
|
+
function targetsToTargetIdentities(targets, context) {
|
|
2615
|
+
const { treatment, identities } = targets;
|
|
2616
|
+
return context.createType('TargetIdentities', {
|
|
2617
|
+
identities: identities.map(identity => stringToIdentityId(signerToString(identity), context)),
|
|
2618
|
+
treatment: context.createType('TargetTreatment', treatment),
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
exports.targetsToTargetIdentities = targetsToTargetIdentities;
|
|
2622
|
+
/**
|
|
2623
|
+
* @hidden
|
|
2624
|
+
*/
|
|
2625
|
+
function distributionToDividendDistributionParams(distribution, context) {
|
|
2626
|
+
const { from, currency, per_share: perShare, amount, expires_at: expiryDate, payment_at: paymentDate, } = distribution;
|
|
2627
|
+
return {
|
|
2628
|
+
origin: meshPortfolioIdToPortfolio(from, context),
|
|
2629
|
+
currency: tickerToString(currency),
|
|
2630
|
+
perShare: balanceToBigNumber(perShare),
|
|
2631
|
+
maxAmount: balanceToBigNumber(amount),
|
|
2632
|
+
expiryDate: expiryDate.isNone ? null : momentToDate(expiryDate.unwrap()),
|
|
2633
|
+
paymentDate: momentToDate(paymentDate),
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
exports.distributionToDividendDistributionParams = distributionToDividendDistributionParams;
|
|
2637
|
+
/**
|
|
2638
|
+
* @hidden
|
|
2639
|
+
*/
|
|
2640
|
+
function corporateActionIdentifierToCaId(corporateActionIdentifier, context) {
|
|
2641
|
+
const { ticker, localId } = corporateActionIdentifier;
|
|
2642
|
+
return context.createType('CAId', {
|
|
2643
|
+
ticker: stringToTicker(ticker, context),
|
|
2644
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2645
|
+
local_id: bigNumberToU32(localId, context),
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2648
|
+
exports.corporateActionIdentifierToCaId = corporateActionIdentifierToCaId;
|
|
2649
|
+
//# sourceMappingURL=conversion.js.map
|