@polymeshassociation/polymesh-sdk 23.0.0-alpha.9 → 23.0.0-beta.2
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/CHANGELOG.md +11 -2
- package/README.md +49 -7
- package/api/client/Assets.d.ts +10 -2
- package/api/client/Assets.d.ts.map +1 -1
- package/api/client/Assets.js +27 -9
- package/api/client/Assets.js.map +1 -1
- package/api/client/Claims.d.ts +26 -1
- package/api/client/Claims.d.ts.map +1 -1
- package/api/client/Claims.js +61 -2
- package/api/client/Claims.js.map +1 -1
- package/api/client/Network.d.ts +1 -1
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js.map +1 -1
- package/api/client/Polymesh.d.ts.map +1 -1
- package/api/client/Polymesh.js +2 -1
- package/api/client/Polymesh.js.map +1 -1
- package/api/entities/Account/MultiSig/index.d.ts.map +1 -1
- package/api/entities/Account/MultiSig/index.js +2 -5
- package/api/entities/Account/MultiSig/index.js.map +1 -1
- package/api/entities/Account/index.d.ts.map +1 -1
- package/api/entities/Account/index.js +1 -1
- package/api/entities/Account/index.js.map +1 -1
- package/api/entities/Account/types.d.ts +1 -1
- package/api/entities/Asset/Base/Settlements/index.d.ts +85 -0
- package/api/entities/Asset/Base/Settlements/index.d.ts.map +1 -0
- package/api/entities/Asset/Base/Settlements/index.js +141 -0
- package/api/entities/Asset/Base/Settlements/index.js.map +1 -0
- package/api/entities/Asset/Fungible/index.d.ts +2 -2
- package/api/entities/Asset/Fungible/index.d.ts.map +1 -1
- package/api/entities/Asset/Fungible/index.js +2 -2
- package/api/entities/Asset/Fungible/index.js.map +1 -1
- package/api/entities/Asset/NonFungible/Nft.d.ts +76 -5
- package/api/entities/Asset/NonFungible/Nft.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/Nft.js +162 -6
- package/api/entities/Asset/NonFungible/Nft.js.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.d.ts +30 -16
- package/api/entities/Asset/NonFungible/NftCollection.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.js +72 -27
- package/api/entities/Asset/NonFungible/NftCollection.js.map +1 -1
- package/api/entities/Asset/types.d.ts +23 -3
- package/api/entities/Asset/types.d.ts.map +1 -1
- package/api/entities/Asset/types.js.map +1 -1
- package/api/entities/Identity/AssetPermissions.d.ts +3 -3
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
- package/api/entities/Identity/AssetPermissions.js.map +1 -1
- package/api/entities/Identity/index.d.ts +17 -2
- package/api/entities/Identity/index.d.ts.map +1 -1
- package/api/entities/Identity/index.js +37 -0
- package/api/entities/Identity/index.js.map +1 -1
- package/api/entities/Instruction/index.d.ts.map +1 -1
- package/api/entities/Instruction/index.js +29 -20
- package/api/entities/Instruction/index.js.map +1 -1
- package/api/entities/Instruction/types.d.ts +10 -3
- package/api/entities/Instruction/types.d.ts.map +1 -1
- package/api/entities/Instruction/types.js.map +1 -1
- package/api/entities/MetadataEntry/index.d.ts +2 -2
- package/api/entities/MetadataEntry/index.d.ts.map +1 -1
- package/api/entities/MetadataEntry/index.js +1 -1
- package/api/entities/MetadataEntry/index.js.map +1 -1
- package/api/entities/MultiSigProposal/index.d.ts +36 -2
- package/api/entities/MultiSigProposal/index.d.ts.map +1 -1
- package/api/entities/MultiSigProposal/index.js +91 -10
- package/api/entities/MultiSigProposal/index.js.map +1 -1
- package/api/entities/MultiSigProposal/types.d.ts +15 -2
- package/api/entities/MultiSigProposal/types.d.ts.map +1 -1
- package/api/entities/MultiSigProposal/types.js +6 -1
- package/api/entities/MultiSigProposal/types.js.map +1 -1
- package/api/entities/Portfolio/index.d.ts +12 -4
- package/api/entities/Portfolio/index.d.ts.map +1 -1
- package/api/entities/Portfolio/index.js +69 -6
- package/api/entities/Portfolio/index.js.map +1 -1
- package/api/entities/Portfolio/types.d.ts +20 -5
- package/api/entities/Portfolio/types.d.ts.map +1 -1
- package/api/entities/Venue/types.d.ts +1 -1
- package/api/entities/common/namespaces/Authorizations.d.ts +2 -1
- package/api/entities/common/namespaces/Authorizations.d.ts.map +1 -1
- package/api/entities/common/namespaces/Authorizations.js.map +1 -1
- package/api/entities/types.d.ts +3 -1
- package/api/entities/types.d.ts.map +1 -1
- package/api/entities/types.js.map +1 -1
- package/api/procedures/addInstruction.d.ts.map +1 -1
- package/api/procedures/addInstruction.js +76 -17
- package/api/procedures/addInstruction.js.map +1 -1
- package/api/procedures/createNftCollection.d.ts.map +1 -1
- package/api/procedures/createNftCollection.js +1 -1
- package/api/procedures/createNftCollection.js.map +1 -1
- package/api/procedures/evaluateMultiSigProposal.d.ts +19 -0
- package/api/procedures/evaluateMultiSigProposal.d.ts.map +1 -0
- package/api/procedures/evaluateMultiSigProposal.js +92 -0
- package/api/procedures/evaluateMultiSigProposal.js.map +1 -0
- package/api/procedures/issueNft.js +1 -1
- package/api/procedures/issueNft.js.map +1 -1
- package/api/procedures/modifyClaims.d.ts.map +1 -1
- package/api/procedures/modifyClaims.js +7 -21
- package/api/procedures/modifyClaims.js.map +1 -1
- package/api/procedures/moveFunds.d.ts.map +1 -1
- package/api/procedures/moveFunds.js +82 -16
- package/api/procedures/moveFunds.js.map +1 -1
- package/api/procedures/redeemNft.d.ts +31 -0
- package/api/procedures/redeemNft.d.ts.map +1 -0
- package/api/procedures/redeemNft.js +87 -0
- package/api/procedures/redeemNft.js.map +1 -0
- package/api/procedures/setPermissionGroup.js +1 -1
- package/api/procedures/setPermissionGroup.js.map +1 -1
- package/api/procedures/types.d.ts +26 -9
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js.map +1 -1
- package/api/procedures/waivePermissions.js +1 -1
- package/api/procedures/waivePermissions.js.map +1 -1
- package/base/Context.d.ts.map +1 -1
- package/base/Context.js +24 -24
- package/base/Context.js.map +1 -1
- package/generated/types.d.ts +15 -4
- package/generated/types.d.ts.map +1 -1
- package/generated/types.js +11 -0
- package/generated/types.js.map +1 -1
- package/internal.d.ts +2 -0
- package/internal.d.ts.map +1 -1
- package/internal.js +7 -3
- package/internal.js.map +1 -1
- package/middleware/queries.d.ts +35 -2
- package/middleware/queries.d.ts.map +1 -1
- package/middleware/queries.js +153 -6
- package/middleware/queries.js.map +1 -1
- package/middleware/types.d.ts +73191 -17741
- package/middleware/types.d.ts.map +1 -1
- package/middleware/types.js +36984 -999
- package/middleware/types.js.map +1 -1
- package/middleware/typesV1.d.ts +1 -1
- package/middleware/typesV1.d.ts.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-23.0.0-beta.2.tgz +0 -0
- package/package.json +2 -2
- package/polkadot/augment-api-errors.d.ts +32 -18
- package/polkadot/augment-api-errors.d.ts.map +1 -1
- package/polkadot/augment-api-events.d.ts +81 -8
- package/polkadot/augment-api-events.d.ts.map +1 -1
- package/polkadot/augment-api-query.d.ts +75 -26
- package/polkadot/augment-api-query.d.ts.map +1 -1
- package/polkadot/augment-api-rpc.d.ts +9 -2
- package/polkadot/augment-api-rpc.d.ts.map +1 -1
- package/polkadot/augment-api-tx.d.ts +250 -53
- package/polkadot/augment-api-tx.d.ts.map +1 -1
- package/polkadot/augment-types.d.ts +3 -1
- package/polkadot/augment-types.d.ts.map +1 -1
- package/polkadot/lookup.d.ts +336 -259
- package/polkadot/lookup.d.ts.map +1 -1
- package/polkadot/lookup.js +345 -264
- package/polkadot/lookup.js.map +1 -1
- package/polkadot/polymesh/definitions.d.ts +11 -1
- package/polkadot/polymesh/definitions.d.ts.map +1 -1
- package/polkadot/polymesh/definitions.js +14 -1
- package/polkadot/polymesh/definitions.js.map +1 -1
- package/polkadot/polymesh/types.d.ts +17 -2
- package/polkadot/polymesh/types.d.ts.map +1 -1
- package/polkadot/registry.d.ts +8 -6
- package/polkadot/registry.d.ts.map +1 -1
- package/polkadot/schema.d.ts +29 -2
- package/polkadot/schema.d.ts.map +1 -1
- package/polkadot/schema.js +51 -3
- package/polkadot/schema.js.map +1 -1
- package/polkadot/settlement/definitions.d.ts +9 -0
- package/polkadot/settlement/definitions.d.ts.map +1 -1
- package/polkadot/settlement/definitions.js +21 -0
- package/polkadot/settlement/definitions.js.map +1 -1
- package/polkadot/types-lookup.d.ts +377 -269
- package/polkadot/types-lookup.d.ts.map +1 -1
- package/types/index.d.ts +53 -7
- package/types/index.d.ts.map +1 -1
- package/types/index.js +18 -2
- package/types/index.js.map +1 -1
- package/types/internal.d.ts +1 -1
- package/utils/constants.d.ts +17 -1
- package/utils/constants.d.ts.map +1 -1
- package/utils/constants.js +18 -2
- package/utils/constants.js.map +1 -1
- package/utils/conversion.d.ts +38 -13
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +451 -367
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +20 -3
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +119 -42
- package/utils/internal.js.map +1 -1
- package/utils/typeguards.d.ts +26 -2
- package/utils/typeguards.d.ts.map +1 -1
- package/utils/typeguards.js +39 -2
- package/utils/typeguards.js.map +1 -1
- package/api/entities/Asset/Fungible/Settlements/index.d.ts +0 -29
- package/api/entities/Asset/Fungible/Settlements/index.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/Settlements/index.js +0 -70
- package/api/entities/Asset/Fungible/Settlements/index.js.map +0 -1
- package/middleware/enums.d.ts +0 -3
- package/middleware/enums.d.ts.map +0 -1
- package/middleware/enums.js +0 -38
- package/middleware/enums.js.map +0 -1
- package/npm-package/polymeshassociation-polymesh-sdk-23.0.0-alpha.9.tgz +0 -0
package/utils/conversion.js
CHANGED
|
@@ -19,8 +19,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.u32ToBigNumber = exports.bigNumberToU32 = exports.meshPermissionsToPermissions = exports.extrinsicPermissionsToTransactionPermissions = exports.permissionsToMeshPermissions = exports.transactionPermissionsToExtrinsicPermissions = exports.transactionPermissionsToTxGroups = exports.txGroupToTxTags = exports.textToString = exports.stringToText = exports.portfolioToPortfolioKind = exports.portfolioIdToMeshPortfolioId = exports.portfolioLikeToPortfolio = exports.portfolioIdToPortfolio = exports.portfolioLikeToPortfolioId = exports.portfolioToPortfolioId = exports.meshPortfolioIdToPortfolio = exports.claimPercentageToClaimPercentageRestrictionValue = exports.claimCountToClaimCountRestrictionValue = exports.meshClaimToInputStatClaim = exports.permillToBigNumber = exports.percentageToPermill = exports.bigNumberToU128 = exports.bigNumberToU64 = exports.u128ToBigNumber = exports.u64ToBigNumber = exports.signerToString = exports.signerToSignatory = exports.signerValueToSigner = exports.signerToSignerValue = exports.signatoryToSignerValue = exports.signerValueToSignatory = exports.identityIdToString = exports.stringToIdentityId = exports.stringToBlockHash = exports.stringToHash = exports.hashToString = exports.accountIdToString = exports.stringToAccountId = exports.momentToDate = exports.dateToMoment = exports.stringToU8aFixed = exports.tickerToString = exports.stringToTickerKey = exports.stringToTicker = exports.bytesToString = exports.stringToBytes = exports.boolToBoolean = exports.booleanToBool = exports.tickerToDid = void 0;
|
|
21
21
|
exports.txTagToExtrinsicIdentifier = exports.extrinsicIdentifierToTxTag = exports.txTagToProtocolOp = exports.complianceRequirementToRequirement = exports.complianceRequirementResultToRequirementCompliance = exports.requirementToComplianceRequirement = exports.trustedClaimIssuerToTrustedIssuer = exports.trustedIssuerToTrustedClaimIssuer = exports.meshClaimTypeToClaimType = exports.stringToTargetIdentity = exports.statsClaimToStatClaimInputType = exports.meshClaimToClaim = exports.middlewareEventDetailsToEventIdentifier = exports.scopeToMiddlewareScope = exports.middlewareScopeToScope = exports.claimToMeshClaim = exports.cddIdToString = exports.stringToCddId = exports.meshScopeToScope = exports.scopeToMeshScope = exports.canTransferResultToTransferStatus = exports.cddStatusToBoolean = exports.documentToAssetDocument = exports.assetDocumentToDocument = exports.documentHashToString = exports.stringToDocumentHash = exports.assetIdentifierToSecurityIdentifier = exports.securityIdentifierToAssetIdentifier = exports.isFigiValid = exports.isLeiValid = exports.isCusipValid = exports.isIsinValid = exports.fundingRoundToAssetFundingRound = exports.nameToAssetName = exports.posRatioToBigNumber = exports.assetTypeToKnownOrId = exports.internalNftTypeToNftType = exports.internalAssetTypeToAssetType = exports.u8ToTransferStatus = exports.stringToMemo = exports.authorizationDataToAuthorization = exports.agentGroupToPermissionGroup = exports.balanceToBigNumber = exports.bigNumberToBalance = exports.authorizationTypeToMeshAuthorizationType = exports.authorizationToAuthorizationData = exports.agentGroupToPermissionGroupIdentifier = exports.permissionGroupIdentifierToAgentGroup = exports.u8ToBigNumber = exports.u16ToBigNumber = void 0;
|
|
22
|
-
exports.
|
|
23
|
-
exports.nftInputToNftMetadataVec = exports.nftInputToNftMetadataAttribute = exports.meshNftToNftId = exports.meshMetadataKeyToMetadataKey = exports.collectionKeysToMetadataKeys = exports.middlewareAuthorizationDataToAuthorization = exports.middlewarePermissionsDataToPermissions = exports.datesToScheduleCheckpoints = exports.middlewareAgentGroupDataToPermissionGroup = exports.
|
|
22
|
+
exports.createStat2ndKey = exports.transferRestrictionTypeToStatOpType = exports.statTypeToStatOpType = exports.meshStatToStatType = exports.statUpdatesToBtreeStatUpdate = exports.keyAndValueToStatUpdate = exports.transferConditionsToBtreeTransferConditions = exports.statisticStatTypesToBtreeStatType = exports.sortStatsByClaimType = exports.statisticsOpTypeToStatType = exports.corporateActionParamsToMeshCorporateActionArgs = exports.corporateActionIdentifierToCaId = exports.distributionToDividendDistributionParams = exports.caTaxWithholdingsToMeshTaxWithholdings = exports.targetsToTargetIdentities = exports.targetIdentitiesToCorporateActionTargets = exports.checkpointToRecordDateSpec = exports.corporateActionKindToCaKind = exports.meshCorporateActionToCorporateActionParams = exports.fundraiserToOfferingDetails = exports.fundraiserTierToTier = exports.middlewarePortfolioToPortfolio = exports.permissionsLikeToPermissions = exports.offeringTierToPriceTier = exports.granularCanTransferResultToTransferBreakdown = exports.nftDispatchErrorToTransferError = exports.transferConditionToTransferRestriction = exports.identitiesToBtreeSet = exports.transferRestrictionToPolymeshTransferCondition = exports.claimIssuerToMeshClaimIssuer = exports.claimTypeToMeshClaimType = exports.nftMovementToPortfolioFund = exports.fungibleMovementToPortfolioFund = exports.nftToMeshNft = exports.toIdentityWithClaimsArray = exports.middlewareClaimToClaimData = exports.endConditionToSettlementType = exports.meshSettlementTypeToEndCondition = exports.meshAffirmationStatusToAffirmationStatus = exports.meshInstructionStatusToInstructionStatus = exports.venueTypeToMeshVenueType = exports.meshVenueTypeToVenueType = exports.secondaryAccountToMeshSecondaryKey = exports.transactionToTxTag = exports.transactionHexToTxTag = exports.coerceHexToString = exports.addressToKey = exports.keyToAddress = exports.moduleAddressToString = exports.assetComplianceResultToCompliance = void 0;
|
|
23
|
+
exports.toCustomClaimTypeWithIdentity = exports.nftInputToNftMetadataVec = exports.nftInputToNftMetadataAttribute = exports.meshNftToNftId = exports.meshMetadataKeyToMetadataKey = exports.collectionKeysToMetadataKeys = exports.middlewareAuthorizationDataToAuthorization = exports.middlewarePermissionsDataToPermissions = exports.datesToScheduleCheckpoints = exports.middlewareAgentGroupDataToPermissionGroup = exports.legToNonFungibleLeg = exports.legToFungibleLeg = exports.middlewarePortfolioDataToPortfolio = exports.expiryToMoment = exports.middlewareInstructionToHistoricInstruction = exports.instructionMemoToString = exports.metadataValueDetailToMeshMetadataValueDetail = exports.metadataValueToMeshMetadataValue = exports.meshMetadataValueToMetadataValue = exports.metadataToMeshMetadataKey = exports.meshMetadataSpecToMetadataSpec = exports.metadataSpecToMeshMetadataSpec = exports.meshProposalStatusToProposalStatus = exports.inputStatTypeToMeshStatType = exports.countStatInputToStatUpdates = exports.claimCountStatInputToStatUpdates = exports.toExemptKey = exports.complianceConditionsToBtreeSet = exports.sortTransferRestrictionByClaimValue = void 0;
|
|
24
24
|
const util_1 = require("@polkadot/util");
|
|
25
25
|
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
26
26
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
@@ -29,9 +29,9 @@ const lodash_1 = require("lodash");
|
|
|
29
29
|
const utils_1 = require("../api/procedures/utils");
|
|
30
30
|
const utils_2 = require("../generated/utils");
|
|
31
31
|
const internal_1 = require("../internal");
|
|
32
|
-
const
|
|
32
|
+
const types_1 = require("../middleware/types");
|
|
33
33
|
const typesV1_1 = require("../middleware/typesV1");
|
|
34
|
-
const
|
|
34
|
+
const types_2 = require("../types");
|
|
35
35
|
const internal_2 = require("../types/internal");
|
|
36
36
|
const utils_3 = require("../types/utils");
|
|
37
37
|
const constants_1 = require("./constants");
|
|
@@ -189,9 +189,9 @@ function createSignerValue(type, value) {
|
|
|
189
189
|
*/
|
|
190
190
|
function signatoryToSignerValue(signatory) {
|
|
191
191
|
if (signatory.isAccount) {
|
|
192
|
-
return createSignerValue(
|
|
192
|
+
return createSignerValue(types_2.SignerType.Account, accountIdToString(signatory.asAccount));
|
|
193
193
|
}
|
|
194
|
-
return createSignerValue(
|
|
194
|
+
return createSignerValue(types_2.SignerType.Identity, identityIdToString(signatory.asIdentity));
|
|
195
195
|
}
|
|
196
196
|
exports.signatoryToSignerValue = signatoryToSignerValue;
|
|
197
197
|
/**
|
|
@@ -199,9 +199,9 @@ exports.signatoryToSignerValue = signatoryToSignerValue;
|
|
|
199
199
|
*/
|
|
200
200
|
function signerToSignerValue(signer) {
|
|
201
201
|
if (signer instanceof internal_1.Account) {
|
|
202
|
-
return createSignerValue(
|
|
202
|
+
return createSignerValue(types_2.SignerType.Account, signer.address);
|
|
203
203
|
}
|
|
204
|
-
return createSignerValue(
|
|
204
|
+
return createSignerValue(types_2.SignerType.Identity, signer.did);
|
|
205
205
|
}
|
|
206
206
|
exports.signerToSignerValue = signerToSignerValue;
|
|
207
207
|
/**
|
|
@@ -209,7 +209,7 @@ exports.signerToSignerValue = signerToSignerValue;
|
|
|
209
209
|
*/
|
|
210
210
|
function signerValueToSigner(signerValue, context) {
|
|
211
211
|
const { type, value } = signerValue;
|
|
212
|
-
if (type ===
|
|
212
|
+
if (type === types_2.SignerType.Account) {
|
|
213
213
|
return new internal_1.Account({ address: value }, context);
|
|
214
214
|
}
|
|
215
215
|
return new internal_1.Identity({ did: value }, context);
|
|
@@ -271,7 +271,7 @@ function percentageToPermill(value, context) {
|
|
|
271
271
|
(0, internal_3.assertIsPositive)(value);
|
|
272
272
|
if (value.gt(100)) {
|
|
273
273
|
throw new internal_1.PolymeshError({
|
|
274
|
-
code:
|
|
274
|
+
code: types_2.ErrorCode.ValidationError,
|
|
275
275
|
message: "Percentage shouldn't exceed 100",
|
|
276
276
|
});
|
|
277
277
|
}
|
|
@@ -293,19 +293,19 @@ exports.permillToBigNumber = permillToBigNumber;
|
|
|
293
293
|
function meshClaimToInputStatClaim(claim) {
|
|
294
294
|
if (claim.isAccredited) {
|
|
295
295
|
return {
|
|
296
|
-
type:
|
|
296
|
+
type: types_2.ClaimType.Accredited,
|
|
297
297
|
accredited: boolToBoolean(claim.asAccredited),
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
300
|
else if (claim.isAffiliate) {
|
|
301
301
|
return {
|
|
302
|
-
type:
|
|
302
|
+
type: types_2.ClaimType.Affiliate,
|
|
303
303
|
affiliate: boolToBoolean(claim.asAffiliate),
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
else {
|
|
307
307
|
return {
|
|
308
|
-
type:
|
|
308
|
+
type: types_2.ClaimType.Jurisdiction,
|
|
309
309
|
countryCode: claim.asJurisdiction.isSome
|
|
310
310
|
? (0, utils_2.meshCountryCodeToCountryCode)(claim.asJurisdiction.unwrap())
|
|
311
311
|
: undefined,
|
|
@@ -449,89 +449,89 @@ exports.textToString = textToString;
|
|
|
449
449
|
*/
|
|
450
450
|
function txGroupToTxTags(group) {
|
|
451
451
|
switch (group) {
|
|
452
|
-
case
|
|
452
|
+
case types_2.TxGroup.PortfolioManagement: {
|
|
453
453
|
return [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
454
|
+
types_2.TxTags.identity.AddInvestorUniquenessClaim,
|
|
455
|
+
types_2.TxTags.portfolio.MovePortfolioFunds,
|
|
456
|
+
types_2.TxTags.settlement.AddInstruction,
|
|
457
|
+
types_2.TxTags.settlement.AddInstructionWithMemo,
|
|
458
|
+
types_2.TxTags.settlement.AddAndAffirmInstruction,
|
|
459
|
+
types_2.TxTags.settlement.AddAndAffirmInstructionWithMemo,
|
|
460
|
+
types_2.TxTags.settlement.AffirmInstruction,
|
|
461
|
+
types_2.TxTags.settlement.RejectInstruction,
|
|
462
|
+
types_2.TxTags.settlement.CreateVenue,
|
|
463
463
|
];
|
|
464
464
|
}
|
|
465
|
-
case
|
|
465
|
+
case types_2.TxGroup.AssetManagement: {
|
|
466
466
|
return [
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
467
|
+
types_2.TxTags.asset.MakeDivisible,
|
|
468
|
+
types_2.TxTags.asset.RenameAsset,
|
|
469
|
+
types_2.TxTags.asset.SetFundingRound,
|
|
470
|
+
types_2.TxTags.asset.AddDocuments,
|
|
471
|
+
types_2.TxTags.asset.RemoveDocuments,
|
|
472
472
|
];
|
|
473
473
|
}
|
|
474
|
-
case
|
|
474
|
+
case types_2.TxGroup.AdvancedAssetManagement: {
|
|
475
475
|
return [
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
476
|
+
types_2.TxTags.asset.Freeze,
|
|
477
|
+
types_2.TxTags.asset.Unfreeze,
|
|
478
|
+
types_2.TxTags.identity.AddAuthorization,
|
|
479
|
+
types_2.TxTags.identity.RemoveAuthorization,
|
|
480
480
|
];
|
|
481
481
|
}
|
|
482
|
-
case
|
|
482
|
+
case types_2.TxGroup.Distribution: {
|
|
483
483
|
return [
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
484
|
+
types_2.TxTags.identity.AddInvestorUniquenessClaim,
|
|
485
|
+
types_2.TxTags.settlement.CreateVenue,
|
|
486
|
+
types_2.TxTags.settlement.AddInstruction,
|
|
487
|
+
types_2.TxTags.settlement.AddInstructionWithMemo,
|
|
488
|
+
types_2.TxTags.settlement.AddAndAffirmInstruction,
|
|
489
|
+
types_2.TxTags.settlement.AddAndAffirmInstructionWithMemo,
|
|
490
490
|
];
|
|
491
491
|
}
|
|
492
|
-
case
|
|
493
|
-
return [
|
|
492
|
+
case types_2.TxGroup.Issuance: {
|
|
493
|
+
return [types_2.TxTags.asset.Issue];
|
|
494
494
|
}
|
|
495
|
-
case
|
|
495
|
+
case types_2.TxGroup.TrustedClaimIssuersManagement: {
|
|
496
496
|
return [
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
types_2.TxTags.complianceManager.AddDefaultTrustedClaimIssuer,
|
|
498
|
+
types_2.TxTags.complianceManager.RemoveDefaultTrustedClaimIssuer,
|
|
499
499
|
];
|
|
500
500
|
}
|
|
501
|
-
case
|
|
502
|
-
return [
|
|
501
|
+
case types_2.TxGroup.ClaimsManagement: {
|
|
502
|
+
return [types_2.TxTags.identity.AddClaim, types_2.TxTags.identity.RevokeClaim];
|
|
503
503
|
}
|
|
504
|
-
case
|
|
504
|
+
case types_2.TxGroup.ComplianceRequirementsManagement: {
|
|
505
505
|
return [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
506
|
+
types_2.TxTags.complianceManager.AddComplianceRequirement,
|
|
507
|
+
types_2.TxTags.complianceManager.RemoveComplianceRequirement,
|
|
508
|
+
types_2.TxTags.complianceManager.PauseAssetCompliance,
|
|
509
|
+
types_2.TxTags.complianceManager.ResumeAssetCompliance,
|
|
510
|
+
types_2.TxTags.complianceManager.ResetAssetCompliance,
|
|
511
511
|
];
|
|
512
512
|
}
|
|
513
|
-
case
|
|
513
|
+
case types_2.TxGroup.CorporateActionsManagement: {
|
|
514
514
|
return [
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
515
|
+
types_2.TxTags.checkpoint.CreateSchedule,
|
|
516
|
+
types_2.TxTags.checkpoint.RemoveSchedule,
|
|
517
|
+
types_2.TxTags.checkpoint.CreateCheckpoint,
|
|
518
|
+
types_2.TxTags.corporateAction.InitiateCorporateAction,
|
|
519
|
+
types_2.TxTags.capitalDistribution.Distribute,
|
|
520
|
+
types_2.TxTags.capitalDistribution.Claim,
|
|
521
|
+
types_2.TxTags.identity.AddInvestorUniquenessClaim,
|
|
522
522
|
];
|
|
523
523
|
}
|
|
524
|
-
case
|
|
524
|
+
case types_2.TxGroup.StoManagement: {
|
|
525
525
|
return [
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
526
|
+
types_2.TxTags.sto.CreateFundraiser,
|
|
527
|
+
types_2.TxTags.sto.FreezeFundraiser,
|
|
528
|
+
types_2.TxTags.sto.Invest,
|
|
529
|
+
types_2.TxTags.sto.ModifyFundraiserWindow,
|
|
530
|
+
types_2.TxTags.sto.Stop,
|
|
531
|
+
types_2.TxTags.sto.UnfreezeFundraiser,
|
|
532
|
+
types_2.TxTags.identity.AddInvestorUniquenessClaim,
|
|
533
|
+
types_2.TxTags.asset.Issue,
|
|
534
|
+
types_2.TxTags.settlement.CreateVenue,
|
|
535
535
|
];
|
|
536
536
|
}
|
|
537
537
|
}
|
|
@@ -550,7 +550,7 @@ function transactionPermissionsToTxGroups(permissions) {
|
|
|
550
550
|
const { values: transactionValues, type, exceptions = [] } = permissions;
|
|
551
551
|
let includedTags;
|
|
552
552
|
let excludedTags;
|
|
553
|
-
if (type ===
|
|
553
|
+
if (type === types_2.PermissionType.Include) {
|
|
554
554
|
includedTags = transactionValues;
|
|
555
555
|
excludedTags = exceptions;
|
|
556
556
|
}
|
|
@@ -558,7 +558,7 @@ function transactionPermissionsToTxGroups(permissions) {
|
|
|
558
558
|
includedTags = exceptions;
|
|
559
559
|
excludedTags = transactionValues;
|
|
560
560
|
}
|
|
561
|
-
return (0, lodash_1.values)(
|
|
561
|
+
return (0, lodash_1.values)(types_2.TxGroup)
|
|
562
562
|
.sort()
|
|
563
563
|
.filter(group => {
|
|
564
564
|
const tagsInGroup = txGroupToTxTags(group);
|
|
@@ -594,7 +594,7 @@ function initExtrinsicDict(txValues, message) {
|
|
|
594
594
|
let pallet = extrinsicDict[palletName];
|
|
595
595
|
if (pallet === null) {
|
|
596
596
|
throw new internal_1.PolymeshError({
|
|
597
|
-
code:
|
|
597
|
+
code: types_2.ErrorCode.ValidationError,
|
|
598
598
|
message,
|
|
599
599
|
data: {
|
|
600
600
|
module: palletName,
|
|
@@ -626,7 +626,7 @@ function buildPalletPermissions(transactions) {
|
|
|
626
626
|
const pallet = extrinsicDict[palletName];
|
|
627
627
|
if (pallet === undefined) {
|
|
628
628
|
throw new internal_1.PolymeshError({
|
|
629
|
-
code:
|
|
629
|
+
code: types_2.ErrorCode.ValidationError,
|
|
630
630
|
message: 'Attempting to add a transaction permission exception without its corresponding module being included/excluded',
|
|
631
631
|
});
|
|
632
632
|
}
|
|
@@ -638,7 +638,7 @@ function buildPalletPermissions(transactions) {
|
|
|
638
638
|
}
|
|
639
639
|
else {
|
|
640
640
|
throw new internal_1.PolymeshError({
|
|
641
|
-
code:
|
|
641
|
+
code: types_2.ErrorCode.ValidationError,
|
|
642
642
|
message: 'Cannot simultaneously include and exclude transactions belonging to the same module',
|
|
643
643
|
});
|
|
644
644
|
}
|
|
@@ -668,7 +668,7 @@ function buildPalletPermissions(transactions) {
|
|
|
668
668
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
669
669
|
};
|
|
670
670
|
});
|
|
671
|
-
if (type ===
|
|
671
|
+
if (type === types_2.PermissionType.Include) {
|
|
672
672
|
extrinsic = {
|
|
673
673
|
These: pallets,
|
|
674
674
|
};
|
|
@@ -698,7 +698,7 @@ function permissionsToMeshPermissions(permissions, context) {
|
|
|
698
698
|
const { values: assetValues, type } = assets;
|
|
699
699
|
assetValues.sort(({ ticker: tickerA }, { ticker: tickerB }) => tickerA.localeCompare(tickerB));
|
|
700
700
|
const tickers = assetValues.map(({ ticker }) => stringToTicker(ticker, context));
|
|
701
|
-
if (type ===
|
|
701
|
+
if (type === types_2.PermissionType.Include) {
|
|
702
702
|
asset = {
|
|
703
703
|
These: tickers,
|
|
704
704
|
};
|
|
@@ -713,7 +713,7 @@ function permissionsToMeshPermissions(permissions, context) {
|
|
|
713
713
|
if (portfolios) {
|
|
714
714
|
const { values: portfolioValues, type } = portfolios;
|
|
715
715
|
const portfolioIds = portfolioValues.map(pValue => portfolioIdToMeshPortfolioId(portfolioToPortfolioId(pValue), context));
|
|
716
|
-
if (type ===
|
|
716
|
+
if (type === types_2.PermissionType.Include) {
|
|
717
717
|
portfolio = {
|
|
718
718
|
These: portfolioIds,
|
|
719
719
|
};
|
|
@@ -742,11 +742,11 @@ function extrinsicPermissionsToTransactionPermissions(permissions) {
|
|
|
742
742
|
let extrinsicType;
|
|
743
743
|
let pallets;
|
|
744
744
|
if (permissions.isThese) {
|
|
745
|
-
extrinsicType =
|
|
745
|
+
extrinsicType = types_2.PermissionType.Include;
|
|
746
746
|
pallets = permissions.asThese;
|
|
747
747
|
}
|
|
748
748
|
else if (permissions.isExcept) {
|
|
749
|
-
extrinsicType =
|
|
749
|
+
extrinsicType = types_2.PermissionType.Exclude;
|
|
750
750
|
pallets = permissions.asExcept;
|
|
751
751
|
}
|
|
752
752
|
let txValues = [];
|
|
@@ -794,11 +794,11 @@ function meshPermissionsToPermissions(permissions, context) {
|
|
|
794
794
|
let assetsType;
|
|
795
795
|
let assetsPermissions;
|
|
796
796
|
if (asset.isThese) {
|
|
797
|
-
assetsType =
|
|
797
|
+
assetsType = types_2.PermissionType.Include;
|
|
798
798
|
assetsPermissions = asset.asThese;
|
|
799
799
|
}
|
|
800
800
|
else if (asset.isExcept) {
|
|
801
|
-
assetsType =
|
|
801
|
+
assetsType = types_2.PermissionType.Exclude;
|
|
802
802
|
assetsPermissions = asset.asExcept;
|
|
803
803
|
}
|
|
804
804
|
if (assetsPermissions) {
|
|
@@ -812,11 +812,11 @@ function meshPermissionsToPermissions(permissions, context) {
|
|
|
812
812
|
let portfoliosType;
|
|
813
813
|
let portfolioIds;
|
|
814
814
|
if (portfolio.isThese) {
|
|
815
|
-
portfoliosType =
|
|
815
|
+
portfoliosType = types_2.PermissionType.Include;
|
|
816
816
|
portfolioIds = portfolio.asThese;
|
|
817
817
|
}
|
|
818
818
|
else if (portfolio.isExcept) {
|
|
819
|
-
portfoliosType =
|
|
819
|
+
portfoliosType = types_2.PermissionType.Exclude;
|
|
820
820
|
portfolioIds = portfolio.asExcept;
|
|
821
821
|
}
|
|
822
822
|
if (portfolioIds) {
|
|
@@ -878,16 +878,16 @@ exports.permissionGroupIdentifierToAgentGroup = permissionGroupIdentifierToAgent
|
|
|
878
878
|
*/
|
|
879
879
|
function agentGroupToPermissionGroupIdentifier(agentGroup) {
|
|
880
880
|
if (agentGroup.isFull) {
|
|
881
|
-
return
|
|
881
|
+
return types_2.PermissionGroupType.Full;
|
|
882
882
|
}
|
|
883
883
|
else if (agentGroup.isExceptMeta) {
|
|
884
|
-
return
|
|
884
|
+
return types_2.PermissionGroupType.ExceptMeta;
|
|
885
885
|
}
|
|
886
886
|
else if (agentGroup.isPolymeshV1CAA) {
|
|
887
|
-
return
|
|
887
|
+
return types_2.PermissionGroupType.PolymeshV1Caa;
|
|
888
888
|
}
|
|
889
889
|
else if (agentGroup.isPolymeshV1PIA) {
|
|
890
|
-
return
|
|
890
|
+
return types_2.PermissionGroupType.PolymeshV1Pia;
|
|
891
891
|
}
|
|
892
892
|
else {
|
|
893
893
|
return { custom: u32ToBigNumber(agentGroup.asCustom) };
|
|
@@ -900,26 +900,26 @@ exports.agentGroupToPermissionGroupIdentifier = agentGroupToPermissionGroupIdent
|
|
|
900
900
|
function authorizationToAuthorizationData(auth, context) {
|
|
901
901
|
let value;
|
|
902
902
|
const { type } = auth;
|
|
903
|
-
if (type ===
|
|
903
|
+
if (type === types_2.AuthorizationType.AttestPrimaryKeyRotation) {
|
|
904
904
|
value = stringToIdentityId(auth.value.did, context);
|
|
905
905
|
}
|
|
906
|
-
else if (type ===
|
|
906
|
+
else if (type === types_2.AuthorizationType.RotatePrimaryKey) {
|
|
907
907
|
value = null;
|
|
908
908
|
}
|
|
909
|
-
else if (type ===
|
|
909
|
+
else if (type === types_2.AuthorizationType.JoinIdentity) {
|
|
910
910
|
value = permissionsToMeshPermissions(auth.value, context);
|
|
911
911
|
}
|
|
912
|
-
else if (type ===
|
|
912
|
+
else if (type === types_2.AuthorizationType.PortfolioCustody) {
|
|
913
913
|
value = portfolioIdToMeshPortfolioId(portfolioToPortfolioId(auth.value), context);
|
|
914
914
|
}
|
|
915
|
-
else if (auth.type ===
|
|
916
|
-
auth.type ===
|
|
915
|
+
else if (auth.type === types_2.AuthorizationType.TransferAssetOwnership ||
|
|
916
|
+
auth.type === types_2.AuthorizationType.TransferTicker) {
|
|
917
917
|
value = stringToTicker(auth.value, context);
|
|
918
918
|
}
|
|
919
|
-
else if (type ===
|
|
919
|
+
else if (type === types_2.AuthorizationType.RotatePrimaryKeyToSecondary) {
|
|
920
920
|
value = permissionsToMeshPermissions(auth.value, context);
|
|
921
921
|
}
|
|
922
|
-
else if (type ===
|
|
922
|
+
else if (type === types_2.AuthorizationType.BecomeAgent) {
|
|
923
923
|
const ticker = stringToTicker(auth.value.asset.ticker, context);
|
|
924
924
|
if (auth.value instanceof internal_1.CustomPermissionGroup) {
|
|
925
925
|
const { id } = auth.value;
|
|
@@ -953,7 +953,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
953
953
|
(0, internal_3.assertIsPositive)(value);
|
|
954
954
|
if (value.isGreaterThan(constants_1.MAX_BALANCE)) {
|
|
955
955
|
throw new internal_1.PolymeshError({
|
|
956
|
-
code:
|
|
956
|
+
code: types_2.ErrorCode.ValidationError,
|
|
957
957
|
message: 'The value exceeds the maximum possible balance',
|
|
958
958
|
data: {
|
|
959
959
|
currentValue: value,
|
|
@@ -964,7 +964,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
964
964
|
if (divisible) {
|
|
965
965
|
if (((_a = value.decimalPlaces()) !== null && _a !== void 0 ? _a : 0) > constants_1.MAX_DECIMALS) {
|
|
966
966
|
throw new internal_1.PolymeshError({
|
|
967
|
-
code:
|
|
967
|
+
code: types_2.ErrorCode.ValidationError,
|
|
968
968
|
message: 'The value has more decimal places than allowed',
|
|
969
969
|
data: {
|
|
970
970
|
currentValue: value,
|
|
@@ -976,7 +976,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
976
976
|
else {
|
|
977
977
|
if (value.decimalPlaces()) {
|
|
978
978
|
throw new internal_1.PolymeshError({
|
|
979
|
-
code:
|
|
979
|
+
code: types_2.ErrorCode.ValidationError,
|
|
980
980
|
message: 'The value has decimals but the Asset is indivisible',
|
|
981
981
|
});
|
|
982
982
|
}
|
|
@@ -996,10 +996,10 @@ exports.balanceToBigNumber = balanceToBigNumber;
|
|
|
996
996
|
*/
|
|
997
997
|
function assemblePermissionGroup(permissionGroupIdentifier, ticker, context) {
|
|
998
998
|
switch (permissionGroupIdentifier) {
|
|
999
|
-
case
|
|
1000
|
-
case
|
|
1001
|
-
case
|
|
1002
|
-
case
|
|
999
|
+
case types_2.PermissionGroupType.ExceptMeta:
|
|
1000
|
+
case types_2.PermissionGroupType.Full:
|
|
1001
|
+
case types_2.PermissionGroupType.PolymeshV1Caa:
|
|
1002
|
+
case types_2.PermissionGroupType.PolymeshV1Pia: {
|
|
1003
1003
|
return new internal_1.KnownPermissionGroup({ type: permissionGroupIdentifier, ticker }, context);
|
|
1004
1004
|
}
|
|
1005
1005
|
default: {
|
|
@@ -1022,7 +1022,7 @@ exports.agentGroupToPermissionGroup = agentGroupToPermissionGroup;
|
|
|
1022
1022
|
function authorizationDataToAuthorization(auth, context) {
|
|
1023
1023
|
if (auth.isAttestPrimaryKeyRotation) {
|
|
1024
1024
|
return {
|
|
1025
|
-
type:
|
|
1025
|
+
type: types_2.AuthorizationType.AttestPrimaryKeyRotation,
|
|
1026
1026
|
value: new internal_1.Identity({
|
|
1027
1027
|
did: identityIdToString(auth.asAttestPrimaryKeyRotation),
|
|
1028
1028
|
}, context),
|
|
@@ -1030,43 +1030,43 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1030
1030
|
}
|
|
1031
1031
|
if (auth.isRotatePrimaryKey) {
|
|
1032
1032
|
return {
|
|
1033
|
-
type:
|
|
1033
|
+
type: types_2.AuthorizationType.RotatePrimaryKey,
|
|
1034
1034
|
};
|
|
1035
1035
|
}
|
|
1036
1036
|
if (auth.isTransferTicker) {
|
|
1037
1037
|
return {
|
|
1038
|
-
type:
|
|
1038
|
+
type: types_2.AuthorizationType.TransferTicker,
|
|
1039
1039
|
value: tickerToString(auth.asTransferTicker),
|
|
1040
1040
|
};
|
|
1041
1041
|
}
|
|
1042
1042
|
if (auth.isAddMultiSigSigner) {
|
|
1043
1043
|
return {
|
|
1044
|
-
type:
|
|
1044
|
+
type: types_2.AuthorizationType.AddMultiSigSigner,
|
|
1045
1045
|
value: accountIdToString(auth.asAddMultiSigSigner),
|
|
1046
1046
|
};
|
|
1047
1047
|
}
|
|
1048
1048
|
if (auth.isTransferAssetOwnership) {
|
|
1049
1049
|
return {
|
|
1050
|
-
type:
|
|
1050
|
+
type: types_2.AuthorizationType.TransferAssetOwnership,
|
|
1051
1051
|
value: tickerToString(auth.asTransferAssetOwnership),
|
|
1052
1052
|
};
|
|
1053
1053
|
}
|
|
1054
1054
|
if (auth.isPortfolioCustody) {
|
|
1055
1055
|
return {
|
|
1056
|
-
type:
|
|
1056
|
+
type: types_2.AuthorizationType.PortfolioCustody,
|
|
1057
1057
|
value: meshPortfolioIdToPortfolio(auth.asPortfolioCustody, context),
|
|
1058
1058
|
};
|
|
1059
1059
|
}
|
|
1060
1060
|
if (auth.isJoinIdentity) {
|
|
1061
1061
|
return {
|
|
1062
|
-
type:
|
|
1062
|
+
type: types_2.AuthorizationType.JoinIdentity,
|
|
1063
1063
|
value: meshPermissionsToPermissions(auth.asJoinIdentity, context),
|
|
1064
1064
|
};
|
|
1065
1065
|
}
|
|
1066
1066
|
if (auth.isAddRelayerPayingKey) {
|
|
1067
1067
|
const [userKey, payingKey, polyxLimit] = auth.asAddRelayerPayingKey;
|
|
1068
1068
|
return {
|
|
1069
|
-
type:
|
|
1069
|
+
type: types_2.AuthorizationType.AddRelayerPayingKey,
|
|
1070
1070
|
value: {
|
|
1071
1071
|
beneficiary: new internal_1.Account({ address: accountIdToString(userKey) }, context),
|
|
1072
1072
|
subsidizer: new internal_1.Account({ address: accountIdToString(payingKey) }, context),
|
|
@@ -1077,18 +1077,18 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1077
1077
|
if (auth.isBecomeAgent) {
|
|
1078
1078
|
const [ticker, agentGroup] = auth.asBecomeAgent;
|
|
1079
1079
|
return {
|
|
1080
|
-
type:
|
|
1080
|
+
type: types_2.AuthorizationType.BecomeAgent,
|
|
1081
1081
|
value: agentGroupToPermissionGroup(agentGroup, tickerToString(ticker), context),
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
1084
|
if (auth.isRotatePrimaryKeyToSecondary) {
|
|
1085
1085
|
return {
|
|
1086
|
-
type:
|
|
1086
|
+
type: types_2.AuthorizationType.RotatePrimaryKeyToSecondary,
|
|
1087
1087
|
value: meshPermissionsToPermissions(auth.asRotatePrimaryKeyToSecondary, context),
|
|
1088
1088
|
};
|
|
1089
1089
|
}
|
|
1090
1090
|
throw new internal_1.PolymeshError({
|
|
1091
|
-
code:
|
|
1091
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
1092
1092
|
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
1093
1093
|
data: {
|
|
1094
1094
|
auth: JSON.stringify(auth, null, 2),
|
|
@@ -1102,7 +1102,7 @@ exports.authorizationDataToAuthorization = authorizationDataToAuthorization;
|
|
|
1102
1102
|
function assertMemoValid(value) {
|
|
1103
1103
|
if (value.length > constants_1.MAX_MEMO_LENGTH) {
|
|
1104
1104
|
throw new internal_1.PolymeshError({
|
|
1105
|
-
code:
|
|
1105
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1106
1106
|
message: 'Max memo length exceeded',
|
|
1107
1107
|
data: {
|
|
1108
1108
|
maxLength: constants_1.MAX_MEMO_LENGTH,
|
|
@@ -1125,71 +1125,71 @@ function u8ToTransferStatus(status) {
|
|
|
1125
1125
|
const code = status.toNumber();
|
|
1126
1126
|
switch (code) {
|
|
1127
1127
|
case 81: {
|
|
1128
|
-
return
|
|
1128
|
+
return types_2.TransferStatus.Success;
|
|
1129
1129
|
}
|
|
1130
1130
|
case 82: {
|
|
1131
|
-
return
|
|
1131
|
+
return types_2.TransferStatus.InsufficientBalance;
|
|
1132
1132
|
}
|
|
1133
1133
|
case 83: {
|
|
1134
|
-
return
|
|
1134
|
+
return types_2.TransferStatus.InsufficientAllowance;
|
|
1135
1135
|
}
|
|
1136
1136
|
case 84: {
|
|
1137
|
-
return
|
|
1137
|
+
return types_2.TransferStatus.TransfersHalted;
|
|
1138
1138
|
}
|
|
1139
1139
|
case 85: {
|
|
1140
|
-
return
|
|
1140
|
+
return types_2.TransferStatus.FundsLocked;
|
|
1141
1141
|
}
|
|
1142
1142
|
case 86: {
|
|
1143
|
-
return
|
|
1143
|
+
return types_2.TransferStatus.InvalidSenderAddress;
|
|
1144
1144
|
}
|
|
1145
1145
|
case 87: {
|
|
1146
|
-
return
|
|
1146
|
+
return types_2.TransferStatus.InvalidReceiverAddress;
|
|
1147
1147
|
}
|
|
1148
1148
|
case 88: {
|
|
1149
|
-
return
|
|
1149
|
+
return types_2.TransferStatus.InvalidOperator;
|
|
1150
1150
|
}
|
|
1151
1151
|
case 160: {
|
|
1152
|
-
return
|
|
1152
|
+
return types_2.TransferStatus.InvalidSenderIdentity;
|
|
1153
1153
|
}
|
|
1154
1154
|
case 161: {
|
|
1155
|
-
return
|
|
1155
|
+
return types_2.TransferStatus.InvalidReceiverIdentity;
|
|
1156
1156
|
}
|
|
1157
1157
|
case 162: {
|
|
1158
|
-
return
|
|
1158
|
+
return types_2.TransferStatus.ComplianceFailure;
|
|
1159
1159
|
}
|
|
1160
1160
|
case 163: {
|
|
1161
|
-
return
|
|
1161
|
+
return types_2.TransferStatus.SmartExtensionFailure;
|
|
1162
1162
|
}
|
|
1163
1163
|
case 164: {
|
|
1164
|
-
return
|
|
1164
|
+
return types_2.TransferStatus.InvalidGranularity;
|
|
1165
1165
|
}
|
|
1166
1166
|
case 165: {
|
|
1167
|
-
return
|
|
1167
|
+
return types_2.TransferStatus.VolumeLimitReached;
|
|
1168
1168
|
}
|
|
1169
1169
|
case 166: {
|
|
1170
|
-
return
|
|
1170
|
+
return types_2.TransferStatus.BlockedTransaction;
|
|
1171
1171
|
}
|
|
1172
1172
|
case 168: {
|
|
1173
|
-
return
|
|
1173
|
+
return types_2.TransferStatus.FundsLimitReached;
|
|
1174
1174
|
}
|
|
1175
1175
|
case 169: {
|
|
1176
|
-
return
|
|
1176
|
+
return types_2.TransferStatus.PortfolioFailure;
|
|
1177
1177
|
}
|
|
1178
1178
|
case 170: {
|
|
1179
|
-
return
|
|
1179
|
+
return types_2.TransferStatus.CustodianError;
|
|
1180
1180
|
}
|
|
1181
1181
|
case 171: {
|
|
1182
|
-
return
|
|
1182
|
+
return types_2.TransferStatus.ScopeClaimMissing;
|
|
1183
1183
|
}
|
|
1184
1184
|
case 172: {
|
|
1185
|
-
return
|
|
1185
|
+
return types_2.TransferStatus.TransferRestrictionFailure;
|
|
1186
1186
|
}
|
|
1187
1187
|
case 80: {
|
|
1188
|
-
return
|
|
1188
|
+
return types_2.TransferStatus.Failure;
|
|
1189
1189
|
}
|
|
1190
1190
|
default: {
|
|
1191
1191
|
throw new internal_1.PolymeshError({
|
|
1192
|
-
code:
|
|
1192
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
1193
1193
|
message: `Unsupported status code "${status.toString()}". Please report this issue to the Polymesh team`,
|
|
1194
1194
|
});
|
|
1195
1195
|
}
|
|
@@ -1218,46 +1218,46 @@ function assetTypeToKnownOrId(assetType) {
|
|
|
1218
1218
|
const type = 'NonFungible';
|
|
1219
1219
|
const rawNftType = assetType.asNonFungible;
|
|
1220
1220
|
if (rawNftType.isDerivative) {
|
|
1221
|
-
return { type, value:
|
|
1221
|
+
return { type, value: types_2.KnownNftType.Derivative };
|
|
1222
1222
|
}
|
|
1223
1223
|
else if (rawNftType.isFixedIncome) {
|
|
1224
|
-
return { type, value:
|
|
1224
|
+
return { type, value: types_2.KnownNftType.FixedIncome };
|
|
1225
1225
|
}
|
|
1226
1226
|
else if (rawNftType.isInvoice) {
|
|
1227
|
-
return { type, value:
|
|
1227
|
+
return { type, value: types_2.KnownNftType.Invoice };
|
|
1228
1228
|
}
|
|
1229
1229
|
return { type, value: u32ToBigNumber(rawNftType.asCustom) };
|
|
1230
1230
|
}
|
|
1231
1231
|
const type = 'Fungible';
|
|
1232
1232
|
if (assetType.isEquityCommon) {
|
|
1233
|
-
return { type, value:
|
|
1233
|
+
return { type, value: types_2.KnownAssetType.EquityCommon };
|
|
1234
1234
|
}
|
|
1235
1235
|
if (assetType.isEquityPreferred) {
|
|
1236
|
-
return { type, value:
|
|
1236
|
+
return { type, value: types_2.KnownAssetType.EquityPreferred };
|
|
1237
1237
|
}
|
|
1238
1238
|
if (assetType.isCommodity) {
|
|
1239
|
-
return { type, value:
|
|
1239
|
+
return { type, value: types_2.KnownAssetType.Commodity };
|
|
1240
1240
|
}
|
|
1241
1241
|
if (assetType.isFixedIncome) {
|
|
1242
|
-
return { type, value:
|
|
1242
|
+
return { type, value: types_2.KnownAssetType.FixedIncome };
|
|
1243
1243
|
}
|
|
1244
1244
|
if (assetType.isReit) {
|
|
1245
|
-
return { type, value:
|
|
1245
|
+
return { type, value: types_2.KnownAssetType.Reit };
|
|
1246
1246
|
}
|
|
1247
1247
|
if (assetType.isFund) {
|
|
1248
|
-
return { type, value:
|
|
1248
|
+
return { type, value: types_2.KnownAssetType.Fund };
|
|
1249
1249
|
}
|
|
1250
1250
|
if (assetType.isRevenueShareAgreement) {
|
|
1251
|
-
return { type, value:
|
|
1251
|
+
return { type, value: types_2.KnownAssetType.RevenueShareAgreement };
|
|
1252
1252
|
}
|
|
1253
1253
|
if (assetType.isStructuredProduct) {
|
|
1254
|
-
return { type, value:
|
|
1254
|
+
return { type, value: types_2.KnownAssetType.StructuredProduct };
|
|
1255
1255
|
}
|
|
1256
1256
|
if (assetType.isDerivative) {
|
|
1257
|
-
return { type, value:
|
|
1257
|
+
return { type, value: types_2.KnownAssetType.Derivative };
|
|
1258
1258
|
}
|
|
1259
1259
|
if (assetType.isStableCoin) {
|
|
1260
|
-
return { type, value:
|
|
1260
|
+
return { type, value: types_2.KnownAssetType.StableCoin };
|
|
1261
1261
|
}
|
|
1262
1262
|
return { type, value: u32ToBigNumber(assetType.asCustom) };
|
|
1263
1263
|
}
|
|
@@ -1278,7 +1278,7 @@ function nameToAssetName(value, context) {
|
|
|
1278
1278
|
const nameMaxLength = u32ToBigNumber(assetNameMaxLength);
|
|
1279
1279
|
if (nameMaxLength.lt(value.length)) {
|
|
1280
1280
|
throw new internal_1.PolymeshError({
|
|
1281
|
-
code:
|
|
1281
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1282
1282
|
message: 'Asset name length exceeded',
|
|
1283
1283
|
data: {
|
|
1284
1284
|
maxLength: nameMaxLength,
|
|
@@ -1296,7 +1296,7 @@ function fundingRoundToAssetFundingRound(value, context) {
|
|
|
1296
1296
|
const nameMaxLength = u32ToBigNumber(fundingRoundNameMaxLength);
|
|
1297
1297
|
if (nameMaxLength.lt(value.length)) {
|
|
1298
1298
|
throw new internal_1.PolymeshError({
|
|
1299
|
-
code:
|
|
1299
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1300
1300
|
message: 'Asset funding round name length exceeded',
|
|
1301
1301
|
data: {
|
|
1302
1302
|
maxLength: nameMaxLength,
|
|
@@ -1416,19 +1416,19 @@ function securityIdentifierToAssetIdentifier(identifier, context) {
|
|
|
1416
1416
|
const { type, value } = identifier;
|
|
1417
1417
|
let error = false;
|
|
1418
1418
|
switch (type) {
|
|
1419
|
-
case
|
|
1419
|
+
case types_2.SecurityIdentifierType.Isin: {
|
|
1420
1420
|
if (!isIsinValid(value)) {
|
|
1421
1421
|
error = true;
|
|
1422
1422
|
}
|
|
1423
1423
|
break;
|
|
1424
1424
|
}
|
|
1425
|
-
case
|
|
1425
|
+
case types_2.SecurityIdentifierType.Lei: {
|
|
1426
1426
|
if (!isLeiValid(value)) {
|
|
1427
1427
|
error = true;
|
|
1428
1428
|
}
|
|
1429
1429
|
break;
|
|
1430
1430
|
}
|
|
1431
|
-
case
|
|
1431
|
+
case types_2.SecurityIdentifierType.Figi: {
|
|
1432
1432
|
if (!isFigiValid(value)) {
|
|
1433
1433
|
error = true;
|
|
1434
1434
|
}
|
|
@@ -1443,7 +1443,7 @@ function securityIdentifierToAssetIdentifier(identifier, context) {
|
|
|
1443
1443
|
}
|
|
1444
1444
|
if (error) {
|
|
1445
1445
|
throw new internal_1.PolymeshError({
|
|
1446
|
-
code:
|
|
1446
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1447
1447
|
message: `Invalid security identifier ${value} of type ${type}`,
|
|
1448
1448
|
});
|
|
1449
1449
|
}
|
|
@@ -1456,30 +1456,30 @@ exports.securityIdentifierToAssetIdentifier = securityIdentifierToAssetIdentifie
|
|
|
1456
1456
|
function assetIdentifierToSecurityIdentifier(identifier) {
|
|
1457
1457
|
if (identifier.isCusip) {
|
|
1458
1458
|
return {
|
|
1459
|
-
type:
|
|
1459
|
+
type: types_2.SecurityIdentifierType.Cusip,
|
|
1460
1460
|
value: (0, util_1.u8aToString)(identifier.asCusip),
|
|
1461
1461
|
};
|
|
1462
1462
|
}
|
|
1463
1463
|
if (identifier.isIsin) {
|
|
1464
1464
|
return {
|
|
1465
|
-
type:
|
|
1465
|
+
type: types_2.SecurityIdentifierType.Isin,
|
|
1466
1466
|
value: (0, util_1.u8aToString)(identifier.asIsin),
|
|
1467
1467
|
};
|
|
1468
1468
|
}
|
|
1469
1469
|
if (identifier.isCins) {
|
|
1470
1470
|
return {
|
|
1471
|
-
type:
|
|
1471
|
+
type: types_2.SecurityIdentifierType.Cins,
|
|
1472
1472
|
value: (0, util_1.u8aToString)(identifier.asCins),
|
|
1473
1473
|
};
|
|
1474
1474
|
}
|
|
1475
1475
|
if (identifier.isFigi) {
|
|
1476
1476
|
return {
|
|
1477
|
-
type:
|
|
1477
|
+
type: types_2.SecurityIdentifierType.Figi,
|
|
1478
1478
|
value: (0, util_1.u8aToString)(identifier.asFigi),
|
|
1479
1479
|
};
|
|
1480
1480
|
}
|
|
1481
1481
|
return {
|
|
1482
|
-
type:
|
|
1482
|
+
type: types_2.SecurityIdentifierType.Lei,
|
|
1483
1483
|
value: (0, util_1.u8aToString)(identifier.asLei),
|
|
1484
1484
|
};
|
|
1485
1485
|
}
|
|
@@ -1493,7 +1493,7 @@ function stringToDocumentHash(docHash, context) {
|
|
|
1493
1493
|
}
|
|
1494
1494
|
if (!(0, util_1.isHex)(docHash, -1, true)) {
|
|
1495
1495
|
throw new internal_1.PolymeshError({
|
|
1496
|
-
code:
|
|
1496
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1497
1497
|
message: 'Document hash must be a hexadecimal string prefixed by 0x',
|
|
1498
1498
|
});
|
|
1499
1499
|
}
|
|
@@ -1506,7 +1506,7 @@ function stringToDocumentHash(docHash, context) {
|
|
|
1506
1506
|
const type = hashTypes.find(({ maxLength: max }) => length <= max);
|
|
1507
1507
|
if (!type) {
|
|
1508
1508
|
throw new internal_1.PolymeshError({
|
|
1509
|
-
code:
|
|
1509
|
+
code: types_2.ErrorCode.ValidationError,
|
|
1510
1510
|
message: 'Document hash exceeds max length',
|
|
1511
1511
|
});
|
|
1512
1512
|
}
|
|
@@ -1599,7 +1599,7 @@ exports.cddStatusToBoolean = cddStatusToBoolean;
|
|
|
1599
1599
|
function canTransferResultToTransferStatus(canTransferResult) {
|
|
1600
1600
|
if (canTransferResult.isErr) {
|
|
1601
1601
|
throw new internal_1.PolymeshError({
|
|
1602
|
-
code:
|
|
1602
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
1603
1603
|
message: `Error while checking transfer validity: ${bytesToString(canTransferResult.asErr)}`,
|
|
1604
1604
|
});
|
|
1605
1605
|
}
|
|
@@ -1613,10 +1613,10 @@ function scopeToMeshScope(scope, context) {
|
|
|
1613
1613
|
const { type, value } = scope;
|
|
1614
1614
|
let scopeValue;
|
|
1615
1615
|
switch (type) {
|
|
1616
|
-
case
|
|
1616
|
+
case types_2.ScopeType.Ticker:
|
|
1617
1617
|
scopeValue = stringToTicker(value, context);
|
|
1618
1618
|
break;
|
|
1619
|
-
case
|
|
1619
|
+
case types_2.ScopeType.Identity:
|
|
1620
1620
|
scopeValue = stringToIdentityId(value, context);
|
|
1621
1621
|
break;
|
|
1622
1622
|
default:
|
|
@@ -1634,18 +1634,18 @@ exports.scopeToMeshScope = scopeToMeshScope;
|
|
|
1634
1634
|
function meshScopeToScope(scope) {
|
|
1635
1635
|
if (scope.isTicker) {
|
|
1636
1636
|
return {
|
|
1637
|
-
type:
|
|
1637
|
+
type: types_2.ScopeType.Ticker,
|
|
1638
1638
|
value: tickerToString(scope.asTicker),
|
|
1639
1639
|
};
|
|
1640
1640
|
}
|
|
1641
1641
|
if (scope.isIdentity) {
|
|
1642
1642
|
return {
|
|
1643
|
-
type:
|
|
1643
|
+
type: types_2.ScopeType.Identity,
|
|
1644
1644
|
value: identityIdToString(scope.asIdentity),
|
|
1645
1645
|
};
|
|
1646
1646
|
}
|
|
1647
1647
|
return {
|
|
1648
|
-
type:
|
|
1648
|
+
type: types_2.ScopeType.Custom,
|
|
1649
1649
|
value: (0, util_1.u8aToString)(scope.asCustom),
|
|
1650
1650
|
};
|
|
1651
1651
|
}
|
|
@@ -1670,15 +1670,20 @@ exports.cddIdToString = cddIdToString;
|
|
|
1670
1670
|
function claimToMeshClaim(claim, context) {
|
|
1671
1671
|
let value;
|
|
1672
1672
|
switch (claim.type) {
|
|
1673
|
-
case
|
|
1673
|
+
case types_2.ClaimType.CustomerDueDiligence: {
|
|
1674
1674
|
value = stringToCddId(claim.id, context);
|
|
1675
1675
|
break;
|
|
1676
1676
|
}
|
|
1677
|
-
case
|
|
1677
|
+
case types_2.ClaimType.Jurisdiction: {
|
|
1678
1678
|
const { code, scope } = claim;
|
|
1679
1679
|
value = (0, utils_3.tuple)(code, scopeToMeshScope(scope, context));
|
|
1680
1680
|
break;
|
|
1681
1681
|
}
|
|
1682
|
+
case types_2.ClaimType.Custom: {
|
|
1683
|
+
const { customClaimTypeId, scope } = claim;
|
|
1684
|
+
value = (0, utils_3.tuple)(bigNumberToU32(customClaimTypeId, context), scopeToMeshScope(scope, context));
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1682
1687
|
default: {
|
|
1683
1688
|
value = scopeToMeshScope(claim.scope, context);
|
|
1684
1689
|
}
|
|
@@ -1693,13 +1698,13 @@ function middlewareScopeToScope(scope) {
|
|
|
1693
1698
|
const { type, value } = scope;
|
|
1694
1699
|
switch (type) {
|
|
1695
1700
|
case typesV1_1.ClaimScopeTypeEnum.Ticker:
|
|
1696
|
-
return { type:
|
|
1701
|
+
return { type: types_2.ScopeType.Ticker, value: (0, internal_3.removePadding)(value) };
|
|
1697
1702
|
case typesV1_1.ClaimScopeTypeEnum.Identity:
|
|
1698
1703
|
case typesV1_1.ClaimScopeTypeEnum.Custom:
|
|
1699
1704
|
return { type: scope.type, value };
|
|
1700
1705
|
}
|
|
1701
1706
|
throw new internal_1.PolymeshError({
|
|
1702
|
-
code:
|
|
1707
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
1703
1708
|
message: 'Unsupported Scope Type. Please contact the Polymesh team',
|
|
1704
1709
|
data: {
|
|
1705
1710
|
scope,
|
|
@@ -1713,13 +1718,13 @@ exports.middlewareScopeToScope = middlewareScopeToScope;
|
|
|
1713
1718
|
function scopeToMiddlewareScope(scope, padTicker = true) {
|
|
1714
1719
|
const { type, value } = scope;
|
|
1715
1720
|
switch (type) {
|
|
1716
|
-
case
|
|
1721
|
+
case types_2.ScopeType.Ticker:
|
|
1717
1722
|
return {
|
|
1718
1723
|
type: typesV1_1.ClaimScopeTypeEnum.Ticker,
|
|
1719
1724
|
value: padTicker ? (0, lodash_1.padEnd)(value, 12, '\0') : value,
|
|
1720
1725
|
};
|
|
1721
|
-
case
|
|
1722
|
-
case
|
|
1726
|
+
case types_2.ScopeType.Identity:
|
|
1727
|
+
case types_2.ScopeType.Custom:
|
|
1723
1728
|
return { type: typesV1_1.ClaimScopeTypeEnum[scope.type], value };
|
|
1724
1729
|
}
|
|
1725
1730
|
}
|
|
@@ -1744,55 +1749,55 @@ function meshClaimToClaim(claim) {
|
|
|
1744
1749
|
if (claim.isJurisdiction) {
|
|
1745
1750
|
const [code, scope] = claim.asJurisdiction;
|
|
1746
1751
|
return {
|
|
1747
|
-
type:
|
|
1752
|
+
type: types_2.ClaimType.Jurisdiction,
|
|
1748
1753
|
code: (0, utils_2.meshCountryCodeToCountryCode)(code),
|
|
1749
1754
|
scope: meshScopeToScope(scope),
|
|
1750
1755
|
};
|
|
1751
1756
|
}
|
|
1752
1757
|
if (claim.isAccredited) {
|
|
1753
1758
|
return {
|
|
1754
|
-
type:
|
|
1759
|
+
type: types_2.ClaimType.Accredited,
|
|
1755
1760
|
scope: meshScopeToScope(claim.asAccredited),
|
|
1756
1761
|
};
|
|
1757
1762
|
}
|
|
1758
1763
|
if (claim.isAffiliate) {
|
|
1759
1764
|
return {
|
|
1760
|
-
type:
|
|
1765
|
+
type: types_2.ClaimType.Affiliate,
|
|
1761
1766
|
scope: meshScopeToScope(claim.asAffiliate),
|
|
1762
1767
|
};
|
|
1763
1768
|
}
|
|
1764
1769
|
if (claim.isBuyLockup) {
|
|
1765
1770
|
return {
|
|
1766
|
-
type:
|
|
1771
|
+
type: types_2.ClaimType.BuyLockup,
|
|
1767
1772
|
scope: meshScopeToScope(claim.asBuyLockup),
|
|
1768
1773
|
};
|
|
1769
1774
|
}
|
|
1770
1775
|
if (claim.isSellLockup) {
|
|
1771
1776
|
return {
|
|
1772
|
-
type:
|
|
1777
|
+
type: types_2.ClaimType.SellLockup,
|
|
1773
1778
|
scope: meshScopeToScope(claim.asSellLockup),
|
|
1774
1779
|
};
|
|
1775
1780
|
}
|
|
1776
1781
|
if (claim.isCustomerDueDiligence) {
|
|
1777
1782
|
return {
|
|
1778
|
-
type:
|
|
1783
|
+
type: types_2.ClaimType.CustomerDueDiligence,
|
|
1779
1784
|
id: cddIdToString(claim.asCustomerDueDiligence),
|
|
1780
1785
|
};
|
|
1781
1786
|
}
|
|
1782
1787
|
if (claim.isKnowYourCustomer) {
|
|
1783
1788
|
return {
|
|
1784
|
-
type:
|
|
1789
|
+
type: types_2.ClaimType.KnowYourCustomer,
|
|
1785
1790
|
scope: meshScopeToScope(claim.asKnowYourCustomer),
|
|
1786
1791
|
};
|
|
1787
1792
|
}
|
|
1788
1793
|
if (claim.isExempted) {
|
|
1789
1794
|
return {
|
|
1790
|
-
type:
|
|
1795
|
+
type: types_2.ClaimType.Exempted,
|
|
1791
1796
|
scope: meshScopeToScope(claim.asExempted),
|
|
1792
1797
|
};
|
|
1793
1798
|
}
|
|
1794
1799
|
return {
|
|
1795
|
-
type:
|
|
1800
|
+
type: types_2.ClaimType.Blocked,
|
|
1796
1801
|
scope: meshScopeToScope(claim.asBlocked),
|
|
1797
1802
|
};
|
|
1798
1803
|
}
|
|
@@ -1803,14 +1808,14 @@ exports.meshClaimToClaim = meshClaimToClaim;
|
|
|
1803
1808
|
function statsClaimToStatClaimInputType(claim) {
|
|
1804
1809
|
if (claim.isJurisdiction) {
|
|
1805
1810
|
return {
|
|
1806
|
-
type:
|
|
1811
|
+
type: types_2.ClaimType.Jurisdiction,
|
|
1807
1812
|
};
|
|
1808
1813
|
}
|
|
1809
1814
|
else if (claim.isAccredited) {
|
|
1810
|
-
return { type:
|
|
1815
|
+
return { type: types_2.ClaimType.Accredited };
|
|
1811
1816
|
}
|
|
1812
1817
|
else {
|
|
1813
|
-
return { type:
|
|
1818
|
+
return { type: types_2.ClaimType.Affiliate };
|
|
1814
1819
|
}
|
|
1815
1820
|
}
|
|
1816
1821
|
exports.statsClaimToStatClaimInputType = statsClaimToStatClaimInputType;
|
|
@@ -1828,30 +1833,30 @@ exports.stringToTargetIdentity = stringToTargetIdentity;
|
|
|
1828
1833
|
*/
|
|
1829
1834
|
function meshClaimTypeToClaimType(claimType) {
|
|
1830
1835
|
if (claimType.isJurisdiction) {
|
|
1831
|
-
return
|
|
1836
|
+
return types_2.ClaimType.Jurisdiction;
|
|
1832
1837
|
}
|
|
1833
1838
|
if (claimType.isAccredited) {
|
|
1834
|
-
return
|
|
1839
|
+
return types_2.ClaimType.Accredited;
|
|
1835
1840
|
}
|
|
1836
1841
|
if (claimType.isAffiliate) {
|
|
1837
|
-
return
|
|
1842
|
+
return types_2.ClaimType.Affiliate;
|
|
1838
1843
|
}
|
|
1839
1844
|
if (claimType.isBuyLockup) {
|
|
1840
|
-
return
|
|
1845
|
+
return types_2.ClaimType.BuyLockup;
|
|
1841
1846
|
}
|
|
1842
1847
|
if (claimType.isSellLockup) {
|
|
1843
|
-
return
|
|
1848
|
+
return types_2.ClaimType.SellLockup;
|
|
1844
1849
|
}
|
|
1845
1850
|
if (claimType.isCustomerDueDiligence) {
|
|
1846
|
-
return
|
|
1851
|
+
return types_2.ClaimType.CustomerDueDiligence;
|
|
1847
1852
|
}
|
|
1848
1853
|
if (claimType.isKnowYourCustomer) {
|
|
1849
|
-
return
|
|
1854
|
+
return types_2.ClaimType.KnowYourCustomer;
|
|
1850
1855
|
}
|
|
1851
1856
|
if (claimType.isExempted) {
|
|
1852
|
-
return
|
|
1857
|
+
return types_2.ClaimType.Exempted;
|
|
1853
1858
|
}
|
|
1854
|
-
return
|
|
1859
|
+
return types_2.ClaimType.Blocked;
|
|
1855
1860
|
}
|
|
1856
1861
|
exports.meshClaimTypeToClaimType = meshClaimTypeToClaimType;
|
|
1857
1862
|
/**
|
|
@@ -1912,7 +1917,7 @@ function requirementToComplianceRequirement(requirement, context) {
|
|
|
1912
1917
|
}
|
|
1913
1918
|
else {
|
|
1914
1919
|
// IsExternalAgent does not exist as a condition type in Polymesh, it's SDK sugar
|
|
1915
|
-
type =
|
|
1920
|
+
type = types_2.ConditionType.IsIdentity;
|
|
1916
1921
|
conditionContent = stringToTargetIdentity(null, context);
|
|
1917
1922
|
}
|
|
1918
1923
|
const { target, trustedClaimIssuers = [] } = condition;
|
|
@@ -1922,10 +1927,10 @@ function requirementToComplianceRequirement(requirement, context) {
|
|
|
1922
1927
|
},
|
|
1923
1928
|
issuers: trustedClaimIssuers.map(issuer => trustedClaimIssuerToTrustedIssuer(issuer, context)),
|
|
1924
1929
|
});
|
|
1925
|
-
if ([
|
|
1930
|
+
if ([types_2.ConditionTarget.Both, types_2.ConditionTarget.Receiver].includes(target)) {
|
|
1926
1931
|
receiverConditions.push(meshCondition);
|
|
1927
1932
|
}
|
|
1928
|
-
if ([
|
|
1933
|
+
if ([types_2.ConditionTarget.Both, types_2.ConditionTarget.Sender].includes(target)) {
|
|
1929
1934
|
senderConditions.push(meshCondition);
|
|
1930
1935
|
}
|
|
1931
1936
|
});
|
|
@@ -1942,19 +1947,19 @@ exports.requirementToComplianceRequirement = requirementToComplianceRequirement;
|
|
|
1942
1947
|
function meshConditionTypeToCondition(meshConditionType, context) {
|
|
1943
1948
|
if (meshConditionType.isIsPresent) {
|
|
1944
1949
|
return {
|
|
1945
|
-
type:
|
|
1950
|
+
type: types_2.ConditionType.IsPresent,
|
|
1946
1951
|
claim: meshClaimToClaim(meshConditionType.asIsPresent),
|
|
1947
1952
|
};
|
|
1948
1953
|
}
|
|
1949
1954
|
if (meshConditionType.isIsAbsent) {
|
|
1950
1955
|
return {
|
|
1951
|
-
type:
|
|
1956
|
+
type: types_2.ConditionType.IsAbsent,
|
|
1952
1957
|
claim: meshClaimToClaim(meshConditionType.asIsAbsent),
|
|
1953
1958
|
};
|
|
1954
1959
|
}
|
|
1955
1960
|
if (meshConditionType.isIsAnyOf) {
|
|
1956
1961
|
return {
|
|
1957
|
-
type:
|
|
1962
|
+
type: types_2.ConditionType.IsAnyOf,
|
|
1958
1963
|
claims: meshConditionType.asIsAnyOf.map(claim => meshClaimToClaim(claim)),
|
|
1959
1964
|
};
|
|
1960
1965
|
}
|
|
@@ -1962,16 +1967,16 @@ function meshConditionTypeToCondition(meshConditionType, context) {
|
|
|
1962
1967
|
const target = meshConditionType.asIsIdentity;
|
|
1963
1968
|
if (target.isExternalAgent) {
|
|
1964
1969
|
return {
|
|
1965
|
-
type:
|
|
1970
|
+
type: types_2.ConditionType.IsExternalAgent,
|
|
1966
1971
|
};
|
|
1967
1972
|
}
|
|
1968
1973
|
return {
|
|
1969
|
-
type:
|
|
1974
|
+
type: types_2.ConditionType.IsIdentity,
|
|
1970
1975
|
identity: new internal_1.Identity({ did: identityIdToString(target.asSpecific) }, context),
|
|
1971
1976
|
};
|
|
1972
1977
|
}
|
|
1973
1978
|
return {
|
|
1974
|
-
type:
|
|
1979
|
+
type: types_2.ConditionType.IsNoneOf,
|
|
1975
1980
|
claims: meshConditionType.asIsNoneOf.map(claim => meshClaimToClaim(claim)),
|
|
1976
1981
|
};
|
|
1977
1982
|
}
|
|
@@ -1984,7 +1989,7 @@ function complianceRequirementResultToRequirementCompliance(complianceRequiremen
|
|
|
1984
1989
|
const conditionCompliancesAreEqual = ({ condition: aCondition, complies: aComplies }, { condition: bCondition, complies: bComplies }) => (0, internal_3.conditionsAreEqual)(aCondition, bCondition) && aComplies === bComplies;
|
|
1985
1990
|
complianceRequirement.senderConditions.forEach(({ condition: { conditionType, issuers }, result }) => {
|
|
1986
1991
|
const newCondition = {
|
|
1987
|
-
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
1992
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_2.ConditionTarget.Sender, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1988
1993
|
complies: boolToBoolean(result),
|
|
1989
1994
|
};
|
|
1990
1995
|
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
@@ -1994,12 +1999,12 @@ function complianceRequirementResultToRequirementCompliance(complianceRequiremen
|
|
|
1994
1999
|
});
|
|
1995
2000
|
complianceRequirement.receiverConditions.forEach(({ condition: { conditionType, issuers }, result }) => {
|
|
1996
2001
|
const newCondition = {
|
|
1997
|
-
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
2002
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_2.ConditionTarget.Receiver, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1998
2003
|
complies: boolToBoolean(result),
|
|
1999
2004
|
};
|
|
2000
2005
|
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
2001
|
-
if (existingCondition && existingCondition.condition.target ===
|
|
2002
|
-
existingCondition.condition.target =
|
|
2006
|
+
if (existingCondition && existingCondition.condition.target === types_2.ConditionTarget.Sender) {
|
|
2007
|
+
existingCondition.condition.target = types_2.ConditionTarget.Both;
|
|
2003
2008
|
}
|
|
2004
2009
|
else {
|
|
2005
2010
|
conditions.push(newCondition);
|
|
@@ -2018,7 +2023,7 @@ exports.complianceRequirementResultToRequirementCompliance = complianceRequireme
|
|
|
2018
2023
|
function complianceRequirementToRequirement(complianceRequirement, context) {
|
|
2019
2024
|
const conditions = [];
|
|
2020
2025
|
complianceRequirement.senderConditions.forEach(({ conditionType, issuers }) => {
|
|
2021
|
-
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
2026
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_2.ConditionTarget.Sender });
|
|
2022
2027
|
if (issuers.length) {
|
|
2023
2028
|
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
2024
2029
|
}
|
|
@@ -2028,13 +2033,13 @@ function complianceRequirementToRequirement(complianceRequirement, context) {
|
|
|
2028
2033
|
}
|
|
2029
2034
|
});
|
|
2030
2035
|
complianceRequirement.receiverConditions.forEach(({ conditionType, issuers }) => {
|
|
2031
|
-
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
2036
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_2.ConditionTarget.Receiver });
|
|
2032
2037
|
if (issuers.length) {
|
|
2033
2038
|
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
2034
2039
|
}
|
|
2035
2040
|
const existingCondition = conditions.find(condition => (0, internal_3.conditionsAreEqual)(condition, newCondition));
|
|
2036
|
-
if (existingCondition && existingCondition.target ===
|
|
2037
|
-
existingCondition.target =
|
|
2041
|
+
if (existingCondition && existingCondition.target === types_2.ConditionTarget.Sender) {
|
|
2042
|
+
existingCondition.target = types_2.ConditionTarget.Both;
|
|
2038
2043
|
}
|
|
2039
2044
|
else {
|
|
2040
2045
|
conditions.push(newCondition);
|
|
@@ -2051,25 +2056,25 @@ exports.complianceRequirementToRequirement = complianceRequirementToRequirement;
|
|
|
2051
2056
|
*/
|
|
2052
2057
|
function txTagToProtocolOp(tag, context) {
|
|
2053
2058
|
const protocolOpTags = [
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2059
|
+
types_2.TxTags.asset.RegisterTicker,
|
|
2060
|
+
types_2.TxTags.asset.Issue,
|
|
2061
|
+
types_2.TxTags.asset.AddDocuments,
|
|
2062
|
+
types_2.TxTags.asset.CreateAsset,
|
|
2063
|
+
types_2.TxTags.capitalDistribution.Distribute,
|
|
2064
|
+
types_2.TxTags.checkpoint.CreateSchedule,
|
|
2065
|
+
types_2.TxTags.complianceManager.AddComplianceRequirement,
|
|
2066
|
+
types_2.TxTags.identity.CddRegisterDid,
|
|
2067
|
+
types_2.TxTags.identity.AddClaim,
|
|
2068
|
+
types_2.TxTags.identity.AddSecondaryKeysWithAuthorization,
|
|
2069
|
+
types_2.TxTags.pips.Propose,
|
|
2070
|
+
types_2.TxTags.corporateBallot.AttachBallot,
|
|
2071
|
+
types_2.TxTags.capitalDistribution.Distribute,
|
|
2067
2072
|
];
|
|
2068
2073
|
const [moduleName, extrinsicName] = tag.split('.');
|
|
2069
2074
|
const value = `${(0, util_1.stringUpperFirst)(moduleName)}${(0, util_1.stringUpperFirst)(extrinsicName)}`;
|
|
2070
2075
|
if (!(0, lodash_1.includes)(protocolOpTags, tag)) {
|
|
2071
2076
|
throw new internal_1.PolymeshError({
|
|
2072
|
-
code:
|
|
2077
|
+
code: types_2.ErrorCode.ValidationError,
|
|
2073
2078
|
message: `${value} does not match any PolymeshCommonUtilitiesProtocolFeeProtocolOp`,
|
|
2074
2079
|
});
|
|
2075
2080
|
}
|
|
@@ -2082,7 +2087,7 @@ exports.txTagToProtocolOp = txTagToProtocolOp;
|
|
|
2082
2087
|
function extrinsicIdentifierToTxTag(extrinsicIdentifier) {
|
|
2083
2088
|
const { moduleId, callId } = extrinsicIdentifier;
|
|
2084
2089
|
let moduleName;
|
|
2085
|
-
for (const txTagItem in
|
|
2090
|
+
for (const txTagItem in types_2.TxTags) {
|
|
2086
2091
|
if (txTagItem.toLowerCase() === moduleId) {
|
|
2087
2092
|
moduleName = txTagItem;
|
|
2088
2093
|
}
|
|
@@ -2181,15 +2186,15 @@ exports.secondaryAccountToMeshSecondaryKey = secondaryAccountToMeshSecondaryKey;
|
|
|
2181
2186
|
*/
|
|
2182
2187
|
function meshVenueTypeToVenueType(type) {
|
|
2183
2188
|
if (type.isOther) {
|
|
2184
|
-
return
|
|
2189
|
+
return types_2.VenueType.Other;
|
|
2185
2190
|
}
|
|
2186
2191
|
if (type.isDistribution) {
|
|
2187
|
-
return
|
|
2192
|
+
return types_2.VenueType.Distribution;
|
|
2188
2193
|
}
|
|
2189
2194
|
if (type.isSto) {
|
|
2190
|
-
return
|
|
2195
|
+
return types_2.VenueType.Sto;
|
|
2191
2196
|
}
|
|
2192
|
-
return
|
|
2197
|
+
return types_2.VenueType.Exchange;
|
|
2193
2198
|
}
|
|
2194
2199
|
exports.meshVenueTypeToVenueType = meshVenueTypeToVenueType;
|
|
2195
2200
|
/**
|
|
@@ -2223,12 +2228,12 @@ exports.meshInstructionStatusToInstructionStatus = meshInstructionStatusToInstru
|
|
|
2223
2228
|
*/
|
|
2224
2229
|
function meshAffirmationStatusToAffirmationStatus(status) {
|
|
2225
2230
|
if (status.isUnknown) {
|
|
2226
|
-
return
|
|
2231
|
+
return types_2.AffirmationStatus.Unknown;
|
|
2227
2232
|
}
|
|
2228
2233
|
if (status.isPending) {
|
|
2229
|
-
return
|
|
2234
|
+
return types_2.AffirmationStatus.Pending;
|
|
2230
2235
|
}
|
|
2231
|
-
return
|
|
2236
|
+
return types_2.AffirmationStatus.Affirmed;
|
|
2232
2237
|
}
|
|
2233
2238
|
exports.meshAffirmationStatusToAffirmationStatus = meshAffirmationStatusToAffirmationStatus;
|
|
2234
2239
|
/**
|
|
@@ -2236,15 +2241,15 @@ exports.meshAffirmationStatusToAffirmationStatus = meshAffirmationStatusToAffirm
|
|
|
2236
2241
|
*/
|
|
2237
2242
|
function meshSettlementTypeToEndCondition(type) {
|
|
2238
2243
|
if (type.isSettleOnBlock) {
|
|
2239
|
-
return { type:
|
|
2244
|
+
return { type: types_2.InstructionType.SettleOnBlock, endBlock: u32ToBigNumber(type.asSettleOnBlock) };
|
|
2240
2245
|
}
|
|
2241
2246
|
if (type.isSettleManual) {
|
|
2242
2247
|
return {
|
|
2243
|
-
type:
|
|
2248
|
+
type: types_2.InstructionType.SettleManual,
|
|
2244
2249
|
endAfterBlock: u32ToBigNumber(type.asSettleManual),
|
|
2245
2250
|
};
|
|
2246
2251
|
}
|
|
2247
|
-
return { type:
|
|
2252
|
+
return { type: types_2.InstructionType.SettleOnAffirmation };
|
|
2248
2253
|
}
|
|
2249
2254
|
exports.meshSettlementTypeToEndCondition = meshSettlementTypeToEndCondition;
|
|
2250
2255
|
/**
|
|
@@ -2254,16 +2259,16 @@ function endConditionToSettlementType(endCondition, context) {
|
|
|
2254
2259
|
let value;
|
|
2255
2260
|
const { type } = endCondition;
|
|
2256
2261
|
switch (type) {
|
|
2257
|
-
case
|
|
2258
|
-
value = { [
|
|
2262
|
+
case types_2.InstructionType.SettleOnBlock:
|
|
2263
|
+
value = { [types_2.InstructionType.SettleOnBlock]: bigNumberToU32(endCondition.endBlock, context) };
|
|
2259
2264
|
break;
|
|
2260
|
-
case
|
|
2265
|
+
case types_2.InstructionType.SettleManual:
|
|
2261
2266
|
value = {
|
|
2262
|
-
[
|
|
2267
|
+
[types_2.InstructionType.SettleManual]: bigNumberToU32(endCondition.endAfterBlock, context),
|
|
2263
2268
|
};
|
|
2264
2269
|
break;
|
|
2265
2270
|
default:
|
|
2266
|
-
value =
|
|
2271
|
+
value = types_2.InstructionType.SettleOnAffirmation;
|
|
2267
2272
|
}
|
|
2268
2273
|
return context.createType('PolymeshPrimitivesSettlementSettlementType', value);
|
|
2269
2274
|
}
|
|
@@ -2272,14 +2277,14 @@ exports.endConditionToSettlementType = endConditionToSettlementType;
|
|
|
2272
2277
|
* @hidden
|
|
2273
2278
|
*/
|
|
2274
2279
|
function middlewareClaimToClaimData(claim, context) {
|
|
2275
|
-
const { targetId, issuerId, issuanceDate, lastUpdateDate, expiry, type, jurisdiction, scope, cddId, } = claim;
|
|
2280
|
+
const { targetId, issuerId, issuanceDate, lastUpdateDate, expiry, type, jurisdiction, scope, cddId, customClaimTypeId, } = claim;
|
|
2276
2281
|
return {
|
|
2277
2282
|
target: new internal_1.Identity({ did: targetId }, context),
|
|
2278
2283
|
issuer: new internal_1.Identity({ did: issuerId }, context),
|
|
2279
2284
|
issuedAt: new Date(parseFloat(issuanceDate)),
|
|
2280
2285
|
lastUpdatedAt: new Date(parseFloat(lastUpdateDate)),
|
|
2281
2286
|
expiry: expiry ? new Date(parseFloat(expiry)) : null,
|
|
2282
|
-
claim: (0, internal_3.createClaim)(type, jurisdiction, scope, cddId),
|
|
2287
|
+
claim: (0, internal_3.createClaim)(type, jurisdiction, scope, cddId, customClaimTypeId ? new bignumber_js_1.default(customClaimTypeId) : undefined),
|
|
2283
2288
|
};
|
|
2284
2289
|
}
|
|
2285
2290
|
exports.middlewareClaimToClaimData = middlewareClaimToClaimData;
|
|
@@ -2297,7 +2302,17 @@ exports.toIdentityWithClaimsArray = toIdentityWithClaimsArray;
|
|
|
2297
2302
|
/**
|
|
2298
2303
|
* @hidden
|
|
2299
2304
|
*/
|
|
2300
|
-
function
|
|
2305
|
+
function nftToMeshNft(ticker, nfts, context) {
|
|
2306
|
+
return context.createType('PolymeshPrimitivesNftNfTs', {
|
|
2307
|
+
ticker: stringToTicker(ticker, context),
|
|
2308
|
+
ids: nfts.map(id => bigNumberToU64((0, internal_3.asNftId)(id), context)),
|
|
2309
|
+
});
|
|
2310
|
+
}
|
|
2311
|
+
exports.nftToMeshNft = nftToMeshNft;
|
|
2312
|
+
/**
|
|
2313
|
+
* @hidden
|
|
2314
|
+
*/
|
|
2315
|
+
function fungibleMovementToPortfolioFund(portfolioItem, context) {
|
|
2301
2316
|
const { asset, amount, memo } = portfolioItem;
|
|
2302
2317
|
return context.createType('PolymeshPrimitivesPortfolioFund', {
|
|
2303
2318
|
description: {
|
|
@@ -2309,7 +2324,23 @@ function portfolioMovementToPortfolioFund(portfolioItem, context) {
|
|
|
2309
2324
|
memo: (0, internal_3.optionize)(stringToMemo)(memo, context),
|
|
2310
2325
|
});
|
|
2311
2326
|
}
|
|
2312
|
-
exports.
|
|
2327
|
+
exports.fungibleMovementToPortfolioFund = fungibleMovementToPortfolioFund;
|
|
2328
|
+
/**
|
|
2329
|
+
* @hidden
|
|
2330
|
+
*/
|
|
2331
|
+
function nftMovementToPortfolioFund(portfolioItem, context) {
|
|
2332
|
+
const { asset, nfts, memo } = portfolioItem;
|
|
2333
|
+
return context.createType('PolymeshPrimitivesPortfolioFund', {
|
|
2334
|
+
description: {
|
|
2335
|
+
NonFungible: {
|
|
2336
|
+
ticker: stringToTicker((0, internal_3.asTicker)(asset), context),
|
|
2337
|
+
ids: nfts.map(nftId => bigNumberToU64((0, internal_3.asNftId)(nftId), context)),
|
|
2338
|
+
},
|
|
2339
|
+
},
|
|
2340
|
+
memo: (0, internal_3.optionize)(stringToMemo)(memo, context),
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
exports.nftMovementToPortfolioFund = nftMovementToPortfolioFund;
|
|
2313
2344
|
/**
|
|
2314
2345
|
* @hidden
|
|
2315
2346
|
*/
|
|
@@ -2334,30 +2365,30 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2334
2365
|
let restrictionType;
|
|
2335
2366
|
let restrictionValue;
|
|
2336
2367
|
const extractClaimValue = (claim) => {
|
|
2337
|
-
if (claim.type ===
|
|
2368
|
+
if (claim.type === types_2.ClaimType.Accredited) {
|
|
2338
2369
|
return booleanToBool(claim.accredited, context);
|
|
2339
2370
|
}
|
|
2340
|
-
else if (claim.type ===
|
|
2371
|
+
else if (claim.type === types_2.ClaimType.Affiliate) {
|
|
2341
2372
|
return booleanToBool(claim.affiliate, context);
|
|
2342
2373
|
}
|
|
2343
2374
|
else {
|
|
2344
2375
|
return (0, internal_3.optionize)(utils_2.countryCodeToMeshCountryCode)(claim.countryCode, context);
|
|
2345
2376
|
}
|
|
2346
2377
|
};
|
|
2347
|
-
if (type ===
|
|
2378
|
+
if (type === types_2.TransferRestrictionType.Count) {
|
|
2348
2379
|
restrictionType = 'MaxInvestorCount';
|
|
2349
2380
|
restrictionValue = bigNumberToU64(value, context);
|
|
2350
2381
|
}
|
|
2351
|
-
else if (type ===
|
|
2382
|
+
else if (type === types_2.TransferRestrictionType.Percentage) {
|
|
2352
2383
|
restrictionType = 'MaxInvestorOwnership';
|
|
2353
2384
|
restrictionValue = percentageToPermill(value, context);
|
|
2354
2385
|
}
|
|
2355
|
-
else if (type ===
|
|
2356
|
-
type ===
|
|
2386
|
+
else if (type === types_2.TransferRestrictionType.ClaimCount ||
|
|
2387
|
+
type === types_2.TransferRestrictionType.ClaimPercentage) {
|
|
2357
2388
|
let rawMin;
|
|
2358
2389
|
let rawMax;
|
|
2359
2390
|
const { min, max, claim, issuer } = value;
|
|
2360
|
-
if (type ===
|
|
2391
|
+
if (type === types_2.TransferRestrictionType.ClaimCount) {
|
|
2361
2392
|
restrictionType = 'ClaimCount';
|
|
2362
2393
|
rawMin = bigNumberToU64(min, context);
|
|
2363
2394
|
rawMax = (0, internal_3.optionize)(bigNumberToU64)(max, context);
|
|
@@ -2377,7 +2408,7 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2377
2408
|
}
|
|
2378
2409
|
else {
|
|
2379
2410
|
throw new internal_1.PolymeshError({
|
|
2380
|
-
code:
|
|
2411
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
2381
2412
|
message: `Unexpected transfer restriction type: "${type}". Please report this to the Polymesh team`,
|
|
2382
2413
|
});
|
|
2383
2414
|
}
|
|
@@ -2400,31 +2431,31 @@ exports.identitiesToBtreeSet = identitiesToBtreeSet;
|
|
|
2400
2431
|
function transferConditionToTransferRestriction(transferCondition, context) {
|
|
2401
2432
|
if (transferCondition.isMaxInvestorCount) {
|
|
2402
2433
|
return {
|
|
2403
|
-
type:
|
|
2434
|
+
type: types_2.TransferRestrictionType.Count,
|
|
2404
2435
|
value: u64ToBigNumber(transferCondition.asMaxInvestorCount),
|
|
2405
2436
|
};
|
|
2406
2437
|
}
|
|
2407
2438
|
else if (transferCondition.isMaxInvestorOwnership) {
|
|
2408
2439
|
return {
|
|
2409
|
-
type:
|
|
2440
|
+
type: types_2.TransferRestrictionType.Percentage,
|
|
2410
2441
|
value: permillToBigNumber(transferCondition.asMaxInvestorOwnership),
|
|
2411
2442
|
};
|
|
2412
2443
|
}
|
|
2413
2444
|
else if (transferCondition.isClaimCount) {
|
|
2414
2445
|
return {
|
|
2415
|
-
type:
|
|
2446
|
+
type: types_2.TransferRestrictionType.ClaimCount,
|
|
2416
2447
|
value: claimCountToClaimCountRestrictionValue(transferCondition.asClaimCount, context),
|
|
2417
2448
|
};
|
|
2418
2449
|
}
|
|
2419
2450
|
else if (transferCondition.isClaimOwnership) {
|
|
2420
2451
|
return {
|
|
2421
|
-
type:
|
|
2452
|
+
type: types_2.TransferRestrictionType.ClaimPercentage,
|
|
2422
2453
|
value: claimPercentageToClaimPercentageRestrictionValue(transferCondition.asClaimOwnership, context),
|
|
2423
2454
|
};
|
|
2424
2455
|
}
|
|
2425
2456
|
else {
|
|
2426
2457
|
throw new internal_1.PolymeshError({
|
|
2427
|
-
code:
|
|
2458
|
+
code: types_2.ErrorCode.FatalError,
|
|
2428
2459
|
message: 'Unexpected transfer condition type',
|
|
2429
2460
|
});
|
|
2430
2461
|
}
|
|
@@ -2433,38 +2464,61 @@ exports.transferConditionToTransferRestriction = transferConditionToTransferRest
|
|
|
2433
2464
|
/**
|
|
2434
2465
|
* @hidden
|
|
2435
2466
|
*/
|
|
2436
|
-
function
|
|
2437
|
-
const {
|
|
2467
|
+
function nftDispatchErrorToTransferError(error, context) {
|
|
2468
|
+
const { DuplicatedNFTId: duplicateErr, InvalidNFTTransferComplianceFailure: complianceErr, InvalidNFTTransferFrozenAsset: frozenErr, InvalidNFTTransferInsufficientCount: insufficientErr, NFTNotFound: notFoundErr, InvalidNFTTransferNFTNotOwned: notOwnedErr, InvalidNFTTransferSamePortfolio: samePortfolioErr, } = context.polymeshApi.errors.nft;
|
|
2469
|
+
if (error.isModule) {
|
|
2470
|
+
const moduleErr = error.asModule;
|
|
2471
|
+
if ([notOwnedErr, notFoundErr, insufficientErr, duplicateErr].some(err => err.is(moduleErr))) {
|
|
2472
|
+
return types_2.TransferError.InsufficientPortfolioBalance;
|
|
2473
|
+
}
|
|
2474
|
+
else if (frozenErr.is(moduleErr)) {
|
|
2475
|
+
return types_2.TransferError.TransfersFrozen;
|
|
2476
|
+
}
|
|
2477
|
+
else if (complianceErr.is(moduleErr)) {
|
|
2478
|
+
return types_2.TransferError.ComplianceFailure;
|
|
2479
|
+
}
|
|
2480
|
+
else if (samePortfolioErr.is(moduleErr)) {
|
|
2481
|
+
return types_2.TransferError.SelfTransfer;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
throw new internal_1.PolymeshError({
|
|
2485
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
2486
|
+
message: 'Received unknown NFT can transfer status',
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
exports.nftDispatchErrorToTransferError = nftDispatchErrorToTransferError;
|
|
2490
|
+
/**
|
|
2491
|
+
* @hidden
|
|
2492
|
+
*/
|
|
2493
|
+
function granularCanTransferResultToTransferBreakdown(result, validateNftResult, context) {
|
|
2494
|
+
const { invalid_granularity: invalidGranularity, self_transfer: selfTransfer, invalid_receiver_cdd: invalidReceiverCdd, invalid_sender_cdd: invalidSenderCdd, 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, }, transfer_condition_result: transferConditionResult, compliance_result: complianceResult, result: finalResult, } = result;
|
|
2438
2495
|
const general = [];
|
|
2439
2496
|
if (boolToBoolean(invalidGranularity)) {
|
|
2440
|
-
general.push(
|
|
2497
|
+
general.push(types_2.TransferError.InvalidGranularity);
|
|
2441
2498
|
}
|
|
2442
2499
|
if (boolToBoolean(selfTransfer)) {
|
|
2443
|
-
general.push(
|
|
2500
|
+
general.push(types_2.TransferError.SelfTransfer);
|
|
2444
2501
|
}
|
|
2445
2502
|
if (boolToBoolean(invalidReceiverCdd)) {
|
|
2446
|
-
general.push(
|
|
2503
|
+
general.push(types_2.TransferError.InvalidReceiverCdd);
|
|
2447
2504
|
}
|
|
2448
2505
|
if (boolToBoolean(invalidSenderCdd)) {
|
|
2449
|
-
general.push(
|
|
2450
|
-
}
|
|
2451
|
-
if (boolToBoolean(missingScopeClaim)) {
|
|
2452
|
-
general.push(types_1.TransferError.ScopeClaimMissing);
|
|
2506
|
+
general.push(types_2.TransferError.InvalidSenderCdd);
|
|
2453
2507
|
}
|
|
2454
2508
|
if (boolToBoolean(insufficientBalance)) {
|
|
2455
|
-
general.push(
|
|
2509
|
+
general.push(types_2.TransferError.InsufficientBalance);
|
|
2456
2510
|
}
|
|
2457
2511
|
if (boolToBoolean(assetFrozen)) {
|
|
2458
|
-
general.push(
|
|
2512
|
+
general.push(types_2.TransferError.TransfersFrozen);
|
|
2459
2513
|
}
|
|
2460
2514
|
if (boolToBoolean(senderPortfolioNotExists)) {
|
|
2461
|
-
general.push(
|
|
2515
|
+
general.push(types_2.TransferError.InvalidSenderPortfolio);
|
|
2462
2516
|
}
|
|
2463
2517
|
if (boolToBoolean(receiverPortfolioNotExists)) {
|
|
2464
|
-
general.push(
|
|
2518
|
+
general.push(types_2.TransferError.InvalidReceiverPortfolio);
|
|
2465
2519
|
}
|
|
2466
2520
|
if (boolToBoolean(senderInsufficientBalance)) {
|
|
2467
|
-
general.push(
|
|
2521
|
+
general.push(types_2.TransferError.InsufficientPortfolioBalance);
|
|
2468
2522
|
}
|
|
2469
2523
|
const restrictions = transferConditionResult.map(({ condition, result: tmResult }) => {
|
|
2470
2524
|
return {
|
|
@@ -2472,14 +2526,23 @@ function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
|
2472
2526
|
result: boolToBoolean(tmResult),
|
|
2473
2527
|
};
|
|
2474
2528
|
});
|
|
2529
|
+
let canTransfer = boolToBoolean(finalResult);
|
|
2530
|
+
if (canTransfer && (validateNftResult === null || validateNftResult === void 0 ? void 0 : validateNftResult.isErr)) {
|
|
2531
|
+
const transferError = nftDispatchErrorToTransferError(validateNftResult.asErr, context);
|
|
2532
|
+
general.push(transferError);
|
|
2533
|
+
canTransfer = false;
|
|
2534
|
+
}
|
|
2475
2535
|
return {
|
|
2476
2536
|
general,
|
|
2477
2537
|
compliance: assetComplianceResultToCompliance(complianceResult, context),
|
|
2478
2538
|
restrictions,
|
|
2479
|
-
result:
|
|
2539
|
+
result: canTransfer,
|
|
2480
2540
|
};
|
|
2481
2541
|
}
|
|
2482
2542
|
exports.granularCanTransferResultToTransferBreakdown = granularCanTransferResultToTransferBreakdown;
|
|
2543
|
+
/**
|
|
2544
|
+
* @hidden
|
|
2545
|
+
*/
|
|
2483
2546
|
/**
|
|
2484
2547
|
* @hidden
|
|
2485
2548
|
*/
|
|
@@ -2497,16 +2560,16 @@ exports.offeringTierToPriceTier = offeringTierToPriceTier;
|
|
|
2497
2560
|
function permissionsLikeToPermissions(permissionsLike, context) {
|
|
2498
2561
|
let assetPermissions = {
|
|
2499
2562
|
values: [],
|
|
2500
|
-
type:
|
|
2563
|
+
type: types_2.PermissionType.Include,
|
|
2501
2564
|
};
|
|
2502
2565
|
let transactionPermissions = {
|
|
2503
2566
|
values: [],
|
|
2504
|
-
type:
|
|
2567
|
+
type: types_2.PermissionType.Include,
|
|
2505
2568
|
};
|
|
2506
2569
|
let transactionGroupPermissions = [];
|
|
2507
2570
|
let portfolioPermissions = {
|
|
2508
2571
|
values: [],
|
|
2509
|
-
type:
|
|
2572
|
+
type: types_2.PermissionType.Include,
|
|
2510
2573
|
};
|
|
2511
2574
|
let transactions;
|
|
2512
2575
|
let transactionGroups;
|
|
@@ -2591,29 +2654,29 @@ function fundraiserToOfferingDetails(fundraiser, name, context) {
|
|
|
2591
2654
|
const isStarted = now > start;
|
|
2592
2655
|
const isExpired = end && now > end;
|
|
2593
2656
|
const minInvestment = balanceToBigNumber(rawMinInvestment);
|
|
2594
|
-
let timing =
|
|
2595
|
-
let balance =
|
|
2596
|
-
let sale =
|
|
2657
|
+
let timing = types_2.OfferingTimingStatus.NotStarted;
|
|
2658
|
+
let balance = types_2.OfferingBalanceStatus.Available;
|
|
2659
|
+
let sale = types_2.OfferingSaleStatus.Live;
|
|
2597
2660
|
if (isExpired) {
|
|
2598
|
-
timing =
|
|
2661
|
+
timing = types_2.OfferingTimingStatus.Expired;
|
|
2599
2662
|
}
|
|
2600
2663
|
else if (isStarted) {
|
|
2601
|
-
timing =
|
|
2664
|
+
timing = types_2.OfferingTimingStatus.Started;
|
|
2602
2665
|
}
|
|
2603
2666
|
if (totalRemainingValue.isZero()) {
|
|
2604
|
-
balance =
|
|
2667
|
+
balance = types_2.OfferingBalanceStatus.SoldOut;
|
|
2605
2668
|
}
|
|
2606
2669
|
else if (totalRemainingValue.lt(minInvestment)) {
|
|
2607
|
-
balance =
|
|
2670
|
+
balance = types_2.OfferingBalanceStatus.Residual;
|
|
2608
2671
|
}
|
|
2609
2672
|
if (rawStatus.isClosedEarly) {
|
|
2610
|
-
sale =
|
|
2673
|
+
sale = types_2.OfferingSaleStatus.ClosedEarly;
|
|
2611
2674
|
}
|
|
2612
2675
|
else if (rawStatus.isClosed) {
|
|
2613
|
-
sale =
|
|
2676
|
+
sale = types_2.OfferingSaleStatus.Closed;
|
|
2614
2677
|
}
|
|
2615
2678
|
else if (rawStatus.isFrozen) {
|
|
2616
|
-
sale =
|
|
2679
|
+
sale = types_2.OfferingSaleStatus.Frozen;
|
|
2617
2680
|
}
|
|
2618
2681
|
return {
|
|
2619
2682
|
creator: new internal_1.Identity({ did: identityIdToString(creator) }, context),
|
|
@@ -2643,23 +2706,23 @@ function meshCorporateActionToCorporateActionParams(corporateAction, details, co
|
|
|
2643
2706
|
const { kind: rawKind, declDate, targets: { identities, treatment }, defaultWithholdingTax, withholdingTax, } = corporateAction;
|
|
2644
2707
|
let kind;
|
|
2645
2708
|
if (rawKind.isIssuerNotice) {
|
|
2646
|
-
kind =
|
|
2709
|
+
kind = types_2.CorporateActionKind.IssuerNotice;
|
|
2647
2710
|
}
|
|
2648
2711
|
else if (rawKind.isPredictableBenefit) {
|
|
2649
|
-
kind =
|
|
2712
|
+
kind = types_2.CorporateActionKind.PredictableBenefit;
|
|
2650
2713
|
}
|
|
2651
2714
|
else if (rawKind.isUnpredictableBenefit) {
|
|
2652
|
-
kind =
|
|
2715
|
+
kind = types_2.CorporateActionKind.UnpredictableBenefit;
|
|
2653
2716
|
}
|
|
2654
2717
|
else if (rawKind.isReorganization) {
|
|
2655
|
-
kind =
|
|
2718
|
+
kind = types_2.CorporateActionKind.Reorganization;
|
|
2656
2719
|
}
|
|
2657
2720
|
else {
|
|
2658
|
-
kind =
|
|
2721
|
+
kind = types_2.CorporateActionKind.Other;
|
|
2659
2722
|
}
|
|
2660
2723
|
const targets = {
|
|
2661
2724
|
identities: identities.map(identityId => new internal_1.Identity({ did: identityIdToString(identityId) }, context)),
|
|
2662
|
-
treatment: treatment.isExclude ?
|
|
2725
|
+
treatment: treatment.isExclude ? types_2.TargetTreatment.Exclude : types_2.TargetTreatment.Include,
|
|
2663
2726
|
};
|
|
2664
2727
|
const taxWithholdings = withholdingTax.map(([identityId, tax]) => ({
|
|
2665
2728
|
identity: new internal_1.Identity({ did: identityIdToString(identityId) }, context),
|
|
@@ -2708,7 +2771,7 @@ function targetIdentitiesToCorporateActionTargets(targetIdentities, context) {
|
|
|
2708
2771
|
const { identities, treatment } = targetIdentities;
|
|
2709
2772
|
return {
|
|
2710
2773
|
identities: identities.map(identity => new internal_1.Identity({ did: identityIdToString(identity) }, context)),
|
|
2711
|
-
treatment: treatment.isInclude ?
|
|
2774
|
+
treatment: treatment.isInclude ? types_2.TargetTreatment.Include : types_2.TargetTreatment.Exclude,
|
|
2712
2775
|
};
|
|
2713
2776
|
}
|
|
2714
2777
|
exports.targetIdentitiesToCorporateActionTargets = targetIdentitiesToCorporateActionTargets;
|
|
@@ -2721,7 +2784,7 @@ function targetsToTargetIdentities(targets, context) {
|
|
|
2721
2784
|
const maxTargets = u32ToBigNumber(maxTargetIds);
|
|
2722
2785
|
if (maxTargets.lt(targets.identities.length)) {
|
|
2723
2786
|
throw new internal_1.PolymeshError({
|
|
2724
|
-
code:
|
|
2787
|
+
code: types_2.ErrorCode.ValidationError,
|
|
2725
2788
|
message: 'Too many target Identities',
|
|
2726
2789
|
data: {
|
|
2727
2790
|
maxTargets,
|
|
@@ -2861,17 +2924,17 @@ function meshStatToStatType(rawStat) {
|
|
|
2861
2924
|
const { op: { type }, claimIssuer, } = rawStat;
|
|
2862
2925
|
if (claimIssuer.isNone) {
|
|
2863
2926
|
if (type === 'Count') {
|
|
2864
|
-
return
|
|
2927
|
+
return types_2.StatType.Count;
|
|
2865
2928
|
}
|
|
2866
2929
|
else {
|
|
2867
|
-
return
|
|
2930
|
+
return types_2.StatType.Balance;
|
|
2868
2931
|
}
|
|
2869
2932
|
}
|
|
2870
2933
|
if (type === 'Count') {
|
|
2871
|
-
return
|
|
2934
|
+
return types_2.StatType.ScopedCount;
|
|
2872
2935
|
}
|
|
2873
2936
|
else {
|
|
2874
|
-
return
|
|
2937
|
+
return types_2.StatType.ScopedBalance;
|
|
2875
2938
|
}
|
|
2876
2939
|
}
|
|
2877
2940
|
exports.meshStatToStatType = meshStatToStatType;
|
|
@@ -2879,20 +2942,20 @@ exports.meshStatToStatType = meshStatToStatType;
|
|
|
2879
2942
|
* @hidden
|
|
2880
2943
|
*/
|
|
2881
2944
|
function statTypeToStatOpType(type, context) {
|
|
2882
|
-
if (type ===
|
|
2883
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2945
|
+
if (type === types_2.StatType.Count || type === types_2.StatType.ScopedCount) {
|
|
2946
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_2.StatType.Count);
|
|
2884
2947
|
}
|
|
2885
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2948
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_2.StatType.Balance);
|
|
2886
2949
|
}
|
|
2887
2950
|
exports.statTypeToStatOpType = statTypeToStatOpType;
|
|
2888
2951
|
/**
|
|
2889
2952
|
* @hidden
|
|
2890
2953
|
*/
|
|
2891
2954
|
function transferRestrictionTypeToStatOpType(type, context) {
|
|
2892
|
-
if (type ===
|
|
2893
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2955
|
+
if (type === types_2.TransferRestrictionType.Count || type === types_2.TransferRestrictionType.ClaimCount) {
|
|
2956
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_2.StatType.Count);
|
|
2894
2957
|
}
|
|
2895
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2958
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_2.StatType.Balance);
|
|
2896
2959
|
}
|
|
2897
2960
|
exports.transferRestrictionTypeToStatOpType = transferRestrictionTypeToStatOpType;
|
|
2898
2961
|
/**
|
|
@@ -2967,7 +3030,7 @@ function sortTransferRestrictionByClaimValue(conditions) {
|
|
|
2967
3030
|
}
|
|
2968
3031
|
const aCode = (0, utils_2.meshCountryCodeToCountryCode)(aClaim.unwrap());
|
|
2969
3032
|
const bCode = (0, utils_2.meshCountryCodeToCountryCode)(bClaim.unwrap());
|
|
2970
|
-
const countryOrder = Object.values(
|
|
3033
|
+
const countryOrder = Object.values(types_2.CountryCode);
|
|
2971
3034
|
return countryOrder.indexOf(aCode) - countryOrder.indexOf(bCode);
|
|
2972
3035
|
});
|
|
2973
3036
|
}
|
|
@@ -2993,7 +3056,7 @@ exports.toExemptKey = toExemptKey;
|
|
|
2993
3056
|
function claimCountStatInputToStatUpdates(args, context) {
|
|
2994
3057
|
const { value, claimType: type } = args;
|
|
2995
3058
|
let updateArgs;
|
|
2996
|
-
if (type ===
|
|
3059
|
+
if (type === types_2.ClaimType.Jurisdiction) {
|
|
2997
3060
|
updateArgs = value.map(({ countryCode, count }) => {
|
|
2998
3061
|
const rawSecondKey = createStat2ndKey(type, context, countryCode);
|
|
2999
3062
|
return keyAndValueToStatUpdate(rawSecondKey, bigNumberToU128(count, context), context);
|
|
@@ -3001,7 +3064,7 @@ function claimCountStatInputToStatUpdates(args, context) {
|
|
|
3001
3064
|
}
|
|
3002
3065
|
else {
|
|
3003
3066
|
let yes, no;
|
|
3004
|
-
if (type ===
|
|
3067
|
+
if (type === types_2.ClaimType.Accredited) {
|
|
3005
3068
|
({ accredited: yes, nonAccredited: no } = value);
|
|
3006
3069
|
}
|
|
3007
3070
|
else {
|
|
@@ -3037,7 +3100,7 @@ function inputStatTypeToMeshStatType(input, context) {
|
|
|
3037
3100
|
const { type } = input;
|
|
3038
3101
|
const op = statTypeToStatOpType(type, context);
|
|
3039
3102
|
let claimIssuer;
|
|
3040
|
-
if (type ===
|
|
3103
|
+
if (type === types_2.StatType.ScopedCount || type === types_2.StatType.ScopedBalance) {
|
|
3041
3104
|
claimIssuer = claimIssuerToMeshClaimIssuer(input.claimIssuer, context);
|
|
3042
3105
|
}
|
|
3043
3106
|
return statisticsOpTypeToStatType({ op, claimIssuer }, context);
|
|
@@ -3051,19 +3114,19 @@ function meshProposalStatusToProposalStatus(status, expiry) {
|
|
|
3051
3114
|
switch (type) {
|
|
3052
3115
|
case 'ActiveOrExpired':
|
|
3053
3116
|
if (!expiry || expiry > new Date()) {
|
|
3054
|
-
return
|
|
3117
|
+
return types_2.ProposalStatus.Active;
|
|
3055
3118
|
}
|
|
3056
3119
|
else {
|
|
3057
|
-
return
|
|
3120
|
+
return types_2.ProposalStatus.Expired;
|
|
3058
3121
|
}
|
|
3059
3122
|
case 'Invalid':
|
|
3060
|
-
return
|
|
3123
|
+
return types_2.ProposalStatus.Invalid;
|
|
3061
3124
|
case 'ExecutionSuccessful':
|
|
3062
|
-
return
|
|
3125
|
+
return types_2.ProposalStatus.Successful;
|
|
3063
3126
|
case 'ExecutionFailed':
|
|
3064
|
-
return
|
|
3127
|
+
return types_2.ProposalStatus.Failed;
|
|
3065
3128
|
case 'Rejected':
|
|
3066
|
-
return
|
|
3129
|
+
return types_2.ProposalStatus.Rejected;
|
|
3067
3130
|
default:
|
|
3068
3131
|
throw new utils_1.UnreachableCaseError(type);
|
|
3069
3132
|
}
|
|
@@ -3078,7 +3141,7 @@ function metadataSpecToMeshMetadataSpec(specs, context) {
|
|
|
3078
3141
|
const metadataTypeDefMaxLength = u32ToBigNumber(assetMetadataTypeDefMaxLength);
|
|
3079
3142
|
if (typeDef && metadataTypeDefMaxLength.lt(typeDef.length)) {
|
|
3080
3143
|
throw new internal_1.PolymeshError({
|
|
3081
|
-
code:
|
|
3144
|
+
code: types_2.ErrorCode.ValidationError,
|
|
3082
3145
|
message: '"typeDef" length exceeded for given Asset Metadata spec',
|
|
3083
3146
|
data: {
|
|
3084
3147
|
maxLength: metadataTypeDefMaxLength,
|
|
@@ -3118,7 +3181,7 @@ exports.meshMetadataSpecToMetadataSpec = meshMetadataSpecToMetadataSpec;
|
|
|
3118
3181
|
function metadataToMeshMetadataKey(type, id, context) {
|
|
3119
3182
|
const rawId = bigNumberToU64(id, context);
|
|
3120
3183
|
let metadataKey;
|
|
3121
|
-
if (type ===
|
|
3184
|
+
if (type === types_2.MetadataType.Local) {
|
|
3122
3185
|
metadataKey = { Local: rawId };
|
|
3123
3186
|
}
|
|
3124
3187
|
else {
|
|
@@ -3136,17 +3199,17 @@ function meshMetadataValueToMetadataValue(rawValue, rawDetails) {
|
|
|
3136
3199
|
}
|
|
3137
3200
|
let metadataValue = {
|
|
3138
3201
|
value: bytesToString(rawValue.unwrap()),
|
|
3139
|
-
lockStatus:
|
|
3202
|
+
lockStatus: types_2.MetadataLockStatus.Unlocked,
|
|
3140
3203
|
expiry: null,
|
|
3141
3204
|
};
|
|
3142
3205
|
if (rawDetails.isSome) {
|
|
3143
3206
|
const { lockStatus: rawLockStatus, expire } = rawDetails.unwrap();
|
|
3144
3207
|
metadataValue = Object.assign(Object.assign({}, metadataValue), { expiry: (0, internal_3.optionize)(momentToDate)(expire.unwrapOr(null)) });
|
|
3145
3208
|
if (rawLockStatus.isLocked) {
|
|
3146
|
-
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus:
|
|
3209
|
+
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus: types_2.MetadataLockStatus.Locked });
|
|
3147
3210
|
}
|
|
3148
3211
|
if (rawLockStatus.isLockedUntil) {
|
|
3149
|
-
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus:
|
|
3212
|
+
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus: types_2.MetadataLockStatus.LockedUntil, lockedUntil: momentToDate(rawLockStatus.asLockedUntil) });
|
|
3150
3213
|
}
|
|
3151
3214
|
}
|
|
3152
3215
|
return metadataValue;
|
|
@@ -3160,7 +3223,7 @@ function metadataValueToMeshMetadataValue(value, context) {
|
|
|
3160
3223
|
const metadataValueMaxLength = u32ToBigNumber(assetMetadataValueMaxLength);
|
|
3161
3224
|
if (metadataValueMaxLength.lt(value.length)) {
|
|
3162
3225
|
throw new internal_1.PolymeshError({
|
|
3163
|
-
code:
|
|
3226
|
+
code: types_2.ErrorCode.ValidationError,
|
|
3164
3227
|
message: 'Asset Metadata value length exceeded',
|
|
3165
3228
|
data: {
|
|
3166
3229
|
maxLength: metadataValueMaxLength,
|
|
@@ -3176,11 +3239,11 @@ exports.metadataValueToMeshMetadataValue = metadataValueToMeshMetadataValue;
|
|
|
3176
3239
|
function metadataValueDetailToMeshMetadataValueDetail(details, context) {
|
|
3177
3240
|
const { lockStatus, expiry } = details;
|
|
3178
3241
|
let meshLockStatus;
|
|
3179
|
-
if (lockStatus ===
|
|
3242
|
+
if (lockStatus === types_2.MetadataLockStatus.LockedUntil) {
|
|
3180
3243
|
const { lockedUntil } = details;
|
|
3181
3244
|
if (lockedUntil < new Date()) {
|
|
3182
3245
|
throw new internal_1.PolymeshError({
|
|
3183
|
-
code:
|
|
3246
|
+
code: types_2.ErrorCode.UnmetPrerequisite,
|
|
3184
3247
|
message: 'Locked until date must be in the future',
|
|
3185
3248
|
});
|
|
3186
3249
|
}
|
|
@@ -3191,7 +3254,7 @@ function metadataValueDetailToMeshMetadataValueDetail(details, context) {
|
|
|
3191
3254
|
}
|
|
3192
3255
|
if (expiry && expiry < new Date()) {
|
|
3193
3256
|
throw new internal_1.PolymeshError({
|
|
3194
|
-
code:
|
|
3257
|
+
code: types_2.ErrorCode.UnmetPrerequisite,
|
|
3195
3258
|
message: 'Expiry date must be in the future',
|
|
3196
3259
|
});
|
|
3197
3260
|
}
|
|
@@ -3216,9 +3279,9 @@ function middlewareInstructionToHistoricInstruction(instruction, context) {
|
|
|
3216
3279
|
const { id: instructionId, status, settlementType, endBlock, tradeDate, valueDate, legs: { nodes: legs }, memo, createdBlock, venueId, } = instruction;
|
|
3217
3280
|
const { blockId, hash, datetime } = createdBlock;
|
|
3218
3281
|
let typeDetails;
|
|
3219
|
-
if (settlementType ===
|
|
3282
|
+
if (settlementType === types_2.InstructionType.SettleOnAffirmation) {
|
|
3220
3283
|
typeDetails = {
|
|
3221
|
-
type:
|
|
3284
|
+
type: types_2.InstructionType.SettleOnAffirmation,
|
|
3222
3285
|
};
|
|
3223
3286
|
}
|
|
3224
3287
|
else {
|
|
@@ -3244,7 +3307,7 @@ exports.middlewareInstructionToHistoricInstruction = middlewareInstructionToHist
|
|
|
3244
3307
|
function expiryToMoment(expiry, context) {
|
|
3245
3308
|
if (expiry && expiry <= new Date()) {
|
|
3246
3309
|
throw new internal_1.PolymeshError({
|
|
3247
|
-
code:
|
|
3310
|
+
code: types_2.ErrorCode.UnmetPrerequisite,
|
|
3248
3311
|
message: 'Expiry date must be in the future',
|
|
3249
3312
|
});
|
|
3250
3313
|
}
|
|
@@ -3266,10 +3329,17 @@ exports.middlewarePortfolioDataToPortfolio = middlewarePortfolioDataToPortfolio;
|
|
|
3266
3329
|
/**
|
|
3267
3330
|
* @hidden
|
|
3268
3331
|
*/
|
|
3269
|
-
function
|
|
3270
|
-
return context.createType('PolymeshPrimitivesSettlementLeg', leg);
|
|
3332
|
+
function legToFungibleLeg(leg, context) {
|
|
3333
|
+
return context.createType('PolymeshPrimitivesSettlementLeg', { Fungible: leg });
|
|
3334
|
+
}
|
|
3335
|
+
exports.legToFungibleLeg = legToFungibleLeg;
|
|
3336
|
+
/**
|
|
3337
|
+
* @hidden
|
|
3338
|
+
*/
|
|
3339
|
+
function legToNonFungibleLeg(leg, context) {
|
|
3340
|
+
return context.createType('PolymeshPrimitivesSettlementLeg', { NonFungible: leg });
|
|
3271
3341
|
}
|
|
3272
|
-
exports.
|
|
3342
|
+
exports.legToNonFungibleLeg = legToNonFungibleLeg;
|
|
3273
3343
|
/**
|
|
3274
3344
|
* @hidden
|
|
3275
3345
|
*/
|
|
@@ -3278,16 +3348,16 @@ function middlewareAgentGroupDataToPermissionGroup(agentGroupData, context) {
|
|
|
3278
3348
|
const agentGroup = agentGroupData[asset];
|
|
3279
3349
|
let permissionGroupIdentifier;
|
|
3280
3350
|
if ('full' in agentGroup) {
|
|
3281
|
-
permissionGroupIdentifier =
|
|
3351
|
+
permissionGroupIdentifier = types_2.PermissionGroupType.Full;
|
|
3282
3352
|
}
|
|
3283
3353
|
else if ('exceptMeta' in agentGroup) {
|
|
3284
|
-
permissionGroupIdentifier =
|
|
3354
|
+
permissionGroupIdentifier = types_2.PermissionGroupType.ExceptMeta;
|
|
3285
3355
|
}
|
|
3286
3356
|
else if ('polymeshV1CAA' in agentGroup) {
|
|
3287
|
-
permissionGroupIdentifier =
|
|
3357
|
+
permissionGroupIdentifier = types_2.PermissionGroupType.PolymeshV1Caa;
|
|
3288
3358
|
}
|
|
3289
3359
|
else if ('polymeshV1PIA' in agentGroup) {
|
|
3290
|
-
permissionGroupIdentifier =
|
|
3360
|
+
permissionGroupIdentifier = types_2.PermissionGroupType.PolymeshV1Pia;
|
|
3291
3361
|
}
|
|
3292
3362
|
else {
|
|
3293
3363
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -3304,11 +3374,11 @@ function middlewareExtrinsicPermissionsDataToTransactionPermissions(permissions)
|
|
|
3304
3374
|
let extrinsicType;
|
|
3305
3375
|
let pallets;
|
|
3306
3376
|
if ('these' in permissions) {
|
|
3307
|
-
extrinsicType =
|
|
3377
|
+
extrinsicType = types_2.PermissionType.Include;
|
|
3308
3378
|
pallets = permissions.these;
|
|
3309
3379
|
}
|
|
3310
3380
|
else if ('except' in permissions) {
|
|
3311
|
-
extrinsicType =
|
|
3381
|
+
extrinsicType = types_2.PermissionType.Exclude;
|
|
3312
3382
|
pallets = permissions.except;
|
|
3313
3383
|
}
|
|
3314
3384
|
let txValues = [];
|
|
@@ -3364,11 +3434,11 @@ function middlewarePermissionsDataToPermissions(permissionsData, context) {
|
|
|
3364
3434
|
let assetsType;
|
|
3365
3435
|
let assetsPermissions;
|
|
3366
3436
|
if ('these' in asset) {
|
|
3367
|
-
assetsType =
|
|
3437
|
+
assetsType = types_2.PermissionType.Include;
|
|
3368
3438
|
assetsPermissions = asset.these;
|
|
3369
3439
|
}
|
|
3370
3440
|
else if ('except' in asset) {
|
|
3371
|
-
assetsType =
|
|
3441
|
+
assetsType = types_2.PermissionType.Exclude;
|
|
3372
3442
|
assetsPermissions = asset.except;
|
|
3373
3443
|
}
|
|
3374
3444
|
if (assetsPermissions) {
|
|
@@ -3382,11 +3452,11 @@ function middlewarePermissionsDataToPermissions(permissionsData, context) {
|
|
|
3382
3452
|
let portfoliosType;
|
|
3383
3453
|
let portfolioIds;
|
|
3384
3454
|
if ('these' in portfolio) {
|
|
3385
|
-
portfoliosType =
|
|
3455
|
+
portfoliosType = types_2.PermissionType.Include;
|
|
3386
3456
|
portfolioIds = portfolio.these;
|
|
3387
3457
|
}
|
|
3388
3458
|
else if ('except' in portfolio) {
|
|
3389
|
-
portfoliosType =
|
|
3459
|
+
portfoliosType = types_2.PermissionType.Exclude;
|
|
3390
3460
|
portfolioIds = portfolio.except;
|
|
3391
3461
|
}
|
|
3392
3462
|
if (portfolioIds) {
|
|
@@ -3410,41 +3480,41 @@ exports.middlewarePermissionsDataToPermissions = middlewarePermissionsDataToPerm
|
|
|
3410
3480
|
*/
|
|
3411
3481
|
function middlewareAuthorizationDataToAuthorization(context, type, data) {
|
|
3412
3482
|
switch (type) {
|
|
3413
|
-
case
|
|
3483
|
+
case types_1.AuthTypeEnum.AttestPrimaryKeyRotation:
|
|
3414
3484
|
return {
|
|
3415
|
-
type:
|
|
3485
|
+
type: types_2.AuthorizationType.AttestPrimaryKeyRotation,
|
|
3416
3486
|
value: new internal_1.Identity({ did: data }, context),
|
|
3417
3487
|
};
|
|
3418
|
-
case
|
|
3488
|
+
case types_1.AuthTypeEnum.RotatePrimaryKey: {
|
|
3419
3489
|
return {
|
|
3420
|
-
type:
|
|
3490
|
+
type: types_2.AuthorizationType.RotatePrimaryKey,
|
|
3421
3491
|
};
|
|
3422
3492
|
}
|
|
3423
|
-
case
|
|
3493
|
+
case types_1.AuthTypeEnum.RotatePrimaryKeyToSecondary: {
|
|
3424
3494
|
return {
|
|
3425
|
-
type:
|
|
3495
|
+
type: types_2.AuthorizationType.RotatePrimaryKeyToSecondary,
|
|
3426
3496
|
value: middlewarePermissionsDataToPermissions(data, context),
|
|
3427
3497
|
};
|
|
3428
3498
|
}
|
|
3429
|
-
case
|
|
3499
|
+
case types_1.AuthTypeEnum.JoinIdentity: {
|
|
3430
3500
|
return {
|
|
3431
|
-
type:
|
|
3501
|
+
type: types_2.AuthorizationType.JoinIdentity,
|
|
3432
3502
|
value: middlewarePermissionsDataToPermissions(data, context),
|
|
3433
3503
|
};
|
|
3434
3504
|
}
|
|
3435
|
-
case
|
|
3505
|
+
case types_1.AuthTypeEnum.AddMultiSigSigner:
|
|
3436
3506
|
return {
|
|
3437
|
-
type:
|
|
3507
|
+
type: types_2.AuthorizationType.AddMultiSigSigner,
|
|
3438
3508
|
value: data,
|
|
3439
3509
|
};
|
|
3440
|
-
case
|
|
3510
|
+
case types_1.AuthTypeEnum.AddRelayerPayingKey: {
|
|
3441
3511
|
// data is received in the format - {"5Ci94GCJC2JBM8U1PCkpHX6HkscWmucN9XwUrjb7o4TDgVns","5DZp1QYH49MKZhCtDupNaAeHp8xtqetuSzgf2p2cUWoxW3iu","1000000000"}
|
|
3442
3512
|
const [beneficiary, subsidizer, allowance] = data
|
|
3443
3513
|
.substring(1, data.length - 1)
|
|
3444
3514
|
.replace(/"/g, '')
|
|
3445
3515
|
.split(',');
|
|
3446
3516
|
return {
|
|
3447
|
-
type:
|
|
3517
|
+
type: types_2.AuthorizationType.AddRelayerPayingKey,
|
|
3448
3518
|
value: {
|
|
3449
3519
|
beneficiary: new internal_1.Account({ address: beneficiary }, context),
|
|
3450
3520
|
subsidizer: new internal_1.Account({ address: subsidizer }, context),
|
|
@@ -3452,33 +3522,33 @@ function middlewareAuthorizationDataToAuthorization(context, type, data) {
|
|
|
3452
3522
|
},
|
|
3453
3523
|
};
|
|
3454
3524
|
}
|
|
3455
|
-
case
|
|
3525
|
+
case types_1.AuthTypeEnum.BecomeAgent: {
|
|
3456
3526
|
const becomeAgentData = JSON.parse(data.replace(',', ':'));
|
|
3457
3527
|
return {
|
|
3458
|
-
type:
|
|
3528
|
+
type: types_2.AuthorizationType.BecomeAgent,
|
|
3459
3529
|
value: middlewareAgentGroupDataToPermissionGroup(becomeAgentData, context),
|
|
3460
3530
|
};
|
|
3461
3531
|
}
|
|
3462
|
-
case
|
|
3532
|
+
case types_1.AuthTypeEnum.TransferTicker:
|
|
3463
3533
|
return {
|
|
3464
|
-
type:
|
|
3534
|
+
type: types_2.AuthorizationType.TransferTicker,
|
|
3465
3535
|
value: (0, exports.coerceHexToString)(data),
|
|
3466
3536
|
};
|
|
3467
|
-
case
|
|
3537
|
+
case types_1.AuthTypeEnum.TransferAssetOwnership: {
|
|
3468
3538
|
return {
|
|
3469
|
-
type:
|
|
3539
|
+
type: types_2.AuthorizationType.TransferAssetOwnership,
|
|
3470
3540
|
value: (0, exports.coerceHexToString)(data),
|
|
3471
3541
|
};
|
|
3472
3542
|
}
|
|
3473
|
-
case
|
|
3543
|
+
case types_1.AuthTypeEnum.PortfolioCustody: {
|
|
3474
3544
|
return {
|
|
3475
|
-
type:
|
|
3545
|
+
type: types_2.AuthorizationType.PortfolioCustody,
|
|
3476
3546
|
value: middlewarePortfolioDataToPortfolio(JSON.parse(data), context),
|
|
3477
3547
|
};
|
|
3478
3548
|
}
|
|
3479
3549
|
}
|
|
3480
3550
|
throw new internal_1.PolymeshError({
|
|
3481
|
-
code:
|
|
3551
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
3482
3552
|
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
3483
3553
|
data: {
|
|
3484
3554
|
auth: data,
|
|
@@ -3502,10 +3572,10 @@ exports.collectionKeysToMetadataKeys = collectionKeysToMetadataKeys;
|
|
|
3502
3572
|
*/
|
|
3503
3573
|
function meshMetadataKeyToMetadataKey(rawKey, ticker) {
|
|
3504
3574
|
if (rawKey.isGlobal) {
|
|
3505
|
-
return { type:
|
|
3575
|
+
return { type: types_2.MetadataType.Global, id: u64ToBigNumber(rawKey.asGlobal) };
|
|
3506
3576
|
}
|
|
3507
3577
|
else {
|
|
3508
|
-
return { type:
|
|
3578
|
+
return { type: types_2.MetadataType.Local, id: u64ToBigNumber(rawKey.asLocal), ticker };
|
|
3509
3579
|
}
|
|
3510
3580
|
}
|
|
3511
3581
|
exports.meshMetadataKeyToMetadataKey = meshMetadataKeyToMetadataKey;
|
|
@@ -3541,4 +3611,18 @@ function nftInputToNftMetadataVec(nftInfo, context) {
|
|
|
3541
3611
|
return context.createType('Vec<PolymeshPrimitivesNftNftMetadataAttribute>', rawItems);
|
|
3542
3612
|
}
|
|
3543
3613
|
exports.nftInputToNftMetadataVec = nftInputToNftMetadataVec;
|
|
3614
|
+
/**
|
|
3615
|
+
* @hidden
|
|
3616
|
+
*/
|
|
3617
|
+
function toCustomClaimTypeWithIdentity(data) {
|
|
3618
|
+
return data.map(item => {
|
|
3619
|
+
var _a;
|
|
3620
|
+
return ({
|
|
3621
|
+
name: item.name,
|
|
3622
|
+
id: new bignumber_js_1.default(item.id),
|
|
3623
|
+
did: (_a = item.identity) === null || _a === void 0 ? void 0 : _a.did,
|
|
3624
|
+
});
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
exports.toCustomClaimTypeWithIdentity = toCustomClaimTypeWithIdentity;
|
|
3544
3628
|
//# sourceMappingURL=conversion.js.map
|