@polymeshassociation/polymesh-sdk 15.0.0-alpha.13 → 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 +22 -5
- package/api/client/Assets.d.ts +7 -1
- package/api/client/Assets.d.ts.map +1 -1
- package/api/client/Assets.js +18 -0
- package/api/client/Assets.js.map +1 -1
- package/api/client/Claims.d.ts +60 -1
- package/api/client/Claims.d.ts.map +1 -1
- package/api/client/Claims.js +130 -3
- 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 +51 -0
- package/api/client/Network.d.ts.map +1 -1
- package/api/client/Network.js +106 -0
- package/api/client/Network.js.map +1 -1
- package/api/client/Polymesh.d.ts +1 -0
- package/api/client/Polymesh.d.ts.map +1 -1
- package/api/client/Polymesh.js +33 -28
- package/api/client/Polymesh.js.map +1 -1
- package/api/entities/Account.d.ts +22 -0
- package/api/entities/Account.d.ts.map +1 -1
- package/api/entities/Account.js +71 -5
- 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 +41 -6
- 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/Asset/index.d.ts +15 -0
- package/api/entities/Asset/index.d.ts.map +1 -1
- package/api/entities/Asset/index.js +38 -0
- package/api/entities/Asset/index.js.map +1 -1
- package/api/entities/CorporateActionBase/index.js +1 -1
- package/api/entities/CorporateActionBase/index.js.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.d.ts +7 -0
- package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.js +17 -0
- package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -1
- package/api/entities/DividendDistribution/index.d.ts +16 -0
- package/api/entities/DividendDistribution/index.d.ts.map +1 -1
- package/api/entities/DividendDistribution/index.js +69 -0
- package/api/entities/DividendDistribution/index.js.map +1 -1
- package/api/entities/Identity/AssetPermissions.d.ts +29 -0
- package/api/entities/Identity/AssetPermissions.d.ts.map +1 -1
- package/api/entities/Identity/AssetPermissions.js +53 -1
- package/api/entities/Identity/AssetPermissions.js.map +1 -1
- package/api/entities/Identity/index.d.ts +23 -4
- package/api/entities/Identity/index.d.ts.map +1 -1
- package/api/entities/Identity/index.js +68 -23
- package/api/entities/Identity/index.js.map +1 -1
- package/api/entities/Instruction/index.d.ts +11 -0
- package/api/entities/Instruction/index.d.ts.map +1 -1
- package/api/entities/Instruction/index.js +51 -0
- package/api/entities/Instruction/index.js.map +1 -1
- package/api/entities/NumberedPortfolio.d.ts +7 -0
- package/api/entities/NumberedPortfolio.d.ts.map +1 -1
- package/api/entities/NumberedPortfolio.js +17 -0
- package/api/entities/NumberedPortfolio.js.map +1 -1
- package/api/entities/Offering/index.d.ts +13 -0
- package/api/entities/Offering/index.d.ts.map +1 -1
- package/api/entities/Offering/index.js +32 -0
- package/api/entities/Offering/index.js.map +1 -1
- package/api/entities/Portfolio/index.d.ts +12 -0
- package/api/entities/Portfolio/index.d.ts.map +1 -1
- package/api/entities/Portfolio/index.js +94 -5
- package/api/entities/Portfolio/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 -15
- package/api/procedures/addTransferRestriction.d.ts.map +1 -1
- package/api/procedures/addTransferRestriction.js +43 -87
- 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 -7
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
- package/api/procedures/setTransferRestrictions.js +51 -64
- 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.d.ts +61 -0
- package/base/Context.d.ts.map +1 -1
- package/base/Context.js +150 -5
- package/base/Context.js.map +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 +142 -0
- package/middleware/queriesV2.d.ts.map +1 -0
- package/middleware/queriesV2.js +772 -0
- package/middleware/queriesV2.js.map +1 -0
- package/middleware/typesV2.d.ts +26467 -0
- package/middleware/typesV2.d.ts.map +1 -0
- package/middleware/typesV2.js +2697 -0
- package/middleware/typesV2.js.map +1 -0
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.0-alpha.16.tgz +0 -0
- package/package.json +54 -58
- package/polkadot/augment-api-events.d.ts +135 -34
- package/polkadot/augment-api-events.d.ts.map +1 -1
- package/polkadot/augment-api-query.d.ts +4 -7
- package/polkadot/augment-api-query.d.ts.map +1 -1
- package/polkadot/augment-api-rpc.d.ts +6 -2
- package/polkadot/augment-api-rpc.d.ts.map +1 -1
- package/polkadot/augment-api-tx.d.ts +25 -67
- package/polkadot/augment-api-tx.d.ts.map +1 -1
- package/polkadot/augment-types.d.ts +8 -6
- package/polkadot/augment-types.d.ts.map +1 -1
- package/polkadot/lookup.d.ts +0 -32
- package/polkadot/lookup.d.ts.map +1 -1
- package/polkadot/lookup.js +13 -45
- package/polkadot/lookup.js.map +1 -1
- package/polkadot/registry.d.ts +1 -9
- package/polkadot/registry.d.ts.map +1 -1
- package/polkadot/types-lookup.d.ts +14 -38
- package/polkadot/types-lookup.d.ts.map +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/types/utils/index.d.ts +14 -0
- package/types/utils/index.d.ts.map +1 -1
- package/types/utils/index.js.map +1 -1
- package/utils/conversion.d.ts +101 -15
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +410 -30
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +58 -5
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +252 -17
- 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.13.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
|
*/
|
|
@@ -692,7 +745,7 @@ function extrinsicPermissionsToTransactionPermissions(permissions) {
|
|
|
692
745
|
pallets.forEach(({ palletName, dispatchableNames }) => {
|
|
693
746
|
const moduleName = (0, util_1.stringLowerFirst)(bytesToString(palletName));
|
|
694
747
|
if (dispatchableNames.isExcept) {
|
|
695
|
-
const dispatchables = dispatchableNames.asExcept;
|
|
748
|
+
const dispatchables = [...dispatchableNames.asExcept];
|
|
696
749
|
exceptions = [
|
|
697
750
|
...exceptions,
|
|
698
751
|
...dispatchables.map(name => formatTxTag(bytesToString(name), moduleName)),
|
|
@@ -700,7 +753,7 @@ function extrinsicPermissionsToTransactionPermissions(permissions) {
|
|
|
700
753
|
txValues = [...txValues, moduleName];
|
|
701
754
|
}
|
|
702
755
|
else if (dispatchableNames.isThese) {
|
|
703
|
-
const dispatchables = dispatchableNames.asThese;
|
|
756
|
+
const dispatchables = [...dispatchableNames.asThese];
|
|
704
757
|
txValues = [
|
|
705
758
|
...txValues,
|
|
706
759
|
...dispatchables.map(name => formatTxTag(bytesToString(name), moduleName)),
|
|
@@ -740,7 +793,7 @@ function meshPermissionsToPermissions(permissions, context) {
|
|
|
740
793
|
}
|
|
741
794
|
if (assetsPermissions) {
|
|
742
795
|
assets = {
|
|
743
|
-
values: assetsPermissions.map(ticker => new internal_1.Asset({ ticker: tickerToString(ticker) }, context)),
|
|
796
|
+
values: [...assetsPermissions].map(ticker => new internal_1.Asset({ ticker: tickerToString(ticker) }, context)),
|
|
744
797
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
745
798
|
type: assetsType,
|
|
746
799
|
};
|
|
@@ -758,7 +811,7 @@ function meshPermissionsToPermissions(permissions, context) {
|
|
|
758
811
|
}
|
|
759
812
|
if (portfolioIds) {
|
|
760
813
|
portfolios = {
|
|
761
|
-
values: portfolioIds.map(portfolioId => meshPortfolioIdToPortfolio(portfolioId, context)),
|
|
814
|
+
values: [...portfolioIds].map(portfolioId => meshPortfolioIdToPortfolio(portfolioId, context)),
|
|
762
815
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
763
816
|
type: portfoliosType,
|
|
764
817
|
};
|
|
@@ -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
|
}
|
|
@@ -1596,11 +1649,14 @@ exports.middlewareScopeToScope = middlewareScopeToScope;
|
|
|
1596
1649
|
/**
|
|
1597
1650
|
* @hidden
|
|
1598
1651
|
*/
|
|
1599
|
-
function scopeToMiddlewareScope(scope) {
|
|
1652
|
+
function scopeToMiddlewareScope(scope, padTicker = true) {
|
|
1600
1653
|
const { type, value } = scope;
|
|
1601
1654
|
switch (type) {
|
|
1602
1655
|
case types_2.ScopeType.Ticker:
|
|
1603
|
-
return {
|
|
1656
|
+
return {
|
|
1657
|
+
type: types_1.ClaimScopeTypeEnum.Ticker,
|
|
1658
|
+
value: padTicker ? (0, lodash_1.padEnd)(value, 12, '\0') : value,
|
|
1659
|
+
};
|
|
1604
1660
|
case types_2.ScopeType.Identity:
|
|
1605
1661
|
case types_2.ScopeType.Custom:
|
|
1606
1662
|
return { type: types_1.ClaimScopeTypeEnum[scope.type], value };
|
|
@@ -1622,6 +1678,19 @@ function middlewareEventToEventIdentifier(event) {
|
|
|
1622
1678
|
};
|
|
1623
1679
|
}
|
|
1624
1680
|
exports.middlewareEventToEventIdentifier = middlewareEventToEventIdentifier;
|
|
1681
|
+
/**
|
|
1682
|
+
* @hidden
|
|
1683
|
+
*/
|
|
1684
|
+
function middlewareV2EventDetailsToEventIdentifier(block, eventIdx = 0) {
|
|
1685
|
+
const { blockId, datetime, hash } = block;
|
|
1686
|
+
return {
|
|
1687
|
+
blockNumber: new bignumber_js_1.default(blockId),
|
|
1688
|
+
blockHash: hash,
|
|
1689
|
+
blockDate: new Date(`${datetime}`),
|
|
1690
|
+
eventIndex: new bignumber_js_1.default(eventIdx),
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
exports.middlewareV2EventDetailsToEventIdentifier = middlewareV2EventDetailsToEventIdentifier;
|
|
1625
1694
|
/**
|
|
1626
1695
|
* @hidden
|
|
1627
1696
|
*/
|
|
@@ -1702,6 +1771,23 @@ function meshClaimToClaim(claim) {
|
|
|
1702
1771
|
};
|
|
1703
1772
|
}
|
|
1704
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;
|
|
1705
1791
|
/**
|
|
1706
1792
|
* @hidden
|
|
1707
1793
|
*/
|
|
@@ -1992,6 +2078,17 @@ function extrinsicIdentifierToTxTag(extrinsicIdentifier) {
|
|
|
1992
2078
|
return `${moduleName}.${(0, lodash_1.camelCase)(callId)}`;
|
|
1993
2079
|
}
|
|
1994
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;
|
|
1995
2092
|
/**
|
|
1996
2093
|
* @hidden
|
|
1997
2094
|
*/
|
|
@@ -2015,6 +2112,9 @@ exports.moduleAddressToString = moduleAddressToString;
|
|
|
2015
2112
|
* @hidden
|
|
2016
2113
|
*/
|
|
2017
2114
|
function keyToAddress(key, context) {
|
|
2115
|
+
if (!key.startsWith('0x')) {
|
|
2116
|
+
key = `0x${key}`;
|
|
2117
|
+
}
|
|
2018
2118
|
return (0, util_crypto_1.encodeAddress)(key, context.ss58Format.toNumber());
|
|
2019
2119
|
}
|
|
2020
2120
|
exports.keyToAddress = keyToAddress;
|
|
@@ -2135,6 +2235,31 @@ function toIdentityWithClaimsArray(data, context) {
|
|
|
2135
2235
|
}));
|
|
2136
2236
|
}
|
|
2137
2237
|
exports.toIdentityWithClaimsArray = toIdentityWithClaimsArray;
|
|
2238
|
+
/**
|
|
2239
|
+
* @hidden
|
|
2240
|
+
*/
|
|
2241
|
+
function middlewareV2ClaimToClaimData(claim, context) {
|
|
2242
|
+
const { targetId, issuerId, issuanceDate, expiry, type, jurisdiction, scope, cddId } = claim;
|
|
2243
|
+
return {
|
|
2244
|
+
target: new internal_1.Identity({ did: targetId }, context),
|
|
2245
|
+
issuer: new internal_1.Identity({ did: issuerId }, context),
|
|
2246
|
+
issuedAt: new Date(parseFloat(issuanceDate)),
|
|
2247
|
+
expiry: expiry ? new Date(parseFloat(expiry)) : null,
|
|
2248
|
+
claim: (0, internal_3.createClaim)(type, jurisdiction, scope, cddId, undefined),
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
exports.middlewareV2ClaimToClaimData = middlewareV2ClaimToClaimData;
|
|
2252
|
+
/**
|
|
2253
|
+
* @hidden
|
|
2254
|
+
*/
|
|
2255
|
+
function toIdentityWithClaimsArrayV2(data, context, groupByAttribute) {
|
|
2256
|
+
const groupedData = (0, lodash_1.groupBy)(data, groupByAttribute);
|
|
2257
|
+
return (0, lodash_1.map)(groupedData, (claims, did) => ({
|
|
2258
|
+
identity: new internal_1.Identity({ did }, context),
|
|
2259
|
+
claims: claims.map(claim => middlewareV2ClaimToClaimData(claim, context)),
|
|
2260
|
+
}));
|
|
2261
|
+
}
|
|
2262
|
+
exports.toIdentityWithClaimsArrayV2 = toIdentityWithClaimsArrayV2;
|
|
2138
2263
|
/**
|
|
2139
2264
|
* @hidden
|
|
2140
2265
|
*/
|
|
@@ -2156,6 +2281,15 @@ function claimTypeToMeshClaimType(claimType, context) {
|
|
|
2156
2281
|
return context.createType('PolymeshPrimitivesIdentityClaimClaimType', data);
|
|
2157
2282
|
}
|
|
2158
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;
|
|
2159
2293
|
/**
|
|
2160
2294
|
* @hidden
|
|
2161
2295
|
*/
|
|
@@ -2163,14 +2297,54 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2163
2297
|
const { type, value } = restriction;
|
|
2164
2298
|
let restrictionType;
|
|
2165
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
|
+
};
|
|
2166
2311
|
if (type === types_2.TransferRestrictionType.Count) {
|
|
2167
2312
|
restrictionType = 'MaxInvestorCount';
|
|
2168
2313
|
restrictionValue = bigNumberToU64(value, context);
|
|
2169
2314
|
}
|
|
2170
|
-
else {
|
|
2315
|
+
else if (type === types_2.TransferRestrictionType.Percentage) {
|
|
2171
2316
|
restrictionType = 'MaxInvestorOwnership';
|
|
2172
2317
|
restrictionValue = percentageToPermill(value, context);
|
|
2173
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
|
+
}
|
|
2174
2348
|
return context.createType('PolymeshPrimitivesTransferComplianceTransferCondition', {
|
|
2175
2349
|
[restrictionType]: restrictionValue,
|
|
2176
2350
|
});
|
|
@@ -2180,15 +2354,13 @@ exports.transferRestrictionToPolymeshTransferCondition = transferRestrictionToPo
|
|
|
2180
2354
|
* @hidden
|
|
2181
2355
|
*/
|
|
2182
2356
|
function scopeIdsToBtreeSetIdentityId(scopeIds, context) {
|
|
2183
|
-
|
|
2184
|
-
const sortedScopes = [...scopeIds].sort();
|
|
2185
|
-
return context.createType('BTreeSetIdentityId', sortedScopes);
|
|
2357
|
+
return context.createType('BTreeSet<PolymeshPrimitivesIdentityId>', scopeIds);
|
|
2186
2358
|
}
|
|
2187
2359
|
exports.scopeIdsToBtreeSetIdentityId = scopeIdsToBtreeSetIdentityId;
|
|
2188
2360
|
/**
|
|
2189
2361
|
* @hidden
|
|
2190
2362
|
*/
|
|
2191
|
-
function transferConditionToTransferRestriction(transferCondition) {
|
|
2363
|
+
function transferConditionToTransferRestriction(transferCondition, context) {
|
|
2192
2364
|
if (transferCondition.isMaxInvestorCount) {
|
|
2193
2365
|
return {
|
|
2194
2366
|
type: types_2.TransferRestrictionType.Count,
|
|
@@ -2201,6 +2373,18 @@ function transferConditionToTransferRestriction(transferCondition) {
|
|
|
2201
2373
|
value: permillToBigNumber(transferCondition.asMaxInvestorOwnership),
|
|
2202
2374
|
};
|
|
2203
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
|
+
}
|
|
2204
2388
|
else {
|
|
2205
2389
|
throw new internal_1.PolymeshError({
|
|
2206
2390
|
code: types_2.ErrorCode.FatalError,
|
|
@@ -2247,7 +2431,7 @@ function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
|
2247
2431
|
}
|
|
2248
2432
|
const restrictions = transferConditionResult.map(({ condition, result: tmResult }) => {
|
|
2249
2433
|
return {
|
|
2250
|
-
restriction: transferConditionToTransferRestriction(condition),
|
|
2434
|
+
restriction: transferConditionToTransferRestriction(condition, context),
|
|
2251
2435
|
result: boolToBoolean(tmResult),
|
|
2252
2436
|
};
|
|
2253
2437
|
});
|
|
@@ -2335,6 +2519,17 @@ function middlewarePortfolioToPortfolio(portfolio, context) {
|
|
|
2335
2519
|
return new internal_1.NumberedPortfolio({ did, id: new bignumber_js_1.default(kind) }, context);
|
|
2336
2520
|
}
|
|
2337
2521
|
exports.middlewarePortfolioToPortfolio = middlewarePortfolioToPortfolio;
|
|
2522
|
+
/**
|
|
2523
|
+
* @hidden
|
|
2524
|
+
*/
|
|
2525
|
+
function middlewareV2PortfolioToPortfolio(portfolio, context) {
|
|
2526
|
+
const { identityId: did, number } = portfolio;
|
|
2527
|
+
if (number) {
|
|
2528
|
+
return new internal_1.NumberedPortfolio({ did, id: new bignumber_js_1.default(number) }, context);
|
|
2529
|
+
}
|
|
2530
|
+
return new internal_1.DefaultPortfolio({ did }, context);
|
|
2531
|
+
}
|
|
2532
|
+
exports.middlewareV2PortfolioToPortfolio = middlewareV2PortfolioToPortfolio;
|
|
2338
2533
|
/**
|
|
2339
2534
|
* @hidden
|
|
2340
2535
|
*/
|
|
@@ -2691,30 +2886,79 @@ exports.corporateActionParamsToMeshCorporateActionArgs = corporateActionParamsTo
|
|
|
2691
2886
|
/**
|
|
2692
2887
|
* @hidden
|
|
2693
2888
|
*/
|
|
2694
|
-
function statisticsOpTypeToStatType(
|
|
2695
|
-
|
|
2889
|
+
function statisticsOpTypeToStatType(args, context) {
|
|
2890
|
+
const { op, claimIssuer } = args;
|
|
2891
|
+
return context.createType('PolymeshPrimitivesStatisticsStatType', { op, claimIssuer });
|
|
2696
2892
|
}
|
|
2697
2893
|
exports.statisticsOpTypeToStatType = statisticsOpTypeToStatType;
|
|
2698
2894
|
/**
|
|
2699
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.
|
|
2700
2900
|
*/
|
|
2701
|
-
function
|
|
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;
|
|
2918
|
+
/**
|
|
2919
|
+
* @hidden
|
|
2920
|
+
*/
|
|
2921
|
+
function statisticStatTypesToBtreeStatType(stats, context) {
|
|
2922
|
+
const sortedStats = sortStatsByClaimType(stats);
|
|
2923
|
+
return context.createType('BTreeSet<PolymeshPrimitivesStatisticsStatType>', sortedStats);
|
|
2924
|
+
}
|
|
2925
|
+
exports.statisticStatTypesToBtreeStatType = statisticStatTypesToBtreeStatType;
|
|
2926
|
+
/**
|
|
2927
|
+
* @hidden
|
|
2928
|
+
*/
|
|
2929
|
+
function transferConditionsToBtreeTransferConditions(conditions, context) {
|
|
2930
|
+
return context.createType('BTreeSet<PolymeshPrimitivesTransferComplianceTransferCondition>', conditions);
|
|
2931
|
+
}
|
|
2932
|
+
exports.transferConditionsToBtreeTransferConditions = transferConditionsToBtreeTransferConditions;
|
|
2933
|
+
/**
|
|
2934
|
+
* @hidden
|
|
2935
|
+
*/
|
|
2936
|
+
function keyAndValueToStatUpdate(key2, value, context) {
|
|
2702
2937
|
return context.createType('PolymeshPrimitivesStatisticsStatUpdate', { key2, value });
|
|
2703
2938
|
}
|
|
2704
|
-
exports.
|
|
2939
|
+
exports.keyAndValueToStatUpdate = keyAndValueToStatUpdate;
|
|
2705
2940
|
/**
|
|
2706
2941
|
* @hidden
|
|
2707
2942
|
*/
|
|
2708
2943
|
function statUpdatesToBtreeStatUpdate(statUpdates, context) {
|
|
2709
|
-
|
|
2710
|
-
return context.createType('BTreeSetStatUpdate', sorted);
|
|
2944
|
+
return context.createType('BTreeSet<PolymeshPrimitivesStatisticsStatUpdate>', statUpdates);
|
|
2711
2945
|
}
|
|
2712
2946
|
exports.statUpdatesToBtreeStatUpdate = statUpdatesToBtreeStatUpdate;
|
|
2713
2947
|
/**
|
|
2714
2948
|
* @hidden
|
|
2715
2949
|
*/
|
|
2716
2950
|
function meshStatToStatisticsOpType(rawStat) {
|
|
2717
|
-
|
|
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
|
+
}
|
|
2718
2962
|
}
|
|
2719
2963
|
exports.meshStatToStatisticsOpType = meshStatToStatisticsOpType;
|
|
2720
2964
|
/**
|
|
@@ -2725,20 +2969,100 @@ function statisticsOpTypeToStatOpType(type, context) {
|
|
|
2725
2969
|
}
|
|
2726
2970
|
exports.statisticsOpTypeToStatOpType = statisticsOpTypeToStatOpType;
|
|
2727
2971
|
/**
|
|
2728
|
-
* For now this is hard coded to return a NoClaimStat type. Once Claim scopes are added this should be extended
|
|
2729
2972
|
* @hidden
|
|
2730
2973
|
*/
|
|
2731
|
-
function
|
|
2732
|
-
|
|
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
|
+
}
|
|
2733
3006
|
}
|
|
2734
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;
|
|
2735
3060
|
/**
|
|
2736
3061
|
* @hidden
|
|
2737
3062
|
*/
|
|
2738
3063
|
function complianceConditionsToBtreeSet(conditions, context) {
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
return context.createType('BTreeSetTransferCondition', sorted);
|
|
3064
|
+
const sortedConditions = sortTransferRestrictionByClaimValue(conditions);
|
|
3065
|
+
return context.createType('BTreeSet<PolymeshPrimitivesTransferComplianceTransferCondition> ', sortedConditions);
|
|
2742
3066
|
}
|
|
2743
3067
|
exports.complianceConditionsToBtreeSet = complianceConditionsToBtreeSet;
|
|
2744
3068
|
/**
|
|
@@ -2748,4 +3072,60 @@ function toExemptKey(tickerKey, op) {
|
|
|
2748
3072
|
return { asset: tickerKey, op };
|
|
2749
3073
|
}
|
|
2750
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;
|
|
2751
3131
|
//# sourceMappingURL=conversion.js.map
|