@polymeshassociation/polymesh-sdk 27.8.0-beta.2 → 28.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts +47 -11
- package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts.map +1 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/index.js +214 -21
- package/api/entities/Asset/Fungible/TransferRestrictions/index.js.map +1 -1
- package/api/entities/Asset/types.d.ts +86 -5
- package/api/entities/Asset/types.d.ts.map +1 -1
- package/api/entities/Asset/types.js.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.d.ts +2 -2
- package/api/entities/DefaultTrustedClaimIssuer.d.ts.map +1 -1
- package/api/entities/DefaultTrustedClaimIssuer.js.map +1 -1
- package/api/entities/types.d.ts +11 -9
- package/api/entities/types.d.ts.map +1 -1
- package/api/entities/types.js +6 -1
- package/api/entities/types.js.map +1 -1
- package/api/procedures/setAssetStats.d.ts +22 -0
- package/api/procedures/setAssetStats.d.ts.map +1 -0
- package/api/procedures/setAssetStats.js +87 -0
- package/api/procedures/setAssetStats.js.map +1 -0
- package/api/procedures/setTransferRestrictionExemptions.d.ts +20 -0
- package/api/procedures/setTransferRestrictionExemptions.d.ts.map +1 -0
- package/api/procedures/setTransferRestrictionExemptions.js +102 -0
- package/api/procedures/setTransferRestrictionExemptions.js.map +1 -0
- package/api/procedures/setTransferRestrictions.d.ts +9 -34
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
- package/api/procedures/setTransferRestrictions.js +61 -257
- package/api/procedures/setTransferRestrictions.js.map +1 -1
- package/api/procedures/types.d.ts +40 -48
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js.map +1 -1
- package/internal.d.ts +3 -6
- package/internal.d.ts.map +1 -1
- package/internal.js +7 -11
- package/internal.js.map +1 -1
- package/npm-package/polymeshassociation-polymesh-sdk-28.0.0-beta.2.tgz +0 -0
- package/package.json +1 -1
- package/utils/conversion.d.ts +31 -22
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +181 -164
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +1 -14
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +3 -110
- package/utils/internal.js.map +1 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimCount.d.ts +0 -69
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimCount.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimCount.js +0 -16
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimCount.js.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimPercentage.d.ts +0 -60
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimPercentage.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimPercentage.js +0 -16
- package/api/entities/Asset/Fungible/TransferRestrictions/ClaimPercentage.js.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/Count.d.ts +0 -81
- package/api/entities/Asset/Fungible/TransferRestrictions/Count.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/Count.js +0 -20
- package/api/entities/Asset/Fungible/TransferRestrictions/Count.js.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/Percentage.d.ts +0 -59
- package/api/entities/Asset/Fungible/TransferRestrictions/Percentage.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/Percentage.js +0 -16
- package/api/entities/Asset/Fungible/TransferRestrictions/Percentage.js.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/TransferRestrictionBase.d.ts +0 -62
- package/api/entities/Asset/Fungible/TransferRestrictions/TransferRestrictionBase.d.ts.map +0 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/TransferRestrictionBase.js +0 -189
- package/api/entities/Asset/Fungible/TransferRestrictions/TransferRestrictionBase.js.map +0 -1
- package/api/procedures/addAssetStat.d.ts +0 -16
- package/api/procedures/addAssetStat.d.ts.map +0 -1
- package/api/procedures/addAssetStat.js +0 -87
- package/api/procedures/addAssetStat.js.map +0 -1
- package/api/procedures/addTransferRestriction.d.ts +0 -23
- package/api/procedures/addTransferRestriction.d.ts.map +0 -1
- package/api/procedures/addTransferRestriction.js +0 -122
- package/api/procedures/addTransferRestriction.js.map +0 -1
- package/api/procedures/removeAssetStat.d.ts +0 -16
- package/api/procedures/removeAssetStat.d.ts.map +0 -1
- package/api/procedures/removeAssetStat.js +0 -85
- package/api/procedures/removeAssetStat.js.map +0 -1
- package/npm-package/polymeshassociation-polymesh-sdk-27.8.0-beta.2.tgz +0 -0
|
@@ -8,215 +8,97 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.setTransferRestrictions = exports.
|
|
16
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
17
|
-
const lodash_1 = require("lodash");
|
|
12
|
+
exports.setTransferRestrictions = exports.getAuthorization = exports.prepareSetTransferRestrictions = void 0;
|
|
18
13
|
const internal_1 = require("../../internal");
|
|
19
14
|
const types_1 = require("../../types");
|
|
20
15
|
const conversion_1 = require("../../utils/conversion");
|
|
21
16
|
const internal_2 = require("../../utils/internal");
|
|
22
|
-
const newExemptionRecord = () => ({
|
|
23
|
-
Accredited: [],
|
|
24
|
-
Affiliate: [],
|
|
25
|
-
Jurisdiction: [],
|
|
26
|
-
None: [],
|
|
27
|
-
});
|
|
28
|
-
exports.newExemptionRecord = newExemptionRecord;
|
|
29
|
-
/**
|
|
30
|
-
* @hidden
|
|
31
|
-
* @param toInsertId - Identity to insert into the exemption records
|
|
32
|
-
* @param exemptionRecords - records that will be mutated if the Identity should be added
|
|
33
|
-
* @param claimType - type of Claim the Identity is exempt from
|
|
34
|
-
* @param filterSet - set of Identities that should not be added into exemption records if given
|
|
35
|
-
*/
|
|
36
|
-
const addExemptionIfNotPresent = (toInsertId, exemptionRecords, claimType, filterSet = []) => {
|
|
37
|
-
const found = filterSet.some(currentId => currentId.did === toInsertId.did);
|
|
38
|
-
if (!found) {
|
|
39
|
-
exemptionRecords[claimType].push(toInsertId);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
exports.addExemptionIfNotPresent = addExemptionIfNotPresent;
|
|
43
17
|
/**
|
|
44
18
|
* @hidden
|
|
45
19
|
* Checks if the input restrictions are valid
|
|
46
20
|
*/
|
|
47
|
-
function assertInputValid(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const seenClaimTypes = new Set();
|
|
59
|
-
inputRestrictions.forEach(restriction => {
|
|
60
|
-
var _a;
|
|
61
|
-
const { claim } = restriction;
|
|
62
|
-
if (claim.type === types_1.ClaimType.Jurisdiction) {
|
|
63
|
-
// cannot add two claims with same country code restrictions will result in internal error
|
|
64
|
-
if (seenJurisdictions.has(claim.countryCode || 'none')) {
|
|
65
|
-
throw new internal_1.PolymeshError({
|
|
66
|
-
code: types_1.ErrorCode.ValidationError,
|
|
67
|
-
message: 'Duplicate Jurisdiction CountryCode found in input',
|
|
68
|
-
data: { countryCode: claim.countryCode },
|
|
69
|
-
});
|
|
21
|
+
function assertInputValid(input) {
|
|
22
|
+
input.restrictions.forEach(restriction => {
|
|
23
|
+
const type = restriction.type;
|
|
24
|
+
if (type === types_1.TransferRestrictionType.ClaimCount) {
|
|
25
|
+
const seenJurisdictions = new Set();
|
|
26
|
+
const seenClaimTypes = new Set();
|
|
27
|
+
input.restrictions.forEach(rest => {
|
|
28
|
+
var _a;
|
|
29
|
+
const { claim } = rest;
|
|
30
|
+
if (!claim) {
|
|
31
|
+
return;
|
|
70
32
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
33
|
+
if (claim.type === types_1.ClaimType.Jurisdiction) {
|
|
34
|
+
// cannot add two claims with same country code restrictions will result in internal error
|
|
35
|
+
if (seenJurisdictions.has(claim.countryCode || 'none')) {
|
|
36
|
+
throw new internal_1.PolymeshError({
|
|
37
|
+
code: types_1.ErrorCode.ValidationError,
|
|
38
|
+
message: 'Duplicate Jurisdiction CountryCode found in input',
|
|
39
|
+
data: { countryCode: claim.countryCode },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
seenJurisdictions.add((_a = claim.countryCode) !== null && _a !== void 0 ? _a : 'none');
|
|
81
43
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const toSetExemptions = (0, exports.newExemptionRecord)();
|
|
95
|
-
const toRemoveExemptions = (0, exports.newExemptionRecord)();
|
|
96
|
-
let needDifferentConditions = inputRestrictions.length !== currentRestrictions.length;
|
|
97
|
-
const conditions = [];
|
|
98
|
-
const inputExemptions = (0, exports.newExemptionRecord)();
|
|
99
|
-
// for each restriction check if we need to make a condition and track all exemptions
|
|
100
|
-
inputRestrictions.forEach(restriction => {
|
|
101
|
-
var _a;
|
|
102
|
-
let value;
|
|
103
|
-
let claimType;
|
|
104
|
-
if ('count' in restriction) {
|
|
105
|
-
value = restriction.count;
|
|
106
|
-
}
|
|
107
|
-
else if ('percentage' in restriction) {
|
|
108
|
-
value = restriction.percentage;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
value = restriction;
|
|
112
|
-
claimType = restriction.claim.type;
|
|
113
|
-
}
|
|
114
|
-
const condition = { type, value };
|
|
115
|
-
const compareConditions = (transferCondition) => (0, internal_2.compareTransferRestrictionToInput)(transferCondition, condition);
|
|
116
|
-
if (!needDifferentConditions) {
|
|
117
|
-
needDifferentConditions = ![...currentRestrictions].find(compareConditions);
|
|
44
|
+
else {
|
|
45
|
+
// cannot add two ClaimType.Accredited or ClaimType.Affiliate restrictions will result in internal error
|
|
46
|
+
if (seenClaimTypes.has(claim.type)) {
|
|
47
|
+
throw new internal_1.PolymeshError({
|
|
48
|
+
code: types_1.ErrorCode.ValidationError,
|
|
49
|
+
message: 'Duplicate ClaimType found in input',
|
|
50
|
+
data: { claimType: claim.type },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
seenClaimTypes.add(claim.type);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
118
56
|
}
|
|
119
|
-
const rawCondition = (0, conversion_1.transferRestrictionToPolymeshTransferCondition)(condition, context);
|
|
120
|
-
conditions.push(rawCondition);
|
|
121
|
-
(_a = restriction.exemptedIdentities) === null || _a === void 0 ? void 0 : _a.forEach(exemption => {
|
|
122
|
-
const key = claimType || 'None';
|
|
123
|
-
const id = (0, internal_2.asIdentity)(exemption, context);
|
|
124
|
-
(0, exports.addExemptionIfNotPresent)(id, inputExemptions, key);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
// calculate exemptions to add — for each input exemption check if it already exists
|
|
128
|
-
(0, lodash_1.forEach)(inputExemptions, (toAddIds, cType) => {
|
|
129
|
-
const key = cType;
|
|
130
|
-
const currentIds = currentExemptions[key];
|
|
131
|
-
toAddIds.forEach(id => {
|
|
132
|
-
(0, exports.addExemptionIfNotPresent)(id, toSetExemptions, key, currentIds);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
// calculate exemptions to remove — for each current exemption check if it was in the input
|
|
136
|
-
(0, lodash_1.forEach)(currentExemptions, (currentIds, cType) => {
|
|
137
|
-
const key = cType;
|
|
138
|
-
const given = inputExemptions[key];
|
|
139
|
-
currentIds.forEach(id => {
|
|
140
|
-
(0, exports.addExemptionIfNotPresent)(id, toRemoveExemptions, key, given);
|
|
141
|
-
});
|
|
142
57
|
});
|
|
143
|
-
const sizeOf = (obj) => (0, lodash_1.flatten)((0, lodash_1.entries)(obj).map(([, identities]) => identities)).length;
|
|
144
|
-
const needDifferentExemptions = sizeOf(toSetExemptions) > 0 || sizeOf(toRemoveExemptions) > 0;
|
|
145
|
-
if (!needDifferentConditions && !needDifferentExemptions) {
|
|
146
|
-
throw new internal_1.PolymeshError({
|
|
147
|
-
code: types_1.ErrorCode.NoDataChange,
|
|
148
|
-
message: inputRestrictions.length
|
|
149
|
-
? 'The restrictions and exemptions are already in place'
|
|
150
|
-
: 'No restrictions to remove',
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return { conditions, toSetExemptions, toRemoveExemptions };
|
|
154
58
|
}
|
|
155
59
|
/**
|
|
156
60
|
* @hidden
|
|
157
61
|
*/
|
|
158
62
|
function prepareSetTransferRestrictions(args) {
|
|
159
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
const { context: { polymeshApi: { tx: { statistics },
|
|
161
|
-
const { restrictions
|
|
64
|
+
const { context: { polymeshApi: { query, tx: { statistics }, }, }, context, } = this;
|
|
65
|
+
const { restrictions, asset } = args;
|
|
162
66
|
const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
|
|
163
|
-
assertInputValid(
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
67
|
+
assertInputValid(args);
|
|
68
|
+
const currentStats = yield query.statistics.activeAssetStats(rawAssetId);
|
|
69
|
+
const conditions = restrictions.map(restriction => {
|
|
70
|
+
let value;
|
|
71
|
+
if ('count' in restriction) {
|
|
72
|
+
value = restriction.count;
|
|
73
|
+
}
|
|
74
|
+
else if ('percentage' in restriction) {
|
|
75
|
+
value = restriction.percentage;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
value = restriction;
|
|
79
|
+
}
|
|
80
|
+
const condition = { type: restriction.type, value };
|
|
81
|
+
const neededStat = (0, internal_2.neededStatTypeForRestrictionInput)(restriction, context);
|
|
82
|
+
(0, internal_2.assertStatIsSet)(currentStats, neededStat);
|
|
83
|
+
return (0, conversion_1.transferRestrictionToPolymeshTransferCondition)(condition, context);
|
|
84
|
+
});
|
|
85
|
+
const rawConditions = (0, conversion_1.complianceConditionsToBtreeSet)(conditions, context);
|
|
86
|
+
return {
|
|
179
87
|
transaction: statistics.setAssetTransferCompliance,
|
|
180
|
-
args: [
|
|
181
|
-
|
|
182
|
-
(0, conversion_1.complianceConditionsToBtreeSet)([...filteredRestrictions, ...conditions], context),
|
|
183
|
-
],
|
|
184
|
-
}));
|
|
185
|
-
const pushExemptions = (exemptions, exempt) => {
|
|
186
|
-
(0, lodash_1.forEach)(exemptions, (exempted, claimType) => {
|
|
187
|
-
if (exempted.length === 0) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const rawClaimType = claimType === 'None' ? undefined : claimType;
|
|
191
|
-
const exemptKey = (0, conversion_1.toExemptKey)(rawAssetId, op, rawClaimType);
|
|
192
|
-
const exemptedBtreeSet = (0, conversion_1.identitiesToBtreeSet)(exempted, context);
|
|
193
|
-
const rawExempt = (0, conversion_1.booleanToBool)(exempt, context);
|
|
194
|
-
transactions.push((0, internal_2.checkTxType)({
|
|
195
|
-
transaction: statistics.setEntitiesExempt,
|
|
196
|
-
feeMultiplier: new bignumber_js_1.default(exemptedBtreeSet.size),
|
|
197
|
-
args: [rawExempt, exemptKey, exemptedBtreeSet],
|
|
198
|
-
}));
|
|
199
|
-
});
|
|
88
|
+
args: [rawAssetId, rawConditions],
|
|
89
|
+
resolver: undefined,
|
|
200
90
|
};
|
|
201
|
-
pushExemptions(toSetExemptions, true);
|
|
202
|
-
pushExemptions(toRemoveExemptions, false);
|
|
203
|
-
return { transactions, resolver: finalCount };
|
|
204
91
|
});
|
|
205
92
|
}
|
|
206
93
|
exports.prepareSetTransferRestrictions = prepareSetTransferRestrictions;
|
|
207
94
|
/**
|
|
208
95
|
* @hidden
|
|
209
96
|
*/
|
|
210
|
-
function getAuthorization({ asset
|
|
211
|
-
const transactions = [types_1.TxTags.statistics.SetAssetTransferCompliance];
|
|
212
|
-
const needExemptionsPermission = restrictions.some(r => { var _a; return (_a = r.exemptedIdentities) === null || _a === void 0 ? void 0 : _a.length; });
|
|
213
|
-
if (needExemptionsPermission) {
|
|
214
|
-
transactions.push(types_1.TxTags.statistics.SetEntitiesExempt);
|
|
215
|
-
}
|
|
97
|
+
function getAuthorization({ asset }) {
|
|
216
98
|
return {
|
|
217
99
|
permissions: {
|
|
218
100
|
assets: [asset],
|
|
219
|
-
transactions,
|
|
101
|
+
transactions: [types_1.TxTags.statistics.SetAssetTransferCompliance],
|
|
220
102
|
portfolios: [],
|
|
221
103
|
},
|
|
222
104
|
};
|
|
@@ -225,84 +107,6 @@ exports.getAuthorization = getAuthorization;
|
|
|
225
107
|
/**
|
|
226
108
|
* @hidden
|
|
227
109
|
*/
|
|
228
|
-
|
|
229
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
const { context, context: { polymeshApi: { query: { statistics }, }, }, } = this;
|
|
231
|
-
const { asset, type } = args;
|
|
232
|
-
const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
|
|
233
|
-
const [currentStats, { requirements: currentRestrictions }] = yield (0, internal_2.requestMulti)(context, [
|
|
234
|
-
[statistics.activeAssetStats, rawAssetId],
|
|
235
|
-
[statistics.assetTransferCompliances, rawAssetId],
|
|
236
|
-
]);
|
|
237
|
-
args.restrictions.forEach(restriction => {
|
|
238
|
-
let claimIssuer;
|
|
239
|
-
if (type === types_1.TransferRestrictionType.ClaimCount ||
|
|
240
|
-
type === types_1.TransferRestrictionType.ClaimPercentage) {
|
|
241
|
-
const { claim: { type: claimType }, issuer, } = restriction;
|
|
242
|
-
claimIssuer = { claimType, issuer };
|
|
243
|
-
}
|
|
244
|
-
const neededStat = (0, internal_2.neededStatTypeForRestrictionInput)({ type, claimIssuer }, context);
|
|
245
|
-
(0, internal_2.assertStatIsSet)(currentStats, neededStat);
|
|
246
|
-
});
|
|
247
|
-
const filteredRestrictions = [...currentRestrictions].filter(requirement => {
|
|
248
|
-
if (type === types_1.TransferRestrictionType.Count) {
|
|
249
|
-
return !requirement.isMaxInvestorCount;
|
|
250
|
-
}
|
|
251
|
-
else if (type === types_1.TransferRestrictionType.Percentage) {
|
|
252
|
-
return !requirement.isMaxInvestorOwnership;
|
|
253
|
-
}
|
|
254
|
-
else if (type === types_1.TransferRestrictionType.ClaimCount) {
|
|
255
|
-
return !requirement.isClaimCount;
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
return !requirement.isClaimOwnership;
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
const currentTypeRestrictions = [...currentRestrictions].filter(requirement => {
|
|
262
|
-
if (type === types_1.TransferRestrictionType.Count) {
|
|
263
|
-
return requirement.isMaxInvestorCount;
|
|
264
|
-
}
|
|
265
|
-
else if (type === types_1.TransferRestrictionType.Percentage) {
|
|
266
|
-
return requirement.isMaxInvestorOwnership;
|
|
267
|
-
}
|
|
268
|
-
else if (type === types_1.TransferRestrictionType.ClaimCount) {
|
|
269
|
-
return requirement.isClaimCount;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
return requirement.isClaimOwnership;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
const op = (0, conversion_1.transferRestrictionTypeToStatOpType)(type, context);
|
|
276
|
-
const claimTypes = type === types_1.TransferRestrictionType.Count || type === types_1.TransferRestrictionType.Percentage
|
|
277
|
-
? [undefined]
|
|
278
|
-
: [types_1.ClaimType.Accredited, types_1.ClaimType.Affiliate, types_1.ClaimType.Jurisdiction];
|
|
279
|
-
const exemptionFetchers = [];
|
|
280
|
-
claimTypes.forEach(claimType => {
|
|
281
|
-
exemptionFetchers.push(statistics.transferConditionExemptEntities.entries((0, conversion_1.toExemptKey)(rawAssetId, op, claimType)));
|
|
282
|
-
});
|
|
283
|
-
const rawCurrentExemptions = (0, lodash_1.flatten)(yield Promise.all(exemptionFetchers));
|
|
284
|
-
const currentExemptions = (0, exports.newExemptionRecord)();
|
|
285
|
-
rawCurrentExemptions.forEach(([{ args: [{ claimType: rawClaimType }, rawDid], },]) => {
|
|
286
|
-
const did = (0, conversion_1.identityIdToString)(rawDid);
|
|
287
|
-
let claimType = 'None';
|
|
288
|
-
if (rawClaimType.isSome) {
|
|
289
|
-
claimType = (0, conversion_1.meshClaimTypeToClaimType)(rawClaimType.unwrap());
|
|
290
|
-
}
|
|
291
|
-
const identity = new internal_1.Identity({ did }, context);
|
|
292
|
-
(0, exports.addExemptionIfNotPresent)(identity, currentExemptions, claimType);
|
|
293
|
-
});
|
|
294
|
-
return {
|
|
295
|
-
occupiedSlots: new bignumber_js_1.default(filteredRestrictions.length),
|
|
296
|
-
currentTypeRestrictions,
|
|
297
|
-
filteredRestrictions,
|
|
298
|
-
currentExemptions,
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
exports.prepareStorage = prepareStorage;
|
|
303
|
-
/**
|
|
304
|
-
* @hidden
|
|
305
|
-
*/
|
|
306
|
-
const setTransferRestrictions = () => new internal_1.Procedure(prepareSetTransferRestrictions, getAuthorization, prepareStorage);
|
|
110
|
+
const setTransferRestrictions = () => new internal_1.Procedure(prepareSetTransferRestrictions, getAuthorization);
|
|
307
111
|
exports.setTransferRestrictions = setTransferRestrictions;
|
|
308
112
|
//# sourceMappingURL=setTransferRestrictions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTransferRestrictions.js","sourceRoot":"","sources":["../../../src/api/procedures/setTransferRestrictions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setTransferRestrictions.js","sourceRoot":"","sources":["../../../src/api/procedures/setTransferRestrictions.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { BallotMeta, BallotVote } from "../entities/CorporateBallot/types";
|
|
3
3
|
import { Account, AuthorizationRequest, CheckpointSchedule, ChildIdentity, CorporateActionBase, CorporateBallot, CustomPermissionGroup, DefaultPortfolio, FungibleAsset, Identity, KnownPermissionGroup, MultiSig, Nft, NumberedPortfolio, PolymeshTransaction, PolymeshTransactionBatch, Venue } from "../../internal";
|
|
4
|
-
import {
|
|
4
|
+
import { AddCountStatInput, AssetDocument, CheckPermissionsResult, CheckRolesResult, ClaimCountStatInput, ClaimTarget, ClaimType, CorporateActionKind, CorporateActionTargets, InputCaCheckpoint, InputCondition, InputStatClaim, InputStatType, InputTargets, InputTaxWithholding, InputTrustedClaimIssuer, KnownAssetType, KnownNftType, MetadataSpec, MetadataType, MetadataValueDetails, NftCollection, OfferingTier, PermissionedAccount, PermissionsLike, PortfolioLike, PortfolioMovement, Requirement, Scope, SecurityIdentifier, Signer, SignerType, StatClaimIssuer, StatType, TaxWithholding, TransactionPermissions, TxTag, VenueType } from "../../types";
|
|
5
5
|
import { Modify } from "../../types/utils";
|
|
6
6
|
export interface ProcedureAuthorizationStatus {
|
|
7
7
|
/**
|
|
@@ -268,12 +268,7 @@ export declare enum TxGroup {
|
|
|
268
268
|
*/
|
|
269
269
|
StoManagement = "StoManagement"
|
|
270
270
|
}
|
|
271
|
-
export declare type
|
|
272
|
-
export declare type SetRestrictionsParams<T> = Omit<T extends TransferRestrictionType.Count ? SetCountTransferRestrictionsParams : T extends TransferRestrictionType.Percentage ? SetPercentageTransferRestrictionsParams : T extends TransferRestrictionType.ClaimCount ? SetClaimCountTransferRestrictionsParams : SetClaimPercentageTransferRestrictionsParams, 'type'>;
|
|
273
|
-
export declare type GetTransferRestrictionReturnType<T> = ActiveTransferRestrictions<T extends TransferRestrictionType.Count ? CountTransferRestriction : T extends TransferRestrictionType.Percentage ? PercentageTransferRestriction : T extends TransferRestrictionType.ClaimCount ? ClaimCountTransferRestriction : ClaimPercentageTransferRestriction>;
|
|
274
|
-
export declare type RemoveAssetStatParams = {
|
|
275
|
-
asset: FungibleAsset;
|
|
276
|
-
} & (RemoveCountStatParams | RemoveBalanceStatParams | RemoveScopedCountParams | RemoveScopedBalanceParams);
|
|
271
|
+
export declare type SetTransferRestrictionParams = CountTransferRestrictionInput | PercentageTransferRestrictionInput | ClaimCountTransferRestrictionInput | ClaimPercentageTransferRestrictionInput;
|
|
277
272
|
export declare type AddCountStatParams = AddCountStatInput & {
|
|
278
273
|
type: StatType.Count;
|
|
279
274
|
};
|
|
@@ -289,19 +284,9 @@ export declare type AddClaimPercentageStatParams = StatClaimIssuer & {
|
|
|
289
284
|
export declare type AddAssetStatParams = {
|
|
290
285
|
asset: FungibleAsset;
|
|
291
286
|
} & (AddCountStatParams | AddPercentageStatParams | AddClaimCountStatParams | AddClaimPercentageStatParams);
|
|
292
|
-
export declare type
|
|
293
|
-
|
|
294
|
-
};
|
|
295
|
-
export declare type RemoveBalanceStatParams = {
|
|
296
|
-
type: StatType.Balance;
|
|
297
|
-
};
|
|
298
|
-
export declare type RemoveScopedCountParams = StatClaimIssuer & {
|
|
299
|
-
type: StatType.ScopedCount;
|
|
287
|
+
export declare type SetTransferRestrictionStatParams = {
|
|
288
|
+
stats: (AddCountStatParams | AddPercentageStatParams | AddClaimCountStatParams | AddClaimPercentageStatParams)[];
|
|
300
289
|
};
|
|
301
|
-
export declare type RemoveScopedBalanceParams = StatClaimIssuer & {
|
|
302
|
-
type: StatType.ScopedBalance;
|
|
303
|
-
};
|
|
304
|
-
export declare type SetAssetStatParams<T> = Omit<T extends TransferRestrictionType.Count ? AddCountStatParams : T extends TransferRestrictionType.Percentage ? AddPercentageStatParams : T extends TransferRestrictionType.ClaimCount ? AddClaimCountStatParams : AddClaimPercentageStatParams, 'type'>;
|
|
305
290
|
export declare enum TransferRestrictionType {
|
|
306
291
|
Count = "Count",
|
|
307
292
|
Percentage = "Percentage",
|
|
@@ -333,51 +318,66 @@ export declare type TransferRestriction = {
|
|
|
333
318
|
type: TransferRestrictionType.ClaimPercentage;
|
|
334
319
|
value: ClaimPercentageRestrictionValue;
|
|
335
320
|
};
|
|
336
|
-
interface
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
*/
|
|
340
|
-
exemptedIdentities?: (Identity | string)[];
|
|
341
|
-
/**
|
|
342
|
-
* (optional) Set to `true` to skip stat is enabled check, useful for batch transactions
|
|
343
|
-
*/
|
|
344
|
-
skipStatIsEnabledCheck?: boolean;
|
|
321
|
+
export interface TransferRestrictionInputCount {
|
|
322
|
+
count: BigNumber;
|
|
323
|
+
type: TransferRestrictionType.Count;
|
|
345
324
|
}
|
|
346
|
-
export interface CountTransferRestrictionInput
|
|
325
|
+
export interface CountTransferRestrictionInput {
|
|
347
326
|
/**
|
|
348
327
|
* limit on the amount of different (unique) investors that can hold the Asset at once
|
|
349
328
|
*/
|
|
350
329
|
count: BigNumber;
|
|
330
|
+
type: TransferRestrictionType.Count;
|
|
351
331
|
}
|
|
352
|
-
export interface PercentageTransferRestrictionInput
|
|
332
|
+
export interface PercentageTransferRestrictionInput {
|
|
353
333
|
/**
|
|
354
334
|
* maximum percentage (0-100) of the total supply of the Asset that can be held by a single investor at once
|
|
355
335
|
*/
|
|
356
336
|
percentage: BigNumber;
|
|
337
|
+
type: TransferRestrictionType.Percentage;
|
|
357
338
|
}
|
|
358
|
-
export interface ClaimCountTransferRestrictionInput
|
|
339
|
+
export interface ClaimCountTransferRestrictionInput {
|
|
359
340
|
min: BigNumber;
|
|
360
341
|
max?: BigNumber;
|
|
361
342
|
issuer: Identity;
|
|
362
343
|
claim: InputStatClaim;
|
|
344
|
+
type: TransferRestrictionType.ClaimCount;
|
|
363
345
|
}
|
|
364
|
-
export interface ClaimPercentageTransferRestrictionInput
|
|
346
|
+
export interface ClaimPercentageTransferRestrictionInput {
|
|
365
347
|
min: BigNumber;
|
|
366
348
|
max: BigNumber;
|
|
367
349
|
issuer: Identity;
|
|
368
350
|
claim: InputStatClaim;
|
|
351
|
+
type: TransferRestrictionType.ClaimPercentage;
|
|
369
352
|
}
|
|
370
|
-
export
|
|
371
|
-
|
|
372
|
-
};
|
|
373
|
-
export declare type AddPercentageTransferRestrictionParams = PercentageTransferRestrictionInput & {
|
|
353
|
+
export interface TransferRestrictionInputPercentage {
|
|
354
|
+
percentage: BigNumber;
|
|
374
355
|
type: TransferRestrictionType.Percentage;
|
|
375
|
-
}
|
|
376
|
-
export
|
|
356
|
+
}
|
|
357
|
+
export interface TransferRestrictionClaimCountInput {
|
|
358
|
+
min: BigNumber;
|
|
359
|
+
max?: BigNumber;
|
|
360
|
+
issuer: Identity;
|
|
361
|
+
claim: InputStatClaim;
|
|
377
362
|
type: TransferRestrictionType.ClaimCount;
|
|
378
|
-
}
|
|
379
|
-
export
|
|
363
|
+
}
|
|
364
|
+
export interface TransferRestrictionInputClaimPercentage {
|
|
365
|
+
min: BigNumber;
|
|
366
|
+
max: BigNumber;
|
|
367
|
+
issuer: Identity;
|
|
368
|
+
claim: InputStatClaim;
|
|
380
369
|
type: TransferRestrictionType.ClaimPercentage;
|
|
370
|
+
}
|
|
371
|
+
export declare type TransferRestrictionParams = {
|
|
372
|
+
restrictions: (TransferRestrictionInputCount | TransferRestrictionInputPercentage | TransferRestrictionClaimCountInput | TransferRestrictionInputClaimPercentage)[];
|
|
373
|
+
};
|
|
374
|
+
export declare type AddCountTransferRestrictionParams = CountTransferRestrictionInput & {
|
|
375
|
+
type: TransferRestrictionType.Count;
|
|
376
|
+
};
|
|
377
|
+
export declare type TransferRestrictionExemptionParams = {
|
|
378
|
+
type: StatType;
|
|
379
|
+
identities: (Identity | string)[];
|
|
380
|
+
claim?: ClaimType;
|
|
381
381
|
};
|
|
382
382
|
export interface SetCountTransferRestrictionsParams {
|
|
383
383
|
/**
|
|
@@ -386,13 +386,6 @@ export interface SetCountTransferRestrictionsParams {
|
|
|
386
386
|
restrictions: CountTransferRestrictionInput[];
|
|
387
387
|
type: TransferRestrictionType.Count;
|
|
388
388
|
}
|
|
389
|
-
export interface SetPercentageTransferRestrictionsParams {
|
|
390
|
-
/**
|
|
391
|
-
* array of Percentage Transfer Restrictions with their corresponding exemptions (if applicable)
|
|
392
|
-
*/
|
|
393
|
-
restrictions: PercentageTransferRestrictionInput[];
|
|
394
|
-
type: TransferRestrictionType.Percentage;
|
|
395
|
-
}
|
|
396
389
|
export interface SetClaimCountTransferRestrictionsParams {
|
|
397
390
|
restrictions: ClaimCountTransferRestrictionInput[];
|
|
398
391
|
type: TransferRestrictionType.ClaimCount;
|
|
@@ -1565,5 +1558,4 @@ export declare type InitiateCorporateActionParams = {
|
|
|
1565
1558
|
*/
|
|
1566
1559
|
defaultTaxWithholding: BigNumber | null;
|
|
1567
1560
|
};
|
|
1568
|
-
export {};
|
|
1569
1561
|
//# sourceMappingURL=types.d.ts.map
|