@polymeshassociation/polymesh-sdk 22.0.0-alpha.2 → 22.0.0-alpha.4
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 +8 -3
- package/api/client/AccountManagement.d.ts +1 -1
- package/api/client/AccountManagement.js +1 -1
- package/api/client/Claims.d.ts +3 -58
- package/api/client/Claims.d.ts.map +1 -1
- package/api/client/Claims.js +13 -121
- package/api/client/Claims.js.map +1 -1
- package/api/client/Network.d.ts +9 -60
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js +9 -141
- package/api/client/Network.js.map +1 -1
- package/api/client/Polymesh.d.ts +0 -9
- package/api/client/Polymesh.d.ts.map +1 -1
- package/api/client/Polymesh.js +2 -26
- package/api/client/Polymesh.js.map +1 -1
- package/api/entities/Account/index.d.ts +2 -24
- package/api/entities/Account/index.d.ts.map +1 -1
- package/api/entities/Account/index.js +10 -91
- package/api/entities/Account/index.js.map +1 -1
- package/api/entities/Account/types.d.ts +1 -1
- package/api/entities/Account/types.d.ts.map +1 -1
- package/api/entities/Asset/index.d.ts +2 -17
- package/api/entities/Asset/index.d.ts.map +1 -1
- package/api/entities/Asset/index.js +11 -93
- package/api/entities/Asset/index.js.map +1 -1
- package/api/entities/Asset/types.d.ts +1 -1
- package/api/entities/Asset/types.d.ts.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.d.ts +1 -8
- package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.js +3 -24
- package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -1
- package/api/entities/DividendDistribution/index.d.ts +2 -18
- package/api/entities/DividendDistribution/index.d.ts.map +1 -1
- package/api/entities/DividendDistribution/index.js +4 -90
- package/api/entities/DividendDistribution/index.js.map +1 -1
- package/api/entities/Identity/AssetPermissions.d.ts +5 -34
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
- package/api/entities/Identity/AssetPermissions.js +18 -106
- package/api/entities/Identity/AssetPermissions.js.map +1 -1
- package/api/entities/Identity/index.d.ts +4 -21
- package/api/entities/Identity/index.d.ts.map +1 -1
- package/api/entities/Identity/index.js +5 -56
- package/api/entities/Identity/index.js.map +1 -1
- package/api/entities/Instruction/index.d.ts +2 -13
- package/api/entities/Instruction/index.d.ts.map +1 -1
- package/api/entities/Instruction/index.js +28 -81
- package/api/entities/Instruction/index.js.map +1 -1
- package/api/entities/NumberedPortfolio.d.ts +1 -8
- package/api/entities/NumberedPortfolio.d.ts.map +1 -1
- package/api/entities/NumberedPortfolio.js +5 -28
- package/api/entities/NumberedPortfolio.js.map +1 -1
- package/api/entities/Offering/index.d.ts +1 -14
- package/api/entities/Offering/index.d.ts.map +1 -1
- package/api/entities/Offering/index.js +3 -48
- package/api/entities/Offering/index.js.map +1 -1
- package/api/entities/Portfolio/index.d.ts +2 -19
- package/api/entities/Portfolio/index.d.ts.map +1 -1
- package/api/entities/Portfolio/index.js +15 -92
- package/api/entities/Portfolio/index.js.map +1 -1
- package/api/entities/Portfolio/types.d.ts +2 -1
- package/api/entities/Portfolio/types.d.ts.map +1 -1
- package/api/entities/Venue/index.js +2 -2
- package/api/entities/Venue/index.js.map +1 -1
- package/api/entities/Venue/types.d.ts +1 -1
- package/api/entities/Venue/types.d.ts.map +1 -1
- package/api/entities/common/namespaces/Authorizations.js +2 -2
- package/api/entities/common/namespaces/Authorizations.js.map +1 -1
- package/api/procedures/modifyClaims.d.ts.map +1 -1
- package/api/procedures/modifyClaims.js +15 -21
- package/api/procedures/modifyClaims.js.map +1 -1
- package/base/Context.d.ts +5 -73
- package/base/Context.d.ts.map +1 -1
- package/base/Context.js +39 -206
- package/base/Context.js.map +1 -1
- package/base/PolymeshTransactionBase.d.ts.map +1 -1
- package/base/PolymeshTransactionBase.js +3 -20
- package/base/PolymeshTransactionBase.js.map +1 -1
- package/middleware/{enumsV2.d.ts → enums.d.ts} +3 -3
- package/middleware/enums.d.ts.map +1 -0
- package/middleware/{enumsV2.js → enums.js} +20 -20
- package/middleware/enums.js.map +1 -0
- package/middleware/queries.d.ts +105 -42
- package/middleware/queries.d.ts.map +1 -1
- package/middleware/queries.js +841 -397
- package/middleware/queries.js.map +1 -1
- package/middleware/types.d.ts +30888 -1459
- package/middleware/types.d.ts.map +1 -1
- package/middleware/types.js +3212 -904
- package/middleware/types.js.map +1 -1
- package/middleware/typesV1.d.ts +27 -0
- package/middleware/typesV1.d.ts.map +1 -0
- package/middleware/typesV1.js +28 -0
- package/middleware/typesV1.js.map +1 -0
- package/npm-package/polymeshassociation-polymesh-sdk-22.0.0-alpha.4.tgz +0 -0
- package/package.json +3 -4
- package/types/index.d.ts +4 -4
- package/types/index.d.ts.map +1 -1
- package/types/index.js +8 -13
- package/types/index.js.map +1 -1
- package/types/internal.d.ts +1 -6
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js.map +1 -1
- package/types/utils/index.d.ts +1 -2
- package/types/utils/index.d.ts.map +1 -1
- package/types/utils/index.js.map +1 -1
- package/utils/conversion.d.ts +9 -25
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +385 -433
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +1 -1
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +2 -2
- package/utils/internal.js.map +1 -1
- package/middleware/enumsV2.d.ts.map +0 -1
- package/middleware/enumsV2.js.map +0 -1
- package/middleware/queriesV2.d.ts +0 -192
- package/middleware/queriesV2.d.ts.map +0 -1
- package/middleware/queriesV2.js +0 -1145
- package/middleware/queriesV2.js.map +0 -1
- package/middleware/typesV2.d.ts +0 -31094
- package/middleware/typesV2.d.ts.map +0 -1
- package/middleware/typesV2.js +0 -3215
- package/middleware/typesV2.js.map +0 -1
- package/npm-package/polymeshassociation-polymesh-sdk-22.0.0-alpha.2.tgz +0 -0
package/utils/conversion.js
CHANGED
|
@@ -18,9 +18,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
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
|
-
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.
|
|
23
|
-
exports.stringToInstructionMemo = exports.scheduleSpecToMeshScheduleSpec = exports.storedScheduleToCheckpointScheduleParams = exports.meshCalendarPeriodToCalendarPeriod = exports.calendarPeriodToMeshCalendarPeriod = exports.middlewareAuthorizationDataToAuthorization = exports.middlewarePermissionsDataToPermissions = exports.datesToScheduleCheckpoints = exports.middlewareAgentGroupDataToPermissionGroup = exports.legToSettlementLeg = 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 =
|
|
21
|
+
exports.assetComplianceResultToCompliance = 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.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.claimCountStatInputToStatUpdates = exports.toExemptKey = exports.complianceConditionsToBtreeSet = exports.sortTransferRestrictionByClaimValue = 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.transferConditionToTransferRestriction = exports.identitiesToBtreeSet = exports.transferRestrictionToPolymeshTransferCondition = exports.claimIssuerToMeshClaimIssuer = exports.claimTypeToMeshClaimType = exports.portfolioMovementToPortfolioFund = 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 = void 0;
|
|
23
|
+
exports.stringToInstructionMemo = exports.scheduleSpecToMeshScheduleSpec = exports.storedScheduleToCheckpointScheduleParams = exports.meshCalendarPeriodToCalendarPeriod = exports.calendarPeriodToMeshCalendarPeriod = exports.middlewareAuthorizationDataToAuthorization = exports.middlewarePermissionsDataToPermissions = exports.datesToScheduleCheckpoints = exports.middlewareAgentGroupDataToPermissionGroup = exports.legToSettlementLeg = 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 = 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
|
|
33
|
-
const
|
|
34
|
-
const
|
|
32
|
+
const enums_1 = require("../middleware/enums");
|
|
33
|
+
const typesV1_1 = require("../middleware/typesV1");
|
|
34
|
+
const types_1 = 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_1.SignerType.Account, accountIdToString(signatory.asAccount));
|
|
193
193
|
}
|
|
194
|
-
return createSignerValue(
|
|
194
|
+
return createSignerValue(types_1.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_1.SignerType.Account, signer.address);
|
|
203
203
|
}
|
|
204
|
-
return createSignerValue(
|
|
204
|
+
return createSignerValue(types_1.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_1.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_1.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_1.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_1.ClaimType.Affiliate,
|
|
303
303
|
affiliate: boolToBoolean(claim.asAffiliate),
|
|
304
304
|
};
|
|
305
305
|
}
|
|
306
306
|
else {
|
|
307
307
|
return {
|
|
308
|
-
type:
|
|
308
|
+
type: types_1.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_1.TxGroup.PortfolioManagement: {
|
|
453
453
|
return [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
454
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
455
|
+
types_1.TxTags.portfolio.MovePortfolioFunds,
|
|
456
|
+
types_1.TxTags.settlement.AddInstruction,
|
|
457
|
+
types_1.TxTags.settlement.AddInstructionWithMemo,
|
|
458
|
+
types_1.TxTags.settlement.AddAndAffirmInstruction,
|
|
459
|
+
types_1.TxTags.settlement.AddAndAffirmInstructionWithMemo,
|
|
460
|
+
types_1.TxTags.settlement.AffirmInstruction,
|
|
461
|
+
types_1.TxTags.settlement.RejectInstruction,
|
|
462
|
+
types_1.TxTags.settlement.CreateVenue,
|
|
463
463
|
];
|
|
464
464
|
}
|
|
465
|
-
case
|
|
465
|
+
case types_1.TxGroup.AssetManagement: {
|
|
466
466
|
return [
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
467
|
+
types_1.TxTags.asset.MakeDivisible,
|
|
468
|
+
types_1.TxTags.asset.RenameAsset,
|
|
469
|
+
types_1.TxTags.asset.SetFundingRound,
|
|
470
|
+
types_1.TxTags.asset.AddDocuments,
|
|
471
|
+
types_1.TxTags.asset.RemoveDocuments,
|
|
472
472
|
];
|
|
473
473
|
}
|
|
474
|
-
case
|
|
474
|
+
case types_1.TxGroup.AdvancedAssetManagement: {
|
|
475
475
|
return [
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
476
|
+
types_1.TxTags.asset.Freeze,
|
|
477
|
+
types_1.TxTags.asset.Unfreeze,
|
|
478
|
+
types_1.TxTags.identity.AddAuthorization,
|
|
479
|
+
types_1.TxTags.identity.RemoveAuthorization,
|
|
480
480
|
];
|
|
481
481
|
}
|
|
482
|
-
case
|
|
482
|
+
case types_1.TxGroup.Distribution: {
|
|
483
483
|
return [
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
484
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
485
|
+
types_1.TxTags.settlement.CreateVenue,
|
|
486
|
+
types_1.TxTags.settlement.AddInstruction,
|
|
487
|
+
types_1.TxTags.settlement.AddInstructionWithMemo,
|
|
488
|
+
types_1.TxTags.settlement.AddAndAffirmInstruction,
|
|
489
|
+
types_1.TxTags.settlement.AddAndAffirmInstructionWithMemo,
|
|
490
490
|
];
|
|
491
491
|
}
|
|
492
|
-
case
|
|
493
|
-
return [
|
|
492
|
+
case types_1.TxGroup.Issuance: {
|
|
493
|
+
return [types_1.TxTags.asset.Issue];
|
|
494
494
|
}
|
|
495
|
-
case
|
|
495
|
+
case types_1.TxGroup.TrustedClaimIssuersManagement: {
|
|
496
496
|
return [
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
types_1.TxTags.complianceManager.AddDefaultTrustedClaimIssuer,
|
|
498
|
+
types_1.TxTags.complianceManager.RemoveDefaultTrustedClaimIssuer,
|
|
499
499
|
];
|
|
500
500
|
}
|
|
501
|
-
case
|
|
502
|
-
return [
|
|
501
|
+
case types_1.TxGroup.ClaimsManagement: {
|
|
502
|
+
return [types_1.TxTags.identity.AddClaim, types_1.TxTags.identity.RevokeClaim];
|
|
503
503
|
}
|
|
504
|
-
case
|
|
504
|
+
case types_1.TxGroup.ComplianceRequirementsManagement: {
|
|
505
505
|
return [
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
506
|
+
types_1.TxTags.complianceManager.AddComplianceRequirement,
|
|
507
|
+
types_1.TxTags.complianceManager.RemoveComplianceRequirement,
|
|
508
|
+
types_1.TxTags.complianceManager.PauseAssetCompliance,
|
|
509
|
+
types_1.TxTags.complianceManager.ResumeAssetCompliance,
|
|
510
|
+
types_1.TxTags.complianceManager.ResetAssetCompliance,
|
|
511
511
|
];
|
|
512
512
|
}
|
|
513
|
-
case
|
|
513
|
+
case types_1.TxGroup.CorporateActionsManagement: {
|
|
514
514
|
return [
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
515
|
+
types_1.TxTags.checkpoint.CreateSchedule,
|
|
516
|
+
types_1.TxTags.checkpoint.RemoveSchedule,
|
|
517
|
+
types_1.TxTags.checkpoint.CreateCheckpoint,
|
|
518
|
+
types_1.TxTags.corporateAction.InitiateCorporateAction,
|
|
519
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
520
|
+
types_1.TxTags.capitalDistribution.Claim,
|
|
521
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
522
522
|
];
|
|
523
523
|
}
|
|
524
|
-
case
|
|
524
|
+
case types_1.TxGroup.StoManagement: {
|
|
525
525
|
return [
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
526
|
+
types_1.TxTags.sto.CreateFundraiser,
|
|
527
|
+
types_1.TxTags.sto.FreezeFundraiser,
|
|
528
|
+
types_1.TxTags.sto.Invest,
|
|
529
|
+
types_1.TxTags.sto.ModifyFundraiserWindow,
|
|
530
|
+
types_1.TxTags.sto.Stop,
|
|
531
|
+
types_1.TxTags.sto.UnfreezeFundraiser,
|
|
532
|
+
types_1.TxTags.identity.AddInvestorUniquenessClaim,
|
|
533
|
+
types_1.TxTags.asset.Issue,
|
|
534
|
+
types_1.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_1.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_1.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_1.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_1.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_1.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_1.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_1.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_1.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_1.PermissionType.Include;
|
|
746
746
|
pallets = permissions.asThese;
|
|
747
747
|
}
|
|
748
748
|
else if (permissions.isExcept) {
|
|
749
|
-
extrinsicType =
|
|
749
|
+
extrinsicType = types_1.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_1.PermissionType.Include;
|
|
798
798
|
assetsPermissions = asset.asThese;
|
|
799
799
|
}
|
|
800
800
|
else if (asset.isExcept) {
|
|
801
|
-
assetsType =
|
|
801
|
+
assetsType = types_1.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_1.PermissionType.Include;
|
|
816
816
|
portfolioIds = portfolio.asThese;
|
|
817
817
|
}
|
|
818
818
|
else if (portfolio.isExcept) {
|
|
819
|
-
portfoliosType =
|
|
819
|
+
portfoliosType = types_1.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_1.PermissionGroupType.Full;
|
|
882
882
|
}
|
|
883
883
|
else if (agentGroup.isExceptMeta) {
|
|
884
|
-
return
|
|
884
|
+
return types_1.PermissionGroupType.ExceptMeta;
|
|
885
885
|
}
|
|
886
886
|
else if (agentGroup.isPolymeshV1CAA) {
|
|
887
|
-
return
|
|
887
|
+
return types_1.PermissionGroupType.PolymeshV1Caa;
|
|
888
888
|
}
|
|
889
889
|
else if (agentGroup.isPolymeshV1PIA) {
|
|
890
|
-
return
|
|
890
|
+
return types_1.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_1.AuthorizationType.AttestPrimaryKeyRotation) {
|
|
904
904
|
value = stringToIdentityId(auth.value.did, context);
|
|
905
905
|
}
|
|
906
|
-
else if (type ===
|
|
906
|
+
else if (type === types_1.AuthorizationType.RotatePrimaryKey) {
|
|
907
907
|
value = null;
|
|
908
908
|
}
|
|
909
|
-
else if (type ===
|
|
909
|
+
else if (type === types_1.AuthorizationType.JoinIdentity) {
|
|
910
910
|
value = permissionsToMeshPermissions(auth.value, context);
|
|
911
911
|
}
|
|
912
|
-
else if (type ===
|
|
912
|
+
else if (type === types_1.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_1.AuthorizationType.TransferAssetOwnership ||
|
|
916
|
+
auth.type === types_1.AuthorizationType.TransferTicker) {
|
|
917
917
|
value = stringToTicker(auth.value, context);
|
|
918
918
|
}
|
|
919
|
-
else if (type ===
|
|
919
|
+
else if (type === types_1.AuthorizationType.RotatePrimaryKeyToSecondary) {
|
|
920
920
|
value = permissionsToMeshPermissions(auth.value, context);
|
|
921
921
|
}
|
|
922
|
-
else if (type ===
|
|
922
|
+
else if (type === types_1.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;
|
|
@@ -952,7 +952,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
952
952
|
(0, internal_3.assertIsPositive)(value);
|
|
953
953
|
if (value.isGreaterThan(constants_1.MAX_BALANCE)) {
|
|
954
954
|
throw new internal_1.PolymeshError({
|
|
955
|
-
code:
|
|
955
|
+
code: types_1.ErrorCode.ValidationError,
|
|
956
956
|
message: 'The value exceeds the maximum possible balance',
|
|
957
957
|
data: {
|
|
958
958
|
currentValue: value,
|
|
@@ -963,7 +963,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
963
963
|
if (divisible) {
|
|
964
964
|
if (value.decimalPlaces() > constants_1.MAX_DECIMALS) {
|
|
965
965
|
throw new internal_1.PolymeshError({
|
|
966
|
-
code:
|
|
966
|
+
code: types_1.ErrorCode.ValidationError,
|
|
967
967
|
message: 'The value has more decimal places than allowed',
|
|
968
968
|
data: {
|
|
969
969
|
currentValue: value,
|
|
@@ -975,7 +975,7 @@ function bigNumberToBalance(value, context, divisible = true) {
|
|
|
975
975
|
else {
|
|
976
976
|
if (value.decimalPlaces()) {
|
|
977
977
|
throw new internal_1.PolymeshError({
|
|
978
|
-
code:
|
|
978
|
+
code: types_1.ErrorCode.ValidationError,
|
|
979
979
|
message: 'The value has decimals but the Asset is indivisible',
|
|
980
980
|
});
|
|
981
981
|
}
|
|
@@ -995,10 +995,10 @@ exports.balanceToBigNumber = balanceToBigNumber;
|
|
|
995
995
|
*/
|
|
996
996
|
function assemblePermissionGroup(permissionGroupIdentifier, ticker, context) {
|
|
997
997
|
switch (permissionGroupIdentifier) {
|
|
998
|
-
case
|
|
999
|
-
case
|
|
1000
|
-
case
|
|
1001
|
-
case
|
|
998
|
+
case types_1.PermissionGroupType.ExceptMeta:
|
|
999
|
+
case types_1.PermissionGroupType.Full:
|
|
1000
|
+
case types_1.PermissionGroupType.PolymeshV1Caa:
|
|
1001
|
+
case types_1.PermissionGroupType.PolymeshV1Pia: {
|
|
1002
1002
|
return new internal_1.KnownPermissionGroup({ type: permissionGroupIdentifier, ticker }, context);
|
|
1003
1003
|
}
|
|
1004
1004
|
default: {
|
|
@@ -1021,7 +1021,7 @@ exports.agentGroupToPermissionGroup = agentGroupToPermissionGroup;
|
|
|
1021
1021
|
function authorizationDataToAuthorization(auth, context) {
|
|
1022
1022
|
if (auth.isAttestPrimaryKeyRotation) {
|
|
1023
1023
|
return {
|
|
1024
|
-
type:
|
|
1024
|
+
type: types_1.AuthorizationType.AttestPrimaryKeyRotation,
|
|
1025
1025
|
value: new internal_1.Identity({
|
|
1026
1026
|
did: identityIdToString(auth.asAttestPrimaryKeyRotation),
|
|
1027
1027
|
}, context),
|
|
@@ -1029,43 +1029,43 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1029
1029
|
}
|
|
1030
1030
|
if (auth.isRotatePrimaryKey) {
|
|
1031
1031
|
return {
|
|
1032
|
-
type:
|
|
1032
|
+
type: types_1.AuthorizationType.RotatePrimaryKey,
|
|
1033
1033
|
};
|
|
1034
1034
|
}
|
|
1035
1035
|
if (auth.isTransferTicker) {
|
|
1036
1036
|
return {
|
|
1037
|
-
type:
|
|
1037
|
+
type: types_1.AuthorizationType.TransferTicker,
|
|
1038
1038
|
value: tickerToString(auth.asTransferTicker),
|
|
1039
1039
|
};
|
|
1040
1040
|
}
|
|
1041
1041
|
if (auth.isAddMultiSigSigner) {
|
|
1042
1042
|
return {
|
|
1043
|
-
type:
|
|
1043
|
+
type: types_1.AuthorizationType.AddMultiSigSigner,
|
|
1044
1044
|
value: accountIdToString(auth.asAddMultiSigSigner),
|
|
1045
1045
|
};
|
|
1046
1046
|
}
|
|
1047
1047
|
if (auth.isTransferAssetOwnership) {
|
|
1048
1048
|
return {
|
|
1049
|
-
type:
|
|
1049
|
+
type: types_1.AuthorizationType.TransferAssetOwnership,
|
|
1050
1050
|
value: tickerToString(auth.asTransferAssetOwnership),
|
|
1051
1051
|
};
|
|
1052
1052
|
}
|
|
1053
1053
|
if (auth.isPortfolioCustody) {
|
|
1054
1054
|
return {
|
|
1055
|
-
type:
|
|
1055
|
+
type: types_1.AuthorizationType.PortfolioCustody,
|
|
1056
1056
|
value: meshPortfolioIdToPortfolio(auth.asPortfolioCustody, context),
|
|
1057
1057
|
};
|
|
1058
1058
|
}
|
|
1059
1059
|
if (auth.isJoinIdentity) {
|
|
1060
1060
|
return {
|
|
1061
|
-
type:
|
|
1061
|
+
type: types_1.AuthorizationType.JoinIdentity,
|
|
1062
1062
|
value: meshPermissionsToPermissions(auth.asJoinIdentity, context),
|
|
1063
1063
|
};
|
|
1064
1064
|
}
|
|
1065
1065
|
if (auth.isAddRelayerPayingKey) {
|
|
1066
1066
|
const [userKey, payingKey, polyxLimit] = auth.asAddRelayerPayingKey;
|
|
1067
1067
|
return {
|
|
1068
|
-
type:
|
|
1068
|
+
type: types_1.AuthorizationType.AddRelayerPayingKey,
|
|
1069
1069
|
value: {
|
|
1070
1070
|
beneficiary: new internal_1.Account({ address: accountIdToString(userKey) }, context),
|
|
1071
1071
|
subsidizer: new internal_1.Account({ address: accountIdToString(payingKey) }, context),
|
|
@@ -1076,18 +1076,18 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1076
1076
|
if (auth.isBecomeAgent) {
|
|
1077
1077
|
const [ticker, agentGroup] = auth.asBecomeAgent;
|
|
1078
1078
|
return {
|
|
1079
|
-
type:
|
|
1079
|
+
type: types_1.AuthorizationType.BecomeAgent,
|
|
1080
1080
|
value: agentGroupToPermissionGroup(agentGroup, tickerToString(ticker), context),
|
|
1081
1081
|
};
|
|
1082
1082
|
}
|
|
1083
1083
|
if (auth.isRotatePrimaryKeyToSecondary) {
|
|
1084
1084
|
return {
|
|
1085
|
-
type:
|
|
1085
|
+
type: types_1.AuthorizationType.RotatePrimaryKeyToSecondary,
|
|
1086
1086
|
value: meshPermissionsToPermissions(auth.asRotatePrimaryKeyToSecondary, context),
|
|
1087
1087
|
};
|
|
1088
1088
|
}
|
|
1089
1089
|
throw new internal_1.PolymeshError({
|
|
1090
|
-
code:
|
|
1090
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
1091
1091
|
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
1092
1092
|
data: {
|
|
1093
1093
|
auth: JSON.stringify(auth, null, 2),
|
|
@@ -1101,7 +1101,7 @@ exports.authorizationDataToAuthorization = authorizationDataToAuthorization;
|
|
|
1101
1101
|
function assertMemoValid(value) {
|
|
1102
1102
|
if (value.length > constants_1.MAX_MEMO_LENGTH) {
|
|
1103
1103
|
throw new internal_1.PolymeshError({
|
|
1104
|
-
code:
|
|
1104
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1105
1105
|
message: 'Max memo length exceeded',
|
|
1106
1106
|
data: {
|
|
1107
1107
|
maxLength: constants_1.MAX_MEMO_LENGTH,
|
|
@@ -1129,71 +1129,71 @@ function u8ToTransferStatus(status) {
|
|
|
1129
1129
|
const code = status.toNumber();
|
|
1130
1130
|
switch (code) {
|
|
1131
1131
|
case 81: {
|
|
1132
|
-
return
|
|
1132
|
+
return types_1.TransferStatus.Success;
|
|
1133
1133
|
}
|
|
1134
1134
|
case 82: {
|
|
1135
|
-
return
|
|
1135
|
+
return types_1.TransferStatus.InsufficientBalance;
|
|
1136
1136
|
}
|
|
1137
1137
|
case 83: {
|
|
1138
|
-
return
|
|
1138
|
+
return types_1.TransferStatus.InsufficientAllowance;
|
|
1139
1139
|
}
|
|
1140
1140
|
case 84: {
|
|
1141
|
-
return
|
|
1141
|
+
return types_1.TransferStatus.TransfersHalted;
|
|
1142
1142
|
}
|
|
1143
1143
|
case 85: {
|
|
1144
|
-
return
|
|
1144
|
+
return types_1.TransferStatus.FundsLocked;
|
|
1145
1145
|
}
|
|
1146
1146
|
case 86: {
|
|
1147
|
-
return
|
|
1147
|
+
return types_1.TransferStatus.InvalidSenderAddress;
|
|
1148
1148
|
}
|
|
1149
1149
|
case 87: {
|
|
1150
|
-
return
|
|
1150
|
+
return types_1.TransferStatus.InvalidReceiverAddress;
|
|
1151
1151
|
}
|
|
1152
1152
|
case 88: {
|
|
1153
|
-
return
|
|
1153
|
+
return types_1.TransferStatus.InvalidOperator;
|
|
1154
1154
|
}
|
|
1155
1155
|
case 160: {
|
|
1156
|
-
return
|
|
1156
|
+
return types_1.TransferStatus.InvalidSenderIdentity;
|
|
1157
1157
|
}
|
|
1158
1158
|
case 161: {
|
|
1159
|
-
return
|
|
1159
|
+
return types_1.TransferStatus.InvalidReceiverIdentity;
|
|
1160
1160
|
}
|
|
1161
1161
|
case 162: {
|
|
1162
|
-
return
|
|
1162
|
+
return types_1.TransferStatus.ComplianceFailure;
|
|
1163
1163
|
}
|
|
1164
1164
|
case 163: {
|
|
1165
|
-
return
|
|
1165
|
+
return types_1.TransferStatus.SmartExtensionFailure;
|
|
1166
1166
|
}
|
|
1167
1167
|
case 164: {
|
|
1168
|
-
return
|
|
1168
|
+
return types_1.TransferStatus.InvalidGranularity;
|
|
1169
1169
|
}
|
|
1170
1170
|
case 165: {
|
|
1171
|
-
return
|
|
1171
|
+
return types_1.TransferStatus.VolumeLimitReached;
|
|
1172
1172
|
}
|
|
1173
1173
|
case 166: {
|
|
1174
|
-
return
|
|
1174
|
+
return types_1.TransferStatus.BlockedTransaction;
|
|
1175
1175
|
}
|
|
1176
1176
|
case 168: {
|
|
1177
|
-
return
|
|
1177
|
+
return types_1.TransferStatus.FundsLimitReached;
|
|
1178
1178
|
}
|
|
1179
1179
|
case 169: {
|
|
1180
|
-
return
|
|
1180
|
+
return types_1.TransferStatus.PortfolioFailure;
|
|
1181
1181
|
}
|
|
1182
1182
|
case 170: {
|
|
1183
|
-
return
|
|
1183
|
+
return types_1.TransferStatus.CustodianError;
|
|
1184
1184
|
}
|
|
1185
1185
|
case 171: {
|
|
1186
|
-
return
|
|
1186
|
+
return types_1.TransferStatus.ScopeClaimMissing;
|
|
1187
1187
|
}
|
|
1188
1188
|
case 172: {
|
|
1189
|
-
return
|
|
1189
|
+
return types_1.TransferStatus.TransferRestrictionFailure;
|
|
1190
1190
|
}
|
|
1191
1191
|
case 80: {
|
|
1192
|
-
return
|
|
1192
|
+
return types_1.TransferStatus.Failure;
|
|
1193
1193
|
}
|
|
1194
1194
|
default: {
|
|
1195
1195
|
throw new internal_1.PolymeshError({
|
|
1196
|
-
code:
|
|
1196
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
1197
1197
|
message: `Unsupported status code "${status.toString()}". Please report this issue to the Polymesh team`,
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
@@ -1212,34 +1212,34 @@ exports.internalAssetTypeToAssetType = internalAssetTypeToAssetType;
|
|
|
1212
1212
|
*/
|
|
1213
1213
|
function assetTypeToKnownOrId(assetType) {
|
|
1214
1214
|
if (assetType.isEquityCommon) {
|
|
1215
|
-
return
|
|
1215
|
+
return types_1.KnownAssetType.EquityCommon;
|
|
1216
1216
|
}
|
|
1217
1217
|
if (assetType.isEquityPreferred) {
|
|
1218
|
-
return
|
|
1218
|
+
return types_1.KnownAssetType.EquityPreferred;
|
|
1219
1219
|
}
|
|
1220
1220
|
if (assetType.isCommodity) {
|
|
1221
|
-
return
|
|
1221
|
+
return types_1.KnownAssetType.Commodity;
|
|
1222
1222
|
}
|
|
1223
1223
|
if (assetType.isFixedIncome) {
|
|
1224
|
-
return
|
|
1224
|
+
return types_1.KnownAssetType.FixedIncome;
|
|
1225
1225
|
}
|
|
1226
1226
|
if (assetType.isReit) {
|
|
1227
|
-
return
|
|
1227
|
+
return types_1.KnownAssetType.Reit;
|
|
1228
1228
|
}
|
|
1229
1229
|
if (assetType.isFund) {
|
|
1230
|
-
return
|
|
1230
|
+
return types_1.KnownAssetType.Fund;
|
|
1231
1231
|
}
|
|
1232
1232
|
if (assetType.isRevenueShareAgreement) {
|
|
1233
|
-
return
|
|
1233
|
+
return types_1.KnownAssetType.RevenueShareAgreement;
|
|
1234
1234
|
}
|
|
1235
1235
|
if (assetType.isStructuredProduct) {
|
|
1236
|
-
return
|
|
1236
|
+
return types_1.KnownAssetType.StructuredProduct;
|
|
1237
1237
|
}
|
|
1238
1238
|
if (assetType.isDerivative) {
|
|
1239
|
-
return
|
|
1239
|
+
return types_1.KnownAssetType.Derivative;
|
|
1240
1240
|
}
|
|
1241
1241
|
if (assetType.isStableCoin) {
|
|
1242
|
-
return
|
|
1242
|
+
return types_1.KnownAssetType.StableCoin;
|
|
1243
1243
|
}
|
|
1244
1244
|
return u32ToBigNumber(assetType.asCustom);
|
|
1245
1245
|
}
|
|
@@ -1260,7 +1260,7 @@ function nameToAssetName(value, context) {
|
|
|
1260
1260
|
const nameMaxLength = u32ToBigNumber(assetNameMaxLength);
|
|
1261
1261
|
if (nameMaxLength.lt(value.length)) {
|
|
1262
1262
|
throw new internal_1.PolymeshError({
|
|
1263
|
-
code:
|
|
1263
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1264
1264
|
message: 'Asset name length exceeded',
|
|
1265
1265
|
data: {
|
|
1266
1266
|
maxLength: nameMaxLength,
|
|
@@ -1278,7 +1278,7 @@ function fundingRoundToAssetFundingRound(value, context) {
|
|
|
1278
1278
|
const nameMaxLength = u32ToBigNumber(fundingRoundNameMaxLength);
|
|
1279
1279
|
if (nameMaxLength.lt(value.length)) {
|
|
1280
1280
|
throw new internal_1.PolymeshError({
|
|
1281
|
-
code:
|
|
1281
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1282
1282
|
message: 'Asset funding round name length exceeded',
|
|
1283
1283
|
data: {
|
|
1284
1284
|
maxLength: nameMaxLength,
|
|
@@ -1398,19 +1398,19 @@ function securityIdentifierToAssetIdentifier(identifier, context) {
|
|
|
1398
1398
|
const { type, value } = identifier;
|
|
1399
1399
|
let error = false;
|
|
1400
1400
|
switch (type) {
|
|
1401
|
-
case
|
|
1401
|
+
case types_1.SecurityIdentifierType.Isin: {
|
|
1402
1402
|
if (!isIsinValid(value)) {
|
|
1403
1403
|
error = true;
|
|
1404
1404
|
}
|
|
1405
1405
|
break;
|
|
1406
1406
|
}
|
|
1407
|
-
case
|
|
1407
|
+
case types_1.SecurityIdentifierType.Lei: {
|
|
1408
1408
|
if (!isLeiValid(value)) {
|
|
1409
1409
|
error = true;
|
|
1410
1410
|
}
|
|
1411
1411
|
break;
|
|
1412
1412
|
}
|
|
1413
|
-
case
|
|
1413
|
+
case types_1.SecurityIdentifierType.Figi: {
|
|
1414
1414
|
if (!isFigiValid(value)) {
|
|
1415
1415
|
error = true;
|
|
1416
1416
|
}
|
|
@@ -1425,7 +1425,7 @@ function securityIdentifierToAssetIdentifier(identifier, context) {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
if (error) {
|
|
1427
1427
|
throw new internal_1.PolymeshError({
|
|
1428
|
-
code:
|
|
1428
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1429
1429
|
message: `Invalid security identifier ${value} of type ${type}`,
|
|
1430
1430
|
});
|
|
1431
1431
|
}
|
|
@@ -1438,30 +1438,30 @@ exports.securityIdentifierToAssetIdentifier = securityIdentifierToAssetIdentifie
|
|
|
1438
1438
|
function assetIdentifierToSecurityIdentifier(identifier) {
|
|
1439
1439
|
if (identifier.isCusip) {
|
|
1440
1440
|
return {
|
|
1441
|
-
type:
|
|
1441
|
+
type: types_1.SecurityIdentifierType.Cusip,
|
|
1442
1442
|
value: (0, util_1.u8aToString)(identifier.asCusip),
|
|
1443
1443
|
};
|
|
1444
1444
|
}
|
|
1445
1445
|
if (identifier.isIsin) {
|
|
1446
1446
|
return {
|
|
1447
|
-
type:
|
|
1447
|
+
type: types_1.SecurityIdentifierType.Isin,
|
|
1448
1448
|
value: (0, util_1.u8aToString)(identifier.asIsin),
|
|
1449
1449
|
};
|
|
1450
1450
|
}
|
|
1451
1451
|
if (identifier.isCins) {
|
|
1452
1452
|
return {
|
|
1453
|
-
type:
|
|
1453
|
+
type: types_1.SecurityIdentifierType.Cins,
|
|
1454
1454
|
value: (0, util_1.u8aToString)(identifier.asCins),
|
|
1455
1455
|
};
|
|
1456
1456
|
}
|
|
1457
1457
|
if (identifier.isFigi) {
|
|
1458
1458
|
return {
|
|
1459
|
-
type:
|
|
1459
|
+
type: types_1.SecurityIdentifierType.Figi,
|
|
1460
1460
|
value: (0, util_1.u8aToString)(identifier.asFigi),
|
|
1461
1461
|
};
|
|
1462
1462
|
}
|
|
1463
1463
|
return {
|
|
1464
|
-
type:
|
|
1464
|
+
type: types_1.SecurityIdentifierType.Lei,
|
|
1465
1465
|
value: (0, util_1.u8aToString)(identifier.asLei),
|
|
1466
1466
|
};
|
|
1467
1467
|
}
|
|
@@ -1475,7 +1475,7 @@ function stringToDocumentHash(docHash, context) {
|
|
|
1475
1475
|
}
|
|
1476
1476
|
if (!(0, util_1.isHex)(docHash, -1, true)) {
|
|
1477
1477
|
throw new internal_1.PolymeshError({
|
|
1478
|
-
code:
|
|
1478
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1479
1479
|
message: 'Document hash must be a hexadecimal string prefixed by 0x',
|
|
1480
1480
|
});
|
|
1481
1481
|
}
|
|
@@ -1488,7 +1488,7 @@ function stringToDocumentHash(docHash, context) {
|
|
|
1488
1488
|
const type = hashTypes.find(({ maxLength: max }) => length <= max);
|
|
1489
1489
|
if (!type) {
|
|
1490
1490
|
throw new internal_1.PolymeshError({
|
|
1491
|
-
code:
|
|
1491
|
+
code: types_1.ErrorCode.ValidationError,
|
|
1492
1492
|
message: 'Document hash exceeds max length',
|
|
1493
1493
|
});
|
|
1494
1494
|
}
|
|
@@ -1581,7 +1581,7 @@ exports.cddStatusToBoolean = cddStatusToBoolean;
|
|
|
1581
1581
|
function canTransferResultToTransferStatus(canTransferResult) {
|
|
1582
1582
|
if (canTransferResult.isErr) {
|
|
1583
1583
|
throw new internal_1.PolymeshError({
|
|
1584
|
-
code:
|
|
1584
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
1585
1585
|
message: `Error while checking transfer validity: ${bytesToString(canTransferResult.asErr)}`,
|
|
1586
1586
|
});
|
|
1587
1587
|
}
|
|
@@ -1595,10 +1595,10 @@ function scopeToMeshScope(scope, context) {
|
|
|
1595
1595
|
const { type, value } = scope;
|
|
1596
1596
|
let scopeValue;
|
|
1597
1597
|
switch (type) {
|
|
1598
|
-
case
|
|
1598
|
+
case types_1.ScopeType.Ticker:
|
|
1599
1599
|
scopeValue = stringToTicker(value, context);
|
|
1600
1600
|
break;
|
|
1601
|
-
case
|
|
1601
|
+
case types_1.ScopeType.Identity:
|
|
1602
1602
|
scopeValue = stringToIdentityId(value, context);
|
|
1603
1603
|
break;
|
|
1604
1604
|
default:
|
|
@@ -1616,18 +1616,18 @@ exports.scopeToMeshScope = scopeToMeshScope;
|
|
|
1616
1616
|
function meshScopeToScope(scope) {
|
|
1617
1617
|
if (scope.isTicker) {
|
|
1618
1618
|
return {
|
|
1619
|
-
type:
|
|
1619
|
+
type: types_1.ScopeType.Ticker,
|
|
1620
1620
|
value: tickerToString(scope.asTicker),
|
|
1621
1621
|
};
|
|
1622
1622
|
}
|
|
1623
1623
|
if (scope.isIdentity) {
|
|
1624
1624
|
return {
|
|
1625
|
-
type:
|
|
1625
|
+
type: types_1.ScopeType.Identity,
|
|
1626
1626
|
value: identityIdToString(scope.asIdentity),
|
|
1627
1627
|
};
|
|
1628
1628
|
}
|
|
1629
1629
|
return {
|
|
1630
|
-
type:
|
|
1630
|
+
type: types_1.ScopeType.Custom,
|
|
1631
1631
|
value: (0, util_1.u8aToString)(scope.asCustom),
|
|
1632
1632
|
};
|
|
1633
1633
|
}
|
|
@@ -1652,11 +1652,11 @@ exports.cddIdToString = cddIdToString;
|
|
|
1652
1652
|
function claimToMeshClaim(claim, context) {
|
|
1653
1653
|
let value;
|
|
1654
1654
|
switch (claim.type) {
|
|
1655
|
-
case
|
|
1655
|
+
case types_1.ClaimType.CustomerDueDiligence: {
|
|
1656
1656
|
value = stringToCddId(claim.id, context);
|
|
1657
1657
|
break;
|
|
1658
1658
|
}
|
|
1659
|
-
case
|
|
1659
|
+
case types_1.ClaimType.Jurisdiction: {
|
|
1660
1660
|
const { code, scope } = claim;
|
|
1661
1661
|
value = (0, utils_3.tuple)(code, scopeToMeshScope(scope, context));
|
|
1662
1662
|
break;
|
|
@@ -1674,13 +1674,19 @@ exports.claimToMeshClaim = claimToMeshClaim;
|
|
|
1674
1674
|
function middlewareScopeToScope(scope) {
|
|
1675
1675
|
const { type, value } = scope;
|
|
1676
1676
|
switch (type) {
|
|
1677
|
-
case
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
case
|
|
1681
|
-
|
|
1682
|
-
return { type: types_2.ScopeType[scope.type], value };
|
|
1677
|
+
case typesV1_1.ClaimScopeTypeEnum.Ticker:
|
|
1678
|
+
return { type: types_1.ScopeType.Ticker, value: (0, internal_3.removePadding)(value) };
|
|
1679
|
+
case typesV1_1.ClaimScopeTypeEnum.Identity:
|
|
1680
|
+
case typesV1_1.ClaimScopeTypeEnum.Custom:
|
|
1681
|
+
return { type: scope.type, value };
|
|
1683
1682
|
}
|
|
1683
|
+
throw new internal_1.PolymeshError({
|
|
1684
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
1685
|
+
message: 'Unsupported Scope Type. Please contact the Polymesh team',
|
|
1686
|
+
data: {
|
|
1687
|
+
scope,
|
|
1688
|
+
},
|
|
1689
|
+
});
|
|
1684
1690
|
}
|
|
1685
1691
|
exports.middlewareScopeToScope = middlewareScopeToScope;
|
|
1686
1692
|
/**
|
|
@@ -1689,36 +1695,21 @@ exports.middlewareScopeToScope = middlewareScopeToScope;
|
|
|
1689
1695
|
function scopeToMiddlewareScope(scope, padTicker = true) {
|
|
1690
1696
|
const { type, value } = scope;
|
|
1691
1697
|
switch (type) {
|
|
1692
|
-
case
|
|
1698
|
+
case types_1.ScopeType.Ticker:
|
|
1693
1699
|
return {
|
|
1694
|
-
type:
|
|
1700
|
+
type: typesV1_1.ClaimScopeTypeEnum.Ticker,
|
|
1695
1701
|
value: padTicker ? (0, lodash_1.padEnd)(value, 12, '\0') : value,
|
|
1696
1702
|
};
|
|
1697
|
-
case
|
|
1698
|
-
case
|
|
1699
|
-
return { type:
|
|
1703
|
+
case types_1.ScopeType.Identity:
|
|
1704
|
+
case types_1.ScopeType.Custom:
|
|
1705
|
+
return { type: typesV1_1.ClaimScopeTypeEnum[scope.type], value };
|
|
1700
1706
|
}
|
|
1701
1707
|
}
|
|
1702
1708
|
exports.scopeToMiddlewareScope = scopeToMiddlewareScope;
|
|
1703
1709
|
/**
|
|
1704
1710
|
* @hidden
|
|
1705
1711
|
*/
|
|
1706
|
-
function
|
|
1707
|
-
const { block_id: blockNumber, block, event_idx: eventIndex } = event;
|
|
1708
|
-
return {
|
|
1709
|
-
blockNumber: new bignumber_js_1.default(blockNumber),
|
|
1710
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
1711
|
-
blockDate: new Date(block.datetime),
|
|
1712
|
-
blockHash: block.hash,
|
|
1713
|
-
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
1714
|
-
eventIndex: new bignumber_js_1.default(eventIndex),
|
|
1715
|
-
};
|
|
1716
|
-
}
|
|
1717
|
-
exports.middlewareEventToEventIdentifier = middlewareEventToEventIdentifier;
|
|
1718
|
-
/**
|
|
1719
|
-
* @hidden
|
|
1720
|
-
*/
|
|
1721
|
-
function middlewareV2EventDetailsToEventIdentifier(block, eventIdx = 0) {
|
|
1712
|
+
function middlewareEventDetailsToEventIdentifier(block, eventIdx = 0) {
|
|
1722
1713
|
const { blockId, datetime, hash } = block;
|
|
1723
1714
|
return {
|
|
1724
1715
|
blockNumber: new bignumber_js_1.default(blockId),
|
|
@@ -1727,7 +1718,7 @@ function middlewareV2EventDetailsToEventIdentifier(block, eventIdx = 0) {
|
|
|
1727
1718
|
eventIndex: new bignumber_js_1.default(eventIdx),
|
|
1728
1719
|
};
|
|
1729
1720
|
}
|
|
1730
|
-
exports.
|
|
1721
|
+
exports.middlewareEventDetailsToEventIdentifier = middlewareEventDetailsToEventIdentifier;
|
|
1731
1722
|
/**
|
|
1732
1723
|
* @hidden
|
|
1733
1724
|
*/
|
|
@@ -1735,55 +1726,55 @@ function meshClaimToClaim(claim) {
|
|
|
1735
1726
|
if (claim.isJurisdiction) {
|
|
1736
1727
|
const [code, scope] = claim.asJurisdiction;
|
|
1737
1728
|
return {
|
|
1738
|
-
type:
|
|
1729
|
+
type: types_1.ClaimType.Jurisdiction,
|
|
1739
1730
|
code: (0, utils_2.meshCountryCodeToCountryCode)(code),
|
|
1740
1731
|
scope: meshScopeToScope(scope),
|
|
1741
1732
|
};
|
|
1742
1733
|
}
|
|
1743
1734
|
if (claim.isAccredited) {
|
|
1744
1735
|
return {
|
|
1745
|
-
type:
|
|
1736
|
+
type: types_1.ClaimType.Accredited,
|
|
1746
1737
|
scope: meshScopeToScope(claim.asAccredited),
|
|
1747
1738
|
};
|
|
1748
1739
|
}
|
|
1749
1740
|
if (claim.isAffiliate) {
|
|
1750
1741
|
return {
|
|
1751
|
-
type:
|
|
1742
|
+
type: types_1.ClaimType.Affiliate,
|
|
1752
1743
|
scope: meshScopeToScope(claim.asAffiliate),
|
|
1753
1744
|
};
|
|
1754
1745
|
}
|
|
1755
1746
|
if (claim.isBuyLockup) {
|
|
1756
1747
|
return {
|
|
1757
|
-
type:
|
|
1748
|
+
type: types_1.ClaimType.BuyLockup,
|
|
1758
1749
|
scope: meshScopeToScope(claim.asBuyLockup),
|
|
1759
1750
|
};
|
|
1760
1751
|
}
|
|
1761
1752
|
if (claim.isSellLockup) {
|
|
1762
1753
|
return {
|
|
1763
|
-
type:
|
|
1754
|
+
type: types_1.ClaimType.SellLockup,
|
|
1764
1755
|
scope: meshScopeToScope(claim.asSellLockup),
|
|
1765
1756
|
};
|
|
1766
1757
|
}
|
|
1767
1758
|
if (claim.isCustomerDueDiligence) {
|
|
1768
1759
|
return {
|
|
1769
|
-
type:
|
|
1760
|
+
type: types_1.ClaimType.CustomerDueDiligence,
|
|
1770
1761
|
id: cddIdToString(claim.asCustomerDueDiligence),
|
|
1771
1762
|
};
|
|
1772
1763
|
}
|
|
1773
1764
|
if (claim.isKnowYourCustomer) {
|
|
1774
1765
|
return {
|
|
1775
|
-
type:
|
|
1766
|
+
type: types_1.ClaimType.KnowYourCustomer,
|
|
1776
1767
|
scope: meshScopeToScope(claim.asKnowYourCustomer),
|
|
1777
1768
|
};
|
|
1778
1769
|
}
|
|
1779
1770
|
if (claim.isExempted) {
|
|
1780
1771
|
return {
|
|
1781
|
-
type:
|
|
1772
|
+
type: types_1.ClaimType.Exempted,
|
|
1782
1773
|
scope: meshScopeToScope(claim.asExempted),
|
|
1783
1774
|
};
|
|
1784
1775
|
}
|
|
1785
1776
|
return {
|
|
1786
|
-
type:
|
|
1777
|
+
type: types_1.ClaimType.Blocked,
|
|
1787
1778
|
scope: meshScopeToScope(claim.asBlocked),
|
|
1788
1779
|
};
|
|
1789
1780
|
}
|
|
@@ -1794,14 +1785,14 @@ exports.meshClaimToClaim = meshClaimToClaim;
|
|
|
1794
1785
|
function statsClaimToStatClaimInputType(claim) {
|
|
1795
1786
|
if (claim.isJurisdiction) {
|
|
1796
1787
|
return {
|
|
1797
|
-
type:
|
|
1788
|
+
type: types_1.ClaimType.Jurisdiction,
|
|
1798
1789
|
};
|
|
1799
1790
|
}
|
|
1800
1791
|
else if (claim.isAccredited) {
|
|
1801
|
-
return { type:
|
|
1792
|
+
return { type: types_1.ClaimType.Accredited };
|
|
1802
1793
|
}
|
|
1803
1794
|
else {
|
|
1804
|
-
return { type:
|
|
1795
|
+
return { type: types_1.ClaimType.Affiliate };
|
|
1805
1796
|
}
|
|
1806
1797
|
}
|
|
1807
1798
|
exports.statsClaimToStatClaimInputType = statsClaimToStatClaimInputType;
|
|
@@ -1819,30 +1810,30 @@ exports.stringToTargetIdentity = stringToTargetIdentity;
|
|
|
1819
1810
|
*/
|
|
1820
1811
|
function meshClaimTypeToClaimType(claimType) {
|
|
1821
1812
|
if (claimType.isJurisdiction) {
|
|
1822
|
-
return
|
|
1813
|
+
return types_1.ClaimType.Jurisdiction;
|
|
1823
1814
|
}
|
|
1824
1815
|
if (claimType.isAccredited) {
|
|
1825
|
-
return
|
|
1816
|
+
return types_1.ClaimType.Accredited;
|
|
1826
1817
|
}
|
|
1827
1818
|
if (claimType.isAffiliate) {
|
|
1828
|
-
return
|
|
1819
|
+
return types_1.ClaimType.Affiliate;
|
|
1829
1820
|
}
|
|
1830
1821
|
if (claimType.isBuyLockup) {
|
|
1831
|
-
return
|
|
1822
|
+
return types_1.ClaimType.BuyLockup;
|
|
1832
1823
|
}
|
|
1833
1824
|
if (claimType.isSellLockup) {
|
|
1834
|
-
return
|
|
1825
|
+
return types_1.ClaimType.SellLockup;
|
|
1835
1826
|
}
|
|
1836
1827
|
if (claimType.isCustomerDueDiligence) {
|
|
1837
|
-
return
|
|
1828
|
+
return types_1.ClaimType.CustomerDueDiligence;
|
|
1838
1829
|
}
|
|
1839
1830
|
if (claimType.isKnowYourCustomer) {
|
|
1840
|
-
return
|
|
1831
|
+
return types_1.ClaimType.KnowYourCustomer;
|
|
1841
1832
|
}
|
|
1842
1833
|
if (claimType.isExempted) {
|
|
1843
|
-
return
|
|
1834
|
+
return types_1.ClaimType.Exempted;
|
|
1844
1835
|
}
|
|
1845
|
-
return
|
|
1836
|
+
return types_1.ClaimType.Blocked;
|
|
1846
1837
|
}
|
|
1847
1838
|
exports.meshClaimTypeToClaimType = meshClaimTypeToClaimType;
|
|
1848
1839
|
/**
|
|
@@ -1903,7 +1894,7 @@ function requirementToComplianceRequirement(requirement, context) {
|
|
|
1903
1894
|
}
|
|
1904
1895
|
else {
|
|
1905
1896
|
// IsExternalAgent does not exist as a condition type in Polymesh, it's SDK sugar
|
|
1906
|
-
type =
|
|
1897
|
+
type = types_1.ConditionType.IsIdentity;
|
|
1907
1898
|
conditionContent = stringToTargetIdentity(null, context);
|
|
1908
1899
|
}
|
|
1909
1900
|
const { target, trustedClaimIssuers = [] } = condition;
|
|
@@ -1913,10 +1904,10 @@ function requirementToComplianceRequirement(requirement, context) {
|
|
|
1913
1904
|
},
|
|
1914
1905
|
issuers: trustedClaimIssuers.map(issuer => trustedClaimIssuerToTrustedIssuer(issuer, context)),
|
|
1915
1906
|
});
|
|
1916
|
-
if ([
|
|
1907
|
+
if ([types_1.ConditionTarget.Both, types_1.ConditionTarget.Receiver].includes(target)) {
|
|
1917
1908
|
receiverConditions.push(meshCondition);
|
|
1918
1909
|
}
|
|
1919
|
-
if ([
|
|
1910
|
+
if ([types_1.ConditionTarget.Both, types_1.ConditionTarget.Sender].includes(target)) {
|
|
1920
1911
|
senderConditions.push(meshCondition);
|
|
1921
1912
|
}
|
|
1922
1913
|
});
|
|
@@ -1933,19 +1924,19 @@ exports.requirementToComplianceRequirement = requirementToComplianceRequirement;
|
|
|
1933
1924
|
function meshConditionTypeToCondition(meshConditionType, context) {
|
|
1934
1925
|
if (meshConditionType.isIsPresent) {
|
|
1935
1926
|
return {
|
|
1936
|
-
type:
|
|
1927
|
+
type: types_1.ConditionType.IsPresent,
|
|
1937
1928
|
claim: meshClaimToClaim(meshConditionType.asIsPresent),
|
|
1938
1929
|
};
|
|
1939
1930
|
}
|
|
1940
1931
|
if (meshConditionType.isIsAbsent) {
|
|
1941
1932
|
return {
|
|
1942
|
-
type:
|
|
1933
|
+
type: types_1.ConditionType.IsAbsent,
|
|
1943
1934
|
claim: meshClaimToClaim(meshConditionType.asIsAbsent),
|
|
1944
1935
|
};
|
|
1945
1936
|
}
|
|
1946
1937
|
if (meshConditionType.isIsAnyOf) {
|
|
1947
1938
|
return {
|
|
1948
|
-
type:
|
|
1939
|
+
type: types_1.ConditionType.IsAnyOf,
|
|
1949
1940
|
claims: meshConditionType.asIsAnyOf.map(claim => meshClaimToClaim(claim)),
|
|
1950
1941
|
};
|
|
1951
1942
|
}
|
|
@@ -1953,16 +1944,16 @@ function meshConditionTypeToCondition(meshConditionType, context) {
|
|
|
1953
1944
|
const target = meshConditionType.asIsIdentity;
|
|
1954
1945
|
if (target.isExternalAgent) {
|
|
1955
1946
|
return {
|
|
1956
|
-
type:
|
|
1947
|
+
type: types_1.ConditionType.IsExternalAgent,
|
|
1957
1948
|
};
|
|
1958
1949
|
}
|
|
1959
1950
|
return {
|
|
1960
|
-
type:
|
|
1951
|
+
type: types_1.ConditionType.IsIdentity,
|
|
1961
1952
|
identity: new internal_1.Identity({ did: identityIdToString(target.asSpecific) }, context),
|
|
1962
1953
|
};
|
|
1963
1954
|
}
|
|
1964
1955
|
return {
|
|
1965
|
-
type:
|
|
1956
|
+
type: types_1.ConditionType.IsNoneOf,
|
|
1966
1957
|
claims: meshConditionType.asIsNoneOf.map(claim => meshClaimToClaim(claim)),
|
|
1967
1958
|
};
|
|
1968
1959
|
}
|
|
@@ -1975,7 +1966,7 @@ function complianceRequirementResultToRequirementCompliance(complianceRequiremen
|
|
|
1975
1966
|
const conditionCompliancesAreEqual = ({ condition: aCondition, complies: aComplies }, { condition: bCondition, complies: bComplies }) => (0, internal_3.conditionsAreEqual)(aCondition, bCondition) && aComplies === bComplies;
|
|
1976
1967
|
complianceRequirement.senderConditions.forEach(({ condition: { conditionType, issuers }, result }) => {
|
|
1977
1968
|
const newCondition = {
|
|
1978
|
-
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
1969
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_1.ConditionTarget.Sender, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1979
1970
|
complies: boolToBoolean(result),
|
|
1980
1971
|
};
|
|
1981
1972
|
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
@@ -1985,12 +1976,12 @@ function complianceRequirementResultToRequirementCompliance(complianceRequiremen
|
|
|
1985
1976
|
});
|
|
1986
1977
|
complianceRequirement.receiverConditions.forEach(({ condition: { conditionType, issuers }, result }) => {
|
|
1987
1978
|
const newCondition = {
|
|
1988
|
-
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
1979
|
+
condition: Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_1.ConditionTarget.Receiver, trustedClaimIssuers: issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context)) }),
|
|
1989
1980
|
complies: boolToBoolean(result),
|
|
1990
1981
|
};
|
|
1991
1982
|
const existingCondition = conditions.find(condition => conditionCompliancesAreEqual(condition, newCondition));
|
|
1992
|
-
if (existingCondition && existingCondition.condition.target ===
|
|
1993
|
-
existingCondition.condition.target =
|
|
1983
|
+
if (existingCondition && existingCondition.condition.target === types_1.ConditionTarget.Sender) {
|
|
1984
|
+
existingCondition.condition.target = types_1.ConditionTarget.Both;
|
|
1994
1985
|
}
|
|
1995
1986
|
else {
|
|
1996
1987
|
conditions.push(newCondition);
|
|
@@ -2009,7 +2000,7 @@ exports.complianceRequirementResultToRequirementCompliance = complianceRequireme
|
|
|
2009
2000
|
function complianceRequirementToRequirement(complianceRequirement, context) {
|
|
2010
2001
|
const conditions = [];
|
|
2011
2002
|
complianceRequirement.senderConditions.forEach(({ conditionType, issuers }) => {
|
|
2012
|
-
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
2003
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_1.ConditionTarget.Sender });
|
|
2013
2004
|
if (issuers.length) {
|
|
2014
2005
|
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
2015
2006
|
}
|
|
@@ -2019,13 +2010,13 @@ function complianceRequirementToRequirement(complianceRequirement, context) {
|
|
|
2019
2010
|
}
|
|
2020
2011
|
});
|
|
2021
2012
|
complianceRequirement.receiverConditions.forEach(({ conditionType, issuers }) => {
|
|
2022
|
-
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target:
|
|
2013
|
+
const newCondition = Object.assign(Object.assign({}, meshConditionTypeToCondition(conditionType, context)), { target: types_1.ConditionTarget.Receiver });
|
|
2023
2014
|
if (issuers.length) {
|
|
2024
2015
|
newCondition.trustedClaimIssuers = issuers.map(trustedIssuer => trustedIssuerToTrustedClaimIssuer(trustedIssuer, context));
|
|
2025
2016
|
}
|
|
2026
2017
|
const existingCondition = conditions.find(condition => (0, internal_3.conditionsAreEqual)(condition, newCondition));
|
|
2027
|
-
if (existingCondition && existingCondition.target ===
|
|
2028
|
-
existingCondition.target =
|
|
2018
|
+
if (existingCondition && existingCondition.target === types_1.ConditionTarget.Sender) {
|
|
2019
|
+
existingCondition.target = types_1.ConditionTarget.Both;
|
|
2029
2020
|
}
|
|
2030
2021
|
else {
|
|
2031
2022
|
conditions.push(newCondition);
|
|
@@ -2042,49 +2033,38 @@ exports.complianceRequirementToRequirement = complianceRequirementToRequirement;
|
|
|
2042
2033
|
*/
|
|
2043
2034
|
function txTagToProtocolOp(tag, context) {
|
|
2044
2035
|
const protocolOpTags = [
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2036
|
+
types_1.TxTags.asset.RegisterTicker,
|
|
2037
|
+
types_1.TxTags.asset.Issue,
|
|
2038
|
+
types_1.TxTags.asset.AddDocuments,
|
|
2039
|
+
types_1.TxTags.asset.CreateAsset,
|
|
2040
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
2041
|
+
types_1.TxTags.checkpoint.CreateSchedule,
|
|
2042
|
+
types_1.TxTags.complianceManager.AddComplianceRequirement,
|
|
2043
|
+
types_1.TxTags.identity.CddRegisterDid,
|
|
2044
|
+
types_1.TxTags.identity.AddClaim,
|
|
2045
|
+
types_1.TxTags.identity.AddSecondaryKeysWithAuthorization,
|
|
2046
|
+
types_1.TxTags.pips.Propose,
|
|
2047
|
+
types_1.TxTags.corporateBallot.AttachBallot,
|
|
2048
|
+
types_1.TxTags.capitalDistribution.Distribute,
|
|
2058
2049
|
];
|
|
2059
2050
|
const [moduleName, extrinsicName] = tag.split('.');
|
|
2060
2051
|
const value = `${(0, util_1.stringUpperFirst)(moduleName)}${(0, util_1.stringUpperFirst)(extrinsicName)}`;
|
|
2061
2052
|
if (!(0, lodash_1.includes)(protocolOpTags, tag)) {
|
|
2062
2053
|
throw new internal_1.PolymeshError({
|
|
2063
|
-
code:
|
|
2054
|
+
code: types_1.ErrorCode.ValidationError,
|
|
2064
2055
|
message: `${value} does not match any PolymeshCommonUtilitiesProtocolFeeProtocolOp`,
|
|
2065
2056
|
});
|
|
2066
2057
|
}
|
|
2067
2058
|
return context.createType('PolymeshCommonUtilitiesProtocolFeeProtocolOp', value);
|
|
2068
2059
|
}
|
|
2069
2060
|
exports.txTagToProtocolOp = txTagToProtocolOp;
|
|
2070
|
-
/**
|
|
2071
|
-
* @hidden
|
|
2072
|
-
*/
|
|
2073
|
-
function txTagToExtrinsicIdentifier(tag) {
|
|
2074
|
-
const [moduleName, extrinsicName] = tag.split('.');
|
|
2075
|
-
return {
|
|
2076
|
-
moduleId: moduleName.toLowerCase(),
|
|
2077
|
-
callId: (0, lodash_1.snakeCase)(extrinsicName),
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
exports.txTagToExtrinsicIdentifier = txTagToExtrinsicIdentifier;
|
|
2081
2061
|
/**
|
|
2082
2062
|
* @hidden
|
|
2083
2063
|
*/
|
|
2084
2064
|
function extrinsicIdentifierToTxTag(extrinsicIdentifier) {
|
|
2085
2065
|
const { moduleId, callId } = extrinsicIdentifier;
|
|
2086
2066
|
let moduleName;
|
|
2087
|
-
for (const txTagItem in
|
|
2067
|
+
for (const txTagItem in types_1.TxTags) {
|
|
2088
2068
|
if (txTagItem.toLowerCase() === moduleId) {
|
|
2089
2069
|
moduleName = txTagItem;
|
|
2090
2070
|
}
|
|
@@ -2095,14 +2075,14 @@ exports.extrinsicIdentifierToTxTag = extrinsicIdentifierToTxTag;
|
|
|
2095
2075
|
/**
|
|
2096
2076
|
* @hidden
|
|
2097
2077
|
*/
|
|
2098
|
-
function
|
|
2078
|
+
function txTagToExtrinsicIdentifier(tag) {
|
|
2099
2079
|
const [moduleName, extrinsicName] = tag.split('.');
|
|
2100
2080
|
return {
|
|
2101
2081
|
moduleId: moduleName.toLowerCase(),
|
|
2102
2082
|
callId: (0, lodash_1.snakeCase)(extrinsicName),
|
|
2103
2083
|
};
|
|
2104
2084
|
}
|
|
2105
|
-
exports.
|
|
2085
|
+
exports.txTagToExtrinsicIdentifier = txTagToExtrinsicIdentifier;
|
|
2106
2086
|
/**
|
|
2107
2087
|
* @hidden
|
|
2108
2088
|
*/
|
|
@@ -2183,15 +2163,15 @@ exports.secondaryAccountToMeshSecondaryKey = secondaryAccountToMeshSecondaryKey;
|
|
|
2183
2163
|
*/
|
|
2184
2164
|
function meshVenueTypeToVenueType(type) {
|
|
2185
2165
|
if (type.isOther) {
|
|
2186
|
-
return
|
|
2166
|
+
return types_1.VenueType.Other;
|
|
2187
2167
|
}
|
|
2188
2168
|
if (type.isDistribution) {
|
|
2189
|
-
return
|
|
2169
|
+
return types_1.VenueType.Distribution;
|
|
2190
2170
|
}
|
|
2191
2171
|
if (type.isSto) {
|
|
2192
|
-
return
|
|
2172
|
+
return types_1.VenueType.Sto;
|
|
2193
2173
|
}
|
|
2194
|
-
return
|
|
2174
|
+
return types_1.VenueType.Exchange;
|
|
2195
2175
|
}
|
|
2196
2176
|
exports.meshVenueTypeToVenueType = meshVenueTypeToVenueType;
|
|
2197
2177
|
/**
|
|
@@ -2230,12 +2210,12 @@ exports.meshInstructionStatusToInstructionStatus = meshInstructionStatusToInstru
|
|
|
2230
2210
|
*/
|
|
2231
2211
|
function meshAffirmationStatusToAffirmationStatus(status) {
|
|
2232
2212
|
if (status.isUnknown) {
|
|
2233
|
-
return
|
|
2213
|
+
return types_1.AffirmationStatus.Unknown;
|
|
2234
2214
|
}
|
|
2235
2215
|
if (status.isPending) {
|
|
2236
|
-
return
|
|
2216
|
+
return types_1.AffirmationStatus.Pending;
|
|
2237
2217
|
}
|
|
2238
|
-
return
|
|
2218
|
+
return types_1.AffirmationStatus.Affirmed;
|
|
2239
2219
|
}
|
|
2240
2220
|
exports.meshAffirmationStatusToAffirmationStatus = meshAffirmationStatusToAffirmationStatus;
|
|
2241
2221
|
/**
|
|
@@ -2243,15 +2223,15 @@ exports.meshAffirmationStatusToAffirmationStatus = meshAffirmationStatusToAffirm
|
|
|
2243
2223
|
*/
|
|
2244
2224
|
function meshSettlementTypeToEndCondition(type) {
|
|
2245
2225
|
if (type.isSettleOnBlock) {
|
|
2246
|
-
return { type:
|
|
2226
|
+
return { type: types_1.InstructionType.SettleOnBlock, endBlock: u32ToBigNumber(type.asSettleOnBlock) };
|
|
2247
2227
|
}
|
|
2248
2228
|
if (type.isSettleManual) {
|
|
2249
2229
|
return {
|
|
2250
|
-
type:
|
|
2230
|
+
type: types_1.InstructionType.SettleManual,
|
|
2251
2231
|
endAfterBlock: u32ToBigNumber(type.asSettleManual),
|
|
2252
2232
|
};
|
|
2253
2233
|
}
|
|
2254
|
-
return { type:
|
|
2234
|
+
return { type: types_1.InstructionType.SettleOnAffirmation };
|
|
2255
2235
|
}
|
|
2256
2236
|
exports.meshSettlementTypeToEndCondition = meshSettlementTypeToEndCondition;
|
|
2257
2237
|
/**
|
|
@@ -2261,16 +2241,16 @@ function endConditionToSettlementType(endCondition, context) {
|
|
|
2261
2241
|
let value;
|
|
2262
2242
|
const { type } = endCondition;
|
|
2263
2243
|
switch (type) {
|
|
2264
|
-
case
|
|
2265
|
-
value = { [
|
|
2244
|
+
case types_1.InstructionType.SettleOnBlock:
|
|
2245
|
+
value = { [types_1.InstructionType.SettleOnBlock]: bigNumberToU32(endCondition.endBlock, context) };
|
|
2266
2246
|
break;
|
|
2267
|
-
case
|
|
2247
|
+
case types_1.InstructionType.SettleManual:
|
|
2268
2248
|
value = {
|
|
2269
|
-
[
|
|
2249
|
+
[types_1.InstructionType.SettleManual]: bigNumberToU32(endCondition.endAfterBlock, context),
|
|
2270
2250
|
};
|
|
2271
2251
|
break;
|
|
2272
2252
|
default:
|
|
2273
|
-
value =
|
|
2253
|
+
value = types_1.InstructionType.SettleOnAffirmation;
|
|
2274
2254
|
}
|
|
2275
2255
|
if (context.isV5) {
|
|
2276
2256
|
return context.createType('PalletSettlementSettlementType', value);
|
|
@@ -2283,24 +2263,7 @@ exports.endConditionToSettlementType = endConditionToSettlementType;
|
|
|
2283
2263
|
/**
|
|
2284
2264
|
* @hidden
|
|
2285
2265
|
*/
|
|
2286
|
-
function
|
|
2287
|
-
return data.map(({ did, claims }) => ({
|
|
2288
|
-
identity: new internal_1.Identity({ did }, context),
|
|
2289
|
-
claims: claims.map(({ targetDID: targetDid, issuer, issuance_date: issuanceDate, last_update_date: lastUpdateDate, expiry, type, jurisdiction, scope: claimScope, cdd_id: cddId, }) => ({
|
|
2290
|
-
target: new internal_1.Identity({ did: targetDid }, context),
|
|
2291
|
-
issuer: new internal_1.Identity({ did: issuer }, context),
|
|
2292
|
-
issuedAt: new Date(issuanceDate),
|
|
2293
|
-
lastUpdatedAt: new Date(lastUpdateDate),
|
|
2294
|
-
expiry: expiry ? new Date(expiry) : null,
|
|
2295
|
-
claim: (0, internal_3.createClaim)(type, jurisdiction, claimScope, cddId),
|
|
2296
|
-
})),
|
|
2297
|
-
}));
|
|
2298
|
-
}
|
|
2299
|
-
exports.toIdentityWithClaimsArray = toIdentityWithClaimsArray;
|
|
2300
|
-
/**
|
|
2301
|
-
* @hidden
|
|
2302
|
-
*/
|
|
2303
|
-
function middlewareV2ClaimToClaimData(claim, context) {
|
|
2266
|
+
function middlewareClaimToClaimData(claim, context) {
|
|
2304
2267
|
const { targetId, issuerId, issuanceDate, lastUpdateDate, expiry, type, jurisdiction, scope, cddId, } = claim;
|
|
2305
2268
|
return {
|
|
2306
2269
|
target: new internal_1.Identity({ did: targetId }, context),
|
|
@@ -2311,18 +2274,18 @@ function middlewareV2ClaimToClaimData(claim, context) {
|
|
|
2311
2274
|
claim: (0, internal_3.createClaim)(type, jurisdiction, scope, cddId),
|
|
2312
2275
|
};
|
|
2313
2276
|
}
|
|
2314
|
-
exports.
|
|
2277
|
+
exports.middlewareClaimToClaimData = middlewareClaimToClaimData;
|
|
2315
2278
|
/**
|
|
2316
2279
|
* @hidden
|
|
2317
2280
|
*/
|
|
2318
|
-
function
|
|
2281
|
+
function toIdentityWithClaimsArray(data, context, groupByAttribute) {
|
|
2319
2282
|
const groupedData = (0, lodash_1.groupBy)(data, groupByAttribute);
|
|
2320
2283
|
return (0, lodash_1.map)(groupedData, (claims, did) => ({
|
|
2321
2284
|
identity: new internal_1.Identity({ did }, context),
|
|
2322
|
-
claims: claims.map(claim =>
|
|
2285
|
+
claims: claims.map(claim => middlewareClaimToClaimData(claim, context)),
|
|
2323
2286
|
}));
|
|
2324
2287
|
}
|
|
2325
|
-
exports.
|
|
2288
|
+
exports.toIdentityWithClaimsArray = toIdentityWithClaimsArray;
|
|
2326
2289
|
/**
|
|
2327
2290
|
* @hidden
|
|
2328
2291
|
*/
|
|
@@ -2370,30 +2333,30 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2370
2333
|
let restrictionType;
|
|
2371
2334
|
let restrictionValue;
|
|
2372
2335
|
const extractClaimValue = (claim) => {
|
|
2373
|
-
if (claim.type ===
|
|
2336
|
+
if (claim.type === types_1.ClaimType.Accredited) {
|
|
2374
2337
|
return booleanToBool(claim.accredited, context);
|
|
2375
2338
|
}
|
|
2376
|
-
else if (claim.type ===
|
|
2339
|
+
else if (claim.type === types_1.ClaimType.Affiliate) {
|
|
2377
2340
|
return booleanToBool(claim.affiliate, context);
|
|
2378
2341
|
}
|
|
2379
2342
|
else {
|
|
2380
2343
|
return (0, internal_3.optionize)(utils_2.countryCodeToMeshCountryCode)(claim.countryCode, context);
|
|
2381
2344
|
}
|
|
2382
2345
|
};
|
|
2383
|
-
if (type ===
|
|
2346
|
+
if (type === types_1.TransferRestrictionType.Count) {
|
|
2384
2347
|
restrictionType = 'MaxInvestorCount';
|
|
2385
2348
|
restrictionValue = bigNumberToU64(value, context);
|
|
2386
2349
|
}
|
|
2387
|
-
else if (type ===
|
|
2350
|
+
else if (type === types_1.TransferRestrictionType.Percentage) {
|
|
2388
2351
|
restrictionType = 'MaxInvestorOwnership';
|
|
2389
2352
|
restrictionValue = percentageToPermill(value, context);
|
|
2390
2353
|
}
|
|
2391
|
-
else if (type ===
|
|
2392
|
-
type ===
|
|
2354
|
+
else if (type === types_1.TransferRestrictionType.ClaimCount ||
|
|
2355
|
+
type === types_1.TransferRestrictionType.ClaimPercentage) {
|
|
2393
2356
|
let rawMin;
|
|
2394
2357
|
let rawMax;
|
|
2395
2358
|
const { min, max, claim, issuer } = value;
|
|
2396
|
-
if (type ===
|
|
2359
|
+
if (type === types_1.TransferRestrictionType.ClaimCount) {
|
|
2397
2360
|
restrictionType = 'ClaimCount';
|
|
2398
2361
|
rawMin = bigNumberToU64(min, context);
|
|
2399
2362
|
rawMax = (0, internal_3.optionize)(bigNumberToU64)(max, context);
|
|
@@ -2413,7 +2376,7 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2413
2376
|
}
|
|
2414
2377
|
else {
|
|
2415
2378
|
throw new internal_1.PolymeshError({
|
|
2416
|
-
code:
|
|
2379
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
2417
2380
|
message: `Unexpected transfer restriction type: "${type}". Please report this to the Polymesh team`,
|
|
2418
2381
|
});
|
|
2419
2382
|
}
|
|
@@ -2436,31 +2399,31 @@ exports.identitiesToBtreeSet = identitiesToBtreeSet;
|
|
|
2436
2399
|
function transferConditionToTransferRestriction(transferCondition, context) {
|
|
2437
2400
|
if (transferCondition.isMaxInvestorCount) {
|
|
2438
2401
|
return {
|
|
2439
|
-
type:
|
|
2402
|
+
type: types_1.TransferRestrictionType.Count,
|
|
2440
2403
|
value: u64ToBigNumber(transferCondition.asMaxInvestorCount),
|
|
2441
2404
|
};
|
|
2442
2405
|
}
|
|
2443
2406
|
else if (transferCondition.isMaxInvestorOwnership) {
|
|
2444
2407
|
return {
|
|
2445
|
-
type:
|
|
2408
|
+
type: types_1.TransferRestrictionType.Percentage,
|
|
2446
2409
|
value: permillToBigNumber(transferCondition.asMaxInvestorOwnership),
|
|
2447
2410
|
};
|
|
2448
2411
|
}
|
|
2449
2412
|
else if (transferCondition.isClaimCount) {
|
|
2450
2413
|
return {
|
|
2451
|
-
type:
|
|
2414
|
+
type: types_1.TransferRestrictionType.ClaimCount,
|
|
2452
2415
|
value: claimCountToClaimCountRestrictionValue(transferCondition.asClaimCount, context),
|
|
2453
2416
|
};
|
|
2454
2417
|
}
|
|
2455
2418
|
else if (transferCondition.isClaimOwnership) {
|
|
2456
2419
|
return {
|
|
2457
|
-
type:
|
|
2420
|
+
type: types_1.TransferRestrictionType.ClaimPercentage,
|
|
2458
2421
|
value: claimPercentageToClaimPercentageRestrictionValue(transferCondition.asClaimOwnership, context),
|
|
2459
2422
|
};
|
|
2460
2423
|
}
|
|
2461
2424
|
else {
|
|
2462
2425
|
throw new internal_1.PolymeshError({
|
|
2463
|
-
code:
|
|
2426
|
+
code: types_1.ErrorCode.FatalError,
|
|
2464
2427
|
message: 'Unexpected transfer condition type',
|
|
2465
2428
|
});
|
|
2466
2429
|
}
|
|
@@ -2473,34 +2436,34 @@ function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
|
2473
2436
|
const { invalid_granularity: invalidGranularity, self_transfer: selfTransfer, invalid_receiver_cdd: invalidReceiverCdd, invalid_sender_cdd: invalidSenderCdd, missing_scope_claim: missingScopeClaim, sender_insufficient_balance: insufficientBalance, asset_frozen: assetFrozen, portfolio_validity_result: { sender_portfolio_does_not_exist: senderPortfolioNotExists, receiver_portfolio_does_not_exist: receiverPortfolioNotExists, sender_insufficient_balance: senderInsufficientBalance, }, transfer_condition_result: transferConditionResult, compliance_result: complianceResult, result: finalResult, } = result;
|
|
2474
2437
|
const general = [];
|
|
2475
2438
|
if (boolToBoolean(invalidGranularity)) {
|
|
2476
|
-
general.push(
|
|
2439
|
+
general.push(types_1.TransferError.InvalidGranularity);
|
|
2477
2440
|
}
|
|
2478
2441
|
if (boolToBoolean(selfTransfer)) {
|
|
2479
|
-
general.push(
|
|
2442
|
+
general.push(types_1.TransferError.SelfTransfer);
|
|
2480
2443
|
}
|
|
2481
2444
|
if (boolToBoolean(invalidReceiverCdd)) {
|
|
2482
|
-
general.push(
|
|
2445
|
+
general.push(types_1.TransferError.InvalidReceiverCdd);
|
|
2483
2446
|
}
|
|
2484
2447
|
if (boolToBoolean(invalidSenderCdd)) {
|
|
2485
|
-
general.push(
|
|
2448
|
+
general.push(types_1.TransferError.InvalidSenderCdd);
|
|
2486
2449
|
}
|
|
2487
2450
|
if (boolToBoolean(missingScopeClaim)) {
|
|
2488
|
-
general.push(
|
|
2451
|
+
general.push(types_1.TransferError.ScopeClaimMissing);
|
|
2489
2452
|
}
|
|
2490
2453
|
if (boolToBoolean(insufficientBalance)) {
|
|
2491
|
-
general.push(
|
|
2454
|
+
general.push(types_1.TransferError.InsufficientBalance);
|
|
2492
2455
|
}
|
|
2493
2456
|
if (boolToBoolean(assetFrozen)) {
|
|
2494
|
-
general.push(
|
|
2457
|
+
general.push(types_1.TransferError.TransfersFrozen);
|
|
2495
2458
|
}
|
|
2496
2459
|
if (boolToBoolean(senderPortfolioNotExists)) {
|
|
2497
|
-
general.push(
|
|
2460
|
+
general.push(types_1.TransferError.InvalidSenderPortfolio);
|
|
2498
2461
|
}
|
|
2499
2462
|
if (boolToBoolean(receiverPortfolioNotExists)) {
|
|
2500
|
-
general.push(
|
|
2463
|
+
general.push(types_1.TransferError.InvalidReceiverPortfolio);
|
|
2501
2464
|
}
|
|
2502
2465
|
if (boolToBoolean(senderInsufficientBalance)) {
|
|
2503
|
-
general.push(
|
|
2466
|
+
general.push(types_1.TransferError.InsufficientPortfolioBalance);
|
|
2504
2467
|
}
|
|
2505
2468
|
const restrictions = transferConditionResult.map(({ condition, result: tmResult }) => {
|
|
2506
2469
|
return {
|
|
@@ -2533,16 +2496,16 @@ exports.offeringTierToPriceTier = offeringTierToPriceTier;
|
|
|
2533
2496
|
function permissionsLikeToPermissions(permissionsLike, context) {
|
|
2534
2497
|
let assetPermissions = {
|
|
2535
2498
|
values: [],
|
|
2536
|
-
type:
|
|
2499
|
+
type: types_1.PermissionType.Include,
|
|
2537
2500
|
};
|
|
2538
2501
|
let transactionPermissions = {
|
|
2539
2502
|
values: [],
|
|
2540
|
-
type:
|
|
2503
|
+
type: types_1.PermissionType.Include,
|
|
2541
2504
|
};
|
|
2542
2505
|
let transactionGroupPermissions = [];
|
|
2543
2506
|
let portfolioPermissions = {
|
|
2544
2507
|
values: [],
|
|
2545
|
-
type:
|
|
2508
|
+
type: types_1.PermissionType.Include,
|
|
2546
2509
|
};
|
|
2547
2510
|
let transactions;
|
|
2548
2511
|
let transactionGroups;
|
|
@@ -2585,24 +2548,13 @@ exports.permissionsLikeToPermissions = permissionsLikeToPermissions;
|
|
|
2585
2548
|
* @hidden
|
|
2586
2549
|
*/
|
|
2587
2550
|
function middlewarePortfolioToPortfolio(portfolio, context) {
|
|
2588
|
-
const { did, kind } = portfolio;
|
|
2589
|
-
if (kind.toLowerCase() === 'default' || kind === '0') {
|
|
2590
|
-
return new internal_1.DefaultPortfolio({ did }, context);
|
|
2591
|
-
}
|
|
2592
|
-
return new internal_1.NumberedPortfolio({ did, id: new bignumber_js_1.default(kind) }, context);
|
|
2593
|
-
}
|
|
2594
|
-
exports.middlewarePortfolioToPortfolio = middlewarePortfolioToPortfolio;
|
|
2595
|
-
/**
|
|
2596
|
-
* @hidden
|
|
2597
|
-
*/
|
|
2598
|
-
function middlewareV2PortfolioToPortfolio(portfolio, context) {
|
|
2599
2551
|
const { identityId: did, number } = portfolio;
|
|
2600
2552
|
if (number) {
|
|
2601
2553
|
return new internal_1.NumberedPortfolio({ did, id: new bignumber_js_1.default(number) }, context);
|
|
2602
2554
|
}
|
|
2603
2555
|
return new internal_1.DefaultPortfolio({ did }, context);
|
|
2604
2556
|
}
|
|
2605
|
-
exports.
|
|
2557
|
+
exports.middlewarePortfolioToPortfolio = middlewarePortfolioToPortfolio;
|
|
2606
2558
|
/**
|
|
2607
2559
|
* @hidden
|
|
2608
2560
|
*/
|
|
@@ -2638,29 +2590,29 @@ function fundraiserToOfferingDetails(fundraiser, name, context) {
|
|
|
2638
2590
|
const isStarted = now > start;
|
|
2639
2591
|
const isExpired = end && now > end;
|
|
2640
2592
|
const minInvestment = balanceToBigNumber(rawMinInvestment);
|
|
2641
|
-
let timing =
|
|
2642
|
-
let balance =
|
|
2643
|
-
let sale =
|
|
2593
|
+
let timing = types_1.OfferingTimingStatus.NotStarted;
|
|
2594
|
+
let balance = types_1.OfferingBalanceStatus.Available;
|
|
2595
|
+
let sale = types_1.OfferingSaleStatus.Live;
|
|
2644
2596
|
if (isExpired) {
|
|
2645
|
-
timing =
|
|
2597
|
+
timing = types_1.OfferingTimingStatus.Expired;
|
|
2646
2598
|
}
|
|
2647
2599
|
else if (isStarted) {
|
|
2648
|
-
timing =
|
|
2600
|
+
timing = types_1.OfferingTimingStatus.Started;
|
|
2649
2601
|
}
|
|
2650
2602
|
if (totalRemainingValue.isZero()) {
|
|
2651
|
-
balance =
|
|
2603
|
+
balance = types_1.OfferingBalanceStatus.SoldOut;
|
|
2652
2604
|
}
|
|
2653
2605
|
else if (totalRemainingValue.lt(minInvestment)) {
|
|
2654
|
-
balance =
|
|
2606
|
+
balance = types_1.OfferingBalanceStatus.Residual;
|
|
2655
2607
|
}
|
|
2656
2608
|
if (rawStatus.isClosedEarly) {
|
|
2657
|
-
sale =
|
|
2609
|
+
sale = types_1.OfferingSaleStatus.ClosedEarly;
|
|
2658
2610
|
}
|
|
2659
2611
|
else if (rawStatus.isClosed) {
|
|
2660
|
-
sale =
|
|
2612
|
+
sale = types_1.OfferingSaleStatus.Closed;
|
|
2661
2613
|
}
|
|
2662
2614
|
else if (rawStatus.isFrozen) {
|
|
2663
|
-
sale =
|
|
2615
|
+
sale = types_1.OfferingSaleStatus.Frozen;
|
|
2664
2616
|
}
|
|
2665
2617
|
return {
|
|
2666
2618
|
creator: new internal_1.Identity({ did: identityIdToString(creator) }, context),
|
|
@@ -2690,23 +2642,23 @@ function meshCorporateActionToCorporateActionParams(corporateAction, details, co
|
|
|
2690
2642
|
const { kind: rawKind, declDate, targets: { identities, treatment }, defaultWithholdingTax, withholdingTax, } = corporateAction;
|
|
2691
2643
|
let kind;
|
|
2692
2644
|
if (rawKind.isIssuerNotice) {
|
|
2693
|
-
kind =
|
|
2645
|
+
kind = types_1.CorporateActionKind.IssuerNotice;
|
|
2694
2646
|
}
|
|
2695
2647
|
else if (rawKind.isPredictableBenefit) {
|
|
2696
|
-
kind =
|
|
2648
|
+
kind = types_1.CorporateActionKind.PredictableBenefit;
|
|
2697
2649
|
}
|
|
2698
2650
|
else if (rawKind.isUnpredictableBenefit) {
|
|
2699
|
-
kind =
|
|
2651
|
+
kind = types_1.CorporateActionKind.UnpredictableBenefit;
|
|
2700
2652
|
}
|
|
2701
2653
|
else if (rawKind.isReorganization) {
|
|
2702
|
-
kind =
|
|
2654
|
+
kind = types_1.CorporateActionKind.Reorganization;
|
|
2703
2655
|
}
|
|
2704
2656
|
else {
|
|
2705
|
-
kind =
|
|
2657
|
+
kind = types_1.CorporateActionKind.Other;
|
|
2706
2658
|
}
|
|
2707
2659
|
const targets = {
|
|
2708
2660
|
identities: identities.map(identityId => new internal_1.Identity({ did: identityIdToString(identityId) }, context)),
|
|
2709
|
-
treatment: treatment.isExclude ?
|
|
2661
|
+
treatment: treatment.isExclude ? types_1.TargetTreatment.Exclude : types_1.TargetTreatment.Include,
|
|
2710
2662
|
};
|
|
2711
2663
|
const taxWithholdings = withholdingTax.map(([identityId, tax]) => ({
|
|
2712
2664
|
identity: new internal_1.Identity({ did: identityIdToString(identityId) }, context),
|
|
@@ -2755,7 +2707,7 @@ function targetIdentitiesToCorporateActionTargets(targetIdentities, context) {
|
|
|
2755
2707
|
const { identities, treatment } = targetIdentities;
|
|
2756
2708
|
return {
|
|
2757
2709
|
identities: identities.map(identity => new internal_1.Identity({ did: identityIdToString(identity) }, context)),
|
|
2758
|
-
treatment: treatment.isInclude ?
|
|
2710
|
+
treatment: treatment.isInclude ? types_1.TargetTreatment.Include : types_1.TargetTreatment.Exclude,
|
|
2759
2711
|
};
|
|
2760
2712
|
}
|
|
2761
2713
|
exports.targetIdentitiesToCorporateActionTargets = targetIdentitiesToCorporateActionTargets;
|
|
@@ -2768,7 +2720,7 @@ function targetsToTargetIdentities(targets, context) {
|
|
|
2768
2720
|
const maxTargets = u32ToBigNumber(maxTargetIds);
|
|
2769
2721
|
if (maxTargets.lt(targets.identities.length)) {
|
|
2770
2722
|
throw new internal_1.PolymeshError({
|
|
2771
|
-
code:
|
|
2723
|
+
code: types_1.ErrorCode.ValidationError,
|
|
2772
2724
|
message: 'Too many target Identities',
|
|
2773
2725
|
data: {
|
|
2774
2726
|
maxTargets,
|
|
@@ -2908,17 +2860,17 @@ function meshStatToStatType(rawStat) {
|
|
|
2908
2860
|
const { op: { type }, claimIssuer, } = rawStat;
|
|
2909
2861
|
if (claimIssuer.isNone) {
|
|
2910
2862
|
if (type === 'Count') {
|
|
2911
|
-
return
|
|
2863
|
+
return types_1.StatType.Count;
|
|
2912
2864
|
}
|
|
2913
2865
|
else {
|
|
2914
|
-
return
|
|
2866
|
+
return types_1.StatType.Balance;
|
|
2915
2867
|
}
|
|
2916
2868
|
}
|
|
2917
2869
|
if (type === 'Count') {
|
|
2918
|
-
return
|
|
2870
|
+
return types_1.StatType.ScopedCount;
|
|
2919
2871
|
}
|
|
2920
2872
|
else {
|
|
2921
|
-
return
|
|
2873
|
+
return types_1.StatType.ScopedBalance;
|
|
2922
2874
|
}
|
|
2923
2875
|
}
|
|
2924
2876
|
exports.meshStatToStatType = meshStatToStatType;
|
|
@@ -2926,20 +2878,20 @@ exports.meshStatToStatType = meshStatToStatType;
|
|
|
2926
2878
|
* @hidden
|
|
2927
2879
|
*/
|
|
2928
2880
|
function statTypeToStatOpType(type, context) {
|
|
2929
|
-
if (type ===
|
|
2930
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2881
|
+
if (type === types_1.StatType.Count || type === types_1.StatType.ScopedCount) {
|
|
2882
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_1.StatType.Count);
|
|
2931
2883
|
}
|
|
2932
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2884
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_1.StatType.Balance);
|
|
2933
2885
|
}
|
|
2934
2886
|
exports.statTypeToStatOpType = statTypeToStatOpType;
|
|
2935
2887
|
/**
|
|
2936
2888
|
* @hidden
|
|
2937
2889
|
*/
|
|
2938
2890
|
function transferRestrictionTypeToStatOpType(type, context) {
|
|
2939
|
-
if (type ===
|
|
2940
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2891
|
+
if (type === types_1.TransferRestrictionType.Count || type === types_1.TransferRestrictionType.ClaimCount) {
|
|
2892
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_1.StatType.Count);
|
|
2941
2893
|
}
|
|
2942
|
-
return context.createType('PolymeshPrimitivesStatisticsStatOpType',
|
|
2894
|
+
return context.createType('PolymeshPrimitivesStatisticsStatOpType', types_1.StatType.Balance);
|
|
2943
2895
|
}
|
|
2944
2896
|
exports.transferRestrictionTypeToStatOpType = transferRestrictionTypeToStatOpType;
|
|
2945
2897
|
/**
|
|
@@ -3014,7 +2966,7 @@ function sortTransferRestrictionByClaimValue(conditions) {
|
|
|
3014
2966
|
}
|
|
3015
2967
|
const aCode = (0, utils_2.meshCountryCodeToCountryCode)(aClaim.unwrap());
|
|
3016
2968
|
const bCode = (0, utils_2.meshCountryCodeToCountryCode)(bClaim.unwrap());
|
|
3017
|
-
const countryOrder = Object.values(
|
|
2969
|
+
const countryOrder = Object.values(types_1.CountryCode);
|
|
3018
2970
|
return countryOrder.indexOf(aCode) - countryOrder.indexOf(bCode);
|
|
3019
2971
|
});
|
|
3020
2972
|
}
|
|
@@ -3040,7 +2992,7 @@ exports.toExemptKey = toExemptKey;
|
|
|
3040
2992
|
function claimCountStatInputToStatUpdates(args, context) {
|
|
3041
2993
|
const { value, claimType: type } = args;
|
|
3042
2994
|
let updateArgs;
|
|
3043
|
-
if (type ===
|
|
2995
|
+
if (type === types_1.ClaimType.Jurisdiction) {
|
|
3044
2996
|
updateArgs = value.map(({ countryCode, count }) => {
|
|
3045
2997
|
const rawSecondKey = createStat2ndKey(type, context, countryCode);
|
|
3046
2998
|
return keyAndValueToStatUpdate(rawSecondKey, bigNumberToU128(count, context), context);
|
|
@@ -3048,7 +3000,7 @@ function claimCountStatInputToStatUpdates(args, context) {
|
|
|
3048
3000
|
}
|
|
3049
3001
|
else {
|
|
3050
3002
|
let yes, no;
|
|
3051
|
-
if (type ===
|
|
3003
|
+
if (type === types_1.ClaimType.Accredited) {
|
|
3052
3004
|
({ accredited: yes, nonAccredited: no } = value);
|
|
3053
3005
|
}
|
|
3054
3006
|
else {
|
|
@@ -3084,7 +3036,7 @@ function inputStatTypeToMeshStatType(input, context) {
|
|
|
3084
3036
|
const { type } = input;
|
|
3085
3037
|
const op = statTypeToStatOpType(type, context);
|
|
3086
3038
|
let claimIssuer;
|
|
3087
|
-
if (type ===
|
|
3039
|
+
if (type === types_1.StatType.ScopedCount || type === types_1.StatType.ScopedBalance) {
|
|
3088
3040
|
claimIssuer = claimIssuerToMeshClaimIssuer(input.claimIssuer, context);
|
|
3089
3041
|
}
|
|
3090
3042
|
return statisticsOpTypeToStatType({ op, claimIssuer }, context);
|
|
@@ -3098,19 +3050,19 @@ function meshProposalStatusToProposalStatus(status, expiry) {
|
|
|
3098
3050
|
switch (type) {
|
|
3099
3051
|
case 'ActiveOrExpired':
|
|
3100
3052
|
if (!expiry || expiry > new Date()) {
|
|
3101
|
-
return
|
|
3053
|
+
return types_1.ProposalStatus.Active;
|
|
3102
3054
|
}
|
|
3103
3055
|
else {
|
|
3104
|
-
return
|
|
3056
|
+
return types_1.ProposalStatus.Expired;
|
|
3105
3057
|
}
|
|
3106
3058
|
case 'Invalid':
|
|
3107
|
-
return
|
|
3059
|
+
return types_1.ProposalStatus.Invalid;
|
|
3108
3060
|
case 'ExecutionSuccessful':
|
|
3109
|
-
return
|
|
3061
|
+
return types_1.ProposalStatus.Successful;
|
|
3110
3062
|
case 'ExecutionFailed':
|
|
3111
|
-
return
|
|
3063
|
+
return types_1.ProposalStatus.Failed;
|
|
3112
3064
|
case 'Rejected':
|
|
3113
|
-
return
|
|
3065
|
+
return types_1.ProposalStatus.Rejected;
|
|
3114
3066
|
default:
|
|
3115
3067
|
throw new utils_1.UnreachableCaseError(type);
|
|
3116
3068
|
}
|
|
@@ -3125,7 +3077,7 @@ function metadataSpecToMeshMetadataSpec(specs, context) {
|
|
|
3125
3077
|
const metadataTypeDefMaxLength = u32ToBigNumber(assetMetadataTypeDefMaxLength);
|
|
3126
3078
|
if (typeDef && metadataTypeDefMaxLength.lt(typeDef.length)) {
|
|
3127
3079
|
throw new internal_1.PolymeshError({
|
|
3128
|
-
code:
|
|
3080
|
+
code: types_1.ErrorCode.ValidationError,
|
|
3129
3081
|
message: '"typeDef" length exceeded for given Asset Metadata spec',
|
|
3130
3082
|
data: {
|
|
3131
3083
|
maxLength: metadataTypeDefMaxLength,
|
|
@@ -3165,7 +3117,7 @@ exports.meshMetadataSpecToMetadataSpec = meshMetadataSpecToMetadataSpec;
|
|
|
3165
3117
|
function metadataToMeshMetadataKey(type, id, context) {
|
|
3166
3118
|
const rawId = bigNumberToU64(id, context);
|
|
3167
3119
|
let metadataKey;
|
|
3168
|
-
if (type ===
|
|
3120
|
+
if (type === types_1.MetadataType.Local) {
|
|
3169
3121
|
metadataKey = { Local: rawId };
|
|
3170
3122
|
}
|
|
3171
3123
|
else {
|
|
@@ -3183,17 +3135,17 @@ function meshMetadataValueToMetadataValue(rawValue, rawDetails) {
|
|
|
3183
3135
|
}
|
|
3184
3136
|
let metadataValue = {
|
|
3185
3137
|
value: bytesToString(rawValue.unwrap()),
|
|
3186
|
-
lockStatus:
|
|
3138
|
+
lockStatus: types_1.MetadataLockStatus.Unlocked,
|
|
3187
3139
|
expiry: null,
|
|
3188
3140
|
};
|
|
3189
3141
|
if (rawDetails.isSome) {
|
|
3190
3142
|
const { lockStatus: rawLockStatus, expire } = rawDetails.unwrap();
|
|
3191
3143
|
metadataValue = Object.assign(Object.assign({}, metadataValue), { expiry: (0, internal_3.optionize)(momentToDate)(expire.unwrapOr(null)) });
|
|
3192
3144
|
if (rawLockStatus.isLocked) {
|
|
3193
|
-
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus:
|
|
3145
|
+
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus: types_1.MetadataLockStatus.Locked });
|
|
3194
3146
|
}
|
|
3195
3147
|
if (rawLockStatus.isLockedUntil) {
|
|
3196
|
-
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus:
|
|
3148
|
+
metadataValue = Object.assign(Object.assign({}, metadataValue), { lockStatus: types_1.MetadataLockStatus.LockedUntil, lockedUntil: momentToDate(rawLockStatus.asLockedUntil) });
|
|
3197
3149
|
}
|
|
3198
3150
|
}
|
|
3199
3151
|
return metadataValue;
|
|
@@ -3207,7 +3159,7 @@ function metadataValueToMeshMetadataValue(value, context) {
|
|
|
3207
3159
|
const metadataValueMaxLength = u32ToBigNumber(assetMetadataValueMaxLength);
|
|
3208
3160
|
if (metadataValueMaxLength.lt(value.length)) {
|
|
3209
3161
|
throw new internal_1.PolymeshError({
|
|
3210
|
-
code:
|
|
3162
|
+
code: types_1.ErrorCode.ValidationError,
|
|
3211
3163
|
message: 'Asset Metadata value length exceeded',
|
|
3212
3164
|
data: {
|
|
3213
3165
|
maxLength: metadataValueMaxLength,
|
|
@@ -3223,11 +3175,11 @@ exports.metadataValueToMeshMetadataValue = metadataValueToMeshMetadataValue;
|
|
|
3223
3175
|
function metadataValueDetailToMeshMetadataValueDetail(details, context) {
|
|
3224
3176
|
const { lockStatus, expiry } = details;
|
|
3225
3177
|
let meshLockStatus;
|
|
3226
|
-
if (lockStatus ===
|
|
3178
|
+
if (lockStatus === types_1.MetadataLockStatus.LockedUntil) {
|
|
3227
3179
|
const { lockedUntil } = details;
|
|
3228
3180
|
if (lockedUntil < new Date()) {
|
|
3229
3181
|
throw new internal_1.PolymeshError({
|
|
3230
|
-
code:
|
|
3182
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
3231
3183
|
message: 'Locked until date must be in the future',
|
|
3232
3184
|
});
|
|
3233
3185
|
}
|
|
@@ -3238,7 +3190,7 @@ function metadataValueDetailToMeshMetadataValueDetail(details, context) {
|
|
|
3238
3190
|
}
|
|
3239
3191
|
if (expiry && expiry < new Date()) {
|
|
3240
3192
|
throw new internal_1.PolymeshError({
|
|
3241
|
-
code:
|
|
3193
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
3242
3194
|
message: 'Expiry date must be in the future',
|
|
3243
3195
|
});
|
|
3244
3196
|
}
|
|
@@ -3263,9 +3215,9 @@ function middlewareInstructionToHistoricInstruction(instruction, context) {
|
|
|
3263
3215
|
const { id: instructionId, status, settlementType, endBlock, tradeDate, valueDate, legs: { nodes: legs }, memo, createdBlock, venueId, } = instruction;
|
|
3264
3216
|
const { blockId, hash, datetime } = createdBlock;
|
|
3265
3217
|
let typeDetails;
|
|
3266
|
-
if (settlementType ===
|
|
3218
|
+
if (settlementType === types_1.InstructionType.SettleOnAffirmation) {
|
|
3267
3219
|
typeDetails = {
|
|
3268
|
-
type:
|
|
3220
|
+
type: types_1.InstructionType.SettleOnAffirmation,
|
|
3269
3221
|
};
|
|
3270
3222
|
}
|
|
3271
3223
|
else {
|
|
@@ -3279,8 +3231,8 @@ function middlewareInstructionToHistoricInstruction(instruction, context) {
|
|
|
3279
3231
|
valueDate }, typeDetails), { memo: memo !== null && memo !== void 0 ? memo : null, venueId: new bignumber_js_1.default(venueId), createdAt: new Date(datetime), legs: legs.map(({ from, to, assetId, amount }) => ({
|
|
3280
3232
|
asset: new internal_1.Asset({ ticker: assetId }, context),
|
|
3281
3233
|
amount: new bignumber_js_1.default(amount).shiftedBy(-6),
|
|
3282
|
-
from:
|
|
3283
|
-
to:
|
|
3234
|
+
from: middlewarePortfolioToPortfolio(from, context),
|
|
3235
|
+
to: middlewarePortfolioToPortfolio(to, context),
|
|
3284
3236
|
})) });
|
|
3285
3237
|
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
3286
3238
|
}
|
|
@@ -3291,7 +3243,7 @@ exports.middlewareInstructionToHistoricInstruction = middlewareInstructionToHist
|
|
|
3291
3243
|
function expiryToMoment(expiry, context) {
|
|
3292
3244
|
if (expiry && expiry <= new Date()) {
|
|
3293
3245
|
throw new internal_1.PolymeshError({
|
|
3294
|
-
code:
|
|
3246
|
+
code: types_1.ErrorCode.UnmetPrerequisite,
|
|
3295
3247
|
message: 'Expiry date must be in the future',
|
|
3296
3248
|
});
|
|
3297
3249
|
}
|
|
@@ -3325,16 +3277,16 @@ function middlewareAgentGroupDataToPermissionGroup(agentGroupData, context) {
|
|
|
3325
3277
|
const agentGroup = agentGroupData[asset];
|
|
3326
3278
|
let permissionGroupIdentifier;
|
|
3327
3279
|
if ('full' in agentGroup) {
|
|
3328
|
-
permissionGroupIdentifier =
|
|
3280
|
+
permissionGroupIdentifier = types_1.PermissionGroupType.Full;
|
|
3329
3281
|
}
|
|
3330
3282
|
else if ('exceptMeta' in agentGroup) {
|
|
3331
|
-
permissionGroupIdentifier =
|
|
3283
|
+
permissionGroupIdentifier = types_1.PermissionGroupType.ExceptMeta;
|
|
3332
3284
|
}
|
|
3333
3285
|
else if ('polymeshV1CAA' in agentGroup) {
|
|
3334
|
-
permissionGroupIdentifier =
|
|
3286
|
+
permissionGroupIdentifier = types_1.PermissionGroupType.PolymeshV1Caa;
|
|
3335
3287
|
}
|
|
3336
3288
|
else if ('polymeshV1PIA' in agentGroup) {
|
|
3337
|
-
permissionGroupIdentifier =
|
|
3289
|
+
permissionGroupIdentifier = types_1.PermissionGroupType.PolymeshV1Pia;
|
|
3338
3290
|
}
|
|
3339
3291
|
else {
|
|
3340
3292
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -3351,11 +3303,11 @@ function middlewareExtrinsicPermissionsDataToTransactionPermissions(permissions)
|
|
|
3351
3303
|
let extrinsicType;
|
|
3352
3304
|
let pallets;
|
|
3353
3305
|
if ('these' in permissions) {
|
|
3354
|
-
extrinsicType =
|
|
3306
|
+
extrinsicType = types_1.PermissionType.Include;
|
|
3355
3307
|
pallets = permissions.these;
|
|
3356
3308
|
}
|
|
3357
3309
|
else if ('except' in permissions) {
|
|
3358
|
-
extrinsicType =
|
|
3310
|
+
extrinsicType = types_1.PermissionType.Exclude;
|
|
3359
3311
|
pallets = permissions.except;
|
|
3360
3312
|
}
|
|
3361
3313
|
let txValues = [];
|
|
@@ -3411,11 +3363,11 @@ function middlewarePermissionsDataToPermissions(permissionsData, context) {
|
|
|
3411
3363
|
let assetsType;
|
|
3412
3364
|
let assetsPermissions;
|
|
3413
3365
|
if ('these' in asset) {
|
|
3414
|
-
assetsType =
|
|
3366
|
+
assetsType = types_1.PermissionType.Include;
|
|
3415
3367
|
assetsPermissions = asset.these;
|
|
3416
3368
|
}
|
|
3417
3369
|
else if ('except' in asset) {
|
|
3418
|
-
assetsType =
|
|
3370
|
+
assetsType = types_1.PermissionType.Exclude;
|
|
3419
3371
|
assetsPermissions = asset.except;
|
|
3420
3372
|
}
|
|
3421
3373
|
if (assetsPermissions) {
|
|
@@ -3429,11 +3381,11 @@ function middlewarePermissionsDataToPermissions(permissionsData, context) {
|
|
|
3429
3381
|
let portfoliosType;
|
|
3430
3382
|
let portfolioIds;
|
|
3431
3383
|
if ('these' in portfolio) {
|
|
3432
|
-
portfoliosType =
|
|
3384
|
+
portfoliosType = types_1.PermissionType.Include;
|
|
3433
3385
|
portfolioIds = portfolio.these;
|
|
3434
3386
|
}
|
|
3435
3387
|
else if ('except' in portfolio) {
|
|
3436
|
-
portfoliosType =
|
|
3388
|
+
portfoliosType = types_1.PermissionType.Exclude;
|
|
3437
3389
|
portfolioIds = portfolio.except;
|
|
3438
3390
|
}
|
|
3439
3391
|
if (portfolioIds) {
|
|
@@ -3457,41 +3409,41 @@ exports.middlewarePermissionsDataToPermissions = middlewarePermissionsDataToPerm
|
|
|
3457
3409
|
*/
|
|
3458
3410
|
function middlewareAuthorizationDataToAuthorization(context, type, data) {
|
|
3459
3411
|
switch (type) {
|
|
3460
|
-
case
|
|
3412
|
+
case enums_1.AuthTypeEnum.AttestPrimaryKeyRotation:
|
|
3461
3413
|
return {
|
|
3462
|
-
type:
|
|
3414
|
+
type: types_1.AuthorizationType.AttestPrimaryKeyRotation,
|
|
3463
3415
|
value: new internal_1.Identity({ did: data }, context),
|
|
3464
3416
|
};
|
|
3465
|
-
case
|
|
3417
|
+
case enums_1.AuthTypeEnum.RotatePrimaryKey: {
|
|
3466
3418
|
return {
|
|
3467
|
-
type:
|
|
3419
|
+
type: types_1.AuthorizationType.RotatePrimaryKey,
|
|
3468
3420
|
};
|
|
3469
3421
|
}
|
|
3470
|
-
case
|
|
3422
|
+
case enums_1.AuthTypeEnum.RotatePrimaryKeyToSecondary: {
|
|
3471
3423
|
return {
|
|
3472
|
-
type:
|
|
3424
|
+
type: types_1.AuthorizationType.RotatePrimaryKeyToSecondary,
|
|
3473
3425
|
value: middlewarePermissionsDataToPermissions(data, context),
|
|
3474
3426
|
};
|
|
3475
3427
|
}
|
|
3476
|
-
case
|
|
3428
|
+
case enums_1.AuthTypeEnum.JoinIdentity: {
|
|
3477
3429
|
return {
|
|
3478
|
-
type:
|
|
3430
|
+
type: types_1.AuthorizationType.JoinIdentity,
|
|
3479
3431
|
value: middlewarePermissionsDataToPermissions(data, context),
|
|
3480
3432
|
};
|
|
3481
3433
|
}
|
|
3482
|
-
case
|
|
3434
|
+
case enums_1.AuthTypeEnum.AddMultiSigSigner:
|
|
3483
3435
|
return {
|
|
3484
|
-
type:
|
|
3436
|
+
type: types_1.AuthorizationType.AddMultiSigSigner,
|
|
3485
3437
|
value: data,
|
|
3486
3438
|
};
|
|
3487
|
-
case
|
|
3439
|
+
case enums_1.AuthTypeEnum.AddRelayerPayingKey: {
|
|
3488
3440
|
// data is received in the format - {"5Ci94GCJC2JBM8U1PCkpHX6HkscWmucN9XwUrjb7o4TDgVns","5DZp1QYH49MKZhCtDupNaAeHp8xtqetuSzgf2p2cUWoxW3iu","1000000000"}
|
|
3489
3441
|
const [beneficiary, subsidizer, allowance] = data
|
|
3490
3442
|
.substring(1, data.length - 1)
|
|
3491
3443
|
.replace(/"/g, '')
|
|
3492
3444
|
.split(',');
|
|
3493
3445
|
return {
|
|
3494
|
-
type:
|
|
3446
|
+
type: types_1.AuthorizationType.AddRelayerPayingKey,
|
|
3495
3447
|
value: {
|
|
3496
3448
|
beneficiary: new internal_1.Account({ address: beneficiary }, context),
|
|
3497
3449
|
subsidizer: new internal_1.Account({ address: subsidizer }, context),
|
|
@@ -3499,33 +3451,33 @@ function middlewareAuthorizationDataToAuthorization(context, type, data) {
|
|
|
3499
3451
|
},
|
|
3500
3452
|
};
|
|
3501
3453
|
}
|
|
3502
|
-
case
|
|
3454
|
+
case enums_1.AuthTypeEnum.BecomeAgent: {
|
|
3503
3455
|
const becomeAgentData = JSON.parse(data.replace(',', ':'));
|
|
3504
3456
|
return {
|
|
3505
|
-
type:
|
|
3457
|
+
type: types_1.AuthorizationType.BecomeAgent,
|
|
3506
3458
|
value: middlewareAgentGroupDataToPermissionGroup(becomeAgentData, context),
|
|
3507
3459
|
};
|
|
3508
3460
|
}
|
|
3509
|
-
case
|
|
3461
|
+
case enums_1.AuthTypeEnum.TransferTicker:
|
|
3510
3462
|
return {
|
|
3511
|
-
type:
|
|
3463
|
+
type: types_1.AuthorizationType.TransferTicker,
|
|
3512
3464
|
value: (0, exports.coerceHexToString)(data),
|
|
3513
3465
|
};
|
|
3514
|
-
case
|
|
3466
|
+
case enums_1.AuthTypeEnum.TransferAssetOwnership: {
|
|
3515
3467
|
return {
|
|
3516
|
-
type:
|
|
3468
|
+
type: types_1.AuthorizationType.TransferAssetOwnership,
|
|
3517
3469
|
value: (0, exports.coerceHexToString)(data),
|
|
3518
3470
|
};
|
|
3519
3471
|
}
|
|
3520
|
-
case
|
|
3472
|
+
case enums_1.AuthTypeEnum.PortfolioCustody: {
|
|
3521
3473
|
return {
|
|
3522
|
-
type:
|
|
3474
|
+
type: types_1.AuthorizationType.PortfolioCustody,
|
|
3523
3475
|
value: middlewarePortfolioDataToPortfolio(JSON.parse(data), context),
|
|
3524
3476
|
};
|
|
3525
3477
|
}
|
|
3526
3478
|
}
|
|
3527
3479
|
throw new internal_1.PolymeshError({
|
|
3528
|
-
code:
|
|
3480
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
3529
3481
|
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
3530
3482
|
data: {
|
|
3531
3483
|
auth: data,
|
|
@@ -3544,7 +3496,7 @@ function calendarPeriodToMeshCalendarPeriod(period, context) {
|
|
|
3544
3496
|
const { unit, amount } = period;
|
|
3545
3497
|
if (amount.isNegative()) {
|
|
3546
3498
|
throw new internal_1.PolymeshError({
|
|
3547
|
-
code:
|
|
3499
|
+
code: types_1.ErrorCode.ValidationError,
|
|
3548
3500
|
message: 'Calendar period cannot have a negative amount',
|
|
3549
3501
|
});
|
|
3550
3502
|
}
|
|
@@ -3562,25 +3514,25 @@ function meshCalendarPeriodToCalendarPeriod(period) {
|
|
|
3562
3514
|
const { unit: rawUnit, amount } = period;
|
|
3563
3515
|
let unit;
|
|
3564
3516
|
if (rawUnit.isSecond) {
|
|
3565
|
-
unit =
|
|
3517
|
+
unit = types_1.CalendarUnit.Second;
|
|
3566
3518
|
}
|
|
3567
3519
|
else if (rawUnit.isMinute) {
|
|
3568
|
-
unit =
|
|
3520
|
+
unit = types_1.CalendarUnit.Minute;
|
|
3569
3521
|
}
|
|
3570
3522
|
else if (rawUnit.isHour) {
|
|
3571
|
-
unit =
|
|
3523
|
+
unit = types_1.CalendarUnit.Hour;
|
|
3572
3524
|
}
|
|
3573
3525
|
else if (rawUnit.isDay) {
|
|
3574
|
-
unit =
|
|
3526
|
+
unit = types_1.CalendarUnit.Day;
|
|
3575
3527
|
}
|
|
3576
3528
|
else if (rawUnit.isWeek) {
|
|
3577
|
-
unit =
|
|
3529
|
+
unit = types_1.CalendarUnit.Week;
|
|
3578
3530
|
}
|
|
3579
3531
|
else if (rawUnit.isMonth) {
|
|
3580
|
-
unit =
|
|
3532
|
+
unit = types_1.CalendarUnit.Month;
|
|
3581
3533
|
}
|
|
3582
3534
|
else {
|
|
3583
|
-
unit =
|
|
3535
|
+
unit = types_1.CalendarUnit.Year;
|
|
3584
3536
|
}
|
|
3585
3537
|
return {
|
|
3586
3538
|
unit,
|
|
@@ -3613,7 +3565,7 @@ function scheduleSpecToMeshScheduleSpec(details, context) {
|
|
|
3613
3565
|
const { start, period, repetitions } = details;
|
|
3614
3566
|
return context.createType('PalletAssetCheckpointScheduleSpec', {
|
|
3615
3567
|
start: start && dateToMoment(start, context),
|
|
3616
|
-
period: calendarPeriodToMeshCalendarPeriod(period !== null && period !== void 0 ? period : { unit:
|
|
3568
|
+
period: calendarPeriodToMeshCalendarPeriod(period !== null && period !== void 0 ? period : { unit: types_1.CalendarUnit.Month, amount: new bignumber_js_1.default(0) }, context),
|
|
3617
3569
|
remaining: bigNumberToU64(repetitions || new bignumber_js_1.default(0), context),
|
|
3618
3570
|
});
|
|
3619
3571
|
}
|