@polymeshassociation/polymesh-sdk 15.0.0-beta.3 → 15.0.0-beta.6
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 +2 -2
- package/api/entities/Account.d.ts.map +1 -1
- package/api/entities/Account.js +6 -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 +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/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/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/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/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/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 +5 -2
- package/internal.d.ts.map +1 -1
- package/internal.js +5 -1
- package/internal.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.0-beta.6.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 +9 -2
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js +2 -0
- package/types/internal.js.map +1 -1
- package/utils/constants.d.ts +2 -2
- package/utils/constants.js +2 -2
- package/utils/conversion.d.ts +66 -10
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +323 -19
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +53 -5
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +222 -6
- package/utils/internal.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-15.0.0-beta.3.tgz +0 -0
package/utils/conversion.js
CHANGED
|
@@ -17,10 +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.
|
|
23
|
-
exports.toExemptKey = void 0;
|
|
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;
|
|
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"));
|
|
@@ -295,6 +295,58 @@ function permillToBigNumber(value) {
|
|
|
295
295
|
return new bignumber_js_1.default(value.toString()).shiftedBy(-4); // (value : 10^6) * 100
|
|
296
296
|
}
|
|
297
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;
|
|
298
350
|
/**
|
|
299
351
|
* @hidden
|
|
300
352
|
*/
|
|
@@ -1015,7 +1067,7 @@ function authorizationDataToAuthorization(auth, context) {
|
|
|
1015
1067
|
}
|
|
1016
1068
|
throw new internal_1.PolymeshError({
|
|
1017
1069
|
code: types_2.ErrorCode.UnexpectedError,
|
|
1018
|
-
message: 'Unsupported Authorization Type. Please contact the
|
|
1070
|
+
message: 'Unsupported Authorization Type. Please contact the Polymesh team',
|
|
1019
1071
|
data: {
|
|
1020
1072
|
auth: JSON.stringify(auth, null, 2),
|
|
1021
1073
|
},
|
|
@@ -1110,7 +1162,7 @@ function u8ToTransferStatus(status) {
|
|
|
1110
1162
|
default: {
|
|
1111
1163
|
throw new internal_1.PolymeshError({
|
|
1112
1164
|
code: types_2.ErrorCode.UnexpectedError,
|
|
1113
|
-
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`,
|
|
1114
1166
|
});
|
|
1115
1167
|
}
|
|
1116
1168
|
}
|
|
@@ -1719,6 +1771,23 @@ function meshClaimToClaim(claim) {
|
|
|
1719
1771
|
};
|
|
1720
1772
|
}
|
|
1721
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;
|
|
1722
1791
|
/**
|
|
1723
1792
|
* @hidden
|
|
1724
1793
|
*/
|
|
@@ -2212,6 +2281,15 @@ function claimTypeToMeshClaimType(claimType, context) {
|
|
|
2212
2281
|
return context.createType('PolymeshPrimitivesIdentityClaimClaimType', data);
|
|
2213
2282
|
}
|
|
2214
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;
|
|
2215
2293
|
/**
|
|
2216
2294
|
* @hidden
|
|
2217
2295
|
*/
|
|
@@ -2219,14 +2297,54 @@ function transferRestrictionToPolymeshTransferCondition(restriction, context) {
|
|
|
2219
2297
|
const { type, value } = restriction;
|
|
2220
2298
|
let restrictionType;
|
|
2221
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
|
+
};
|
|
2222
2311
|
if (type === types_2.TransferRestrictionType.Count) {
|
|
2223
2312
|
restrictionType = 'MaxInvestorCount';
|
|
2224
2313
|
restrictionValue = bigNumberToU64(value, context);
|
|
2225
2314
|
}
|
|
2226
|
-
else {
|
|
2315
|
+
else if (type === types_2.TransferRestrictionType.Percentage) {
|
|
2227
2316
|
restrictionType = 'MaxInvestorOwnership';
|
|
2228
2317
|
restrictionValue = percentageToPermill(value, context);
|
|
2229
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
|
+
}
|
|
2230
2348
|
return context.createType('PolymeshPrimitivesTransferComplianceTransferCondition', {
|
|
2231
2349
|
[restrictionType]: restrictionValue,
|
|
2232
2350
|
});
|
|
@@ -2242,7 +2360,7 @@ exports.scopeIdsToBtreeSetIdentityId = scopeIdsToBtreeSetIdentityId;
|
|
|
2242
2360
|
/**
|
|
2243
2361
|
* @hidden
|
|
2244
2362
|
*/
|
|
2245
|
-
function transferConditionToTransferRestriction(transferCondition) {
|
|
2363
|
+
function transferConditionToTransferRestriction(transferCondition, context) {
|
|
2246
2364
|
if (transferCondition.isMaxInvestorCount) {
|
|
2247
2365
|
return {
|
|
2248
2366
|
type: types_2.TransferRestrictionType.Count,
|
|
@@ -2255,6 +2373,18 @@ function transferConditionToTransferRestriction(transferCondition) {
|
|
|
2255
2373
|
value: permillToBigNumber(transferCondition.asMaxInvestorOwnership),
|
|
2256
2374
|
};
|
|
2257
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
|
+
}
|
|
2258
2388
|
else {
|
|
2259
2389
|
throw new internal_1.PolymeshError({
|
|
2260
2390
|
code: types_2.ErrorCode.FatalError,
|
|
@@ -2301,7 +2431,7 @@ function granularCanTransferResultToTransferBreakdown(result, context) {
|
|
|
2301
2431
|
}
|
|
2302
2432
|
const restrictions = transferConditionResult.map(({ condition, result: tmResult }) => {
|
|
2303
2433
|
return {
|
|
2304
|
-
restriction: transferConditionToTransferRestriction(condition),
|
|
2434
|
+
restriction: transferConditionToTransferRestriction(condition, context),
|
|
2305
2435
|
result: boolToBoolean(tmResult),
|
|
2306
2436
|
};
|
|
2307
2437
|
});
|
|
@@ -2756,15 +2886,41 @@ exports.corporateActionParamsToMeshCorporateActionArgs = corporateActionParamsTo
|
|
|
2756
2886
|
/**
|
|
2757
2887
|
* @hidden
|
|
2758
2888
|
*/
|
|
2759
|
-
function statisticsOpTypeToStatType(
|
|
2760
|
-
|
|
2889
|
+
function statisticsOpTypeToStatType(args, context) {
|
|
2890
|
+
const { op, claimIssuer } = args;
|
|
2891
|
+
return context.createType('PolymeshPrimitivesStatisticsStatType', { op, claimIssuer });
|
|
2761
2892
|
}
|
|
2762
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;
|
|
2763
2918
|
/**
|
|
2764
2919
|
* @hidden
|
|
2765
2920
|
*/
|
|
2766
2921
|
function statisticStatTypesToBtreeStatType(stats, context) {
|
|
2767
|
-
|
|
2922
|
+
const sortedStats = sortStatsByClaimType(stats);
|
|
2923
|
+
return context.createType('BTreeSet<PolymeshPrimitivesStatisticsStatType>', sortedStats);
|
|
2768
2924
|
}
|
|
2769
2925
|
exports.statisticStatTypesToBtreeStatType = statisticStatTypesToBtreeStatType;
|
|
2770
2926
|
/**
|
|
@@ -2777,10 +2933,10 @@ exports.transferConditionsToBtreeTransferConditions = transferConditionsToBtreeT
|
|
|
2777
2933
|
/**
|
|
2778
2934
|
* @hidden
|
|
2779
2935
|
*/
|
|
2780
|
-
function
|
|
2936
|
+
function keyAndValueToStatUpdate(key2, value, context) {
|
|
2781
2937
|
return context.createType('PolymeshPrimitivesStatisticsStatUpdate', { key2, value });
|
|
2782
2938
|
}
|
|
2783
|
-
exports.
|
|
2939
|
+
exports.keyAndValueToStatUpdate = keyAndValueToStatUpdate;
|
|
2784
2940
|
/**
|
|
2785
2941
|
* @hidden
|
|
2786
2942
|
*/
|
|
@@ -2792,7 +2948,17 @@ exports.statUpdatesToBtreeStatUpdate = statUpdatesToBtreeStatUpdate;
|
|
|
2792
2948
|
* @hidden
|
|
2793
2949
|
*/
|
|
2794
2950
|
function meshStatToStatisticsOpType(rawStat) {
|
|
2795
|
-
|
|
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
|
+
}
|
|
2796
2962
|
}
|
|
2797
2963
|
exports.meshStatToStatisticsOpType = meshStatToStatisticsOpType;
|
|
2798
2964
|
/**
|
|
@@ -2803,18 +2969,100 @@ function statisticsOpTypeToStatOpType(type, context) {
|
|
|
2803
2969
|
}
|
|
2804
2970
|
exports.statisticsOpTypeToStatOpType = statisticsOpTypeToStatOpType;
|
|
2805
2971
|
/**
|
|
2806
|
-
* For now this is hard coded to return a NoClaimStat type. Once Claim scopes are added this should be extended
|
|
2807
2972
|
* @hidden
|
|
2808
2973
|
*/
|
|
2809
|
-
function
|
|
2810
|
-
|
|
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
|
+
}
|
|
2811
3006
|
}
|
|
2812
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;
|
|
2813
3060
|
/**
|
|
2814
3061
|
* @hidden
|
|
2815
3062
|
*/
|
|
2816
3063
|
function complianceConditionsToBtreeSet(conditions, context) {
|
|
2817
|
-
|
|
3064
|
+
const sortedConditions = sortTransferRestrictionByClaimValue(conditions);
|
|
3065
|
+
return context.createType('BTreeSet<PolymeshPrimitivesTransferComplianceTransferCondition> ', sortedConditions);
|
|
2818
3066
|
}
|
|
2819
3067
|
exports.complianceConditionsToBtreeSet = complianceConditionsToBtreeSet;
|
|
2820
3068
|
/**
|
|
@@ -2824,4 +3072,60 @@ function toExemptKey(tickerKey, op) {
|
|
|
2824
3072
|
return { asset: tickerKey, op };
|
|
2825
3073
|
}
|
|
2826
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;
|
|
2827
3131
|
//# sourceMappingURL=conversion.js.map
|