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