@polymeshassociation/polymesh-sdk 15.0.0-alpha.15 → 15.0.0-alpha.16
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 +25 -2
- package/api/client/Claims.d.ts.map +1 -1
- package/api/client/Claims.js +1 -1
- package/api/client/Claims.js.map +1 -1
- package/api/client/Identities.d.ts +7 -1
- package/api/client/Identities.d.ts.map +1 -1
- package/api/client/Identities.js +13 -1
- package/api/client/Identities.js.map +1 -1
- package/api/client/Network.d.ts +5 -4
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js +2 -2
- package/api/client/Network.js.map +1 -1
- package/api/entities/Account.d.ts.map +1 -1
- package/api/entities/Account.js +7 -6
- package/api/entities/Account.js.map +1 -1
- package/api/entities/Asset/TransferRestrictions/ClaimCount.d.ts +61 -0
- package/api/entities/Asset/TransferRestrictions/ClaimCount.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/ClaimCount.js +16 -0
- package/api/entities/Asset/TransferRestrictions/ClaimCount.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/ClaimPercentage.d.ts +52 -0
- package/api/entities/Asset/TransferRestrictions/ClaimPercentage.d.ts.map +1 -0
- package/api/entities/Asset/TransferRestrictions/ClaimPercentage.js +16 -0
- package/api/entities/Asset/TransferRestrictions/ClaimPercentage.js.map +1 -0
- package/api/entities/Asset/TransferRestrictions/Count.d.ts +41 -4
- package/api/entities/Asset/TransferRestrictions/Count.d.ts.map +1 -1
- package/api/entities/Asset/TransferRestrictions/Count.js +6 -2
- package/api/entities/Asset/TransferRestrictions/Count.js.map +1 -1
- package/api/entities/Asset/TransferRestrictions/Percentage.d.ts +17 -2
- package/api/entities/Asset/TransferRestrictions/Percentage.d.ts.map +1 -1
- package/api/entities/Asset/TransferRestrictions/Percentage.js.map +1 -1
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.d.ts +15 -1
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.d.ts.map +1 -1
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.js +39 -4
- package/api/entities/Asset/TransferRestrictions/TransferRestrictionBase.js.map +1 -1
- package/api/entities/Asset/TransferRestrictions/index.d.ts +4 -0
- package/api/entities/Asset/TransferRestrictions/index.d.ts.map +1 -1
- package/api/entities/Asset/TransferRestrictions/index.js +4 -0
- package/api/entities/Asset/TransferRestrictions/index.js.map +1 -1
- package/api/entities/Identity/AssetPermissions.d.ts +3 -2
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
- package/api/entities/Identity/AssetPermissions.js.map +1 -1
- package/api/entities/Identity/index.d.ts +5 -4
- package/api/entities/Identity/index.d.ts.map +1 -1
- package/api/entities/Identity/index.js +32 -23
- package/api/entities/Identity/index.js.map +1 -1
- package/api/entities/Instruction/index.js +3 -2
- package/api/entities/Instruction/index.js.map +1 -1
- package/api/entities/Venue/index.d.ts +5 -1
- package/api/entities/Venue/index.d.ts.map +1 -1
- package/api/entities/Venue/index.js +8 -1
- package/api/entities/Venue/index.js.map +1 -1
- package/api/procedures/addAssetStat.d.ts +16 -0
- package/api/procedures/addAssetStat.d.ts.map +1 -0
- package/api/procedures/addAssetStat.js +91 -0
- package/api/procedures/addAssetStat.js.map +1 -0
- package/api/procedures/addTransferRestriction.d.ts +5 -16
- package/api/procedures/addTransferRestriction.d.ts.map +1 -1
- package/api/procedures/addTransferRestriction.js +42 -69
- package/api/procedures/addTransferRestriction.js.map +1 -1
- package/api/procedures/createAsset.d.ts +1 -1
- package/api/procedures/createAsset.d.ts.map +1 -1
- package/api/procedures/createAsset.js +56 -31
- package/api/procedures/createAsset.js.map +1 -1
- package/api/procedures/createPortfolios.d.ts +21 -0
- package/api/procedures/createPortfolios.d.ts.map +1 -0
- package/api/procedures/createPortfolios.js +79 -0
- package/api/procedures/createPortfolios.js.map +1 -0
- package/api/procedures/leaveIdentity.d.ts.map +1 -1
- package/api/procedures/leaveIdentity.js +6 -2
- package/api/procedures/leaveIdentity.js.map +1 -1
- package/api/procedures/modifySignerPermissions.d.ts.map +1 -1
- package/api/procedures/modifySignerPermissions.js +4 -2
- package/api/procedures/modifySignerPermissions.js.map +1 -1
- package/api/procedures/removeAssetRequirement.js +1 -1
- package/api/procedures/removeAssetRequirement.js.map +1 -1
- package/api/procedures/removeAssetStat.d.ts +16 -0
- package/api/procedures/removeAssetStat.d.ts.map +1 -0
- package/api/procedures/removeAssetStat.js +88 -0
- package/api/procedures/removeAssetStat.js.map +1 -0
- package/api/procedures/removeSecondaryAccounts.d.ts.map +1 -1
- package/api/procedures/removeSecondaryAccounts.js +3 -3
- package/api/procedures/removeSecondaryAccounts.js.map +1 -1
- package/api/procedures/renamePortfolio.js +1 -1
- package/api/procedures/renamePortfolio.js.map +1 -1
- package/api/procedures/setTransferRestrictions.d.ts +1 -8
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
- package/api/procedures/setTransferRestrictions.js +52 -62
- package/api/procedures/setTransferRestrictions.js.map +1 -1
- package/api/procedures/types.d.ts +98 -5
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js +25 -1
- package/api/procedures/types.js.map +1 -1
- package/api/procedures/utils.d.ts.map +1 -1
- package/api/procedures/utils.js +3 -7
- package/api/procedures/utils.js.map +1 -1
- package/base/Context.js +1 -1
- package/base/Procedure.js +1 -1
- package/generated/utils.js +1 -1
- package/generated/utils.js.map +1 -1
- package/internal.d.ts +6 -3
- package/internal.d.ts.map +1 -1
- package/internal.js +8 -4
- package/internal.js.map +1 -1
- package/middleware/queriesV2.d.ts +1 -2
- package/middleware/queriesV2.d.ts.map +1 -1
- package/middleware/queriesV2.js +25 -51
- package/middleware/queriesV2.js.map +1 -1
- package/middleware/typesV2.d.ts +1018 -46
- package/middleware/typesV2.d.ts.map +1 -1
- package/middleware/typesV2.js +686 -2
- package/middleware/typesV2.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.0-alpha.16.tgz +0 -0
- package/package.json +1 -1
- package/types/index.d.ts +114 -3
- package/types/index.d.ts.map +1 -1
- package/types/index.js +10 -3
- package/types/index.js.map +1 -1
- package/types/internal.d.ts +14 -2
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js +2 -0
- package/types/internal.js.map +1 -1
- package/utils/conversion.d.ts +71 -11
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +334 -18
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +55 -7
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +246 -21
- package/utils/internal.js.map +1 -1
- package/api/procedures/createPortfolio.d.ts +0 -21
- package/api/procedures/createPortfolio.d.ts.map +0 -1
- package/api/procedures/createPortfolio.js +0 -64
- package/api/procedures/createPortfolio.js.map +0 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.0-alpha.15.tgz +0 -0
package/utils/conversion.js
CHANGED
|
@@ -17,9 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
20
|
+
exports.u32ToBigNumber = exports.bigNumberToU32 = exports.meshPermissionsToPermissions = exports.extrinsicPermissionsToTransactionPermissions = exports.permissionsToMeshPermissions = exports.transactionPermissionsToExtrinsicPermissions = exports.transactionPermissionsToTxGroups = exports.txGroupToTxTags = exports.textToString = exports.stringToText = exports.portfolioIdToMeshPortfolioId = exports.portfolioLikeToPortfolio = exports.portfolioIdToPortfolio = exports.portfolioLikeToPortfolioId = exports.portfolioToPortfolioId = exports.meshPortfolioIdToPortfolio = exports.claimPercentageToClaimPercentageRestrictionValue = exports.claimCountToClaimCountRestrictionValue = exports.meshClaimToInputStatClaim = exports.permillToBigNumber = exports.percentageToPermill = exports.bigNumberToU128 = exports.bigNumberToU64 = exports.u128ToBigNumber = exports.u64ToBigNumber = exports.signerToString = exports.signerValueToSigner = exports.signerToSignerValue = exports.signatoryToSignerValue = exports.signerValueToSignatory = exports.accountIdToAccount = exports.stringToEcdsaSignature = exports.identityIdToString = exports.stringToIdentityId = exports.stringToBlockHash = exports.stringToHash = exports.hashToString = exports.accountIdToString = exports.stringToAccountId = exports.momentToDate = exports.dateToMoment = exports.stringToInvestorZKProofData = exports.tickerToString = exports.stringToTickerKey = exports.stringToTicker = exports.bytesToString = exports.stringToBytes = exports.boolToBoolean = exports.booleanToBool = exports.tickerToDid = void 0;
|
|
21
|
+
exports.extrinsicIdentifierToTxTag = exports.txTagToExtrinsicIdentifier = exports.txTagToProtocolOp = exports.complianceRequirementToRequirement = exports.complianceRequirementResultToRequirementCompliance = exports.requirementToComplianceRequirement = exports.trustedClaimIssuerToTrustedIssuer = exports.trustedIssuerToTrustedClaimIssuer = exports.meshClaimTypeToClaimType = exports.stringToTargetIdentity = exports.statsClaimToStatClaimInputType = exports.meshClaimToClaim = exports.middlewareV2EventDetailsToEventIdentifier = exports.middlewareEventToEventIdentifier = exports.scopeToMiddlewareScope = exports.middlewareScopeToScope = exports.claimToMeshClaim = exports.scopeIdToString = exports.stringToScopeId = exports.cddIdToString = exports.stringToCddId = exports.meshScopeToScope = exports.scopeToMeshScope = exports.canTransferResultToTransferStatus = exports.cddStatusToBoolean = exports.documentToAssetDocument = exports.assetDocumentToDocument = exports.documentHashToString = exports.stringToDocumentHash = exports.assetIdentifierToSecurityIdentifier = exports.securityIdentifierToAssetIdentifier = exports.isFigiValid = exports.isLeiValid = exports.isCusipValid = exports.isIsinValid = exports.posRatioToBigNumber = exports.assetTypeToKnownOrId = exports.internalAssetTypeToAssetType = exports.u8ToTransferStatus = exports.stringToMemo = exports.authorizationDataToAuthorization = exports.agentGroupToPermissionGroup = exports.balanceToBigNumber = exports.bigNumberToBalance = exports.authorizationTypeToMeshAuthorizationType = exports.authorizationToAuthorizationData = exports.agentGroupToPermissionGroupIdentifier = exports.permissionGroupIdentifierToAgentGroup = exports.u8ToBigNumber = exports.u16ToBigNumber = void 0;
|
|
22
|
+
exports.transferConditionsToBtreeTransferConditions = exports.statisticStatTypesToBtreeStatType = exports.sortStatsByClaimType = exports.statisticsOpTypeToStatType = exports.corporateActionParamsToMeshCorporateActionArgs = exports.corporateActionIdentifierToCaId = exports.distributionToDividendDistributionParams = exports.caTaxWithholdingsToMeshTaxWithholdings = exports.targetsToTargetIdentities = exports.targetIdentitiesToCorporateActionTargets = exports.scopeClaimProofToConfidentialIdentityClaimProof = exports.checkpointToRecordDateSpec = exports.stringToScalar = exports.corporateActionKindToCaKind = exports.stringToRistrettoPoint = exports.meshCorporateActionToCorporateActionParams = exports.stringToSignature = exports.storedScheduleToCheckpointScheduleParams = exports.scheduleSpecToMeshScheduleSpec = exports.meshCalendarPeriodToCalendarPeriod = exports.calendarPeriodToMeshCalendarPeriod = exports.fundraiserToOfferingDetails = exports.fundraiserTierToTier = exports.middlewareV2PortfolioToPortfolio = exports.middlewarePortfolioToPortfolio = exports.permissionsLikeToPermissions = exports.offeringTierToPriceTier = exports.granularCanTransferResultToTransferBreakdown = exports.transferConditionToTransferRestriction = exports.scopeIdsToBtreeSetIdentityId = exports.transferRestrictionToPolymeshTransferCondition = exports.claimIssuerToMeshClaimIssuer = exports.claimTypeToMeshClaimType = exports.portfolioMovementToMovePortfolioItem = exports.toIdentityWithClaimsArrayV2 = exports.middlewareV2ClaimToClaimData = exports.toIdentityWithClaimsArray = exports.endConditionToSettlementType = exports.meshAffirmationStatusToAffirmationStatus = exports.meshInstructionStatusToInstructionStatus = exports.venueTypeToMeshVenueType = exports.meshVenueTypeToVenueType = exports.secondaryAccountToMeshSecondaryKey = exports.transactionToTxTag = exports.transactionHexToTxTag = exports.addressToKey = exports.keyToAddress = exports.moduleAddressToString = exports.assetComplianceResultToCompliance = exports.txTagToExtrinsicIdentifierV2 = void 0;
|
|
23
|
+
exports.inputStatTypeToMeshStatType = exports.countStatInputToStatUpdates = exports.claimCountStatInputToStatUpdates = exports.toExemptKey = exports.complianceConditionsToBtreeSet = exports.sortTransferRestrictionByClaimValue = exports.createStat2ndKey = exports.statTypeToStatOpType = exports.statisticsOpTypeToStatOpType = exports.meshStatToStatisticsOpType = exports.statUpdatesToBtreeStatUpdate = exports.keyAndValueToStatUpdate = void 0;
|
|
23
24
|
const util_1 = require("@polkadot/util");
|
|
24
25
|
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
25
26
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
@@ -294,6 +295,58 @@ function permillToBigNumber(value) {
|
|
|
294
295
|
return new bignumber_js_1.default(value.toString()).shiftedBy(-4); // (value : 10^6) * 100
|
|
295
296
|
}
|
|
296
297
|
exports.permillToBigNumber = permillToBigNumber;
|
|
298
|
+
/**
|
|
299
|
+
* @hidden
|
|
300
|
+
*/
|
|
301
|
+
function meshClaimToInputStatClaim(claim) {
|
|
302
|
+
if (claim.isAccredited) {
|
|
303
|
+
return {
|
|
304
|
+
type: types_2.ClaimType.Accredited,
|
|
305
|
+
accredited: boolToBoolean(claim.asAccredited),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
else if (claim.isAffiliate) {
|
|
309
|
+
return {
|
|
310
|
+
type: types_2.ClaimType.Affiliate,
|
|
311
|
+
affiliate: boolToBoolean(claim.asAffiliate),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
return {
|
|
316
|
+
type: types_2.ClaimType.Jurisdiction,
|
|
317
|
+
countryCode: claim.asJurisdiction.isSome
|
|
318
|
+
? (0, utils_2.meshCountryCodeToCountryCode)(claim.asJurisdiction.unwrap())
|
|
319
|
+
: undefined,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
exports.meshClaimToInputStatClaim = meshClaimToInputStatClaim;
|
|
324
|
+
/**
|
|
325
|
+
* @hidden
|
|
326
|
+
*/
|
|
327
|
+
function claimCountToClaimCountRestrictionValue(value, context) {
|
|
328
|
+
const [claim, issuer, min, max] = value;
|
|
329
|
+
return {
|
|
330
|
+
claim: meshClaimToInputStatClaim(claim),
|
|
331
|
+
issuer: new internal_1.Identity({ did: identityIdToString(issuer) }, context),
|
|
332
|
+
min: u64ToBigNumber(min),
|
|
333
|
+
max: max.isSome ? u64ToBigNumber(max.unwrap()) : undefined,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
exports.claimCountToClaimCountRestrictionValue = claimCountToClaimCountRestrictionValue;
|
|
337
|
+
/**
|
|
338
|
+
* @hidden
|
|
339
|
+
*/
|
|
340
|
+
function claimPercentageToClaimPercentageRestrictionValue(value, context) {
|
|
341
|
+
const [claim, issuer, min, max] = value;
|
|
342
|
+
return {
|
|
343
|
+
claim: meshClaimToInputStatClaim(claim),
|
|
344
|
+
issuer: new internal_1.Identity({ did: identityIdToString(issuer) }, context),
|
|
345
|
+
min: permillToBigNumber(min),
|
|
346
|
+
max: permillToBigNumber(max),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
exports.claimPercentageToClaimPercentageRestrictionValue = claimPercentageToClaimPercentageRestrictionValue;
|
|
297
350
|
/**
|
|
298
351
|
* @hidden
|
|
299
352
|
*/
|
|
@@ -1014,7 +1067,7 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1014
1067
|
}
|
|
1015
1068
|
throw new internal_1.PolymeshError({
|
|
1016
1069
|
code: types_2.ErrorCode.UnexpectedError,
|
|
1017
|
-
message: 'Unsupported Authorization Type. Please contact the
|
|
1070
|
+
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
1018
1071
|
data: {
|
|
1019
1072
|
auth: JSON.stringify(auth, null, 2),
|
|
1020
1073
|
},
|
|
@@ -1109,7 +1162,7 @@ function u8ToTransferStatus(status) {
|
|
|
1109
1162
|
default: {
|
|
1110
1163
|
throw new internal_1.PolymeshError({
|
|
1111
1164
|
code: types_2.ErrorCode.UnexpectedError,
|
|
1112
|
-
message: `Unsupported status code "${status.toString()}". Please report this issue to the
|
|
1165
|
+
message: `Unsupported status code "${status.toString()}". Please report this issue to the Polymesh team`,
|
|
1113
1166
|
});
|
|
1114
1167
|
}
|
|
1115
1168
|
}
|
|
@@ -1718,6 +1771,23 @@ function meshClaimToClaim(claim) {
|
|
|
1718
1771
|
};
|
|
1719
1772
|
}
|
|
1720
1773
|
exports.meshClaimToClaim = meshClaimToClaim;
|
|
1774
|
+
/**
|
|
1775
|
+
* @hidden
|
|
1776
|
+
*/
|
|
1777
|
+
function statsClaimToStatClaimInputType(claim) {
|
|
1778
|
+
if (claim.isJurisdiction) {
|
|
1779
|
+
return {
|
|
1780
|
+
type: types_2.ClaimType.Jurisdiction,
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
else if (claim.isAccredited) {
|
|
1784
|
+
return { type: types_2.ClaimType.Accredited };
|
|
1785
|
+
}
|
|
1786
|
+
else {
|
|
1787
|
+
return { type: types_2.ClaimType.Affiliate };
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
exports.statsClaimToStatClaimInputType = statsClaimToStatClaimInputType;
|
|
1721
1791
|
/**
|
|
1722
1792
|
* @hidden
|
|
1723
1793
|
*/
|
|
@@ -2008,6 +2078,17 @@ function extrinsicIdentifierToTxTag(extrinsicIdentifier) {
|
|
|
2008
2078
|
return `${moduleName}.${(0, lodash_1.camelCase)(callId)}`;
|
|
2009
2079
|
}
|
|
2010
2080
|
exports.extrinsicIdentifierToTxTag = extrinsicIdentifierToTxTag;
|
|
2081
|
+
/**
|
|
2082
|
+
* @hidden
|
|
2083
|
+
*/
|
|
2084
|
+
function txTagToExtrinsicIdentifierV2(tag) {
|
|
2085
|
+
const [moduleName, extrinsicName] = tag.split('.');
|
|
2086
|
+
return {
|
|
2087
|
+
moduleId: moduleName.toLowerCase(),
|
|
2088
|
+
callId: (0, lodash_1.snakeCase)(extrinsicName),
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
exports.txTagToExtrinsicIdentifierV2 = txTagToExtrinsicIdentifierV2;
|
|
2011
2092
|
/**
|
|
2012
2093
|
* @hidden
|
|
2013
2094
|
*/
|
|
@@ -2200,6 +2281,15 @@ function claimTypeToMeshClaimType(claimType, context) {
|
|
|
2200
2281
|
return context.createType('PolymeshPrimitivesIdentityClaimClaimType', data);
|
|
2201
2282
|
}
|
|
2202
2283
|
exports.claimTypeToMeshClaimType = claimTypeToMeshClaimType;
|
|
2284
|
+
/**
|
|
2285
|
+
* @hidden
|
|
2286
|
+
*/
|
|
2287
|
+
function claimIssuerToMeshClaimIssuer(claimIssuer, context) {
|
|
2288
|
+
const claimType = claimTypeToMeshClaimType(claimIssuer.claimType, context);
|
|
2289
|
+
const identityId = stringToIdentityId(claimIssuer.issuer.did, context);
|
|
2290
|
+
return [claimType, identityId];
|
|
2291
|
+
}
|
|
2292
|
+
exports.claimIssuerToMeshClaimIssuer = claimIssuerToMeshClaimIssuer;
|
|
2203
2293
|
/**
|
|
2204
2294
|
* @hidden
|
|
2205
2295
|
*/
|
|
@@ -2207,14 +2297,54 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2207
2297
|
const { type, value } = restriction;
|
|
2208
2298
|
let restrictionType;
|
|
2209
2299
|
let restrictionValue;
|
|
2300
|
+
const extractClaimValue = (claim) => {
|
|
2301
|
+
if (claim.type === types_2.ClaimType.Accredited) {
|
|
2302
|
+
return booleanToBool(claim.accredited, context);
|
|
2303
|
+
}
|
|
2304
|
+
else if (claim.type === types_2.ClaimType.Affiliate) {
|
|
2305
|
+
return booleanToBool(claim.affiliate, context);
|
|
2306
|
+
}
|
|
2307
|
+
else {
|
|
2308
|
+
return (0, internal_3.optionize)(utils_2.countryCodeToMeshCountryCode)(claim.countryCode, context);
|
|
2309
|
+
}
|
|
2310
|
+
};
|
|
2210
2311
|
if (type === types_2.TransferRestrictionType.Count) {
|
|
2211
2312
|
restrictionType = 'MaxInvestorCount';
|
|
2212
2313
|
restrictionValue = bigNumberToU64(value, context);
|
|
2213
2314
|
}
|
|
2214
|
-
else {
|
|
2315
|
+
else if (type === types_2.TransferRestrictionType.Percentage) {
|
|
2215
2316
|
restrictionType = 'MaxInvestorOwnership';
|
|
2216
2317
|
restrictionValue = percentageToPermill(value, context);
|
|
2217
2318
|
}
|
|
2319
|
+
else if (type === types_2.TransferRestrictionType.ClaimCount ||
|
|
2320
|
+
type === types_2.TransferRestrictionType.ClaimPercentage) {
|
|
2321
|
+
let rawMin;
|
|
2322
|
+
let rawMax;
|
|
2323
|
+
const { min, max, claim, issuer } = value;
|
|
2324
|
+
if (type === types_2.TransferRestrictionType.ClaimCount) {
|
|
2325
|
+
restrictionType = 'ClaimCount';
|
|
2326
|
+
rawMin = bigNumberToU64(min, context);
|
|
2327
|
+
rawMax = (0, internal_3.optionize)(bigNumberToU64)(max, context);
|
|
2328
|
+
}
|
|
2329
|
+
else {
|
|
2330
|
+
// i.e. TransferRestrictionType.ClaimPercentage
|
|
2331
|
+
restrictionType = 'ClaimOwnership';
|
|
2332
|
+
rawMin = percentageToPermill(min, context);
|
|
2333
|
+
rawMax = percentageToPermill(value.max, context);
|
|
2334
|
+
}
|
|
2335
|
+
const val = extractClaimValue(claim);
|
|
2336
|
+
const claimValue = {
|
|
2337
|
+
[claim.type]: val,
|
|
2338
|
+
};
|
|
2339
|
+
const rawIdentityId = stringToIdentityId(issuer.did, context);
|
|
2340
|
+
restrictionValue = [claimValue, rawIdentityId, rawMin, rawMax];
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
throw new internal_1.PolymeshError({
|
|
2344
|
+
code: types_2.ErrorCode.UnexpectedError,
|
|
2345
|
+
message: `Unexpected transfer restriction type: "${type}". Please report this to the Polymesh team`,
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2218
2348
|
return context.createType('PolymeshPrimitivesTransferComplianceTransferCondition', {
|
|
2219
2349
|
[restrictionType]: restrictionValue,
|
|
2220
2350
|
});
|
|
@@ -2230,7 +2360,7 @@ exports.scopeIdsToBtreeSetIdentityId = scopeIdsToBtreeSetIdentityId;
|
|
|
2230
2360
|
/**
|
|
2231
2361
|
* @hidden
|
|
2232
2362
|
*/
|
|
2233
|
-
function transferConditionToTransferRestriction(transferCondition) {
|
|
2363
|
+
function transferConditionToTransferRestriction(transferCondition, context) {
|
|
2234
2364
|
if (transferCondition.isMaxInvestorCount) {
|
|
2235
2365
|
return {
|
|
2236
2366
|
type: types_2.TransferRestrictionType.Count,
|
|
@@ -2243,6 +2373,18 @@ function transferConditionToTransferRestriction(transferCondition) {
|
|
|
2243
2373
|
value: permillToBigNumber(transferCondition.asMaxInvestorOwnership),
|
|
2244
2374
|
};
|
|
2245
2375
|
}
|
|
2376
|
+
else if (transferCondition.isClaimCount) {
|
|
2377
|
+
return {
|
|
2378
|
+
type: types_2.TransferRestrictionType.ClaimCount,
|
|
2379
|
+
value: claimCountToClaimCountRestrictionValue(transferCondition.asClaimCount, context),
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
else if (transferCondition.isClaimOwnership) {
|
|
2383
|
+
return {
|
|
2384
|
+
type: types_2.TransferRestrictionType.ClaimPercentage,
|
|
2385
|
+
value: claimPercentageToClaimPercentageRestrictionValue(transferCondition.asClaimOwnership, context),
|
|
2386
|
+
};
|
|
2387
|
+
}
|
|
2246
2388
|
else {
|
|
2247
2389
|
throw new internal_1.PolymeshError({
|
|
2248
2390
|
code: types_2.ErrorCode.FatalError,
|
|
@@ -2289,7 +2431,7 @@ function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
|
2289
2431
|
}
|
|
2290
2432
|
const restrictions = transferConditionResult.map(({ condition, result: tmResult }) => {
|
|
2291
2433
|
return {
|
|
2292
|
-
restriction: transferConditionToTransferRestriction(condition),
|
|
2434
|
+
restriction: transferConditionToTransferRestriction(condition, context),
|
|
2293
2435
|
result: boolToBoolean(tmResult),
|
|
2294
2436
|
};
|
|
2295
2437
|
});
|
|
@@ -2744,15 +2886,41 @@ exports.corporateActionParamsToMeshCorporateActionArgs = corporateActionParamsTo
|
|
|
2744
2886
|
/**
|
|
2745
2887
|
* @hidden
|
|
2746
2888
|
*/
|
|
2747
|
-
function statisticsOpTypeToStatType(
|
|
2748
|
-
|
|
2889
|
+
function statisticsOpTypeToStatType(args, context) {
|
|
2890
|
+
const { op, claimIssuer } = args;
|
|
2891
|
+
return context.createType('PolymeshPrimitivesStatisticsStatType', { op, claimIssuer });
|
|
2749
2892
|
}
|
|
2750
2893
|
exports.statisticsOpTypeToStatType = statisticsOpTypeToStatType;
|
|
2894
|
+
/**
|
|
2895
|
+
* @hidden
|
|
2896
|
+
*
|
|
2897
|
+
* The chain requires BTreeSets to be sorted, Polkadot.js will shallow sort elements when calling `createType`,
|
|
2898
|
+
* however it will not look deeper at claimType. This function works around this short fall by sorting based on `claimType`
|
|
2899
|
+
* `createType` built in sorting is relied on otherwise.
|
|
2900
|
+
*/
|
|
2901
|
+
function sortStatsByClaimType(stats) {
|
|
2902
|
+
return [...stats].sort((a, b) => {
|
|
2903
|
+
if (a.claimIssuer.isNone && b.claimIssuer.isNone) {
|
|
2904
|
+
return 0;
|
|
2905
|
+
}
|
|
2906
|
+
if (a.claimIssuer.isNone) {
|
|
2907
|
+
return 1;
|
|
2908
|
+
}
|
|
2909
|
+
if (b.claimIssuer.isNone) {
|
|
2910
|
+
return -1;
|
|
2911
|
+
}
|
|
2912
|
+
const [aClaim] = a.claimIssuer.unwrap();
|
|
2913
|
+
const [bClaim] = b.claimIssuer.unwrap();
|
|
2914
|
+
return aClaim.index - bClaim.index;
|
|
2915
|
+
});
|
|
2916
|
+
}
|
|
2917
|
+
exports.sortStatsByClaimType = sortStatsByClaimType;
|
|
2751
2918
|
/**
|
|
2752
2919
|
* @hidden
|
|
2753
2920
|
*/
|
|
2754
2921
|
function statisticStatTypesToBtreeStatType(stats, context) {
|
|
2755
|
-
|
|
2922
|
+
const sortedStats = sortStatsByClaimType(stats);
|
|
2923
|
+
return context.createType('BTreeSet<PolymeshPrimitivesStatisticsStatType>', sortedStats);
|
|
2756
2924
|
}
|
|
2757
2925
|
exports.statisticStatTypesToBtreeStatType = statisticStatTypesToBtreeStatType;
|
|
2758
2926
|
/**
|
|
@@ -2765,10 +2933,10 @@ exports.transferConditionsToBtreeTransferConditions = transferConditionsToBtreeT
|
|
|
2765
2933
|
/**
|
|
2766
2934
|
* @hidden
|
|
2767
2935
|
*/
|
|
2768
|
-
function
|
|
2936
|
+
function keyAndValueToStatUpdate(key2, value, context) {
|
|
2769
2937
|
return context.createType('PolymeshPrimitivesStatisticsStatUpdate', { key2, value });
|
|
2770
2938
|
}
|
|
2771
|
-
exports.
|
|
2939
|
+
exports.keyAndValueToStatUpdate = keyAndValueToStatUpdate;
|
|
2772
2940
|
/**
|
|
2773
2941
|
* @hidden
|
|
2774
2942
|
*/
|
|
@@ -2780,7 +2948,17 @@ exports.statUpdatesToBtreeStatUpdate = statUpdatesToBtreeStatUpdate;
|
|
|
2780
2948
|
* @hidden
|
|
2781
2949
|
*/
|
|
2782
2950
|
function meshStatToStatisticsOpType(rawStat) {
|
|
2783
|
-
|
|
2951
|
+
if (rawStat.claimIssuer.isNone) {
|
|
2952
|
+
return rawStat.op.type;
|
|
2953
|
+
}
|
|
2954
|
+
else {
|
|
2955
|
+
if (rawStat.op.type === 'Count') {
|
|
2956
|
+
return internal_2.StatisticsOpType.ClaimCount;
|
|
2957
|
+
}
|
|
2958
|
+
else {
|
|
2959
|
+
return internal_2.StatisticsOpType.ClaimPercentage;
|
|
2960
|
+
}
|
|
2961
|
+
}
|
|
2784
2962
|
}
|
|
2785
2963
|
exports.meshStatToStatisticsOpType = meshStatToStatisticsOpType;
|
|
2786
2964
|
/**
|
|
@@ -2791,18 +2969,100 @@ function statisticsOpTypeToStatOpType(type, context) {
|
|
|
2791
2969
|
}
|
|
2792
2970
|
exports.statisticsOpTypeToStatOpType = statisticsOpTypeToStatOpType;
|
|
2793
2971
|
/**
|
|
2794
|
-
* For now this is hard coded to return a NoClaimStat type. Once Claim scopes are added this should be extended
|
|
2795
2972
|
* @hidden
|
|
2796
2973
|
*/
|
|
2797
|
-
function
|
|
2798
|
-
|
|
2974
|
+
function statTypeToStatOpType(type, context) {
|
|
2975
|
+
if (type === types_2.StatType.Count || type === types_2.StatType.ScopedCount) {
|
|
2976
|
+
return statisticsOpTypeToStatOpType(internal_2.StatisticsOpType.Count, context);
|
|
2977
|
+
}
|
|
2978
|
+
else {
|
|
2979
|
+
return statisticsOpTypeToStatOpType(internal_2.StatisticsOpType.Balance, context);
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
exports.statTypeToStatOpType = statTypeToStatOpType;
|
|
2983
|
+
/**
|
|
2984
|
+
* Scoped stats are a map of maps, e.g. Jurisdiction has a counter for each CountryCode. a 2ndKey specifies what Country count to use
|
|
2985
|
+
* @hidden
|
|
2986
|
+
*/
|
|
2987
|
+
function createStat2ndKey(type, context, claimStat) {
|
|
2988
|
+
if (type === 'NoClaimStat') {
|
|
2989
|
+
return context.createType('PolymeshPrimitivesStatisticsStat2ndKey', type);
|
|
2990
|
+
}
|
|
2991
|
+
else {
|
|
2992
|
+
let value;
|
|
2993
|
+
if (claimStat === 'yes') {
|
|
2994
|
+
value = true;
|
|
2995
|
+
}
|
|
2996
|
+
else if (claimStat === 'no') {
|
|
2997
|
+
value = false;
|
|
2998
|
+
}
|
|
2999
|
+
else {
|
|
3000
|
+
value = claimStat;
|
|
3001
|
+
}
|
|
3002
|
+
return context.createType('PolymeshPrimitivesStatisticsStat2ndKey', {
|
|
3003
|
+
claim: { [type]: value },
|
|
3004
|
+
});
|
|
3005
|
+
}
|
|
2799
3006
|
}
|
|
2800
3007
|
exports.createStat2ndKey = createStat2ndKey;
|
|
3008
|
+
/**
|
|
3009
|
+
* @hidden
|
|
3010
|
+
* The chain requires BTreeSets to be sorted. While polkadot.js createType will provide shallow sorting
|
|
3011
|
+
* it fails to consider the nested CountryCode values. This works around the shortfall, but relies on `createType`
|
|
3012
|
+
* sorting for otherwise
|
|
3013
|
+
*/
|
|
3014
|
+
function sortTransferRestrictionByClaimValue(conditions) {
|
|
3015
|
+
const getJurisdictionValue = (condition) => {
|
|
3016
|
+
const { isClaimCount, isClaimOwnership } = condition;
|
|
3017
|
+
if (isClaimCount) {
|
|
3018
|
+
if (!condition.asClaimCount[0].isJurisdiction) {
|
|
3019
|
+
return undefined;
|
|
3020
|
+
}
|
|
3021
|
+
else {
|
|
3022
|
+
return condition.asClaimCount[0].asJurisdiction;
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
else if (isClaimOwnership) {
|
|
3026
|
+
if (!condition.asClaimOwnership[0].isJurisdiction) {
|
|
3027
|
+
return undefined;
|
|
3028
|
+
}
|
|
3029
|
+
return condition.asClaimOwnership[0].asJurisdiction;
|
|
3030
|
+
}
|
|
3031
|
+
else {
|
|
3032
|
+
return undefined;
|
|
3033
|
+
}
|
|
3034
|
+
};
|
|
3035
|
+
return [...conditions].sort((a, b) => {
|
|
3036
|
+
const aClaim = getJurisdictionValue(a);
|
|
3037
|
+
if (!aClaim) {
|
|
3038
|
+
return 1;
|
|
3039
|
+
}
|
|
3040
|
+
const bClaim = getJurisdictionValue(b);
|
|
3041
|
+
if (!bClaim) {
|
|
3042
|
+
return -1;
|
|
3043
|
+
}
|
|
3044
|
+
if (aClaim.isNone && bClaim.isNone) {
|
|
3045
|
+
return 0;
|
|
3046
|
+
}
|
|
3047
|
+
if (aClaim.isNone) {
|
|
3048
|
+
return -1;
|
|
3049
|
+
}
|
|
3050
|
+
if (bClaim.isNone) {
|
|
3051
|
+
return 1;
|
|
3052
|
+
}
|
|
3053
|
+
const aCode = (0, utils_2.meshCountryCodeToCountryCode)(aClaim.unwrap());
|
|
3054
|
+
const bCode = (0, utils_2.meshCountryCodeToCountryCode)(bClaim.unwrap());
|
|
3055
|
+
const countryOrder = Object.values(types_2.CountryCode);
|
|
3056
|
+
return countryOrder.indexOf(aCode) - countryOrder.indexOf(bCode);
|
|
3057
|
+
});
|
|
3058
|
+
}
|
|
3059
|
+
exports.sortTransferRestrictionByClaimValue = sortTransferRestrictionByClaimValue;
|
|
2801
3060
|
/**
|
|
2802
3061
|
* @hidden
|
|
2803
3062
|
*/
|
|
2804
3063
|
function complianceConditionsToBtreeSet(conditions, context) {
|
|
2805
|
-
|
|
3064
|
+
const sortedConditions = sortTransferRestrictionByClaimValue(conditions);
|
|
3065
|
+
return context.createType('BTreeSet<PolymeshPrimitivesTransferComplianceTransferCondition> ', sortedConditions);
|
|
2806
3066
|
}
|
|
2807
3067
|
exports.complianceConditionsToBtreeSet = complianceConditionsToBtreeSet;
|
|
2808
3068
|
/**
|
|
@@ -2812,4 +3072,60 @@ function toExemptKey(tickerKey, op) {
|
|
|
2812
3072
|
return { asset: tickerKey, op };
|
|
2813
3073
|
}
|
|
2814
3074
|
exports.toExemptKey = toExemptKey;
|
|
3075
|
+
/**
|
|
3076
|
+
* @hidden
|
|
3077
|
+
*/
|
|
3078
|
+
function claimCountStatInputToStatUpdates(args, context) {
|
|
3079
|
+
const { value, claimType: type } = args;
|
|
3080
|
+
let updateArgs;
|
|
3081
|
+
if (type === types_2.ClaimType.Jurisdiction) {
|
|
3082
|
+
updateArgs = value.map(({ countryCode, count }) => {
|
|
3083
|
+
const rawSecondKey = createStat2ndKey(type, context, countryCode);
|
|
3084
|
+
return keyAndValueToStatUpdate(rawSecondKey, bigNumberToU128(count, context), context);
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
else {
|
|
3088
|
+
let yes, no;
|
|
3089
|
+
if (type === types_2.ClaimType.Accredited) {
|
|
3090
|
+
({ accredited: yes, nonAccredited: no } = value);
|
|
3091
|
+
}
|
|
3092
|
+
else {
|
|
3093
|
+
({ affiliate: yes, nonAffiliate: no } = value);
|
|
3094
|
+
}
|
|
3095
|
+
const yes2ndKey = createStat2ndKey(type, context, 'yes');
|
|
3096
|
+
const yesCount = bigNumberToU128(yes, context);
|
|
3097
|
+
const no2ndKey = createStat2ndKey(type, context, 'no');
|
|
3098
|
+
const noCount = bigNumberToU128(no, context);
|
|
3099
|
+
updateArgs = [
|
|
3100
|
+
keyAndValueToStatUpdate(yes2ndKey, yesCount, context),
|
|
3101
|
+
keyAndValueToStatUpdate(no2ndKey, noCount, context),
|
|
3102
|
+
];
|
|
3103
|
+
}
|
|
3104
|
+
return statUpdatesToBtreeStatUpdate(updateArgs, context);
|
|
3105
|
+
}
|
|
3106
|
+
exports.claimCountStatInputToStatUpdates = claimCountStatInputToStatUpdates;
|
|
3107
|
+
/**
|
|
3108
|
+
* @hidden
|
|
3109
|
+
* transforms a non scoped count stat to a StatUpdate type
|
|
3110
|
+
*/
|
|
3111
|
+
function countStatInputToStatUpdates(args, context) {
|
|
3112
|
+
const { count } = args;
|
|
3113
|
+
const secondKey = createStat2ndKey('NoClaimStat', context);
|
|
3114
|
+
const stat = keyAndValueToStatUpdate(secondKey, bigNumberToU128(count, context), context);
|
|
3115
|
+
return statUpdatesToBtreeStatUpdate([stat], context);
|
|
3116
|
+
}
|
|
3117
|
+
exports.countStatInputToStatUpdates = countStatInputToStatUpdates;
|
|
3118
|
+
/**
|
|
3119
|
+
* @hidden
|
|
3120
|
+
*/
|
|
3121
|
+
function inputStatTypeToMeshStatType(input, context) {
|
|
3122
|
+
const { type } = input;
|
|
3123
|
+
const op = statTypeToStatOpType(type, context);
|
|
3124
|
+
let claimIssuer;
|
|
3125
|
+
if (type === types_2.StatType.ScopedCount || type === types_2.StatType.ScopedPercentage) {
|
|
3126
|
+
claimIssuer = claimIssuerToMeshClaimIssuer(input.claimIssuer, context);
|
|
3127
|
+
}
|
|
3128
|
+
return statisticsOpTypeToStatType({ op, claimIssuer }, context);
|
|
3129
|
+
}
|
|
3130
|
+
exports.inputStatTypeToMeshStatType = inputStatTypeToMeshStatType;
|
|
2815
3131
|
//# sourceMappingURL=conversion.js.map
|